Wraps a glTF asset and its resources for easier modification.

Documents manage glTF assets and the relationships among dependencies. The document wrapper allow tools to read and write changes without dealing with array indices or byte offsets, which would otherwise require careful management over the course of a file modification. An internal graph structure allows any property in the glTF file to maintain references to its dependencies, and makes it easy to determine where a particular property dependency is being used. For example, finding a list of materials that use a particular texture is as simple as calling Texture.listParents().

A new resource Property (e.g. a Mesh or Material) is created by calling 'create' methods on the document. Resources are destroyed by calling Property.dispose().

import { Document } from '@gltf-transform/core';
import { dedup } from '@gltf-transform/lib';

const doc = new Document();

const texture1 = doc.createTexture('myTexture')
const texture2 = doc.createTexture('myTexture2')

// Document containing duplicate copies of the same texture.
doc.getRoot().listTextures(); // → [texture x 2]

await doc.transform(
    dedup({textures: true}),
    // ...

// Document with duplicate textures removed.
doc.getRoot().listTextures(); // → [texture x 1]



  • Document


  • Clones this Document, copying all resources within it.

  • createBuffer(name?: string): Buffer
  • createCamera(name?: string): Camera
  • createExtension<T>(ctor: {}): T
  • Creates a new Extension, for the extension type of the given constructor. If the extension is already enabled for this Document, the previous Extension reference is reused.

    Type parameters

  • createMaterial(name?: string): Material
  • createMesh(name?: string): Mesh
  • createNode(name?: string): Node
  • createScene(name?: string): Scene
  • createSkin(name?: string): Skin
  • createTexture(name?: string): Texture
  • Returns the Logger instance used for any operations performed on this document.

  • Merges the content of another Document into this one, without affecting the original.

  • Overrides the Logger instance used for any operations performed on this document.


        .setLogger(new Logger(Logger.Verbosity.SILENT))
        .transform(split(), ao({samples: 50}));
  • transform(...transforms: Transform[]): Promise<this>
  • Applies a series of modifications to this document. Each transformation is synchronous, takes the Document as input, and returns nothing. Transforms are applied in the order given, which may affect the final result.


    await doc.transform(
        ao({samples: 500}),
Function symbol, f(📦) → 📦, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy TypeDoc documentation Copyright 2020 under MIT license