You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ctx.res.Meshes() turns a model path or Mesh3D geometry into a MeshID that 3D nodes render. Loads return the ID the same frame and never block; the async decode and GPU upload finish in the background. Beyond loading, the module can build meshes from CPU vertex data, read a mesh's geometry back, and overwrite it, which is what procedural geometry and runtime mesh editing need.
Use Cases
Streaming level geometry: mesh_load!(ctx.res, "res://meshes/pillar.glb") and assign the MeshID to a mesh node.
Procedural geometry: build a Mesh3D (terrain patch, generated wall) and register it with mesh_create!.
Runtime mesh editing: mesh_get_data! to read CPU vertices, deform them, then mesh_write! the modified Mesh3D back into the same ID.
Read without a full copy: get_data_shared returns Arc<Mesh3D> (clones the Arc, not the vertex data); pair w/ Arc::make_mut for read-modify-write.
Deforming built-in primitives: get_data returns canonical CPU geometry for engine preset meshes immediately, so a script can start from a cube or sphere and reshape it.
Decoding downloaded models: create_from_bytes for engine PMESH or glTF/GLB mesh index 0.
Preloading and memory control: mesh_reserve! to pin a mesh, mesh_is_loaded! to poll readiness, mesh_drop! to free it.
Ownership And Choice
The resource cache owns mesh data; render nodes carry MeshID handles. Inject a typed ID for an authored mesh choice and load through ctx.res for generated, downloaded, or runtime-selected data. Keep collision and render ownership explicit: a visual mesh does not by itself define gameplay collision unless the chosen node/path creates it.
Context
Script context path: ctx.res
Module access: ctx.res.Meshes()
Mesh loads return a MeshID immediately and do not block the frame; the renderer uses the mesh once async decode/upload completes.
Geometry type: perro_render_bridge::Mesh3D.
Lifecycle examples stay inside lifecycle! because script hooks get API from the macro expansion.
Runtime Bytes
Use runtime bytes when mesh data is already in memory.
Reading a mesh's CPU geometry to inspect or deform it.
Fails when / edge behavior
Built-in preset IDs return canonical CPU vertices, indices, one surface range, uv, and matching paint_uv immediately, including before renderer upload completes. Other IDs return None when CPU mesh data is unavailable, stale, or the target type does not match.