Header menu logo Mibo.Raylib

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

fromRaylib cam

Full Usage: fromRaylib cam

Parameters:
Returns: Camera

Convert a raylib Camera3D to a Mibo Camera by computing view and projection matrices.

cam : Camera3D
Returns: Camera

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.UnitY)
    fov : float32 - Field of view in radians (e.g., MathF.PI / 4.0f)
    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.UnitY)

fov : float32

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

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
     (MathF.PI / 4.0f)        // 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

overlay camera bounds

Full Usage: overlay camera bounds

Parameters:
Returns: Camera3DConfig

Picture-in-picture overlay. No post-process by default.

camera : Camera3D
bounds : Rectangle
Returns: Camera3DConfig

render camera

Full Usage: render camera

Parameters:
Returns: Camera3DConfig

Create a rendering config from a raylib camera. Defaults: fullscreen, no clear, all post-process passes.

camera : Camera3D
Returns: Camera3DConfig

screenPointToRay camera screenPos viewportWidth viewportHeight

Full Usage: screenPointToRay camera screenPos viewportWidth viewportHeight

Parameters:
    camera : Camera - 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 : Camera

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

Full Usage: splitScreenBottom camera clearColor

Parameters:
Returns: Camera3DConfig

Split-screen bottom half. Clears with given color.

camera : Camera3D
clearColor : Color
Returns: Camera3DConfig

splitScreenLeft camera clearColor

Full Usage: splitScreenLeft camera clearColor

Parameters:
Returns: Camera3DConfig

Split-screen left half. Clears with given color.

camera : Camera3D
clearColor : Color
Returns: Camera3DConfig

splitScreenRight camera clearColor

Full Usage: splitScreenRight camera clearColor

Parameters:
Returns: Camera3DConfig

Split-screen right half. Clears with given color.

camera : Camera3D
clearColor : Color
Returns: Camera3DConfig

splitScreenTop camera clearColor

Full Usage: splitScreenTop camera clearColor

Parameters:
Returns: Camera3DConfig

Split-screen top half. Clears with given color.

camera : Camera3D
clearColor : Color
Returns: Camera3DConfig

withClear color config

Full Usage: withClear color config

Parameters:
Returns: Camera3DConfig

Clear with this color before rendering.

color : Color
config : Camera3DConfig
Returns: Camera3DConfig

withPostProcess passes config

Full Usage: withPostProcess passes config

Parameters:
Returns: Camera3DConfig

Use only specific post-process pass indices.

passes : int[]
config : Camera3DConfig
Returns: Camera3DConfig

withViewport viewport config

Full Usage: withViewport viewport config

Parameters:
Returns: Camera3DConfig

Set viewport in normalized screen coordinates (0-1).

viewport : Rectangle
config : Camera3DConfig
Returns: Camera3DConfig

withoutPostProcess config

Full Usage: withoutPostProcess config

Parameters:
Returns: Camera3DConfig

Disable post-processing for this camera.

config : Camera3DConfig
Returns: Camera3DConfig

Type something to start searching.