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

    Interface CameraInterfaceData

    Interface representing the core data and API of a camera.

    interface CameraInterfaceData {
        activeStrategyType: string;
        aspect: number;
        behaviors: Behavior[];
        pendingDx: number;
        pendingDy: number;
        phi: number;
        position: Vector3D;
        projection: AbstractProjection;
        strategy: CameraStrategy;
        target: Vector3D;
        theta: number;
        up: Vector3D;
        viewMatrix: Float32Array;
        viewMatrix4: Matrix4;
        viewProjectionMatrix: Float32Array;
        viewProjectionMatrix4: Matrix4;
        addBehavior(behavior: Behavior): this;
        addEffect(effect: CameraEffect): void;
        applyEffect(
            type: CameraEffectType,
            intensity?: number,
            duration?: number,
        ): void;
        removeBehavior(behavior: Behavior): this;
        screenToWorld(screenX: number, screenY: number): Vector3D;
        setConstraints(constraints?: CameraConstraints): void;
        setStrategy(type: CameraStrategyType): void;
        update(
            targetPos: Vector3D,
            dx: number,
            dy: number,
            deltaTime?: number,
        ): void;
        updateProjectionMatrix(): void;
        updateViewMatrix(): void;
        zoom(delta: number): void;
    }

    Implemented by

    Index

    Properties

    activeStrategyType: string

    The unique type identifier of the active strategy.

    aspect: number

    The aspect ratio (width / height).

    behaviors: Behavior[]

    The behaviors attached to this camera.

    pendingDx: number

    Horizontal rotation delta accumulated by behaviors.

    pendingDy: number

    Vertical rotation delta accumulated by behaviors.

    phi: number

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

    position: Vector3D

    The position of the camera in world space.

    projection: AbstractProjection

    The active projection (e.g., Perspective, Orthographic).

    strategy: CameraStrategy

    The currently active camera control strategy.

    target: Vector3D

    The target point the camera is looking at.

    theta: number

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

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

    viewMatrix: Float32Array

    The view matrix as a Float32Array.

    viewMatrix4: Matrix4

    The view matrix as a Matrix4 instance.

    viewProjectionMatrix: Float32Array

    The combined view-projection matrix as a Float32Array.

    viewProjectionMatrix4: Matrix4

    The combined view-projection matrix as a Matrix4 instance.

    Methods

    • 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.

      • OptionaldeltaTime: number

        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