three-stdlib 2.5.8 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),i=require("three");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=s(t);const a={IDLE:Symbol(),ROTATE:Symbol(),PAN:Symbol(),SCALE:Symbol(),FOV:Symbol(),FOCUS:Symbol(),ZROTATE:Symbol(),TOUCH_MULTI:Symbol(),ANIMATION_FOCUS:Symbol(),ANIMATION_ROTATE:Symbol()},o={NONE:Symbol(),ONE_FINGER:Symbol(),ONE_FINGER_SWITCHED:Symbol(),TWO_FINGER:Symbol(),MULT_FINGER:Symbol(),CURSOR:Symbol()},h={x:0,y:0},r={camera:new i.Matrix4,gizmos:new i.Matrix4},n={type:"change"},c={type:"start"},m={type:"end"};class _ extends i.Object3D{constructor(t,s,_=null){super(),e.default(this,"onWindowResize",(()=>{const t=(this._gizmos.scale.x+this._gizmos.scale.y+this._gizmos.scale.z)/3;this._tbRadius=this.calculateTbRadius(this.camera);const s=this._tbRadius/t,e=new i.EllipseCurve(0,0,s,s).getPoints(this._curvePts),a=(new i.BufferGeometry).setFromPoints(e);for(const t in this._gizmos.children)this._gizmos.children[t].geometry=a;this.dispatchEvent(n)})),e.default(this,"onContextMenu",(t=>{if(this.enabled)for(let i=0;i<this.mouseActions.length;i++)if(2==this.mouseActions[i].mouse){t.preventDefault();break}})),e.default(this,"onPointerCancel",(()=>{this._touchStart.splice(0,this._touchStart.length),this._touchCurrent.splice(0,this._touchCurrent.length),this._input=o.NONE})),e.default(this,"onPointerDown",(t=>{if(0==t.button&&t.isPrimary?(this._downValid=!0,this._downEvents.push(t),this._downStart=performance.now()):this._downValid=!1,"touch"==t.pointerType&&this._input!=o.CURSOR)switch(this._touchStart.push(t),this._touchCurrent.push(t),this._input){case o.NONE:this._input=o.ONE_FINGER,this.onSinglePanStart(t,"ROTATE"),window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp);break;case o.ONE_FINGER:case o.ONE_FINGER_SWITCHED:this._input=o.TWO_FINGER,this.onRotateStart(),this.onPinchStart(),this.onDoublePanStart();break;case o.TWO_FINGER:this._input=o.MULT_FINGER,this.onTriplePanStart(t)}else if("touch"!=t.pointerType&&this._input==o.NONE){let i=null;t.ctrlKey||t.metaKey?i="CTRL":t.shiftKey&&(i="SHIFT"),this._mouseOp=this.getOpFromAction(t.button,i),null!=this._mouseOp&&(window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),this._input=o.CURSOR,this._button=t.button,this.onSinglePanStart(t,this._mouseOp))}})),e.default(this,"onPointerMove",(t=>{if("touch"==t.pointerType&&this._input!=o.CURSOR)switch(this._input){case o.ONE_FINGER:this.updateTouchEvent(t),this.onSinglePanMove(t,a.ROTATE);break;case o.ONE_FINGER_SWITCHED:if(this.calculatePointersDistance(this._touchCurrent[0],t)*this._devPxRatio>=this._switchSensibility){this._input=o.ONE_FINGER,this.updateTouchEvent(t),this.onSinglePanStart(t,"ROTATE");break}break;case o.TWO_FINGER:this.updateTouchEvent(t),this.onRotateMove(),this.onPinchMove(),this.onDoublePanMove();break;case o.MULT_FINGER:this.updateTouchEvent(t),this.onTriplePanMove(t)}else if("touch"!=t.pointerType&&this._input==o.CURSOR){let i=null;t.ctrlKey||t.metaKey?i="CTRL":t.shiftKey&&(i="SHIFT");const s=this.getOpStateFromAction(this._button,i);null!=s&&this.onSinglePanMove(t,s)}if(this._downValid){this.calculatePointersDistance(this._downEvents[this._downEvents.length-1],t)*this._devPxRatio>this._movementThreshold&&(this._downValid=!1)}})),e.default(this,"onPointerUp",(t=>{if("touch"==t.pointerType&&this._input!=o.CURSOR){const i=this._touchCurrent.length;for(let s=0;s<i;s++)if(this._touchCurrent[s].pointerId==t.pointerId){this._touchCurrent.splice(s,1),this._touchStart.splice(s,1);break}switch(this._input){case o.ONE_FINGER:case o.ONE_FINGER_SWITCHED:window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this._input=o.NONE,this.onSinglePanEnd();break;case o.TWO_FINGER:this.onDoublePanEnd(t),this.onPinchEnd(t),this.onRotateEnd(t),this._input=o.ONE_FINGER_SWITCHED;break;case o.MULT_FINGER:0==this._touchCurrent.length&&(window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this._input=o.NONE,this.onTriplePanEnd())}}else"touch"!=t.pointerType&&this._input==o.CURSOR&&(window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this._input=o.NONE,this.onSinglePanEnd(),this._button=-1);if(t.isPrimary)if(this._downValid){if(t.timeStamp-this._downEvents[this._downEvents.length-1].timeStamp<=this._maxDownTime)if(0==this._nclicks)this._nclicks=1,this._clickStart=performance.now();else{const i=t.timeStamp-this._clickStart,s=this.calculatePointersDistance(this._downEvents[1],this._downEvents[0])*this._devPxRatio;i<=this._maxInterval&&s<=this._posThreshold?(this._nclicks=0,this._downEvents.splice(0,this._downEvents.length),this.onDoubleTap(t)):(this._nclicks=1,this._downEvents.shift(),this._clickStart=performance.now())}else this._downValid=!1,this._nclicks=0,this._downEvents.splice(0,this._downEvents.length)}else this._nclicks=0,this._downEvents.splice(0,this._downEvents.length)})),e.default(this,"onWheel",(t=>{if(this.enabled&&this.enableZoom){let s=null;t.ctrlKey||t.metaKey?s="CTRL":t.shiftKey&&(s="SHIFT");const e=this.getOpFromAction("WHEEL",s);if(null!=e){t.preventDefault(),this.dispatchEvent(c);const s=125;let o=t.deltaY/s,h=1;switch(o>0?h=1/this.scaleFactor:o<0&&(h=this.scaleFactor),e){case"ZOOM":if(this.updateTbState(a.SCALE,!0),o>0?h=1/Math.pow(this.scaleFactor,o):o<0&&(h=Math.pow(this.scaleFactor,-o)),this.cursorZoom&&this.enablePan){let i;this.camera.isOrthographicCamera?i=this.unprojectOnTbPlane(this.camera,t.clientX,t.clientY,this.domElement).applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._gizmos.position):this.camera.isPerspectiveCamera&&(i=this.unprojectOnTbPlane(this.camera,t.clientX,t.clientY,this.domElement).applyQuaternion(this.camera.quaternion).add(this._gizmos.position)),this.applyTransformMatrix(this.setScale(h,i))}else this.applyTransformMatrix(this.setScale(h,this._gizmos.position));null!=this._grid&&(this.disposeGrid(),this.drawGrid()),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n),this.dispatchEvent(m);break;case"FOV":if(this.camera.isPerspectiveCamera){this.updateTbState(a.FOV,!0),0!=t.deltaX&&(o=t.deltaX/s,h=1,o>0?h=1/Math.pow(this.scaleFactor,o):o<0&&(h=Math.pow(this.scaleFactor,-o))),this._v3_1.setFromMatrixPosition(this._cameraMatrixState);const e=this._v3_1.distanceTo(this._gizmos.position);let r=e/h;r=i.MathUtils.clamp(r,this.minDistance,this.maxDistance);const n=e*Math.tan(i.MathUtils.DEG2RAD*this.camera.fov*.5);let c=i.MathUtils.RAD2DEG*(2*Math.atan(n/r));c>this.maxFov?c=this.maxFov:c<this.minFov&&(c=this.minFov);h=e/(n/Math.tan(i.MathUtils.DEG2RAD*(c/2))),this.setFov(c),this.applyTransformMatrix(this.setScale(h,this._gizmos.position,!1))}null!=this._grid&&(this.disposeGrid(),this.drawGrid()),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n),this.dispatchEvent(m)}}}})),e.default(this,"onKeyDown",(t=>{"c"==t.key?(t.ctrlKey||t.metaKey)&&this.copyState():"v"==t.key&&(t.ctrlKey||t.metaKey)&&this.pasteState()})),e.default(this,"onSinglePanStart",((t,i)=>{if(this.enabled)switch(this.dispatchEvent(c),this.setCenter(t.clientX,t.clientY),i){case"PAN":if(!this.enablePan)return;-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1,this.activateGizmos(!1),this.dispatchEvent(n)),this.updateTbState(a.PAN,!0),this._startCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement)),this.enableGrid&&(this.drawGrid(),this.dispatchEvent(n));break;case"ROTATE":if(!this.enableRotate)return;-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1),this.updateTbState(a.ROTATE,!0),this._startCursorPosition.copy(this.unprojectOnTbSurface(this.camera,h.x,h.y,this.domElement,this._tbRadius)),this.activateGizmos(!0),this.enableAnimations&&(this._timePrev=this._timeCurrent=performance.now(),this._angleCurrent=this._anglePrev=0,this._cursorPosPrev.copy(this._startCursorPosition),this._cursorPosCurr.copy(this._cursorPosPrev),this._wCurr=0,this._wPrev=this._wCurr),this.dispatchEvent(n);break;case"FOV":if(!this.camera.isPerspectiveCamera||!this.enableZoom)return;-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1,this.activateGizmos(!1),this.dispatchEvent(n)),this.updateTbState(a.FOV,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition);break;case"ZOOM":if(!this.enableZoom)return;-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1,this.activateGizmos(!1),this.dispatchEvent(n)),this.updateTbState(a.SCALE,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition)}})),e.default(this,"onSinglePanMove",((t,s)=>{if(this.enabled){const e=s!=this._state;switch(this.setCenter(t.clientX,t.clientY),s){case a.PAN:this.enablePan&&(e?(this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement)),this.enableGrid&&this.drawGrid(),this.activateGizmos(!1)):(this._currentCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement)),this.applyTransformMatrix(this.pan(this._startCursorPosition,this._currentCursorPosition))));break;case a.ROTATE:if(this.enableRotate)if(e)this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.copy(this.unprojectOnTbSurface(this.camera,h.x,h.y,this.domElement,this._tbRadius)),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!0);else{this._currentCursorPosition.copy(this.unprojectOnTbSurface(this.camera,h.x,h.y,this.domElement,this._tbRadius));const t=this._startCursorPosition.distanceTo(this._currentCursorPosition),i=this._startCursorPosition.angleTo(this._currentCursorPosition),s=Math.max(t/this._tbRadius,i);this.applyTransformMatrix(this.rotate(this.calculateRotationAxis(this._startCursorPosition,this._currentCursorPosition),s)),this.enableAnimations&&(this._timePrev=this._timeCurrent,this._timeCurrent=performance.now(),this._anglePrev=this._angleCurrent,this._angleCurrent=s,this._cursorPosPrev.copy(this._cursorPosCurr),this._cursorPosCurr.copy(this._currentCursorPosition),this._wPrev=this._wCurr,this._wCurr=this.calculateAngularSpeed(this._anglePrev,this._angleCurrent,this._timePrev,this._timeCurrent))}break;case a.SCALE:if(this.enableZoom)if(e)this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!1);else{const t=8;this._currentCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y);const i=this._currentCursorPosition.y-this._startCursorPosition.y;let s=1;i<0?s=1/Math.pow(this.scaleFactor,-i*t):i>0&&(s=Math.pow(this.scaleFactor,i*t)),this.applyTransformMatrix(this.setScale(s,this._gizmos.position))}break;case a.FOV:if(this.enableZoom&&this.camera.isPerspectiveCamera)if(e)this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!1);else{const t=8;this._currentCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y);const s=this._currentCursorPosition.y-this._startCursorPosition.y;let e=1;s<0?e=1/Math.pow(this.scaleFactor,-s*t):s>0&&(e=Math.pow(this.scaleFactor,s*t)),this._v3_1.setFromMatrixPosition(this._cameraMatrixState);const a=this._v3_1.distanceTo(this._gizmos.position);let o=a/e;o=i.MathUtils.clamp(o,this.minDistance,this.maxDistance);const r=a*Math.tan(i.MathUtils.DEG2RAD*this._fovState*.5);let n=i.MathUtils.RAD2DEG*(2*Math.atan(r/o));n=i.MathUtils.clamp(n,this.minFov,this.maxFov);const c=r/Math.tan(i.MathUtils.DEG2RAD*(n/2));e=a/c,this._v3_2.setFromMatrixPosition(this._gizmoMatrixState),this.setFov(n),this.applyTransformMatrix(this.setScale(e,this._v3_2,!1));const m=this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(c/a);this._m4_1.makeTranslation(m.x,m.y,m.z)}}this.dispatchEvent(n)}})),e.default(this,"onSinglePanEnd",(()=>{if(this._state==a.ROTATE){if(!this.enableRotate)return;if(this.enableAnimations){if(performance.now()-this._timeCurrent<120){const t=Math.abs((this._wPrev+this._wCurr)/2),i=this;this._animationId=window.requestAnimationFrame((function(s){i.updateTbState(a.ANIMATION_ROTATE,!0);const e=i.calculateRotationAxis(i._cursorPosPrev,i._cursorPosCurr);i.onRotationAnim(s,e,Math.min(t,i.wMax))}))}else this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(n)}else this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(n)}else this._state!=a.PAN&&this._state!=a.IDLE||(this.updateTbState(a.IDLE,!1),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!1),this.dispatchEvent(n));this.dispatchEvent(m)})),e.default(this,"onDoubleTap",(t=>{if(this.enabled&&this.enablePan&&null!=this.scene){this.dispatchEvent(c),this.setCenter(t.clientX,t.clientY);const i=this.unprojectOnObj(this.getCursorNDC(h.x,h.y,this.domElement),this.camera);if(null!=i&&this.enableAnimations){const t=this;-1!=this._animationId&&window.cancelAnimationFrame(this._animationId),this._timeStart=-1,this._animationId=window.requestAnimationFrame((function(s){t.updateTbState(a.ANIMATION_FOCUS,!0),t.onFocusAnim(s,i,t._cameraMatrixState,t._gizmoMatrixState)}))}else null==i||this.enableAnimations||(this.updateTbState(a.FOCUS,!0),this.focus(i,this.scaleFactor),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n))}this.dispatchEvent(m)})),e.default(this,"onDoublePanStart",(()=>{this.enabled&&this.enablePan&&(this.dispatchEvent(c),this.updateTbState(a.PAN,!0),this.setCenter((this._touchCurrent[0].clientX+this._touchCurrent[1].clientX)/2,(this._touchCurrent[0].clientY+this._touchCurrent[1].clientY)/2),this._startCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement,!0)),this._currentCursorPosition.copy(this._startCursorPosition),this.activateGizmos(!1))})),e.default(this,"onDoublePanMove",(()=>{this.enabled&&this.enablePan&&(this.setCenter((this._touchCurrent[0].clientX+this._touchCurrent[1].clientX)/2,(this._touchCurrent[0].clientY+this._touchCurrent[1].clientY)/2),this._state!=a.PAN&&(this.updateTbState(a.PAN,!0),this._startCursorPosition.copy(this._currentCursorPosition)),this._currentCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement,!0)),this.applyTransformMatrix(this.pan(this._startCursorPosition,this._currentCursorPosition,!0)),this.dispatchEvent(n))})),e.default(this,"onDoublePanEnd",(()=>{this.updateTbState(a.IDLE,!1),this.dispatchEvent(m)})),e.default(this,"onRotateStart",(()=>{this.enabled&&this.enableRotate&&(this.dispatchEvent(c),this.updateTbState(a.ZROTATE,!0),this._startFingerRotation=this.getAngle(this._touchCurrent[1],this._touchCurrent[0])+this.getAngle(this._touchStart[1],this._touchStart[0]),this._currentFingerRotation=this._startFingerRotation,this.camera.getWorldDirection(this._rotationAxis),this.enablePan||this.enableZoom||this.activateGizmos(!0))})),e.default(this,"onRotateMove",(()=>{if(this.enabled&&this.enableRotate){let t;this.setCenter((this._touchCurrent[0].clientX+this._touchCurrent[1].clientX)/2,(this._touchCurrent[0].clientY+this._touchCurrent[1].clientY)/2),this._state!=a.ZROTATE&&(this.updateTbState(a.ZROTATE,!0),this._startFingerRotation=this._currentFingerRotation),this._currentFingerRotation=this.getAngle(this._touchCurrent[1],this._touchCurrent[0])+this.getAngle(this._touchStart[1],this._touchStart[0]),this.enablePan?(this._v3_2.setFromMatrixPosition(this._gizmoMatrixState),t=this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement).applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._v3_2)):t=(new i.Vector3).setFromMatrixPosition(this._gizmoMatrixState);const s=i.MathUtils.DEG2RAD*(this._startFingerRotation-this._currentFingerRotation);this.applyTransformMatrix(this.zRotate(t,s)),this.dispatchEvent(n)}})),e.default(this,"onRotateEnd",(()=>{this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(m)})),e.default(this,"onPinchStart",(()=>{this.enabled&&this.enableZoom&&(this.dispatchEvent(c),this.updateTbState(a.SCALE,!0),this._startFingerDistance=this.calculatePointersDistance(this._touchCurrent[0],this._touchCurrent[1]),this._currentFingerDistance=this._startFingerDistance,this.activateGizmos(!1))})),e.default(this,"onPinchMove",(()=>{if(this.enabled&&this.enableZoom){this.setCenter((this._touchCurrent[0].clientX+this._touchCurrent[1].clientX)/2,(this._touchCurrent[0].clientY+this._touchCurrent[1].clientY)/2);const t=12;this._state!=a.SCALE&&(this._startFingerDistance=this._currentFingerDistance,this.updateTbState(a.SCALE,!0)),this._currentFingerDistance=Math.max(this.calculatePointersDistance(this._touchCurrent[0],this._touchCurrent[1]),t*this._devPxRatio);const i=this._currentFingerDistance/this._startFingerDistance;let s;this.enablePan?this.camera.isOrthographicCamera?s=this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement).applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._gizmos.position):this.camera.isPerspectiveCamera&&(s=this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement).applyQuaternion(this.camera.quaternion).add(this._gizmos.position)):s=this._gizmos.position,this.applyTransformMatrix(this.setScale(i,s)),this.dispatchEvent(n)}})),e.default(this,"onPinchEnd",(()=>{this.updateTbState(a.IDLE,!1),this.dispatchEvent(m)})),e.default(this,"onTriplePanStart",(()=>{if(this.enabled&&this.enableZoom){this.dispatchEvent(c),this.updateTbState(a.SCALE,!0);let t=0,i=0;const s=this._touchCurrent.length;for(let e=0;e<s;e++)t+=this._touchCurrent[e].clientX,i+=this._touchCurrent[e].clientY;this.setCenter(t/s,i/s),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition)}})),e.default(this,"onTriplePanMove",(()=>{if(this.enabled&&this.enableZoom){let t=0,s=0;const e=this._touchCurrent.length;for(let i=0;i<e;i++)t+=this._touchCurrent[i].clientX,s+=this._touchCurrent[i].clientY;this.setCenter(t/e,s/e);const a=8;this._currentCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y);const o=this._currentCursorPosition.y-this._startCursorPosition.y;let r=1;o<0?r=1/Math.pow(this.scaleFactor,-o*a):o>0&&(r=Math.pow(this.scaleFactor,o*a)),this._v3_1.setFromMatrixPosition(this._cameraMatrixState);const c=this._v3_1.distanceTo(this._gizmos.position);let m=c/r;m=i.MathUtils.clamp(m,this.minDistance,this.maxDistance);const _=c*Math.tan(i.MathUtils.DEG2RAD*this._fovState*.5);let l=i.MathUtils.RAD2DEG*(2*Math.atan(_/m));l=i.MathUtils.clamp(l,this.minFov,this.maxFov);const u=_/Math.tan(i.MathUtils.DEG2RAD*(l/2));r=c/u,this._v3_2.setFromMatrixPosition(this._gizmoMatrixState),this.setFov(l),this.applyTransformMatrix(this.setScale(r,this._v3_2,!1));const p=this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(u/c);this._m4_1.makeTranslation(p.x,p.y,p.z),this.dispatchEvent(n)}})),e.default(this,"onTriplePanEnd",(()=>{this.updateTbState(a.IDLE,!1),this.dispatchEvent(m)})),e.default(this,"setCenter",((t,i)=>{h.x=t,h.y=i})),e.default(this,"initializeMouseActions",(()=>{this.setMouseAction("PAN",0,"CTRL"),this.setMouseAction("PAN",2),this.setMouseAction("ROTATE",0),this.setMouseAction("ZOOM","WHEEL"),this.setMouseAction("ZOOM",1),this.setMouseAction("FOV","WHEEL","SHIFT"),this.setMouseAction("FOV",1,"SHIFT")})),e.default(this,"compareMouseAction",((t,i)=>t.operation==i.operation&&(t.mouse==i.mouse&&t.key==i.key))),e.default(this,"setMouseAction",((t,i,s=null)=>{let e;if(!["PAN","ROTATE","ZOOM","FOV"].includes(t)||![0,1,2,"WHEEL"].includes(i)||!["CTRL","SHIFT",null].includes(s))return!1;if("WHEEL"==i&&"ZOOM"!=t&&"FOV"!=t)return!1;switch(t){case"PAN":e=a.PAN;break;case"ROTATE":e=a.ROTATE;break;case"ZOOM":e=a.SCALE;break;case"FOV":e=a.FOV}const o={operation:t,mouse:i,key:s,state:e};for(let t=0;t<this.mouseActions.length;t++)if(this.mouseActions[t].mouse==o.mouse&&this.mouseActions[t].key==o.key)return this.mouseActions.splice(t,1,o),!0;return this.mouseActions.push(o),!0})),e.default(this,"unsetMouseAction",((t,i=null)=>{for(let s=0;s<this.mouseActions.length;s++)if(this.mouseActions[s].mouse==t&&this.mouseActions[s].key==i)return this.mouseActions.splice(s,1),!0;return!1})),e.default(this,"getOpFromAction",((t,i)=>{let s;for(let e=0;e<this.mouseActions.length;e++)if(s=this.mouseActions[e],s.mouse==t&&s.key==i)return s.operation;if(null!=i)for(let i=0;i<this.mouseActions.length;i++)if(s=this.mouseActions[i],s.mouse==t&&null==s.key)return s.operation;return null})),e.default(this,"getOpStateFromAction",((t,i)=>{let s;for(let e=0;e<this.mouseActions.length;e++)if(s=this.mouseActions[e],s.mouse==t&&s.key==i)return s.state;if(null!=i)for(let i=0;i<this.mouseActions.length;i++)if(s=this.mouseActions[i],s.mouse==t&&null==s.key)return s.state;return null})),e.default(this,"getAngle",((t,i)=>180*Math.atan2(i.clientY-t.clientY,i.clientX-t.clientX)/Math.PI)),e.default(this,"updateTouchEvent",(t=>{for(let i=0;i<this._touchCurrent.length;i++)if(this._touchCurrent[i].pointerId==t.pointerId){this._touchCurrent.splice(i,1,t);break}})),e.default(this,"calculateAngularSpeed",((t,i,s,e)=>{const a=(e-s)/1e3;return 0==a?0:(i-t)/a})),e.default(this,"calculatePointersDistance",((t,i)=>Math.sqrt(Math.pow(i.clientX-t.clientX,2)+Math.pow(i.clientY-t.clientY,2)))),e.default(this,"calculateRotationAxis",((t,i)=>(this._rotationMatrix.extractRotation(this._cameraMatrixState),this._quat.setFromRotationMatrix(this._rotationMatrix),this._rotationAxis.crossVectors(t,i).applyQuaternion(this._quat),this._rotationAxis.normalize().clone()))),e.default(this,"calculateTbRadius",(t=>{const s=t.position.distanceTo(this._gizmos.position);if("PerspectiveCamera"==t.type){const e=i.MathUtils.DEG2RAD*t.fov*.5,a=Math.atan(t.aspect*Math.tan(e));return Math.tan(Math.min(e,a))*s*.67}if("OrthographicCamera"==t.type)return.67*Math.min(t.top,t.right)})),e.default(this,"focus",((t,i,s=1)=>{const e=t.clone();e.sub(this._gizmos.position).multiplyScalar(s),this._translationMatrix.makeTranslation(e.x,e.y,e.z);const a=this._gizmoMatrixState.clone();this._gizmoMatrixState.premultiply(this._translationMatrix),this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale);const o=this._cameraMatrixState.clone();this._cameraMatrixState.premultiply(this._translationMatrix),this._cameraMatrixState.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.enableZoom&&this.applyTransformMatrix(this.setScale(i,this._gizmos.position)),this._gizmoMatrixState.copy(a),this._cameraMatrixState.copy(o)})),e.default(this,"drawGrid",(()=>{if(null!=this.scene){const t=8947848,s=3;let e,a,o,h;if(this.camera.isOrthographicCamera){const t=this.camera.right-this.camera.left,i=this.camera.bottom-this.camera.top;o=Math.max(t,i),h=o/20,e=o/this.camera.zoom*s,a=e/h*this.camera.zoom}else if(this.camera.isPerspectiveCamera){const t=this.camera.position.distanceTo(this._gizmos.position),r=i.MathUtils.DEG2RAD*this.camera.fov*.5,n=Math.atan(this.camera.aspect*Math.tan(r));o=Math.tan(Math.max(r,n))*t*2,h=o/20,e=o*s,a=e/h}null==this._grid&&(this._grid=new i.GridHelper(e,a,t,t),this._grid.position.copy(this._gizmos.position),this._gridPosition.copy(this._grid.position),this._grid.quaternion.copy(this.camera.quaternion),this._grid.rotateX(.5*Math.PI),this.scene.add(this._grid))}})),e.default(this,"connect",(t=>{this.domElement=t,this.domElement.style.touchAction="none",this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("wheel",this.onWheel),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("resize",this.onWindowResize)})),e.default(this,"dispose",(()=>{-1!=this._animationId&&window.cancelAnimationFrame(this._animationId),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),this.domElement.removeEventListener("contextmenu",this.onContextMenu),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keydown",this.onKeyDown),this.scene&&this.scene.remove(this._gizmos),this.disposeGrid()})),e.default(this,"disposeGrid",(()=>{null!=this._grid&&null!=this.scene&&(this.scene.remove(this._grid),this._grid=null)})),e.default(this,"easeOutCubic",(t=>1-Math.pow(1-t,3))),e.default(this,"activateGizmos",(t=>{const i=this._gizmos.children[0],s=this._gizmos.children[1],e=this._gizmos.children[2];t?(i.material.setValues({opacity:1}),s.material.setValues({opacity:1}),e.material.setValues({opacity:1})):(i.material.setValues({opacity:.6}),s.material.setValues({opacity:.6}),e.material.setValues({opacity:.6}))})),e.default(this,"getCursorNDC",((t,i,s)=>{const e=s.getBoundingClientRect();return this._v2_1.setX((t-e.left)/e.width*2-1),this._v2_1.setY((e.bottom-i)/e.height*2-1),this._v2_1.clone()})),e.default(this,"getCursorPosition",((t,i,s)=>(this._v2_1.copy(this.getCursorNDC(t,i,s)),this._v2_1.x*=.5*(this.camera.right-this.camera.left),this._v2_1.y*=.5*(this.camera.top-this.camera.bottom),this._v2_1.clone()))),e.default(this,"setCamera",(t=>{t.lookAt(this.target),t.updateMatrix(),"PerspectiveCamera"==t.type&&(this._fov0=t.fov,this._fovState=t.fov),this._cameraMatrixState0.copy(t.matrix),this._cameraMatrixState.copy(this._cameraMatrixState0),this._cameraProjectionState.copy(t.projectionMatrix),this._zoom0=t.zoom,this._zoomState=this._zoom0,this._initialNear=t.near,this._nearPos0=t.position.distanceTo(this.target)-t.near,this._nearPos=this._initialNear,this._initialFar=t.far,this._farPos0=t.position.distanceTo(this.target)-t.far,this._farPos=this._initialFar,this._up0.copy(t.up),this._upState.copy(t.up),this.camera=t,this.camera.updateProjectionMatrix(),this._tbRadius=this.calculateTbRadius(t),this.makeGizmos(this.target,this._tbRadius)})),e.default(this,"makeGizmos",((t,s)=>{const e=new i.EllipseCurve(0,0,s,s).getPoints(this._curvePts),a=(new i.BufferGeometry).setFromPoints(e),o=new i.LineBasicMaterial({color:16744576,fog:!1,transparent:!0,opacity:.6}),h=new i.LineBasicMaterial({color:8454016,fog:!1,transparent:!0,opacity:.6}),r=new i.LineBasicMaterial({color:8421631,fog:!1,transparent:!0,opacity:.6}),n=new i.Line(a,o),c=new i.Line(a,h),m=new i.Line(a,r),_=.5*Math.PI;if(n.rotation.x=_,c.rotation.y=_,this._gizmoMatrixState0.identity().setPosition(t),this._gizmoMatrixState.copy(this._gizmoMatrixState0),1!=this.camera.zoom){const i=1/this.camera.zoom;this._scaleMatrix.makeScale(i,i,i),this._translationMatrix.makeTranslation(-t.x,-t.y,-t.z),this._gizmoMatrixState.premultiply(this._translationMatrix).premultiply(this._scaleMatrix),this._translationMatrix.makeTranslation(t.x,t.y,t.z),this._gizmoMatrixState.premultiply(this._translationMatrix)}this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this._gizmos.clear(),this._gizmos.add(n),this._gizmos.add(c),this._gizmos.add(m)})),e.default(this,"onFocusAnim",((t,i,s,e)=>{if(-1==this._timeStart&&(this._timeStart=t),this._state==a.ANIMATION_FOCUS){const o=(t-this._timeStart)/this.focusAnimationTime;if(this._gizmoMatrixState.copy(e),o>=1)this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this.focus(i,this.scaleFactor),this._timeStart=-1,this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(n);else{const t=this.easeOutCubic(o),a=1-t+this.scaleFactor*t;this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this.focus(i,a,t),this.dispatchEvent(n);const h=this;this._animationId=window.requestAnimationFrame((function(t){h.onFocusAnim(t,i,s,e.clone())}))}}else this._animationId=-1,this._timeStart=-1})),e.default(this,"onRotationAnim",((t,i,s)=>{if(-1==this._timeStart&&(this._anglePrev=0,this._angleCurrent=0,this._timeStart=t),this._state==a.ANIMATION_ROTATE){const e=(t-this._timeStart)/1e3;if(s+-this.dampingFactor*e>0){this._angleCurrent=.5*-this.dampingFactor*Math.pow(e,2)+s*e+0,this.applyTransformMatrix(this.rotate(i,this._angleCurrent)),this.dispatchEvent(n);const t=this;this._animationId=window.requestAnimationFrame((function(e){t.onRotationAnim(e,i,s)}))}else this._animationId=-1,this._timeStart=-1,this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(n)}else this._animationId=-1,this._timeStart=-1,this._state!=a.ROTATE&&(this.activateGizmos(!1),this.dispatchEvent(n))})),e.default(this,"pan",((t,i,s=!1)=>{const e=t.clone().sub(i);if(this.camera.isOrthographicCamera)e.multiplyScalar(1/this.camera.zoom);else if(this.camera.isPerspectiveCamera&&s){this._v3_1.setFromMatrixPosition(this._cameraMatrixState0),this._v3_2.setFromMatrixPosition(this._gizmoMatrixState0);const t=this._v3_1.distanceTo(this._v3_2)/this.camera.position.distanceTo(this._gizmos.position);e.multiplyScalar(1/t)}return this._v3_1.set(e.x,e.y,0).applyQuaternion(this.camera.quaternion),this._m4_1.makeTranslation(this._v3_1.x,this._v3_1.y,this._v3_1.z),this.setTransformationMatrices(this._m4_1,this._m4_1),r})),e.default(this,"reset",(()=>{this.camera.zoom=this._zoom0,this.camera.isPerspectiveCamera&&(this.camera.fov=this._fov0),this.camera.near=this._nearPos,this.camera.far=this._farPos,this._cameraMatrixState.copy(this._cameraMatrixState0),this._cameraMatrixState.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.up.copy(this._up0),this.camera.updateMatrix(),this.camera.updateProjectionMatrix(),this._gizmoMatrixState.copy(this._gizmoMatrixState0),this._gizmoMatrixState0.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this._gizmos.updateMatrix(),this._tbRadius=this.calculateTbRadius(this.camera),this.makeGizmos(this._gizmos.position,this._tbRadius),this.camera.lookAt(this._gizmos.position),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n)})),e.default(this,"rotate",((t,i)=>{const s=this._gizmos.position;return this._translationMatrix.makeTranslation(-s.x,-s.y,-s.z),this._rotationMatrix.makeRotationAxis(t,-i),this._m4_1.makeTranslation(s.x,s.y,s.z),this._m4_1.multiply(this._rotationMatrix),this._m4_1.multiply(this._translationMatrix),this.setTransformationMatrices(this._m4_1),r})),e.default(this,"copyState",(()=>{let t;this.camera.isOrthographicCamera?t=JSON.stringify({arcballState:{cameraFar:this.camera.far,cameraMatrix:this.camera.matrix,cameraNear:this.camera.near,cameraUp:this.camera.up,cameraZoom:this.camera.zoom,gizmoMatrix:this._gizmos.matrix}}):this.camera.isPerspectiveCamera&&(t=JSON.stringify({arcballState:{cameraFar:this.camera.far,cameraFov:this.camera.fov,cameraMatrix:this.camera.matrix,cameraNear:this.camera.near,cameraUp:this.camera.up,cameraZoom:this.camera.zoom,gizmoMatrix:this._gizmos.matrix}})),navigator.clipboard.writeText(t)})),e.default(this,"pasteState",(()=>{const t=this;navigator.clipboard.readText().then((function(i){t.setStateFromJSON(i)}))})),e.default(this,"saveState",(()=>{this._cameraMatrixState0.copy(this.camera.matrix),this._gizmoMatrixState0.copy(this._gizmos.matrix),this._nearPos=this.camera.near,this._farPos=this.camera.far,this._zoom0=this.camera.zoom,this._up0.copy(this.camera.up),this.camera.isPerspectiveCamera&&(this._fov0=this.camera.fov)})),e.default(this,"setScale",((t,i,s=!0)=>{const e=i.clone();let a=1/t;if(this.camera.isOrthographicCamera){this.camera.zoom=this._zoomState,this.camera.zoom*=t,this.camera.zoom>this.maxZoom?(this.camera.zoom=this.maxZoom,a=this._zoomState/this.maxZoom):this.camera.zoom<this.minZoom&&(this.camera.zoom=this.minZoom,a=this._zoomState/this.minZoom),this.camera.updateProjectionMatrix(),this._v3_1.setFromMatrixPosition(this._gizmoMatrixState),this._scaleMatrix.makeScale(a,a,a),this._translationMatrix.makeTranslation(-this._v3_1.x,-this._v3_1.y,-this._v3_1.z),this._m4_2.makeTranslation(this._v3_1.x,this._v3_1.y,this._v3_1.z).multiply(this._scaleMatrix),this._m4_2.multiply(this._translationMatrix),e.sub(this._v3_1);const i=e.clone().multiplyScalar(a);return e.sub(i),this._m4_1.makeTranslation(e.x,e.y,e.z),this._m4_2.premultiply(this._m4_1),this.setTransformationMatrices(this._m4_1,this._m4_2),r}if(this.camera.isPerspectiveCamera){this._v3_1.setFromMatrixPosition(this._cameraMatrixState),this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);let t=this._v3_1.distanceTo(e),i=t-t*a;const o=t-i;o<this.minDistance?(a=this.minDistance/t,i=t-t*a):o>this.maxDistance&&(a=this.maxDistance/t,i=t-t*a);let h=e.clone().sub(this._v3_1).normalize().multiplyScalar(i);if(this._m4_1.makeTranslation(h.x,h.y,h.z),s){const s=this._v3_2;t=s.distanceTo(e),i=t-t*a,h=e.clone().sub(this._v3_2).normalize().multiplyScalar(i),this._translationMatrix.makeTranslation(s.x,s.y,s.z),this._scaleMatrix.makeScale(a,a,a),this._m4_2.makeTranslation(h.x,h.y,h.z).multiply(this._translationMatrix),this._m4_2.multiply(this._scaleMatrix),this._translationMatrix.makeTranslation(-s.x,-s.y,-s.z),this._m4_2.multiply(this._translationMatrix),this.setTransformationMatrices(this._m4_1,this._m4_2)}else this.setTransformationMatrices(this._m4_1);return r}})),e.default(this,"setFov",(t=>{this.camera.isPerspectiveCamera&&(this.camera.fov=i.MathUtils.clamp(t,this.minFov,this.maxFov),this.camera.updateProjectionMatrix())})),e.default(this,"zRotate",((t,i)=>(this._rotationMatrix.makeRotationAxis(this._rotationAxis,i),this._translationMatrix.makeTranslation(-t.x,-t.y,-t.z),this._m4_1.makeTranslation(t.x,t.y,t.z),this._m4_1.multiply(this._rotationMatrix),this._m4_1.multiply(this._translationMatrix),this._v3_1.setFromMatrixPosition(this._gizmoMatrixState).sub(t),this._v3_2.copy(this._v3_1).applyAxisAngle(this._rotationAxis,i),this._v3_2.sub(this._v3_1),this._m4_2.makeTranslation(this._v3_2.x,this._v3_2.y,this._v3_2.z),this.setTransformationMatrices(this._m4_1,this._m4_2),r))),e.default(this,"unprojectOnObj",((t,s)=>{const e=new i.Raycaster;e.near=s.near,e.far=s.far,e.setFromCamera(t,s);const a=e.intersectObjects(this.scene.children,!0);for(let t=0;t<a.length;t++)if(a[t].object.uuid!=this._gizmos.uuid&&null!=a[t].face)return a[t].point.clone();return null})),e.default(this,"unprojectOnTbSurface",((t,s,e,a,o)=>{if("OrthographicCamera"==t.type){this._v2_1.copy(this.getCursorPosition(s,e,a)),this._v3_1.set(this._v2_1.x,this._v2_1.y,0);const t=Math.pow(this._v2_1.x,2),i=Math.pow(this._v2_1.y,2),o=Math.pow(this._tbRadius,2);return t+i<=.5*o?this._v3_1.setZ(Math.sqrt(o-(t+i))):this._v3_1.setZ(.5*o/Math.sqrt(t+i)),this._v3_1}if("PerspectiveCamera"==t.type){this._v2_1.copy(this.getCursorNDC(s,e,a)),this._v3_1.set(this._v2_1.x,this._v2_1.y,-1),this._v3_1.applyMatrix4(t.projectionMatrixInverse);const h=this._v3_1.clone().normalize(),r=t.position.distanceTo(this._gizmos.position),n=Math.pow(o,2),c=this._v3_1.z,m=Math.sqrt(Math.pow(this._v3_1.x,2)+Math.pow(this._v3_1.y,2));if(0==m)return h.set(this._v3_1.x,this._v3_1.y,o),h;const _=c/m,l=r;let u=Math.pow(_,2)+1,p=2*_*l,d=Math.pow(l,2)-n,v=Math.pow(p,2)-4*u*d;if(v>=0){this._v2_1.setX((-p-Math.sqrt(v))/(2*u)),this._v2_1.setY(_*this._v2_1.x+l);if(i.MathUtils.RAD2DEG*this._v2_1.angle()>=45){const t=Math.sqrt(Math.pow(this._v2_1.x,2)+Math.pow(r-this._v2_1.y,2));return h.multiplyScalar(t),h.z+=r,h}}u=_,p=l,d=.5*-n,v=Math.pow(p,2)-4*u*d,this._v2_1.setX((-p-Math.sqrt(v))/(2*u)),this._v2_1.setY(_*this._v2_1.x+l);const M=Math.sqrt(Math.pow(this._v2_1.x,2)+Math.pow(r-this._v2_1.y,2));return h.multiplyScalar(M),h.z+=r,h}})),e.default(this,"unprojectOnTbPlane",((t,i,s,e,a=!1)=>{if("OrthographicCamera"==t.type)return this._v2_1.copy(this.getCursorPosition(i,s,e)),this._v3_1.set(this._v2_1.x,this._v2_1.y,0),this._v3_1.clone();if("PerspectiveCamera"==t.type){this._v2_1.copy(this.getCursorNDC(i,s,e)),this._v3_1.set(this._v2_1.x,this._v2_1.y,-1),this._v3_1.applyMatrix4(t.projectionMatrixInverse);const o=this._v3_1.clone().normalize(),h=this._v3_1.z,r=Math.sqrt(Math.pow(this._v3_1.x,2)+Math.pow(this._v3_1.y,2));let n;if(n=a?this._v3_1.setFromMatrixPosition(this._cameraMatrixState0).distanceTo(this._v3_2.setFromMatrixPosition(this._gizmoMatrixState0)):t.position.distanceTo(this._gizmos.position),0==r)return o.set(0,0,0),o;const c=n,m=-c/(h/r),_=Math.sqrt(Math.pow(c,2)+Math.pow(m,2));return o.multiplyScalar(_),o.z=0,o}})),e.default(this,"updateMatrixState",(()=>{this._cameraMatrixState.copy(this.camera.matrix),this._gizmoMatrixState.copy(this._gizmos.matrix),this.camera.isOrthographicCamera?(this._cameraProjectionState.copy(this.camera.projectionMatrix),this.camera.updateProjectionMatrix(),this._zoomState=this.camera.zoom):this.camera.isPerspectiveCamera&&(this._fovState=this.camera.fov)})),e.default(this,"updateTbState",((t,i)=>{this._state=t,i&&this.updateMatrixState()})),e.default(this,"update",(()=>{const t=1e-6;if(this.target.x===this._prevTarget.x&&this.target.y===this._prevTarget.y&&this.target.z===this._prevTarget.z||(this._gizmos.position.set(this.target.x,this.target.y,this.target.z),this._tbRadius=this.calculateTbRadius(this.camera),this.makeGizmos(this.target,this._tbRadius),this._prevTarget.copy(this.target)),this.camera.isOrthographicCamera){if(this.camera.zoom>this.maxZoom||this.camera.zoom<this.minZoom){const t=i.MathUtils.clamp(this.camera.zoom,this.minZoom,this.maxZoom);this.applyTransformMatrix(this.setScale(t/this.camera.zoom,this._gizmos.position,!0))}}else if(this.camera.isPerspectiveCamera){const s=this.camera.position.distanceTo(this._gizmos.position);if(s>this.maxDistance+t||s<this.minDistance-t){const t=i.MathUtils.clamp(s,this.minDistance,this.maxDistance);this.applyTransformMatrix(this.setScale(t/s,this._gizmos.position)),this.updateMatrixState()}(this.camera.fov<this.minFov||this.camera.fov>this.maxFov)&&(this.camera.fov=i.MathUtils.clamp(this.camera.fov,this.minFov,this.maxFov),this.camera.updateProjectionMatrix());const e=this._tbRadius;if(this._tbRadius=this.calculateTbRadius(this.camera),e<this._tbRadius-t||e>this._tbRadius+t){const t=(this._gizmos.scale.x+this._gizmos.scale.y+this._gizmos.scale.z)/3,s=this._tbRadius/t,e=new i.EllipseCurve(0,0,s,s).getPoints(this._curvePts),a=(new i.BufferGeometry).setFromPoints(e);for(const t in this._gizmos.children)this._gizmos.children[t].geometry=a}}this.camera.lookAt(this._gizmos.position)})),e.default(this,"setStateFromJSON",(t=>{const s=JSON.parse(t);if(null!=s.arcballState){this._cameraMatrixState.fromArray(s.arcballState.cameraMatrix.elements),this._cameraMatrixState.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.up.copy(s.arcballState.cameraUp),this.camera.near=s.arcballState.cameraNear,this.camera.far=s.arcballState.cameraFar,this.camera.zoom=s.arcballState.cameraZoom,this.camera.isPerspectiveCamera&&(this.camera.fov=s.arcballState.cameraFov),this._gizmoMatrixState.fromArray(s.arcballState.gizmoMatrix.elements),this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this.camera.updateMatrix(),this.camera.updateProjectionMatrix(),this._gizmos.updateMatrix(),this._tbRadius=this.calculateTbRadius(this.camera);const t=(new i.Matrix4).copy(this._gizmoMatrixState0);this.makeGizmos(this._gizmos.position,this._tbRadius),this._gizmoMatrixState0.copy(t),this.camera.lookAt(this._gizmos.position),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n)}})),this.camera=null,this.scene=_,this.mouseActions=[],this._mouseOp=null,this._v2_1=new i.Vector2,this._v3_1=new i.Vector3,this._v3_2=new i.Vector3,this._m4_1=new i.Matrix4,this._m4_2=new i.Matrix4,this._quat=new i.Quaternion,this._translationMatrix=new i.Matrix4,this._rotationMatrix=new i.Matrix4,this._scaleMatrix=new i.Matrix4,this._rotationAxis=new i.Vector3,this._cameraMatrixState=new i.Matrix4,this._cameraProjectionState=new i.Matrix4,this._fovState=1,this._upState=new i.Vector3,this._zoomState=1,this._nearPos=0,this._farPos=0,this._gizmoMatrixState=new i.Matrix4,this._up0=new i.Vector3,this._zoom0=1,this._fov0=0,this._initialNear=0,this._nearPos0=0,this._initialFar=0,this._farPos0=0,this._cameraMatrixState0=new i.Matrix4,this._gizmoMatrixState0=new i.Matrix4,this._button=-1,this._touchStart=[],this._touchCurrent=[],this._input=o.NONE,this._switchSensibility=32,this._startFingerDistance=0,this._currentFingerDistance=0,this._startFingerRotation=0,this._currentFingerRotation=0,this._devPxRatio=0,this._downValid=!0,this._nclicks=0,this._downEvents=[],this._downStart=0,this._clickStart=0,this._maxDownTime=250,this._maxInterval=300,this._posThreshold=24,this._movementThreshold=24,this._currentCursorPosition=new i.Vector3,this._startCursorPosition=new i.Vector3,this._grid=null,this._gridPosition=new i.Vector3,this._gizmos=new i.Group,this._curvePts=128,this._timeStart=-1,this._animationId=-1,this.focusAnimationTime=500,this._timePrev=0,this._timeCurrent=0,this._anglePrev=0,this._angleCurrent=0,this._cursorPosPrev=new i.Vector3,this._cursorPosCurr=new i.Vector3,this._wPrev=0,this._wCurr=0,this.adjustNearFar=!1,this.scaleFactor=1.1,this.dampingFactor=25,this.wMax=20,this.enableAnimations=!0,this.enableGrid=!1,this.cursorZoom=!1,this.minFov=5,this.maxFov=90,this.enabled=!0,this.enablePan=!0,this.enableRotate=!0,this.enableZoom=!0,this.enableGizmos=!0,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.target=new i.Vector3(0,0,0),this._prevTarget=new i.Vector3(0,0,0),this._tbRadius=1,this._state=a.IDLE,this.setCamera(t),null!=this.scene&&this.scene.add(this._gizmos),void 0!==s&&this.connect(s),this._devPxRatio=window.devicePixelRatio,this.initializeMouseActions()}applyTransformMatrix(t){if(null!=t.camera&&(this._m4_1.copy(this._cameraMatrixState).premultiply(t.camera),this._m4_1.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.updateMatrix(),this._state!=a.ROTATE&&this._state!=a.ZROTATE&&this._state!=a.ANIMATION_ROTATE||this.camera.up.copy(this._upState).applyQuaternion(this.camera.quaternion)),null!=t.gizmos&&(this._m4_1.copy(this._gizmoMatrixState).premultiply(t.gizmos),this._m4_1.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this._gizmos.updateMatrix()),this._state==a.SCALE||this._state==a.FOCUS||this._state==a.ANIMATION_FOCUS)if(this._tbRadius=this.calculateTbRadius(this.camera),this.adjustNearFar){const t=this.camera.position.distanceTo(this._gizmos.position),s=new i.Box3;s.setFromObject(this._gizmos);const e=new i.Sphere;s.getBoundingSphere(e);const a=Math.max(this._nearPos0,e.radius+e.center.length()),o=t-this._initialNear,h=Math.min(a,o);this.camera.near=t-h;const r=Math.min(this._farPos0,-e.radius+e.center.length()),n=t-this._initialFar,c=Math.min(r,n);this.camera.far=t-c,this.camera.updateProjectionMatrix()}else{let t=!1;this.camera.near!=this._initialNear&&(this.camera.near=this._initialNear,t=!0),this.camera.far!=this._initialFar&&(this.camera.far=this._initialFar,t=!0),t&&this.camera.updateProjectionMatrix()}}setGizmosVisible(t){this._gizmos.visible=t,this.dispatchEvent(n)}setTransformationMatrices(t=null,i=null){null!=t?null!=r.camera?r.camera.copy(t):r.camera=t.clone():r.camera=null,null!=i?null!=r.gizmos?r.gizmos.copy(i):r.gizmos=i.clone():r.gizmos=null}}exports.ArcballControls=_;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),i=require("three");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=s(t);const a={IDLE:Symbol(),ROTATE:Symbol(),PAN:Symbol(),SCALE:Symbol(),FOV:Symbol(),FOCUS:Symbol(),ZROTATE:Symbol(),TOUCH_MULTI:Symbol(),ANIMATION_FOCUS:Symbol(),ANIMATION_ROTATE:Symbol()},o={NONE:Symbol(),ONE_FINGER:Symbol(),ONE_FINGER_SWITCHED:Symbol(),TWO_FINGER:Symbol(),MULT_FINGER:Symbol(),CURSOR:Symbol()},h={x:0,y:0},r={camera:new i.Matrix4,gizmos:new i.Matrix4},n={type:"change"},c={type:"start"},m={type:"end"};class l extends i.EventDispatcher{constructor(t,s,l=null){super(),e.default(this,"onWindowResize",(()=>{const t=(this._gizmos.scale.x+this._gizmos.scale.y+this._gizmos.scale.z)/3;this._tbRadius=this.calculateTbRadius(this.camera);const s=this._tbRadius/t,e=new i.EllipseCurve(0,0,s,s).getPoints(this._curvePts),a=(new i.BufferGeometry).setFromPoints(e);for(const t in this._gizmos.children)this._gizmos.children[t].geometry=a;this.dispatchEvent(n)})),e.default(this,"onContextMenu",(t=>{if(this.enabled)for(let i=0;i<this.mouseActions.length;i++)if(2==this.mouseActions[i].mouse){t.preventDefault();break}})),e.default(this,"onPointerCancel",(()=>{this._touchStart.splice(0,this._touchStart.length),this._touchCurrent.splice(0,this._touchCurrent.length),this._input=o.NONE})),e.default(this,"onPointerDown",(t=>{if(0==t.button&&t.isPrimary?(this._downValid=!0,this._downEvents.push(t),this._downStart=performance.now()):this._downValid=!1,"touch"==t.pointerType&&this._input!=o.CURSOR)switch(this._touchStart.push(t),this._touchCurrent.push(t),this._input){case o.NONE:this._input=o.ONE_FINGER,this.onSinglePanStart(t,"ROTATE"),window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp);break;case o.ONE_FINGER:case o.ONE_FINGER_SWITCHED:this._input=o.TWO_FINGER,this.onRotateStart(),this.onPinchStart(),this.onDoublePanStart();break;case o.TWO_FINGER:this._input=o.MULT_FINGER,this.onTriplePanStart(t)}else if("touch"!=t.pointerType&&this._input==o.NONE){let i=null;t.ctrlKey||t.metaKey?i="CTRL":t.shiftKey&&(i="SHIFT"),this._mouseOp=this.getOpFromAction(t.button,i),null!=this._mouseOp&&(window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),this._input=o.CURSOR,this._button=t.button,this.onSinglePanStart(t,this._mouseOp))}})),e.default(this,"onPointerMove",(t=>{if("touch"==t.pointerType&&this._input!=o.CURSOR)switch(this._input){case o.ONE_FINGER:this.updateTouchEvent(t),this.onSinglePanMove(t,a.ROTATE);break;case o.ONE_FINGER_SWITCHED:if(this.calculatePointersDistance(this._touchCurrent[0],t)*this._devPxRatio>=this._switchSensibility){this._input=o.ONE_FINGER,this.updateTouchEvent(t),this.onSinglePanStart(t,"ROTATE");break}break;case o.TWO_FINGER:this.updateTouchEvent(t),this.onRotateMove(),this.onPinchMove(),this.onDoublePanMove();break;case o.MULT_FINGER:this.updateTouchEvent(t),this.onTriplePanMove(t)}else if("touch"!=t.pointerType&&this._input==o.CURSOR){let i=null;t.ctrlKey||t.metaKey?i="CTRL":t.shiftKey&&(i="SHIFT");const s=this.getOpStateFromAction(this._button,i);null!=s&&this.onSinglePanMove(t,s)}if(this._downValid){this.calculatePointersDistance(this._downEvents[this._downEvents.length-1],t)*this._devPxRatio>this._movementThreshold&&(this._downValid=!1)}})),e.default(this,"onPointerUp",(t=>{if("touch"==t.pointerType&&this._input!=o.CURSOR){const i=this._touchCurrent.length;for(let s=0;s<i;s++)if(this._touchCurrent[s].pointerId==t.pointerId){this._touchCurrent.splice(s,1),this._touchStart.splice(s,1);break}switch(this._input){case o.ONE_FINGER:case o.ONE_FINGER_SWITCHED:window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this._input=o.NONE,this.onSinglePanEnd();break;case o.TWO_FINGER:this.onDoublePanEnd(t),this.onPinchEnd(t),this.onRotateEnd(t),this._input=o.ONE_FINGER_SWITCHED;break;case o.MULT_FINGER:0==this._touchCurrent.length&&(window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this._input=o.NONE,this.onTriplePanEnd())}}else"touch"!=t.pointerType&&this._input==o.CURSOR&&(window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this._input=o.NONE,this.onSinglePanEnd(),this._button=-1);if(t.isPrimary)if(this._downValid){if(t.timeStamp-this._downEvents[this._downEvents.length-1].timeStamp<=this._maxDownTime)if(0==this._nclicks)this._nclicks=1,this._clickStart=performance.now();else{const i=t.timeStamp-this._clickStart,s=this.calculatePointersDistance(this._downEvents[1],this._downEvents[0])*this._devPxRatio;i<=this._maxInterval&&s<=this._posThreshold?(this._nclicks=0,this._downEvents.splice(0,this._downEvents.length),this.onDoubleTap(t)):(this._nclicks=1,this._downEvents.shift(),this._clickStart=performance.now())}else this._downValid=!1,this._nclicks=0,this._downEvents.splice(0,this._downEvents.length)}else this._nclicks=0,this._downEvents.splice(0,this._downEvents.length)})),e.default(this,"onWheel",(t=>{if(this.enabled&&this.enableZoom){let s=null;t.ctrlKey||t.metaKey?s="CTRL":t.shiftKey&&(s="SHIFT");const e=this.getOpFromAction("WHEEL",s);if(null!=e){t.preventDefault(),this.dispatchEvent(c);const s=125;let o=t.deltaY/s,h=1;switch(o>0?h=1/this.scaleFactor:o<0&&(h=this.scaleFactor),e){case"ZOOM":if(this.updateTbState(a.SCALE,!0),o>0?h=1/Math.pow(this.scaleFactor,o):o<0&&(h=Math.pow(this.scaleFactor,-o)),this.cursorZoom&&this.enablePan){let i;this.camera.isOrthographicCamera?i=this.unprojectOnTbPlane(this.camera,t.clientX,t.clientY,this.domElement).applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._gizmos.position):this.camera.isPerspectiveCamera&&(i=this.unprojectOnTbPlane(this.camera,t.clientX,t.clientY,this.domElement).applyQuaternion(this.camera.quaternion).add(this._gizmos.position)),this.applyTransformMatrix(this.applyScale(h,i))}else this.applyTransformMatrix(this.applyScale(h,this._gizmos.position));null!=this._grid&&(this.disposeGrid(),this.drawGrid()),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n),this.dispatchEvent(m);break;case"FOV":if(this.camera.isPerspectiveCamera){this.updateTbState(a.FOV,!0),0!=t.deltaX&&(o=t.deltaX/s,h=1,o>0?h=1/Math.pow(this.scaleFactor,o):o<0&&(h=Math.pow(this.scaleFactor,-o))),this._v3_1.setFromMatrixPosition(this._cameraMatrixState);const e=this._v3_1.distanceTo(this._gizmos.position);let r=e/h;r=i.MathUtils.clamp(r,this.minDistance,this.maxDistance);const n=e*Math.tan(i.MathUtils.DEG2RAD*this.camera.fov*.5);let c=i.MathUtils.RAD2DEG*(2*Math.atan(n/r));c>this.maxFov?c=this.maxFov:c<this.minFov&&(c=this.minFov);h=e/(n/Math.tan(i.MathUtils.DEG2RAD*(c/2))),this.setFov(c),this.applyTransformMatrix(this.applyScale(h,this._gizmos.position,!1))}null!=this._grid&&(this.disposeGrid(),this.drawGrid()),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n),this.dispatchEvent(m)}}}})),e.default(this,"onKeyDown",(t=>{"c"==t.key?(t.ctrlKey||t.metaKey)&&this.copyState():"v"==t.key&&(t.ctrlKey||t.metaKey)&&this.pasteState()})),e.default(this,"onSinglePanStart",((t,i)=>{if(this.enabled)switch(this.dispatchEvent(c),this.setCenter(t.clientX,t.clientY),i){case"PAN":if(!this.enablePan)return;-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1,this.activateGizmos(!1),this.dispatchEvent(n)),this.updateTbState(a.PAN,!0),this._startCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement)),this.enableGrid&&(this.drawGrid(),this.dispatchEvent(n));break;case"ROTATE":if(!this.enableRotate)return;-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1),this.updateTbState(a.ROTATE,!0),this._startCursorPosition.copy(this.unprojectOnTbSurface(this.camera,h.x,h.y,this.domElement,this._tbRadius)),this.activateGizmos(!0),this.enableAnimations&&(this._timePrev=this._timeCurrent=performance.now(),this._angleCurrent=this._anglePrev=0,this._cursorPosPrev.copy(this._startCursorPosition),this._cursorPosCurr.copy(this._cursorPosPrev),this._wCurr=0,this._wPrev=this._wCurr),this.dispatchEvent(n);break;case"FOV":if(!this.camera.isPerspectiveCamera||!this.enableZoom)return;-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1,this.activateGizmos(!1),this.dispatchEvent(n)),this.updateTbState(a.FOV,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition);break;case"ZOOM":if(!this.enableZoom)return;-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1,this.activateGizmos(!1),this.dispatchEvent(n)),this.updateTbState(a.SCALE,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition)}})),e.default(this,"onSinglePanMove",((t,s)=>{if(this.enabled){const e=s!=this._state;switch(this.setCenter(t.clientX,t.clientY),s){case a.PAN:this.enablePan&&(e?(this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement)),this.enableGrid&&this.drawGrid(),this.activateGizmos(!1)):(this._currentCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement)),this.applyTransformMatrix(this.pan(this._startCursorPosition,this._currentCursorPosition))));break;case a.ROTATE:if(this.enableRotate)if(e)this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.copy(this.unprojectOnTbSurface(this.camera,h.x,h.y,this.domElement,this._tbRadius)),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!0);else{this._currentCursorPosition.copy(this.unprojectOnTbSurface(this.camera,h.x,h.y,this.domElement,this._tbRadius));const t=this._startCursorPosition.distanceTo(this._currentCursorPosition),i=this._startCursorPosition.angleTo(this._currentCursorPosition),s=Math.max(t/this._tbRadius,i);this.applyTransformMatrix(this.rotate(this.calculateRotationAxis(this._startCursorPosition,this._currentCursorPosition),s)),this.enableAnimations&&(this._timePrev=this._timeCurrent,this._timeCurrent=performance.now(),this._anglePrev=this._angleCurrent,this._angleCurrent=s,this._cursorPosPrev.copy(this._cursorPosCurr),this._cursorPosCurr.copy(this._currentCursorPosition),this._wPrev=this._wCurr,this._wCurr=this.calculateAngularSpeed(this._anglePrev,this._angleCurrent,this._timePrev,this._timeCurrent))}break;case a.SCALE:if(this.enableZoom)if(e)this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!1);else{const t=8;this._currentCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y);const i=this._currentCursorPosition.y-this._startCursorPosition.y;let s=1;i<0?s=1/Math.pow(this.scaleFactor,-i*t):i>0&&(s=Math.pow(this.scaleFactor,i*t)),this.applyTransformMatrix(this.applyScale(s,this._gizmos.position))}break;case a.FOV:if(this.enableZoom&&this.camera.isPerspectiveCamera)if(e)this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!1);else{const t=8;this._currentCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y);const s=this._currentCursorPosition.y-this._startCursorPosition.y;let e=1;s<0?e=1/Math.pow(this.scaleFactor,-s*t):s>0&&(e=Math.pow(this.scaleFactor,s*t)),this._v3_1.setFromMatrixPosition(this._cameraMatrixState);const a=this._v3_1.distanceTo(this._gizmos.position);let o=a/e;o=i.MathUtils.clamp(o,this.minDistance,this.maxDistance);const r=a*Math.tan(i.MathUtils.DEG2RAD*this._fovState*.5);let n=i.MathUtils.RAD2DEG*(2*Math.atan(r/o));n=i.MathUtils.clamp(n,this.minFov,this.maxFov);const c=r/Math.tan(i.MathUtils.DEG2RAD*(n/2));e=a/c,this._v3_2.setFromMatrixPosition(this._gizmoMatrixState),this.setFov(n),this.applyTransformMatrix(this.applyScale(e,this._v3_2,!1));const m=this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(c/a);this._m4_1.makeTranslation(m.x,m.y,m.z)}}this.dispatchEvent(n)}})),e.default(this,"onSinglePanEnd",(()=>{if(this._state==a.ROTATE){if(!this.enableRotate)return;if(this.enableAnimations){if(performance.now()-this._timeCurrent<120){const t=Math.abs((this._wPrev+this._wCurr)/2),i=this;this._animationId=window.requestAnimationFrame((function(s){i.updateTbState(a.ANIMATION_ROTATE,!0);const e=i.calculateRotationAxis(i._cursorPosPrev,i._cursorPosCurr);i.onRotationAnim(s,e,Math.min(t,i.wMax))}))}else this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(n)}else this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(n)}else this._state!=a.PAN&&this._state!=a.IDLE||(this.updateTbState(a.IDLE,!1),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!1),this.dispatchEvent(n));this.dispatchEvent(m)})),e.default(this,"onDoubleTap",(t=>{if(this.enabled&&this.enablePan&&null!=this.scene){this.dispatchEvent(c),this.setCenter(t.clientX,t.clientY);const i=this.unprojectOnObj(this.getCursorNDC(h.x,h.y,this.domElement),this.camera);if(null!=i&&this.enableAnimations){const t=this;-1!=this._animationId&&window.cancelAnimationFrame(this._animationId),this._timeStart=-1,this._animationId=window.requestAnimationFrame((function(s){t.updateTbState(a.ANIMATION_FOCUS,!0),t.onFocusAnim(s,i,t._cameraMatrixState,t._gizmoMatrixState)}))}else null==i||this.enableAnimations||(this.updateTbState(a.FOCUS,!0),this.focus(i,this.scaleFactor),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n))}this.dispatchEvent(m)})),e.default(this,"onDoublePanStart",(()=>{this.enabled&&this.enablePan&&(this.dispatchEvent(c),this.updateTbState(a.PAN,!0),this.setCenter((this._touchCurrent[0].clientX+this._touchCurrent[1].clientX)/2,(this._touchCurrent[0].clientY+this._touchCurrent[1].clientY)/2),this._startCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement,!0)),this._currentCursorPosition.copy(this._startCursorPosition),this.activateGizmos(!1))})),e.default(this,"onDoublePanMove",(()=>{this.enabled&&this.enablePan&&(this.setCenter((this._touchCurrent[0].clientX+this._touchCurrent[1].clientX)/2,(this._touchCurrent[0].clientY+this._touchCurrent[1].clientY)/2),this._state!=a.PAN&&(this.updateTbState(a.PAN,!0),this._startCursorPosition.copy(this._currentCursorPosition)),this._currentCursorPosition.copy(this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement,!0)),this.applyTransformMatrix(this.pan(this._startCursorPosition,this._currentCursorPosition,!0)),this.dispatchEvent(n))})),e.default(this,"onDoublePanEnd",(()=>{this.updateTbState(a.IDLE,!1),this.dispatchEvent(m)})),e.default(this,"onRotateStart",(()=>{this.enabled&&this.enableRotate&&(this.dispatchEvent(c),this.updateTbState(a.ZROTATE,!0),this._startFingerRotation=this.getAngle(this._touchCurrent[1],this._touchCurrent[0])+this.getAngle(this._touchStart[1],this._touchStart[0]),this._currentFingerRotation=this._startFingerRotation,this.camera.getWorldDirection(this._rotationAxis),this.enablePan||this.enableZoom||this.activateGizmos(!0))})),e.default(this,"onRotateMove",(()=>{if(this.enabled&&this.enableRotate){let t;this.setCenter((this._touchCurrent[0].clientX+this._touchCurrent[1].clientX)/2,(this._touchCurrent[0].clientY+this._touchCurrent[1].clientY)/2),this._state!=a.ZROTATE&&(this.updateTbState(a.ZROTATE,!0),this._startFingerRotation=this._currentFingerRotation),this._currentFingerRotation=this.getAngle(this._touchCurrent[1],this._touchCurrent[0])+this.getAngle(this._touchStart[1],this._touchStart[0]),this.enablePan?(this._v3_2.setFromMatrixPosition(this._gizmoMatrixState),t=this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement).applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._v3_2)):t=(new i.Vector3).setFromMatrixPosition(this._gizmoMatrixState);const s=i.MathUtils.DEG2RAD*(this._startFingerRotation-this._currentFingerRotation);this.applyTransformMatrix(this.zRotate(t,s)),this.dispatchEvent(n)}})),e.default(this,"onRotateEnd",(()=>{this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(m)})),e.default(this,"onPinchStart",(()=>{this.enabled&&this.enableZoom&&(this.dispatchEvent(c),this.updateTbState(a.SCALE,!0),this._startFingerDistance=this.calculatePointersDistance(this._touchCurrent[0],this._touchCurrent[1]),this._currentFingerDistance=this._startFingerDistance,this.activateGizmos(!1))})),e.default(this,"onPinchMove",(()=>{if(this.enabled&&this.enableZoom){this.setCenter((this._touchCurrent[0].clientX+this._touchCurrent[1].clientX)/2,(this._touchCurrent[0].clientY+this._touchCurrent[1].clientY)/2);const t=12;this._state!=a.SCALE&&(this._startFingerDistance=this._currentFingerDistance,this.updateTbState(a.SCALE,!0)),this._currentFingerDistance=Math.max(this.calculatePointersDistance(this._touchCurrent[0],this._touchCurrent[1]),t*this._devPxRatio);const i=this._currentFingerDistance/this._startFingerDistance;let s;this.enablePan?this.camera.isOrthographicCamera?s=this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement).applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._gizmos.position):this.camera.isPerspectiveCamera&&(s=this.unprojectOnTbPlane(this.camera,h.x,h.y,this.domElement).applyQuaternion(this.camera.quaternion).add(this._gizmos.position)):s=this._gizmos.position,this.applyTransformMatrix(this.applyScale(i,s)),this.dispatchEvent(n)}})),e.default(this,"onPinchEnd",(()=>{this.updateTbState(a.IDLE,!1),this.dispatchEvent(m)})),e.default(this,"onTriplePanStart",(()=>{if(this.enabled&&this.enableZoom){this.dispatchEvent(c),this.updateTbState(a.SCALE,!0);let t=0,i=0;const s=this._touchCurrent.length;for(let e=0;e<s;e++)t+=this._touchCurrent[e].clientX,i+=this._touchCurrent[e].clientY;this.setCenter(t/s,i/s),this._startCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition)}})),e.default(this,"onTriplePanMove",(()=>{if(this.enabled&&this.enableZoom){let t=0,s=0;const e=this._touchCurrent.length;for(let i=0;i<e;i++)t+=this._touchCurrent[i].clientX,s+=this._touchCurrent[i].clientY;this.setCenter(t/e,s/e);const a=8;this._currentCursorPosition.setY(.5*this.getCursorNDC(h.x,h.y,this.domElement).y);const o=this._currentCursorPosition.y-this._startCursorPosition.y;let r=1;o<0?r=1/Math.pow(this.scaleFactor,-o*a):o>0&&(r=Math.pow(this.scaleFactor,o*a)),this._v3_1.setFromMatrixPosition(this._cameraMatrixState);const c=this._v3_1.distanceTo(this._gizmos.position);let m=c/r;m=i.MathUtils.clamp(m,this.minDistance,this.maxDistance);const l=c*Math.tan(i.MathUtils.DEG2RAD*this._fovState*.5);let _=i.MathUtils.RAD2DEG*(2*Math.atan(l/m));_=i.MathUtils.clamp(_,this.minFov,this.maxFov);const u=l/Math.tan(i.MathUtils.DEG2RAD*(_/2));r=c/u,this._v3_2.setFromMatrixPosition(this._gizmoMatrixState),this.setFov(_),this.applyTransformMatrix(this.applyScale(r,this._v3_2,!1));const p=this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(u/c);this._m4_1.makeTranslation(p.x,p.y,p.z),this.dispatchEvent(n)}})),e.default(this,"onTriplePanEnd",(()=>{this.updateTbState(a.IDLE,!1),this.dispatchEvent(m)})),e.default(this,"setCenter",((t,i)=>{h.x=t,h.y=i})),e.default(this,"initializeMouseActions",(()=>{this.setMouseAction("PAN",0,"CTRL"),this.setMouseAction("PAN",2),this.setMouseAction("ROTATE",0),this.setMouseAction("ZOOM","WHEEL"),this.setMouseAction("ZOOM",1),this.setMouseAction("FOV","WHEEL","SHIFT"),this.setMouseAction("FOV",1,"SHIFT")})),e.default(this,"compareMouseAction",((t,i)=>t.operation==i.operation&&(t.mouse==i.mouse&&t.key==i.key))),e.default(this,"setMouseAction",((t,i,s=null)=>{let e;if(!["PAN","ROTATE","ZOOM","FOV"].includes(t)||![0,1,2,"WHEEL"].includes(i)||!["CTRL","SHIFT",null].includes(s))return!1;if("WHEEL"==i&&"ZOOM"!=t&&"FOV"!=t)return!1;switch(t){case"PAN":e=a.PAN;break;case"ROTATE":e=a.ROTATE;break;case"ZOOM":e=a.SCALE;break;case"FOV":e=a.FOV}const o={operation:t,mouse:i,key:s,state:e};for(let t=0;t<this.mouseActions.length;t++)if(this.mouseActions[t].mouse==o.mouse&&this.mouseActions[t].key==o.key)return this.mouseActions.splice(t,1,o),!0;return this.mouseActions.push(o),!0})),e.default(this,"unsetMouseAction",((t,i=null)=>{for(let s=0;s<this.mouseActions.length;s++)if(this.mouseActions[s].mouse==t&&this.mouseActions[s].key==i)return this.mouseActions.splice(s,1),!0;return!1})),e.default(this,"getOpFromAction",((t,i)=>{let s;for(let e=0;e<this.mouseActions.length;e++)if(s=this.mouseActions[e],s.mouse==t&&s.key==i)return s.operation;if(null!=i)for(let i=0;i<this.mouseActions.length;i++)if(s=this.mouseActions[i],s.mouse==t&&null==s.key)return s.operation;return null})),e.default(this,"getOpStateFromAction",((t,i)=>{let s;for(let e=0;e<this.mouseActions.length;e++)if(s=this.mouseActions[e],s.mouse==t&&s.key==i)return s.state;if(null!=i)for(let i=0;i<this.mouseActions.length;i++)if(s=this.mouseActions[i],s.mouse==t&&null==s.key)return s.state;return null})),e.default(this,"getAngle",((t,i)=>180*Math.atan2(i.clientY-t.clientY,i.clientX-t.clientX)/Math.PI)),e.default(this,"updateTouchEvent",(t=>{for(let i=0;i<this._touchCurrent.length;i++)if(this._touchCurrent[i].pointerId==t.pointerId){this._touchCurrent.splice(i,1,t);break}})),e.default(this,"calculateAngularSpeed",((t,i,s,e)=>{const a=(e-s)/1e3;return 0==a?0:(i-t)/a})),e.default(this,"calculatePointersDistance",((t,i)=>Math.sqrt(Math.pow(i.clientX-t.clientX,2)+Math.pow(i.clientY-t.clientY,2)))),e.default(this,"calculateRotationAxis",((t,i)=>(this._rotationMatrix.extractRotation(this._cameraMatrixState),this._quat.setFromRotationMatrix(this._rotationMatrix),this._rotationAxis.crossVectors(t,i).applyQuaternion(this._quat),this._rotationAxis.normalize().clone()))),e.default(this,"calculateTbRadius",(t=>{const s=t.position.distanceTo(this._gizmos.position);if("PerspectiveCamera"==t.type){const e=i.MathUtils.DEG2RAD*t.fov*.5,a=Math.atan(t.aspect*Math.tan(e));return Math.tan(Math.min(e,a))*s*.67}if("OrthographicCamera"==t.type)return.67*Math.min(t.top,t.right)})),e.default(this,"focus",((t,i,s=1)=>{const e=t.clone();e.sub(this._gizmos.position).multiplyScalar(s),this._translationMatrix.makeTranslation(e.x,e.y,e.z);const a=this._gizmoMatrixState.clone();this._gizmoMatrixState.premultiply(this._translationMatrix),this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale);const o=this._cameraMatrixState.clone();this._cameraMatrixState.premultiply(this._translationMatrix),this._cameraMatrixState.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.enableZoom&&this.applyTransformMatrix(this.applyScale(i,this._gizmos.position)),this._gizmoMatrixState.copy(a),this._cameraMatrixState.copy(o)})),e.default(this,"drawGrid",(()=>{if(null!=this.scene){const t=8947848,s=3;let e,a,o,h;if(this.camera.isOrthographicCamera){const t=this.camera.right-this.camera.left,i=this.camera.bottom-this.camera.top;o=Math.max(t,i),h=o/20,e=o/this.camera.zoom*s,a=e/h*this.camera.zoom}else if(this.camera.isPerspectiveCamera){const t=this.camera.position.distanceTo(this._gizmos.position),r=i.MathUtils.DEG2RAD*this.camera.fov*.5,n=Math.atan(this.camera.aspect*Math.tan(r));o=Math.tan(Math.max(r,n))*t*2,h=o/20,e=o*s,a=e/h}null==this._grid&&(this._grid=new i.GridHelper(e,a,t,t),this._grid.position.copy(this._gizmos.position),this._gridPosition.copy(this._grid.position),this._grid.quaternion.copy(this.camera.quaternion),this._grid.rotateX(.5*Math.PI),this.scene.add(this._grid))}})),e.default(this,"connect",(t=>{this.domElement=t,this.domElement.style.touchAction="none",this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("wheel",this.onWheel),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("resize",this.onWindowResize)})),e.default(this,"dispose",(()=>{-1!=this._animationId&&window.cancelAnimationFrame(this._animationId),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onWheel),this.domElement.removeEventListener("contextmenu",this.onContextMenu),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keydown",this.onKeyDown),this.scene&&this.scene.remove(this._gizmos),this.disposeGrid()})),e.default(this,"disposeGrid",(()=>{null!=this._grid&&null!=this.scene&&(this.scene.remove(this._grid),this._grid=null)})),e.default(this,"easeOutCubic",(t=>1-Math.pow(1-t,3))),e.default(this,"activateGizmos",(t=>{const i=this._gizmos.children[0],s=this._gizmos.children[1],e=this._gizmos.children[2];t?(i.material.setValues({opacity:1}),s.material.setValues({opacity:1}),e.material.setValues({opacity:1})):(i.material.setValues({opacity:.6}),s.material.setValues({opacity:.6}),e.material.setValues({opacity:.6}))})),e.default(this,"getCursorNDC",((t,i,s)=>{const e=s.getBoundingClientRect();return this._v2_1.setX((t-e.left)/e.width*2-1),this._v2_1.setY((e.bottom-i)/e.height*2-1),this._v2_1.clone()})),e.default(this,"getCursorPosition",((t,i,s)=>(this._v2_1.copy(this.getCursorNDC(t,i,s)),this._v2_1.x*=.5*(this.camera.right-this.camera.left),this._v2_1.y*=.5*(this.camera.top-this.camera.bottom),this._v2_1.clone()))),e.default(this,"setCamera",(t=>{t.lookAt(this.target),t.updateMatrix(),"PerspectiveCamera"==t.type&&(this._fov0=t.fov,this._fovState=t.fov),this._cameraMatrixState0.copy(t.matrix),this._cameraMatrixState.copy(this._cameraMatrixState0),this._cameraProjectionState.copy(t.projectionMatrix),this._zoom0=t.zoom,this._zoomState=this._zoom0,this._initialNear=t.near,this._nearPos0=t.position.distanceTo(this.target)-t.near,this._nearPos=this._initialNear,this._initialFar=t.far,this._farPos0=t.position.distanceTo(this.target)-t.far,this._farPos=this._initialFar,this._up0.copy(t.up),this._upState.copy(t.up),this.camera=t,this.camera.updateProjectionMatrix(),this._tbRadius=this.calculateTbRadius(t),this.makeGizmos(this.target,this._tbRadius)})),e.default(this,"makeGizmos",((t,s)=>{const e=new i.EllipseCurve(0,0,s,s).getPoints(this._curvePts),a=(new i.BufferGeometry).setFromPoints(e),o=new i.LineBasicMaterial({color:16744576,fog:!1,transparent:!0,opacity:.6}),h=new i.LineBasicMaterial({color:8454016,fog:!1,transparent:!0,opacity:.6}),r=new i.LineBasicMaterial({color:8421631,fog:!1,transparent:!0,opacity:.6}),n=new i.Line(a,o),c=new i.Line(a,h),m=new i.Line(a,r),l=.5*Math.PI;if(n.rotation.x=l,c.rotation.y=l,this._gizmoMatrixState0.identity().setPosition(t),this._gizmoMatrixState.copy(this._gizmoMatrixState0),1!=this.camera.zoom){const i=1/this.camera.zoom;this._scaleMatrix.makeScale(i,i,i),this._translationMatrix.makeTranslation(-t.x,-t.y,-t.z),this._gizmoMatrixState.premultiply(this._translationMatrix).premultiply(this._scaleMatrix),this._translationMatrix.makeTranslation(t.x,t.y,t.z),this._gizmoMatrixState.premultiply(this._translationMatrix)}this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this._gizmos.clear(),this._gizmos.add(n),this._gizmos.add(c),this._gizmos.add(m)})),e.default(this,"onFocusAnim",((t,i,s,e)=>{if(-1==this._timeStart&&(this._timeStart=t),this._state==a.ANIMATION_FOCUS){const o=(t-this._timeStart)/this.focusAnimationTime;if(this._gizmoMatrixState.copy(e),o>=1)this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this.focus(i,this.scaleFactor),this._timeStart=-1,this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(n);else{const t=this.easeOutCubic(o),a=1-t+this.scaleFactor*t;this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this.focus(i,a,t),this.dispatchEvent(n);const h=this;this._animationId=window.requestAnimationFrame((function(t){h.onFocusAnim(t,i,s,e.clone())}))}}else this._animationId=-1,this._timeStart=-1})),e.default(this,"onRotationAnim",((t,i,s)=>{if(-1==this._timeStart&&(this._anglePrev=0,this._angleCurrent=0,this._timeStart=t),this._state==a.ANIMATION_ROTATE){const e=(t-this._timeStart)/1e3;if(s+-this.dampingFactor*e>0){this._angleCurrent=.5*-this.dampingFactor*Math.pow(e,2)+s*e+0,this.applyTransformMatrix(this.rotate(i,this._angleCurrent)),this.dispatchEvent(n);const t=this;this._animationId=window.requestAnimationFrame((function(e){t.onRotationAnim(e,i,s)}))}else this._animationId=-1,this._timeStart=-1,this.updateTbState(a.IDLE,!1),this.activateGizmos(!1),this.dispatchEvent(n)}else this._animationId=-1,this._timeStart=-1,this._state!=a.ROTATE&&(this.activateGizmos(!1),this.dispatchEvent(n))})),e.default(this,"pan",((t,i,s=!1)=>{const e=t.clone().sub(i);if(this.camera.isOrthographicCamera)e.multiplyScalar(1/this.camera.zoom);else if(this.camera.isPerspectiveCamera&&s){this._v3_1.setFromMatrixPosition(this._cameraMatrixState0),this._v3_2.setFromMatrixPosition(this._gizmoMatrixState0);const t=this._v3_1.distanceTo(this._v3_2)/this.camera.position.distanceTo(this._gizmos.position);e.multiplyScalar(1/t)}return this._v3_1.set(e.x,e.y,0).applyQuaternion(this.camera.quaternion),this._m4_1.makeTranslation(this._v3_1.x,this._v3_1.y,this._v3_1.z),this.setTransformationMatrices(this._m4_1,this._m4_1),r})),e.default(this,"reset",(()=>{this.camera.zoom=this._zoom0,this.camera.isPerspectiveCamera&&(this.camera.fov=this._fov0),this.camera.near=this._nearPos,this.camera.far=this._farPos,this._cameraMatrixState.copy(this._cameraMatrixState0),this._cameraMatrixState.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.up.copy(this._up0),this.camera.updateMatrix(),this.camera.updateProjectionMatrix(),this._gizmoMatrixState.copy(this._gizmoMatrixState0),this._gizmoMatrixState0.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this._gizmos.updateMatrix(),this._tbRadius=this.calculateTbRadius(this.camera),this.makeGizmos(this._gizmos.position,this._tbRadius),this.camera.lookAt(this._gizmos.position),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n)})),e.default(this,"rotate",((t,i)=>{const s=this._gizmos.position;return this._translationMatrix.makeTranslation(-s.x,-s.y,-s.z),this._rotationMatrix.makeRotationAxis(t,-i),this._m4_1.makeTranslation(s.x,s.y,s.z),this._m4_1.multiply(this._rotationMatrix),this._m4_1.multiply(this._translationMatrix),this.setTransformationMatrices(this._m4_1),r})),e.default(this,"copyState",(()=>{let t;this.camera.isOrthographicCamera?t=JSON.stringify({arcballState:{cameraFar:this.camera.far,cameraMatrix:this.camera.matrix,cameraNear:this.camera.near,cameraUp:this.camera.up,cameraZoom:this.camera.zoom,gizmoMatrix:this._gizmos.matrix}}):this.camera.isPerspectiveCamera&&(t=JSON.stringify({arcballState:{cameraFar:this.camera.far,cameraFov:this.camera.fov,cameraMatrix:this.camera.matrix,cameraNear:this.camera.near,cameraUp:this.camera.up,cameraZoom:this.camera.zoom,gizmoMatrix:this._gizmos.matrix}})),navigator.clipboard.writeText(t)})),e.default(this,"pasteState",(()=>{const t=this;navigator.clipboard.readText().then((function(i){t.setStateFromJSON(i)}))})),e.default(this,"saveState",(()=>{this._cameraMatrixState0.copy(this.camera.matrix),this._gizmoMatrixState0.copy(this._gizmos.matrix),this._nearPos=this.camera.near,this._farPos=this.camera.far,this._zoom0=this.camera.zoom,this._up0.copy(this.camera.up),this.camera.isPerspectiveCamera&&(this._fov0=this.camera.fov)})),e.default(this,"applyScale",((t,i,s=!0)=>{const e=i.clone();let a=1/t;if(this.camera.isOrthographicCamera){this.camera.zoom=this._zoomState,this.camera.zoom*=t,this.camera.zoom>this.maxZoom?(this.camera.zoom=this.maxZoom,a=this._zoomState/this.maxZoom):this.camera.zoom<this.minZoom&&(this.camera.zoom=this.minZoom,a=this._zoomState/this.minZoom),this.camera.updateProjectionMatrix(),this._v3_1.setFromMatrixPosition(this._gizmoMatrixState),this._scaleMatrix.makeScale(a,a,a),this._translationMatrix.makeTranslation(-this._v3_1.x,-this._v3_1.y,-this._v3_1.z),this._m4_2.makeTranslation(this._v3_1.x,this._v3_1.y,this._v3_1.z).multiply(this._scaleMatrix),this._m4_2.multiply(this._translationMatrix),e.sub(this._v3_1);const i=e.clone().multiplyScalar(a);return e.sub(i),this._m4_1.makeTranslation(e.x,e.y,e.z),this._m4_2.premultiply(this._m4_1),this.setTransformationMatrices(this._m4_1,this._m4_2),r}if(this.camera.isPerspectiveCamera){this._v3_1.setFromMatrixPosition(this._cameraMatrixState),this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);let t=this._v3_1.distanceTo(e),i=t-t*a;const o=t-i;o<this.minDistance?(a=this.minDistance/t,i=t-t*a):o>this.maxDistance&&(a=this.maxDistance/t,i=t-t*a);let h=e.clone().sub(this._v3_1).normalize().multiplyScalar(i);if(this._m4_1.makeTranslation(h.x,h.y,h.z),s){const s=this._v3_2;t=s.distanceTo(e),i=t-t*a,h=e.clone().sub(this._v3_2).normalize().multiplyScalar(i),this._translationMatrix.makeTranslation(s.x,s.y,s.z),this._scaleMatrix.makeScale(a,a,a),this._m4_2.makeTranslation(h.x,h.y,h.z).multiply(this._translationMatrix),this._m4_2.multiply(this._scaleMatrix),this._translationMatrix.makeTranslation(-s.x,-s.y,-s.z),this._m4_2.multiply(this._translationMatrix),this.setTransformationMatrices(this._m4_1,this._m4_2)}else this.setTransformationMatrices(this._m4_1);return r}})),e.default(this,"setFov",(t=>{this.camera.isPerspectiveCamera&&(this.camera.fov=i.MathUtils.clamp(t,this.minFov,this.maxFov),this.camera.updateProjectionMatrix())})),e.default(this,"zRotate",((t,i)=>(this._rotationMatrix.makeRotationAxis(this._rotationAxis,i),this._translationMatrix.makeTranslation(-t.x,-t.y,-t.z),this._m4_1.makeTranslation(t.x,t.y,t.z),this._m4_1.multiply(this._rotationMatrix),this._m4_1.multiply(this._translationMatrix),this._v3_1.setFromMatrixPosition(this._gizmoMatrixState).sub(t),this._v3_2.copy(this._v3_1).applyAxisAngle(this._rotationAxis,i),this._v3_2.sub(this._v3_1),this._m4_2.makeTranslation(this._v3_2.x,this._v3_2.y,this._v3_2.z),this.setTransformationMatrices(this._m4_1,this._m4_2),r))),e.default(this,"unprojectOnObj",((t,s)=>{const e=new i.Raycaster;e.near=s.near,e.far=s.far,e.setFromCamera(t,s);const a=e.intersectObjects(this.scene.children,!0);for(let t=0;t<a.length;t++)if(a[t].object.uuid!=this._gizmos.uuid&&null!=a[t].face)return a[t].point.clone();return null})),e.default(this,"unprojectOnTbSurface",((t,s,e,a,o)=>{if("OrthographicCamera"==t.type){this._v2_1.copy(this.getCursorPosition(s,e,a)),this._v3_1.set(this._v2_1.x,this._v2_1.y,0);const t=Math.pow(this._v2_1.x,2),i=Math.pow(this._v2_1.y,2),o=Math.pow(this._tbRadius,2);return t+i<=.5*o?this._v3_1.setZ(Math.sqrt(o-(t+i))):this._v3_1.setZ(.5*o/Math.sqrt(t+i)),this._v3_1}if("PerspectiveCamera"==t.type){this._v2_1.copy(this.getCursorNDC(s,e,a)),this._v3_1.set(this._v2_1.x,this._v2_1.y,-1),this._v3_1.applyMatrix4(t.projectionMatrixInverse);const h=this._v3_1.clone().normalize(),r=t.position.distanceTo(this._gizmos.position),n=Math.pow(o,2),c=this._v3_1.z,m=Math.sqrt(Math.pow(this._v3_1.x,2)+Math.pow(this._v3_1.y,2));if(0==m)return h.set(this._v3_1.x,this._v3_1.y,o),h;const l=c/m,_=r;let u=Math.pow(l,2)+1,p=2*l*_,d=Math.pow(_,2)-n,v=Math.pow(p,2)-4*u*d;if(v>=0){this._v2_1.setX((-p-Math.sqrt(v))/(2*u)),this._v2_1.setY(l*this._v2_1.x+_);if(i.MathUtils.RAD2DEG*this._v2_1.angle()>=45){const t=Math.sqrt(Math.pow(this._v2_1.x,2)+Math.pow(r-this._v2_1.y,2));return h.multiplyScalar(t),h.z+=r,h}}u=l,p=_,d=.5*-n,v=Math.pow(p,2)-4*u*d,this._v2_1.setX((-p-Math.sqrt(v))/(2*u)),this._v2_1.setY(l*this._v2_1.x+_);const M=Math.sqrt(Math.pow(this._v2_1.x,2)+Math.pow(r-this._v2_1.y,2));return h.multiplyScalar(M),h.z+=r,h}})),e.default(this,"unprojectOnTbPlane",((t,i,s,e,a=!1)=>{if("OrthographicCamera"==t.type)return this._v2_1.copy(this.getCursorPosition(i,s,e)),this._v3_1.set(this._v2_1.x,this._v2_1.y,0),this._v3_1.clone();if("PerspectiveCamera"==t.type){this._v2_1.copy(this.getCursorNDC(i,s,e)),this._v3_1.set(this._v2_1.x,this._v2_1.y,-1),this._v3_1.applyMatrix4(t.projectionMatrixInverse);const o=this._v3_1.clone().normalize(),h=this._v3_1.z,r=Math.sqrt(Math.pow(this._v3_1.x,2)+Math.pow(this._v3_1.y,2));let n;if(n=a?this._v3_1.setFromMatrixPosition(this._cameraMatrixState0).distanceTo(this._v3_2.setFromMatrixPosition(this._gizmoMatrixState0)):t.position.distanceTo(this._gizmos.position),0==r)return o.set(0,0,0),o;const c=n,m=-c/(h/r),l=Math.sqrt(Math.pow(c,2)+Math.pow(m,2));return o.multiplyScalar(l),o.z=0,o}})),e.default(this,"updateMatrixState",(()=>{this._cameraMatrixState.copy(this.camera.matrix),this._gizmoMatrixState.copy(this._gizmos.matrix),this.camera.isOrthographicCamera?(this._cameraProjectionState.copy(this.camera.projectionMatrix),this.camera.updateProjectionMatrix(),this._zoomState=this.camera.zoom):this.camera.isPerspectiveCamera&&(this._fovState=this.camera.fov)})),e.default(this,"updateTbState",((t,i)=>{this._state=t,i&&this.updateMatrixState()})),e.default(this,"update",(()=>{const t=1e-6;if(this.target.equals(this._currentTarget)||(this._gizmos.position.set(this.target.x,this.target.y,this.target.z),this._tbRadius=this.calculateTbRadius(this.camera),this.makeGizmos(this.target,this._tbRadius),this._currentTarget.copy(this.target)),this.camera.isOrthographicCamera){if(this.camera.zoom>this.maxZoom||this.camera.zoom<this.minZoom){const t=i.MathUtils.clamp(this.camera.zoom,this.minZoom,this.maxZoom);this.applyTransformMatrix(this.applyScale(t/this.camera.zoom,this._gizmos.position,!0))}}else if(this.camera.isPerspectiveCamera){const s=this.camera.position.distanceTo(this._gizmos.position);if(s>this.maxDistance+t||s<this.minDistance-t){const t=i.MathUtils.clamp(s,this.minDistance,this.maxDistance);this.applyTransformMatrix(this.applyScale(t/s,this._gizmos.position)),this.updateMatrixState()}(this.camera.fov<this.minFov||this.camera.fov>this.maxFov)&&(this.camera.fov=i.MathUtils.clamp(this.camera.fov,this.minFov,this.maxFov),this.camera.updateProjectionMatrix());const e=this._tbRadius;if(this._tbRadius=this.calculateTbRadius(this.camera),e<this._tbRadius-t||e>this._tbRadius+t){const t=(this._gizmos.scale.x+this._gizmos.scale.y+this._gizmos.scale.z)/3,s=this._tbRadius/t,e=new i.EllipseCurve(0,0,s,s).getPoints(this._curvePts),a=(new i.BufferGeometry).setFromPoints(e);for(const t in this._gizmos.children)this._gizmos.children[t].geometry=a}}this.camera.lookAt(this._gizmos.position)})),e.default(this,"setStateFromJSON",(t=>{const s=JSON.parse(t);if(null!=s.arcballState){this._cameraMatrixState.fromArray(s.arcballState.cameraMatrix.elements),this._cameraMatrixState.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.up.copy(s.arcballState.cameraUp),this.camera.near=s.arcballState.cameraNear,this.camera.far=s.arcballState.cameraFar,this.camera.zoom=s.arcballState.cameraZoom,this.camera.isPerspectiveCamera&&(this.camera.fov=s.arcballState.cameraFov),this._gizmoMatrixState.fromArray(s.arcballState.gizmoMatrix.elements),this._gizmoMatrixState.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this.camera.updateMatrix(),this.camera.updateProjectionMatrix(),this._gizmos.updateMatrix(),this._tbRadius=this.calculateTbRadius(this.camera);const t=(new i.Matrix4).copy(this._gizmoMatrixState0);this.makeGizmos(this._gizmos.position,this._tbRadius),this._gizmoMatrixState0.copy(t),this.camera.lookAt(this._gizmos.position),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n)}})),this.camera=null,this.scene=l,this.mouseActions=[],this._mouseOp=null,this._v2_1=new i.Vector2,this._v3_1=new i.Vector3,this._v3_2=new i.Vector3,this._m4_1=new i.Matrix4,this._m4_2=new i.Matrix4,this._quat=new i.Quaternion,this._translationMatrix=new i.Matrix4,this._rotationMatrix=new i.Matrix4,this._scaleMatrix=new i.Matrix4,this._rotationAxis=new i.Vector3,this._cameraMatrixState=new i.Matrix4,this._cameraProjectionState=new i.Matrix4,this._fovState=1,this._upState=new i.Vector3,this._zoomState=1,this._nearPos=0,this._farPos=0,this._gizmoMatrixState=new i.Matrix4,this._up0=new i.Vector3,this._zoom0=1,this._fov0=0,this._initialNear=0,this._nearPos0=0,this._initialFar=0,this._farPos0=0,this._cameraMatrixState0=new i.Matrix4,this._gizmoMatrixState0=new i.Matrix4,this._button=-1,this._touchStart=[],this._touchCurrent=[],this._input=o.NONE,this._switchSensibility=32,this._startFingerDistance=0,this._currentFingerDistance=0,this._startFingerRotation=0,this._currentFingerRotation=0,this._devPxRatio=0,this._downValid=!0,this._nclicks=0,this._downEvents=[],this._downStart=0,this._clickStart=0,this._maxDownTime=250,this._maxInterval=300,this._posThreshold=24,this._movementThreshold=24,this._currentCursorPosition=new i.Vector3,this._startCursorPosition=new i.Vector3,this._grid=null,this._gridPosition=new i.Vector3,this._gizmos=new i.Group,this._curvePts=128,this._timeStart=-1,this._animationId=-1,this.focusAnimationTime=500,this._timePrev=0,this._timeCurrent=0,this._anglePrev=0,this._angleCurrent=0,this._cursorPosPrev=new i.Vector3,this._cursorPosCurr=new i.Vector3,this._wPrev=0,this._wCurr=0,this.adjustNearFar=!1,this.scaleFactor=1.1,this.dampingFactor=25,this.wMax=20,this.enableAnimations=!0,this.enableGrid=!1,this.cursorZoom=!1,this.minFov=5,this.maxFov=90,this.enabled=!0,this.enablePan=!0,this.enableRotate=!0,this.enableZoom=!0,this.enableGizmos=!0,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.target=new i.Vector3(0,0,0),this._currentTarget=new i.Vector3(0,0,0),this._tbRadius=1,this._state=a.IDLE,this.setCamera(t),null!=this.scene&&this.scene.add(this._gizmos),void 0!==s&&this.connect(s),this._devPxRatio=window.devicePixelRatio,this.initializeMouseActions()}applyTransformMatrix(t){if(null!=t.camera&&(this._m4_1.copy(this._cameraMatrixState).premultiply(t.camera),this._m4_1.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.updateMatrix(),this._state!=a.ROTATE&&this._state!=a.ZROTATE&&this._state!=a.ANIMATION_ROTATE||this.camera.up.copy(this._upState).applyQuaternion(this.camera.quaternion)),null!=t.gizmos&&(this._m4_1.copy(this._gizmoMatrixState).premultiply(t.gizmos),this._m4_1.decompose(this._gizmos.position,this._gizmos.quaternion,this._gizmos.scale),this._gizmos.updateMatrix()),this._state==a.SCALE||this._state==a.FOCUS||this._state==a.ANIMATION_FOCUS)if(this._tbRadius=this.calculateTbRadius(this.camera),this.adjustNearFar){const t=this.camera.position.distanceTo(this._gizmos.position),s=new i.Box3;s.setFromObject(this._gizmos);const e=new i.Sphere;s.getBoundingSphere(e);const a=Math.max(this._nearPos0,e.radius+e.center.length()),o=t-this._initialNear,h=Math.min(a,o);this.camera.near=t-h;const r=Math.min(this._farPos0,-e.radius+e.center.length()),n=t-this._initialFar,c=Math.min(r,n);this.camera.far=t-c,this.camera.updateProjectionMatrix()}else{let t=!1;this.camera.near!=this._initialNear&&(this.camera.near=this._initialNear,t=!0),this.camera.far!=this._initialFar&&(this.camera.far=this._initialFar,t=!0),t&&this.camera.updateProjectionMatrix()}}setGizmosVisible(t){this._gizmos.visible=t,this.dispatchEvent(n)}setTransformationMatrices(t=null,i=null){null!=t?null!=r.camera?r.camera.copy(t):r.camera=t.clone():r.camera=null,null!=i?null!=r.gizmos?r.gizmos.copy(i):r.gizmos=i.clone():r.gizmos=null}}exports.ArcballControls=l;
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import { Matrix4, Object3D, EllipseCurve, BufferGeometry, MathUtils, Vector3, GridHelper, LineBasicMaterial, Line, Raycaster, Vector2, Quaternion, Group, Box3, Sphere } from 'three';
2
+ import { Matrix4, EventDispatcher, EllipseCurve, BufferGeometry, MathUtils, Vector3, GridHelper, LineBasicMaterial, Line, Raycaster, Vector2, Quaternion, Group, Box3, Sphere } from 'three';
3
3
 
