updateMatrixWorld method

  1. @override
void updateMatrixWorld([
  1. bool force = false
])
override

Implementation

@override
updateMatrixWorld([bool force = false]) {
  var space = this.space;

  position.copy(worldPosition);

  if (mode == 'scale') space = 'local'; // scale always oriented to local rotation

  _v1.copy(_unitX).applyQuaternion(space == 'local' ? worldQuaternion : _identityQuaternion);
  _v2.copy(_unitY).applyQuaternion(space == 'local' ? worldQuaternion : _identityQuaternion);
  _v3.copy(_unitZ).applyQuaternion(space == 'local' ? worldQuaternion : _identityQuaternion);

  // Align the plane for current transform mode, axis and space.

  _alignVector.copy(_v2);

  switch (mode) {
    case 'translate':
    case 'scale':
      switch (axis) {
        case 'X':
          _alignVector.copy(eye).cross(_v1);
          _dirVector.copy(_v1).cross(_alignVector);
          break;
        case 'Y':
          _alignVector.copy(eye).cross(_v2);
          _dirVector.copy(_v2).cross(_alignVector);
          break;
        case 'Z':
          _alignVector.copy(eye).cross(_v3);
          _dirVector.copy(_v3).cross(_alignVector);
          break;
        case 'XY':
          _dirVector.copy(_v3);
          break;
        case 'YZ':
          _dirVector.copy(_v1);
          break;
        case 'XZ':
          _alignVector.copy(_v3);
          _dirVector.copy(_v2);
          break;
        case 'XYZ':
        case 'E':
          _dirVector.set(0, 0, 0);
          break;
      }

      break;
    case 'rotate':
    default:
      // special case for rotate
      _dirVector.set(0, 0, 0);
  }

  if (_dirVector.length() == 0) {
    // If in rotate mode, make the plane parallel to camera
    quaternion.copy(cameraQuaternion);
  } else {
    _tempMatrix.lookAt(_tempVector.set(0, 0, 0), _dirVector, _alignVector);

    quaternion.setFromRotationMatrix(_tempMatrix);
  }

  super.updateMatrixWorld(force);
}