Skip to content

@modoki/engine / index / registerRuntimeMeshTemplate

Function: registerRuntimeMeshTemplate()

registerRuntimeMeshTemplate(key, geometry, material): void

Register a RUNTIME-BUILT mesh under a synthetic key so a normal Renderable3D can reference it (mesh = key) and render through the standard renderer path (resolveMeshTemplatenew THREE.Mesh(template.geometry, material)).

The key must be a plain string that is NOT a GUID and NOT a *.mesh.json path — those route through the manifest/asset-fetch branches of resolveMeshTemplate and would never hit this cache entry. A synthetic key (e.g. sling:field:cap) lands in the same legacy-key slot primitives/sprite names use (cache.get(key)).

For procedurally generated, Transient content (e.g. the sling field mesher) that builds geometry at runtime instead of loading a GLB. The caller owns the geometry (disposed here on overwrite, and by unregisterRuntimeMeshTemplate); the material is typically shared/scene-owned (resolve it via resolveMaterial) and is NOT disposed by these helpers. Overwriting an existing key disposes the previous geometry, so a rebuild is idempotent.

Parameters

key

string

geometry

BufferGeometry

material

Material

Returns

void

Built with Modoki.