simvx.core.nodes_3d.multimesh

MultiMesh and MultiMeshInstance3D – instanced rendering.

Module Contents

Classes

MultiMesh

Resource holding per-instance transforms for mass rendering.

MultiMeshInstance3D

Renders thousands of instances of a single mesh efficiently.

API

class simvx.core.nodes_3d.multimesh.MultiMesh(mesh=None, instance_count: int = 0)[source]

Resource holding per-instance transforms for mass rendering.

Stores transforms (and optional per-instance colours / custom data) as flat numpy arrays suitable for bulk GPU upload. Used by MultiMeshInstance3D.

Usage::

mm = MultiMesh(mesh=Mesh.cube(), instance_count=1000)
for i in range(1000):
    mm.set_instance_transform(i, mat4_from_trs(Vec3(i, 0, 0), Quat(), Vec3(1)))

Initialization

__slots__

(‘mesh’, ‘instance_count’, ‘transforms’, ‘colours’, ‘custom_data’, ‘_dirty’, ‘_colour_materials’)

set_instance_transform(index: int, transform: numpy.ndarray) None[source]

Set the 4x4 model matrix for a single instance.

set_instance_colour(index: int, colour: tuple[float, ...]) None[source]

Set per-instance RGBA colour override. Allocates colour array on first use.

set_instance_custom_data(index: int, data: tuple[float, ...] | numpy.ndarray) None[source]

Set per-instance vec4 custom data. Allocates array on first use.

set_all_transforms(transforms: numpy.ndarray) None[source]

Bulk-set all instance transforms from an (N, 4, 4) array.

set_all_colours(colours: numpy.ndarray) None[source]

Bulk-set all instance colours from an (N, 4) array.

set_all_custom_data(data: numpy.ndarray) None[source]

Bulk-set all custom data from an (N, 4) array.

set_buffer(transforms: numpy.ndarray) None[source]

Bulk-set transforms from an (N, 4, 4) array, resizing if needed.

set_instance_count(count: int) None[source]

Set instance count, allocating/resizing buffers as needed.

resize(new_count: int) None[source]

Resize the instance arrays, preserving existing data where possible.

class simvx.core.nodes_3d.multimesh.MultiMeshInstance3D(position=None, rotation=None, scale=None, **kwargs)[source]

Bases: simvx.core.nodes_3d.node3d.Node3D

Renders thousands of instances of a single mesh efficiently.

Attach a :class:MultiMesh resource and the renderer will submit all instances in a single batch using the existing multi-draw indirect pipeline.

Usage::

mm = MultiMesh(mesh=Mesh.cube(), instance_count=500)
# ... populate transforms ...
node = MultiMeshInstance3D(multi_mesh=mm)
scene.add_child(node)

Initialization

multi_mesh

‘Property(…)’

material

‘Property(…)’

property instance_count: int

Total instance count from the attached MultiMesh (0 if none).

property visible_instance_count: int

Number of visible instances. Returns -1 to indicate all instances are visible.

property model_matrix: numpy.ndarray

Global model matrix for this node (applied to all instances).

render_layer

‘Property(…)’

property position
property rotation: simvx.core.math.types.Quat
property scale
property rotation_degrees: simvx.core.math.types.Vec3
property world_position: simvx.core.math.types.Vec3
property world_rotation: simvx.core.math.types.Quat
property world_scale: simvx.core.math.types.Vec3
property forward: simvx.core.math.types.Vec3
property right: simvx.core.math.types.Vec3
property up: simvx.core.math.types.Vec3
translate(offset: tuple[float, float, float] | numpy.ndarray)
translate_global(offset: tuple[float, float, float] | numpy.ndarray)
rotate(axis: tuple[float, float, float] | numpy.ndarray, angle: float)
rotate_x(angle: float)
rotate_y(angle: float)
rotate_z(angle: float)
look_at(target: tuple[float, float, float] | numpy.ndarray, up=None)
set_render_layer(index: int, enabled: bool = True) None
is_on_render_layer(index: int) bool
wrap_bounds(bounds: tuple[float, float, float] | numpy.ndarray, margin: float = 1.0)
strict_errors: ClassVar[bool]

True

script_error_raised

‘Signal(…)’

classmethod __init_subclass__(**kwargs)
property name: str
property process_mode: simvx.core.descriptors.ProcessMode
reset_error() None
add_child(node: simvx.core.node.Node) simvx.core.node.Node
remove_child(node: simvx.core.node.Node)
reparent(new_parent: simvx.core.node.Node)
get_node(path: str) simvx.core.node.Node
find_child(name: str, recursive: bool = False) simvx.core.node.Node | None
find(node_type: type, recursive: bool = True) simvx.core.node.Node | None
find_all(node_type: type, recursive: bool = True) list
property path: str
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) bool
ready() None
enter_tree() None
exit_tree() None
process(dt: float) None
physics_process(dt: float) None
draw(renderer) None
input_event(event: simvx.core.events.InputEvent) None
input(event: simvx.core.events.TreeInputEvent) None
unhandled_input(event: simvx.core.events.TreeInputEvent) None
start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
clear_children()
destroy()
property app
property tree: simvx.core.scene_tree.SceneTree
get_tree() simvx.core.scene_tree.SceneTree
__getitem__(key: str)
classmethod get_properties() dict[str, simvx.core.descriptors.Property]
__repr__()