nodes/meshes.pyΒΆ

Part of Q1K3.

 1"""Cached mesh primitives for Q1K3 port.
 2
 3Mesh objects are heavy to build but identical for many entities: every block,
 4enemy, projectile and particle in the port is a scaled cube. Build one shared
 5cube and instance it via separately-positioned ``MeshInstance3D`` nodes.
 6"""
 7
 8from __future__ import annotations
 9
10from simvx.core import Mesh
11
12_CUBE: Mesh | None = None
13
14
15def cube() -> Mesh:
16    """Shared 1x1x1 cube. Caller scales via ``MeshInstance3D.scale``."""
17    global _CUBE
18    if _CUBE is None:
19        _CUBE = Mesh.cube(size=1.0)
20    return _CUBE