vec3Utils: {
    abs(v: Point3D): Point3D;
    add(v: Point3D, value: number): Point3D;
    addVec(v1: Point3D, ...v2: Point3D[]): Point3D;
    angle(v1: Point3D, v2: Point3D): number;
    cross(v1: Point3D, v2: Point3D): Point3D;
    divide(v: Point3D, divisor: number): Point3D;
    divideVec(v1: Point3D, ...v2: Point3D[]): Point3D;
    dot(v1: Point3D, v2: Point3D): number;
    equals(a: Point3D, b: Point3D): boolean;
    length(v: Point3D): number;
    lerp(a: Point3D, b: Point3D, amount: number): Point3D;
    multiply(v: Point3D, multiplier: number): Point3D;
    multiplyVec(v1: Point3D, ...v2: Point3D[]): Point3D;
    normalize(v: Point3D): Point3D;
    rotateAroundAxis(v: Point3D, axis: Point3D, theta: number): Point3D;
    sign(v: Point3D): Point3D;
    subtract(v: Point3D, value: number): Point3D;
    subtractVec(v1: Point3D, ...v2: Point3D[]): Point3D;
} = ...

Collection of math utilities for numeric Vec3s.

Type declaration

  • abs:function
    • Get vector as absolute.

      Returns

      { x: Math.abs( v.x ), y: Math.abs( v.y ), z: Math.abs( v.z ) }

      Parameters

      • v: Point3D

        Vector to get absolute value of

      Returns Point3D

  • add:function
    • Add a single value to all values of a 3-dimensional Vector.

      Returns

      Result as a new 3-dimensional Vector as 3D Point.

      Parameters

      • v: Point3D

        3-dimensional Vector to add to.

      • value: number

        Value to add to all 3-dimensional Vector's values.

      Returns Point3D

  • addVec:function
    • Add two or more 3-dimensional Vectors together.

      Returns

      New 3-dimensional Vector as 3D Point.

      Parameters

      • v1: Point3D

        First 3-dimensional Vector to add to.

      • Rest ...v2: Point3D[]

        One or multiple 3-dimensional Vectors to add.

      Returns Point3D

  • angle:function
  • cross:function
  • divide:function
    • Divide values of a 3-dimensional Vector by a single value.

      Returns

      Result as a new 3-dimensional Vector as 3D Point.

      Parameters

      • v: Point3D

        3-dimensional Vector to divide.

      • divisor: number

        Number to divide the 3-dimensional Vectors values with.

      Returns Point3D

  • divideVec:function
    • Divide one 3-dimensional Vector with one or more 3-dimensional Vectors in the order they were provided.

      Returns

      Result as a new 3-dimensional Vector as 3D Point.

      Parameters

      • v1: Point3D

        3-dimensional Vector to divide.

      • Rest ...v2: Point3D[]

        One or multiple 3-dimensional Vector to divide with.

      Returns Point3D

  • dot:function
    • Get the dot product of two 3-dimensional Vectors.

      Parameters

      Returns number

  • equals:function
  • length:function
    • Get the length of a 3-dimensional Vector.

      Returns

      Length of a 3-dimensional Vector.

      Parameters

      Returns number

  • lerp:function
    • Linear interpolation between two vectors and an arbitrary amount as %. amount = 0 -> returns a amount = 1 -> returns b

      Parameters

      • a: Point3D

        Vector a for interpolation

      • b: Point3D

        Vector b for interpolation

      • amount: number

        Interpolation amount

      Returns Point3D

  • multiply:function
    • Multiply values of a 3-dimensional Vector by a single value.

      Returns

      Result as a new 3-dimensional Vector as 3D Point.

      Parameters

      • v: Point3D

        3-dimensional Vector to multiply.

      • multiplier: number

        Number to multiply the 3-dimensional Vectors values with.

      Returns Point3D

  • multiplyVec:function
    • Multiply one 3-dimensional Vector with one or more 3-dimensional Vectors in the order they were provided.

      Returns

      Result as a new 3-dimensional Vector as 3D Point.

      Parameters

      • v1: Point3D

        3-dimensional Vector.

      • Rest ...v2: Point3D[]

        One or multiple 3-dimensional Vectors to multiply with.

      Returns Point3D

  • normalize:function
    • Get the normal of a 3-dimensional Vector.

      Returns

      Normal as a 3-dimensional Vector.

      Parameters

      Returns Point3D

  • rotateAroundAxis:function
    • Rotate vector around another arbitrary axis, by amount 'theta' in radians.

      Parameters

      • v: Point3D

        Vector to rotate

      • axis: Point3D

        Vector of arbitrary rotation axis

      • theta: number

        Rotation amount in radians

      Returns Point3D

  • sign:function
    • Sign of Vector.

      Returns

      { x: Math.sign( v.x ), y: Math.sign( v.y ), z: Math.sign( v.z ) }

      Parameters

      Returns Point3D

  • subtract:function
    • Subtract a single value from all values of a 3-dimensional Vector.

      Returns

      Result as a new 3-dimensional Vector as 3D Point.

      Parameters

      • v: Point3D

        3-dimensional Vector to subtract from.

      • value: number

        Value to subtract from all 3-dimensional Vector's values.

      Returns Point3D

  • subtractVec:function
    • Subtract one or more 3-dimensional Vector from another.

      Returns

      Result as a new 3-dimensional Vector as 3D Point.

      Parameters

      • v1: Point3D

        3-dimensional Vector to subtract from.

      • Rest ...v2: Point3D[]

        One or multiple 3-dimensional Vectors to subtract.

      Returns Point3D