The glb-loader is a NiiVue plugin that converts glTF (Graphics Library Transmission Format) binary files (.glb) files into mz3 meshes. While glTF enables compact, fast-transferring files, it remains uncommon in neuroimaging. Additionally, supporting glTF introduces dependencies. Specifically, here we use the glTF Transform library installed as a npm package. By offering glTF support as an optional plugin, NiiVue stays lightweight while providing compatibility when needed.
To illustrate this library, glb2mz3
is a node.js converter that can be run from the command line:
git clone [email protected]:rordenlab/glb-loader.git
cd glb-loader
npm install
node ./src/glb2mz3.js ./tests/testData/mesh.glb
You can also embed this loader into a hot-reloadable NiiVue web page to evaluate integration:
git clone [email protected]:rordenlab/glb-loader.git
cd glb-loader
npm install
npm run dev
- NIH 3D provides thousands of GLB meshes. Note the sample meshes included in this repository are from here.
This library also supports glTF .glb files optimized with Draco mesh compression. Note that the vertex reording may disrupt mesh overlays (e.g. statistical maps, gray matter thickness, curvature) and decimation properties. While this dramatically reduces file size, be warned that these compressed not compatible with all glTF viewers. For these reasons, most glTF files (including sample data from NIH 3D) are not compressed this way. You can compress glTF meshes to use Draco from the command line:
npm install --global @gltf-transform/cli
gltf-transform optimize water-bas-color-print_NIH3D.glb water.glb --compress draco --texture-compress webp