Module glb

Source
Expand description

Binary glTF 2.0 (GLB) export of a RenderScene.

to_glb writes one self-contained .glb file that any glTF viewer opens. The JSON chunk is built with serde_json; no glTF library is used.

§Layout

  • One root node, named IFCX, holds the scene’s origin as its translation and, by default, the rotation from IFCX’s Z-up to glTF’s Y-up axes. Its extras record the origin in the file’s coordinates (ifcxOrigin) and the up axis written (ifcxUpAxis).
  • Each Instance becomes one child node of the root, named by the instance path, with the instance’s render matrix and extras.ifcxNode set to Instance::node. A node with several kinds of geometry gives one glTF node per kind, all with the same name.
  • Each pair of geometry buffer and material becomes one glTF mesh, which every instance of that pair references. Each buffer is written once, so instances share vertex data even across materials.
  • Meshes are TRIANGLES with POSITION, NORMAL, and u32 indices; lines are LINES with indices; points are POINTS with COLOR_0 when they have colours. POSITION accessors carry min and max.
  • Materials used by an instance map onto pbrMetallicRoughness: a BasicMaterial is its colour with opacity as alpha, metallic 0, roughness 1, and BLEND when not opaque; a GltfMaterial keeps its factors, alphaMode, alphaCutoff, and doubleSided. Texture references are not written, since the scene does not load them. Factors and colours are clamped to 0..=1, as glTF requires, and alphaCutoff to a finite number of at least 0 (0.5 for NaN). With the scene’s own finite coordinates (see SceneWarningKind::OutOfRange), every number in the JSON chunk is finite, so it never holds null.
  • Every buffer view starts on a 4-byte boundary, and both chunks are padded to 4 bytes, the JSON chunk with spaces.

Structs§

GlbOptions
Options for to_glb.

Enums§

GlbError
Why a scene could not be written as GLB.

Functions§

to_glb
Writes scene as a binary glTF 2.0 file.