Skip to Content
defold-typescript libraries
whiteboxdev

whiteboxdev/library-defold-rendy/rendy

A versatile camera suite and render pipeline

  • GitHub: whiteboxdev/library-defold-rendy — pinned to b72ee24
    1. Pick a release from whiteboxdev/library-defold-rendy releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as rendy from "rendy.rendy"

Functions

create_camera(camera_id: CameraId)

Creates a camera. This function is called automatically by the rendy.go game object.

Parameters

  • camera_id: CameraId — The identifier for the camera.

destroy_camera(camera_id: CameraId)

Destroys a camera. This function is called automatically by the rendy.go game object.

Parameters

  • camera_id: CameraId — The identifier for the camera to be destroyed.

set(camera_id: CameraId, property: Hash | string, value: any)

Sets a camera property. This function replaces the standard go.set().

Parameters

  • camera_id: CameraId — The identifier for the camera.
  • property: Hash | string — The property to be set.
  • value: any — The value to set the property to.

get(camera_id: CameraId, property: Hash | string): unknown

Gets a camera property. This function is equivalent to the standard go.get().

Parameters

  • camera_id: CameraId — The identifier for the camera.
  • property: Hash | string — The property to be retrieved.

Returns

  • unknown — The value of the specified property.

get_display_size(): Vector3

Gets the initial window size specified in the game.project file.

Returns

  • Vector3 — The initial window size.

get_window_size(): Vector3

Gets the current window size.

Returns

  • Vector3 — The current window size.

get_stack(screen_x: number, screen_y: number): CameraId[]

Gets camera ids whose viewports intersect a screen position.

Parameters

  • screen_x: number — The x-coordinate of the screen position.
  • screen_y: number — The y-coordinate of the screen position.

Returns

  • CameraId[] — An array of camera ids.

shake(camera_id: CameraId, radius: number, intensity: number, duration: number, scaler?: number)

Starts a camera shake animation. If the camera is already shaking, then the animation is cancelled and restarted. The radius is increased or decreased over time if the scaler argument is ~= 1.

Parameters

  • camera_id: CameraId — The identifier for the camera.
  • radius: number — The initial radius of the camera shake.
  • intensity: number — The intensity of the camera shake.
  • duration: number — The duration of the camera shake animation.
  • scaler?: number — Optional scaler argument for adjusting the radius over time.

cancel_shake(camera_id: CameraId)

Cancels an ongoing camera shake animation.

Parameters

  • camera_id: CameraId — The identifier for the camera.

screen_to_world(camera_id: CameraId, screen_position: Vector3): Vector3

Converts a screen position to a world position. The screen position's z component maps to the camera frustum's z component.

Parameters

  • camera_id: CameraId — The identifier for the camera.
  • screen_position: Vector3 — The screen position to be converted.

Returns

  • Vector3 — The corresponding world position.

world_to_screen(camera_id: CameraId, world_position: Vector3): Vector3

Converts a world position to a screen position. The world position's z component maps to the camera frustum's z component.

Parameters

  • camera_id: CameraId — The identifier for the camera.
  • world_position: Vector3 — The world position to be converted.

Returns

  • Vector3 — The corresponding screen position.

Variables

cameras: LuaMap<CameraId, unknown>

Every camera except the GUI camera, keyed by camera id. Exposed only because the rendy.render_script file needs write-access to it; reach for set and get rather than accessing or manipulating it directly.

display_width: number

Initial width of the window, specified in the game.project file. Exposed only because the rendy.render_script file needs write-access to it; it is unset until that script has run.

display_height: number

Initial height of the window, specified in the game.project file. Exposed only because the rendy.render_script file needs write-access to it; it is unset until that script has run.

window_width: number

Current width of the window. Exposed only because the rendy.render_script file needs write-access to it; it is unset until that script has run.

window_height: number

Current height of the window. Exposed only because the rendy.render_script file needs write-access to it; it is unset until that script has run.

Types

type CameraId = Hash | string

On this page