Esc

Gltf_Document

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

Declaration

Gltf_Document :: struct @json(rename_all=camelCase) {
    asset: Gltf_Metadata;    scene: Json_Maybe(u32);    scenes: [] Gltf_Scene; @json(default,skip_serializing_if=empty)    nodes: [] Gltf_Node; @json(default,skip_serializing_if=empty)    meshes: [] Gltf_Mesh; @json(default,skip_serializing_if=empty)    accessors: [] Gltf_Accessor; @json(default,skip_serializing_if=empty)    buffer_views: [] Gltf_Buffer_View; @json(default,skip_serializing_if=empty)    buffers: [] Gltf_Buffer; @json(default,skip_serializing_if=empty)    materials: [] Gltf_Material; @json(default,skip_serializing_if=empty)    textures: [] Gltf_Texture; @json(default,skip_serializing_if=empty)    images: [] Gltf_Image; @json(default,skip_serializing_if=empty)    samplers: [] Gltf_Sampler; @json(default,skip_serializing_if=empty)    skins: [] Gltf_Skin; @json(default,skip_serializing_if=empty)    animations: [] Gltf_Animation; @json(default,skip_serializing_if=empty)    cameras: [] Gltf_Camera; @json(default,skip_serializing_if=empty)    extensions_used: [] string; @json(default,skip_serializing_if=empty)    extensions_required: [] string; @json(default,skip_serializing_if=empty)    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)}

The glTF root object: every array of scene data, which refer to each other by index. Decoded from and encoded to JSON through the @json notes; an optional index is a Json_Maybe so that omission differs from index 0. extensions and extras keep unknown data as Json_Value.

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);
document := asset.document;
assert(document.scene.state == .SET && document.scene.value == 0);
assert(document.nodes.count == 1 && document.meshes.count == 1);

See also