Camera ​
Local camera state and screen-space conversions.
| Function | Returns | Description |
|---|---|---|
camera.get_position() | vec3 | Camera world position |
camera.get_view_angles() | vec3 | Pitch, yaw, roll in degrees |
camera.get_forward() | vec3 | Unit vector pointing where camera is looking |
camera.get_fov() | number | Field of view in degrees |
camera.get_screen_size() | vec2 | Screen dimensions: .x is width, .y is height |
camera.world_to_screen(vec3) | vec2 | nil | Pixel position with .x / .y, or nil if behind the camera |
lua
local pos = camera.world_to_screen(vec3(100, 200, 50))
if pos then
draw.text(pos.x, pos.y, "here", 0xFFFFFFFF)
endworld_to_screen is also available as draw.world_to_screen. Same function.