simvx.graphics.assets.mesh_loader

Full glTF scene loading: meshes, materials, textures, node hierarchy.

Pure-Python parsing step: produces a GLTFScene with per-stream vertex data (:class:~simvx.graphics.types.VertexStreams), index arrays, and texture URIs (str) or embedded bytes. Backends (Vulkan desktop, WebRenderer) consume the same data through TextureManager.resolve.

Two parser backends:

  • pygltflib: full glTF 2.0 support (default when available).

  • Pure-stdlib fallback: handles the common .gltf JSON + external .bin + image files subset (POSITION, NORMAL, TANGENT, TEXCOORD_0, TEXCOORD_1, COLOR_0, indices, base-colour texture, KHR_lights_punctual, KHR_texture_transform, KHR_materials_emissive_strength, cameras). Used when pygltflib isn’t installed (notably inside Pyodide / web exports). Advanced features (other glTF 2.0 extensions, embedded .glb binaries) require pygltflib.

Module Contents

Classes

GLTFMaterial

Extracted PBR metallic-roughness material.

GLTFNode

Scene graph node with optional mesh reference.

GLTFScene

Complete loaded glTF scene.

Functions

load_gltf

Load complete glTF scene with all meshes, materials, textures, and hierarchy.

Data

API

simvx.graphics.assets.mesh_loader.__all__

[‘load_gltf’, ‘GLTFScene’, ‘GLTFMaterial’, ‘GLTFNode’]

simvx.graphics.assets.mesh_loader.log

‘getLogger(…)’

class simvx.graphics.assets.mesh_loader.GLTFMaterial[source]

Extracted PBR metallic-roughness material.

name: str = <Multiline-String>
albedo: tuple[float, float, float, float]

(1.0, 1.0, 1.0, 1.0)

metallic: float

1.0

roughness: float

1.0

albedo_texture: str | bytes | None

None

normal_texture: str | bytes | None

None

metallic_roughness_texture: str | bytes | None

None

emissive_texture: str | bytes | None

None

ao_texture: str | bytes | None

None

double_sided: bool

False

alpha_mode: str

‘OPAQUE’

alpha_cutoff: float

0.5

emissive: tuple[float, float, float]

(0.0, 0.0, 0.0)

emissive_strength: float

1.0

uv_offset: tuple[float, float]

(0.0, 0.0)

uv_scale: tuple[float, float]

(1.0, 1.0)

uv_rotation: float

0.0

class simvx.graphics.assets.mesh_loader.GLTFNode[source]

Scene graph node with optional mesh reference.

primitives carries every glTF mesh primitive attached to this node as (scene_mesh_index, material_index) pairs (indices into GLTFScene.meshes / GLTFScene.materials; material index -1 means none). Empty for meshless nodes.

name: str = <Multiline-String>
primitives: list[tuple[int, int]]

‘field(…)’

transform: numpy.ndarray

‘field(…)’

children: list[int]

‘field(…)’

skin_index: int | None

None

light_index: int | None

None

camera_index: int | None

None

class simvx.graphics.assets.mesh_loader.GLTFScene[source]

Complete loaded glTF scene.

meshes: list[tuple[simvx.graphics.types.VertexStreams, numpy.ndarray]]

‘field(…)’

materials: list[simvx.graphics.assets.mesh_loader.GLTFMaterial]

‘field(…)’

nodes: list[simvx.graphics.assets.mesh_loader.GLTFNode]

‘field(…)’

root_nodes: list[int]

‘field(…)’

skins: list[dict[str, Any]]

‘field(…)’

animations: list[dict[str, Any]]

‘field(…)’

lights: list[dict[str, Any]]

‘field(…)’

cameras: list[dict[str, Any]]

‘field(…)’

mesh_extras: list[dict[str, numpy.ndarray]]

‘field(…)’

simvx.graphics.assets.mesh_loader.load_gltf(file_path: str) simvx.graphics.assets.mesh_loader.GLTFScene[source]

Load complete glTF scene with all meshes, materials, textures, and hierarchy.

Returns a GLTFScene with all data extracted and ready for import. Dispatches to pygltflib when available, falling back to a stdlib parser suitable for simple .gltf + .bin + image bundles (Pyodide / web).