Skip to content

jkfhto/gltf-pipeline

 
 

Repository files navigation

glTF Pipeline

License Build Status Coverage Status

Content pipeline tools for optimizing glTF assets by Richard Lee and the Cesium team.

Richard Lee和Cesium团队优化glTF文件的内容管道工具

This project is under active development, see the roadmap.

该项目正在积极开发中,请参阅路线图

gltf-pipeline can be used as a command-line tool or Node.js module.

gltf-pipeline可以用作命令行工具或Node.js模块

Instructions 说明

Clone this repo and install Node.js 6.x or later. From the root directory of this repo, run:

克隆此repo并安装Node.js 6.x或更高版本。从此repo的根目录中运行

npm install

Command-Line Example: 命令行示例

node ./bin/gltf-pipeline.js -i ./specs/data/boxTexturedUnoptimized/CesiumTexturedBoxTest.gltf -o output.gltf

Compress textures to the dxt1 and etc1 formats 将纹理压缩为dxt1和etc1格式

node ./bin/gltf-pipeline.js -i ./specs/data/boxTexturedUnoptimized/CesiumTexturedBoxTest.gltf -o output.gltf --texcomp.dxt1.enable --texcomp.dxt1.quality=10 --texcomp.etc1.enable

Command-Line Flags 命令行标志

Flag Description Required
--help, -h Display help 显示帮助 No
--input, -i input=PATH, Read unoptimized glTF from the specified file.
input = PATH,从指定文件读取未优化的glTF
✅ Yes
--output, -o output=PATH, Write optimized glTF to the specified file.
输出= PATH,将优化的glTF输出到指定的文件
No
--binary, -b Write binary glTF file using KHR_binary_glTF extension.
使用KHR_binary_glTF扩展编写一个二进制glTF文件
No, default false
--separate, -s Write separate geometry/animation data files, shader files, and textures instead of embedding them in the glTF asset.
编写独立的几何/动画数据文件,着色器文件和纹理,而不是将它们嵌入到glTF资源中
No, default false
--separateImage, -t Write out separate textures, but embeds geometry/animation data files and shader files in the glTF asset.
纹理独立,但将几何/动画数据文件和着色器文件嵌入到glTF资源中
No, default false
--quantize, -q Quantize the attributes of this glTF asset using the WEB3D_quantized_attributes extension.
使用WEB3D_quantized_attributes扩展来量化此glTF文件的属性
No, default false
--encodeNormals, -n Oct-encode the normals of this glTF asset.
Oct-编码这个glTF文件的法线
No, default false
--compressTextureCoordinates, -c Compress the testure coordinates of this glTF asset.
压缩此glTF文件的纹理坐标
No, default false
--removeNormals, -r Strips off existing normals, allowing them to be regenerated.
剥离现有法线,允许它们再生
No, default false
--smoothNormals, -m If normals are missing, they should be generated with smooth normals.
如果法线缺失,则生成平滑法线
No, default false
--faceNormals, -f If normals are missing, they should be generated using the face normal.
如果法线缺失,则应使用面法线生成法线
No, default false
--cesium Optimize the glTF for Cesium by using the sun as a default light source.
使用太阳作为默认光源为Cesium优化glTF文件
No, default false
--tangentsBitangents If normals and texture coordinates are given, generate tangents and bitangents.
如果有法线和纹理坐标,则生成切线和负切线
No, default false
--stats Print statistics to console for input and output glTF files.
将输入和输出glTF文件的统计信息打印到控制台
No, default false
--kmc.enable Materials should be expressed using the KHR_materials_common extension. If other kmc flags are enabled, this is implicitly true.
如果启用了其他kmc标志,材料应使用KHR_materials_common扩展表示。
No, default false
--kmc.doubleSided Declares whether backface culling should be disabled.
声明是否应禁用背面剔除
No, default false
--kmc.technique The lighting model to use. 要使用的光照模型 No, default PHONG
--ao.enable Bake ambient occlusion (to vertex data by default). If other ao flags are enabled, this is implicitly true. Advanced settings in lib/bakeAmbientOcclusion.js 烘烤环境遮挡(默认情况下为顶点数据)。如果启用了其他ao标志,则这是隐含的。 位于lib / bakeAmbientOcclusion.js中的高级设置 No, default false
--ao.toTexture Bake AO to existing diffuse textures instead of to vertices. Does not modify shaders.
将AO烘焙到现有的漫反射纹理中而不是顶点中。不修改着色器
No, default false
--ao.groundPlane Simulate a groundplane at the lowest point of the model when baking AO.
烘烤AO时,在模型的最低点模拟地平面
No, default false
--ao.ambientShadowContribution Amount of AO to show when blending between shader computed lighting and AO. 1.0 is full AO, 0.5 is a 50/50 blend.
在着色器计算光照和AO之间混合时显示的AO量。 1.0表示完全AO,0.5是50/50混合物
No, default 0.5
--ao.quality Quality to use when baking AO. Valid settings are high, medium, and low.
烘烤AO时使用的质量。有效的设置是高,中,低
No, default low
--texcomp.<format>.enable Whether to compress textures with the given compressed texture format. If other texcomp.<format> flags are enabled, this is implicitly true. Multiple formats may be supplied by repeating this flag. Must be one of the following: pvrtc1, pvrtc2, etc1, etc2, astc, dxt1, dxt3, dxt5, crunch-dxt1, crunch-dxt5. Compressed textures are saved as Cesium and 3D Tiles specific metadata inside image.extras.compressedImage3DTiles. More details about texture compression in glTF here: KhronosGroup/glTF#739 No, unless other texcomp options are set.
--texcomp.<format>.quality The compressed texture quality from 0 to 10.
压缩的纹理质量从0到10
No, default 5
--texcomp.<format>.bitrate The bitrate when using the pvrtc or astc formats. For pvrtc formats this value must be 2.0 or 4.0.
使用pvrtc或astc格式时的比特率。对于pvrtc格式,此值必须为2.0或4.0
No, default 2.0
--texcomp.<format>.blockSize The block size for astc compression. Smaller block sizes result in higher bitrates. This value is ignored if options.bitrate is also set. Must be one of the following: 4x4, 5x4, 5x5, 6x5, 6x6, 8x5, 8x6, 8x8, 10x5, 10x6, 10x8, 10x10, 12x10, 12x12
astc压缩的块大小。较小的块大小会导致较高的比特率。如果options.bitrate也被设置,这个值将被忽略。必须是以下之一
No, default 8x8
--texcomp.<format>.alphaBit Store a single bit for alpha. Only supported for etc2.
存储一个alpha值。只支持etc2
No, default false

