Header menu logo Mibo

Camera3D Module

Helper functions for 3D Cameras (Perspective projection).

Use these for first-person, third-person, or any 3D game rendering.

Functions and values

Function or value Description

boundingFrustum camera

Full Usage: boundingFrustum camera

Parameters:
Returns: BoundingFrustum

Calculates the BoundingFrustum for the camera.

The frustum represents the visible volume of the camera. Useful for 3D culling (octree queries, sphere/box visibility checks).

camera : Camera
Returns: BoundingFrustum
Example

 let frustum = Camera3D.boundingFrustum camera
 if Culling.isVisible frustum entitySphere then
     // Entity is visible, render it
val frustum: obj

lookAt position target up fov aspectRatio nearPlane farPlane

Full Usage: lookAt position target up fov aspectRatio nearPlane farPlane

Parameters:
    position : Vector3 - Camera position in world space
    target : Vector3 - Point the camera is looking at
    up : Vector3 - Up vector (typically Vector3.Up)
    fov : float32 - Field of view in radians (e.g., MathHelper.PiOver4)
    aspectRatio : float32 - Width / Height of the viewport
    nearPlane : float32 - Near clipping distance (objects closer are not rendered)
    farPlane : float32 - Far clipping distance (objects farther are not rendered)

Returns: Camera

Creates a camera that looks at a target from a position.

position : Vector3

Camera position in world space

target : Vector3

Point the camera is looking at

up : Vector3

Up vector (typically Vector3.Up)

fov : float32

Field of view in radians (e.g., MathHelper.PiOver4)

aspectRatio : float32

Width / Height of the viewport

nearPlane : float32

Near clipping distance (objects closer are not rendered)

farPlane : float32

Far clipping distance (objects farther are not rendered)

Returns: Camera
Example

 let camera = Camera3D.lookAt
     (Vector3(0f, 10f, 20f))  // position
     Vector3.Zero              // target
     Vector3.Up                // up
     MathHelper.PiOver4        // 45° FOV
     (16f / 9f)                // aspect ratio
     0.1f                      // near plane
     1000f                     // far plane
val camera: obj

orbit target yaw pitch radius fov aspect near far

Full Usage: orbit target yaw pitch radius fov aspect near far

Parameters:
    target : Vector3 - Point the camera orbits around
    yaw : float32 - Horizontal rotation angle in radians
    pitch : float32 - Vertical rotation angle in radians
    radius : float32 - Distance from target
    fov : float32 - Field of view in radians
    aspect : float32 - Aspect ratio
    near : float32 - Near plane
    far : float32 - Far plane

Returns: Camera

Creates an orbiting camera using spherical coordinates.

Useful for third-person cameras, inspection views, or editor cameras.

target : Vector3

Point the camera orbits around

yaw : float32

Horizontal rotation angle in radians

pitch : float32

Vertical rotation angle in radians

radius : float32

Distance from target

fov : float32

Field of view in radians

aspect : float32

Aspect ratio

near : float32

Near plane

far : float32

Far plane

Returns: Camera

screenPointToRay camera screenPos viewport

Full Usage: screenPointToRay camera screenPos viewport

Parameters:
Returns: Ray

Creates a ray from screen coordinates for mouse/touch picking.

The ray originates at the camera's near plane at the screen position and points into the scene. Use Ray.Intersects to test against geometry.

camera : Camera
screenPos : Vector2
viewport : Viewport
Returns: Ray
Example

 let ray = Camera3D.screenPointToRay camera mousePos viewport
 if ray.Intersects(boundingBox).HasValue then
     // Mouse is hovering over object
val ray: obj

Type something to start searching.