diff --git a/dist/CameraControls.d.ts b/dist/CameraControls.d.ts index 8ff74ca..6a372d7 100644 --- a/dist/CameraControls.d.ts +++ b/dist/CameraControls.d.ts @@ -89,7 +89,7 @@ export declare class CameraControls extends EventDispatcher { truck(x: number, y: number, enableTransition?: boolean): Promise; forward(distance: number, enableTransition?: boolean): Promise; moveTo(x: number, y: number, z: number, enableTransition?: boolean): Promise; - fitToBox(box3OrObject: _THREE.Box3 | _THREE.Object3D, enableTransition: boolean, { paddingLeft, paddingRight, paddingBottom, paddingTop }?: Partial): Promise; + fitToBox(box3OrObject: _THREE.Box3 | _THREE.Object3D, enableTransition: boolean, { paddingLeft, paddingRight, paddingBottom, paddingTop }?: Partial, lock?: "front" | "back"): Promise; fitTo(box3OrObject: _THREE.Box3 | _THREE.Object3D, enableTransition: boolean, fitToOptions?: Partial): Promise; fitToSphere(sphereOrMesh: _THREE.Sphere | _THREE.Object3D, enableTransition: boolean): Promise; setLookAt(positionX: number, positionY: number, positionZ: number, targetX: number, targetY: number, targetZ: number, enableTransition?: boolean): Promise; diff --git a/dist/camera-controls.js b/dist/camera-controls.js index 9b6b74e..a914285 100644 --- a/dist/camera-controls.js +++ b/dist/camera-controls.js @@ -966,7 +966,7 @@ approxEquals(this._target.z, this._targetEnd.z, this.restThreshold); return this._createOnRestPromise(resolveImmediately); }; - CameraControls.prototype.fitToBox = function (box3OrObject, enableTransition, _a) { + CameraControls.prototype.fitToBox = function (box3OrObject, enableTransition, _a, lock) { var _b = _a === void 0 ? {} : _a, _c = _b.paddingLeft, paddingLeft = _c === void 0 ? 0 : _c, _d = _b.paddingRight, paddingRight = _d === void 0 ? 0 : _d, _e = _b.paddingBottom, paddingBottom = _e === void 0 ? 0 : _e, _f = _b.paddingTop, paddingTop = _f === void 0 ? 0 : _f; var promises = []; var aabb = box3OrObject.isBox3 @@ -976,8 +976,16 @@ console.warn('camera-controls: fitTo() cannot be used with an empty box. Aborting'); Promise.resolve(); } - var theta = roundToStep(this._sphericalEnd.theta, PI_HALF); - var phi = roundToStep(this._sphericalEnd.phi, PI_HALF); + var theta; + var phi; + if (!lock) { + theta = roundToStep(this._sphericalEnd.theta, PI_HALF); + phi = roundToStep(this._sphericalEnd.phi, PI_HALF); + } + else { + theta = lock === "front" ? 0 : Math.PI; + phi = lock === "front" ? 0 : Math.PI; + } promises.push(this.rotateTo(theta, phi, enableTransition)); var normal = _v3A.setFromSpherical(this._sphericalEnd).normalize(); var rotation = _quaternionA.setFromUnitVectors(normal, _AXIS_Z); diff --git a/dist/camera-controls.min.js b/dist/camera-controls.min.js index 7589da7..6d4290f 100644 --- a/dist/camera-controls.min.js +++ b/dist/camera-controls.min.js @@ -18,4 +18,4 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};function __extends(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}var ACTION;(function(ACTION){ACTION[ACTION["NONE"]=0]="NONE";ACTION[ACTION["ROTATE"]=1]="ROTATE";ACTION[ACTION["TRUCK"]=2]="TRUCK";ACTION[ACTION["OFFSET"]=3]="OFFSET";ACTION[ACTION["DOLLY"]=4]="DOLLY";ACTION[ACTION["ZOOM"]=5]="ZOOM";ACTION[ACTION["TOUCH_ROTATE"]=6]="TOUCH_ROTATE";ACTION[ACTION["TOUCH_TRUCK"]=7]="TOUCH_TRUCK";ACTION[ACTION["TOUCH_OFFSET"]=8]="TOUCH_OFFSET";ACTION[ACTION["TOUCH_DOLLY"]=9]="TOUCH_DOLLY";ACTION[ACTION["TOUCH_ZOOM"]=10]="TOUCH_ZOOM";ACTION[ACTION["TOUCH_DOLLY_TRUCK"]=11]="TOUCH_DOLLY_TRUCK";ACTION[ACTION["TOUCH_DOLLY_OFFSET"]=12]="TOUCH_DOLLY_OFFSET";ACTION[ACTION["TOUCH_ZOOM_TRUCK"]=13]="TOUCH_ZOOM_TRUCK";ACTION[ACTION["TOUCH_ZOOM_OFFSET"]=14]="TOUCH_ZOOM_OFFSET"})(ACTION||(ACTION={}));function isPerspectiveCamera(camera){return camera.isPerspectiveCamera}function isOrthographicCamera(camera){return camera.isOrthographicCamera}var PI_2=Math.PI*2;var PI_HALF=Math.PI/2;var EPSILON=1e-5;function approxZero(number,error){if(error===void 0){error=EPSILON}return Math.abs(number)=0?-1:1);_this.dollyTo(distance);if(_this.infinityDolly&&(distance<_this.minDistance||_this.maxDistance===_this.minDistance)){_this._camera.getWorldDirection(_v3A);_this._targetEnd.add(_v3A.normalize().multiplyScalar(signedPrevRadius));_this._target.add(_v3A.normalize().multiplyScalar(signedPrevRadius))}if(_this.dollyToCursor){_this._dollyControlAmount+=_this._sphericalEnd.radius-prevRadius;if(_this.infinityDolly&&(distance<_this.minDistance||_this.maxDistance===_this.minDistance)){_this._dollyControlAmount-=signedPrevRadius}_this._dollyControlCoord.set(x,y)}return};_this._zoomInternal=function(delta,x,y){var zoomScale=Math.pow(.95,delta*_this.dollySpeed);_this.zoomTo(_this._zoom*zoomScale);if(_this.dollyToCursor){_this._dollyControlAmount=_this._zoomEnd;_this._dollyControlCoord.set(x,y)}return};if(typeof THREE==="undefined"){console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information.")}_this._camera=camera;_this._yAxisUpSpace=(new THREE.Quaternion).setFromUnitVectors(_this._camera.up,_AXIS_Y);_this._yAxisUpSpaceInverse=quatInvertCompat(_this._yAxisUpSpace.clone());_this._state=ACTION.NONE;_this._domElement=domElement;_this._domElement.style.touchAction="none";_this._target=new THREE.Vector3;_this._targetEnd=_this._target.clone();_this._focalOffset=new THREE.Vector3;_this._focalOffsetEnd=_this._focalOffset.clone();_this._spherical=(new THREE.Spherical).setFromVector3(_v3A.copy(_this._camera.position).applyQuaternion(_this._yAxisUpSpace));_this._sphericalEnd=_this._spherical.clone();_this._zoom=_this._camera.zoom;_this._zoomEnd=_this._zoom;_this._nearPlaneCorners=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];_this._updateNearPlaneCorners();_this._boundary=new THREE.Box3(new THREE.Vector3(-Infinity,-Infinity,-Infinity),new THREE.Vector3(Infinity,Infinity,Infinity));_this._target0=_this._target.clone();_this._position0=_this._camera.position.clone();_this._zoom0=_this._zoom;_this._focalOffset0=_this._focalOffset.clone();_this._dollyControlAmount=0;_this._dollyControlCoord=new THREE.Vector2;_this.mouseButtons={left:ACTION.ROTATE,middle:ACTION.DOLLY,right:ACTION.TRUCK,wheel:isPerspectiveCamera(_this._camera)?ACTION.DOLLY:isOrthographicCamera(_this._camera)?ACTION.ZOOM:ACTION.NONE,shiftLeft:ACTION.NONE,pinch:ACTION.NONE};_this.touches={one:ACTION.TOUCH_ROTATE,two:isPerspectiveCamera(_this._camera)?ACTION.TOUCH_DOLLY_TRUCK:isOrthographicCamera(_this._camera)?ACTION.TOUCH_ZOOM_TRUCK:ACTION.NONE,three:ACTION.TOUCH_TRUCK};_this._elementRect=new THREE.Vector4;if(_this._domElement){var dragStartPosition_1=new THREE.Vector2;var lastDragPosition_1=new THREE.Vector2;var dollyStart_1=new THREE.Vector2;var cancelDragging_1=function(){_this._state=ACTION.NONE;_this._activePointers.length=0;endDragging_1()};var onPointerDown_1=function(event){if(!_this._enabled)return;var pointer={pointerId:event.pointerId,clientX:event.clientX,clientY:event.clientY};_this._activePointers.push(pointer);switch(event.button){case THREE.MOUSE.LEFT:_this._state=event.shiftKey?_this.mouseButtons.shiftLeft:_this.mouseButtons.left;break;case THREE.MOUSE.MIDDLE:_this._state=_this.mouseButtons.middle;break;case THREE.MOUSE.RIGHT:_this._state=_this.mouseButtons.right;break}if(event.pointerType==="touch"){switch(_this._activePointers.length){case 1:_this._state=_this.touches.one;break;case 2:_this._state=_this.touches.two;break;case 3:_this._state=_this.touches.three;break}}_this._domElement.ownerDocument.removeEventListener("pointermove",onPointerMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("pointerup",onPointerUp_1);_this._domElement.ownerDocument.addEventListener("pointermove",onPointerMove_1,{passive:false});_this._domElement.ownerDocument.addEventListener("pointerup",onPointerUp_1);startDragging_1()};var onMouseDown_1=function(event){if(!_this._enabled)return;var pointer={pointerId:0,clientX:event.clientX,clientY:event.clientY};_this._activePointers.push(pointer);switch(event.button){case THREE.MOUSE.LEFT:_this._state=event.shiftKey?_this.mouseButtons.shiftLeft:_this.mouseButtons.left;break;case THREE.MOUSE.MIDDLE:_this._state=_this.mouseButtons.middle;break;case THREE.MOUSE.RIGHT:_this._state=_this.mouseButtons.right;break}_this._domElement.ownerDocument.removeEventListener("mousemove",onMouseMove_1);_this._domElement.ownerDocument.removeEventListener("mouseup",onMouseUp_1);_this._domElement.ownerDocument.addEventListener("mousemove",onMouseMove_1);_this._domElement.ownerDocument.addEventListener("mouseup",onMouseUp_1);startDragging_1()};var onTouchStart_1=function(event){if(!_this._enabled)return;event.preventDefault();Array.prototype.forEach.call(event.changedTouches,(function(touch){var pointer={pointerId:touch.identifier,clientX:touch.clientX,clientY:touch.clientY};_this._activePointers.push(pointer)}));switch(_this._activePointers.length){case 1:_this._state=_this.touches.one;break;case 2:_this._state=_this.touches.two;break;case 3:_this._state=_this.touches.three;break}_this._domElement.ownerDocument.removeEventListener("touchmove",onTouchMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("touchend",onTouchEnd_1);_this._domElement.ownerDocument.addEventListener("touchmove",onTouchMove_1,{passive:false});_this._domElement.ownerDocument.addEventListener("touchend",onTouchEnd_1);startDragging_1()};var onPointerMove_1=function(event){if(event.cancelable)event.preventDefault();var pointerId=event.pointerId;var pointer=_this._findPointerById(pointerId);if(!pointer)return;pointer.clientX=event.clientX;pointer.clientY=event.clientY;dragging_1()};var onMouseMove_1=function(event){var pointer=_this._findPointerById(0);if(!pointer)return;pointer.clientX=event.clientX;pointer.clientY=event.clientY;dragging_1()};var onTouchMove_1=function(event){if(event.cancelable)event.preventDefault();Array.prototype.forEach.call(event.changedTouches,(function(touch){var pointerId=touch.identifier;var pointer=_this._findPointerById(pointerId);if(!pointer)return;pointer.clientX=touch.clientX;pointer.clientY=touch.clientY}));dragging_1()};var onPointerUp_1=function(event){var pointerId=event.pointerId;var pointer=_this._findPointerById(pointerId);pointer&&_this._activePointers.splice(_this._activePointers.indexOf(pointer),1);if(event.pointerType==="touch"){switch(_this._activePointers.length){case 0:_this._state=ACTION.NONE;break;case 1:_this._state=_this.touches.one;break;case 2:_this._state=_this.touches.two;break;case 3:_this._state=_this.touches.three;break}}else{_this._state=ACTION.NONE}endDragging_1()};var onMouseUp_1=function(){var pointer=_this._findPointerById(0);pointer&&_this._activePointers.splice(_this._activePointers.indexOf(pointer),1);_this._state=ACTION.NONE;endDragging_1()};var onTouchEnd_1=function(event){Array.prototype.forEach.call(event.changedTouches,(function(touch){var pointerId=touch.identifier;var pointer=_this._findPointerById(pointerId);pointer&&_this._activePointers.splice(_this._activePointers.indexOf(pointer),1)}));switch(_this._activePointers.length){case 0:_this._state=ACTION.NONE;break;case 1:_this._state=_this.touches.one;break;case 2:_this._state=_this.touches.two;break;case 3:_this._state=_this.touches.three;break}endDragging_1()};var onGestureStart_1=function(event){if(!_this._enabled||_this.mouseButtons.pinch===ACTION.NONE||isTouchScreen)return;_this._gesturing=true;_this._gestureScaleStart=_this._zoom;event.preventDefault()};var onGestureChanged_1=function(event){if(!_this._enabled||_this.mouseButtons.pinch===ACTION.NONE||isTouchScreen||typeof _this._gestureScaleStart!=="number")return;_this._getClientRect(_this._elementRect);var x=_this.dollyToCursor?(event.clientX-_this._elementRect.x)/_this._elementRect.z*2-1:0;var y=_this.dollyToCursor?(event.clientY-_this._elementRect.y)/_this._elementRect.w*-2+1:0;var FACTOR=.5;if(_this.mouseButtons.pinch===ACTION.ZOOM){var to=(1-event.scale)*FACTOR;_this._zoomInternal(to,x,y)}if(_this.mouseButtons.pinch===ACTION.DOLLY){var to=(1-event.scale)*FACTOR;_this._dollyInternal(to,x,y)}event.preventDefault()};var lastScrollTimeStamp_1=-1;var onMouseWheel_1=function(event){var state=event.ctrlKey&&_this.mouseButtons.pinch!==ACTION.NONE?_this.mouseButtons.pinch:_this.mouseButtons.wheel;if(!_this._enabled||state===ACTION.NONE)return;event.preventDefault();if(_this.dollyToCursor||state===ACTION.ROTATE||state===ACTION.TRUCK){var now=performance.now();if(lastScrollTimeStamp_1-now<1e3)_this._getClientRect(_this._elementRect);lastScrollTimeStamp_1=now}var deltaYFactor=isMac?-1:-3;var delta=event.deltaMode===1?event.deltaY/deltaYFactor:event.deltaY/(deltaYFactor*10);var x=_this.dollyToCursor?(event.clientX-_this._elementRect.x)/_this._elementRect.z*2-1:0;var y=_this.dollyToCursor?(event.clientY-_this._elementRect.y)/_this._elementRect.w*-2+1:0;switch(state){case ACTION.ROTATE:{_this._rotateInternal(event.deltaX,event.deltaY);break}case ACTION.TRUCK:{_this._truckInternal(event.deltaX,event.deltaY,false);break}case ACTION.OFFSET:{_this._truckInternal(event.deltaX,event.deltaY,true);break}case ACTION.DOLLY:{_this._dollyInternal(-delta,x,y);break}case ACTION.ZOOM:{_this._zoomInternal(-delta,x,y);break}}_this.dispatchEvent({type:"control"})};var onContextMenu_1=function(event){if(!_this._enabled)return;event.preventDefault()};var startDragging_1=function(){if(!_this._enabled)return;extractClientCoordFromEvent(_this._activePointers,_v2);_this._getClientRect(_this._elementRect);dragStartPosition_1.copy(_v2);lastDragPosition_1.copy(_v2);var isMultiTouch=_this._activePointers.length>=2;if(isMultiTouch){var dx=_v2.x-_this._activePointers[1].clientX;var dy=_v2.y-_this._activePointers[1].clientY;var distance=Math.sqrt(dx*dx+dy*dy);dollyStart_1.set(0,distance);var x=(_this._activePointers[0].clientX+_this._activePointers[1].clientX)*.5;var y=(_this._activePointers[0].clientY+_this._activePointers[1].clientY)*.5;lastDragPosition_1.set(x,y)}_this.dispatchEvent({type:"controlstart"})};var dragging_1=function(){if(!_this._enabled)return;extractClientCoordFromEvent(_this._activePointers,_v2);var deltaX=lastDragPosition_1.x-_v2.x;var deltaY=lastDragPosition_1.y-_v2.y;lastDragPosition_1.copy(_v2);switch(_this._state){case ACTION.ROTATE:case ACTION.TOUCH_ROTATE:{_this._rotateInternal(deltaX,deltaY);break}case ACTION.DOLLY:case ACTION.ZOOM:{var dollyX=_this.dollyToCursor?(dragStartPosition_1.x-_this._elementRect.x)/_this._elementRect.z*2-1:0;var dollyY=_this.dollyToCursor?(dragStartPosition_1.y-_this._elementRect.y)/_this._elementRect.w*-2+1:0;_this._state===ACTION.DOLLY?_this._dollyInternal(deltaY*TOUCH_DOLLY_FACTOR,dollyX,dollyY):_this._zoomInternal(deltaY*TOUCH_DOLLY_FACTOR,dollyX,dollyY);break}case ACTION.TOUCH_DOLLY:case ACTION.TOUCH_ZOOM:case ACTION.TOUCH_DOLLY_TRUCK:case ACTION.TOUCH_ZOOM_TRUCK:case ACTION.TOUCH_DOLLY_OFFSET:case ACTION.TOUCH_ZOOM_OFFSET:{var dx=_v2.x-_this._activePointers[1].clientX;var dy=_v2.y-_this._activePointers[1].clientY;var distance=Math.sqrt(dx*dx+dy*dy);var dollyDelta=dollyStart_1.y-distance;dollyStart_1.set(0,distance);var dollyX=_this.dollyToCursor?(lastDragPosition_1.x-_this._elementRect.x)/_this._elementRect.z*2-1:0;var dollyY=_this.dollyToCursor?(lastDragPosition_1.y-_this._elementRect.y)/_this._elementRect.w*-2+1:0;_this._state===ACTION.TOUCH_DOLLY||_this._state===ACTION.TOUCH_DOLLY_TRUCK||_this._state===ACTION.TOUCH_DOLLY_OFFSET?_this._dollyInternal(dollyDelta*TOUCH_DOLLY_FACTOR,dollyX,dollyY):_this._zoomInternal(dollyDelta*TOUCH_DOLLY_FACTOR,dollyX,dollyY);if(_this._state===ACTION.TOUCH_DOLLY_TRUCK||_this._state===ACTION.TOUCH_ZOOM_TRUCK){_this._truckInternal(deltaX,deltaY,false)}else if(_this._state===ACTION.TOUCH_DOLLY_OFFSET||_this._state===ACTION.TOUCH_ZOOM_OFFSET){_this._truckInternal(deltaX,deltaY,true)}break}case ACTION.TRUCK:case ACTION.TOUCH_TRUCK:{_this._truckInternal(deltaX,deltaY,false);break}case ACTION.OFFSET:case ACTION.TOUCH_OFFSET:{_this._truckInternal(deltaX,deltaY,true);break}}_this.dispatchEvent({type:"control"})};var endDragging_1=function(){extractClientCoordFromEvent(_this._activePointers,_v2);lastDragPosition_1.copy(_v2);if(_this._activePointers.length===0){_this._domElement.ownerDocument.removeEventListener("pointermove",onPointerMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("pointerup",onPointerUp_1);_this._domElement.ownerDocument.removeEventListener("touchmove",onTouchMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("touchend",onTouchEnd_1)}_this.dispatchEvent({type:"controlend"})};_this._domElement.addEventListener("pointerdown",onPointerDown_1);isPointerEventsNotSupported&&_this._domElement.addEventListener("mousedown",onMouseDown_1);isPointerEventsNotSupported&&_this._domElement.addEventListener("touchstart",onTouchStart_1);_this._domElement.addEventListener("pointercancel",onPointerUp_1);_this._domElement.addEventListener("wheel",onMouseWheel_1,{passive:false});_this._domElement.addEventListener("contextmenu",onContextMenu_1);_this._domElement.addEventListener("gesturestart",onGestureStart_1);_this._domElement.addEventListener("gesturechange",onGestureChanged_1);_this._removeAllEventListeners=function(){_this._domElement.removeEventListener("pointerdown",onPointerDown_1);_this._domElement.removeEventListener("mousedown",onMouseDown_1);_this._domElement.removeEventListener("touchstart",onTouchStart_1);_this._domElement.removeEventListener("pointercancel",onPointerUp_1);_this._domElement.removeEventListener("wheel",onMouseWheel_1,{passive:false});_this._domElement.removeEventListener("contextmenu",onContextMenu_1);_this._domElement.ownerDocument.removeEventListener("pointermove",onPointerMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("mousemove",onMouseMove_1);_this._domElement.ownerDocument.removeEventListener("touchmove",onTouchMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("pointerup",onPointerUp_1);_this._domElement.ownerDocument.removeEventListener("mouseup",onMouseUp_1);_this._domElement.ownerDocument.removeEventListener("touchend",onTouchEnd_1);_this._domElement.removeEventListener("gesturestart",onGestureStart_1);_this._domElement.removeEventListener("gesturechange",onGestureChanged_1)};_this.cancel=function(){cancelDragging_1();_this.dispatchEvent({type:"controlend"})}}_this.update(0);return _this}CameraControls.install=function(libs){THREE=libs.THREE;_ORIGIN=Object.freeze(new THREE.Vector3(0,0,0));_AXIS_Y=Object.freeze(new THREE.Vector3(0,1,0));_AXIS_Z=Object.freeze(new THREE.Vector3(0,0,1));_v2=new THREE.Vector2;_v3A=new THREE.Vector3;_v3B=new THREE.Vector3;_v3C=new THREE.Vector3;_xColumn=new THREE.Vector3;_yColumn=new THREE.Vector3;_zColumn=new THREE.Vector3;_sphericalA=new THREE.Spherical;_sphericalB=new THREE.Spherical;_box3A=new THREE.Box3;_box3B=new THREE.Box3;_sphere=new THREE.Sphere;_quaternionA=new THREE.Quaternion;_quaternionB=new THREE.Quaternion;_rotationMatrix=new THREE.Matrix4;_raycaster=new THREE.Raycaster};Object.defineProperty(CameraControls,"ACTION",{get:function(){return readonlyACTION},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"camera",{get:function(){return this._camera},set:function(camera){this._camera=camera;this.updateCameraUp();this._camera.updateProjectionMatrix();this._updateNearPlaneCorners();this._needsUpdate=true},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"enabled",{get:function(){return this._enabled},set:function(enabled){this._enabled=enabled;if(!enabled)this.cancel()},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"active",{get:function(){return!this._hasRested},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"currentAction",{get:function(){return this._state},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"distance",{get:function(){return this._spherical.radius},set:function(distance){if(this._spherical.radius===distance&&this._sphericalEnd.radius===distance)return;this._spherical.radius=distance;this._sphericalEnd.radius=distance;this._needsUpdate=true},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"azimuthAngle",{get:function(){return this._spherical.theta},set:function(azimuthAngle){if(this._spherical.theta===azimuthAngle&&this._sphericalEnd.theta===azimuthAngle)return;this._spherical.theta=azimuthAngle;this._sphericalEnd.theta=azimuthAngle;this._needsUpdate=true},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"polarAngle",{get:function(){return this._spherical.phi},set:function(polarAngle){if(this._spherical.phi===polarAngle&&this._sphericalEnd.phi===polarAngle)return;this._spherical.phi=polarAngle;this._sphericalEnd.phi=polarAngle;this._needsUpdate=true},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"boundaryEnclosesCamera",{get:function(){return this._boundaryEnclosesCamera},set:function(boundaryEnclosesCamera){this._boundaryEnclosesCamera=boundaryEnclosesCamera;this._needsUpdate=true},enumerable:false,configurable:true});CameraControls.prototype.addEventListener=function(type,listener){_super.prototype.addEventListener.call(this,type,listener)};CameraControls.prototype.removeEventListener=function(type,listener){_super.prototype.removeEventListener.call(this,type,listener)};CameraControls.prototype.rotate=function(azimuthAngle,polarAngle,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.rotateTo(this._sphericalEnd.theta+azimuthAngle,this._sphericalEnd.phi+polarAngle,enableTransition)};CameraControls.prototype.rotateAzimuthTo=function(azimuthAngle,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.rotateTo(this._sphericalEnd.theta+azimuthAngle,this._sphericalEnd.phi,enableTransition)};CameraControls.prototype.rotatePolarTo=function(polarAngle,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.rotateTo(this._sphericalEnd.theta,this._sphericalEnd.phi+polarAngle,enableTransition)};CameraControls.prototype.rotateTo=function(azimuthAngle,polarAngle,enableTransition){if(enableTransition===void 0){enableTransition=false}var theta=THREE.MathUtils.clamp(azimuthAngle,this.minAzimuthAngle,this.maxAzimuthAngle);var phi=THREE.MathUtils.clamp(polarAngle,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=theta;this._sphericalEnd.phi=phi;this._sphericalEnd.makeSafe();this._needsUpdate=true;if(!enableTransition){this._spherical.theta=this._sphericalEnd.theta;this._spherical.phi=this._sphericalEnd.phi}var resolveImmediately=!enableTransition||approxEquals(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&approxEquals(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.dolly=function(distance,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.dollyTo(this._sphericalEnd.radius-distance,enableTransition)};CameraControls.prototype.dollyTo=function(distance,enableTransition){if(enableTransition===void 0){enableTransition=false}var lastRadius=this._sphericalEnd.radius;var newRadius=THREE.MathUtils.clamp(distance,this.minDistance,this.maxDistance);var hasCollider=this.colliderMeshes.length>=1;if(hasCollider){var maxDistanceByCollisionTest=this._collisionTest();var isCollided=approxEquals(maxDistanceByCollisionTest,this._spherical.radius);var isDollyIn=lastRadius>newRadius;if(!isDollyIn&&isCollided)return Promise.resolve();this._sphericalEnd.radius=Math.min(newRadius,maxDistanceByCollisionTest)}else{this._sphericalEnd.radius=newRadius}this._needsUpdate=true;if(!enableTransition){this._spherical.radius=this._sphericalEnd.radius}var resolveImmediately=!enableTransition||approxEquals(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.zoom=function(zoomStep,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.zoomTo(this._zoomEnd+zoomStep,enableTransition)};CameraControls.prototype.zoomTo=function(zoom,enableTransition){if(enableTransition===void 0){enableTransition=false}this._zoomEnd=THREE.MathUtils.clamp(zoom,this.minZoom,this.maxZoom);this._needsUpdate=true;if(!enableTransition){this._zoom=this._zoomEnd}var resolveImmediately=!enableTransition||approxEquals(this._zoom,this._zoomEnd,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.pan=function(x,y,enableTransition){if(enableTransition===void 0){enableTransition=false}console.warn("`pan` has been renamed to `truck`");return this.truck(x,y,enableTransition)};CameraControls.prototype.truck=function(x,y,enableTransition){if(enableTransition===void 0){enableTransition=false}this._camera.updateMatrix();_xColumn.setFromMatrixColumn(this._camera.matrix,0);_yColumn.setFromMatrixColumn(this._camera.matrix,1);_xColumn.multiplyScalar(x);_yColumn.multiplyScalar(-y);var offset=_v3A.copy(_xColumn).add(_yColumn);var to=_v3B.copy(this._targetEnd).add(offset);return this.moveTo(to.x,to.y,to.z,enableTransition)};CameraControls.prototype.forward=function(distance,enableTransition){if(enableTransition===void 0){enableTransition=false}_v3A.setFromMatrixColumn(this._camera.matrix,0);_v3A.crossVectors(this._camera.up,_v3A);_v3A.multiplyScalar(distance);var to=_v3B.copy(this._targetEnd).add(_v3A);return this.moveTo(to.x,to.y,to.z,enableTransition)};CameraControls.prototype.moveTo=function(x,y,z,enableTransition){if(enableTransition===void 0){enableTransition=false}var offset=_v3A.set(x,y,z).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,offset,this.boundaryFriction);this._needsUpdate=true;if(!enableTransition){this._target.copy(this._targetEnd)}var resolveImmediately=!enableTransition||approxEquals(this._target.x,this._targetEnd.x,this.restThreshold)&&approxEquals(this._target.y,this._targetEnd.y,this.restThreshold)&&approxEquals(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.fitToBox=function(box3OrObject,enableTransition,_a){var _b=_a===void 0?{}:_a,_c=_b.paddingLeft,paddingLeft=_c===void 0?0:_c,_d=_b.paddingRight,paddingRight=_d===void 0?0:_d,_e=_b.paddingBottom,paddingBottom=_e===void 0?0:_e,_f=_b.paddingTop,paddingTop=_f===void 0?0:_f;var promises=[];var aabb=box3OrObject.isBox3?_box3A.copy(box3OrObject):_box3A.setFromObject(box3OrObject);if(aabb.isEmpty()){console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting");Promise.resolve()}var theta=roundToStep(this._sphericalEnd.theta,PI_HALF);var phi=roundToStep(this._sphericalEnd.phi,PI_HALF);promises.push(this.rotateTo(theta,phi,enableTransition));var normal=_v3A.setFromSpherical(this._sphericalEnd).normalize();var rotation=_quaternionA.setFromUnitVectors(normal,_AXIS_Z);var viewFromPolar=approxEquals(Math.abs(normal.y),1);if(viewFromPolar){rotation.multiply(_quaternionB.setFromAxisAngle(_AXIS_Y,theta))}var bb=_box3B.makeEmpty();_v3B.copy(aabb.min).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.min).setX(aabb.max.x).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.min).setY(aabb.max.y).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.max).setZ(aabb.min.z).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.min).setZ(aabb.max.z).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.max).setY(aabb.min.y).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.max).setX(aabb.min.x).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.max).applyQuaternion(rotation);bb.expandByPoint(_v3B);rotation.setFromUnitVectors(_AXIS_Z,normal);bb.min.x-=paddingLeft;bb.min.y-=paddingBottom;bb.max.x+=paddingRight;bb.max.y+=paddingTop;var bbSize=bb.getSize(_v3A);var center=bb.getCenter(_v3B).applyQuaternion(rotation);if(isPerspectiveCamera(this._camera)){var distance=this.getDistanceToFitBox(bbSize.x,bbSize.y,bbSize.z);promises.push(this.moveTo(center.x,center.y,center.z,enableTransition));promises.push(this.dollyTo(distance,enableTransition));promises.push(this.setFocalOffset(0,0,0,enableTransition))}else if(isOrthographicCamera(this._camera)){var camera=this._camera;var width=camera.right-camera.left;var height=camera.top-camera.bottom;var zoom=Math.min(width/bbSize.x,height/bbSize.y);promises.push(this.moveTo(center.x,center.y,center.z,enableTransition));promises.push(this.zoomTo(zoom,enableTransition));promises.push(this.setFocalOffset(0,0,0,enableTransition))}return Promise.all(promises)};CameraControls.prototype.fitTo=function(box3OrObject,enableTransition,fitToOptions){if(fitToOptions===void 0){fitToOptions={}}console.warn("camera-controls: fitTo() has been renamed to fitToBox()");return this.fitToBox(box3OrObject,enableTransition,fitToOptions)};CameraControls.prototype.fitToSphere=function(sphereOrMesh,enableTransition){var promises=[];var isSphere=sphereOrMesh instanceof THREE.Sphere;var boundingSphere=isSphere?_sphere.copy(sphereOrMesh):createBoundingSphere(sphereOrMesh,_sphere);promises.push(this.moveTo(boundingSphere.center.x,boundingSphere.center.y,boundingSphere.center.z,enableTransition));if(isPerspectiveCamera(this._camera)){var distanceToFit=this.getDistanceToFitSphere(boundingSphere.radius);promises.push(this.dollyTo(distanceToFit,enableTransition))}else if(isOrthographicCamera(this._camera)){var width=this._camera.right-this._camera.left;var height=this._camera.top-this._camera.bottom;var diameter=2*boundingSphere.radius;var zoom=Math.min(width/diameter,height/diameter);promises.push(this.zoomTo(zoom,enableTransition))}promises.push(this.setFocalOffset(0,0,0,enableTransition));return Promise.all(promises)};CameraControls.prototype.setLookAt=function(positionX,positionY,positionZ,targetX,targetY,targetZ,enableTransition){if(enableTransition===void 0){enableTransition=false}var target=_v3B.set(targetX,targetY,targetZ);var position=_v3A.set(positionX,positionY,positionZ);this._targetEnd.copy(target);this._sphericalEnd.setFromVector3(position.sub(target).applyQuaternion(this._yAxisUpSpace));this.normalizeRotations();this._needsUpdate=true;if(!enableTransition){this._target.copy(this._targetEnd);this._spherical.copy(this._sphericalEnd)}var resolveImmediately=!enableTransition||approxEquals(this._target.x,this._targetEnd.x,this.restThreshold)&&approxEquals(this._target.y,this._targetEnd.y,this.restThreshold)&&approxEquals(this._target.z,this._targetEnd.z,this.restThreshold)&&approxEquals(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&approxEquals(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&approxEquals(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.lerpLookAt=function(positionAX,positionAY,positionAZ,targetAX,targetAY,targetAZ,positionBX,positionBY,positionBZ,targetBX,targetBY,targetBZ,t,enableTransition){if(enableTransition===void 0){enableTransition=false}var targetA=_v3A.set(targetAX,targetAY,targetAZ);var positionA=_v3B.set(positionAX,positionAY,positionAZ);_sphericalA.setFromVector3(positionA.sub(targetA).applyQuaternion(this._yAxisUpSpace));var targetB=_v3C.set(targetBX,targetBY,targetBZ);var positionB=_v3B.set(positionBX,positionBY,positionBZ);_sphericalB.setFromVector3(positionB.sub(targetB).applyQuaternion(this._yAxisUpSpace));this._targetEnd.copy(targetA.lerp(targetB,t));var deltaTheta=_sphericalB.theta-_sphericalA.theta;var deltaPhi=_sphericalB.phi-_sphericalA.phi;var deltaRadius=_sphericalB.radius-_sphericalA.radius;this._sphericalEnd.set(_sphericalA.radius+deltaRadius*t,_sphericalA.phi+deltaPhi*t,_sphericalA.theta+deltaTheta*t);this.normalizeRotations();this._needsUpdate=true;if(!enableTransition){this._target.copy(this._targetEnd);this._spherical.copy(this._sphericalEnd)}var resolveImmediately=!enableTransition||approxEquals(this._target.x,this._targetEnd.x,this.restThreshold)&&approxEquals(this._target.y,this._targetEnd.y,this.restThreshold)&&approxEquals(this._target.z,this._targetEnd.z,this.restThreshold)&&approxEquals(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&approxEquals(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&approxEquals(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.setPosition=function(positionX,positionY,positionZ,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.setLookAt(positionX,positionY,positionZ,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,enableTransition)};CameraControls.prototype.setTarget=function(targetX,targetY,targetZ,enableTransition){if(enableTransition===void 0){enableTransition=false}var pos=this.getPosition(_v3A);return this.setLookAt(pos.x,pos.y,pos.z,targetX,targetY,targetZ,enableTransition)};CameraControls.prototype.setFocalOffset=function(x,y,z,enableTransition){if(enableTransition===void 0){enableTransition=false}this._focalOffsetEnd.set(x,y,z);this._needsUpdate=true;if(!enableTransition){this._focalOffset.copy(this._focalOffsetEnd)}var resolveImmediately=!enableTransition||approxEquals(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&approxEquals(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&approxEquals(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.setOrbitPoint=function(targetX,targetY,targetZ){_xColumn.setFromMatrixColumn(this._camera.matrixWorldInverse,0);_yColumn.setFromMatrixColumn(this._camera.matrixWorldInverse,1);_zColumn.setFromMatrixColumn(this._camera.matrixWorldInverse,2);var position=_v3A.set(targetX,targetY,targetZ);var distance=position.distanceTo(this._camera.position);var cameraToPoint=position.sub(this._camera.position);_xColumn.multiplyScalar(cameraToPoint.x);_yColumn.multiplyScalar(cameraToPoint.y);_zColumn.multiplyScalar(cameraToPoint.z);_v3A.copy(_xColumn).add(_yColumn).add(_zColumn);_v3A.z=_v3A.z+distance;this.dollyTo(distance,false);this.setFocalOffset(-_v3A.x,_v3A.y,-_v3A.z,false);this.moveTo(targetX,targetY,targetZ,false)};CameraControls.prototype.setBoundary=function(box3){if(!box3){this._boundary.min.set(-Infinity,-Infinity,-Infinity);this._boundary.max.set(Infinity,Infinity,Infinity);this._needsUpdate=true;return}this._boundary.copy(box3);this._boundary.clampPoint(this._targetEnd,this._targetEnd);this._needsUpdate=true};CameraControls.prototype.setViewport=function(viewportOrX,y,width,height){if(viewportOrX===null){this._viewport=null;return}this._viewport=this._viewport||new THREE.Vector4;if(typeof viewportOrX==="number"){this._viewport.set(viewportOrX,y,width,height)}else{this._viewport.copy(viewportOrX)}};CameraControls.prototype.getDistanceToFitBox=function(width,height,depth){if(notSupportedInOrthographicCamera(this._camera,"getDistanceToFitBox"))return this._spherical.radius;var boundingRectAspect=width/height;var fov=this._camera.getEffectiveFOV()*THREE.MathUtils.DEG2RAD;var aspect=this._camera.aspect;var heightToFit=boundingRectAspect=1;if(!hasCollider)return distance;if(notSupportedInOrthographicCamera(this._camera,"_collisionTest"))return distance;var direction=_v3A.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);_rotationMatrix.lookAt(_ORIGIN,direction,this._camera.up);for(var i=0;i<4;i++){var nearPlaneCorner=_v3B.copy(this._nearPlaneCorners[i]);nearPlaneCorner.applyMatrix4(_rotationMatrix);var origin_1=_v3C.addVectors(this._target,nearPlaneCorner);_raycaster.set(origin_1,direction);_raycaster.far=this._spherical.radius+1;var intersects=_raycaster.intersectObjects(this.colliderMeshes);if(intersects.length!==0&&intersects[0].distance=0?-1:1);_this.dollyTo(distance);if(_this.infinityDolly&&(distance<_this.minDistance||_this.maxDistance===_this.minDistance)){_this._camera.getWorldDirection(_v3A);_this._targetEnd.add(_v3A.normalize().multiplyScalar(signedPrevRadius));_this._target.add(_v3A.normalize().multiplyScalar(signedPrevRadius))}if(_this.dollyToCursor){_this._dollyControlAmount+=_this._sphericalEnd.radius-prevRadius;if(_this.infinityDolly&&(distance<_this.minDistance||_this.maxDistance===_this.minDistance)){_this._dollyControlAmount-=signedPrevRadius}_this._dollyControlCoord.set(x,y)}return};_this._zoomInternal=function(delta,x,y){var zoomScale=Math.pow(.95,delta*_this.dollySpeed);_this.zoomTo(_this._zoom*zoomScale);if(_this.dollyToCursor){_this._dollyControlAmount=_this._zoomEnd;_this._dollyControlCoord.set(x,y)}return};if(typeof THREE==="undefined"){console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information.")}_this._camera=camera;_this._yAxisUpSpace=(new THREE.Quaternion).setFromUnitVectors(_this._camera.up,_AXIS_Y);_this._yAxisUpSpaceInverse=quatInvertCompat(_this._yAxisUpSpace.clone());_this._state=ACTION.NONE;_this._domElement=domElement;_this._domElement.style.touchAction="none";_this._target=new THREE.Vector3;_this._targetEnd=_this._target.clone();_this._focalOffset=new THREE.Vector3;_this._focalOffsetEnd=_this._focalOffset.clone();_this._spherical=(new THREE.Spherical).setFromVector3(_v3A.copy(_this._camera.position).applyQuaternion(_this._yAxisUpSpace));_this._sphericalEnd=_this._spherical.clone();_this._zoom=_this._camera.zoom;_this._zoomEnd=_this._zoom;_this._nearPlaneCorners=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];_this._updateNearPlaneCorners();_this._boundary=new THREE.Box3(new THREE.Vector3(-Infinity,-Infinity,-Infinity),new THREE.Vector3(Infinity,Infinity,Infinity));_this._target0=_this._target.clone();_this._position0=_this._camera.position.clone();_this._zoom0=_this._zoom;_this._focalOffset0=_this._focalOffset.clone();_this._dollyControlAmount=0;_this._dollyControlCoord=new THREE.Vector2;_this.mouseButtons={left:ACTION.ROTATE,middle:ACTION.DOLLY,right:ACTION.TRUCK,wheel:isPerspectiveCamera(_this._camera)?ACTION.DOLLY:isOrthographicCamera(_this._camera)?ACTION.ZOOM:ACTION.NONE,shiftLeft:ACTION.NONE,pinch:ACTION.NONE};_this.touches={one:ACTION.TOUCH_ROTATE,two:isPerspectiveCamera(_this._camera)?ACTION.TOUCH_DOLLY_TRUCK:isOrthographicCamera(_this._camera)?ACTION.TOUCH_ZOOM_TRUCK:ACTION.NONE,three:ACTION.TOUCH_TRUCK};_this._elementRect=new THREE.Vector4;if(_this._domElement){var dragStartPosition_1=new THREE.Vector2;var lastDragPosition_1=new THREE.Vector2;var dollyStart_1=new THREE.Vector2;var cancelDragging_1=function(){_this._state=ACTION.NONE;_this._activePointers.length=0;endDragging_1()};var onPointerDown_1=function(event){if(!_this._enabled)return;var pointer={pointerId:event.pointerId,clientX:event.clientX,clientY:event.clientY};_this._activePointers.push(pointer);switch(event.button){case THREE.MOUSE.LEFT:_this._state=event.shiftKey?_this.mouseButtons.shiftLeft:_this.mouseButtons.left;break;case THREE.MOUSE.MIDDLE:_this._state=_this.mouseButtons.middle;break;case THREE.MOUSE.RIGHT:_this._state=_this.mouseButtons.right;break}if(event.pointerType==="touch"){switch(_this._activePointers.length){case 1:_this._state=_this.touches.one;break;case 2:_this._state=_this.touches.two;break;case 3:_this._state=_this.touches.three;break}}_this._domElement.ownerDocument.removeEventListener("pointermove",onPointerMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("pointerup",onPointerUp_1);_this._domElement.ownerDocument.addEventListener("pointermove",onPointerMove_1,{passive:false});_this._domElement.ownerDocument.addEventListener("pointerup",onPointerUp_1);startDragging_1()};var onMouseDown_1=function(event){if(!_this._enabled)return;var pointer={pointerId:0,clientX:event.clientX,clientY:event.clientY};_this._activePointers.push(pointer);switch(event.button){case THREE.MOUSE.LEFT:_this._state=event.shiftKey?_this.mouseButtons.shiftLeft:_this.mouseButtons.left;break;case THREE.MOUSE.MIDDLE:_this._state=_this.mouseButtons.middle;break;case THREE.MOUSE.RIGHT:_this._state=_this.mouseButtons.right;break}_this._domElement.ownerDocument.removeEventListener("mousemove",onMouseMove_1);_this._domElement.ownerDocument.removeEventListener("mouseup",onMouseUp_1);_this._domElement.ownerDocument.addEventListener("mousemove",onMouseMove_1);_this._domElement.ownerDocument.addEventListener("mouseup",onMouseUp_1);startDragging_1()};var onTouchStart_1=function(event){if(!_this._enabled)return;event.preventDefault();Array.prototype.forEach.call(event.changedTouches,(function(touch){var pointer={pointerId:touch.identifier,clientX:touch.clientX,clientY:touch.clientY};_this._activePointers.push(pointer)}));switch(_this._activePointers.length){case 1:_this._state=_this.touches.one;break;case 2:_this._state=_this.touches.two;break;case 3:_this._state=_this.touches.three;break}_this._domElement.ownerDocument.removeEventListener("touchmove",onTouchMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("touchend",onTouchEnd_1);_this._domElement.ownerDocument.addEventListener("touchmove",onTouchMove_1,{passive:false});_this._domElement.ownerDocument.addEventListener("touchend",onTouchEnd_1);startDragging_1()};var onPointerMove_1=function(event){if(event.cancelable)event.preventDefault();var pointerId=event.pointerId;var pointer=_this._findPointerById(pointerId);if(!pointer)return;pointer.clientX=event.clientX;pointer.clientY=event.clientY;dragging_1()};var onMouseMove_1=function(event){var pointer=_this._findPointerById(0);if(!pointer)return;pointer.clientX=event.clientX;pointer.clientY=event.clientY;dragging_1()};var onTouchMove_1=function(event){if(event.cancelable)event.preventDefault();Array.prototype.forEach.call(event.changedTouches,(function(touch){var pointerId=touch.identifier;var pointer=_this._findPointerById(pointerId);if(!pointer)return;pointer.clientX=touch.clientX;pointer.clientY=touch.clientY}));dragging_1()};var onPointerUp_1=function(event){var pointerId=event.pointerId;var pointer=_this._findPointerById(pointerId);pointer&&_this._activePointers.splice(_this._activePointers.indexOf(pointer),1);if(event.pointerType==="touch"){switch(_this._activePointers.length){case 0:_this._state=ACTION.NONE;break;case 1:_this._state=_this.touches.one;break;case 2:_this._state=_this.touches.two;break;case 3:_this._state=_this.touches.three;break}}else{_this._state=ACTION.NONE}endDragging_1()};var onMouseUp_1=function(){var pointer=_this._findPointerById(0);pointer&&_this._activePointers.splice(_this._activePointers.indexOf(pointer),1);_this._state=ACTION.NONE;endDragging_1()};var onTouchEnd_1=function(event){Array.prototype.forEach.call(event.changedTouches,(function(touch){var pointerId=touch.identifier;var pointer=_this._findPointerById(pointerId);pointer&&_this._activePointers.splice(_this._activePointers.indexOf(pointer),1)}));switch(_this._activePointers.length){case 0:_this._state=ACTION.NONE;break;case 1:_this._state=_this.touches.one;break;case 2:_this._state=_this.touches.two;break;case 3:_this._state=_this.touches.three;break}endDragging_1()};var onGestureStart_1=function(event){if(!_this._enabled||_this.mouseButtons.pinch===ACTION.NONE||isTouchScreen)return;_this._gesturing=true;_this._gestureScaleStart=_this._zoom;event.preventDefault()};var onGestureChanged_1=function(event){if(!_this._enabled||_this.mouseButtons.pinch===ACTION.NONE||isTouchScreen||typeof _this._gestureScaleStart!=="number")return;_this._getClientRect(_this._elementRect);var x=_this.dollyToCursor?(event.clientX-_this._elementRect.x)/_this._elementRect.z*2-1:0;var y=_this.dollyToCursor?(event.clientY-_this._elementRect.y)/_this._elementRect.w*-2+1:0;var FACTOR=.5;if(_this.mouseButtons.pinch===ACTION.ZOOM){var to=(1-event.scale)*FACTOR;_this._zoomInternal(to,x,y)}if(_this.mouseButtons.pinch===ACTION.DOLLY){var to=(1-event.scale)*FACTOR;_this._dollyInternal(to,x,y)}event.preventDefault()};var lastScrollTimeStamp_1=-1;var onMouseWheel_1=function(event){var state=event.ctrlKey&&_this.mouseButtons.pinch!==ACTION.NONE?_this.mouseButtons.pinch:_this.mouseButtons.wheel;if(!_this._enabled||state===ACTION.NONE)return;event.preventDefault();if(_this.dollyToCursor||state===ACTION.ROTATE||state===ACTION.TRUCK){var now=performance.now();if(lastScrollTimeStamp_1-now<1e3)_this._getClientRect(_this._elementRect);lastScrollTimeStamp_1=now}var deltaYFactor=isMac?-1:-3;var delta=event.deltaMode===1?event.deltaY/deltaYFactor:event.deltaY/(deltaYFactor*10);var x=_this.dollyToCursor?(event.clientX-_this._elementRect.x)/_this._elementRect.z*2-1:0;var y=_this.dollyToCursor?(event.clientY-_this._elementRect.y)/_this._elementRect.w*-2+1:0;switch(state){case ACTION.ROTATE:{_this._rotateInternal(event.deltaX,event.deltaY);break}case ACTION.TRUCK:{_this._truckInternal(event.deltaX,event.deltaY,false);break}case ACTION.OFFSET:{_this._truckInternal(event.deltaX,event.deltaY,true);break}case ACTION.DOLLY:{_this._dollyInternal(-delta,x,y);break}case ACTION.ZOOM:{_this._zoomInternal(-delta,x,y);break}}_this.dispatchEvent({type:"control"})};var onContextMenu_1=function(event){if(!_this._enabled)return;event.preventDefault()};var startDragging_1=function(){if(!_this._enabled)return;extractClientCoordFromEvent(_this._activePointers,_v2);_this._getClientRect(_this._elementRect);dragStartPosition_1.copy(_v2);lastDragPosition_1.copy(_v2);var isMultiTouch=_this._activePointers.length>=2;if(isMultiTouch){var dx=_v2.x-_this._activePointers[1].clientX;var dy=_v2.y-_this._activePointers[1].clientY;var distance=Math.sqrt(dx*dx+dy*dy);dollyStart_1.set(0,distance);var x=(_this._activePointers[0].clientX+_this._activePointers[1].clientX)*.5;var y=(_this._activePointers[0].clientY+_this._activePointers[1].clientY)*.5;lastDragPosition_1.set(x,y)}_this.dispatchEvent({type:"controlstart"})};var dragging_1=function(){if(!_this._enabled)return;extractClientCoordFromEvent(_this._activePointers,_v2);var deltaX=lastDragPosition_1.x-_v2.x;var deltaY=lastDragPosition_1.y-_v2.y;lastDragPosition_1.copy(_v2);switch(_this._state){case ACTION.ROTATE:case ACTION.TOUCH_ROTATE:{_this._rotateInternal(deltaX,deltaY);break}case ACTION.DOLLY:case ACTION.ZOOM:{var dollyX=_this.dollyToCursor?(dragStartPosition_1.x-_this._elementRect.x)/_this._elementRect.z*2-1:0;var dollyY=_this.dollyToCursor?(dragStartPosition_1.y-_this._elementRect.y)/_this._elementRect.w*-2+1:0;_this._state===ACTION.DOLLY?_this._dollyInternal(deltaY*TOUCH_DOLLY_FACTOR,dollyX,dollyY):_this._zoomInternal(deltaY*TOUCH_DOLLY_FACTOR,dollyX,dollyY);break}case ACTION.TOUCH_DOLLY:case ACTION.TOUCH_ZOOM:case ACTION.TOUCH_DOLLY_TRUCK:case ACTION.TOUCH_ZOOM_TRUCK:case ACTION.TOUCH_DOLLY_OFFSET:case ACTION.TOUCH_ZOOM_OFFSET:{var dx=_v2.x-_this._activePointers[1].clientX;var dy=_v2.y-_this._activePointers[1].clientY;var distance=Math.sqrt(dx*dx+dy*dy);var dollyDelta=dollyStart_1.y-distance;dollyStart_1.set(0,distance);var dollyX=_this.dollyToCursor?(lastDragPosition_1.x-_this._elementRect.x)/_this._elementRect.z*2-1:0;var dollyY=_this.dollyToCursor?(lastDragPosition_1.y-_this._elementRect.y)/_this._elementRect.w*-2+1:0;_this._state===ACTION.TOUCH_DOLLY||_this._state===ACTION.TOUCH_DOLLY_TRUCK||_this._state===ACTION.TOUCH_DOLLY_OFFSET?_this._dollyInternal(dollyDelta*TOUCH_DOLLY_FACTOR,dollyX,dollyY):_this._zoomInternal(dollyDelta*TOUCH_DOLLY_FACTOR,dollyX,dollyY);if(_this._state===ACTION.TOUCH_DOLLY_TRUCK||_this._state===ACTION.TOUCH_ZOOM_TRUCK){_this._truckInternal(deltaX,deltaY,false)}else if(_this._state===ACTION.TOUCH_DOLLY_OFFSET||_this._state===ACTION.TOUCH_ZOOM_OFFSET){_this._truckInternal(deltaX,deltaY,true)}break}case ACTION.TRUCK:case ACTION.TOUCH_TRUCK:{_this._truckInternal(deltaX,deltaY,false);break}case ACTION.OFFSET:case ACTION.TOUCH_OFFSET:{_this._truckInternal(deltaX,deltaY,true);break}}_this.dispatchEvent({type:"control"})};var endDragging_1=function(){extractClientCoordFromEvent(_this._activePointers,_v2);lastDragPosition_1.copy(_v2);if(_this._activePointers.length===0){_this._domElement.ownerDocument.removeEventListener("pointermove",onPointerMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("pointerup",onPointerUp_1);_this._domElement.ownerDocument.removeEventListener("touchmove",onTouchMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("touchend",onTouchEnd_1)}_this.dispatchEvent({type:"controlend"})};_this._domElement.addEventListener("pointerdown",onPointerDown_1);isPointerEventsNotSupported&&_this._domElement.addEventListener("mousedown",onMouseDown_1);isPointerEventsNotSupported&&_this._domElement.addEventListener("touchstart",onTouchStart_1);_this._domElement.addEventListener("pointercancel",onPointerUp_1);_this._domElement.addEventListener("wheel",onMouseWheel_1,{passive:false});_this._domElement.addEventListener("contextmenu",onContextMenu_1);_this._domElement.addEventListener("gesturestart",onGestureStart_1);_this._domElement.addEventListener("gesturechange",onGestureChanged_1);_this._removeAllEventListeners=function(){_this._domElement.removeEventListener("pointerdown",onPointerDown_1);_this._domElement.removeEventListener("mousedown",onMouseDown_1);_this._domElement.removeEventListener("touchstart",onTouchStart_1);_this._domElement.removeEventListener("pointercancel",onPointerUp_1);_this._domElement.removeEventListener("wheel",onMouseWheel_1,{passive:false});_this._domElement.removeEventListener("contextmenu",onContextMenu_1);_this._domElement.ownerDocument.removeEventListener("pointermove",onPointerMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("mousemove",onMouseMove_1);_this._domElement.ownerDocument.removeEventListener("touchmove",onTouchMove_1,{passive:false});_this._domElement.ownerDocument.removeEventListener("pointerup",onPointerUp_1);_this._domElement.ownerDocument.removeEventListener("mouseup",onMouseUp_1);_this._domElement.ownerDocument.removeEventListener("touchend",onTouchEnd_1);_this._domElement.removeEventListener("gesturestart",onGestureStart_1);_this._domElement.removeEventListener("gesturechange",onGestureChanged_1)};_this.cancel=function(){cancelDragging_1();_this.dispatchEvent({type:"controlend"})}}_this.update(0);return _this}CameraControls.install=function(libs){THREE=libs.THREE;_ORIGIN=Object.freeze(new THREE.Vector3(0,0,0));_AXIS_Y=Object.freeze(new THREE.Vector3(0,1,0));_AXIS_Z=Object.freeze(new THREE.Vector3(0,0,1));_v2=new THREE.Vector2;_v3A=new THREE.Vector3;_v3B=new THREE.Vector3;_v3C=new THREE.Vector3;_xColumn=new THREE.Vector3;_yColumn=new THREE.Vector3;_zColumn=new THREE.Vector3;_sphericalA=new THREE.Spherical;_sphericalB=new THREE.Spherical;_box3A=new THREE.Box3;_box3B=new THREE.Box3;_sphere=new THREE.Sphere;_quaternionA=new THREE.Quaternion;_quaternionB=new THREE.Quaternion;_rotationMatrix=new THREE.Matrix4;_raycaster=new THREE.Raycaster};Object.defineProperty(CameraControls,"ACTION",{get:function(){return readonlyACTION},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"camera",{get:function(){return this._camera},set:function(camera){this._camera=camera;this.updateCameraUp();this._camera.updateProjectionMatrix();this._updateNearPlaneCorners();this._needsUpdate=true},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"enabled",{get:function(){return this._enabled},set:function(enabled){this._enabled=enabled;if(!enabled)this.cancel()},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"active",{get:function(){return!this._hasRested},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"currentAction",{get:function(){return this._state},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"distance",{get:function(){return this._spherical.radius},set:function(distance){if(this._spherical.radius===distance&&this._sphericalEnd.radius===distance)return;this._spherical.radius=distance;this._sphericalEnd.radius=distance;this._needsUpdate=true},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"azimuthAngle",{get:function(){return this._spherical.theta},set:function(azimuthAngle){if(this._spherical.theta===azimuthAngle&&this._sphericalEnd.theta===azimuthAngle)return;this._spherical.theta=azimuthAngle;this._sphericalEnd.theta=azimuthAngle;this._needsUpdate=true},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"polarAngle",{get:function(){return this._spherical.phi},set:function(polarAngle){if(this._spherical.phi===polarAngle&&this._sphericalEnd.phi===polarAngle)return;this._spherical.phi=polarAngle;this._sphericalEnd.phi=polarAngle;this._needsUpdate=true},enumerable:false,configurable:true});Object.defineProperty(CameraControls.prototype,"boundaryEnclosesCamera",{get:function(){return this._boundaryEnclosesCamera},set:function(boundaryEnclosesCamera){this._boundaryEnclosesCamera=boundaryEnclosesCamera;this._needsUpdate=true},enumerable:false,configurable:true});CameraControls.prototype.addEventListener=function(type,listener){_super.prototype.addEventListener.call(this,type,listener)};CameraControls.prototype.removeEventListener=function(type,listener){_super.prototype.removeEventListener.call(this,type,listener)};CameraControls.prototype.rotate=function(azimuthAngle,polarAngle,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.rotateTo(this._sphericalEnd.theta+azimuthAngle,this._sphericalEnd.phi+polarAngle,enableTransition)};CameraControls.prototype.rotateAzimuthTo=function(azimuthAngle,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.rotateTo(this._sphericalEnd.theta+azimuthAngle,this._sphericalEnd.phi,enableTransition)};CameraControls.prototype.rotatePolarTo=function(polarAngle,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.rotateTo(this._sphericalEnd.theta,this._sphericalEnd.phi+polarAngle,enableTransition)};CameraControls.prototype.rotateTo=function(azimuthAngle,polarAngle,enableTransition){if(enableTransition===void 0){enableTransition=false}var theta=THREE.MathUtils.clamp(azimuthAngle,this.minAzimuthAngle,this.maxAzimuthAngle);var phi=THREE.MathUtils.clamp(polarAngle,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=theta;this._sphericalEnd.phi=phi;this._sphericalEnd.makeSafe();this._needsUpdate=true;if(!enableTransition){this._spherical.theta=this._sphericalEnd.theta;this._spherical.phi=this._sphericalEnd.phi}var resolveImmediately=!enableTransition||approxEquals(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&approxEquals(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.dolly=function(distance,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.dollyTo(this._sphericalEnd.radius-distance,enableTransition)};CameraControls.prototype.dollyTo=function(distance,enableTransition){if(enableTransition===void 0){enableTransition=false}var lastRadius=this._sphericalEnd.radius;var newRadius=THREE.MathUtils.clamp(distance,this.minDistance,this.maxDistance);var hasCollider=this.colliderMeshes.length>=1;if(hasCollider){var maxDistanceByCollisionTest=this._collisionTest();var isCollided=approxEquals(maxDistanceByCollisionTest,this._spherical.radius);var isDollyIn=lastRadius>newRadius;if(!isDollyIn&&isCollided)return Promise.resolve();this._sphericalEnd.radius=Math.min(newRadius,maxDistanceByCollisionTest)}else{this._sphericalEnd.radius=newRadius}this._needsUpdate=true;if(!enableTransition){this._spherical.radius=this._sphericalEnd.radius}var resolveImmediately=!enableTransition||approxEquals(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.zoom=function(zoomStep,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.zoomTo(this._zoomEnd+zoomStep,enableTransition)};CameraControls.prototype.zoomTo=function(zoom,enableTransition){if(enableTransition===void 0){enableTransition=false}this._zoomEnd=THREE.MathUtils.clamp(zoom,this.minZoom,this.maxZoom);this._needsUpdate=true;if(!enableTransition){this._zoom=this._zoomEnd}var resolveImmediately=!enableTransition||approxEquals(this._zoom,this._zoomEnd,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.pan=function(x,y,enableTransition){if(enableTransition===void 0){enableTransition=false}console.warn("`pan` has been renamed to `truck`");return this.truck(x,y,enableTransition)};CameraControls.prototype.truck=function(x,y,enableTransition){if(enableTransition===void 0){enableTransition=false}this._camera.updateMatrix();_xColumn.setFromMatrixColumn(this._camera.matrix,0);_yColumn.setFromMatrixColumn(this._camera.matrix,1);_xColumn.multiplyScalar(x);_yColumn.multiplyScalar(-y);var offset=_v3A.copy(_xColumn).add(_yColumn);var to=_v3B.copy(this._targetEnd).add(offset);return this.moveTo(to.x,to.y,to.z,enableTransition)};CameraControls.prototype.forward=function(distance,enableTransition){if(enableTransition===void 0){enableTransition=false}_v3A.setFromMatrixColumn(this._camera.matrix,0);_v3A.crossVectors(this._camera.up,_v3A);_v3A.multiplyScalar(distance);var to=_v3B.copy(this._targetEnd).add(_v3A);return this.moveTo(to.x,to.y,to.z,enableTransition)};CameraControls.prototype.moveTo=function(x,y,z,enableTransition){if(enableTransition===void 0){enableTransition=false}var offset=_v3A.set(x,y,z).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,offset,this.boundaryFriction);this._needsUpdate=true;if(!enableTransition){this._target.copy(this._targetEnd)}var resolveImmediately=!enableTransition||approxEquals(this._target.x,this._targetEnd.x,this.restThreshold)&&approxEquals(this._target.y,this._targetEnd.y,this.restThreshold)&&approxEquals(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.fitToBox=function(box3OrObject,enableTransition,_a,lock){var _b=_a===void 0?{}:_a,_c=_b.paddingLeft,paddingLeft=_c===void 0?0:_c,_d=_b.paddingRight,paddingRight=_d===void 0?0:_d,_e=_b.paddingBottom,paddingBottom=_e===void 0?0:_e,_f=_b.paddingTop,paddingTop=_f===void 0?0:_f;var promises=[];var aabb=box3OrObject.isBox3?_box3A.copy(box3OrObject):_box3A.setFromObject(box3OrObject);if(aabb.isEmpty()){console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting");Promise.resolve()}var theta;var phi;if(!lock){theta=roundToStep(this._sphericalEnd.theta,PI_HALF);phi=roundToStep(this._sphericalEnd.phi,PI_HALF)}else{theta=lock==="front"?0:Math.PI;phi=lock==="front"?0:Math.PI}promises.push(this.rotateTo(theta,phi,enableTransition));var normal=_v3A.setFromSpherical(this._sphericalEnd).normalize();var rotation=_quaternionA.setFromUnitVectors(normal,_AXIS_Z);var viewFromPolar=approxEquals(Math.abs(normal.y),1);if(viewFromPolar){rotation.multiply(_quaternionB.setFromAxisAngle(_AXIS_Y,theta))}var bb=_box3B.makeEmpty();_v3B.copy(aabb.min).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.min).setX(aabb.max.x).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.min).setY(aabb.max.y).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.max).setZ(aabb.min.z).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.min).setZ(aabb.max.z).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.max).setY(aabb.min.y).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.max).setX(aabb.min.x).applyQuaternion(rotation);bb.expandByPoint(_v3B);_v3B.copy(aabb.max).applyQuaternion(rotation);bb.expandByPoint(_v3B);rotation.setFromUnitVectors(_AXIS_Z,normal);bb.min.x-=paddingLeft;bb.min.y-=paddingBottom;bb.max.x+=paddingRight;bb.max.y+=paddingTop;var bbSize=bb.getSize(_v3A);var center=bb.getCenter(_v3B).applyQuaternion(rotation);if(isPerspectiveCamera(this._camera)){var distance=this.getDistanceToFitBox(bbSize.x,bbSize.y,bbSize.z);promises.push(this.moveTo(center.x,center.y,center.z,enableTransition));promises.push(this.dollyTo(distance,enableTransition));promises.push(this.setFocalOffset(0,0,0,enableTransition))}else if(isOrthographicCamera(this._camera)){var camera=this._camera;var width=camera.right-camera.left;var height=camera.top-camera.bottom;var zoom=Math.min(width/bbSize.x,height/bbSize.y);promises.push(this.moveTo(center.x,center.y,center.z,enableTransition));promises.push(this.zoomTo(zoom,enableTransition));promises.push(this.setFocalOffset(0,0,0,enableTransition))}return Promise.all(promises)};CameraControls.prototype.fitTo=function(box3OrObject,enableTransition,fitToOptions){if(fitToOptions===void 0){fitToOptions={}}console.warn("camera-controls: fitTo() has been renamed to fitToBox()");return this.fitToBox(box3OrObject,enableTransition,fitToOptions)};CameraControls.prototype.fitToSphere=function(sphereOrMesh,enableTransition){var promises=[];var isSphere=sphereOrMesh instanceof THREE.Sphere;var boundingSphere=isSphere?_sphere.copy(sphereOrMesh):createBoundingSphere(sphereOrMesh,_sphere);promises.push(this.moveTo(boundingSphere.center.x,boundingSphere.center.y,boundingSphere.center.z,enableTransition));if(isPerspectiveCamera(this._camera)){var distanceToFit=this.getDistanceToFitSphere(boundingSphere.radius);promises.push(this.dollyTo(distanceToFit,enableTransition))}else if(isOrthographicCamera(this._camera)){var width=this._camera.right-this._camera.left;var height=this._camera.top-this._camera.bottom;var diameter=2*boundingSphere.radius;var zoom=Math.min(width/diameter,height/diameter);promises.push(this.zoomTo(zoom,enableTransition))}promises.push(this.setFocalOffset(0,0,0,enableTransition));return Promise.all(promises)};CameraControls.prototype.setLookAt=function(positionX,positionY,positionZ,targetX,targetY,targetZ,enableTransition){if(enableTransition===void 0){enableTransition=false}var target=_v3B.set(targetX,targetY,targetZ);var position=_v3A.set(positionX,positionY,positionZ);this._targetEnd.copy(target);this._sphericalEnd.setFromVector3(position.sub(target).applyQuaternion(this._yAxisUpSpace));this.normalizeRotations();this._needsUpdate=true;if(!enableTransition){this._target.copy(this._targetEnd);this._spherical.copy(this._sphericalEnd)}var resolveImmediately=!enableTransition||approxEquals(this._target.x,this._targetEnd.x,this.restThreshold)&&approxEquals(this._target.y,this._targetEnd.y,this.restThreshold)&&approxEquals(this._target.z,this._targetEnd.z,this.restThreshold)&&approxEquals(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&approxEquals(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&approxEquals(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.lerpLookAt=function(positionAX,positionAY,positionAZ,targetAX,targetAY,targetAZ,positionBX,positionBY,positionBZ,targetBX,targetBY,targetBZ,t,enableTransition){if(enableTransition===void 0){enableTransition=false}var targetA=_v3A.set(targetAX,targetAY,targetAZ);var positionA=_v3B.set(positionAX,positionAY,positionAZ);_sphericalA.setFromVector3(positionA.sub(targetA).applyQuaternion(this._yAxisUpSpace));var targetB=_v3C.set(targetBX,targetBY,targetBZ);var positionB=_v3B.set(positionBX,positionBY,positionBZ);_sphericalB.setFromVector3(positionB.sub(targetB).applyQuaternion(this._yAxisUpSpace));this._targetEnd.copy(targetA.lerp(targetB,t));var deltaTheta=_sphericalB.theta-_sphericalA.theta;var deltaPhi=_sphericalB.phi-_sphericalA.phi;var deltaRadius=_sphericalB.radius-_sphericalA.radius;this._sphericalEnd.set(_sphericalA.radius+deltaRadius*t,_sphericalA.phi+deltaPhi*t,_sphericalA.theta+deltaTheta*t);this.normalizeRotations();this._needsUpdate=true;if(!enableTransition){this._target.copy(this._targetEnd);this._spherical.copy(this._sphericalEnd)}var resolveImmediately=!enableTransition||approxEquals(this._target.x,this._targetEnd.x,this.restThreshold)&&approxEquals(this._target.y,this._targetEnd.y,this.restThreshold)&&approxEquals(this._target.z,this._targetEnd.z,this.restThreshold)&&approxEquals(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&approxEquals(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&approxEquals(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.setPosition=function(positionX,positionY,positionZ,enableTransition){if(enableTransition===void 0){enableTransition=false}return this.setLookAt(positionX,positionY,positionZ,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,enableTransition)};CameraControls.prototype.setTarget=function(targetX,targetY,targetZ,enableTransition){if(enableTransition===void 0){enableTransition=false}var pos=this.getPosition(_v3A);return this.setLookAt(pos.x,pos.y,pos.z,targetX,targetY,targetZ,enableTransition)};CameraControls.prototype.setFocalOffset=function(x,y,z,enableTransition){if(enableTransition===void 0){enableTransition=false}this._focalOffsetEnd.set(x,y,z);this._needsUpdate=true;if(!enableTransition){this._focalOffset.copy(this._focalOffsetEnd)}var resolveImmediately=!enableTransition||approxEquals(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&approxEquals(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&approxEquals(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(resolveImmediately)};CameraControls.prototype.setOrbitPoint=function(targetX,targetY,targetZ){_xColumn.setFromMatrixColumn(this._camera.matrixWorldInverse,0);_yColumn.setFromMatrixColumn(this._camera.matrixWorldInverse,1);_zColumn.setFromMatrixColumn(this._camera.matrixWorldInverse,2);var position=_v3A.set(targetX,targetY,targetZ);var distance=position.distanceTo(this._camera.position);var cameraToPoint=position.sub(this._camera.position);_xColumn.multiplyScalar(cameraToPoint.x);_yColumn.multiplyScalar(cameraToPoint.y);_zColumn.multiplyScalar(cameraToPoint.z);_v3A.copy(_xColumn).add(_yColumn).add(_zColumn);_v3A.z=_v3A.z+distance;this.dollyTo(distance,false);this.setFocalOffset(-_v3A.x,_v3A.y,-_v3A.z,false);this.moveTo(targetX,targetY,targetZ,false)};CameraControls.prototype.setBoundary=function(box3){if(!box3){this._boundary.min.set(-Infinity,-Infinity,-Infinity);this._boundary.max.set(Infinity,Infinity,Infinity);this._needsUpdate=true;return}this._boundary.copy(box3);this._boundary.clampPoint(this._targetEnd,this._targetEnd);this._needsUpdate=true};CameraControls.prototype.setViewport=function(viewportOrX,y,width,height){if(viewportOrX===null){this._viewport=null;return}this._viewport=this._viewport||new THREE.Vector4;if(typeof viewportOrX==="number"){this._viewport.set(viewportOrX,y,width,height)}else{this._viewport.copy(viewportOrX)}};CameraControls.prototype.getDistanceToFitBox=function(width,height,depth){if(notSupportedInOrthographicCamera(this._camera,"getDistanceToFitBox"))return this._spherical.radius;var boundingRectAspect=width/height;var fov=this._camera.getEffectiveFOV()*THREE.MathUtils.DEG2RAD;var aspect=this._camera.aspect;var heightToFit=boundingRectAspect=1;if(!hasCollider)return distance;if(notSupportedInOrthographicCamera(this._camera,"_collisionTest"))return distance;var direction=_v3A.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);_rotationMatrix.lookAt(_ORIGIN,direction,this._camera.up);for(var i=0;i<4;i++){var nearPlaneCorner=_v3B.copy(this._nearPlaneCorners[i]);nearPlaneCorner.applyMatrix4(_rotationMatrix);var origin_1=_v3C.addVectors(this._target,nearPlaneCorner);_raycaster.set(origin_1,direction);_raycaster.far=this._spherical.radius+1;var intersects=_raycaster.intersectObjects(this.colliderMeshes);if(intersects.length!==0&&intersects[0].distance = {} ): Promise { + }: Partial = {}, lock?: "front" | "back" ): Promise { const promises = []; const aabb = ( box3OrObject as _THREE.Box3 ).isBox3 @@ -1295,8 +1295,15 @@ export class CameraControls extends EventDispatcher { } // round to closest axis ( forward | backward | right | left | top | bottom ) - const theta = roundToStep( this._sphericalEnd.theta, PI_HALF ); - const phi = roundToStep( this._sphericalEnd.phi, PI_HALF ); + let theta; + let phi; + if (!lock) { + theta = roundToStep( this._sphericalEnd.theta, PI_HALF ); + phi = roundToStep( this._sphericalEnd.phi, PI_HALF ); + } else { + theta = lock === "front" ? 0 : Math.PI; + phi = lock === "front" ? 0 : Math.PI; + } promises.push( this.rotateTo( theta, phi, enableTransition ) );