Skip to content

stdlib/gltfView source ↗

gltf

23 items · generated by scribe fromstdlib/gltf.fd· synced 2026-11-15

stdlib/gltf23 items

Contents

GLB_MAGIC:

pub const GLB_MAGIC: i64 = 0x46546C67;  // "glTF" little-endian

Defined at line 15


GLB_JSON:

pub const GLB_JSON: i64 = 0x4E4F534A;  // "JSON"

Defined at line 16


GLB_BIN:

pub const GLB_BIN: i64 = 0x004E4942;  // "BIN\0"

Defined at line 17


GltfDoc

Parsed asset: json is the canonicalized JSON document; bin_off/ bin_len locate the BIN chunk inside b for GLB sources (bin_len 0 for JSON-only .gltf — caller supplies the .bin blob as b then).

pub struct GltfDoc {

Fields:

NameType
okbool
jsonstr
bin_offi64
bin_leni64

Defined at line 46


gltf_open

Parse a .glb blob: 12-byte header + length-prefixed chunks. ok=false when magic/version/length don’t check out.

pub fn gltf_open(b: Vec<i64>) -> GltfDoc {

Parameters:

  • b: Vec<i64>

Returns: GltfDoc

Defined at line 55


gltf_open_json

Wrap a standalone .gltf JSON string (buffers external — pass the .bin bytes as b to the accessor readers).

Example (native only): var d = gltf_open_json(”{“meshes”:[{“name”:“tri”}]}”); println(int_to_str(gltf_mesh_count(d))); // 1

pub fn gltf_open_json(j: str) -> GltfDoc {

Parameters:

  • j: str

Returns: GltfDoc

Defined at line 111


gltf_mesh_count

pub fn gltf_mesh_count(d: GltfDoc) -> i64 {

Parameters:

  • d: GltfDoc

Returns: i64

Defined at line 136


gltf_node_count

pub fn gltf_node_count(d: GltfDoc) -> i64 {

Parameters:

  • d: GltfDoc

Returns: i64

Defined at line 143


gltf_comp_size

componentType -> byte size, or 0 when unknown.

pub fn gltf_comp_size(ct: i64) -> i64 {

Parameters:

  • ct: i64

Returns: i64

Defined at line 154


gltf_type_count

type string -> number of components per element.

pub fn gltf_type_count(t: str) -> i64 {

Parameters:

  • t: str

Returns: i64

Defined at line 168


GltfAcc

Resolved accessor — the JSON lookups happen once in gltf_acc; the per-element readers below then touch only the binary buffer (a real model’s POSITION accessor would otherwise re-parse JSON per vertex).

pub struct GltfAcc {

Fields:

NameType
okbool
offi64
stridei64
counti64
ctypei64
csizei64
ncompi64
normbool

Defined at line 196


gltf_acc

Resolve accessor ai: bufferView + byteOffset + byteStride. base is the buffer’s offset inside b (d.bin_off for GLB, 0 for .bin).

pub fn gltf_acc(d: GltfDoc, ai: i64, base: i64) -> GltfAcc {

Parameters:

  • d: GltfDoc
  • ai: i64
  • base: i64

Returns: GltfAcc

Defined at line 214


gltf_acc_uint_at

Unsigned component j of element i — BYTE/UNSIGNED_*/unsigned ints.

pub fn gltf_acc_uint_at(b: Vec<i64>, a: GltfAcc, i: i64, j: i64) -> i64 {

Parameters:

  • b: Vec<i64>
  • a: GltfAcc
  • i: i64
  • j: i64

Returns: i64

Defined at line 247


gltf_acc_int_at

Signed variant (BYTE=5120, SHORT=5122).

pub fn gltf_acc_int_at(b: Vec<i64>, a: GltfAcc, i: i64, j: i64) -> i64 {

Parameters:

  • b: Vec<i64>
  • a: GltfAcc
  • i: i64
  • j: i64

Returns: i64

Defined at line 268


gltf_acc_f32_at

Float component — FLOAT (5126) directly, integer types as raw value or /max when the accessor is normalized.

pub fn gltf_acc_f32_at(b: Vec<i64>, a: GltfAcc, i: i64, j: i64) -> f64 {

Parameters:

  • b: Vec<i64>
  • a: GltfAcc
  • i: i64
  • j: i64

Returns: f64

Defined at line 281


gltf_mesh

Build mesh.fd’s Mesh from mesh mi, primitive pi (default 0). Reads POSITION/NORMAL/TEXCOORD_0 attributes and the index accessor. Unindexed primitives assume consecutive triangles. valid=false when the mesh/primitive or its POSITION accessor is missing.

pub fn gltf_mesh(b: Vec<i64>, d: GltfDoc, mi: i64, pi: i64) -> Mesh {

Parameters:

  • b: Vec<i64>
  • d: GltfDoc
  • mi: i64
  • pi: i64

Returns: Mesh

Defined at line 322


gltf_material_color

baseColorFactor of material mi as [r,g,b,a] (defaults 1,1,1,1).

pub fn gltf_material_color(d: GltfDoc, mi: i64) -> Vec<f64> {

Parameters:

  • d: GltfDoc
  • mi: i64

Returns: Vec<f64>

Defined at line 420


Generated by scribe, the Fides documentation generator