@ridp/threejs 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";const t=require("three");var e=function(){var t=0,i=document.createElement("div");function s(t){return i.appendChild(t.dom),t}function o(e){for(var s=0;s<i.children.length;s++)i.children[s].style.display=s===e?"block":"none";t=e}i.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",i.addEventListener("click",(function(e){e.preventDefault(),o(++t%i.children.length)}),!1);var n=(performance||Date).now(),a=n,r=0,h=s(new e.Panel("FPS","#0ff","#002")),l=s(new e.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=s(new e.Panel("MB","#f08","#201"));return o(0),{REVISION:16,dom:i,addPanel:s,showPanel:o,begin:function(){n=(performance||Date).now()},end:function(){r++;var t=(performance||Date).now();if(l.update(t-n,200),t>=a+1e3&&(h.update(1e3*r/(t-a),100),a=t,r=0,c)){var e=performance.memory;c.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576)}return t},update:function(){n=this.end()},domElement:i,setMode:o}};e.Panel=function(t,e,i){var s=1/0,o=0,n=Math.round,a=n(window.devicePixelRatio||1),r=80*a,h=48*a,l=3*a,c=2*a,p=3*a,d=15*a,m=74*a,u=30*a,_=document.createElement("canvas");_.width=r,_.height=h,_.style.cssText="width:80px;height:48px";var y=_.getContext("2d");return y.font="bold "+9*a+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=i,y.fillRect(0,0,r,h),y.fillStyle=e,y.fillText(t,l,c),y.fillRect(p,d,m,u),y.fillStyle=i,y.globalAlpha=.9,y.fillRect(p,d,m,u),{dom:_,update:function(h,f){s=Math.min(s,h),o=Math.max(o,h),y.fillStyle=i,y.globalAlpha=1,y.fillRect(0,0,r,d),y.fillStyle=e,y.fillText(n(h)+" "+t+" ("+n(s)+"-"+n(o)+")",l,c),y.drawImage(_,p+a,d,m-a,u,p,d,m-a,u),y.fillRect(p+m-a,d,a,u),y.fillStyle=i,y.globalAlpha=.9,y.fillRect(p+m-a,d,a,n((1-h/f)*u))}}};const i=new t.Vector3,s=new t.Quaternion,o=new t.Vector3;class n extends t.Object3D{constructor(t=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=t,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",(function(){this.traverse((function(t){t.element instanceof t.element.ownerDocument.defaultView.Element&&null!==t.element.parentNode&&t.element.remove()}))}))}copy(t,e){return super.copy(t,e),this.element=t.element.cloneNode(!0),this}}const a=new t.Matrix4,r=new t.Matrix4;const h={type:"change"},l={type:"start"},c={type:"end"},p=new t.Ray,d=new t.Plane,m=Math.cos(70*t.MathUtils.DEG2RAD),u=new t.Vector3,_=2*Math.PI,y=-1,f=0,g=1,b=2,E=3,v=4,w=5,S=6,P=1e-6;class D extends t.Controls{constructor(e,i=null){super(e,i),this.state=y,this.target=new t.Vector3,this.cursor=new t.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:t.MOUSE.ROTATE,MIDDLE:t.MOUSE.DOLLY,RIGHT:t.MOUSE.PAN},this.touches={ONE:t.TOUCH.ROTATE,TWO:t.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new t.Vector3,this._lastQuaternion=new t.Quaternion,this._lastTargetPosition=new t.Vector3,this._quat=(new t.Quaternion).setFromUnitVectors(e.up,new t.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new t.Spherical,this._sphericalDelta=new t.Spherical,this._scale=1,this._panOffset=new t.Vector3,this._rotateStart=new t.Vector2,this._rotateEnd=new t.Vector2,this._rotateDelta=new t.Vector2,this._panStart=new t.Vector2,this._panEnd=new t.Vector2,this._panDelta=new t.Vector2,this._dollyStart=new t.Vector2,this._dollyEnd=new t.Vector2,this._dollyDelta=new t.Vector2,this._dollyDirection=new t.Vector3,this._mouse=new t.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=x.bind(this),this._onPointerDown=M.bind(this),this._onPointerUp=T.bind(this),this._onContextMenu=k.bind(this),this._onMouseWheel=A.bind(this),this._onKeyDown=L.bind(this),this._onTouchStart=C.bind(this),this._onTouchMove=O.bind(this),this._onMouseDown=R.bind(this),this._onMouseMove=j.bind(this),this._interceptControlDown=U.bind(this),this._interceptControlUp=H.bind(this),null!==this.domElement&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1});this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){null!==this._domElementKeyEvents&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(h),this.update(),this.state=y}update(e=null){const i=this.object.position;u.copy(i).sub(this.target),u.applyQuaternion(this._quat),this._spherical.setFromVector3(u),this.autoRotate&&this.state===y&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,o=this.maxAzimuthAngle;isFinite(s)&&isFinite(o)&&(s<-Math.PI?s+=_:s>Math.PI&&(s-=_),o<-Math.PI?o+=_:o>Math.PI&&(o-=_),this._spherical.theta=s<=o?Math.max(s,Math.min(o,this._spherical.theta)):this._spherical.theta>(s+o)/2?Math.max(s,this._spherical.theta):Math.min(o,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let n=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const t=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),n=t!=this._spherical.radius}if(u.setFromSpherical(this._spherical),u.applyQuaternion(this._quatInverse),i.copy(this.target).add(u),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){const t=u.length();e=this._clampDistance(t*this._scale);const i=t-e;this.object.position.addScaledVector(this._dollyDirection,i),this.object.updateMatrixWorld(),n=!!i}else if(this.object.isOrthographicCamera){const i=new t.Vector3(this._mouse.x,this._mouse.y,0);i.unproject(this.object);const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),n=s!==this.object.zoom;const o=new t.Vector3(this._mouse.x,this._mouse.y,0);o.unproject(this.object),this.object.position.sub(o).add(i),this.object.updateMatrixWorld(),e=u.length()}else this.zoomToCursor=!1;null!==e&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(p.origin.copy(this.object.position),p.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(p.direction))<m?this.object.lookAt(this.target):(d.setFromNormalAndCoplanarPoint(this.object.up,this.target),p.intersectPlane(d,this.target))))}else if(this.object.isOrthographicCamera){const t=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),t!==this.object.zoom&&(this.object.updateProjectionMatrix(),n=!0)}return this._scale=1,this._performCursorZoom=!1,!!(n||this._lastPosition.distanceToSquared(this.object.position)>P||8*(1-this._lastQuaternion.dot(this.object.quaternion))>P||this._lastTargetPosition.distanceToSquared(this.target)>P)&&(this.dispatchEvent(h),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(t){return null!==t?_/60*this.autoRotateSpeed*t:_/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){u.setFromMatrixColumn(e,0),u.multiplyScalar(-t),this._panOffset.add(u)}_panUp(t,e){!0===this.screenSpacePanning?u.setFromMatrixColumn(e,1):(u.setFromMatrixColumn(e,0),u.crossVectors(this.object.up,u)),u.multiplyScalar(t),this._panOffset.add(u)}_pan(t,e){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;u.copy(s).sub(this.target);let o=u.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*o/i.clientHeight,this.object.matrix),this._panUp(2*e*o/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):this.enablePan=!1}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:this.enableZoom=!1}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:this.enableZoom=!1}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=t-i.left,o=e-i.top,n=i.width,a=i.height;this._mouse.x=s/n*2-1,this._mouse.y=-o/a*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(_*this._rotateDelta.x/e.clientHeight),this._rotateUp(_*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(1===this._pointers.length)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(t){if(1===this._pointers.length)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(i,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,s=t.pageY-e.y,o=Math.sqrt(i*i+s*s);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(1==this._pointers.length)this._rotateEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(_*this._rotateDelta.x/e.clientHeight),this._rotateUp(_*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(1===this._pointers.length)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,s=t.pageY-e.y,o=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const n=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._updateZoomParameters(n,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return void this._pointers.splice(e,1)}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(e){let i=this._pointerPositions[e.pointerId];void 0===i&&(i=new t.Vector2,this._pointerPositions[e.pointerId]=i),i.set(e.pageX,e.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,i={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100}return t.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function M(t){!1!==this.enabled&&(0===this._pointers.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._isTrackingPointer(t)||(this._addPointer(t),"touch"===t.pointerType?this._onTouchStart(t):this._onMouseDown(t)))}function x(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchMove(t):this._onMouseMove(t))}function T(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(c),this.state=y;break;case 1:const e=this._pointers[0],i=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:i.x,pageY:i.y})}}function R(e){let i;switch(e.button){case 0:i=this.mouseButtons.LEFT;break;case 1:i=this.mouseButtons.MIDDLE;break;case 2:i=this.mouseButtons.RIGHT;break;default:i=-1}switch(i){case t.MOUSE.DOLLY:if(!1===this.enableZoom)return;this._handleMouseDownDolly(e),this.state=g;break;case t.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===this.enablePan)return;this._handleMouseDownPan(e),this.state=b}else{if(!1===this.enableRotate)return;this._handleMouseDownRotate(e),this.state=f}break;case t.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===this.enableRotate)return;this._handleMouseDownRotate(e),this.state=f}else{if(!1===this.enablePan)return;this._handleMouseDownPan(e),this.state=b}break;default:this.state=y}this.state!==y&&this.dispatchEvent(l)}function j(t){switch(this.state){case f:if(!1===this.enableRotate)return;this._handleMouseMoveRotate(t);break;case g:if(!1===this.enableZoom)return;this._handleMouseMoveDolly(t);break;case b:if(!1===this.enablePan)return;this._handleMouseMovePan(t)}}function A(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===y&&(t.preventDefault(),this.dispatchEvent(l),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(c))}function L(t){!1!==this.enabled&&this._handleKeyDown(t)}function C(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case t.TOUCH.ROTATE:if(!1===this.enableRotate)return;this._handleTouchStartRotate(e),this.state=E;break;case t.TOUCH.PAN:if(!1===this.enablePan)return;this._handleTouchStartPan(e),this.state=v;break;default:this.state=y}break;case 2:switch(this.touches.TWO){case t.TOUCH.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchStartDollyPan(e),this.state=w;break;case t.TOUCH.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchStartDollyRotate(e),this.state=S;break;default:this.state=y}break;default:this.state=y}this.state!==y&&this.dispatchEvent(l)}function O(t){switch(this._trackPointer(t),this.state){case E:if(!1===this.enableRotate)return;this._handleTouchMoveRotate(t),this.update();break;case v:if(!1===this.enablePan)return;this._handleTouchMovePan(t),this.update();break;case w:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchMoveDollyPan(t),this.update();break;case S:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=y}}function k(t){!1!==this.enabled&&t.preventDefault()}function U(t){if("Control"===t.key){this._controlActive=!0;this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}}function H(t){if("Control"===t.key){this._controlActive=!1;this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}}class F extends D{constructor(e,i){super(e,i),this.screenSpacePanning=!1,this.mouseButtons={LEFT:t.MOUSE.PAN,MIDDLE:t.MOUSE.DOLLY,RIGHT:t.MOUSE.ROTATE},this.touches={ONE:t.TOUCH.PAN,TWO:t.TOUCH.DOLLY_ROTATE}}}class Y extends t.DataTextureLoader{constructor(e){super(e),this.type=t.HalfFloatType}parse(e){const i=function(t,e){switch(t){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(e||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(e||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(e||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(e||""))}},s=function(t,e,i){e=e||1024;let s=t.pos,o=-1,n=0,a="",r=String.fromCharCode.apply(null,new Uint16Array(t.subarray(s,s+128)));for(;0>(o=r.indexOf("\n"))&&n<e&&s<t.byteLength;)a+=r,n+=r.length,s+=128,r+=String.fromCharCode.apply(null,new Uint16Array(t.subarray(s,s+128)));return-1<o&&(t.pos+=n+o+1,a+r.slice(0,o))},o=function(t,e,i,s){const o=t[e+3],n=Math.pow(2,o-128)/255;i[s+0]=t[e+0]*n,i[s+1]=t[e+1]*n,i[s+2]=t[e+2]*n,i[s+3]=1},n=function(e,i,s,o){const n=e[i+3],a=Math.pow(2,n-128)/255;s[o+0]=t.DataUtils.toHalfFloat(Math.min(e[i+0]*a,65504)),s[o+1]=t.DataUtils.toHalfFloat(Math.min(e[i+1]*a,65504)),s[o+2]=t.DataUtils.toHalfFloat(Math.min(e[i+2]*a,65504)),s[o+3]=t.DataUtils.toHalfFloat(1)},a=new Uint8Array(e);a.pos=0;const r=function(t){const e=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*FORMAT=(\S+)\s*$/,a=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,r={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let h,l;for((t.pos>=t.byteLength||!(h=s(t)))&&i(1,"no header found"),(l=h.match(/^#\?(\S+)/))||i(3,"bad initial token"),r.valid|=1,r.programtype=l[1],r.string+=h+"\n";h=s(t),!1!==h;)if(r.string+=h+"\n","#"!==h.charAt(0)){if((l=h.match(e))&&(r.gamma=parseFloat(l[1])),(l=h.match(o))&&(r.exposure=parseFloat(l[1])),(l=h.match(n))&&(r.valid|=2,r.format=l[1]),(l=h.match(a))&&(r.valid|=4,r.height=parseInt(l[1],10),r.width=parseInt(l[2],10)),2&r.valid&&4&r.valid)break}else r.comments+=h+"\n";return 2&r.valid||i(3,"missing format specifier"),4&r.valid||i(3,"missing image size specifier"),r}(a),h=r.width,l=r.height,c=function(t,e,s){const o=e;if(o<8||o>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);o!==(t[2]<<8|t[3])&&i(3,"wrong scanline width");const n=new Uint8Array(4*e*s);n.length||i(4,"unable to allocate buffer space");let a=0,r=0;const h=4*o,l=new Uint8Array(4),c=new Uint8Array(h);let p=s;for(;p>0&&r<t.byteLength;){r+4>t.byteLength&&i(1),l[0]=t[r++],l[1]=t[r++],l[2]=t[r++],l[3]=t[r++],2==l[0]&&2==l[1]&&(l[2]<<8|l[3])==o||i(3,"bad rgbe scanline format");let e,s=0;for(;s<h&&r<t.byteLength;){e=t[r++];const o=e>128;if(o&&(e-=128),(0===e||s+e>h)&&i(3,"bad scanline data"),o){const i=t[r++];for(let t=0;t<e;t++)c[s++]=i}else c.set(t.subarray(r,r+e),s),s+=e,r+=e}const d=o;for(let t=0;t<d;t++){let e=0;n[a]=c[t+e],e+=o,n[a+1]=c[t+e],e+=o,n[a+2]=c[t+e],e+=o,n[a+3]=c[t+e],a+=4}p--}return n}(a.subarray(a.pos),h,l);let p,d,m;switch(this.type){case t.FloatType:m=c.length/4;const e=new Float32Array(4*m);for(let t=0;t<m;t++)o(c,4*t,e,4*t);p=e,d=t.FloatType;break;case t.HalfFloatType:m=c.length/4;const i=new Uint16Array(4*m);for(let t=0;t<m;t++)n(c,4*t,i,4*t);p=i,d=t.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:h,height:l,data:p,header:r.string,gamma:r.gamma,exposure:r.exposure,type:d}}setDataType(t){return this.type=t,this}load(e,i,s,o){return super.load(e,(function(e,s){switch(e.type){case t.FloatType:case t.HalfFloatType:e.colorSpace=t.LinearSRGBColorSpace,e.minFilter=t.LinearFilter,e.magFilter=t.LinearFilter,e.generateMipmaps=!1,e.flipY=!0}i&&i(e,s)}),s,o)}}const I=t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach((t=>{z(t)})):z(t.material)),t.children&&t.children.forEach((t=>I(t)))};function z(t){for(const e in t)t[e]&&t[e].isTexture&&t[e].dispose();t.dispose()}const V={},Z=new Y;exports.CSS3DRenderer=class{constructor(t={}){const e=this;let n,h,l,c;const p={camera:{style:""},objects:new WeakMap},d=void 0!==t.element?t.element:document.createElement("div");d.style.overflow="hidden",this.domElement=d;const m=document.createElement("div");m.style.transformOrigin="0 0",m.style.pointerEvents="none",d.appendChild(m);const u=document.createElement("div");function _(t){return Math.abs(t)<1e-10?0:t}function y(t){const e=t.elements;return"matrix3d("+_(e[0])+","+_(-e[1])+","+_(e[2])+","+_(e[3])+","+_(e[4])+","+_(-e[5])+","+_(e[6])+","+_(e[7])+","+_(e[8])+","+_(-e[9])+","+_(e[10])+","+_(e[11])+","+_(e[12])+","+_(-e[13])+","+_(e[14])+","+_(e[15])+")"}function f(t){const e=t.elements;return"translate(-50%,-50%)"+("matrix3d("+_(e[0])+","+_(e[1])+","+_(e[2])+","+_(e[3])+","+_(-e[4])+","+_(-e[5])+","+_(-e[6])+","+_(-e[7])+","+_(e[8])+","+_(e[9])+","+_(e[10])+","+_(e[11])+","+_(e[12])+","+_(e[13])+","+_(e[14])+","+_(e[15])+")")}function g(t){t.isCSS3DObject&&(t.element.style.display="none");for(let e=0,i=t.children.length;e<i;e++)g(t.children[e])}function b(t,n,h,l){if(!1!==t.visible){if(t.isCSS3DObject){const l=!0===t.layers.test(h.layers),c=t.element;if(c.style.display=!0===l?"":"none",!0===l){let l;t.onBeforeRender(e,n,h),t.isCSS3DSprite?(a.copy(h.matrixWorldInverse),a.transpose(),0!==t.rotation2D&&a.multiply(r.makeRotationZ(t.rotation2D)),t.matrixWorld.decompose(i,s,o),a.setPosition(i),a.scale(o),a.elements[3]=0,a.elements[7]=0,a.elements[11]=0,a.elements[15]=1,l=f(a)):l=f(t.matrixWorld);const d=p.objects.get(t);if(void 0===d||d.style!==l){c.style.transform=l;const e={style:l};p.objects.set(t,e)}c.parentNode!==u&&u.appendChild(c),t.onAfterRender(e,n,h)}}for(let e=0,i=t.children.length;e<i;e++)b(t.children[e],n,h)}else g(t)}u.style.transformStyle="preserve-3d",m.appendChild(u),this.getSize=function(){return{width:n,height:h}},this.render=function(t,e){const i=e.projectionMatrix.elements[5]*c;let s,o;e.view&&e.view.enabled?(m.style.transform=`translate( ${-e.view.offsetX*(n/e.view.width)}px, ${-e.view.offsetY*(h/e.view.height)}px )`,m.style.transform+=`scale( ${e.view.fullWidth/e.view.width}, ${e.view.fullHeight/e.view.height} )`):m.style.transform="",!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),e.isOrthographicCamera&&(s=-(e.right+e.left)/2,o=(e.top+e.bottom)/2);const a=e.view&&e.view.enabled?e.view.height/e.view.fullHeight:1,r=e.isOrthographicCamera?`scale( ${a} )scale(`+i+")translate("+_(s)+"px,"+_(o)+"px)"+y(e.matrixWorldInverse):`scale( ${a} )translateZ(`+i+"px)"+y(e.matrixWorldInverse),d=(e.isPerspectiveCamera?"perspective("+i+"px) ":"")+r+"translate("+l+"px,"+c+"px)";p.camera.style!==d&&(u.style.transform=d,p.camera.style=d),b(t,t,e)},this.setSize=function(t,e){n=t,h=e,l=n/2,c=h/2,d.style.width=t+"px",d.style.height=e+"px",m.style.width=t+"px",m.style.height=e+"px",u.style.width=t+"px",u.style.height=e+"px"}}},exports.CSS3DSprite=class extends n{constructor(t){super(t),this.isCSS3DSprite=!0,this.rotation2D=0}copy(t,e){return super.copy(t,e),this.rotation2D=t.rotation2D,this}},exports.ImageLoader=async function(t){return new Promise(((e,i)=>{Z.load(t,e,void 0,i)}))},exports.Stats=e,exports.createArrowHelper=function(e=new t.Vector3(1,1,1),i=new t.Vector3(10,10,10),s=5,o=16776960){return e.normalize(),new t.ArrowHelper(e,i,s,o)},exports.createAxesHelper=function(e=10){return new t.AxesHelper(e)},exports.createBox3Helper=function(e){return new t.BoxHelper(e,16776960)},exports.createCameraHelper=function(e){return new t.CameraHelper(e)},exports.createGridHelper=function(e=150,...i){return new t.GridHelper(e,e/10,...i)},exports.createMapControls=function(t,e){return new F(t,e)},exports.createOrbitControl=function(t,e){return new D(t,e)},exports.createRaycaster=function(){return{raycaster:new t.Raycaster,pointer:new t.Vector2(0,0)}},exports.createStats=function(){const t=new e;return t.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t},exports.disposeThreeObject=I,exports.initEnvImage=async function(e,i){if(i){if(!V[i])return new Promise(((t,e)=>{Z.load(i,t,void 0,e)})).then((s=>{s.mapping=t.EquirectangularReflectionMapping,e.environment=s,V[i]=s})).catch((t=>{}));{const t=V[i];e.environment=t}}};