three-stdlib 2.6.1 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/{Nodes-acab3ca5.js → Nodes-427f68b0.js} +0 -0
- package/{Nodes-244507d0.js → Nodes-ec4e1143.js} +0 -0
- package/controls/ArcballControls.cjs.js +1 -1
- package/controls/ArcballControls.d.ts +164 -0
- package/controls/ArcballControls.js +512 -197
- package/controls/OrbitControls.cjs.js +1 -1
- package/controls/OrbitControls.d.ts +1 -0
- package/controls/OrbitControls.js +13 -2
- package/geometries/TextGeometry.cjs.js +1 -0
- package/geometries/TextGeometry.d.ts +16 -0
- package/geometries/TextGeometry.js +26 -0
- package/index.cjs.js +1 -1
- package/index.d.ts +2 -0
- package/index.js +3 -1
- package/loaders/AMFLoader.js +1 -3
- package/loaders/ColladaLoader.cjs.js +1 -1
- package/loaders/ColladaLoader.js +58 -35
- package/loaders/EXRLoader.cjs.js +1 -1
- package/loaders/EXRLoader.js +197 -262
- package/loaders/FBXLoader.cjs.js +1 -1
- package/loaders/FBXLoader.js +41 -90
- package/loaders/FontLoader.cjs.js +1 -0
- package/loaders/FontLoader.d.ts +32 -0
- package/loaders/FontLoader.js +139 -0
- package/loaders/GLTFLoader.cjs.js +1 -1
- package/loaders/GLTFLoader.js +160 -72
- package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
- package/loaders/HDRCubeTextureLoader.js +2 -10
- package/loaders/NodeMaterialLoader.cjs.js +1 -1
- package/loaders/RGBELoader.cjs.js +1 -1
- package/loaders/RGBELoader.js +11 -25
- package/loaders/RGBMLoader.cjs.js +1 -1
- package/loaders/RGBMLoader.js +225 -263
- package/loaders/SVGLoader.cjs.js +1 -1
- package/loaders/SVGLoader.js +46 -30
- package/loaders/VRMLLoader.cjs.js +1 -1
- package/loaders/VRMLLoader.js +2 -1
- package/misc/WebGL.cjs.js +1 -1
- package/misc/WebGL.d.ts +5 -7
- package/misc/WebGL.js +67 -54
- package/nodes/core/NodeBuilder.cjs.js +1 -1
- package/nodes/core/NodeBuilder.js +2 -2
- package/nodes/inputs/CubeTextureNode.cjs.js +1 -1
- package/nodes/inputs/RTTNode.cjs.js +1 -1
- package/nodes/inputs/ReflectorNode.cjs.js +1 -1
- package/nodes/inputs/ScreenNode.cjs.js +1 -1
- package/nodes/inputs/TextureNode.cjs.js +1 -1
- package/nodes/materials/BasicNodeMaterial.cjs.js +1 -1
- package/nodes/materials/NodeMaterial.cjs.js +1 -1
- package/nodes/materials/SpriteNodeMaterial.cjs.js +1 -1
- package/nodes/postprocessing/NodePass.cjs.js +1 -1
- package/nodes/postprocessing/NodePostProcessing.cjs.js +1 -1
- package/nodes/utils/ColorSpaceNode.cjs.js +1 -1
- package/nodes/utils/ColorSpaceNode.js +2 -45
- package/package.json +1 -1
- package/shaders/GammaCorrectionShader.js +1 -2
File without changes
|
File without changes
|
@@ -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 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
|
+
"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()},r={x:0,y:0},h={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,"camera",void 0),e.default(this,"domElement",void 0),e.default(this,"scene",void 0),e.default(this,"mouseActions",void 0),e.default(this,"_mouseOp",void 0),e.default(this,"_v2_1",void 0),e.default(this,"_v3_1",void 0),e.default(this,"_v3_2",void 0),e.default(this,"_m4_1",void 0),e.default(this,"_m4_2",void 0),e.default(this,"_quat",void 0),e.default(this,"_translationMatrix",void 0),e.default(this,"_rotationMatrix",void 0),e.default(this,"_scaleMatrix",void 0),e.default(this,"_rotationAxis",void 0),e.default(this,"_cameraMatrixState",void 0),e.default(this,"_cameraProjectionState",void 0),e.default(this,"_fovState",void 0),e.default(this,"_upState",void 0),e.default(this,"_zoomState",void 0),e.default(this,"_nearPos",void 0),e.default(this,"_farPos",void 0),e.default(this,"_gizmoMatrixState",void 0),e.default(this,"_up0",void 0),e.default(this,"_zoom0",void 0),e.default(this,"_fov0",void 0),e.default(this,"_initialNear",void 0),e.default(this,"_nearPos0",void 0),e.default(this,"_initialFar",void 0),e.default(this,"_farPos0",void 0),e.default(this,"_cameraMatrixState0",void 0),e.default(this,"_gizmoMatrixState0",void 0),e.default(this,"_button",void 0),e.default(this,"_touchStart",void 0),e.default(this,"_touchCurrent",void 0),e.default(this,"_input",void 0),e.default(this,"_switchSensibility",void 0),e.default(this,"_startFingerDistance",void 0),e.default(this,"_currentFingerDistance",void 0),e.default(this,"_startFingerRotation",void 0),e.default(this,"_currentFingerRotation",void 0),e.default(this,"_devPxRatio",void 0),e.default(this,"_downValid",void 0),e.default(this,"_nclicks",void 0),e.default(this,"_downEvents",void 0),e.default(this,"_downStart",void 0),e.default(this,"_clickStart",void 0),e.default(this,"_maxDownTime",void 0),e.default(this,"_maxInterval",void 0),e.default(this,"_posThreshold",void 0),e.default(this,"_movementThreshold",void 0),e.default(this,"_currentCursorPosition",void 0),e.default(this,"_startCursorPosition",void 0),e.default(this,"_grid",void 0),e.default(this,"_gridPosition",void 0),e.default(this,"_gizmos",void 0),e.default(this,"_curvePts",void 0),e.default(this,"_timeStart",void 0),e.default(this,"_animationId",void 0),e.default(this,"focusAnimationTime",void 0),e.default(this,"_timePrev",void 0),e.default(this,"_timeCurrent",void 0),e.default(this,"_anglePrev",void 0),e.default(this,"_angleCurrent",void 0),e.default(this,"_cursorPosPrev",void 0),e.default(this,"_cursorPosCurr",void 0),e.default(this,"_wPrev",void 0),e.default(this,"_wCurr",void 0),e.default(this,"adjustNearFar",void 0),e.default(this,"scaleFactor",void 0),e.default(this,"dampingFactor",void 0),e.default(this,"wMax",void 0),e.default(this,"enableAnimations",void 0),e.default(this,"enableGrid",void 0),e.default(this,"cursorZoom",void 0),e.default(this,"minFov",void 0),e.default(this,"maxFov",void 0),e.default(this,"enabled",void 0),e.default(this,"enablePan",void 0),e.default(this,"enableRotate",void 0),e.default(this,"enableZoom",void 0),e.default(this,"enableGizmos",void 0),e.default(this,"minDistance",void 0),e.default(this,"maxDistance",void 0),e.default(this,"minZoom",void 0),e.default(this,"maxZoom",void 0),e.default(this,"target",void 0),e.default(this,"_currentTarget",void 0),e.default(this,"_tbRadius",void 0),e.default(this,"_state",void 0),e.default(this,"onWindowResize",(()=>{const t=(this._gizmos.scale.x+this._gizmos.scale.y+this._gizmos.scale.z)/3;if(null!==this.camera){const t=this.calculateTbRadius(this.camera);void 0!==t&&(this._tbRadius=t)}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){const s=this._gizmos.children[t];s instanceof i.Mesh&&(s.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()}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()}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(),this.onPinchEnd(),this.onRotateEnd(),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 o=null;t.ctrlKey||t.metaKey?o="CTRL":t.shiftKey&&(o="SHIFT");const r=this.getOpFromAction("WHEEL",o);if(null!=r){t.preventDefault(),this.dispatchEvent(c);const o=125;let h=t.deltaY/o,l=1;switch(h>0?l=1/this.scaleFactor:h<0&&(l=this.scaleFactor),r){case"ZOOM":if(this.updateTbState(a.SCALE,!0),h>0?l=1/Math.pow(this.scaleFactor,h):h<0&&(l=Math.pow(this.scaleFactor,-h)),this.cursorZoom&&this.enablePan){let a;var s;if(this.camera instanceof i.OrthographicCamera&&this.camera.isOrthographicCamera)a=null===(s=this.unprojectOnTbPlane(this.camera,t.clientX,t.clientY,this.domElement))||void 0===s?void 0:s.applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._gizmos.position);else if(this.camera instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera){var e;a=null===(e=this.unprojectOnTbPlane(this.camera,t.clientX,t.clientY,this.domElement))||void 0===e?void 0:e.applyQuaternion(this.camera.quaternion).add(this._gizmos.position)}void 0!==a&&this.applyTransformMatrix(this.applyScale(l,a))}else this.applyTransformMatrix(this.applyScale(l,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 instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera){this.updateTbState(a.FOV,!0),0!=t.deltaX&&(h=t.deltaX/o,l=1,h>0?l=1/Math.pow(this.scaleFactor,h):h<0&&(l=Math.pow(this.scaleFactor,-h))),this._v3_1.setFromMatrixPosition(this._cameraMatrixState);const s=this._v3_1.distanceTo(this._gizmos.position);let e=s/l;e=i.MathUtils.clamp(e,this.minDistance,this.maxDistance);const r=s*Math.tan(i.MathUtils.DEG2RAD*this.camera.fov*.5);let n=i.MathUtils.RAD2DEG*(2*Math.atan(r/e));n>this.maxFov?n=this.maxFov:n<this.minFov&&(n=this.minFov);l=s/(r/Math.tan(i.MathUtils.DEG2RAD*(n/2))),this.setFov(n),this.applyTransformMatrix(this.applyScale(l,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,s)=>{if(this.enabled)switch(this.dispatchEvent(c),this.setCenter(t.clientX,t.clientY),s){case"PAN":if(!this.enablePan)return;if(-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1,this.activateGizmos(!1),this.dispatchEvent(n)),null!==this.camera){this.updateTbState(a.PAN,!0);const t=this.unprojectOnTbPlane(this.camera,r.x,r.y,this.domElement);void 0!==t&&this._startCursorPosition.copy(t),this.enableGrid&&(this.drawGrid(),this.dispatchEvent(n))}break;case"ROTATE":if(!this.enableRotate)return;if(-1!=this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=-1,this._timeStart=-1),null!==this.camera){this.updateTbState(a.ROTATE,!0);const t=this.unprojectOnTbSurface(this.camera,r.x,r.y,this.domElement,this._tbRadius);void 0!==t&&this._startCursorPosition.copy(t),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 instanceof i.PerspectiveCamera&&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(r.x,r.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(r.x,r.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:if(this.enablePan&&null!==this.camera)if(e){this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0);const t=this.unprojectOnTbPlane(this.camera,r.x,r.y,this.domElement);void 0!==t&&this._startCursorPosition.copy(t),this.enableGrid&&this.drawGrid(),this.activateGizmos(!1)}else{const t=this.unprojectOnTbPlane(this.camera,r.x,r.y,this.domElement);void 0!==t&&this._currentCursorPosition.copy(t),this.applyTransformMatrix(this.pan(this._startCursorPosition,this._currentCursorPosition))}break;case a.ROTATE:if(this.enableRotate&&null!==this.camera)if(e){this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0);const t=this.unprojectOnTbSurface(this.camera,r.x,r.y,this.domElement,this._tbRadius);void 0!==t&&this._startCursorPosition.copy(t),this.enableGrid&&this.disposeGrid(),this.activateGizmos(!0)}else{const t=this.unprojectOnTbSurface(this.camera,r.x,r.y,this.domElement,this._tbRadius);void 0!==t&&this._currentCursorPosition.copy(t);const i=this._startCursorPosition.distanceTo(this._currentCursorPosition),s=this._startCursorPosition.angleTo(this._currentCursorPosition),e=Math.max(i/this._tbRadius,s);this.applyTransformMatrix(this.rotate(this.calculateRotationAxis(this._startCursorPosition,this._currentCursorPosition),e)),this.enableAnimations&&(this._timePrev=this._timeCurrent,this._timeCurrent=performance.now(),this._anglePrev=this._angleCurrent,this._angleCurrent=e,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(r.x,r.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(r.x,r.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 instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera)if(e)this.dispatchEvent(m),this.dispatchEvent(c),this.updateTbState(s,!0),this._startCursorPosition.setY(.5*this.getCursorNDC(r.x,r.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(r.x,r.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 h=a*Math.tan(i.MathUtils.DEG2RAD*this._fovState*.5);let n=i.MathUtils.RAD2DEG*(2*Math.atan(h/o));n=i.MathUtils.clamp(n,this.minFov,this.maxFov);const c=h/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&&null!==this.camera){this.dispatchEvent(c),this.setCenter(t.clientX,t.clientY);const i=this.unprojectOnObj(this.getCursorNDC(r.x,r.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",(()=>{if(this.enabled&&this.enablePan&&null!==this.camera){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);const t=this.unprojectOnTbPlane(this.camera,r.x,r.y,this.domElement,!0);void 0!==t&&this._startCursorPosition.copy(t),this._currentCursorPosition.copy(this._startCursorPosition),this.activateGizmos(!1)}})),e.default(this,"onDoublePanMove",(()=>{if(this.enabled&&this.enablePan&&null!==this.camera){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));const t=this.unprojectOnTbPlane(this.camera,r.x,r.y,this.domElement,!0);void 0!==t&&this._currentCursorPosition.copy(t),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",(()=>{var t;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,null===(t=this.camera)||void 0===t||t.getWorldDirection(this._rotationAxis),this.enablePan||this.enableZoom||this.activateGizmos(!0))})),e.default(this,"onRotateMove",(()=>{if(this.enabled&&this.enableRotate&&null!==this.camera){let s;if(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){if(this.camera instanceof i.PerspectiveCamera||this.camera instanceof i.OrthographicCamera){var t;this._v3_2.setFromMatrixPosition(this._gizmoMatrixState),s=null===(t=this.unprojectOnTbPlane(this.camera,r.x,r.y,this.domElement))||void 0===t?void 0:t.applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._v3_2)}}else s=(new i.Vector3).setFromMatrixPosition(this._gizmoMatrixState);const e=i.MathUtils.DEG2RAD*(this._startFingerRotation-this._currentFingerRotation);void 0!==s&&this.applyTransformMatrix(this.zRotate(s,e)),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 e=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]),e*this._devPxRatio);const o=this._currentFingerDistance/this._startFingerDistance;let h;var t;if(this.enablePan){if(this.camera instanceof i.OrthographicCamera&&this.camera.isOrthographicCamera)h=null===(t=this.unprojectOnTbPlane(this.camera,r.x,r.y,this.domElement))||void 0===t?void 0:t.applyQuaternion(this.camera.quaternion).multiplyScalar(1/this.camera.zoom).add(this._gizmos.position);else if(this.camera instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera){var s;h=null===(s=this.unprojectOnTbPlane(this.camera,r.x,r.y,this.domElement))||void 0===s?void 0:s.applyQuaternion(this.camera.quaternion).add(this._gizmos.position)}}else h=this._gizmos.position;void 0!==h&&this.applyTransformMatrix(this.applyScale(o,h)),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(r.x,r.y,this.domElement).y),this._currentCursorPosition.copy(this._startCursorPosition)}})),e.default(this,"onTriplePanMove",(()=>{if(this.enabled&&this.enableZoom&&null!==this.camera){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(r.x,r.y,this.domElement).y);const o=this._currentCursorPosition.y-this._startCursorPosition.y;let h=1;o<0?h=1/Math.pow(this.scaleFactor,-o*a):o>0&&(h=Math.pow(this.scaleFactor,o*a)),this._v3_1.setFromMatrixPosition(this._cameraMatrixState);const c=this._v3_1.distanceTo(this._gizmos.position);let m=c/h;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));h=c/u,this._v3_2.setFromMatrixPosition(this._gizmoMatrixState),this.setFov(_),this.applyTransformMatrix(this.applyScale(h,this._v3_2,!1));const d=this._gizmos.position.clone().sub(this.camera.position).normalize().multiplyScalar(u/c);this._m4_1.makeTranslation(d.x,d.y,d.z),this.dispatchEvent(n)}})),e.default(this,"onTriplePanEnd",(()=>{this.updateTbState(a.IDLE,!1),this.dispatchEvent(m)})),e.default(this,"setCenter",((t,i)=>{r.x=t,r.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&&t instanceof i.PerspectiveCamera){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&&t instanceof i.OrthographicCamera)return.67*Math.min(t.top,t.right)})),e.default(this,"focus",((t,i,s=1)=>{if(null!==this.camera){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,r;if(this.camera instanceof i.OrthographicCamera&&this.camera.isOrthographicCamera){const t=this.camera.right-this.camera.left,i=this.camera.bottom-this.camera.top;o=Math.max(t,i),r=o/20,e=o/this.camera.zoom*s,a=e/r*this.camera.zoom}else if(this.camera instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera){const t=this.camera.position.distanceTo(this._gizmos.position),h=i.MathUtils.DEG2RAD*this.camera.fov*.5,n=Math.atan(this.camera.aspect*Math.tan(h));o=Math.tan(Math.max(h,n))*t*2,r=o/20,e=o*s,a=e/r}null==this._grid&&null!==this.camera&&(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,"dispose",(()=>{var t;-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.addEventListener("keydown",this.onKeyDown),null===(t=this.scene)||void 0===t||t.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,s,e)=>(this._v2_1.copy(this.getCursorNDC(t,s,e)),this.camera instanceof i.OrthographicCamera&&(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=>{if(t instanceof i.PerspectiveCamera||t instanceof i.OrthographicCamera){t.lookAt(this.target),t.updateMatrix(),"PerspectiveCamera"==(null==t?void 0:t.type)&&t instanceof i.PerspectiveCamera&&(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 instanceof i.PerspectiveCamera||this.camera instanceof i.OrthographicCamera)&&this.camera.updateProjectionMatrix();const s=this.calculateTbRadius(t);void 0!==s&&(this._tbRadius=s),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}),r=new i.LineBasicMaterial({color:8454016,fog:!1,transparent:!0,opacity:.6}),h=new i.LineBasicMaterial({color:8421631,fog:!1,transparent:!0,opacity:.6}),n=new i.Line(a,o),c=new i.Line(a,r),m=new i.Line(a,h),l=.5*Math.PI;if(n.rotation.x=l,c.rotation.y=l,this._gizmoMatrixState0.identity().setPosition(t),this._gizmoMatrixState.copy(this._gizmoMatrixState0),(this.camera instanceof i.PerspectiveCamera||this.camera instanceof i.OrthographicCamera)&&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 r=this;this._animationId=window.requestAnimationFrame((function(t){r.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,s,e=!1)=>{if(null!==this.camera){const a=t.clone().sub(s);if(this.camera instanceof i.OrthographicCamera&&this.camera.isOrthographicCamera)a.multiplyScalar(1/this.camera.zoom);else if(this.camera instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera&&e){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);a.multiplyScalar(1/t)}this._v3_1.set(a.x,a.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)}return h})),e.default(this,"reset",(()=>{if(this.camera instanceof i.PerspectiveCamera||this.camera instanceof i.OrthographicCamera){this.camera.zoom=this._zoom0,this.camera instanceof i.PerspectiveCamera&&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();const t=this.calculateTbRadius(this.camera);void 0!==t&&(this._tbRadius=t),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),h})),e.default(this,"copyState",(()=>{let t;this.camera instanceof i.OrthographicCamera&&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 instanceof i.PerspectiveCamera&&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}})),void 0!==t&&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.camera instanceof i.PerspectiveCamera||this.camera instanceof i.OrthographicCamera)&&(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 instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera&&(this._fov0=this.camera.fov))})),e.default(this,"applyScale",((t,s,e=!0)=>{const a=s.clone();let o=1/t;if(this.camera instanceof i.OrthographicCamera&&this.camera.isOrthographicCamera){this.camera.zoom=this._zoomState,this.camera.zoom*=t,this.camera.zoom>this.maxZoom?(this.camera.zoom=this.maxZoom,o=this._zoomState/this.maxZoom):this.camera.zoom<this.minZoom&&(this.camera.zoom=this.minZoom,o=this._zoomState/this.minZoom),this.camera.updateProjectionMatrix(),this._v3_1.setFromMatrixPosition(this._gizmoMatrixState),this._scaleMatrix.makeScale(o,o,o),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),a.sub(this._v3_1);const i=a.clone().multiplyScalar(o);return a.sub(i),this._m4_1.makeTranslation(a.x,a.y,a.z),this._m4_2.premultiply(this._m4_1),this.setTransformationMatrices(this._m4_1,this._m4_2),h}if(this.camera instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera){this._v3_1.setFromMatrixPosition(this._cameraMatrixState),this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);let t=this._v3_1.distanceTo(a),i=t-t*o;const s=t-i;s<this.minDistance?(o=this.minDistance/t,i=t-t*o):s>this.maxDistance&&(o=this.maxDistance/t,i=t-t*o);let r=a.clone().sub(this._v3_1).normalize().multiplyScalar(i);if(this._m4_1.makeTranslation(r.x,r.y,r.z),e){const s=this._v3_2;t=s.distanceTo(a),i=t-t*o,r=a.clone().sub(this._v3_2).normalize().multiplyScalar(i),this._translationMatrix.makeTranslation(s.x,s.y,s.z),this._scaleMatrix.makeScale(o,o,o),this._m4_2.makeTranslation(r.x,r.y,r.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 h}})),e.default(this,"setFov",(t=>{this.camera instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera&&(this.camera.fov=i.MathUtils.clamp(t,this.minFov,this.maxFov),this.camera.updateProjectionMatrix())})),e.default(this,"setTarget",((t,i,s)=>{if(null!==this.camera){this.target.set(t,i,s),this._gizmos.position.set(t,i,s);const e=this.calculateTbRadius(this.camera);void 0!==e&&(this._tbRadius=e),this.makeGizmos(this.target,this._tbRadius),this.camera.lookAt(this.target)}})),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),h))),e.default(this,"unprojectOnObj",((t,s)=>{if((s instanceof i.PerspectiveCamera||s instanceof i.OrthographicCamera)&&null!=this.scene){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 r=this._v3_1.clone().normalize(),h=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 r.set(this._v3_1.x,this._v3_1.y,o),r;const l=c/m,_=h;let u=Math.pow(l,2)+1,d=2*l*_,p=Math.pow(_,2)-n,v=Math.pow(d,2)-4*u*p;if(v>=0){this._v2_1.setX((-d-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(h-this._v2_1.y,2));return r.multiplyScalar(t),r.z+=h,r}}u=l,d=_,p=.5*-n,v=Math.pow(d,2)-4*u*p,this._v2_1.setX((-d-Math.sqrt(v))/(2*u)),this._v2_1.setY(l*this._v2_1.x+_);const f=Math.sqrt(Math.pow(this._v2_1.x,2)+Math.pow(h-this._v2_1.y,2));return r.multiplyScalar(f),r.z+=h,r}})),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(),r=this._v3_1.z,h=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==h)return o.set(0,0,0),o;const c=n,m=-c/(r/h),l=Math.sqrt(Math.pow(c,2)+Math.pow(m,2));return o.multiplyScalar(l),o.z=0,o}})),e.default(this,"updateMatrixState",(()=>{null!==this.camera&&(this._cameraMatrixState.copy(this.camera.matrix),this._gizmoMatrixState.copy(this._gizmos.matrix),this.camera instanceof i.OrthographicCamera&&this.camera.isOrthographicCamera?(this._cameraProjectionState.copy(this.camera.projectionMatrix),this.camera.updateProjectionMatrix(),this._zoomState=this.camera.zoom):this.camera instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera&&(this._fovState=this.camera.fov))})),e.default(this,"updateTbState",((t,i)=>{this._state=t,i&&this.updateMatrixState()})),e.default(this,"update",(()=>{var t;const s=1e-6;if(!this.target.equals(this._currentTarget)&&null!==this.camera){this._gizmos.position.set(this.target.x,this.target.y,this.target.z);const t=this.calculateTbRadius(this.camera);void 0!==t&&(this._tbRadius=t),this.makeGizmos(this.target,this._tbRadius),this._currentTarget.copy(this.target)}if(this.camera instanceof i.OrthographicCamera&&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 instanceof i.PerspectiveCamera&&this.camera.isPerspectiveCamera){const t=this.camera.position.distanceTo(this._gizmos.position);if(t>this.maxDistance+s||t<this.minDistance-s){const s=i.MathUtils.clamp(t,this.minDistance,this.maxDistance);this.applyTransformMatrix(this.applyScale(s/t,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,a=this.calculateTbRadius(this.camera);if(void 0!==a&&(this._tbRadius=a),e<this._tbRadius-s||e>this._tbRadius+s){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){const s=this._gizmos.children[t];s instanceof i.Mesh&&(s.geometry=a)}}}null===(t=this.camera)||void 0===t||t.lookAt(this._gizmos.position)})),e.default(this,"setStateFromJSON",(t=>{const s=JSON.parse(t);if(null!=s.arcballState&&(this.camera instanceof i.PerspectiveCamera||this.camera instanceof i.OrthographicCamera)){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 instanceof i.PerspectiveCamera&&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();const t=this.calculateTbRadius(this.camera);void 0!==t&&(this._tbRadius=t);const e=(new i.Matrix4).copy(this._gizmoMatrixState0);this.makeGizmos(this._gizmos.position,this._tbRadius),this._gizmoMatrixState0.copy(e),this.camera.lookAt(this._gizmos.position),this.updateTbState(a.IDLE,!1),this.dispatchEvent(n)}})),this.camera=null,this.domElement=s,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),this.domElement.style.touchAction="none",this._devPxRatio=window.devicePixelRatio,this.initializeMouseActions(),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)}applyTransformMatrix(t){if(null!=(null==t?void 0:t.camera)&&null!==this.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!=(null==t?void 0: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)&&(this.camera instanceof i.PerspectiveCamera||this.camera instanceof i.OrthographicCamera)){const t=this.calculateTbRadius(this.camera);if(void 0!==t&&(this._tbRadius=t),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,r=Math.min(a,o);this.camera.near=t-r;const h=Math.min(this._farPos0,-e.radius+e.center.length()),n=t-this._initialFar,c=Math.min(h,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!=h.camera?h.camera.copy(t):h.camera=t.clone():h.camera=null,null!=i?null!=h.gizmos?h.gizmos.copy(i):h.gizmos=i.clone():h.gizmos=null}}exports.ArcballControls=l;
|
@@ -0,0 +1,164 @@
|
|
1
|
+
import { Camera, Scene, EventDispatcher } from 'three';
|
2
|
+
declare class ArcballControls extends EventDispatcher {
|
3
|
+
private camera;
|
4
|
+
private domElement;
|
5
|
+
private scene;
|
6
|
+
private mouseActions;
|
7
|
+
private _mouseOp;
|
8
|
+
private _v2_1;
|
9
|
+
private _v3_1;
|
10
|
+
private _v3_2;
|
11
|
+
private _m4_1;
|
12
|
+
private _m4_2;
|
13
|
+
private _quat;
|
14
|
+
private _translationMatrix;
|
15
|
+
private _rotationMatrix;
|
16
|
+
private _scaleMatrix;
|
17
|
+
private _rotationAxis;
|
18
|
+
private _cameraMatrixState;
|
19
|
+
private _cameraProjectionState;
|
20
|
+
private _fovState;
|
21
|
+
private _upState;
|
22
|
+
private _zoomState;
|
23
|
+
private _nearPos;
|
24
|
+
private _farPos;
|
25
|
+
private _gizmoMatrixState;
|
26
|
+
private _up0;
|
27
|
+
private _zoom0;
|
28
|
+
private _fov0;
|
29
|
+
private _initialNear;
|
30
|
+
private _nearPos0;
|
31
|
+
private _initialFar;
|
32
|
+
private _farPos0;
|
33
|
+
private _cameraMatrixState0;
|
34
|
+
private _gizmoMatrixState0;
|
35
|
+
private _button;
|
36
|
+
private _touchStart;
|
37
|
+
private _touchCurrent;
|
38
|
+
private _input;
|
39
|
+
private _switchSensibility;
|
40
|
+
private _startFingerDistance;
|
41
|
+
private _currentFingerDistance;
|
42
|
+
private _startFingerRotation;
|
43
|
+
private _currentFingerRotation;
|
44
|
+
private _devPxRatio;
|
45
|
+
private _downValid;
|
46
|
+
private _nclicks;
|
47
|
+
private _downEvents;
|
48
|
+
private _downStart;
|
49
|
+
private _clickStart;
|
50
|
+
private _maxDownTime;
|
51
|
+
private _maxInterval;
|
52
|
+
private _posThreshold;
|
53
|
+
private _movementThreshold;
|
54
|
+
private _currentCursorPosition;
|
55
|
+
private _startCursorPosition;
|
56
|
+
private _grid;
|
57
|
+
private _gridPosition;
|
58
|
+
private _gizmos;
|
59
|
+
private _curvePts;
|
60
|
+
private _timeStart;
|
61
|
+
private _animationId;
|
62
|
+
focusAnimationTime: number;
|
63
|
+
private _timePrev;
|
64
|
+
private _timeCurrent;
|
65
|
+
private _anglePrev;
|
66
|
+
private _angleCurrent;
|
67
|
+
private _cursorPosPrev;
|
68
|
+
private _cursorPosCurr;
|
69
|
+
private _wPrev;
|
70
|
+
private _wCurr;
|
71
|
+
adjustNearFar: boolean;
|
72
|
+
scaleFactor: number;
|
73
|
+
dampingFactor: number;
|
74
|
+
wMax: number;
|
75
|
+
enableAnimations: boolean;
|
76
|
+
enableGrid: boolean;
|
77
|
+
cursorZoom: boolean;
|
78
|
+
minFov: number;
|
79
|
+
maxFov: number;
|
80
|
+
enabled: boolean;
|
81
|
+
enablePan: boolean;
|
82
|
+
enableRotate: boolean;
|
83
|
+
enableZoom: boolean;
|
84
|
+
enableGizmos: boolean;
|
85
|
+
minDistance: number;
|
86
|
+
maxDistance: number;
|
87
|
+
minZoom: number;
|
88
|
+
maxZoom: number;
|
89
|
+
private target;
|
90
|
+
private _currentTarget;
|
91
|
+
private _tbRadius;
|
92
|
+
private _state;
|
93
|
+
constructor(camera: Camera | null, domElement: HTMLElement, scene?: Scene | null | undefined);
|
94
|
+
private onWindowResize;
|
95
|
+
private onContextMenu;
|
96
|
+
private onPointerCancel;
|
97
|
+
private onPointerDown;
|
98
|
+
private onPointerMove;
|
99
|
+
private onPointerUp;
|
100
|
+
private onWheel;
|
101
|
+
private onKeyDown;
|
102
|
+
private onSinglePanStart;
|
103
|
+
private onSinglePanMove;
|
104
|
+
private onSinglePanEnd;
|
105
|
+
private onDoubleTap;
|
106
|
+
private onDoublePanStart;
|
107
|
+
private onDoublePanMove;
|
108
|
+
private onDoublePanEnd;
|
109
|
+
private onRotateStart;
|
110
|
+
private onRotateMove;
|
111
|
+
private onRotateEnd;
|
112
|
+
private onPinchStart;
|
113
|
+
private onPinchMove;
|
114
|
+
private onPinchEnd;
|
115
|
+
private onTriplePanStart;
|
116
|
+
private onTriplePanMove;
|
117
|
+
private onTriplePanEnd;
|
118
|
+
private setCenter;
|
119
|
+
private initializeMouseActions;
|
120
|
+
private compareMouseAction;
|
121
|
+
private setMouseAction;
|
122
|
+
private unsetMouseAction;
|
123
|
+
private getOpFromAction;
|
124
|
+
private getOpStateFromAction;
|
125
|
+
private getAngle;
|
126
|
+
private updateTouchEvent;
|
127
|
+
private applyTransformMatrix;
|
128
|
+
private calculateAngularSpeed;
|
129
|
+
private calculatePointersDistance;
|
130
|
+
private calculateRotationAxis;
|
131
|
+
private calculateTbRadius;
|
132
|
+
private focus;
|
133
|
+
private drawGrid;
|
134
|
+
dispose: () => void;
|
135
|
+
private disposeGrid;
|
136
|
+
private easeOutCubic;
|
137
|
+
private activateGizmos;
|
138
|
+
private getCursorNDC;
|
139
|
+
private getCursorPosition;
|
140
|
+
private setCamera;
|
141
|
+
setGizmosVisible(value: boolean): void;
|
142
|
+
private makeGizmos;
|
143
|
+
private onFocusAnim;
|
144
|
+
private onRotationAnim;
|
145
|
+
private pan;
|
146
|
+
reset: () => void;
|
147
|
+
private rotate;
|
148
|
+
private copyState;
|
149
|
+
private pasteState;
|
150
|
+
saveState: () => void;
|
151
|
+
private applyScale;
|
152
|
+
private setFov;
|
153
|
+
setTarget: (x: number, y: number, z: number) => void;
|
154
|
+
private setTransformationMatrices;
|
155
|
+
private zRotate;
|
156
|
+
private unprojectOnObj;
|
157
|
+
private unprojectOnTbSurface;
|
158
|
+
private unprojectOnTbPlane;
|
159
|
+
private updateMatrixState;
|
160
|
+
private updateTbState;
|
161
|
+
update: () => void;
|
162
|
+
private setStateFromJSON;
|
163
|
+
}
|
164
|
+
export { ArcballControls };
|