rotateAboutPoint static method

dynamic rotateAboutPoint(
  1. dynamic obj,
  2. dynamic point,
  3. dynamic axis,
  4. dynamic theta, {
  5. bool pointIsWorld = false,
})

Implementation

static rotateAboutPoint(obj, point, axis, theta,
    {bool pointIsWorld = false}) {
  if (pointIsWorld) {
    obj.parent.localToWorld(obj.position); // compensate for world coordinate
  }

  obj.position.sub(point); // remove the offset
  obj.position.applyAxisAngle(axis, theta); // rotate the POSITION
  obj.position.add(point); // re-add the offset

  if (pointIsWorld) {
    obj.parent
        .worldToLocal(obj.position); // undo world coordinates compensation
  }

  obj.rotateOnAxis(axis, theta); // rotate the OBJECT
}