Skip to main content

Module gltf

Module gltf 

Source
Expand description

glTF 2.0: binary .glb and JSON .gltf with its buffers.

Geometry, the base colour, the base colour, normal and emissive textures, the emissive factor and the alpha mode are read (no other textures, animation, skins or sparse accessors). The default scene is walked, node transforms are baked into positions and normals, and every primitive of every mesh instance becomes one Mesh.

A texture comes from the GLB’s binary chunk, a data URI or a file next to the model (sampler wrap modes are ignored, textures always repeat; see super::texture). The base colour texture has the base colour factor as its tint (glTF multiplies the two) and, for the MASK alpha mode, its alpha cutoff. A mesh has one set of texture coordinates, those of the base colour texture, else of the normal texture, else of the emissive one, with that texture’s KHR_texture_transform baked in. The BLEND and MASK alpha modes draw see-through. A material with KHR_materials_pbrSpecularGlossiness has no normal, emissive or see-through part, as in Eagle’s viewer. A texture or factor that is out of range, undecodable or malformed is left out; it never fails the file.

Functions§

parse_glb
Reads a .glb file.
parse_gltf
Reads a .gltf file; its buffers are data URIs or fetched with side.