setDirection method

void setDirection(
  1. Vector3 dir
)

dir - The desired direction. Must be a unit vector.

Sets the direction of the arrowhelper.

Implementation

void setDirection(Vector3 dir) {
  // dir is assumed to be normalized

  if (dir.y > 0.99999) {
    quaternion.set(0, 0, 0, 1);
  } else if (dir.y < -0.99999) {
    quaternion.set(1, 0, 0, 0);
  } else {
    _axis.setValues(dir.z, 0, -dir.x).normalize();

    final radians = math.acos(dir.y);

    quaternion.setFromAxisAngle(_axis, radians);
  }
}