setFromAxisAngle method

Quaternion setFromAxisAngle(
  1. Vector3 axis,
  2. num angle
)

Implementation

Quaternion setFromAxisAngle(Vector3 axis, num angle) {
  // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm

  // assumes axis is normalized

  var halfAngle = angle / 2, s = Math.sin(halfAngle);

  _x = axis.x * s;
  _y = axis.y * s;
  _z = axis.z * s;
  _w = Math.cos(halfAngle);

  onChangeCallback();

  return this;
}