OrbitControls constructor

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

Implementation

OrbitControls(Camera object, GlobalKey<DomLikeListenableState> listenableKey)
    : super() {
  scope = this;

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

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

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

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

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

  // How far you can orbit vertically, upper and lower limits.
  // Range is 0 to Math.PI radians.
  this.minPolarAngle = 0; // radians
  this.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 )
  this.minAzimuthAngle = -Infinity; // radians
  this.maxAzimuthAngle = Infinity; // radians

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

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

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

  // Set to false to disable panning
  this.enablePan = true;
  this.panSpeed = 1.0;
  this.screenSpacePanning =
      true; // if false, pan orthogonal to world-space direction camera.up
  this.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
  this.autoRotate = false;
  this.autoRotateSpeed = 2.0; // 30 seconds per orbit when fps is 60

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

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

  // for reset
  this.target0 = this.target.clone();
  this.position0 = this.object.position.clone();
  this.zoom0 = this.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 = new Quaternion().setFromUnitVectors(object.up, new Vector3(0, 1, 0));
  quatInverse = quat.clone().invert();

  this.update();
}