4
4
  const STATE = {
5
5
  IDLE: Symbol(),
@@ -48,7 +48,7 @@ const _endEvent = {
48
48
  * @param {Scene} scene The scene to be rendered
49
49
  */
50
50
 
51
- class ArcballControls extends Object3D {
51
+ class ArcballControls extends EventDispatcher {
52
52
  constructor(_camera, _domElement, scene = null) {
53
53
  super();
54
54
 
@@ -355,9 +355,9 @@ class ArcballControls extends Object3D {
355
355
  scalePoint = this.unprojectOnTbPlane(this.camera, event.clientX, event.clientY, this.domElement).applyQuaternion(this.camera.quaternion).add(this._gizmos.position);
356
356
  }
357
357
 
358
- this.applyTransformMatrix(this.setScale(size, scalePoint));
358
+ this.applyTransformMatrix(this.applyScale(size, scalePoint));
359
359
  } else {
360
- this.applyTransformMatrix(this.setScale(size, this._gizmos.position));
360
+ this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
361
361
  }
362
362
 
363
363
  if (this._grid != null) {
@@ -416,7 +416,7 @@ class ArcballControls extends Object3D {
416
416
  const newDistance = y / Math.tan(MathUtils.DEG2RAD * (newFov / 2));
417
417
  size = x / newDistance;
418
418
  this.setFov(newFov);
419
- this.applyTransformMatrix(this.setScale(size, this._gizmos.position, false));
419
+ this.applyTransformMatrix(this.applyScale(size, this._gizmos.position, false));
420
420
  }
421
421
 
422
422
  if (this._grid != null) {
@@ -660,7 +660,7 @@ class ArcballControls extends Object3D {
660
660
  size = Math.pow(this.scaleFactor, movement * screenNotches);
661
661
  }
662
662
 
663
- this.applyTransformMatrix(this.setScale(size, this._gizmos.position));
663
+ this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
664
664
  }
665
665
  }
666
666
 
@@ -717,7 +717,7 @@ class ArcballControls extends Object3D {
717
717
  this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
718
718
 
719
719
  this.setFov(newFov);
720
- this.applyTransformMatrix(this.setScale(size, this._v3_2, false)); //adjusting distance
720
+ this.applyTransformMatrix(this.applyScale(size, this._v3_2, false)); //adjusting distance
721
721
 
722
722
  const direction = this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(newDistance / x);
723
723
 
@@ -922,7 +922,7 @@ class ArcballControls extends Object3D {
922
922
  }
923
923
  }
924
924
 
925
- this.applyTransformMatrix(this.setScale(amount, scalePoint));
925
+ this.applyTransformMatrix(this.applyScale(amount, scalePoint));
926
926
  this.dispatchEvent(_changeEvent);
927
927
  }
928
928
  });
@@ -1008,7 +1008,7 @@ class ArcballControls extends Object3D {
1008
1008
  this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);
1009
1009
 
1010
1010
  this.setFov(newFov);
1011
- this.applyTransformMatrix(this.setScale(size, this._v3_2, false)); //adjusting distance
1011
+ this.applyTransformMatrix(this.applyScale(size, this._v3_2, false)); //adjusting distance
1012
1012
 
1013
1013
  const direction = this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(newDistance / x);
1014
1014
 
@@ -1238,7 +1238,7 @@ class ArcballControls extends Object3D {
1238
1238
 
1239
1239
 
1240
1240
  if (this.enableZoom) {
1241
- this.applyTransformMatrix(this.setScale(size, this._gizmos.position));
1241
+ this.applyTransformMatrix(this.applyScale(size, this._gizmos.position));
1242
1242
  }
1243
1243
 
1244
1244
  this._gizmoMatrixState.copy(gizmoStateTemp);
@@ -1678,7 +1678,7 @@ class ArcballControls extends Object3D {
1678
1678
  }
1679
1679
  });
