npm.io
9.4.1 • Published 1 week ago

@luma.gl/gltf

Licence
MIT
Version
9.4.1
Deps
0
Vulns
0
Weekly
0
Stars
2.5K
glTF

@luma.gl/gltf

Standards-first glTF assets with physically based materials, animated skeletons, morph deformation, native animation pointers, and source-faithful .gltf / .glb interchange on WebGPU and WebGL.

import {load} from '@loaders.gl/core';
import {GLTFLoader, postProcessGLTF} from '@loaders.gl/gltf';
import {createScenegraphsFromGLTF, exportGLTF} from '@luma.gl/gltf';

const asset = await load('/models/model.glb', GLTFLoader);
const gltf = postProcessGLTF(asset);

const {scenes, animator, lights, modelBounds} = createScenegraphsFromGLTF(device, gltf, {
  useTangents: true,
  useByteColors: false
});

animator.setTime(performance.now());

const exportScene = {name: 'Exported scene', nodes: [{name: 'Root'}]};
const gltfDocument = exportGLTF(exportScene);
const binaryAsset = exportGLTF(exportScene, {binary: true});

The module preserves all 21 supported core/PBR-extension texture slots, sampler filters and mipmaps, independent UV transforms and TEXCOORD_1, authored punctual lights, node transforms, material/texture animation pointers, skin attributes, and animated morph targets. Generic exportGLTF() descriptors also preserve hierarchy, skins, inverse bind matrices, morph targets, animation clips, variants, GPU instancing, cameras, lights, and source-faithful accessors.

@loaders.gl/gltf owns .gltf / .glb parsing, linked buffers and images, Draco and EXT_meshopt_compression decoding, Basis/KTX2 and supported WebP texture selection, typed accessor postprocessing, feature/structural metadata decoding, and GLB container encoding. KHR_meshopt_compression and automatic EXT_texture_avif source selection are not implemented by the installed loader. Generic animation, scenegraph, and morph primitives remain in @luma.gl/engine; shared PBR, lighting, and skinning shaders remain in @luma.gl/shadertools.

Keywords