Library

Collection of common functions, written using the core API, that modify glTF files.

Installation

Install the 'core' and 'lib' packages:

npm install --save @gltf-transform/core @gltf-transform/lib

Then, import some modules:

import { WebIO } from '@gltf-transform/core';
import { ao, dedup } from '@gltf-transform/lib';

const doc = await new WebIO().readGLB('path/to/model.glb');
await doc.transform(
  ao({samples: 500}),
  dedup({textures: true})
);

Transforms

Transforms are functions applying a modification to the Document. This project includes a few simple transforms already, and more are likely to be added in the future.

transform compatibility description
ao Node.js, Web Bakes per-vertex ambient occlusion. Cheaper but lower-quality than AO baked with a UV map. Powered by geo-ambient-occlusion
colorspace Node.js, Web Vertex color colorspace correction.
center Node.js, Web Centers the scene at the origin, or above/below it.
dedup Node.js, Web Prunes duplicate accessors and textures. Based on a gist by mattdesl.
metalRough Node.js, Web Convert materials from spec/gloss to metal/rough.
partition Node.js, Web Partitions the binary payload of a glTF file so separate mesh or animation data is in separate .bin files.
sequence Node.js, Web Creates an animation displaying each of the specified nodes sequentially.

Other functions

function compatibility description
inspect Node.js, Web Inspects the contents of a glTF file and returns a report.
bounds Node.js, Web Computes world bounding box of given Node or Scene, ignoring animation.
Function symbol, f(📦) → 📦, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy TypeDoc documentation Copyright 2020 under MIT license