Small World Engine API Reference - v0.78.00
    Preparing search index...

    Class Camera

    Standard implementation of the CameraInterfaceData.

    Implements

    Index
    behaviors: Behavior[] = []

    The behaviors attached to this camera.

    jitterX: number = 0

    Sub-pixel jitter offset (NDC units) for TAA, baked into viewProjectionMatrix for every consumer rather than a separate matrix -- see docs/adr/0002-taa-jitter-shared-viewproj-matrix.md.

    jitterY: number = 0
    pendingDx: number = 0

    Horizontal rotation delta accumulated by behaviors.

    pendingDy: number = 0

    Vertical rotation delta accumulated by behaviors.

    phi: number = 0

    The rotation angle around the X-axis (pitch).

    position: Vector3D = ...

    The position of the camera in world space.

    target: Vector3D = ...

    The target point the camera is looking at.

    theta: number = 0

    The rotation angle around the Y-axis (yaw).

    up: Vector3D = ...

    The up vector of the camera (usually 0, 1, 0).

    • Projects a 3D world position into Normalized Device Coordinates (NDC: [-1, 1] on X, Y, Z). After projection, Z >= -1 means the point is in front of the camera (true NDC depth; with OpenGL-style depth, in-front points closer than ~2x the near plane legitimately have negative NDC Z, so callers MUST NOT gate on Z > 0). The sentinel Z = -2 marks a point behind the camera.

      Parameters

      • worldPos: Vector3D

        The 3D world coordinates.

      • result: Vector3D = ...

        Optional Vector3D to receive the result.

      Returns Vector3D

      The projected NDC vector.

    • Maps screen coordinates (NDC -1 to 1) to world coordinates on the Y=0 plane.

      Parameters

      • screenX: number

        Normalized X coordinate (-1 to 1).

      • screenY: number

        Normalized Y coordinate (-1 to 1).

      Returns Vector3D

      The world position on the Y=0 plane.

    • Performs the movement and logic of the active strategy.

      Parameters

      • targetPos: Vector3D

        The target position to follow.

      • dx: number

        The horizontal rotation delta.

      • dy: number

        The vertical rotation delta.

      • deltaTime: number = 0.016

        Elapsed time since the last frame.

      Returns void

    • Adjusts the zoom level (radius, FOV, or orthographic bounds).

      Parameters

      • delta: number

        The zoom delta.

      Returns void