@sayduck/gltf-pipeline
v3.4.2-pre-1
Published
Node package holding all of Sayduck's scripts to convert assets and products to glTF 2.0
Downloads
369
Keywords
Readme
sayduck-gltf-pipeline
Node package holding all of Sayduck's scripts to convert assets and products to glTF 2.0
Pipeline help
$ sayduck-gltf-pipeline -h
Usage: sayduck-gltf-pipeline [options] [command]
Options:
-v, --version output the version number
-h, --help output usage information
Commands:
obj-utility [options]
gltf-utility [options] <gltf-files...>
create-gltf [options]
obj-utility
help
$ sayduck-gltf-pipeline obj-utility -h
Usage: obj-utility [options]
Options:
-i, --input-file <input-file> [required] path to .obj file to process
-o, --output-folder <output-folder> [required] output folder for generated file(s)
--obj-split outputs one .obj per group present in .obj to process
--obj-fix generates normals and UVs for the input .obj (or the resulting split .objs) if missing
--gltf-convert convert the input .obj (or the resulting split .objs) to .gltf + .bin
-h, --help output usage information
Example
$ sayduck-gltf-pipeline obj-utility -i path/to/source.obj -o path/to/output/folder/ --obj-split --gltf-convert
{
"status": "success",
"meshes": [
{
"reference": "source_obj_group_1_name",
"assets": [
{
"type": "obj",
"uri": "path/to/output/folder/source_obj_group_1_name.obj",
"content_type": "text/plain"
},
{
"type": "gltf",
"uri": "path/to/output/folder/source_obj_group_1_name.gltf",
"content_type": "model/gltf+json"
},
{
"type": "bin",
"uri": "path/to/output/folder/source_obj_group_1_name.bin",
"content_type": "application/octet-stream"
},
]
},
...
]
}
gltf-utility
help
$ sayduck-gltf-pipeline gltf-utility -h
Usage: gltf-utility [options] <gltf-files...>
Options:
-o, --output-folder <output-folder> [required] output folder for generated file(s)
--gltf-optimize optimize the passed-in .gltf files
--gltf-binary create .glb file(s) instead of .gltf
--gltf-embed-assets embed assets in .gltf files (meshes are always embedded with --gltf-binary)
--gltf-draco-compression enable draco compression for meshes
-h, --help output usage information
Example: gltf-optimize
$ sayduck-gltf-pipeline gltf-utility --gltf-optimize -o path/to/output/folder/ path/to/first.gltf path/to/second.gltf
{
"status": "success",
"meshes": [
{
"reference": "first",
"assets": [
{
"type": "gltf",
"uri": "path/to/output/folder/first.gltf",
"content_type": "model/gltf+json"
},
{
"type": "png",
"uri": "path/to/output/folder/texture.png",
"content_type": "image/png"
},
{
"type": "bin",
"uri": "path/to/output/folder/mesh.bin",
"content_type": "application/octet-stream"
},
...
]
},
...
]
}
Example: create glb
$ sayduck-gltf-pipeline gltf-utility --gltf-optimize --gltf-binary --gltf-embed-assets -o path/to/output/folder/ path/to/input.gltf
{
"status": "success",
"meshes": [
{
"reference": "input",
"assets": [
{
"type": "glb",
"uri": "path/to/output/folder/input.glb",
"content_type": "model/gltf-binary"
}
]
}
]
}
create-gltf
help
Usage: create-gltf [options]
Options:
-i, --input-file <input-file> [required] path to the JSON file to process
-o --output-file <output-file> [required] processed glTF file
--meshes-key specifify a JSON key to read glTF meshes from (defaults to `meshes`)
--materials-key specifify a JSON key to read glTF materials from (defaults to `materials`)
--mesh-assignments-key specifify a JSON key to read mesh-material assignments from (defaults to `mesh_assignments`)
-h, --help output usage information
Example
$ sayduck-gltf-pipeline create-gltf -i path/to/input/file.json -o path/to/output/file.gltf
{
"status": "success",
"gltfPath": "path/to/output/file.gltf"
}
Example input-file.json
{
"meshes": {
[meshUuid]: { meshGltf },
...
},
"materials": {
[materialUuid]: {
name,
extras,
alpha_mode,
is_double_sided,
albedo_colour, // { red, green, blue, alpha }
emissive_colour, // { red, green, blue }
albedo_transparency,
roughness, // 0.0 - 1.0
metallicness, // 0.0 - 1.0
occlusion_map_intensity, // 0.0 - 1.0
maps,
// [
// {
// kind, // 'albedo' / 'occlusion_roughness_metallic' / 'normal' / 'emissive'
// urls: { jpg, png },
// },
// ...
// ]
map_tiling, // { x, y }
map_tiling_offset, // { x, y }
map_tiling_rotation, // 0 - 360
},
...
},
"mesh_assignments": {
[meshAssignmentUuid]: {
"mesh": [meshUuid],
"material": [materialUuid]
},
...
}
}
create-glb
help
Usage: create-glb [options]
Options:
-i, --input-file <input-file> [required] path to the .gltf file to process
-o --output-file <output-file> [required] processed .glb file
-h, --help output usage information
Example
$ sayduck-gltf-pipeline create-glb -i path/to/input/file.gltf -o path/to/output/file.glb
{
"status": "success",
"gltfPath": "path/to/output/file.glb"
}