1680
1680
 
1681
- _defineProperty(this, "setScale", (size, point, scaleGizmos = true) => {
1681
+ _defineProperty(this, "applyScale", (size, point, scaleGizmos = true) => {
1682
1682
  const scalePoint = point.clone();
1683
1683
  let sizeInverse = 1 / size;
1684
1684
 
@@ -2013,16 +2013,16 @@ class ArcballControls extends Object3D {
2013
2013
  });
2014
2014
 
2015
2015
  _defineProperty(this, "update", () => {
2016
- const EPS = 0.000001;
2016
+ const EPS = 0.000001; // Update target and gizmos state
2017
2017
 
2018
- if (this.target.x !== this._prevTarget.x || this.target.y !== this._prevTarget.y || this.target.z !== this._prevTarget.z) {
2018
+ if (!this.target.equals(this._currentTarget)) {
2019
2019
  this._gizmos.position.set(this.target.x, this.target.y, this.target.z); //for correct radius calculation
2020
2020
 
2021
2021
 
2022
2022
  this._tbRadius = this.calculateTbRadius(this.camera);
2023
2023
  this.makeGizmos(this.target, this._tbRadius);
2024
2024
 
2025
- this._prevTarget.copy(this.target);
2025
+ this._currentTarget.copy(this.target);
2026
2026
  } //check min/max parameters
2027
2027
 
2028
2028
 
@@ -2030,7 +2030,7 @@ class ArcballControls extends Object3D {
2030
2030
  //check zoom
2031
2031
  if (this.camera.zoom > this.maxZoom || this.camera.zoom < this.minZoom) {
2032
2032
  const newZoom = MathUtils.clamp(this.camera.zoom, this.minZoom, this.maxZoom);
2033
- this.applyTransformMatrix(this.setScale(newZoom / this.camera.zoom, this._gizmos.position, true));
2033
+ this.applyTransformMatrix(this.applyScale(newZoom / this.camera.zoom, this._gizmos.position, true));
2034
2034
  }
2035
2035
  } else if (this.camera.isPerspectiveCamera) {
2036
2036
  //check distance
@@ -2038,7 +2038,7 @@ class ArcballControls extends Object3D {
2038
2038
 
2039
2039
  if (distance > this.maxDistance + EPS || distance < this.minDistance - EPS) {
2040
2040
  const newDistance = MathUtils.clamp(distance, this.minDistance, this.maxDistance);
2041
- this.applyTransformMatrix(this.setScale(newDistance / distance, this._gizmos.position));
2041
+ this.applyTransformMatrix(this.applyScale(newDistance / distance, this._gizmos.position));
2042
2042
  this.updateMatrixState();
2043
2043
  } //check fov
2044
2044
 
@@ -2231,7 +2231,7 @@ class ArcballControls extends Object3D {
2231
2231
  this.maxZoom = Infinity; //trackball parameters
2232
2232
 
2233
2233
  this.target = new Vector3(0, 0, 0);
2234
- this._prevTarget = new Vector3(0, 0, 0);
2234
+ this._currentTarget = new Vector3(0, 0, 0);
2235
2235
  this._tbRadius = 1; //FSA
2236
2236
 
2237
2237
  this._state = STATE.IDLE;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("three");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e);const a=(e,t)=>(e%t+t)%t;class i extends t.EventDispatcher{constructor(e,n){super(),o.default(this,"object",void 0),o.default(this,"domElement",void 0),o.default(this,"enabled",!0),o.default(this,"target",new t.Vector3),o.default(this,"minDistance",0),o.default(this,"maxDistance",1/0),o.default(this,"minZoom",0),o.default(this,"maxZoom",1/0),o.default(this,"minPolarAngle",0),o.default(this,"maxPolarAngle",Math.PI),o.default(this,"minAzimuthAngle",-1/0),o.default(this,"maxAzimuthAngle",1/0),o.default(this,"enableDamping",!1),o.default(this,"dampingFactor",.05),o.default(this,"enableZoom",!0),o.default(this,"zoomSpeed",1),o.default(this,"enableRotate",!0),o.default(this,"rotateSpeed",1),o.default(this,"enablePan",!0),o.default(this,"panSpeed",1),o.default(this,"screenSpacePanning",!0),o.default(this,"keyPanSpeed",7),o.default(this,"autoRotate",!1),o.default(this,"autoRotateSpeed",2),o.default(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),o.default(this,"mouseButtons",{LEFT:t.MOUSE.ROTATE,MIDDLE:t.MOUSE.DOLLY,RIGHT:t.MOUSE.PAN}),o.default(this,"touches",{ONE:t.TOUCH.ROTATE,TWO:t.TOUCH.DOLLY_PAN}),o.default(this,"target0",void 0),o.default(this,"position0",void 0),o.default(this,"zoom0",void 0),o.default(this,"_domElementKeyEvents",null),o.default(this,"getPolarAngle",void 0),o.default(this,"getAzimuthalAngle",void 0),o.default(this,"setPolarAngle",void 0),o.default(this,"setAzimuthalAngle",void 0),o.default(this,"getDistance",void 0),o.default(this,"listenToKeyEvents",void 0),o.default(this,"saveState",void 0),o.default(this,"reset",void 0),o.default(this,"update",void 0),o.default(this,"connect",void 0),o.default(this,"dispose",void 0),this.object=e,this.domElement=n,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object instanceof t.PerspectiveCamera?this.object.zoom:1,this.getPolarAngle=()=>h.phi,this.getAzimuthalAngle=()=>h.theta,this.setPolarAngle=e=>{let t=a(e,2*Math.PI),n=h.phi;n<0&&(n+=2*Math.PI),t<0&&(t+=2*Math.PI);let o=Math.abs(t-n);2*Math.PI-o<o&&(t<n?t+=2*Math.PI:n+=2*Math.PI),m.phi=t-n,i.update()},this.setAzimuthalAngle=e=>{let t=a(e,2*Math.PI),n=h.theta;n<0&&(n+=2*Math.PI),t<0&&(t+=2*Math.PI);let o=Math.abs(t-n);2*Math.PI-o<o&&(t<n?t+=2*Math.PI:n+=2*Math.PI),m.theta=t-n,i.update()},this.getDistance=()=>i.object.position.distanceTo(i.target),this.listenToKeyEvents=e=>{e.addEventListener("keydown",q),this._domElementKeyEvents=e},this.saveState=()=>{i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object instanceof t.PerspectiveCamera?i.object.zoom:1},this.reset=()=>{i.target.copy(i.target0),i.object.position.copy(i.position0),i.object instanceof t.PerspectiveCamera&&(i.object.zoom=i.zoom0,i.object.updateProjectionMatrix()),i.dispatchEvent(s),i.update(),u=l.NONE},this.update=(()=>{const n=new t.Vector3,o=(new t.Quaternion).setFromUnitVectors(e.up,new t.Vector3(0,1,0)),a=o.clone().invert(),r=new t.Vector3,c=new t.Quaternion,E=2*Math.PI;return function(){const e=i.object.position;n.copy(e).sub(i.target),n.applyQuaternion(o),h.setFromVector3(n),i.autoRotate&&u===l.NONE&&N(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(h.theta+=m.theta*i.dampingFactor,h.phi+=m.phi*i.dampingFactor):(h.theta+=m.theta,h.phi+=m.phi);let t=i.minAzimuthAngle,g=i.maxAzimuthAngle;return isFinite(t)&&isFinite(g)&&(t<-Math.PI?t+=E:t>Math.PI&&(t-=E),g<-Math.PI?g+=E:g>Math.PI&&(g-=E),h.theta=t<=g?Math.max(t,Math.min(g,h.theta)):h.theta>(t+g)/2?Math.max(t,h.theta):Math.min(g,h.theta)),h.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,h.phi)),h.makeSafe(),h.radius*=p,h.radius=Math.max(i.minDistance,Math.min(i.maxDistance,h.radius)),!0===i.enableDamping?i.target.addScaledVector(b,i.dampingFactor):i.target.add(b),n.setFromSpherical(h),n.applyQuaternion(a),e.copy(i.target).add(n),i.object.lookAt(i.target),!0===i.enableDamping?(m.theta*=1-i.dampingFactor,m.phi*=1-i.dampingFactor,b.multiplyScalar(1-i.dampingFactor)):(m.set(0,0,0),b.set(0,0,0)),p=1,!!(f||r.distanceToSquared(i.object.position)>d||8*(1-c.dot(i.object.quaternion))>d)&&(i.dispatchEvent(s),r.copy(i.object.position),c.copy(i.object.quaternion),f=!1,!0)}})(),this.connect=e=>{e===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),i.domElement=e,i.domElement.style.touchAction="none",i.domElement.addEventListener("contextmenu",W),i.domElement.addEventListener("pointerdown",X),i.domElement.addEventListener("pointercancel",B),i.domElement.addEventListener("wheel",G)},this.dispose=()=>{var e,t,n,o,a,s;null===(e=i.domElement)||void 0===e||e.removeEventListener("contextmenu",W),null===(t=i.domElement)||void 0===t||t.removeEventListener("pointerdown",X),null===(n=i.domElement)||void 0===n||n.removeEventListener("pointercancel",B),null===(o=i.domElement)||void 0===o||o.removeEventListener("wheel",G),null===(a=i.domElement)||void 0===a||a.ownerDocument.removeEventListener("pointermove",Z),null===(s=i.domElement)||void 0===s||s.ownerDocument.removeEventListener("pointerup",K),null!==i._domElementKeyEvents&&i._domElementKeyEvents.removeEventListener("keydown",q)};const i=this,s={type:"change"},r={type:"start"},c={type:"end"},l={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let u=l.NONE;const d=1e-6,h=new t.Spherical,m=new t.Spherical;let p=1;const b=new t.Vector3;let f=!1;const E=new t.Vector2,g=new t.Vector2,O=new t.Vector2,v=new t.Vector2,P=new t.Vector2,T=new t.Vector2,y=new t.Vector2,A=new t.Vector2,M=new t.Vector2,j=[],w={};function L(){return Math.pow(.95,i.zoomSpeed)}function N(e){m.theta-=e}function C(e){m.phi-=e}const I=(()=>{const e=new t.Vector3;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),b.add(e)}})(),R=(()=>{const e=new t.Vector3;return function(t,n){!0===i.screenSpacePanning?e.setFromMatrixColumn(n,1):(e.setFromMatrixColumn(n,0),e.crossVectors(i.object.up,e)),e.multiplyScalar(t),b.add(e)}})(),S=(()=>{const e=new t.Vector3;return function(n,o){const a=i.domElement;if(a&&i.object instanceof t.PerspectiveCamera&&i.object.isPerspectiveCamera){const t=i.object.position;e.copy(t).sub(i.target);let s=e.length();s*=Math.tan(i.object.fov/2*Math.PI/180),I(2*n*s/a.clientHeight,i.object.matrix),R(2*o*s/a.clientHeight,i.object.matrix)}else a&&i.object instanceof t.OrthographicCamera&&i.object.isOrthographicCamera?(I(n*(i.object.right-i.object.left)/i.object.zoom/a.clientWidth,i.object.matrix),R(o*(i.object.top-i.object.bottom)/i.object.zoom/a.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function D(e){i.object instanceof t.PerspectiveCamera&&i.object.isPerspectiveCamera?p/=e:i.object instanceof t.OrthographicCamera&&i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*e)),i.object.updateProjectionMatrix(),f=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function x(e){i.object instanceof t.PerspectiveCamera&&i.object.isPerspectiveCamera?p*=e:i.object instanceof t.OrthographicCamera&&i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/e)),i.object.updateProjectionMatrix(),f=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function k(e){E.set(e.clientX,e.clientY)}function Y(e){v.set(e.clientX,e.clientY)}function H(){if(1==j.length)E.set(j[0].pageX,j[0].pageY);else{const e=.5*(j[0].pageX+j[1].pageX),t=.5*(j[0].pageY+j[1].pageY);E.set(e,t)}}function U(){if(1==j.length)v.set(j[0].pageX,j[0].pageY);else{const e=.5*(j[0].pageX+j[1].pageX),t=.5*(j[0].pageY+j[1].pageY);v.set(e,t)}}function _(){const e=j[0].pageX-j[1].pageX,t=j[0].pageY-j[1].pageY,n=Math.sqrt(e*e+t*t);y.set(0,n)}function V(e){if(1==j.length)g.set(e.pageX,e.pageY);else{const t=$(e),n=.5*(e.pageX+t.x),o=.5*(e.pageY+t.y);g.set(n,o)}O.subVectors(g,E).multiplyScalar(i.rotateSpeed);const t=i.domElement;t&&(N(2*Math.PI*O.x/t.clientHeight),C(2*Math.PI*O.y/t.clientHeight)),E.copy(g)}function z(e){if(1==j.length)P.set(e.pageX,e.pageY);else{const t=$(e),n=.5*(e.pageX+t.x),o=.5*(e.pageY+t.y);P.set(n,o)}T.subVectors(P,v).multiplyScalar(i.panSpeed),S(T.x,T.y),v.copy(P)}function F(e){const t=$(e),n=e.pageX-t.x,o=e.pageY-t.y,a=Math.sqrt(n*n+o*o);A.set(0,a),M.set(0,Math.pow(A.y/y.y,i.zoomSpeed)),D(M.y),y.copy(A)}function X(e){if(!1!==i.enabled){var n,o;if(0===j.length)null===(n=i.domElement)||void 0===n||n.ownerDocument.addEventListener("pointermove",Z),null===(o=i.domElement)||void 0===o||o.ownerDocument.addEventListener("pointerup",K);!function(e){j.push(e)}(e),"touch"===e.pointerType?function(e){switch(J(e),j.length){case 1:switch(i.touches.ONE){case t.TOUCH.ROTATE:if(!1===i.enableRotate)return;H(),u=l.TOUCH_ROTATE;break;case t.TOUCH.PAN:if(!1===i.enablePan)return;U(),u=l.TOUCH_PAN;break;default:u=l.NONE}break;case 2:switch(i.touches.TWO){case t.TOUCH.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&_(),i.enablePan&&U(),u=l.TOUCH_DOLLY_PAN;break;case t.TOUCH.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&_(),i.enableRotate&&H(),u=l.TOUCH_DOLLY_ROTATE;break;default:u=l.NONE}break;default:u=l.NONE}u!==l.NONE&&i.dispatchEvent(r)}(e):function(e){let n;switch(e.button){case 0:n=i.mouseButtons.LEFT;break;case 1:n=i.mouseButtons.MIDDLE;break;case 2:n=i.mouseButtons.RIGHT;break;default:n=-1}switch(n){case t.MOUSE.DOLLY:if(!1===i.enableZoom)return;!function(e){y.set(e.clientX,e.clientY)}(e),u=l.DOLLY;break;case t.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===i.enablePan)return;Y(e),u=l.PAN}else{if(!1===i.enableRotate)return;k(e),u=l.ROTATE}break;case t.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===i.enableRotate)return;k(e),u=l.ROTATE}else{if(!1===i.enablePan)return;Y(e),u=l.PAN}break;default:u=l.NONE}u!==l.NONE&&i.dispatchEvent(r)}(e)}}function Z(e){!1!==i.enabled&&("touch"===e.pointerType?function(e){switch(J(e),u){case l.TOUCH_ROTATE:if(!1===i.enableRotate)return;V(e),i.update();break;case l.TOUCH_PAN:if(!1===i.enablePan)return;z(e),i.update();break;case l.TOUCH_DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(e){i.enableZoom&&F(e),i.enablePan&&z(e)}(e),i.update();break;case l.TOUCH_DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(e){i.enableZoom&&F(e),i.enableRotate&&V(e)}(e),i.update();break;default:u=l.NONE}}(e):function(e){if(!1===i.enabled)return;switch(u){case l.ROTATE:if(!1===i.enableRotate)return;!function(e){g.set(e.clientX,e.clientY),O.subVectors(g,E).multiplyScalar(i.rotateSpeed);const t=i.domElement;t&&(N(2*Math.PI*O.x/t.clientHeight),C(2*Math.PI*O.y/t.clientHeight)),E.copy(g),i.update()}(e);break;case l.DOLLY:if(!1===i.enableZoom)return;!function(e){A.set(e.clientX,e.clientY),M.subVectors(A,y),M.y>0?D(L()):M.y<0&&x(L()),y.copy(A),i.update()}(e);break;case l.PAN:if(!1===i.enablePan)return;!function(e){P.set(e.clientX,e.clientY),T.subVectors(P,v).multiplyScalar(i.panSpeed),S(T.x,T.y),v.copy(P),i.update()}(e)}}(e))}function K(e){var t,n;!1!==i.enabled&&(e.pointerType,i.dispatchEvent(c),u=l.NONE,Q(e),0===j.length&&(null===(t=i.domElement)||void 0===t||t.ownerDocument.removeEventListener("pointermove",Z),null===(n=i.domElement)||void 0===n||n.ownerDocument.removeEventListener("pointerup",K)))}function B(e){Q(e)}function G(e){!1===i.enabled||!1===i.enableZoom||u!==l.NONE&&u!==l.ROTATE||(e.preventDefault(),i.dispatchEvent(r),function(e){e.deltaY<0?x(L()):e.deltaY>0&&D(L()),i.update()}(e),i.dispatchEvent(c))}function q(e){!1!==i.enabled&&!1!==i.enablePan&&function(e){let t=!1;switch(e.code){case i.keys.UP:S(0,i.keyPanSpeed),t=!0;break;case i.keys.BOTTOM:S(0,-i.keyPanSpeed),t=!0;break;case i.keys.LEFT:S(i.keyPanSpeed,0),t=!0;break;case i.keys.RIGHT:S(-i.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),i.update())}(e)}function W(e){!1!==i.enabled&&e.preventDefault()}function Q(e){delete w[e.pointerId];for(let t=0;t<j.length;t++)if(j[t].pointerId==e.pointerId)return void j.splice(t,1)}function J(e){let n=w[e.pointerId];void 0===n&&(n=new t.Vector2,w[e.pointerId]=n),n.set(e.pageX,e.pageY)}function $(e){const t=e.pointerId===j[0].pointerId?j[1]:j[0];return w[t.pointerId]}void 0!==n&&this.connect(n),this.update()}}exports.MapControls=class extends i{constructor(e,n){super(e,n),this.screenSpacePanning=!1,this.mouseButtons.LEFT=t.MOUSE.PAN,this.mouseButtons.RIGHT=t.MOUSE.ROTATE,this.touches.ONE=t.TOUCH.PAN,this.touches.TWO=t.TOUCH.DOLLY_ROTATE}},exports.OrbitControls=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("three");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e);const a=(e,t)=>(e%t+t)%t;class i extends t.EventDispatcher{constructor(e,n){super(),o.default(this,"object",void 0),o.default(this,"domElement",void 0),o.default(this,"enabled",!0),o.default(this,"target",new t.Vector3),o.default(this,"minDistance",0),o.default(this,"maxDistance",1/0),o.default(this,"minZoom",0),o.default(this,"maxZoom",1/0),o.default(this,"minPolarAngle",0),o.default(this,"maxPolarAngle",Math.PI),o.default(this,"minAzimuthAngle",-1/0),o.default(this,"maxAzimuthAngle",1/0),o.default(this,"enableDamping",!1),o.default(this,"dampingFactor",.05),o.default(this,"enableZoom",!0),o.default(this,"zoomSpeed",1),o.default(this,"enableRotate",!0),o.default(this,"rotateSpeed",1),o.default(this,"enablePan",!0),o.default(this,"panSpeed",1),o.default(this,"screenSpacePanning",!0),o.default(this,"keyPanSpeed",7),o.default(this,"autoRotate",!1),o.default(this,"autoRotateSpeed",2),o.default(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),o.default(this,"mouseButtons",{LEFT:t.MOUSE.ROTATE,MIDDLE:t.MOUSE.DOLLY,RIGHT:t.MOUSE.PAN}),o.default(this,"touches",{ONE:t.TOUCH.ROTATE,TWO:t.TOUCH.DOLLY_PAN}),o.default(this,"target0",void 0),o.default(this,"position0",void 0),o.default(this,"zoom0",void 0),o.default(this,"_domElementKeyEvents",null),o.default(this,"getPolarAngle",void 0),o.default(this,"getAzimuthalAngle",void 0),o.default(this,"setPolarAngle",void 0),o.default(this,"setAzimuthalAngle",void 0),o.default(this,"getDistance",void 0),o.default(this,"listenToKeyEvents",void 0),o.default(this,"saveState",void 0),o.default(this,"reset",void 0),o.default(this,"update",void 0),o.default(this,"connect",void 0),o.default(this,"dispose",void 0),this.object=e,this.domElement=n,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object instanceof t.PerspectiveCamera?this.object.zoom:1,this.getPolarAngle=()=>h.phi,this.getAzimuthalAngle=()=>h.theta,this.setPolarAngle=e=>{let t=a(e,2*Math.PI),n=h.phi;n<0&&(n+=2*Math.PI),t<0&&(t+=2*Math.PI);let o=Math.abs(t-n);2*Math.PI-o<o&&(t<n?t+=2*Math.PI:n+=2*Math.PI),m.phi=t-n,i.update()},this.setAzimuthalAngle=e=>{let t=a(e,2*Math.PI),n=h.theta;n<0&&(n+=2*Math.PI),t<0&&(t+=2*Math.PI);let o=Math.abs(t-n);2*Math.PI-o<o&&(t<n?t+=2*Math.PI:n+=2*Math.PI),m.theta=t-n,i.update()},this.getDistance=()=>i.object.position.distanceTo(i.target),this.listenToKeyEvents=e=>{e.addEventListener("keydown",q),this._domElementKeyEvents=e},this.saveState=()=>{i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object instanceof t.PerspectiveCamera?i.object.zoom:1},this.reset=()=>{i.target.copy(i.target0),i.object.position.copy(i.position0),i.object instanceof t.PerspectiveCamera&&(i.object.zoom=i.zoom0,i.object.updateProjectionMatrix()),i.dispatchEvent(r),i.update(),u=l.NONE},this.update=(()=>{const n=new t.Vector3,o=(new t.Quaternion).setFromUnitVectors(e.up,new t.Vector3(0,1,0)),a=o.clone().invert(),s=new t.Vector3,c=new t.Quaternion,E=2*Math.PI;return function(){const e=i.object.position;n.copy(e).sub(i.target),n.applyQuaternion(o),h.setFromVector3(n),i.autoRotate&&u===l.NONE&&N(2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(h.theta+=m.theta*i.dampingFactor,h.phi+=m.phi*i.dampingFactor):(h.theta+=m.theta,h.phi+=m.phi);let t=i.minAzimuthAngle,g=i.maxAzimuthAngle;return isFinite(t)&&isFinite(g)&&(t<-Math.PI?t+=E:t>Math.PI&&(t-=E),g<-Math.PI?g+=E:g>Math.PI&&(g-=E),h.theta=t<=g?Math.max(t,Math.min(g,h.theta)):h.theta>(t+g)/2?Math.max(t,h.theta):Math.min(g,h.theta)),h.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,h.phi)),h.makeSafe(),h.radius*=p,h.radius=Math.max(i.minDistance,Math.min(i.maxDistance,h.radius)),!0===i.enableDamping?i.target.addScaledVector(b,i.dampingFactor):i.target.add(b),n.setFromSpherical(h),n.applyQuaternion(a),e.copy(i.target).add(n),i.object.lookAt(i.target),!0===i.enableDamping?(m.theta*=1-i.dampingFactor,m.phi*=1-i.dampingFactor,b.multiplyScalar(1-i.dampingFactor)):(m.set(0,0,0),b.set(0,0,0)),p=1,!!(f||s.distanceToSquared(i.object.position)>d||8*(1-c.dot(i.object.quaternion))>d)&&(i.dispatchEvent(r),s.copy(i.object.position),c.copy(i.object.quaternion),f=!1,!0)}})(),this.connect=e=>{e===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),i.domElement=e,i.domElement.style.touchAction="none",i.domElement.addEventListener("contextmenu",W),i.domElement.addEventListener("pointerdown",X),i.domElement.addEventListener("pointercancel",B),i.domElement.addEventListener("wheel",G)},this.dispose=()=>{var e,t,n,o,a,r;null===(e=i.domElement)||void 0===e||e.removeEventListener("contextmenu",W),null===(t=i.domElement)||void 0===t||t.removeEventListener("pointerdown",X),null===(n=i.domElement)||void 0===n||n.removeEventListener("pointercancel",B),null===(o=i.domElement)||void 0===o||o.removeEventListener("wheel",G),null===(a=i.domElement)||void 0===a||a.ownerDocument.removeEventListener("pointermove",Z),null===(r=i.domElement)||void 0===r||r.ownerDocument.removeEventListener("pointerup",K),null!==i._domElementKeyEvents&&i._domElementKeyEvents.removeEventListener("keydown",q)};const i=this,r={type:"change"},s={type:"start"},c={type:"end"},l={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let u=l.NONE;const d=1e-6,h=new t.Spherical,m=new t.Spherical;let p=1;const b=new t.Vector3;let f=!1;const E=new t.Vector2,g=new t.Vector2,O=new t.Vector2,v=new t.Vector2,P=new t.Vector2,T=new t.Vector2,y=new t.Vector2,A=new t.Vector2,M=new t.Vector2,j=[],w={};function L(){return Math.pow(.95,i.zoomSpeed)}function N(e){m.theta-=e}function C(e){m.phi-=e}const I=(()=>{const e=new t.Vector3;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),b.add(e)}})(),R=(()=>{const e=new t.Vector3;return function(t,n){!0===i.screenSpacePanning?e.setFromMatrixColumn(n,1):(e.setFromMatrixColumn(n,0),e.crossVectors(i.object.up,e)),e.multiplyScalar(t),b.add(e)}})(),S=(()=>{const e=new t.Vector3;return function(n,o){const a=i.domElement;if(a&&i.object instanceof t.PerspectiveCamera&&i.object.isPerspectiveCamera){const t=i.object.position;e.copy(t).sub(i.target);let r=e.length();r*=Math.tan(i.object.fov/2*Math.PI/180),I(2*n*r/a.clientHeight,i.object.matrix),R(2*o*r/a.clientHeight,i.object.matrix)}else a&&i.object instanceof t.OrthographicCamera&&i.object.isOrthographicCamera?(I(n*(i.object.right-i.object.left)/i.object.zoom/a.clientWidth,i.object.matrix),R(o*(i.object.top-i.object.bottom)/i.object.zoom/a.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function D(e){i.object instanceof t.PerspectiveCamera&&i.object.isPerspectiveCamera?p/=e:i.object instanceof t.OrthographicCamera&&i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom*e)),i.object.updateProjectionMatrix(),f=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function x(e){i.object instanceof t.PerspectiveCamera&&i.object.isPerspectiveCamera?p*=e:i.object instanceof t.OrthographicCamera&&i.object.isOrthographicCamera?(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/e)),i.object.updateProjectionMatrix(),f=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function k(e){E.set(e.clientX,e.clientY)}function Y(e){v.set(e.clientX,e.clientY)}function H(){if(1==j.length)E.set(j[0].pageX,j[0].pageY);else{const e=.5*(j[0].pageX+j[1].pageX),t=.5*(j[0].pageY+j[1].pageY);E.set(e,t)}}function U(){if(1==j.length)v.set(j[0].pageX,j[0].pageY);else{const e=.5*(j[0].pageX+j[1].pageX),t=.5*(j[0].pageY+j[1].pageY);v.set(e,t)}}function _(){const e=j[0].pageX-j[1].pageX,t=j[0].pageY-j[1].pageY,n=Math.sqrt(e*e+t*t);y.set(0,n)}function V(e){if(1==j.length)g.set(e.pageX,e.pageY);else{const t=$(e),n=.5*(e.pageX+t.x),o=.5*(e.pageY+t.y);g.set(n,o)}O.subVectors(g,E).multiplyScalar(i.rotateSpeed);const t=i.domElement;t&&(N(2*Math.PI*O.x/t.clientHeight),C(2*Math.PI*O.y/t.clientHeight)),E.copy(g)}function z(e){if(1==j.length)P.set(e.pageX,e.pageY);else{const t=$(e),n=.5*(e.pageX+t.x),o=.5*(e.pageY+t.y);P.set(n,o)}T.subVectors(P,v).multiplyScalar(i.panSpeed),S(T.x,T.y),v.copy(P)}function F(e){const t=$(e),n=e.pageX-t.x,o=e.pageY-t.y,a=Math.sqrt(n*n+o*o);A.set(0,a),M.set(0,Math.pow(A.y/y.y,i.zoomSpeed)),D(M.y),y.copy(A)}function X(e){if(!1!==i.enabled){var n,o;if(0===j.length)null===(n=i.domElement)||void 0===n||n.ownerDocument.addEventListener("pointermove",Z),null===(o=i.domElement)||void 0===o||o.ownerDocument.addEventListener("pointerup",K);!function(e){j.push(e)}(e),"touch"===e.pointerType?function(e){switch(J(e),j.length){case 1:switch(i.touches.ONE){case t.TOUCH.ROTATE:if(!1===i.enableRotate)return;H(),u=l.TOUCH_ROTATE;break;case t.TOUCH.PAN:if(!1===i.enablePan)return;U(),u=l.TOUCH_PAN;break;default:u=l.NONE}break;case 2:switch(i.touches.TWO){case t.TOUCH.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&_(),i.enablePan&&U(),u=l.TOUCH_DOLLY_PAN;break;case t.TOUCH.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&_(),i.enableRotate&&H(),u=l.TOUCH_DOLLY_ROTATE;break;default:u=l.NONE}break;default:u=l.NONE}u!==l.NONE&&i.dispatchEvent(s)}(e):function(e){let n;switch(e.button){case 0:n=i.mouseButtons.LEFT;break;case 1:n=i.mouseButtons.MIDDLE;break;case 2:n=i.mouseButtons.RIGHT;break;default:n=-1}switch(n){case t.MOUSE.DOLLY:if(!1===i.enableZoom)return;!function(e){y.set(e.clientX,e.clientY)}(e),u=l.DOLLY;break;case t.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===i.enablePan)return;Y(e),u=l.PAN}else{if(!1===i.enableRotate)return;k(e),u=l.ROTATE}break;case t.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===i.enableRotate)return;k(e),u=l.ROTATE}else{if(!1===i.enablePan)return;Y(e),u=l.PAN}break;default:u=l.NONE}u!==l.NONE&&i.dispatchEvent(s)}(e)}}function Z(e){!1!==i.enabled&&("touch"===e.pointerType?function(e){switch(J(e),u){case l.TOUCH_ROTATE:if(!1===i.enableRotate)return;V(e),i.update();break;case l.TOUCH_PAN:if(!1===i.enablePan)return;z(e),i.update();break;case l.TOUCH_DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(e){i.enableZoom&&F(e),i.enablePan&&z(e)}(e),i.update();break;case l.TOUCH_DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;!function(e){i.enableZoom&&F(e),i.enableRotate&&V(e)}(e),i.update();break;default:u=l.NONE}}(e):function(e){if(!1===i.enabled)return;switch(u){case l.ROTATE:if(!1===i.enableRotate)return;!function(e){g.set(e.clientX,e.clientY),O.subVectors(g,E).multiplyScalar(i.rotateSpeed);const t=i.domElement;t&&(N(2*Math.PI*O.x/t.clientHeight),C(2*Math.PI*O.y/t.clientHeight)),E.copy(g),i.update()}(e);break;case l.DOLLY:if(!1===i.enableZoom)return;!function(e){A.set(e.clientX,e.clientY),M.subVectors(A,y),M.y>0?D(L()):M.y<0&&x(L()),y.copy(A),i.update()}(e);break;case l.PAN:if(!1===i.enablePan)return;!function(e){P.set(e.clientX,e.clientY),T.subVectors(P,v).multiplyScalar(i.panSpeed),S(T.x,T.y),v.copy(P),i.update()}(e)}}(e))}function K(e){var t,n,o;(Q(e),0===j.length)&&(null===(t=i.domElement)||void 0===t||t.releasePointerCapture(e.pointerId),null===(n=i.domElement)||void 0===n||n.ownerDocument.removeEventListener("pointermove",Z),null===(o=i.domElement)||void 0===o||o.ownerDocument.removeEventListener("pointerup",K));i.dispatchEvent(c),u=l.NONE}function B(e){Q(e)}function G(e){!1===i.enabled||!1===i.enableZoom||u!==l.NONE&&u!==l.ROTATE||(e.preventDefault(),i.dispatchEvent(s),function(e){e.deltaY<0?x(L()):e.deltaY>0&&D(L()),i.update()}(e),i.dispatchEvent(c))}function q(e){!1!==i.enabled&&!1!==i.enablePan&&function(e){let t=!1;switch(e.code){case i.keys.UP:S(0,i.keyPanSpeed),t=!0;break;case i.keys.BOTTOM:S(0,-i.keyPanSpeed),t=!0;break;case i.keys.LEFT:S(i.keyPanSpeed,0),t=!0;break;case i.keys.RIGHT:S(-i.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),i.update())}(e)}function W(e){!1!==i.enabled&&e.preventDefault()}function Q(e){delete w[e.pointerId];for(let t=0;t<j.length;t++)if(j[t].pointerId==e.pointerId)return void j.splice(t,1)}function J(e){let n=w[e.pointerId];void 0===n&&(n=new t.Vector2,w[e.pointerId]=n),n.set(e.pageX,e.pageY)}function $(e){const t=e.pointerId===j[0].pointerId?j[1]:j[0];return w[t.pointerId]}void 0!==n&&this.connect(n),this.update()}}exports.MapControls=class extends i{constructor(e,n){super(e,n),this.screenSpacePanning=!1,this.mouseButtons.LEFT=t.MOUSE.PAN,this.mouseButtons.RIGHT=t.MOUSE.ROTATE,this.touches.ONE=t.TOUCH.PAN,this.touches.TWO=t.TOUCH.DOLLY_ROTATE}},exports.OrbitControls=i;
