OrbitControls constructor
OrbitControls(
- Camera object,
- GlobalKey<
PeripheralsState> listenableKey
object
- The camera to be controlled.
listenableKey
- The element used for event listeners.
Implementation
OrbitControls(this.object, this.listenableKey):super() {
scope = this;
// 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.dollyPan};
// 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(PeripheralType.contextmenu, onContextMenu);
scope.domElement.addEventListener(PeripheralType.pointerdown, onPointerDown);
scope.domElement.addEventListener(PeripheralType.pointercancel, onPointerCancel);
scope.domElement.addEventListener(PeripheralType.wheel, onMouseWheel);
scope.domElement.addEventListener(PeripheralType.keydown, onKeyDown);
scope.domElement.addEventListener(PeripheralType.keyup, onKeyUp);
// 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();
}