Open Source Node.js SDK for Working with 3D glTF Models
A Leading Open Source Node.js 3D SDK allows Software Developers to Read, Write, Edit, Optimize and Manipulate glTF 3D Models inside Node.js Applications.
In the ever-evolving world of 3D graphics and digital content, efficient and versatile tools are essential for software developers and artists alike. One such tool that has been making waves in the industry is the glTF-Transform library, an open-source project developed by Don McCurdy enables software developers to handle all complexities related to 3d geometry processing. The glTF format, short for GL Transmission Format, is a standard developed by the Khronos Group for the efficient transmission and loading of 3D scenes and models. Known as the "JPEG of 3D," glTF is optimized for the web, ensuring fast load times and minimal storage requirements.
The glTF-Transform library is an invaluable tool for anyone working with 3D graphics in the glTF format. . It is designed to be efficient for loading on the web, providing a lightweight and easy-to-use format that supports various types of 3D content, including textures, animations, and shaders. It can significantly reduce the size of glTF files while preserving visual quality and optimize 3D models for faster load times and better performance on web pages. Moreover, it converts and optimize assets for different game engines and platforms with ease. Its robust feature set, ease of use, and open-source nature make it a go-to solution for optimizing and transforming 3D assets. Overall, the glTF-Transform library is a valuable asset for anyone working with 3D models in the glTF format.s
Getting Started with glTF-Transform
The easiest way to install glTF-Transform stable release is using npm. Please use the following command for a smooth installation.
Install glTF-Transform via npm
npm install --global @gltf-transform/cli
install glTF-Transform via GitHub.
clone https://github.com/donmccurdy/glTF-Transform.git
You can download the compiled shared library from Github repository.
Read & Write glTF Scenes in Node.js
The open source glTF-Transform SDK, makes it easy for software developers to create new glTF Scenes from scratch or load and read existing scenes inside their own Node.js applications. The library supports modifying existing scenes, compressing a glTF file, modifying materials properties, adjusting node Hierarchies and so on. Here is a simple example that shows, how software developers can load an existing glTF file and update it and save it modified glTF file to a place of his choice inside Node.js applications.
How to Load and Save Modified glTF File inside Node.js Apps?
const { NodeIO } = require('@gltf-transform/io');
// Create an IO instance.
const io = new NodeIO();
// Load a glTF file.
const document = io.read('path/to/your/model.glb');
// Perform operations on the document...
// Save the modified glTF file.
io.write('path/to/your/output.glb', document);
glTF Files Compression & Optimization in Node.js
The open source glTF-Transform SDK is very feature rich and allows software developers to compress as well as optimize glTF files inside their own Node.js environment. With just a couple of lines of code, library can significantly reduce their size while maintaining visual quality. This is crucial for enhancing performance, especially in web applications where load times and bandwidth are critical. The following example demonstrates, how software developers can compress existing glTF files to reduce their size inside Node.js applications.
How to Compress a glTF File to Optimize Its Size inside Node.js Apps?
const { NodeIO } = require('@gltf-transform/io');
const { DracoMeshCompression } = require('@gltf-transform/extensions');
const { DracoMeshEncoder } = require('@gltf-transform/functions');
const io = new NodeIO();
const document = io.read('path/to/your/model.glb');
// Add Draco compression.
document.createExtension(DracoMeshCompression)
.setRequired(true);
await document.transform(
DracoMeshEncoder({ method: DracoMeshEncoder.Method.EDGEBREAKER })
);
io.write('path/to/your/output-compressed.glb', document);
glTF Files Transformation and Editing in Node.js
The glTF format, developed by the Khronos Group, is a royalty-free standard for 3D asset delivery. It is optimized for efficient transmission and loading of 3D scenes and models. The glTF-Transform SDK allows for extensive modifications of glTF files, including altering node hierarchies, modifying material properties, adjusting animations and so on. These capabilities give developers the flexibility to customize 3D assets to fit specific needs. The following example shows, how software developers can adjust node hierarchies inside their own Node.js applications.
How to Adjusting Node Hierarchies inside Node.js Apps?
const { NodeIO } = require('@gltf-transform/io');
const { DracoMeshCompression } = require('@gltf-transform/extensions');
const { DracoMeshEncoder } = require('@gltf-transform/functions');
const io = new NodeIO();
const document = io.read('path/to/your/model.glb');
// Add Draco compression.
document.createExtension(DracoMeshCompression)
.setRequired(true);
await document.transform(
DracoMeshEncoder({ method: DracoMeshEncoder.Method.EDGEBREAKER })
);
io.write('path/to/your/output-compressed.glb', document);
glTF 3D Files Conversion inside Node.js
The glTF-Transform SDK fully supports converting glTF files between different versions and extensions inside Node.js applications. This feature is particularly useful for ensuring compatibility with various platforms and applications. The library can also export glTF files to other file formats, facilitating broader usage and integration.