natiny.mesh.reload
natiny.mesh.reload(mesh, resource)
Replaces the geometry inside an existing mesh. The handle does not change.
Parameters
| Name | Type | Description |
|---|---|---|
mesh |
number |
Live mesh handle from natiny.mesh.load |
resource |
number |
Resource handle containing a glTF or GLB model |
Example
local mesh = natiny.mesh.load(resource)
natiny.model.set_mesh(model, mesh)
local replacement = natiny.resource.load("models/tree.glb")
-- the model keeps its place in the scene and shows the new shape
natiny.mesh.reload(mesh, replacement)
natiny.resource.destroy(replacement)
Notes
- Raises an error if
meshis not live or the resource cannot be loaded as glTF 2.0. A failure leaves the mesh exactly as it was. - The resource data is copied during the call and may be destroyed after a successful reload.