OrbitControls constructor

OrbitControls(
  1. Camera object,
  2. GlobalKey<DomLikeListenableState> listenableKey
)

Implementation

OrbitControls(this.object, this.listenableKey) : super() {
  scope = this;

  // this.domElement = domElement;
  // this.domElement.style.touchAction = 'none'; // disable touch scroll

  // Set to false to disable this control
  enabled = true;

  // "target" sets the location of focus, where the object orbits around
  target = Vector3();

  // How far you can dolly in and out ( PerspectiveCamera only )
  minDistance = 0;
  maxDistance = infinity;

  // How far you can zoom in and out ( OrthographicCamera only )
  minZoom = 0;
  maxZoom = infinity;

  // How far you can orbit vertically, upper and lower limits.
  // Range is 0 to Math.pi radians.
  minPolarAngle = 0; // radians
  maxPolarAngle = Math.pi; // radians

  // How far you can orbit horizontally, upper and lower limits.
  // If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI )
  minAzimuthAngle = -infinity; // radians
  maxAzimuthAngle = infinity; // radians

  // Set to true to enable damping (inertia)
  // If damping is enabled, you must call controls.update() in your animation loop
  enableDamping = false;
  dampingFactor = 0.05;

  // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
  // Set to false to disable zooming
  enableZoom = true;
  zoomSpeed = 1.0;

  // Set to false to disable rotating
  enableRotate = true;
  rotateSpeed = 1.0;

  // Set to false to disable panning
  enablePan = true;
  panSpeed = 1.0;
  screenSpacePanning = true; // if false, pan orthogonal to world-space direction camera.up
  keyPanSpeed = 7.0; // pixels moved per arrow key push

  // Set to true to automatically rotate around the target
  // If auto-rotate is enabled, you must call controls.update() in your animation loop
  autoRotate = false;
  autoRotateSpeed = 2.0; // 30 seconds per orbit when fps is 60

  // Mouse buttons
  mouseButtons = {'LEFT': MOUSE.ROTATE, 'MIDDLE': MOUSE.DOLLY, 'RIGHT': MOUSE.PAN};

  // Touch fingers
  touches = {'ONE': TOUCH.ROTATE, 'TWO': TOUCH.DOLLY_PAN};

  // for reset
  target0 = target.clone();
  position0 = object.position.clone();
  zoom0 = object.zoom;

  // the target DOM element for key events
  // this._domElementKeyEvents = null;

  scope.domElement.addEventListener('contextmenu', onContextMenu);

  scope.domElement.addEventListener('pointerdown', onPointerDown);
  scope.domElement.addEventListener('pointercancel', onPointerCancel);
  scope.domElement.addEventListener('wheel', onMouseWheel);

  // force an update at start

  // so camera.up is the orbit axis
  quat = Quaternion().setFromUnitVectors(object.up, Vector3(0, 1, 0));
  quatInverse = quat.clone().invert();

  update();
}