Documentation
    Preparing search index...

    Class Vector3

    A vector with 3 components, labeled: X, Y, Z.

    Hierarchy (View Summary)

    Index

    Constructors

    • Constructs a new Vector3.

      Parameters

      • x: number = 0

        The X component.

      • y: number = 0

        The Y component.

      • z: number = 0

        The Z component.

      Returns Vector3

    Properties

    x: number

    The X component of the vector.

    y: number

    The Y component of the vector.

    z: number

    The Z component of the vector.

    Methods

    • Scales another vector and adds it to this vector.

      Parameters

      • vector: Readonly<Vector3>

        The vector to add to this vector.

      • scale: number

        The scaling to apply to the input vector.

      Returns this

      This instance.

    • Scales another vector and adds it to this vector.

      Parameters

      • x: number

        The value to add to the X component.

      • y: number

        The value to add to the Y component.

      • z: number

        The value to add to the Z component.

      • scale: number

        The scaling to apply to the input vector.

      Returns this

      This instance.

    • Adds another vector to this vector.

      Parameters

      • x: number

        The value to add to the X component.

      • y: number

        The value to add to the Y component.

      • z: number

        The value to add to the Z component.

      Returns this

      This instance.

    • Return the components of this vector as an array.

      Returns [number, number, number]

      The components of this vector as an array.

    • Clamps the components of the vector at the given boundary.

      Parameters

      • floor: number

        The lowest value to allow.

      • ceil: number

        The largest value to allow.

      Returns this

      This instance.

    • Divides the vector by the given scale.

      Parameters

      • scale: number

        The scaling to apply to the vector.

      Returns this

      This instance.

    • Divides this vector by another vector.

      Parameters

      • x: number

        The value to divide the X component with.

      • y: number

        The value to divide the Y component with.

      • z: number

        The value to divide the Z component with.

      Returns this

      This instance.

    • Returns the dot product between two vectors.

      Parameters

      • x: number

        The X component of the other vector.

      • y: number

        The Y component of the other vector.

      • z: number

        The Z component of the other vector.

      Returns number

      The dot product between the two vectors.

    • Calculates the reflection of this vector, based on the angle of incident into a material with the given refractive index, according to Snell's law. This vector is then set to the result.

      Parameters

      • normal: Readonly<Vector3>

        The normal against which to reflect.

      • index: number

        The refractive index of the material.

      Returns this

      This instance.

    • Calculates the length of the vector.

      Returns number

      The length of the vector.

    • Multiplies the vector by the given scale.

      Parameters

      • scale: number

        The scaling to apply to the vector.

      Returns this

      This instance.

    • Multiplies this vector by another vector.

      Parameters

      • x: number

        The value to multiply with the X component.

      • y: number

        The value to multiply with the Y component.

      • z: number

        The value to multiply with the Z component.

      Returns this

      This instance.

    • Sets the vector to new coordinates.

      Parameters

      • x: number

        The new X component for the vector.

      • y: number

        The new Y component for the vector.

      • z: number

        The new Z component for the vector.

      Returns this

      This instance.

    • Subtracts another vector from this vector.

      Parameters

      • vector: Vector3

        The vector to subtract from this vector.

      Returns this

      This instance.

    • Subtracts another vector from this vector.

      Parameters

      • x: number

        The value to subtract from the X component.

      • y: number

        The value to subtract from the Y component.

      • z: number

        The value to subtract from the Z component.

      Returns this

      This instance.