Esc

Gltf_Asset

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

Declaration

Gltf_Asset :: struct {
    document: Gltf_Document;    buffers: [..] string;// each node's parent, or -1; built by validation for gltf_node_world    parents: [..] s64;// extensions_used and extensions_required are the asset's to free, not borrowed    owns_extension_lists: bool;}

A loaded asset: the decoded document plus the bytes of each of its buffers, in the document's order. Owned; release it with gltf_free.

An asset can also be built by hand, starting from Gltf_Asset.{}. gltf_free releases the document's strings and arrays as free_json does, so a hand-built document must hold allocated ones (use copy_string), with one exception: extensions_used and extensions_required may be literals. They are borrowed until gltf_use_extension or gltf_remove_extension changes them, which copies them into storage the asset owns.

Example↗
asset, error := gltf_load("{\"asset\":{\"version\":\"2.0\"},\"buffers\":[{\"byteLength\":4,\"uri\":\"data:application/octet-stream;base64,AAAAAA==\"}],\"bufferViews\":[{\"buffer\":0,\"byteLength\":4,\"target\":34962}]}");
assert(error.kind == .NONE);
defer gltf_free(*asset);
assert(asset.document.buffers.count == 1);
assert(asset.buffers[0].count == 4); // the bytes of buffer 0

See also