gltf-bundle v0.12.0
gltf-bundle
gltf-bundle is a command line tool and nodejs library that creates glTF files that are optimized for distribution on the web.
Installation
cargo install gltf_unlit_generator
npm install -g gltf-bundleUsage
Usage: gltf-bundle [bundleConfigPath]
Options:
-V, --version output the version number
-o --out <out> Bundle output path (required).
-h, --help output usage information
Examples:
1. Search all subdirectories for *.bundle.config.json files and output bundles
in out dir.
$ gltf-bundle -o ./out
2. Specify a bundle config file and output to the out directory.
$ gltf-bundle ./avatar.bundle.config.json -o ./outExample .bundle.config.json file:
{
"name": "BotDefault",
"version": "0.0.1",
"output": {
"filePath": "bots"
},
"assets": [
{
"name": "BotDefault",
"src": "./BotDefault_Avatar.fbx",
"components": ["./components.json"]
}
]
}The name, version, and assets properties are required.
output.filePath determines the subdirectory to place the bundle and associated files in the dist/ directory. Files with the same name will be overwritten. This can be useful when assets have textures or binary data in common.
The asset.src property can be a .fbx, .gltf, or .glb file. This asset file will have the following build steps applied to it before being placed in the dist/ folder:
- Convert from
.fbxor.glbto.gltf..fbx. Conversions are handled by FBX2glTF. - Generate unlit textures and add the
MOZ_alt_materialextension to any materials in the.gltffile using gltf-unlit-generator. Add component data using gltf-component-data to
gltf.node.extrasusing the suppliedasset.componentsarray. Thecomponentsarray can include paths to json files containing component data or JSON objects containing component data.Example component.json:
{ "scenes": { "Root Scene": { "loop-animation": { "clip": "idle_eyes" } } }, "nodes": { "Head": { "scale-audio-feedback": "" } } }Example
.bundle.config.jsonfile:{ "name": "BotDefault", "version": "0.0.1", "output": { "filePath": "bots" }, "assets": [ { "name": "BotDefault", "src": "./BotDefault_Avatar.fbx", "components": [ "./components.json", { "nodes": { "Head": { "test-component": true } } } ] } ] }Using gltf-content-hash, rename all referenced assets in the glTF to
<contenthash>.<extension>. This ensures that cached files referenced in the.gltfcan be updated. Assets shared between multiple.gltffiles will have the same content hash and will be fetched from cache rather than downloaded again..gltffiles will be renamed to<gltfName>-<contentHash>.gltfso that you can easily find and preview gltf files, but still get the same cache busting functionality.- Output two final
.bundle.jsonfiles<bundle.name>.bundle.jsonand<bundle.name>-<bundle.version>-<timestamp>.bundle.json. The first bundle will always contain the most recent assets. The second will be a version-locked bundle that you can assume is immutable.
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago