@minecraft/math
    Preparing search index...

    Class Vector3Builder

    Vector3 wrapper class which can be used as a Vector3 for APIs on @minecraft/server which require a Vector, but also contain additional helper methods. This is an alternative to using the core Vector 3 utility methods directly, for those who prefer a more object-oriented approach. This version of the class is mutable and changes state inline.

    For an immutable version of the build, use ImmutableVector3Builder.

    Implements

    • Vector3
    Index

    Constructors

    • Parameters

      • vec: Vector3
      • Optionalarg: undefined
      • Optionalarg2: undefined

      Returns Vector3Builder

    • Parameters

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

      Returns Vector3Builder

    Properties

    x: number

    X component of this vector.

    y: number

    Y component of this vector.

    z: number

    Z component of this vector.

    Methods

    • add

      Adds the vector v to this, returning itself.

      Parameters

      • v: Partial<Vector3>

      Returns this

    • Assigns the values of the passed in vector to this vector. Returns itself.

      Parameters

      • vec: Vector3

      Returns this

    • clamp

      Clamps the components of a vector to limits to produce a new vector

      Parameters

      • limits: { max?: Partial<Vector3>; min?: Partial<Vector3> }

      Returns this

    • cross

      Computes the cross product of this and the passed in vector, returning itself.

      Parameters

      • vec: Vector3

      Returns this

    • distance

      Calculate the distance between two vectors

      Parameters

      • vec: Vector3

      Returns number

    • dot

      Computes the dot product of this and the passed in vector.

      Parameters

      • vec: Vector3

      Returns number

    • equals

      Check the equality of two vectors

      Parameters

      • v: Vector3

      Returns boolean

    • floor

      Floor the components of a vector to produce a new vector

      Returns this

    • lerp

      Constructs a new vector using linear interpolation on each component from two vectors.

      Parameters

      • vec: Vector3
      • t: number

      Returns this

    • magnitude

      The magnitude of the vector

      Returns number

    • multiply

      Element-wise multiplication of two vectors together. Not to be confused with Vector3Builder.dot product or Vector3Builder.cross product

      Parameters

      • vec: Vector3

      Returns this

    • normalize

      Normalizes this vector, returning itself.

      Returns this

    • rotateX

      Rotates the vector around the x axis counterclockwise (left hand rule)

      Parameters

      • a: number

        Angle in radians

      Returns this

    • rotateY

      Rotates the vector around the y axis counterclockwise (left hand rule)

      Parameters

      • a: number

        Angle in radians

      Returns this

    • rotateZ

      Rotates the vector around the z axis counterclockwise (left hand rule)

      Parameters

      • a: number

        Angle in radians

      Returns this

    • scale

      Scales this by the passed in value, returning itself.

      Parameters

      • val: number

      Returns this

    • slerp

      Constructs a new vector using spherical linear interpolation on each component from two vectors.

      Parameters

      • vec: Vector3
      • t: number

      Returns this

    • subtract

      Subtracts the vector v from this, returning itself.

      Parameters

      • v: Partial<Vector3>

      Returns this

    • toString

      Create a string representation of a vector

      Parameters

      • Optionaloptions: { decimals?: number; delimiter?: string }

      Returns string