1. Products
  2.   3D
  3.   Node.js
  4.   glTF-Transform
 
  

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.

What is glTF-Transform?

The world of 3D graphics and digital content is always changing. For software developers and artists, having the right tools is crucial. One tool that’s been getting a lot of attention is the glTF-Transform library. Created by Don McCurdy, this open-source project is a game-changer. It helps software developers and artists deal with all the tricky aspects of 3D geometry processing. The glTF format, which stands for GL Transmission Format, is a standard created by the Khronos Group. It’s all about efficiently transmitting 3D and loading of 3D scenes and models inside Node.js applications.

If you’re into creating 3D graphics using glTF format, the glTF-Transform library is a must-have tool for you. It’s great for web use, as it keeps things light and simple. This tool can handle all kinds of 3D content like textures, animations, and shaders. Plus, it helps shrink the size of glTF files without compromising the visuals. By doing so, it speeds up loading times and boosts performance on your web pages. Furthermore, it effortlessly converts and enhances assets for various game engines and platforms. Its strong range of features, user-friendly interface, and open-source design make it the preferred choice for refining and converting 3D assets. In general, the glTF-Transform library is a valuable tool for individuals dealing with 3D models in the glTF format.

Previous Next

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.