同步操作将从 李亮/gltf-pipeline 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Content pipeline tools for optimizing glTF assets by Richard Lee and the Cesium team.
Supports common operations including:
gltf-pipeline
can be used as a command-line tool or Node.js module.
Install Node.js if you don't already have it, and then:
npm install -g gltf-pipeline
gltf-pipeline -i model.gltf -o model.glb
gltf-pipeline -i model.gltf -b
gltf-pipeline -i model.glb -o model.gltf
gltf-pipeline -i model.glb -j
gltf-pipeline -i model.gltf -o modelDraco.gltf -d -s
gltf-pipeline -i model.gltf -t
var gltfPipeline = require('gltf-pipeline');
var fsExtra = require('fs-extra');
var gltfToGlb = gltfPipeline.gltfToGlb;
var gltf = fsExtra.readJsonSync('model.gltf');
gltfToGlb(gltf)
.then(function(results) {
fsExtra.writeFileSync('model.glb', results.glb);
}
var gltfPipeline = require('gltf-pipeline');
var fsExtra = require('fs-extra');
var glbToGltf = gltfPipeline.glbToGltf;
var glb = fsExtra.readFileSync('model.glb');
glbToGltf(glb)
.then(function(results) {
fsExtra.writeJsonSync('model.gltf', results.gltf);
}
var gltfPipeline = require('gltf-pipeline');
var fsExtra = require('fs-extra');
var gltf = fsExtra.readJsonSync('model.gltf');
var options = {
dracoOptions: {
compressionLevel: 10
}
}
processGltf(gltf, options)
.then(function(results) {
fsExtra.writeJsonSync('model.gltf', results.gltf);
}
var gltfPipeline = require('gltf-pipeline');
var fsExtra = require('fs-extra');
var gltf = fsExtra.readJsonSync('model.gltf');
var options = {
separateTextures: true
};
processGltf(gltf, options)
.then(function(results) {
fsExtra.writeJsonSync('model.gltf', results.gltf);
// Save separate resources
var separateResources = results.separateResources;
for (var relativePath in separateResources) {
if (separateResources.hasOwnProperty(relativePath)) {
var resource = separateResources[relativePath];
fsExtra.writeFileSync(relativePath, resource));
}
}
}
Flag | Description | Required |
---|---|---|
--help , -h
|
Display help | No |
--input , -i
|
Path to the glTF or glb file. | Yes |
--output , -o
|
Output path of the glTF or glb file. Separate resources will be saved to the same directory. | No |
--binary , -b
|
Convert the input glTF to glb. | No, default false
|
--json , -j
|
Convert the input glb to glTF. | No, default false
|
--separate , -s
|
Write separate buffers, shaders, and textures instead of embedding them in the glTF. | No, default false
|
--separateTextures , -t
|
Write out separate textures only. | No, default false
|
--secure |
Prevent the source model from referencing paths outside of its directory. | No, default false
|
--stats |
Print statistics to console for output glTF file. | No, default false
|
--draco.compressMeshes , -d
|
Compress the meshes using Draco. Adds the KHR_draco_mesh_compression extension. | No, default false
|
--draco.compressionLevel |
Draco compression level [0-10], most is 10, least is 0. A value of 0 will apply sequential encoding and preserve face order. | No, default 7
|
--draco.quantizePositionBits |
Quantization bits for position attribute when using Draco compression. | No, default 14
|
--draco.quantizeNormalBits |
Quantization bits for normal attribute when using Draco compression. | No, default 10
|
--draco.quantizeTexcoordBits |
Quantization bits for texture coordinate attribute when using Draco compression. | No, default 12
|
--draco.quantizeColorBits |
Quantization bits for color attribute when using Draco compression. | No, default 8
|
--draco.quantizeGenericBits |
Quantization bits for skinning attribute (joint indices and joint weights) and custom attributes when using Draco compression. | No, default 12
|
--draco.unifiedQuantization |
Quantize positions of all primitives using the same quantization grid. If not set, quantization is applied separately. | No, default false
|
Run the tests:
npm run test
To run ESLint on the entire codebase, run:
npm run eslint
To run ESLint automatically when a file is saved, run the following and leave it open in a console window:
npm run eslint-watch
Some functionality of gltf-pipeline is used by Cesium as a third party library. The necessary files can be generated using:
npm run build-cesium
This will output a portion of the gltf-pipeline code into the dist/cesium
folder, reformatted into AMD style for use with RequireJS and Cesium in the browser.
Coverage uses nyc. Run:
npm run coverage
For complete coverage details, open coverage/lcov-report/index.html
.
The tests and coverage covers the Node.js module; it does not cover the command-line interface, which is tiny.
To generate the documentation:
npm run jsdoc
The documentation will be placed in the doc
folder.
Pull requests are appreciated! Please use the same Contributor License Agreement (CLA) and Coding Guide used for Cesium.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。