Code Monkey home page Code Monkey logo

gltf-to-glb's Introduction

glTF to GLB

dependencies devDependencies

CLI tool for converting glTF to GLB.

gltf-to-glb extends the functionality of gltf-pipeline by adding hooks for preprocessing of glTF files and postprocessing of GLB files allowing you to more easily plug in certain transformations and optimisations without having to modify the core library. It also makes sure to validate your glTF file using gltf-validator to flag any potential issues before processing.

Installation

$ npm install

$ git submodule init
$ git submodule update

$ npm --prefix ./submodules/gltf-pipeline install ./submodules/gltf-pipeline

$ git submodule update --recursive --remote --force

Live demo

Live demo of a Draco compressed glTF file rendered in Three.js using HDR Image-based Lighting with run-time generated pre-filtered roughness mipmaps.

Screenshot

Example

Before adding further optimizations like Draco and ZLib compression you have to ask yourself: does it make sense in my context? At what point does it start making sense to use these type of optimizations?

I would say: only when you are dealing with a lot of geometry and a lot of models in your scene. Only then the upfront cost of the ZLib inflating, the Draco decoding and decompression will make up for its own cost. When you have a single model like in the live demo it is likely not worth it. A use case as shown in the video Draco 3D Geometry Compression: Comparing Draco to gzip by Google Open Source shows that it clearly is worth it when dealing with a lot of geometry.

Please note that textures don't compress well so the cost of ZLib inflating is only really worth it if your model is geometry heavy.

glTF to glb ~ 4.8M (gltf embedded) > 3.6M (glb, requires no decompression)

$ node bin/gltf-to-glb.js -i ./submodules/glTF-Sample-Models/2.0/DamagedHelmet/glTF/DamagedHelmet.gltf -o ./output/DamagedHelmet.glb

glTF to glb using Draco compression ~ 4.8M (gltf embedded) > 3.1M (glb, requires Draco decompression)

$ node bin/gltf-to-glb.js -i ./submodules/glTF-Sample-Models/2.0/DamagedHelmet/glTF/DamagedHelmet.gltf -o ./output/DamagedHelmet_draco.glb -d

glTF to glb using Draco compression and ZLib postprocess compression ~ 4.8M (gltf embedded) > 3.0M (glb, requires ZLib inflating and Draco decompression)

$ node bin/gltf-to-glb.js -i ./submodules/glTF-Sample-Models/2.0/DamagedHelmet/glTF/DamagedHelmet.gltf -o ./output/DamagedHelmet_draco_zlib.glb -post ./plugins/ZLibDeflatePostProcess.js -d

Flags

Required

-i, --input [example: ./input/example.gltf] [required]
-o, --output [example: ./output/example.glb] [required]

Optional

-d, --draco [true / false, default: false] [not required]
-s, --seperateTextures [true / false, default: false] [not required]
-pre, --preProcess [example: ./plugins/examplePreProcess.js] [not required]
-post, --postProcess [example ./plugins/examplePostProcess.js] [not required]

Resources

Licence

My work is released under the MIT licence.

gltf-to-glb's People

Contributors

timvanscherpenzeel avatar

Forkers

kissarat funkylen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.