@bedrock-oss/bedrock-boost
    Preparing search index...

    Class Vec3

    Implements

    • Vector3
    Index

    Constructors

    • Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

    • Parameters

      Returns Vec3

    • Parameters

      • x: Vector3

      Returns Vec3

    • Parameters

      • x: Direction

      Returns Vec3

    • Parameters

      • x: number[]

      Returns Vec3

    Properties

    x: number

    X component of this vector.

    y: number

    Y component of this vector.

    z: number

    Z component of this vector.

    Down: Vec3
    East: Vec3
    North: Vec3
    South: Vec3
    Up: Vec3
    West: Vec3
    Zero: Vec3

    Methods

    • Adds another vector to the current vector.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      Returns Vec3

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      • x: Vector3

      Returns Vec3

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      • x: Direction

      Returns Vec3

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      • x: number[]

      Returns Vec3

      The updated vector after addition.

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: number
      • y: number
      • z: number
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Vec3
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Vector3
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Direction
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: number[]
      • delta: number

      Returns boolean

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns number

      The angle in radians between the two vectors.

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      Returns number

      The angle in radians between the two vectors.

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      • x: Vector3

      Returns number

      The angle in radians between the two vectors.

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      • x: Direction

      Returns number

      The angle in radians between the two vectors.

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      • x: number[]

      Returns number

      The angle in radians between the two vectors.

    • Ceils the X, Y, and Z components of the vector.

      Returns Vec3

      A new vector with the ceiled components.

    • Ceils the X component of the vector.

      Returns Vec3

      A new vector with the ceiled X component.

    • Ceils the Y component of the vector.

      Returns Vec3

      A new vector with the ceiled Y component.

    • Ceils the Z component of the vector.

      Returns Vec3

      A new vector with the ceiled Z component.

    • Creates a copy of the current vector.

      Returns Vec3

      A new vector with the same values as the current vector.

    • Computes the cross product of the current vector with another vector.

      A cross product is a vector that is perpendicular to both vectors.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

      A new vector representing the cross product.

    • Computes the cross product of the current vector with another vector.

      A cross product is a vector that is perpendicular to both vectors.

      Parameters

      Returns Vec3

      A new vector representing the cross product.

    • Computes the cross product of the current vector with another vector.

      A cross product is a vector that is perpendicular to both vectors.

      Parameters

      • x: Vector3

      Returns Vec3

      A new vector representing the cross product.

    • Computes the cross product of the current vector with another vector.

      A cross product is a vector that is perpendicular to both vectors.

      Parameters

      • x: Direction

      Returns Vec3

      A new vector representing the cross product.

    • Computes the cross product of the current vector with another vector.

      A cross product is a vector that is perpendicular to both vectors.

      Parameters

      • x: number[]

      Returns Vec3

      A new vector representing the cross product.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: Vector3

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: Direction

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: number[]

      Returns number

      The distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: Vector3

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: Direction

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: number[]

      Returns number

      The squared distance between the two vectors.

    • Calculates the shortest distance between a point (represented by this Vector3 instance) and a line segment.

      This method finds the perpendicular projection of the point onto the line defined by the segment. If this projection lies outside the line segment, then the method calculates the distance from the point to the nearest segment endpoint.

      Parameters

      • start: Vector3

        The starting point of the line segment.

      • end: Vector3

        The ending point of the line segment.

      Returns number

      The shortest distance between the point and the line segment.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      Returns Vec3

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: Vector3

      Returns Vec3

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: Direction

      Returns Vec3

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: number[]

      Returns Vec3

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: number

      Returns Vec3

      The updated vector after division.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: Vector3

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: Direction

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: number[]

      Returns number

      The dot product of the two vectors.

    • Returns a new vector offset from the current vector down by 1 block.

      Returns Vec3

      A new vector offset from the current vector down by 1 block.

    • Returns a new vector offset from the current vector east by 1 block.

      Returns Vec3

      A new vector offset from the current vector east by 1 block.

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Vector3

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Direction

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: number[]

      Returns boolean

    • Floors the X, Y, and Z components of the vector.

      Returns Vec3

      A new vector with the floored components.

    • Floors the X component of the vector.

      Returns Vec3

      A new vector with the floored X component.

    • Floors the Y component of the vector.

      Returns Vec3

      A new vector with the floored Y component.

    • Floors the Z component of the vector.

      Returns Vec3

      A new vector with the floored Z component.

    • Checks if the current vector is equal to the zero vector.

      Returns boolean

      true if the vector is equal to the zero vector, else returns false.

    • Computes the length (magnitude) of the vector.

      Returns number

      The length of the vector.

    • Computes the squared length of the vector. This is faster than computing the actual length and can be useful for comparison purposes.

      Returns number

      The squared length of the vector.

    • Computes the linear interpolation between the current vector and another vector, when t is in the range [0, 1]. Computes the extrapolation when t is outside this range.

      Parameters

      • v: Vector3

        The other vector.

      • t: number

        The interpolation factor.

      Returns Vec3

      A new vector after performing the lerp operation.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      Returns Vec3

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: Vector3

      Returns Vec3

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: Direction

      Returns Vec3

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: number[]

      Returns Vec3

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: number

      Returns Vec3

      The updated vector after multiplication.

    • Normalizes the vector to have a length (magnitude) of 1. Normalized vectors are often used as a direction vectors.

      Returns Vec3

      The normalized vector.

    • Returns a new vector offset from the current vector north by 1 block.

      Returns Vec3

      A new vector offset from the current vector north by 1 block.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      Returns Vec3

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: Vector3

      Returns Vec3

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: Direction

      Returns Vec3

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: number[]

      Returns Vec3

      A new vector representing the projection of the current vector onto v.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      Returns Vec3

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: Vector3

      Returns Vec3

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: Direction

      Returns Vec3

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: number[]

      Returns Vec3

      A new vector representing the reflection of the current vector.

    • Rotates the current normalized vector by a given angle around a given axis.

      Parameters

      • axis: Vector3

        The axis of rotation.

      • angle: number

        The angle of rotation in degrees.

      Returns Vec3

      The rotated vector.

    • Rounds the X, Y, and Z components of the vector.

      Returns Vec3

      A new vector with the rounded components.

    • Rounds the X component of the vector.

      Returns Vec3

      A new vector with the rounded X component.

    • Rounds the Y component of the vector.

      Returns Vec3

      A new vector with the rounded Y component.

    • Rounds the Z component of the vector.

      Returns Vec3

      A new vector with the rounded Z component.

    • Scales the current vector by a scalar.

      Parameters

      • scalar: number

      Returns Vec3

      The updated vector after scaling.

    • Sets the X component of the vector.

      Parameters

      • value: number

        The new X value.

      Returns Vec3

      The updated vector with the new X value.

    • Sets the X component of the vector.

      Parameters

      • value: (x: number) => number

        The new X value.

      Returns Vec3

      The updated vector with the new X value.

    • Sets the Y component of the vector.

      Parameters

      • value: number

        The new Y value.

      Returns Vec3

      The updated vector with the new Y value.

    • Sets the Y component of the vector.

      Parameters

      • value: (y: number) => number

        The new Y value.

      Returns Vec3

      The updated vector with the new Y value.

    • Sets the Z component of the vector.

      Parameters

      • value: number

        The new Z value.

      Returns Vec3

      The updated vector with the new Z value.

    • Sets the Z component of the vector.

      Parameters

      • value: (z: number) => number

        The new Z value.

      Returns Vec3

      The updated vector with the new Z value.

    • Computes the spherical linear interpolation between the current vector and another vector, when t is in the range [0, 1]. Computes the extrapolation when t is outside this range.

      Parameters

      • v: Vector3

        The other vector.

      • t: number

        The interpolation factor.

      Returns Vec3

      A new vector after performing the slerp operation.

    • Returns a new vector offset from the current vector south by 1 block.

      Returns Vec3

      A new vector offset from the current vector south by 1 block.

    • Subtracts another vector from the current vector.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      Returns Vec3

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      • x: Vector3

      Returns Vec3

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      • x: Direction

      Returns Vec3

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      • x: number[]

      Returns Vec3

      The updated vector after subtraction.

    • Converts the vector to an array containing the X, Y, and Z components of the vector.

      Returns number[]

      An array containing the X, Y, and Z components of the vector.

    • Returns a new vector with the X, Y, and Z components rounded to the nearest block location.

      Returns Vec3

    • Converts the vector to a direction. If the vector is not a unit vector, then it will be normalized and rounded to the nearest direction.

      Returns Direction

    • Returns a string representation of an object.

      Parameters

      • Optionalformat: "long" | "short"
      • Optionalseparator: string

      Returns string

    • Converts the normal vector to yaw and pitch values.

      Returns Vector2

      A Vector2 containing the yaw and pitch values.

    • Returns a new vector offset from the current vector up by 1 block.

      Returns Vec3

      A new vector offset from the current vector up by 1 block.

    • Updates the X, Y, and Z components of the vector.

      Parameters

      • x: undefined | ((x: number) => number)

        The function to use to update the X value.

      • y: undefined | ((y: number) => number)

        The function to use to update the Y value.

      • z: undefined | ((z: number) => number)

        The function to use to update the Z value.

      Returns Vec3

      The updated vector with the new values.

    • Returns a new vector offset from the current vector west by 1 block.

      Returns Vec3

      A new vector offset from the current vector west by 1 block.

    • Creates a new vector from the given values.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns Vec3

    • Creates a new vector from the given values.

      Parameters

      Returns Vec3

    • Creates a new vector from the given values.

      Parameters

      • x: Vector3

      Returns Vec3

    • Creates a new vector from the given values.

      Parameters

      • x: Direction

      Returns Vec3

    • Creates a new vector from the given values.

      Parameters

      • x: number[]

      Returns Vec3

    • Creates a new direction vector from yaw and pitch values.

      Parameters

      • rotation: Vector2

      Returns Vec3

      A new vector representing the direction.

    • Creates a new direction vector from yaw and pitch values.

      Parameters

      • yaw: number

        The yaw value in degrees.

      • pitch: number

        The pitch value in degrees.

      Returns Vec3

      A new vector representing the direction.