API

Class Quaternion

Class used to store quaternion data Example Playground - Overview - https://playground.babylonjs.com/#L49EJ7#100

Implements

Index
  • Creates a new Quaternion from the given floats

    Parameters

    • x: number = 0.0

      defines the first component (0 by default)

    • y: number = 0.0

      defines the second component (0 by default)

    • z: number = 0.0

      defines the third component (0 by default)

    • w: number = 1.0

      defines the fourth component (1.0 by default)

    Returns Quaternion

dimension: readonly [4]

Tensor.dimension

rank: 1

Tensor.rank

_V8PerformanceHack: DeepImmutableObject<Quaternion> = ...

If the first quaternion is flagged with integers (as everything is 0,0,0,0), V8 stores all of the properties as integers internally because it doesn't know any better yet. If subsequent quaternion are created with non-integer values, V8 determines that it would be best to represent these properties as doubles instead of integers, and henceforth it will use floating-point representation for all quaternion instances that it creates. But the original quaternion instances are unchanged and has a "deprecated map". If we keep using the quaternion instances from step 1, it will now be a poison pill which will mess up optimizations in any code it touches.

  • Adds in place the given floats to the current quaternion

    Parameters

    • x: number

      defines the x coordinate

    • y: number

      defines the y coordinate

    • z: number

      defines the z coordinate

    • w: number

      defines the w coordinate

    Returns this

    the current updated quaternion

  • Updates the current quaternion with the given float coordinates Example Playground https://playground.babylonjs.com/#L49EJ7#87

    Parameters

    • x: number

      defines the x coordinate

    • y: number

      defines the y coordinate

    • z: number

      defines the z coordinate

    • w: number

      defines the w coordinate

    Returns this

    the updated current quaternion

  • Determines if the current quaternion equals the given floats

    Parameters

    • x: number

      defines the x coordinate

    • y: number

      defines the y coordinate

    • z: number

      defines the z coordinate

    • w: number

      defines the w coordinate

    Returns boolean

    true if the quaternion coordinates match the given floats

  • Multiplies the current quaternion coordinates by the given floats

    Parameters

    • x: number

      defines the x coordinate

    • y: number

      defines the y coordinate

    • z: number

      defines the z coordinate

    • w: number

      defines the w coordinate

    Returns this

    the current updated quaternion

  • Normalize the current quaternion with the given input length. Please note that this is an in place operation.

    Parameters

    • len: number

      the length of the quaternion

    Returns this

    the current updated Quaternion

  • Sets all the quaternion coordinates to the given value

    Parameters

    • value: number

      the value to set

    Returns this

    the current updated quaternion

  • Subtracts the given floats from the current quaternion

    Parameters

    • x: number

      defines the x coordinate

    • y: number

      defines the y coordinate

    • z: number

      defines the z coordinate

    • w: number

      defines the w coordinate

    Returns Quaternion

    a new quaternion as the subtraction result

  • Subtracts the given floats from the current quaternion and stores the result in the given one

    Type Parameters

    Parameters

    • x: number

      defines the x coordinate

    • y: number

      defines the y coordinate

    • z: number

      defines the z coordinate

    • w: number

      defines the w coordinate

    • result: T

      defines the quaternion to store the result

    Returns T

    result input

  • Sets the given quaternion "result" with the given floats.

    Type Parameters

    Parameters

    • x: number

      defines the x coordinate of the source

    • y: number

      defines the y coordinate of the source

    • z: number

      defines the z coordinate of the source

    • w: number

      defines the w coordinate of the source

    • result: T

      defines the quaternion where to store the result

    Returns T

    the result quaternion

  • Sets a Quaternion with random values between min and max

    Type Parameters

    Parameters

    • min: number = 0

      the minimum random value

    • max: number = 1

      the maximum random value

    • ref: T

      the ref to store the values in

    Returns T

    the ref with random values between min and max

  • Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#69

    Type Parameters

    Parameters

    • alpha: number

      defines the rotation around first axis

    • beta: number

      defines the rotation around second axis

    • gamma: number

      defines the rotation around third axis

    • result: T

      defines the target quaternion

    Returns T

    result input

  • Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion Example Playground https://playground.babylonjs.com/#L49EJ7#561

    Type Parameters

    Parameters

    • yaw: number

      defines the rotation around Y axis

    • pitch: number

      defines the rotation around X axis

    • roll: number

      defines the rotation around Z axis

    • result: T

      defines the target quaternion

    Returns T

    result input