Skip to content

gltf_parser

FreeBodyEngine.graphics.model.gltf_parser #

GLBParser(data_bytes) #

Splits a .glb (binary glTF) blob into its JSON and binary chunks.

Parses .glb (glTF blob) files into its glTF + bin data.

bin_chunk = None instance-attribute #

bytes = data_bytes instance-attribute #

json_chunk = None instance-attribute #

get_binary_buffer() #

Returns the raw BIN chunk bytes, or None if the file had none.

get_json() #

Returns the parsed glTF JSON document.

GLTFParser(gltf_dict, bin_data) #

Builds a Model from a parsed glTF JSON document plus its binary buffer data. Legacy/dead code - not used anywhere in the engine; the actively-used glTF loader is core/files/loaders/model.py.

Stores the parsed glTF JSON (gltf_dict) and its binary buffer (bin_data).

bin_data = bin_data instance-attribute #

gltf = gltf_dict instance-attribute #

build_model(model_name, pipeline, renderer, scale=None) #

Builds a single named mesh (model_name, or the glTF's first mesh if None) into a Model, uploading every image in the file as a standalone texture and every material as a real Material along the way. Unlike core/files/loaders/model.py's build_model(), this always builds exactly one mesh, not every mesh in the file.

get_accessor_data(accessor_index) #

Returns a flat list of per-element tuples decoded from the glTF accessor at accessor_index (e.g. a VEC3 accessor yields a list of 3-float tuples).

get_image_data(image_index) #

Returns the raw encoded bytes of image image_index, from either the GLB BIN chunk or an embedded base64 data: URI - an external (non-data:) URI raises NotImplementedError, since this parser has no base path to resolve a sibling file against.

get_model_index(name) #

Returns the index into self.gltf['meshes'] of the mesh named name, or None if no mesh has that name.