Header menu logo Mibo

Camera3D Module

Helper functions for 3D Cameras (Perspective / Orthographic projection).

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

Functions and values

Function or value Description

asOrthographic camera

Full Usage: asOrthographic camera

Parameters:
Returns: Camera3D
Modifiers: inline

Switch the camera to orthographic projection.

FovY is reinterpreted as the view height in world units.

camera : Camera3D
Returns: Camera3D

create position target fovY

Full Usage: create position target fovY

Parameters:
    position : Vector3 - Camera position in world space.
    target : Vector3 - Point the camera is looking at.
    fovY : float32 - Vertical field of view in radians (e.g., MathF.PI / 4.0f).

Returns: Camera3D
Modifiers: inline

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

Defaults: up = Vector3.Up, near = 0.1f, far = 1000f. Override with Camera3D.withUp / Camera3D.withNearFar. The aspect ratio is computed from the active viewport at render time.

position : Vector3

Camera position in world space.

target : Vector3

Point the camera is looking at.

fovY : float32

Vertical field of view in radians (e.g., MathF.PI / 4.0f).

Returns: Camera3D
Example

 let camera = Camera3D.create (Vector3(0.f, 10.f, 20.f)) Vector3.Zero (MathF.PI / 4.f)
val camera: obj

orbit target yaw pitch radius fovY

Full Usage: orbit target yaw pitch radius fovY

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.
    fovY : float32 - Vertical field of view in radians.

Returns: Camera3D
Modifiers: inline

Creates an orbiting perspective camera using spherical coordinates.

Useful for third-person cameras, inspection views, or editor cameras. Defaults: up = Vector3.Up, near = 0.1f, far = 1000f.

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.

fovY : float32

Vertical field of view in radians.

Returns: Camera3D

render camera

Full Usage: render camera

Parameters:
Returns: Camera3DConfig
Modifiers: inline

Create a rendering config from a MonoGame 3D camera. Defaults: fullscreen, no clear.

camera : Camera3D
Returns: Camera3DConfig

screenPointToRay camera screenPos viewportWidth viewportHeight

Full Usage: screenPointToRay camera screenPos viewportWidth viewportHeight

Parameters:
    camera : Camera3D - The camera to compute the ray for.
    screenPos : Vector2 - The screen position in pixels.
    viewportWidth : float32 - Viewport width in pixels.
    viewportHeight : float32 - Viewport height in pixels.

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.

camera : Camera3D

The camera to compute the ray for.

screenPos : Vector2

The screen position in pixels.

viewportWidth : float32

Viewport width in pixels.

viewportHeight : float32

Viewport height in pixels.

Returns: Ray

splitScreenBottom camera clearColor bounds

Full Usage: splitScreenBottom camera clearColor bounds

Parameters:
    camera : Camera3D
    clearColor : Color
    bounds : Rectangle - Parent viewport bounds in pixels (typically the window size).

Returns: Camera3DConfig
Modifiers: inline

Split-screen bottom half. Clears with given color.

camera : Camera3D
clearColor : Color
bounds : Rectangle

Parent viewport bounds in pixels (typically the window size).

Returns: Camera3DConfig

splitScreenLeft camera clearColor bounds

Full Usage: splitScreenLeft camera clearColor bounds

Parameters:
    camera : Camera3D
    clearColor : Color
    bounds : Rectangle - Parent viewport bounds in pixels (typically the window size).

Returns: Camera3DConfig
Modifiers: inline

Split-screen left half. Clears with given color.

camera : Camera3D
clearColor : Color
bounds : Rectangle

Parent viewport bounds in pixels (typically the window size).

Returns: Camera3DConfig

splitScreenRight camera clearColor bounds

Full Usage: splitScreenRight camera clearColor bounds

Parameters:
    camera : Camera3D
    clearColor : Color
    bounds : Rectangle - Parent viewport bounds in pixels (typically the window size).

Returns: Camera3DConfig
Modifiers: inline

Split-screen right half. Clears with given color.

camera : Camera3D
clearColor : Color
bounds : Rectangle

Parent viewport bounds in pixels (typically the window size).

Returns: Camera3DConfig

splitScreenTop camera clearColor bounds

Full Usage: splitScreenTop camera clearColor bounds

Parameters:
    camera : Camera3D
    clearColor : Color
    bounds : Rectangle - Parent viewport bounds in pixels (typically the window size).

Returns: Camera3DConfig
Modifiers: inline

Split-screen top half. Clears with given color.

camera : Camera3D
clearColor : Color
bounds : Rectangle

Parent viewport bounds in pixels (typically the window size).

Returns: Camera3DConfig

withClear color config

Full Usage: withClear color config

Parameters:
Returns: Camera3DConfig
Modifiers: inline

Clear with this color before rendering.

color : Color
config : Camera3DConfig
Returns: Camera3DConfig

withNearFar nearPlane farPlane camera

Full Usage: withNearFar nearPlane farPlane camera

Parameters:
    nearPlane : float32
    farPlane : float32
    camera : Camera3D

Returns: Camera3D
Modifiers: inline

Set the near and far clipping planes (defaults are 0.1f / 1000f).

nearPlane : float32
farPlane : float32
camera : Camera3D
Returns: Camera3D

withUp up camera

Full Usage: withUp up camera

Parameters:
Returns: Camera3D
Modifiers: inline

Set the up vector (default is Vector3.Up).

up : Vector3
camera : Camera3D
Returns: Camera3D

withViewport viewport config

Full Usage: withViewport viewport config

Parameters:
Returns: Camera3DConfig
Modifiers: inline

Set viewport in pixel coordinates.

viewport : Rectangle
config : Camera3DConfig
Returns: Camera3DConfig

Type something to start searching.