@@ -664,7 +664,7 @@ class OrbitControls extends EventDispatcher {
664
664
  function handleTouchMoveDollyRotate(event) {
665
665
  if (scope.enableZoom) handleTouchMoveDolly(event);
666
666
  if (scope.enableRotate) handleTouchMoveRotate(event);
667
- }
667
+ } //
668
668
  // event handlers - FSM: listen for events and reset state
669
669
  //
670
670
 
@@ -699,22 +699,18 @@ class OrbitControls extends EventDispatcher {
699
699
  }
700
700
 
701
701
  function onPointerUp(event) {
702
- if (scope.enabled === false) return;
703
-
704
- if (event.pointerType === 'touch') {
705
- onTouchEnd();
706
- } else {
707
- onMouseUp();
708
- }
709
-
710
702
  removePointer(event);
711
703
 
712
704
  if (pointers.length === 0) {
713
- var _scope$domElement9, _scope$domElement10;
705
+ var _scope$domElement9, _scope$domElement10, _scope$domElement11;
714
706
 
715
- (_scope$domElement9 = scope.domElement) === null || _scope$domElement9 === void 0 ? void 0 : _scope$domElement9.ownerDocument.removeEventListener('pointermove', onPointerMove);
716
- (_scope$domElement10 = scope.domElement) === null || _scope$domElement10 === void 0 ? void 0 : _scope$domElement10.ownerDocument.removeEventListener('pointerup', onPointerUp);
707
+ (_scope$domElement9 = scope.domElement) === null || _scope$domElement9 === void 0 ? void 0 : _scope$domElement9.releasePointerCapture(event.pointerId);
708
+ (_scope$domElement10 = scope.domElement) === null || _scope$domElement10 === void 0 ? void 0 : _scope$domElement10.ownerDocument.removeEventListener('pointermove', onPointerMove);
709
+ (_scope$domElement11 = scope.domElement) === null || _scope$domElement11 === void 0 ? void 0 : _scope$domElement11.ownerDocument.removeEventListener('pointerup', onPointerUp);
717
710
  }
711
+
712
+ scope.dispatchEvent(endEvent);
713
+ state = STATE.NONE;
718
714
  }
