Module src.backends.camera

Camera module for the Cholidean harmony structure viewer.

Manages camera position, yaw/pitch orientation, movement, tweened resets, and input bindings.

Tables

M Module table

Tween/reset orientation state (private)

View Public view snapshot (updated each frame)
init (dream) Initialize the camera module.
update (dt) Update the camera each frame.
mousemoved (dx, dy) Handle mouse‐drag movements.
pressedAction (action) Handle action bindings (reset view or FOV).


Tables

M
Module table

Tween/reset orientation state (private)

View
Public view snapshot (updated each frame)

Fields:

  • yaw number Current yaw in radians.
  • pitch number Current pitch in radians.
  • Pos table Current position {x,y,z}.
  • fov number Current FOV in degrees.
init (dream)
Initialize the camera module. Sets starting position/orientation, FOV, and mouse callbacks.

Parameters:

  • dream table Dream framework instance containing dream.camera.

Usage:

    camera:init(dream)
update (dt)
Update the camera each frame. Handles orientation resets, FOV changes, panning, rotation, and mouse/grab toggles.

Parameters:

  • dt number Delta time since last update.

Usage:

    camera:update(dt)
mousemoved (dx, dy)
Handle mouse‐drag movements. Right‐button rotates, middle‐button pans along view direction.

Parameters:

  • dx number Mouse movement in x (pixels).
  • dy number Mouse movement in y (pixels).

Usage:

    camera:mousemoved(dx, dy)
pressedAction (action)
Handle action bindings (reset view or FOV).

Parameters:

Returns:

    boolean True if the action was handled.

Usage:

    if camera:pressedAction(A.RESET_VIEW) then
generated by LDoc 1.5.0 Last updated 2025-09-04 12:20:37