Function setDefaultType

  • Sets the type this library creates for a Quat4

    Parameters

    • ctor: (new (n) => Quat)

      the constructor for the type. Either Float32Array, Float64Array, or Array

        • new (n): Quat
        • Parameters

          • n: number

          Returns Quat

    Returns (new (n) => Quat)

    previous constructor for Quat4

      • new (n): Quat
      • Quat4 math functions.

        Almost all functions take an optional dst argument. If it is not passed in the functions will create a new Quat4. In other words you can do this

        const v = quat4.cross(v1, v2);  // Creates a new Quat4 with the cross product of v1 x v2.
        

        or

        const v = quat4.create();
        quat4.cross(v1, v2, v); // Puts the cross product of v1 x v2 in v

        The first style is often easier but depending on where it's used it generates garbage where as there is almost never allocation with the second style.

        It is always safe to pass any vector as the destination. So for example

        quat4.cross(v1, v2, v1);  // Puts the cross product of v1 x v2 in v1
        

        Parameters

        • n: number

        Returns Quat