Latest NPM release Minzipped size License

glTF 2.0 SDK for JavaScript, TypeScript, and Node.js.


glTF-Transform supports reading, editing, and writing 3D models in glTF 2.0 format. Unlike 3D modeling tools β€”Β which are ideal for artistic changes to geometry, materials, and animation β€” glTF-Transform provides fast, reproducible, and lossless control of the low-level details in 3D model. The API automatically manages array indices and byte offsets, which would otherwise require careful management when editing files. These traits make it a good choice for bundling, splitting, or optimizing an existing model. It can also be used to apply quick fixes for common issues, to build a model procedurally, or to easily develop custom extensions on top of the glTF format. Because the core SDK is compatible with both Node.js and Web, glTF-Transform may be used to develop offline workflows and web applications alike.

glTF-Transform is modular:

  • @gltf-transform/core: Core SDK, providing an expressive API to read, edit, and write glTF files.
  • @gltf-transform/extensions: Extensions (optional glTF features) for the Core SDK.
  • @gltf-transform/lib: Library of common functions, written using the core API, that modify glTF files.
  • @gltf-transform/cli: Command-line interface to apply changes quickly or in batch.

Getting started

To learn how glTF-Transform works, see Concepts. To get started developing with the SDK, see SDK Installation below. Visit the Library for examples of functionality created with the SDK already. To use the commandline interface, see Commandline (CLI). If you're interested in contributing to or customizing the project, see contributing.

SDK Installation

Install the core SDK for programmatic use:

npm install --save @gltf-transform/core

Then, import some modules:

// ES Modules.
import { Document, Scene, WebIO } from '@gltf-transform/core';

// CommonJS.
const { Document, Scene, WebIO } = require('@gltf-transform/core');

All classes described by this documentation are imported from the core package, as shown above. Most projects should start with the Document or PlatformIO classes.

Alternatives and related projects

Several existing projects provide complementary functionality to that of glTF-Transform:

  • glTF-Pipeline, by AGI, can pack and unpack variations of the glTF format (which glTF-Transform also does) and can apply Draco compression to mesh geometry (which glTF-Transform currently does not, in order to remain portable across both Node.js and Web). While glTF-Pipeline also offers APIs to develop custom pipelines, those APIs are currently less expressive than glTF-Transform's. Because glTF-Pipeline is nearly lossless, it is a good option for applying Draco compression to models produced by glTF-Tranform. glTF-Pipeline does not run in web browsers.
  • meshoptimizer / gltfpack, by @zeux, is an excellent tool for optimizing glTF files, and offers far better performance tuning than anything I'll ever write. It is not, however, a general-purpose SDK, and is best used for final optimizations to models produced by glTF-Transform and other tools. gltfpack does not run in web browsers.
  • Gestaltor, by UX3D, is the only visual editor dedicated to inspection and editing of glTF files. If you like the 1:1 parity of glTF features that glTF-Transform provides, but need a visual editor, Gestaltor is a good choice.
  • cgltf, by @jkuhlmann, and glTF-Toolkit, by Microsoft, provide native SDKs for glTF. If JavaScript/TypeScript don't fit your needs, try these.
  • Blender offers a Python API in addition to its better-known UI. I rely on Blender for many projects, although I've only occasionally worked with its Python API.
Function symbol, f(πŸ“¦) β†’ πŸ“¦, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy β€’ TypeDoc documentation β€’ Copyright 2020 under MIT license