@lakuna/uscene
    Preparing search index...

    Class Camera

    A camera that views a scene.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    enabled: boolean

    Whether or not this node is enabled. Disabled nodes and their descendents are not included in traversals.

    matrix: Matrix4Like

    The transformation matrix of this node relative to its parent.

    projMat: Matrix4Like

    The projection matrix of this camera.

    Accessors

    • get rotation(): Readonly<QuaternionLike> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      The rotation of this node relative to its parent.

      Returns Readonly<QuaternionLike> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      • Readonlybuffer: Readonly<
            Pick<
                Float32Array["buffer"],
                "byteLength"
                | "maxByteLength"
                | "slice"
                | typeof Symbol.toStringTag,
            >,
        >

        The ArrayBuffer instance referenced by the array.

    • set rotation(value: Readonly<QuaternionLike>): void

      The rotation of this node relative to its parent.

      Parameters

      • value: Readonly<QuaternionLike>

      Returns void

    • get scaling(): Readonly<Vector3Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      The scaling of this node relative to its parent.

      Returns Readonly<Vector3Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      • Readonlybuffer: Readonly<
            Pick<
                Float32Array["buffer"],
                "byteLength"
                | "maxByteLength"
                | "slice"
                | typeof Symbol.toStringTag,
            >,
        >

        The ArrayBuffer instance referenced by the array.

    • set scaling(value: Readonly<Vector3Like>): void

      The scaling of this node relative to its parent.

      Parameters

      • value: Readonly<Vector3Like>

      Returns void

    • get translation(): Readonly<Vector3Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      The translation of this node relative to its parent.

      Returns Readonly<Vector3Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      • Readonlybuffer: Readonly<
            Pick<
                Float32Array["buffer"],
                "byteLength"
                | "maxByteLength"
                | "slice"
                | typeof Symbol.toStringTag,
            >,
        >

        The ArrayBuffer instance referenced by the array.

    • set translation(value: Readonly<Vector3Like>): void

      The translation of this node relative to its parent.

      Parameters

      • value: Readonly<Vector3Like>

      Returns void

    • get viewMat(): Readonly<Matrix4Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      The view matrix of this camera, which represents the transformation that would move a scene into view of this camera. This is the inverse of this camera's world matrix.

      Returns Readonly<Matrix4Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      • Readonlybuffer: Readonly<
            Pick<
                Float32Array["buffer"],
                "byteLength"
                | "maxByteLength"
                | "slice"
                | typeof Symbol.toStringTag,
            >,
        >

        The ArrayBuffer instance referenced by the array.

    • get viewProjMat(): Readonly<Matrix4Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      The view projection matrix of this camera, which represents the transformation that would move a scene into view of this camera and apply a projection to it. This is the product of this camera's view matrix and projection matrix.

      Returns Readonly<Matrix4Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      • Readonlybuffer: Readonly<
            Pick<
                Float32Array["buffer"],
                "byteLength"
                | "maxByteLength"
                | "slice"
                | typeof Symbol.toStringTag,
            >,
        >

        The ArrayBuffer instance referenced by the array.

    • get worldMat(): Readonly<Matrix4Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      The world matrix of this node, which represents its transformation relative to the origin.

      Returns Readonly<Matrix4Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      • Readonlybuffer: Readonly<
            Pick<
                Float32Array["buffer"],
                "byteLength"
                | "maxByteLength"
                | "slice"
                | typeof Symbol.toStringTag,
            >,
        >

        The ArrayBuffer instance referenced by the array.

    • get worldTranslation(): Readonly<Vector3Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      The translation of this node relative to the origin.

      Returns Readonly<Vector3Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      • Readonlybuffer: Readonly<
            Pick<
                Float32Array["buffer"],
                "byteLength"
                | "maxByteLength"
                | "slice"
                | typeof Symbol.toStringTag,
            >,
        >

        The ArrayBuffer instance referenced by the array.

    Methods

    • Add a child to this node.

      Parameters

      • node: Node

        The child. The child's parent will be updated to point to this node. If the child already had a parent, it will be removed from that parent's children.

      Returns void

    • Get the world view projection matrix created by multiplying this camera's view projection matrix by the given world matrix. This can be used to render a node as it would appear from the perspective of this camera.

      Parameters

      • worldMat: Readonly<Matrix4Like>

        The world matrix.

      Returns Readonly<Matrix4Like> & Readonly<
          Omit<
              Float32Array<ArrayBufferLike>,
              "buffer" | "copyWithin" | "fill" | "reverse" | "set" | "sort",
          >,
      > & {
          buffer: Readonly<
              Pick<
                  Float32Array["buffer"],
                  "byteLength"
                  | "maxByteLength"
                  | "slice"
                  | typeof Symbol.toStringTag,
              >,
          >;
      }

      The world view projection matrix.

      • Readonlybuffer: Readonly<
            Pick<
                Float32Array["buffer"],
                "byteLength"
                | "maxByteLength"
                | "slice"
                | typeof Symbol.toStringTag,
            >,
        >

        The ArrayBuffer instance referenced by the array.

    • Reset this node's transformation relative to its parent.

      Returns void

    • Set this camera to use an orthogonal projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of [-1, 1] (OpenGL/WebGL).

      Parameters

      • left: number

        The left bound of the frustum.

      • right: number

        The right bound of the frustum.

      • bottom: number

        The bottom bound of the frustum.

      • top: number

        The top bound of the frustum.

      • near: number

        The near bound of the frustum.

      • far: number

        The far bound of the frustum.

      Returns void

    • Set this camera to use an orthogonal projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of [0, 1] (WebGPU/Vulkan/DirectX/Metal).

      Parameters

      • left: number

        The left bound of the frustum.

      • right: number

        The right bound of the frustum.

      • bottom: number

        The bottom bound of the frustum.

      • top: number

        The top bound of the frustum.

      • near: number

        The near bound of the frustum.

      • far: number

        The far bound of the frustum.

      Returns void

    • Set this camera to use a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of [-1, 1] (OpenGL/WebGL).

      Parameters

      • fov: number

        The vertical field of view in radians.

      • aspect: number

        The aspect ratio (typically the width of the viewport divided by its height).

      • near: number

        The near bound of the frustum. Must be strictly positive.

      • far: number

        The far bound of the frustum.

      Returns void

    • Set this camera to use a perspective projection matrix generated from a field of view. Useful for generating projection matrices to be used with the WebXR API.

      Parameters

      • fov: Readonly<FieldOfView>

        The field of view.

      • near: number

        The near bound of the frustum.

      • far: number

        The far bound of the frustum.

      Returns void

    • Set this camera to use a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of [0, 1] (WebGPU/Vulkan/DirectX/Metal).

      Parameters

      • fov: number

        The vertical field of view in radians.

      • aspect: number

        The aspect ratio (typically the width of the viewport divided by its height).

      • near: number

        The near bound of the frustum. Must be strictly positive.

      • far: number

        The far bound of the frustum.

      Returns void

    • Remove a child from this node.

      Parameters

      • node: Node

        The child. The child's parent will be updated to point to nothing.

      Returns void

    • Rotate this node relative to its parent.

      Parameters

      • r: number

        The number of radians to rotate by.

      • axis: Readonly<Vector3Like>

        The axis to rotate around.

      Returns void

    • Rotate this node around the X-axis relative to its parent.

      Parameters

      • r: number

        The number of radians to rotate by.

      Returns void

    • Rotate this node around the Y-axis relative to its parent.

      Parameters

      • r: number

        The number of radians to rotate by.

      Returns void

    • Rotate this node around the Z-axis relative to its parent.

      Parameters

      • r: number

        The number of radians to rotate by.

      Returns void

    • Scale this node relative to its parent.

      Parameters

      • s: Readonly<Vector3Like>

        The scaling factor.

      Returns void

    • Position this node such that it is pointing at a target position.

      Parameters

      • eye: Readonly<Vector3Like>

        The new position of this node.

      • target: Readonly<Vector3Like>

        The position for this node to point at.

      • up: Readonly<Vector3Like> = ...

        The up vector.

      Returns void

    • Translate this node relative to its parent.

      Parameters

      • t: Readonly<Vector3Like>

        The translation vector.

      Returns void

    • Perform a function on this node and each of its children recursively.

      Parameters

      • f:
            | (
                (
                    self: Node,
                    worldMat: Float32Array<ArrayBufferLike> & Matrix4Like,
                ) => boolean
            )
            | (
                (
                    self: Node,
                    worldMat: Float32Array<ArrayBufferLike> & Matrix4Like,
                ) => void
            )

        The function to perform for each node. Receives as an argument the node and the node's transformation matrix relative to the node on which the traversal started. If this function returns false, the node's children are not included in the traversal.

      Returns void