719
715
 
720
716
  function onPointerCancel(event) {
@@ -804,11 +800,6 @@ class OrbitControls extends EventDispatcher {
804
800
  }
805
801
  }
806
802
 
807
- function onMouseUp() {
808
- scope.dispatchEvent(endEvent);
809
- state = STATE.NONE;
810
- }
811
-
812
803
  function onMouseWheel(event) {
813
804
  if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE && state !== STATE.ROTATE) {
814
805
  return;
@@ -911,11 +902,6 @@ class OrbitControls extends EventDispatcher {
911
902
  }
912
903
  }
913
904
 
914
- function onTouchEnd() {
915
- scope.dispatchEvent(endEvent);
916
- state = STATE.NONE;
917
- }
918
-
919
905
  function onContextMenu(event) {
920
906
  if (scope.enabled === false) return;
921
907
  event.preventDefault();
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),e=require("three");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);class o extends e.EventDispatcher{constructor(t,s){super(),i.default(this,"enabled",!0),i.default(this,"screen",{left:0,top:0,width:0,height:0}),i.default(this,"rotateSpeed",1),i.default(this,"zoomSpeed",1.2),i.default(this,"panSpeed",.3),i.default(this,"noRotate",!1),i.default(this,"noZoom",!1),i.default(this,"noPan",!1),i.default(this,"staticMoving",!1),i.default(this,"dynamicDampingFactor",.2),i.default(this,"minDistance",0),i.default(this,"maxDistance",1/0),i.default(this,"keys",["KeyA","KeyS","KeyD"]),i.default(this,"mouseButtons",{LEFT:e.MOUSE.ROTATE,MIDDLE:e.MOUSE.DOLLY,RIGHT:e.MOUSE.PAN}),i.default(this,"object",void 0),i.default(this,"domElement",void 0),i.default(this,"target",new e.Vector3),i.default(this,"STATE",{NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4}),i.default(this,"EPS",1e-6),i.default(this,"lastPosition",new e.Vector3),i.default(this,"lastZoom",1),i.default(this,"_state",this.STATE.NONE),i.default(this,"_keyState",this.STATE.NONE),i.default(this,"_eye",new e.Vector3),i.default(this,"_movePrev",new e.Vector2),i.default(this,"_moveCurr",new e.Vector2),i.default(this,"_lastAxis",new e.Vector3),i.default(this,"_lastAngle",0),i.default(this,"_zoomStart",new e.Vector2),i.default(this,"_zoomEnd",new e.Vector2),i.default(this,"_touchZoomDistanceStart",0),i.default(this,"_touchZoomDistanceEnd",0),i.default(this,"_panStart",new e.Vector2),i.default(this,"_panEnd",new e.Vector2),i.default(this,"target0",void 0),i.default(this,"position0",void 0),i.default(this,"up0",void 0),i.default(this,"zoom0",void 0),i.default(this,"changeEvent",{type:"change"}),i.default(this,"startEvent",{type:"start"}),i.default(this,"endEvent",{type:"end"}),i.default(this,"onScreenVector",new e.Vector2),i.default(this,"getMouseOnScreen",((t,e)=>(this.onScreenVector.set((t-this.screen.left)/this.screen.width,(e-this.screen.top)/this.screen.height),this.onScreenVector))),i.default(this,"onCircleVector",new e.Vector2),i.default(this,"getMouseOnCircle",((t,e)=>(this.onCircleVector.set((t-.5*this.screen.width-this.screen.left)/(.5*this.screen.width),(this.screen.height+2*(this.screen.top-e))/this.screen.width),this.onCircleVector))),i.default(this,"axis",new e.Vector3),i.default(this,"quaternion",new e.Quaternion),i.default(this,"eyeDirection",new e.Vector3),i.default(this,"objectUpDirection",new e.Vector3),i.default(this,"objectSidewaysDirection",new e.Vector3),i.default(this,"moveDirection",new e.Vector3),i.default(this,"angle",0),i.default(this,"rotateCamera",(()=>{this.moveDirection.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0),this.angle=this.moveDirection.length(),this.angle?(this._eye.copy(this.object.position).sub(this.target),this.eyeDirection.copy(this._eye).normalize(),this.objectUpDirection.copy(this.object.up).normalize(),this.objectSidewaysDirection.crossVectors(this.objectUpDirection,this.eyeDirection).normalize(),this.objectUpDirection.setLength(this._moveCurr.y-this._movePrev.y),this.objectSidewaysDirection.setLength(this._moveCurr.x-this._movePrev.x),this.moveDirection.copy(this.objectUpDirection.add(this.objectSidewaysDirection)),this.axis.crossVectors(this.moveDirection,this._eye).normalize(),this.angle*=this.rotateSpeed,this.quaternion.setFromAxisAngle(this.axis,this.angle),this._eye.applyQuaternion(this.quaternion),this.object.up.applyQuaternion(this.quaternion),this._lastAxis.copy(this.axis),this._lastAngle=this.angle):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),this.quaternion.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(this.quaternion),this.object.up.applyQuaternion(this.quaternion)),this._movePrev.copy(this._moveCurr)})),i.default(this,"zoomCamera",(()=>{let t;this._state===this.STATE.TOUCH_ZOOM_PAN?(t=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(t):this.object.isOrthographicCamera?(this.object.zoom/=t,this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(t=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,1!==t&&t>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(t):this.object.isOrthographicCamera?(this.object.zoom/=t,this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)})),i.default(this,"mouseChange",new e.Vector2),i.default(this,"objectUp",new e.Vector3),i.default(this,"pan",new e.Vector3),i.default(this,"panCamera",(()=>{if(this.domElement&&(this.mouseChange.copy(this._panEnd).sub(this._panStart),this.mouseChange.lengthSq())){if(this.object.isOrthographicCamera){const t=this.object,e=(t.right-t.left)/this.object.zoom/this.domElement.clientWidth,s=(t.top-t.bottom)/this.object.zoom/this.domElement.clientWidth;this.mouseChange.x*=e,this.mouseChange.y*=s}this.mouseChange.multiplyScalar(this._eye.length()*this.panSpeed),this.pan.copy(this._eye).cross(this.object.up).setLength(this.mouseChange.x),this.pan.add(this.objectUp.copy(this.object.up).setLength(this.mouseChange.y)),this.object.position.add(this.pan),this.target.add(this.pan),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(this.mouseChange.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}})),i.default(this,"checkDistances",(()=>{this.noZoom&&this.noPan||(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))})),i.default(this,"handleResize",(()=>{if(!this.domElement)return;const t=this.domElement.getBoundingClientRect(),e=this.domElement.ownerDocument.documentElement;this.screen.left=t.left+window.pageXOffset-e.clientLeft,this.screen.top=t.top+window.pageYOffset-e.clientTop,this.screen.width=t.width,this.screen.height=t.height})),i.default(this,"update",(()=>{this._eye.subVectors(this.object.position,this.target),this.noRotate||this.rotateCamera(),this.noZoom||this.zoomCamera(),this.noPan||this.panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this.checkDistances(),this.object.lookAt(this.target),this.lastPosition.distanceToSquared(this.object.position)>this.EPS&&(this.dispatchEvent(this.changeEvent),this.lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this.lastPosition.distanceToSquared(this.object.position)>this.EPS||this.lastZoom!==this.object.zoom)&&(this.dispatchEvent(this.changeEvent),this.lastPosition.copy(this.object.position),this.lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type")})),i.default(this,"reset",(()=>{this._state=this.STATE.NONE,this._keyState=this.STATE.NONE,this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.up.copy(this.up0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(this.changeEvent),this.lastPosition.copy(this.object.position),this.lastZoom=this.object.zoom})),i.default(this,"keydown",(t=>{!1!==this.enabled&&(window.removeEventListener("keydown",this.keydown),this._keyState===this.STATE.NONE&&(t.code!==this.keys[this.STATE.ROTATE]||this.noRotate?t.code!==this.keys[this.STATE.ZOOM]||this.noZoom?t.code!==this.keys[this.STATE.PAN]||this.noPan||(this._keyState=this.STATE.PAN):this._keyState=this.STATE.ZOOM:this._keyState=this.STATE.ROTATE))})),i.default(this,"onPointerDown",(t=>{if(!1!==this.enabled)switch(t.pointerType){case"mouse":case"pen":this.onMouseDown(t)}})),i.default(this,"onPointerMove",(t=>{if(!1!==this.enabled)switch(t.pointerType){case"mouse":case"pen":this.onMouseMove(t)}})),i.default(this,"onPointerUp",(t=>{if(!1!==this.enabled)switch(t.pointerType){case"mouse":case"pen":this.onMouseUp()}})),i.default(this,"keyup",(()=>{!1!==this.enabled&&(this._keyState=this.STATE.NONE,window.addEventListener("keydown",this.keydown))})),i.default(this,"onMouseDown",(t=>{if(!this.domElement)return;if(this._state===this.STATE.NONE)switch(t.button){case this.mouseButtons.LEFT:this._state=this.STATE.ROTATE;break;case this.mouseButtons.MIDDLE:this._state=this.STATE.ZOOM;break;case this.mouseButtons.RIGHT:this._state=this.STATE.PAN;break;default:this._state=this.STATE.NONE}const e=this._keyState!==this.STATE.NONE?this._keyState:this._state;e!==this.STATE.ROTATE||this.noRotate?e!==this.STATE.ZOOM||this.noZoom?e!==this.STATE.PAN||this.noPan||(this._panStart.copy(this.getMouseOnScreen(t.pageX,t.pageY)),this._panEnd.copy(this._panStart)):(this._zoomStart.copy(this.getMouseOnScreen(t.pageX,t.pageY)),this._zoomEnd.copy(this._zoomStart)):(this._moveCurr.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._movePrev.copy(this._moveCurr)),this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.dispatchEvent(this.startEvent)})),i.default(this,"onMouseMove",(t=>{if(!1===this.enabled)return;const e=this._keyState!==this.STATE.NONE?this._keyState:this._state;e!==this.STATE.ROTATE||this.noRotate?e!==this.STATE.ZOOM||this.noZoom?e!==this.STATE.PAN||this.noPan||this._panEnd.copy(this.getMouseOnScreen(t.pageX,t.pageY)):this._zoomEnd.copy(this.getMouseOnScreen(t.pageX,t.pageY)):(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this.getMouseOnCircle(t.pageX,t.pageY)))})),i.default(this,"onMouseUp",(()=>{this.domElement&&!1!==this.enabled&&(this._state=this.STATE.NONE,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),this.dispatchEvent(this.endEvent))})),i.default(this,"mousewheel",(t=>{if(!1!==this.enabled&&!0!==this.noZoom){switch(t.preventDefault(),t.deltaMode){case 2:this._zoomStart.y-=.025*t.deltaY;break;case 1:this._zoomStart.y-=.01*t.deltaY;break;default:this._zoomStart.y-=25e-5*t.deltaY}this.dispatchEvent(this.startEvent),this.dispatchEvent(this.endEvent)}})),i.default(this,"touchstart",(t=>{if(!1!==this.enabled){switch(t.preventDefault(),t.touches.length){case 1:this._state=this.STATE.TOUCH_ROTATE,this._moveCurr.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this._state=this.STATE.TOUCH_ZOOM_PAN;const e=t.touches[0].pageX-t.touches[1].pageX,s=t.touches[0].pageY-t.touches[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(e*e+s*s);const i=(t.touches[0].pageX+t.touches[1].pageX)/2,o=(t.touches[0].pageY+t.touches[1].pageY)/2;this._panStart.copy(this.getMouseOnScreen(i,o)),this._panEnd.copy(this._panStart)}this.dispatchEvent(this.startEvent)}})),i.default(this,"touchmove",(t=>{if(!1!==this.enabled)switch(t.preventDefault(),t.touches.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY));break;default:const e=t.touches[0].pageX-t.touches[1].pageX,s=t.touches[0].pageY-t.touches[1].pageY;this._touchZoomDistanceEnd=Math.sqrt(e*e+s*s);const i=(t.touches[0].pageX+t.touches[1].pageX)/2,o=(t.touches[0].pageY+t.touches[1].pageY)/2;this._panEnd.copy(this.getMouseOnScreen(i,o))}})),i.default(this,"touchend",(t=>{if(!1!==this.enabled){switch(t.touches.length){case 0:this._state=this.STATE.NONE;break;case 1:this._state=this.STATE.TOUCH_ROTATE,this._moveCurr.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._movePrev.copy(this._moveCurr)}this.dispatchEvent(this.endEvent)}})),i.default(this,"contextmenu",(t=>{!1!==this.enabled&&t.preventDefault()})),i.default(this,"connect",(t=>{t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=t,this.domElement.addEventListener("contextmenu",this.contextmenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.mousewheel),this.domElement.addEventListener("touchstart",this.touchstart),this.domElement.addEventListener("touchend",this.touchend),this.domElement.addEventListener("touchmove",this.touchmove),this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),this.handleResize()})),i.default(this,"dispose",(()=>{this.domElement&&(this.domElement.removeEventListener("contextmenu",this.contextmenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.mousewheel),this.domElement.removeEventListener("touchstart",this.touchstart),this.domElement.removeEventListener("touchend",this.touchend),this.domElement.removeEventListener("touchmove",this.touchmove),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup))})),this.object=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.zoom0=this.object.zoom,void 0!==s&&this.connect(s),this.update()}}exports.TrackballControls=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),e=require("three");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);class o extends e.EventDispatcher{constructor(t,s){super(),i.default(this,"enabled",!0),i.default(this,"screen",{left:0,top:0,width:0,height:0}),i.default(this,"rotateSpeed",1),i.default(this,"zoomSpeed",1.2),i.default(this,"panSpeed",.3),i.default(this,"noRotate",!1),i.default(this,"noZoom",!1),i.default(this,"noPan",!1),i.default(this,"staticMoving",!1),i.default(this,"dynamicDampingFactor",.2),i.default(this,"minDistance",0),i.default(this,"maxDistance",1/0),i.default(this,"keys",["KeyA","KeyS","KeyD"]),i.default(this,"mouseButtons",{LEFT:e.MOUSE.ROTATE,MIDDLE:e.MOUSE.DOLLY,RIGHT:e.MOUSE.PAN}),i.default(this,"object",void 0),i.default(this,"domElement",void 0),i.default(this,"cursorZoom",!1),i.default(this,"target",new e.Vector3),i.default(this,"mousePosition",new e.Vector2),i.default(this,"STATE",{NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4}),i.default(this,"EPS",1e-6),i.default(this,"lastZoom",1),i.default(this,"lastPosition",new e.Vector3),i.default(this,"cursorVector",new e.Vector3),i.default(this,"targetVector",new e.Vector3),i.default(this,"_state",this.STATE.NONE),i.default(this,"_keyState",this.STATE.NONE),i.default(this,"_eye",new e.Vector3),i.default(this,"_movePrev",new e.Vector2),i.default(this,"_moveCurr",new e.Vector2),i.default(this,"_lastAxis",new e.Vector3),i.default(this,"_lastAngle",0),i.default(this,"_zoomStart",new e.Vector2),i.default(this,"_zoomEnd",new e.Vector2),i.default(this,"_touchZoomDistanceStart",0),i.default(this,"_touchZoomDistanceEnd",0),i.default(this,"_panStart",new e.Vector2),i.default(this,"_panEnd",new e.Vector2),i.default(this,"target0",void 0),i.default(this,"position0",void 0),i.default(this,"up0",void 0),i.default(this,"zoom0",void 0),i.default(this,"changeEvent",{type:"change"}),i.default(this,"startEvent",{type:"start"}),i.default(this,"endEvent",{type:"end"}),i.default(this,"onScreenVector",new e.Vector2),i.default(this,"getMouseOnScreen",((t,e)=>(this.onScreenVector.set((t-this.screen.left)/this.screen.width,(e-this.screen.top)/this.screen.height),this.onScreenVector))),i.default(this,"onCircleVector",new e.Vector2),i.default(this,"getMouseOnCircle",((t,e)=>(this.onCircleVector.set((t-.5*this.screen.width-this.screen.left)/(.5*this.screen.width),(this.screen.height+2*(this.screen.top-e))/this.screen.width),this.onCircleVector))),i.default(this,"axis",new e.Vector3),i.default(this,"quaternion",new e.Quaternion),i.default(this,"eyeDirection",new e.Vector3),i.default(this,"objectUpDirection",new e.Vector3),i.default(this,"objectSidewaysDirection",new e.Vector3),i.default(this,"moveDirection",new e.Vector3),i.default(this,"angle",0),i.default(this,"rotateCamera",(()=>{this.moveDirection.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0),this.angle=this.moveDirection.length(),this.angle?(this._eye.copy(this.object.position).sub(this.target),this.eyeDirection.copy(this._eye).normalize(),this.objectUpDirection.copy(this.object.up).normalize(),this.objectSidewaysDirection.crossVectors(this.objectUpDirection,this.eyeDirection).normalize(),this.objectUpDirection.setLength(this._moveCurr.y-this._movePrev.y),this.objectSidewaysDirection.setLength(this._moveCurr.x-this._movePrev.x),this.moveDirection.copy(this.objectUpDirection.add(this.objectSidewaysDirection)),this.axis.crossVectors(this.moveDirection,this._eye).normalize(),this.angle*=this.rotateSpeed,this.quaternion.setFromAxisAngle(this.axis,this.angle),this._eye.applyQuaternion(this.quaternion),this.object.up.applyQuaternion(this.quaternion),this._lastAxis.copy(this.axis),this._lastAngle=this.angle):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),this.quaternion.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(this.quaternion),this.object.up.applyQuaternion(this.quaternion)),this._movePrev.copy(this._moveCurr)})),i.default(this,"zoomCamera",(()=>{let t;if(this._state===this.STATE.TOUCH_ZOOM_PAN)t=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(t):this.object.isOrthographicCamera?(this.object.zoom/=t,this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type");else if(t=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,1!==t&&t>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(t):this.object.isOrthographicCamera?(this.object.zoom/=t,this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor,this.cursorZoom){this.targetVector.copy(this.target).project(this.object);let e=this.cursorVector.set(this.mousePosition.x,this.mousePosition.y,this.targetVector.z).unproject(this.object);this.target.lerpVectors(e,this.target,t)}})),i.default(this,"mouseChange",new e.Vector2),i.default(this,"objectUp",new e.Vector3),i.default(this,"pan",new e.Vector3),i.default(this,"panCamera",(()=>{if(this.domElement&&(this.mouseChange.copy(this._panEnd).sub(this._panStart),this.mouseChange.lengthSq())){if(this.object.isOrthographicCamera){const t=this.object,e=(t.right-t.left)/this.object.zoom/this.domElement.clientWidth,s=(t.top-t.bottom)/this.object.zoom/this.domElement.clientWidth;this.mouseChange.x*=e,this.mouseChange.y*=s}this.mouseChange.multiplyScalar(this._eye.length()*this.panSpeed),this.pan.copy(this._eye).cross(this.object.up).setLength(this.mouseChange.x),this.pan.add(this.objectUp.copy(this.object.up).setLength(this.mouseChange.y)),this.object.position.add(this.pan),this.target.add(this.pan),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(this.mouseChange.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}})),i.default(this,"checkDistances",(()=>{this.noZoom&&this.noPan||(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))})),i.default(this,"handleResize",(()=>{if(!this.domElement)return;const t=this.domElement.getBoundingClientRect(),e=this.domElement.ownerDocument.documentElement;this.screen.left=t.left+window.pageXOffset-e.clientLeft,this.screen.top=t.top+window.pageYOffset-e.clientTop,this.screen.width=t.width,this.screen.height=t.height})),i.default(this,"update",(()=>{this._eye.subVectors(this.object.position,this.target),this.noRotate||this.rotateCamera(),this.noZoom||this.zoomCamera(),this.noPan||this.panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this.checkDistances(),this.object.lookAt(this.target),this.lastPosition.distanceToSquared(this.object.position)>this.EPS&&(this.dispatchEvent(this.changeEvent),this.lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this.lastPosition.distanceToSquared(this.object.position)>this.EPS||this.lastZoom!==this.object.zoom)&&(this.dispatchEvent(this.changeEvent),this.lastPosition.copy(this.object.position),this.lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type")})),i.default(this,"reset",(()=>{this._state=this.STATE.NONE,this._keyState=this.STATE.NONE,this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.up.copy(this.up0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(this.changeEvent),this.lastPosition.copy(this.object.position),this.lastZoom=this.object.zoom})),i.default(this,"keydown",(t=>{!1!==this.enabled&&(window.removeEventListener("keydown",this.keydown),this._keyState===this.STATE.NONE&&(t.code!==this.keys[this.STATE.ROTATE]||this.noRotate?t.code!==this.keys[this.STATE.ZOOM]||this.noZoom?t.code!==this.keys[this.STATE.PAN]||this.noPan||(this._keyState=this.STATE.PAN):this._keyState=this.STATE.ZOOM:this._keyState=this.STATE.ROTATE))})),i.default(this,"onPointerDown",(t=>{if(!1!==this.enabled)switch(t.pointerType){case"mouse":case"pen":this.onMouseDown(t)}})),i.default(this,"onPointerMove",(t=>{if(!1!==this.enabled)switch(t.pointerType){case"mouse":case"pen":this.onMouseMove(t)}})),i.default(this,"onPointerUp",(t=>{if(!1!==this.enabled)switch(t.pointerType){case"mouse":case"pen":this.onMouseUp()}})),i.default(this,"keyup",(()=>{!1!==this.enabled&&(this._keyState=this.STATE.NONE,window.addEventListener("keydown",this.keydown))})),i.default(this,"onMouseDown",(t=>{if(!this.domElement)return;if(this._state===this.STATE.NONE)switch(t.button){case this.mouseButtons.LEFT:this._state=this.STATE.ROTATE;break;case this.mouseButtons.MIDDLE:this._state=this.STATE.ZOOM;break;case this.mouseButtons.RIGHT:this._state=this.STATE.PAN;break;default:this._state=this.STATE.NONE}const e=this._keyState!==this.STATE.NONE?this._keyState:this._state;e!==this.STATE.ROTATE||this.noRotate?e!==this.STATE.ZOOM||this.noZoom?e!==this.STATE.PAN||this.noPan||(this._panStart.copy(this.getMouseOnScreen(t.pageX,t.pageY)),this._panEnd.copy(this._panStart)):(this._zoomStart.copy(this.getMouseOnScreen(t.pageX,t.pageY)),this._zoomEnd.copy(this._zoomStart)):(this._moveCurr.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._movePrev.copy(this._moveCurr)),this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.dispatchEvent(this.startEvent)})),i.default(this,"onMouseMove",(t=>{if(!1===this.enabled)return;const e=this._keyState!==this.STATE.NONE?this._keyState:this._state;e!==this.STATE.ROTATE||this.noRotate?e!==this.STATE.ZOOM||this.noZoom?e!==this.STATE.PAN||this.noPan||this._panEnd.copy(this.getMouseOnScreen(t.pageX,t.pageY)):this._zoomEnd.copy(this.getMouseOnScreen(t.pageX,t.pageY)):(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this.getMouseOnCircle(t.pageX,t.pageY)))})),i.default(this,"onMouseUp",(()=>{this.domElement&&!1!==this.enabled&&(this._state=this.STATE.NONE,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),this.dispatchEvent(this.endEvent))})),i.default(this,"mousewheel",(t=>{if(!1!==this.enabled&&!0!==this.noZoom){switch(t.preventDefault(),t.deltaMode){case 2:this._zoomStart.y-=.025*t.deltaY;break;case 1:this._zoomStart.y-=.01*t.deltaY;break;default:this._zoomStart.y-=25e-5*t.deltaY}this.mousePosition.x=t.offsetX/this.screen.width*2-1,this.mousePosition.y=-t.offsetY/this.screen.height*2+1,this.dispatchEvent(this.startEvent),this.dispatchEvent(this.endEvent)}})),i.default(this,"touchstart",(t=>{if(!1!==this.enabled){switch(t.preventDefault(),t.touches.length){case 1:this._state=this.STATE.TOUCH_ROTATE,this._moveCurr.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this._state=this.STATE.TOUCH_ZOOM_PAN;const e=t.touches[0].pageX-t.touches[1].pageX,s=t.touches[0].pageY-t.touches[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(e*e+s*s);const i=(t.touches[0].pageX+t.touches[1].pageX)/2,o=(t.touches[0].pageY+t.touches[1].pageY)/2;this._panStart.copy(this.getMouseOnScreen(i,o)),this._panEnd.copy(this._panStart)}this.dispatchEvent(this.startEvent)}})),i.default(this,"touchmove",(t=>{if(!1!==this.enabled)switch(t.preventDefault(),t.touches.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY));break;default:const e=t.touches[0].pageX-t.touches[1].pageX,s=t.touches[0].pageY-t.touches[1].pageY;this._touchZoomDistanceEnd=Math.sqrt(e*e+s*s);const i=(t.touches[0].pageX+t.touches[1].pageX)/2,o=(t.touches[0].pageY+t.touches[1].pageY)/2;this._panEnd.copy(this.getMouseOnScreen(i,o))}})),i.default(this,"touchend",(t=>{if(!1!==this.enabled){switch(t.touches.length){case 0:this._state=this.STATE.NONE;break;case 1:this._state=this.STATE.TOUCH_ROTATE,this._moveCurr.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._movePrev.copy(this._moveCurr)}this.dispatchEvent(this.endEvent)}})),i.default(this,"contextmenu",(t=>{!1!==this.enabled&&t.preventDefault()})),i.default(this,"connect",(t=>{t===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=t,this.domElement.addEventListener("contextmenu",this.contextmenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.mousewheel),this.domElement.addEventListener("touchstart",this.touchstart),this.domElement.addEventListener("touchend",this.touchend),this.domElement.addEventListener("touchmove",this.touchmove),this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),this.handleResize()})),i.default(this,"dispose",(()=>{this.domElement&&(this.domElement.removeEventListener("contextmenu",this.contextmenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.mousewheel),this.domElement.removeEventListener("touchstart",this.touchstart),this.domElement.removeEventListener("touchend",this.touchend),this.domElement.removeEventListener("touchmove",this.touchmove),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup))})),this.object=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone(),this.zoom0=this.object.zoom,void 0!==s&&this.connect(s),this.update()}}exports.TrackballControls=o;
@@ -25,11 +25,15 @@ declare class TrackballControls extends EventDispatcher {
25
25
  };
26
26
  object: PerspectiveCamera | OrthographicCamera;
27
27
  domElement: HTMLElement | undefined;
28
+ cursorZoom: boolean;
28
29
  private target;
30
+ private mousePosition;
29
31
  private STATE;
30
32
  private EPS;
31
- private lastPosition;
32
33
  private lastZoom;
34
+ private lastPosition;
35
+ private cursorVector;
36
+ private targetVector;
33
37
  private _state;
34
38
  private _keyState;
35
39
  private _eye;