Arcball camera

How to create an arcball camera:

let camera = create_node(NodeData(name = "arcball_camera"))
// it's not neccessary to add Camera component, ArcballCamera will add it automatically if it's not present
camera.add_component(new ArcballCamera(distance = 5f, focusPosition = float3(0, 1, 0), euler = float3(PI / 6f, PI, 0f)))

Or if you want more control

let camera = create_node(NodeData(name = "arcball_camera"))
camera.add_component(new Camera(fov = 65. * TO_RAD)) // add Camera component with custom fov parameter
camera.add_component(new ArcballCamera(
    minFocusDistance = 1f,
    distance = 10f,
    focusPosition = float3(0, 1, 0),
    euler = float3(PI / 6f, PI, 0f),
    lerpTime = 0.05f,
    useScaledTime = false
))

Classes

ArcballCamera : Component

Note

Camera component is automatically added to the node if it is not already present

Represents the arcball camera component. The camera orbits around a focus point at a certain distance, and can be rotated and zoomed in/out by user input.

Control scheme:

  • Rotate: Hold right mouse button and move the mouse to rotate the camera around the focus point.

  • Pan: Hold left or middle mouse button and move the mouse to pan the camera (move the focus point parallel to the view plane).

  • Zoom: Use mouse wheel to zoom in/out (change the distance from the camera to the focus point). The zoom will be clamped to a minimum distance to prevent going through the focus point.

Fields:
  • minFocusDistance : float = 1f - The minimum allowed distance from the focus point. This is used to prevent the camera from going through the focus point when zooming in.

  • distance : float = 10f - The distance from the focus point. The camera will be positioned at this distance from the focus point.

  • focusPosition : float3 - The position of the focus point. The camera will orbit around this point.

  • euler : float3 - The euler angles of the camera rotation. The camera will be rotated by these angles from the default orientation (looking towards -Z, with Y as up).

  • lerpTime : float = 0.05f - The time it takes for the camera to interpolate to its target position and rotation in seconds.

  • useScaledTime : bool = false - Whether to use scaled game time for the camera movement. ‘get_delta_time()’ or ‘get_unscaled_delta_time()’ will be used based on this flag.