3D Camera
3D camera methods control the viewpoint used when rendering 3D content. Cameras can be positioned, rotated, aimed at targets, and configured with custom projection settings.
Methods
Section titled “Methods”clearZBuffer
Section titled “clearZBuffer”Clears the depth buffer for a display.
Call this before rendering a new 3D frame to ensure old depth information does not affect the current frame.
Requires: DisplayID
Example
Section titled “Example”gpu.clearZBuffer(displayId)getCameraInfo
Section titled “getCameraInfo”Returns the current camera configuration for a display.
Requires: DisplayID
Returns: Camera information table.
Example
Section titled “Example”local info = gpu.getCameraInfo(displayId)
print(info)lookAt
Section titled “lookAt”Rotates the camera to face a world position.
Requires: DisplayID, targetX : number, targetY : number, targetZ : number
Example
Section titled “Example”gpu.lookAt(displayId, 0, 0, 0)setCameraPosition
Section titled “setCameraPosition”Moves the camera to a specific world position.
Requires: DisplayID, x : number, y : number, z : number
Example
Section titled “Example”gpu.setCameraPosition(displayId, 0, 2, 5)setCameraRotation
Section titled “setCameraRotation”Sets the camera rotation directly.
Rotation values are provided as:
pitch- rotation around the X axisyaw- rotation around the Y axisroll- rotation around the Z axis
Requires: DisplayID, pitch : number, yaw : number, roll : number
Example
Section titled “Example”gpu.setCameraRotation(displayId, 10, 30, 0)setCameraTarget
Section titled “setCameraTarget”Sets the point the camera should target.
This can be used instead of manually controlling rotation.
Requires: DisplayID, x : number, y : number, z : number
Example
Section titled “Example”gpu.setCameraTarget(displayId, 0, 0, 0)setupCamera
Section titled “setupCamera”Initializes the camera projection settings.
Common values:
fov: 60near: 0.1far: 1000
Requires: DisplayID, fov : number, near : number, far : number
Returns: Camera information table.
Example
Section titled “Example”local info = gpu.setupCamera( displayId, 60, 0.1, 1000)