npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gltf-to-glb

v0.1.0

Published

CLI tool for packing glTF to GLB.

Downloads

4

Readme

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.