sprunk-engine

    A 3D camera class that manages projection, view transformations, and screen-to-world raycasting for a rendering engine.

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    • Creates a new Camera behavior.

      Parameters

      • fov: number = ...

        Field of view in radians.

      • aspect: number = 1

        Aspect ratio (width / height).

      • near: number = 0.1

        Near clipping plane.

      • far: number = 100

        Far clipping plane.

      Returns Camera

    Properties

    _projectionMatrix: Float32Array

    Accessors

    Methods

    • Detach this behavior from the GameObject it is attached to.

      Parameters

      • from: GameObject

        The GameObject to detach this behavior from.

      Returns void

      Error if the behavior is not attached to the GameObject.

    • Returns the Model-View-Projection (MVP) matrix for the given model matrix.

      Parameters

      • modelMatrix: Float32Array

        The model matrix of the object.

      Returns Float32Array

      The MVP matrix as a mat4.

    • Protected

      Observe a LogicBehavior and call the observer function when the data changes.

      Type Parameters

      Parameters

      • BehaviorClass: new (...args: any[]) => T

        The specific LogicBehavior class type to observe.

      • observer: (data: U) => void

        The function to call when the data changes.

      Returns void

    • Converts a 2D mouse screen position to a 3D world space direction (ray). This function assumes that the screen position corresponds to the mouse position on a 2D screen. It unprojects the mouse position into a direction in 3D space using the camera's view and projection matrices.

      Parameters

      • screenSpacePosition: Vector2

        The 2D screen position of the mouse.

      Returns Vector3

      The normalized direction vector of the ray in world space.

    • Like onEnable, but should only be for internal use, so some non-abstact direct behaviors could expose attachedOn to the user.

      Parameters

      • attachedOn: GameObject

        The GameObject this behavior is attached to.

      Returns void

      Error if the behavior is already attached to a GameObject.

    • Protected

      Called every frame. Override this method to add custom behavior.

      Parameters

      • _deltaTime: number

        The time in seconds since the last frame.

        • This method should not be called directly except by the GameEngineWindowComponent.

      Returns void

    MMNEPVFCICPMFPCPTTAAATR