omega-game-engine
    Preparing search index...

    Represents a camera in the 3D scene, responsible for generating the view and projection matrices.

    Hierarchy (View Summary)

    Indexable

    • [key: string]: any
    Index

    Constructors

    Properties

    _className: string = 'Camera'
    _serializationIgnoreKeys: string[]
    _uuid: string
    active: boolean = true

    A flag indicating if the entity is active and should be updated. *

    aspectRatio: number = 1

    The aspect ratio of the viewport.

    behaviours: EntityBehaviour[] = []

    A collection of behaviours attached to the entity. * *

    cameraType: CameraType = CameraType.PERSPECTIVE

    The type of projection this camera uses.

    destroyed: boolean = false

    A flag indicating if the entity has been destroyed. * *

    entityType: number = EntityType.STATIC

    The type of the entity (e.g., STATIC, DYNAMIC). *

    farPlane: number = 2000.0

    The distance to the far clipping plane.

    fieldOfView: number = 45

    The camera's field of view in DEGREES.

    name: string = ''
    nearPlane: number = 0.01

    The distance to the near clipping plane.

    orthoSize: number = 10.0

    The size of the orthographic projection (half the vertical size of the viewing volume).

    scene: Scene

    The scene to which this entity belongs. *

    show: boolean = true

    A flag indicating if the entity should be rendered. *

    tag: string = 'Camera'

    The tag for the camera entity.

    transform: Transform

    The transform component of the entity. *

    updateInEditor: boolean = false

    A flag to determine if the entity should update in the editor. *

    Accessors

    • get className(): string

      Returns string

    Methods

    • Retrieves the first behaviour of a specific type from the collection. *

      Type Parameters

      Parameters

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

        The constructor function of the type to filter by. *

      Returns undefined | T

      • The first behaviour found of the specified type, or undefined if none is found.
    • Retrieves all behaviours of a specific type from the collection. *

      Type Parameters

      Parameters

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

        The constructor function of the type to filter by. *

      Returns T[]

      • An array of behaviours of the specified type.
    • Unprojects a 2D screen coordinate to a specific 3D world position at a given distance from the camera. This is useful for placing objects directly in front of the camera based on mouse input.

      Parameters

      • screenPosition: vec2

        The 2D screen position in pixels (e.g., from mouse input).

      • distance: number

        The distance from the camera along the ray.

      • viewportWidth: number

        The width of the viewport in pixels.

      • viewportHeight: number

        The height of the viewport in pixels.

      Returns vec3

      The 3D world position.

    • Unprojects a 2D screen coordinate into a 3D ray in world space. This is useful for picking objects with the mouse.

      Parameters

      • screenPosition: vec2

        The 2D screen position in pixels (e.g., from mouse input).

      • viewportWidth: number

        The width of the viewport in pixels.

      • viewportHeight: number

        The height of the viewport in pixels.

      Returns { direction: vec3; origin: vec3 }

      An object containing the ray's origin and direction vectors.

    • Updates the camera each frame.

      Parameters

      • ellapsed: number

        The elapsed time since the last update.

      Returns void

    • Updates the camera's projection matrix based on its current fieldOfView, aspectRatio, nearPlane, and farPlane. This should be called whenever the viewport dimensions change.

      Returns void

    • Converts a 3D world position to a 4D clip-space position. This is the final step before the hardware performs the perspective divide and rasterization.

      Parameters

      • worldPosition: vec3

        The 3D world position vector to convert.

      Returns vec4

      The 4D clip-space position vector.

    • Converts a world position to a 2D screen coordinate.

      Parameters

      • worldPosition: vec3

        The world position vector to convert.

      • viewportWidth: number

        The width of the viewport in pixels.

      • viewportHeight: number

        The height of the viewport in pixels.

      Returns vec2

      The 2D screen position in pixels.

    • Sets the main camera instance for static access.

      Parameters

      • camera: Camera

        The camera to set as the main camera.

      Returns void