Esc

Gltf_Accessor

structextensionsince 0.36.1Source
  • macOS: Gltf_Accessor works on macOS
  • Linux: Gltf_Accessor works on Linux
  • Windows: Gltf_Accessor works on Windows
  • Wasm: Gltf_Accessor works on Wasm

Declaration

Gltf_Accessor :: struct @json(rename_all=camelCase) {
    buffer_view: Json_Maybe(u32);    byte_offset: u32 = 0; @json(default,skip_serializing_if=zero)    component_type: Gltf_Component; @json(as_number)    normalized: bool = false; @json(default)    count: u32;    type: Gltf_Accessor_Type;    min: [] float64; @json(default,skip_serializing_if=empty)    max: [] float64; @json(default,skip_serializing_if=empty)    sparse: *Gltf_Sparse; @json(default,skip_serializing_if=null)    name: string; @json(default,skip_serializing_if=empty)    extensions: Json_Value; @json(default,skip_serializing_if=null)    extras: Json_Value; @json(default,skip_serializing_if=null)}

A typed view onto a buffer view: count elements of type made of component_type, with optional min and max bounds and a sparse override. Read one with gltf_accessor.

Example↗
asset, error := gltf_load("{\"asset\":{\"version\":\"2.0\"},\"scene\":0,\"scenes\":[{\"nodes\":[0]}],\"nodes\":[{\"mesh\":0}],\"meshes\":[{\"primitives\":[{\"attributes\":{\"POSITION\":0},\"indices\":1}]}],\"buffers\":[{\"byteLength\":42,\"uri\":\"data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAABAAIA\"}],\"bufferViews\":[{\"buffer\":0,\"byteLength\":36,\"target\":34962},{\"buffer\":0,\"byteOffset\":36,\"byteLength\":6,\"target\":34963}],\"accessors\":[{\"bufferView\":0,\"componentType\":5126,\"count\":3,\"type\":\"VEC3\",\"min\":[0,0,0],\"max\":[1,1,0]},{\"bufferView\":1,\"componentType\":5123,\"count\":3,\"type\":\"SCALAR\"}]}");
assert(error.kind == .NONE);
defer gltf_free(*asset);
accessor := asset.document.accessors[0];
assert(accessor.component_type == .FLOAT && accessor.type == .VEC3 && accessor.count == 3);

See also