natiny.camera.bind
natiny.camera.bind(cam [, fn])
Binds a camera. All subsequent 3D draw calls use this camera until it is unbound or another one is bound.
If an optional function fn is provided, the bind ends when it returns.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
cam |
number |
Camera handle from natiny.camera.create |
|
fn |
function |
nil |
Callback executed while the camera is bound |
Example
natiny.camera.bind(cam)
natiny.camera.unbind()
natiny.camera.bind(cam, function()
draw_scene()
end)
Notes
- Binding another camera replaces the current one.
natiny.camera.unbindselects the default 2D projection; it does not restore the previous camera. - With
fn, Lua unbinds the camera even if the callback raises an error, then propagates the error.