All Projects → CesiumGS → Gltf Pipeline

CesiumGS / Gltf Pipeline

Licence: apache-2.0
Content pipeline tools for optimizing glTF assets. 🌐

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Gltf Pipeline

vpx-js
🎮 Visual Pinball in the Browser
Stars: ✭ 38 (-95.18%)
Mutual labels:  gltf
Gltf Sdk
glTF-SDK is a C++ Software Development Kit for glTF (GL Transmission Format -https://github.com/KhronosGroup/glTF).
Stars: ✭ 312 (-60.46%)
Mutual labels:  gltf
Objto3d Tiles
Convert obj model file to 3d tiles
Stars: ✭ 480 (-39.16%)
Mutual labels:  gltf
orkid
Orkid Media Engine (C++/Lua/Python3/Linux/MacOs/OpenVR/Qt5)
Stars: ✭ 20 (-97.47%)
Mutual labels:  gltf
Exporters
Exporters for Babylon.js and gltf file formats
Stars: ✭ 302 (-61.72%)
Mutual labels:  gltf
Spoke
Easily create custom 3D environments
Stars: ✭ 321 (-59.32%)
Mutual labels:  gltf
playcanvas-viewer
glTF 2.0 model viewer
Stars: ✭ 152 (-80.74%)
Mutual labels:  gltf
Cgltf
💠 Single-file glTF 2.0 loader and writer written in C99
Stars: ✭ 628 (-20.41%)
Mutual labels:  gltf
Gltfutility
Simple GLTF importer for Unity
Stars: ✭ 305 (-61.34%)
Mutual labels:  gltf
Castle Engine
Cross-platform (desktop, mobile, console) 3D and 2D game engine supporting many asset formats (glTF, X3D, Spine...) and using modern Object Pascal
Stars: ✭ 475 (-39.8%)
Mutual labels:  gltf
Fx Gltf
A C++14/C++17 header-only library for simple, efficient, and robust serialization/deserialization of glTF 2.0
Stars: ✭ 257 (-67.43%)
Mutual labels:  gltf
Loaders.gl
Loaders for big data visualization. Website:
Stars: ✭ 272 (-65.53%)
Mutual labels:  gltf
3dtilesrendererjs
Renderer for 3D Tiles in Javascript using three.js
Stars: ✭ 333 (-57.79%)
Mutual labels:  gltf
MeshIO
CloudCompare plugin for loading COLLADA, glTF, and IFC-SPF 3D models
Stars: ✭ 14 (-98.23%)
Mutual labels:  gltf
Lighthouse2
Lighthouse 2 framework for real-time ray tracing
Stars: ✭ 542 (-31.31%)
Mutual labels:  gltf
VRMKit
VRM loader and VRM renderer (3D model / gltf)
Stars: ✭ 85 (-89.23%)
Mutual labels:  gltf
Xeokit Sdk
Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
Stars: ✭ 316 (-59.95%)
Mutual labels:  gltf
Engine
Fast and lightweight JavaScript game engine built on WebGL and glTF
Stars: ✭ 6,890 (+773.26%)
Mutual labels:  gltf
Clay Viewer
3D model viewer with high quality rendering and glTF2.0/GLB export
Stars: ✭ 558 (-29.28%)
Mutual labels:  gltf
Vulkan Gltf Pbr
Physical based rendering with Vulkan using glTF 2.0 models
Stars: ✭ 438 (-44.49%)
Mutual labels:  gltf

glTF Pipeline

License Build Status

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

Supports common operations including:

  • Converting glTF to glb (and reverse)
  • Saving buffers/textures as embedded or separate files
  • Converting glTF 1.0 models to glTF 2.0 (using the KHR_techniques_webgl and KHR_blend extensions)
  • Applying Draco mesh compression

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

Getting Started

Install Node.js if you don't already have it, and then:

npm install -g gltf-pipeline

Using gltf-pipeline as a command-line tool:

Converting a glTF to glb

gltf-pipeline -i model.gltf -o model.glb

gltf-pipeline -i model.gltf -b

Converting a glb to glTF

gltf-pipeline -i model.glb -o model.gltf

gltf-pipeline -i model.glb -j

Converting a glTF to Draco glTF

gltf-pipeline -i model.gltf -o modelDraco.gltf -d

Saving separate textures

gltf-pipeline -i model.gltf -t

Using gltf-pipeline as a library:

Converting a glTF to glb:

const gltfPipeline = require('gltf-pipeline');
const fsExtra = require('fs-extra');
const gltfToGlb = gltfPipeline.gltfToGlb;
const gltf = fsExtra.readJsonSync('model.gltf');
gltfToGlb(gltf)
    .then(function(results) {
        fsExtra.writeFileSync('model.glb', results.glb);
    });

Converting a glb to glTF

const gltfPipeline = require('gltf-pipeline');
const fsExtra = require('fs-extra');
const glbToGltf = gltfPipeline.glbToGltf;
const glb = fsExtra.readFileSync('model.glb');
glbToGltf(glb)
    .then(function(results) {
        fsExtra.writeJsonSync('model.gltf', results.gltf);
    });

Converting a glTF to Draco glTF

const gltfPipeline = require('gltf-pipeline');
const fsExtra = require('fs-extra');
const processGltf = gltfPipeline.processGltf;
const gltf = fsExtra.readJsonSync('model.gltf');
const options = {
    dracoOptions: {
        compressionLevel: 10
    }
};
processGltf(gltf, options)
    .then(function(results) {
        fsExtra.writeJsonSync('model-draco.gltf', results.gltf);
    });

Saving separate textures

const gltfPipeline = require('gltf-pipeline');
const fsExtra = require('fs-extra');
const processGltf = gltfPipeline.processGltf;
const gltf = fsExtra.readJsonSync('model.gltf');
const options = {
    separateTextures: true
};
processGltf(gltf, options)
    .then(function(results) {
        fsExtra.writeJsonSync('model-separate.gltf', results.gltf);
        // Save separate resources
        const separateResources = results.separateResources;
        for (const relativePath in separateResources) {
            if (separateResources.hasOwnProperty(relativePath)) {
                const resource = separateResources[relativePath];
                fsExtra.writeFileSync(relativePath, resource);
            }
        }
    });

Command-Line Flags

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
--stats Print statistics to console for output glTF file. No, default false
--keepUnusedElements Keep unused materials, nodes and meshes. 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

Build Instructions

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

Building for CesiumJS integration

Some functionality of gltf-pipeline is used by CesiumJS 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 for use with CesiumJS in the browser.

Running Test Coverage

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.

Generating Documentation

To generate the documentation:

npm run jsdoc

The documentation will be placed in the doc folder.

Contributions

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].