Build Instructions 构建说明

Run the tests: 运行测试

npm run test

To run ESLint on the entire codebase, run:

要在整个代码库上运行ESLint,请运行

npm run eslint

To run ESLint automatically when a file is saved, run the following and leave it open in a console window:

要在保存文件时自动运行ESLint,请运行以下命令并将其保留在控制台窗口中打开

npm run eslint-watch

Building for Cesium integration

Some functionality of gltf-pipeline is used by Cesium as a third party library. The necessary files can be generated using:

gltf-pipeline的一些功能被Cesium使用作为第三方库。必要的文件可以使用以下方式生成

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.

这会将部分gltf-pipeline代码输出到dist / cesium文件夹中,重新格式化为AMD风格,以便在浏览器中与RequireJS和Cesium一起使用

Third-party tools 第三方工具

This project bundles several native binaries for texture compression.

该项目捆绑了几个本地二进制文件进行纹理压缩

  • PVRTexTool - Windows, macOS, and Linux binaries are provided by the PowerVR SDK.Windows,macOS和Linux二进制文件由PowerVR SDK提供
  • etc2comp - Windows, macOS, and Linux binaries built from source.从源代码构建Windows,macOS和Linux的二进制文件
  • crunch - Windows binary built from crunch, macOS binary built from BKcore/crunch-osx, Linux binary built from tomerb/linux_fixes.
  • astc-encoder - Windows, macOS, and Linux binaries built from source.

On Linux you may need to install g++ 4.8 as some of the tools link to the libgcc and libstdc++ runtimes.

Run the help command for each tool for a more detailed description of the supported command-line options.

对每个工具运行help命令以获得对受支持命令行选项的更详细描述

Building for other integration 建设其他一体化

Some functionality of gltf-pipeline is used by other projects along with Cesium as a third party library. The necessary files can be generated using:

其他项目使用gltf-pipeline的一些功能以及Cesium作为第三方库。必要的文件可以使用以下方式生成

npm run build-cesium-combine

This will output a portion of the gltf-pipeline code into the dist/cesium-combined folder, reformatted into self-contained file. Currently, only files that have no other local dependencies are allowed.

这会将一部分gltf-pipeline代码输出到dist / cesium组合文件夹中,并重新格式化为自包含文件。目前,只允许没有其他本地依赖项的文件

Running Test Coverage 运行测试覆盖率

Coverage uses nyc. Run:测试覆盖率使用nyc。运行

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.

测试和覆盖涵盖了Node.js模块;它并不包含很小的命令行界面

Generating Documentation 生成文档

To generate the documentation: 要生成文档

npm run jsdoc

The documentation will be placed in the doc folder. 文档将被放置在doc文件夹中

Debugging 调试

  • To debug the tests in Webstorm, open the Gulp tab, right click the test task, and click Debug 'test'.

要在Webstorm中调试测试,请打开Gulp选项卡,右键单击测试任务,然后单击Debug'test'

  • To run a single test, change the test function from it to fit 要运行单例测试,请将测试方法从it 改为 fit.

Deploying to npm 部署到npm

  • Proofread CHANGES.md.

    校对CHANGES.MD。

  • Update the version in package.json to match the latest version in CHANGES.md.

    更新package.json中的版本以匹配CHANGES.md中的最新版本

  • Make sure to run the tests and ensure they pass.

    确保运行测试并确保它们通过

  • If any changes are required, commit and push them to the repository.

    如果需要更改,请提交并将其推送到存储库

  • Create and test the package.

    创建并测试包

## NPM Pack
## Creates tarball. Verify using 7-zip (or your favorite archiver).
## If you find unexpected/unwanted files, add them to .npmignore, and then run npm pack again.
npm pack

## Test the package
## Copy and install the package in a temporary directory
mkdir temp && cp <tarball> temp/
npm install --production <tarball>
node -e "var test = require('gltf-pipeline');" # No output on success

# If module has executables, then test those now.
  • Tag and push the release. 标记并推送发布
    • git tag -a <version> -m "<message>"
    • git push origin <version>
  • Publish 发布
npm publish

Contact @lilleyse if you need access to publish.

Contributions

Pull requests are appreciated! Please use the same Contributor License Agreement (CLA) and Coding Guide used for Cesium.

Attribution

This product includes components of the PowerVR Tools Software from Imagination Technologies Limited. https://community.imgtec.com/developers/powervr/powervr-tools-software-eula/


About

Content pipeline tools for optimizing glTF assets. 🌐 用于优化glTF文件的内容管道工具

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.7%
  • GLSL 0.3%