gl-draw 0.15.7 → 0.15.8

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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ut=Object.defineProperty,ft=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var Se=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable;var Me=(h,e,t)=>e in h?ut(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t,z=(h,e)=>{for(var t in e||(e={}))gt.call(e,t)&&Me(h,t,e[t]);if(Se)for(var t of Se(e))yt.call(e,t)&&Me(h,t,e[t]);return h},ee=(h,e)=>ft(h,_t(e));var te=(h,e,t)=>new Promise((s,i)=>{var r=a=>{try{n(t.next(a))}catch(c){i(c)}},o=a=>{try{n(t.throw(a))}catch(c){i(c)}},n=a=>a.done?s(a.value):Promise.resolve(a.value).then(r,o);n((t=t.apply(h,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("three"),vt=require("three/examples/jsm/misc/Timer"),Ct=require("@tweenjs/tween.js"),Ot=require("deepmerge"),Et=require("stats-gl"),Pe=require("./isPlainObject.js"),B=require("./index2.js"),Tt=require("three/examples/jsm/helpers/RectAreaLightHelper"),wt=require("three/examples/jsm/helpers/ViewHelper"),xt=require("three/examples/jsm/controls/TransformControls"),Re=require("three/examples/jsm/postprocessing/EffectComposer"),bt=require("three/examples/jsm/postprocessing/RenderPass"),Lt=require("three/examples/jsm/postprocessing/SSAOPass"),De=require("three/examples/jsm/postprocessing/Pass"),Pt=require("three/examples/jsm/postprocessing/OutputPass"),At=require("three/examples/jsm/postprocessing/ShaderPass"),St=require("three/examples/jsm/postprocessing/UnrealBloomPass");require("three/examples/jsm/renderers/CSS2DRenderer");require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo");require("d3-geo-projection");require("three/examples/jsm/lights/RectAreaLightUniformsLib");require("three/examples/jsm/utils/BufferGeometryUtils");require("three/examples/jsm/lines/LineSegments2");require("three/examples/jsm/lines/LineSegmentsGeometry");require("three/examples/jsm/lines/LineMaterial");require("three-bvh-csg");const Ue=require("three/examples/jsm/loaders/GLTFLoader"),Mt=require("three/examples/jsm/loaders/DRACOLoader"),Rt=require("three/examples/jsm/loaders/EXRLoader"),Dt=require("three/examples/jsm/loaders/LottieLoader"),Le=require("esus-lite");function Ut(h){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>h[t]})}}return e.default=h,Object.freeze(e)}const ve=Ut(Ct),R={LEFT:1,RIGHT:2,MIDDLE:4},d=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768,SCREEN_PAN:65536,TOUCH_SCREEN_PAN:131072,TOUCH_DOLLY_SCREEN_PAN:262144,TOUCH_ZOOM_SCREEN_PAN:524288}),q={NONE:0,IN:1,OUT:-1};function Y(h){return h.isPerspectiveCamera}function j(h){return h.isOrthographicCamera}const W=Math.PI*2,ze=Math.PI/2,et=1e-5,se=Math.PI/180;function F(h,e,t){return Math.max(e,Math.min(t,h))}function M(h,e=et){return Math.abs(h)<e}function A(h,e,t=et){return M(h-e,t)}function ke(h,e){return Math.round(h/e)*e}function ie(h){return isFinite(h)?h:h<0?-Number.MAX_VALUE:Number.MAX_VALUE}function re(h){return Math.abs(h)<Number.MAX_VALUE?h:h*(1/0)}function le(h,e,t,s,i=1/0,r){s=Math.max(1e-4,s);const o=2/s,n=o*r,a=1/(1+n+.48*n*n+.235*n*n*n);let c=h-e;const f=e,m=i*s;c=F(c,-m,m),e=h-c;const C=(t.value+o*c)*r;t.value=(t.value-o*C)*a;let p=e+(c+C)*a;return f-h>0==p>f&&(p=f,t.value=(p-f)/r),p}function Fe(h,e,t,s,i=1/0,r,o){s=Math.max(1e-4,s);const n=2/s,a=n*r,c=1/(1+a+.48*a*a+.235*a*a*a);let f=e.x,m=e.y,C=e.z,p=h.x-f,u=h.y-m,g=h.z-C;const y=f,l=m,_=C,E=i*s,O=E*E,x=p*p+u*u+g*g;if(x>O){const ye=Math.sqrt(x);p=p/ye*E,u=u/ye*E,g=g/ye*E}f=h.x-p,m=h.y-u,C=h.z-g;const T=(t.x+n*p)*r,L=(t.y+n*u)*r,D=(t.z+n*g)*r;t.x=(t.x-n*T)*c,t.y=(t.y-n*L)*c,t.z=(t.z-n*D)*c,o.x=f+(p+T)*c,o.y=m+(u+L)*c,o.z=C+(g+D)*c;const V=y-h.x,ae=l-h.y,ct=_-h.z,dt=o.x-y,mt=o.y-l,pt=o.z-_;return V*dt+ae*mt+ct*pt>0&&(o.x=y,o.y=l,o.z=_,t.x=(o.x-y)/r,t.y=(o.y-l)/r,t.z=(o.z-_)/r),o}function Ce(h,e){e.set(0,0),h.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=h.length,e.y/=h.length}function Oe(h,e){return j(h)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class zt{constructor(){this._listeners={}}addEventListener(e,t){const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const s=this._listeners[e.type];if(s!==void 0){e.target=this;const i=s.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e)}}}const he=1/8,kt=/Mac/.test(navigator.platform);let w,Ne,ce,Ee,U,b,P,K,oe,N,H,Z,He,Ie,k,ne,G,je,Te,Be,we,xe,de;class Q extends zt{static install(e){w=e.THREE,Ne=Object.freeze(new w.Vector3(0,0,0)),ce=Object.freeze(new w.Vector3(0,1,0)),Ee=Object.freeze(new w.Vector3(0,0,1)),U=new w.Vector2,b=new w.Vector3,P=new w.Vector3,K=new w.Vector3,oe=new w.Vector3,N=new w.Vector3,H=new w.Vector3,Z=new w.Vector3,He=new w.Vector3,Ie=new w.Vector3,k=new w.Spherical,ne=new w.Spherical,G=new w.Box3,je=new w.Box3,Te=new w.Sphere,Be=new w.Quaternion,we=new w.Quaternion,xe=new w.Matrix4,de=new w.Raycaster}static get ACTION(){return d}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=d.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=q.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new w.Vector3,this._focalOffsetVelocity=new w.Vector3,this._zoomVelocity={value:0},this._truckInternal=(l,_,E,O)=>{let x,T;if(Y(this._camera)){const L=b.copy(this._camera.position).sub(this._target),D=this._camera.getEffectiveFOV()*se,V=L.length()*Math.tan(D*.5);x=this.truckSpeed*l*V/this._elementRect.height,T=this.truckSpeed*_*V/this._elementRect.height}else if(j(this._camera)){const L=this._camera;x=this.truckSpeed*l*(L.right-L.left)/L.zoom/this._elementRect.width,T=this.truckSpeed*_*(L.top-L.bottom)/L.zoom/this._elementRect.height}else return;O?(E?this.setFocalOffset(this._focalOffsetEnd.x+x,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(x,0,!0),this.forward(-T,!0)):E?this.setFocalOffset(this._focalOffsetEnd.x+x,this._focalOffsetEnd.y+T,this._focalOffsetEnd.z,!0):this.truck(x,T,!0)},this._rotateInternal=(l,_)=>{const E=W*this.azimuthRotateSpeed*l/this._elementRect.height,O=W*this.polarRotateSpeed*_/this._elementRect.height;this.rotate(E,O,!0)},this._dollyInternal=(l,_,E)=>{const O=Math.pow(.95,-l*this.dollySpeed),x=this._sphericalEnd.radius,T=this._sphericalEnd.radius*O,L=F(T,this.minDistance,this.maxDistance),D=L-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(D,!0),this._dollyToNoClamp(L,!0)):this._dollyToNoClamp(L,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:L)-x,this._dollyControlCoord.set(_,E)),this._lastDollyDirection=Math.sign(-l)},this._zoomInternal=(l,_,E)=>{const O=Math.pow(.95,l*this.dollySpeed),x=this._zoom,T=this._zoom*O;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-x,this._dollyControlCoord.set(_,E))},typeof w=="undefined"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new w.Quaternion().setFromUnitVectors(this._camera.up,ce),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=d.NONE,this._target=new w.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new w.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new w.Spherical().setFromVector3(b.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new w.Vector3,new w.Vector3,new w.Vector3,new w.Vector3],this._updateNearPlaneCorners(),this._boundary=new w.Box3(new w.Vector3(-1/0,-1/0,-1/0),new w.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new w.Vector2,this.mouseButtons={left:d.ROTATE,middle:d.DOLLY,right:d.TRUCK,wheel:Y(this._camera)?d.DOLLY:j(this._camera)?d.ZOOM:d.NONE},this.touches={one:d.TOUCH_ROTATE,two:Y(this._camera)?d.TOUCH_DOLLY_TRUCK:j(this._camera)?d.TOUCH_ZOOM_TRUCK:d.NONE,three:d.TOUCH_TRUCK};const s=new w.Vector2,i=new w.Vector2,r=new w.Vector2,o=l=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),x=(l.clientX-O.left)/(O.right-O.left),T=(l.clientY-O.top)/(O.bottom-O.top);if(x<this._interactiveArea.left||x>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const _=l.pointerType!=="mouse"?null:(l.buttons&R.LEFT)===R.LEFT?R.LEFT:(l.buttons&R.MIDDLE)===R.MIDDLE?R.MIDDLE:(l.buttons&R.RIGHT)===R.RIGHT?R.RIGHT:null;if(_!==null){const O=this._findPointerByMouseButton(_);O&&this._disposePointer(O)}if((l.buttons&R.LEFT)===R.LEFT&&this._lockedPointer)return;const E={pointerId:l.pointerId,clientX:l.clientX,clientY:l.clientY,deltaX:0,deltaY:0,mouseButton:_};this._activePointers.push(E),this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.ownerDocument.addEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",a),this._isDragging=!0,C(l)},n=l=>{l.cancelable&&l.preventDefault();const _=l.pointerId,E=this._lockedPointer||this._findPointerById(_);if(E){if(E.clientX=l.clientX,E.clientY=l.clientY,E.deltaX=l.movementX,E.deltaY=l.movementY,this._state=0,l.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(l.buttons&R.LEFT)===R.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(l.buttons&R.MIDDLE)===R.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(l.buttons&R.RIGHT)===R.RIGHT&&(this._state=this._state|this.mouseButtons.right);p()}},a=l=>{const _=this._findPointerById(l.pointerId);if(!(_&&_===this._lockedPointer)){if(_&&this._disposePointer(_),l.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=d.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=d.NONE;u()}};let c=-1;const f=l=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===d.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const T=this._domElement.getBoundingClientRect(),L=(l.clientX-T.left)/(T.right-T.left),D=(l.clientY-T.top)/(T.bottom-T.top);if(L<this._interactiveArea.left||L>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}if(l.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===d.ROTATE||this.mouseButtons.wheel===d.TRUCK){const T=performance.now();c-T<1e3&&this._getClientRect(this._elementRect),c=T}const _=kt?-1:-3,E=l.deltaMode===1||l.ctrlKey?l.deltaY/_:l.deltaY/(_*10),O=this.dollyToCursor?(l.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(l.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case d.ROTATE:{this._rotateInternal(l.deltaX,l.deltaY),this._isUserControllingRotate=!0;break}case d.TRUCK:{this._truckInternal(l.deltaX,l.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case d.SCREEN_PAN:{this._truckInternal(l.deltaX,l.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case d.OFFSET:{this._truckInternal(l.deltaX,l.deltaY,!0,!1),this._isUserControllingOffset=!0;break}case d.DOLLY:{this._dollyInternal(-E,O,x),this._isUserControllingDolly=!0;break}case d.ZOOM:{this._zoomInternal(-E,O,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=l=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Q.ACTION.NONE){const _=l instanceof PointerEvent?l.pointerId:0,E=this._findPointerById(_);E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a);return}l.preventDefault()}},C=l=>{if(!this._enabled)return;if(Ce(this._activePointers,U),this._getClientRect(this._elementRect),s.copy(U),i.copy(U),this._activePointers.length>=2){const E=U.x-this._activePointers[1].clientX,O=U.y-this._activePointers[1].clientY,x=Math.sqrt(E*E+O*O);r.set(0,x);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,L=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(T,L)}if(this._state=0,!l)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in l&&l.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(l.buttons&R.LEFT)===R.LEFT&&(this._state=this._state|this.mouseButtons.left),(l.buttons&R.MIDDLE)===R.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(l.buttons&R.RIGHT)===R.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&d.ROTATE)===d.ROTATE||(this._state&d.TOUCH_ROTATE)===d.TOUCH_ROTATE||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE||(this._state&d.TOUCH_ZOOM_ROTATE)===d.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&d.TRUCK)===d.TRUCK||(this._state&d.SCREEN_PAN)===d.SCREEN_PAN||(this._state&d.TOUCH_TRUCK)===d.TOUCH_TRUCK||(this._state&d.TOUCH_SCREEN_PAN)===d.TOUCH_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_ZOOM_TRUCK)===d.TOUCH_ZOOM_TRUCK||(this._state&d.TOUCH_ZOOM_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&d.DOLLY)===d.DOLLY||(this._state&d.TOUCH_DOLLY)===d.TOUCH_DOLLY||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&d.ZOOM)===d.ZOOM||(this._state&d.TOUCH_ZOOM)===d.TOUCH_ZOOM||(this._state&d.TOUCH_ZOOM_TRUCK)===d.TOUCH_ZOOM_TRUCK||(this._state&d.TOUCH_ZOOM_SCREEN_PAN)===d.TOUCH_ZOOM_SCREEN_PAN||(this._state&d.TOUCH_ZOOM_OFFSET)===d.TOUCH_ZOOM_OFFSET||(this._state&d.TOUCH_ZOOM_ROTATE)===d.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&d.OFFSET)===d.OFFSET||(this._state&d.TOUCH_OFFSET)===d.TOUCH_OFFSET||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET||(this._state&d.TOUCH_ZOOM_OFFSET)===d.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},p=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,Ce(this._activePointers,U);const _=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,E=_?-_.deltaX:i.x-U.x,O=_?-_.deltaY:i.y-U.y;if(i.copy(U),((this._state&d.ROTATE)===d.ROTATE||(this._state&d.TOUCH_ROTATE)===d.TOUCH_ROTATE||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE||(this._state&d.TOUCH_ZOOM_ROTATE)===d.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(E,O),this._isUserControllingRotate=!0),(this._state&d.DOLLY)===d.DOLLY||(this._state&d.ZOOM)===d.ZOOM){const x=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,L=this.dollyDragInverted?-1:1;(this._state&d.DOLLY)===d.DOLLY?(this._dollyInternal(L*O*he,x,T),this._isUserControllingDolly=!0):(this._zoomInternal(L*O*he,x,T),this._isUserControllingZoom=!0)}if((this._state&d.TOUCH_DOLLY)===d.TOUCH_DOLLY||(this._state&d.TOUCH_ZOOM)===d.TOUCH_ZOOM||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_ZOOM_TRUCK)===d.TOUCH_ZOOM_TRUCK||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_ZOOM_SCREEN_PAN)===d.TOUCH_ZOOM_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET||(this._state&d.TOUCH_ZOOM_OFFSET)===d.TOUCH_ZOOM_OFFSET||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE||(this._state&d.TOUCH_ZOOM_ROTATE)===d.TOUCH_ZOOM_ROTATE){const x=U.x-this._activePointers[1].clientX,T=U.y-this._activePointers[1].clientY,L=Math.sqrt(x*x+T*T),D=r.y-L;r.set(0,L);const V=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,ae=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&d.TOUCH_DOLLY)===d.TOUCH_DOLLY||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET?(this._dollyInternal(D*he,V,ae),this._isUserControllingDolly=!0):(this._zoomInternal(D*he,V,ae),this._isUserControllingZoom=!0)}((this._state&d.TRUCK)===d.TRUCK||(this._state&d.TOUCH_TRUCK)===d.TOUCH_TRUCK||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_ZOOM_TRUCK)===d.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(E,O,!1,!1),this._isUserControllingTruck=!0),((this._state&d.SCREEN_PAN)===d.SCREEN_PAN||(this._state&d.TOUCH_SCREEN_PAN)===d.TOUCH_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_ZOOM_SCREEN_PAN)===d.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(E,O,!1,!0),this._isUserControllingTruck=!0),((this._state&d.OFFSET)===d.OFFSET||(this._state&d.TOUCH_OFFSET)===d.TOUCH_OFFSET||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET||(this._state&d.TOUCH_ZOOM_OFFSET)===d.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(E,O,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},u=()=>{Ce(this._activePointers,U),i.copy(U),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",g),this._domElement.ownerDocument.addEventListener("pointerlockerror",y),this._domElement.ownerDocument.addEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",a),C())},this.unlockPointer=()=>{var l,_,E;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(l=this._domElement)===null||l===void 0||l.ownerDocument.exitPointerLock(),(_=this._domElement)===null||_===void 0||_.ownerDocument.removeEventListener("pointerlockchange",g),(E=this._domElement)===null||E===void 0||E.ownerDocument.removeEventListener("pointerlockerror",y),this.cancel()};const g=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},y=()=>{this.unlockPointer()};this._addAllEventListeners=l=>{this._domElement=l,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",a),this._domElement.addEventListener("wheel",f,{passive:!1}),this._domElement.addEventListener("contextmenu",m)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",a),this._domElement.removeEventListener("wheel",f,{passive:!1}),this._domElement.removeEventListener("contextmenu",m),this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement.ownerDocument.removeEventListener("pointerlockerror",y))},this.cancel=()=>{this._state!==d.NONE&&(this._state=d.NONE,this._activePointers.length=0,u())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=F(e.width,0,1),this._interactiveArea.height=F(e.height,0,1),this._interactiveArea.x=F(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=F(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,s=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,s)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,s=!1){this._isUserControllingRotate=!1;const i=F(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=F(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!s||A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0,this._dollyToNoClamp(F(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),n=A(o,this._spherical.radius);if(!(s>e)&&n)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(oe).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=F(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||A(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(e,t,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,s)}truck(e,t,s=!1){this._camera.updateMatrix(),N.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),N.multiplyScalar(e),H.multiplyScalar(-t);const i=b.copy(N).add(H),r=P.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,s)}forward(e,t=!1){b.setFromMatrixColumn(this._camera.matrix,0),b.crossVectors(this._camera.up,b),b.multiplyScalar(e);const s=P.copy(this._targetEnd).add(b);return this.moveTo(s.x,s.y,s.z,t)}elevate(e,t=!1){return b.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+b.x,this._targetEnd.y+b.y,this._targetEnd.z+b.z,t)}moveTo(e,t,s,i=!1){this._isUserControllingTruck=!1;const r=b.set(e,t,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const o=!i||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,s,i=!1){const n=b.set(e,t,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(n.x,n.y,n.z,i)}fitToBox(e,t,{cover:s=!1,paddingLeft:i=0,paddingRight:r=0,paddingBottom:o=0,paddingTop:n=0}={}){const a=[],c=e.isBox3?G.copy(e):G.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const f=ke(this._sphericalEnd.theta,ze),m=ke(this._sphericalEnd.phi,ze);a.push(this.rotateTo(f,m,t));const C=b.setFromSpherical(this._sphericalEnd).normalize(),p=Be.setFromUnitVectors(C,Ee),u=A(Math.abs(C.y),1);u&&p.multiply(we.setFromAxisAngle(ce,f)),p.multiply(this._yAxisUpSpaceInverse);const g=je.makeEmpty();P.copy(c.min).applyQuaternion(p),g.expandByPoint(P),P.copy(c.min).setX(c.max.x).applyQuaternion(p),g.expandByPoint(P),P.copy(c.min).setY(c.max.y).applyQuaternion(p),g.expandByPoint(P),P.copy(c.max).setZ(c.min.z).applyQuaternion(p),g.expandByPoint(P),P.copy(c.min).setZ(c.max.z).applyQuaternion(p),g.expandByPoint(P),P.copy(c.max).setY(c.min.y).applyQuaternion(p),g.expandByPoint(P),P.copy(c.max).setX(c.min.x).applyQuaternion(p),g.expandByPoint(P),P.copy(c.max).applyQuaternion(p),g.expandByPoint(P),g.min.x-=i,g.min.y-=o,g.max.x+=r,g.max.y+=n,p.setFromUnitVectors(Ee,C),u&&p.premultiply(we.invert()),p.premultiply(this._yAxisUpSpace);const y=g.getSize(b),l=g.getCenter(P).applyQuaternion(p);if(Y(this._camera)){const _=this.getDistanceToFitBox(y.x,y.y,y.z,s);a.push(this.moveTo(l.x,l.y,l.z,t)),a.push(this.dollyTo(_,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(j(this._camera)){const _=this._camera,E=_.right-_.left,O=_.top-_.bottom,x=s?Math.max(E/y.x,O/y.y):Math.min(E/y.x,O/y.y);a.push(this.moveTo(l.x,l.y,l.z,t)),a.push(this.zoomTo(x,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const s=[],r="isObject3D"in e?Q.createBoundingSphere(e,Te):Te.copy(e);if(s.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),Y(this._camera)){const o=this.getDistanceToFitSphere(r.radius);s.push(this.dollyTo(o,t))}else if(j(this._camera)){const o=this._camera.right-this._camera.left,n=this._camera.top-this._camera.bottom,a=2*r.radius,c=Math.min(o/a,n/a);s.push(this.zoomTo(c,t))}return s.push(this.setFocalOffset(0,0,0,t)),Promise.all(s)}setLookAt(e,t,s,i,r,o,n=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0;const a=P.set(i,r,o),c=b.set(e,t,s);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(c.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,n||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const f=!n||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold)&&A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(f)}lerpLookAt(e,t,s,i,r,o,n,a,c,f,m,C,p,u=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0;const g=b.set(i,r,o),y=P.set(e,t,s);k.setFromVector3(y.sub(g).applyQuaternion(this._yAxisUpSpace));const l=K.set(f,m,C),_=P.set(n,a,c);ne.setFromVector3(_.sub(l).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(g.lerp(l,p));const E=ne.theta-k.theta,O=ne.phi-k.phi,x=ne.radius-k.radius;this._sphericalEnd.set(k.radius+x*p,k.phi+O*p,k.theta+E*p),this.normalizeRotations(),this._needsUpdate=!0,u||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!u||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold)&&A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}setPosition(e,t,s,i=!1){return this.setLookAt(e,t,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(e,t,s,i=!1){const r=this.getPosition(b),o=this.setLookAt(r.x,r.y,r.z,e,t,s,i);return this._sphericalEnd.phi=F(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,s,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,s),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const r=!i||A(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&A(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&A(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),N.setFromMatrixColumn(this._camera.matrixWorldInverse,0),H.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Z.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=b.set(e,t,s),r=i.distanceTo(this._camera.position),o=i.sub(this._camera.position);N.multiplyScalar(o.x),H.multiplyScalar(o.y),Z.multiplyScalar(o.z),b.copy(N).add(H).add(Z),b.z=b.z+r,this.dollyTo(r,!1),this.setFocalOffset(-b.x,b.y,-b.z,!1),this.moveTo(e,t,s,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,s,i){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new w.Vector4,typeof e=="number"?this._viewport.set(e,t,s,i):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,i=!1){if(Oe(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,o=this._camera.getEffectiveFOV()*se,n=this._camera.aspect;return((i?r>n:r<n)?t:e/n)*.5/Math.tan(o*.5)+s*.5}getDistanceToFitSphere(e){if(Oe(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*se,s=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,i=1<this._camera.aspect?t:s;return e/Math.sin(i*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new w.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new w.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new w.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new w.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%W,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=W),this._spherical.theta+=W*Math.round((this._sphericalEnd.theta-this._spherical.theta)/W)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!A(this._camera.up.x,this._cameraUp0.x)||!A(this._camera.up.y,this._cameraUp0.y)||!A(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(b);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,ce),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=b.subVectors(this._target,this._camera.position).normalize(),t=P.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(b);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,s=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,r=He.subVectors(this._targetEnd,this._target),o=Ie.subVectors(this._focalOffsetEnd,this._focalOffset),n=this._zoomEnd-this._zoom;if(M(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=le(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,e),this._needsUpdate=!0}if(M(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=le(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,e),this._needsUpdate=!0}if(M(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=le(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,e),this._needsUpdate=!0}if(M(r.x)&&M(r.y)&&M(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Fe(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(M(o.x)&&M(o.y)&&M(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Fe(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(M(n))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=le(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,e)}if(this.dollyToCursor){if(Y(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,C=this._camera,p=this._getCameraDirection(oe),u=b.copy(p).cross(C.up).normalize();u.lengthSq()===0&&(u.x=1);const g=P.crossVectors(u,p),y=this._sphericalEnd.radius*Math.tan(C.getEffectiveFOV()*se*.5),_=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=K.copy(this._targetEnd).add(u.multiplyScalar(this._dollyControlCoord.x*y*C.aspect)).add(g.multiplyScalar(this._dollyControlCoord.y*y)),O=b.copy(this._targetEnd).lerp(E,_),x=this._lastDollyDirection===q.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===q.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(x||T)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const D=P.copy(p).multiplyScalar(-m);O.add(D)}this._boundary.clampPoint(O,O);const L=P.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(L),this._changedDolly-=m,M(this._changedDolly)&&(this._changedDolly=0)}else if(j(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,C=this._camera,p=b.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(C.near+C.far)/(C.near-C.far)).unproject(C),u=P.set(0,0,-1).applyQuaternion(C.quaternion),g=K.copy(p).add(u.multiplyScalar(-p.dot(C.up))),l=-(this._zoom-m-this._zoom)/this._zoom,_=this._getCameraDirection(oe),E=this._targetEnd.dot(_),O=b.copy(this._targetEnd).lerp(g,l),x=O.dot(_),T=_.multiplyScalar(x-E);O.sub(T),this._boundary.clampPoint(O,O);const L=P.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(L),this._changedZoom-=m,M(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!M(this._focalOffset.x)||!M(this._focalOffset.y)||!M(this._focalOffset.z))&&(N.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),Z.setFromMatrixColumn(this._camera.matrix,2),N.multiplyScalar(this._focalOffset.x),H.multiplyScalar(-this._focalOffset.y),Z.multiplyScalar(this._focalOffset.z),b.copy(N).add(H).add(Z),this._camera.position.add(b),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),b.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const f=this._needsUpdate;return f&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):f?(this.dispatchEvent({type:"update"}),M(t,this.restThreshold)&&M(s,this.restThreshold)&&M(i,this.restThreshold)&&M(r.x,this.restThreshold)&&M(r.y,this.restThreshold)&&M(r.z,this.restThreshold)&&M(o.x,this.restThreshold)&&M(o.y,this.restThreshold)&&M(o.z,this.restThreshold)&&M(n,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!f&&this._updatedLastTime&&(this._hasRested||(this._hasRested=!0,this.dispatchEvent({type:"rest"})),this.dispatchEvent({type:"sleep"})),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=f,this._needsUpdate=!1,f}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ie(this.maxDistance),minZoom:this.minZoom,maxZoom:ie(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ie(this.maxPolarAngle),minAzimuthAngle:ie(this.minAzimuthAngle),maxAzimuthAngle:ie(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:b.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const s=JSON.parse(e);this.enabled=s.enabled,this.minDistance=s.minDistance,this.maxDistance=re(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=re(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=re(s.maxPolarAngle),this.minAzimuthAngle=re(s.minAzimuthAngle),this.maxAzimuthAngle=re(s.maxAzimuthAngle),this.smoothTime=s.smoothTime,this.draggingSmoothTime=s.draggingSmoothTime,this.dollySpeed=s.dollySpeed,this.truckSpeed=s.truckSpeed,this.dollyToCursor=s.dollyToCursor,this._target0.fromArray(s.target0),this._position0.fromArray(s.position0),this._zoom0=s.zoom0,this._focalOffset0.fromArray(s.focalOffset0),this.moveTo(s.target[0],s.target[1],s.target[2],t),k.setFromVector3(b.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(k.theta,k.phi,t),this.dollyTo(k.radius,t),this.zoomTo(s.zoom,t),this.setFocalOffset(s.focalOffset[0],s.focalOffset[1],s.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,s){const i=t.lengthSq();if(i===0)return e;const r=P.copy(t).add(e),n=this._boundary.clampPoint(r,K).sub(r),a=n.lengthSq();if(a===0)return e.add(t);if(a===i)return e;if(s===0)return e.add(t).add(n);{const c=1+s*a/t.dot(n);return e.add(P.copy(t).multiplyScalar(c)).add(n.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(Y(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*se,i=Math.tan(s*.5)*t,r=i*e.aspect;this._nearPlaneCorners[0].set(-r,-i,0),this._nearPlaneCorners[1].set(r,-i,0),this._nearPlaneCorners[2].set(r,i,0),this._nearPlaneCorners[3].set(-r,i,0)}else if(j(this._camera)){const e=this._camera,t=1/e.zoom,s=e.left*t,i=e.right*t,r=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(s,r,0),this._nearPlaneCorners[1].set(i,r,0),this._nearPlaneCorners[2].set(i,o,0),this._nearPlaneCorners[3].set(s,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Oe(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(oe);xe.lookAt(Ne,s,this._camera.up);for(let i=0;i<4;i++){const r=P.copy(this._nearPlaneCorners[i]);r.applyMatrix4(xe);const o=K.addVectors(this._target,r);de.set(o,s),de.far=this._spherical.radius+1;const n=de.intersectObjects(this.colliderMeshes);n.length!==0&&n[0].distance<e&&(e=n[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const s=()=>{this.removeEventListener("rest",s),t()};this.addEventListener("rest",s)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new w.Sphere){const s=t,i=s.center;G.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&G.expandByObject(o)}),G.getCenter(i);let r=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const n=o;if(!n.geometry)return;const a=n.geometry.clone();a.applyMatrix4(n.matrixWorld);const f=a.attributes.position;for(let m=0,C=f.count;m<C;m++)b.fromBufferAttribute(f,m),r=Math.max(r,i.distanceToSquared(b))}),s.radius=Math.sqrt(r),s}}var Ae={exports:{}},$=typeof Reflect=="object"?Reflect:null,Ve=$&&typeof $.apply=="function"?$.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)},pe;$&&typeof $.ownKeys=="function"?pe=$.ownKeys:Object.getOwnPropertySymbols?pe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pe=function(e){return Object.getOwnPropertyNames(e)};function Ft(h){console&&console.warn&&console.warn(h)}var tt=Number.isNaN||function(e){return e!==e};function S(){S.init.call(this)}Ae.exports=S;Ae.exports.once=jt;S.EventEmitter=S;S.prototype._events=void 0;S.prototype._eventsCount=0;S.prototype._maxListeners=void 0;var Ye=10;function _e(h){if(typeof h!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof h)}Object.defineProperty(S,"defaultMaxListeners",{enumerable:!0,get:function(){return Ye},set:function(h){if(typeof h!="number"||h<0||tt(h))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+h+".");Ye=h}});S.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};S.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||tt(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function st(h){return h._maxListeners===void 0?S.defaultMaxListeners:h._maxListeners}S.prototype.getMaxListeners=function(){return st(this)};S.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var i=e==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var n=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw n.context=o,n}var a=r[e];if(a===void 0)return!1;if(typeof a=="function")Ve(a,this,t);else for(var c=a.length,f=at(a,c),s=0;s<c;++s)Ve(f[s],this,t);return!0};function it(h,e,t,s){var i,r,o;if(_e(t),r=h._events,r===void 0?(r=h._events=Object.create(null),h._eventsCount=0):(r.newListener!==void 0&&(h.emit("newListener",e,t.listener?t.listener:t),r=h._events),o=r[e]),o===void 0)o=r[e]=t,++h._eventsCount;else if(typeof o=="function"?o=r[e]=s?[t,o]:[o,t]:s?o.unshift(t):o.push(t),i=st(h),i>0&&o.length>i&&!o.warned){o.warned=!0;var n=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");n.name="MaxListenersExceededWarning",n.emitter=h,n.type=e,n.count=o.length,Ft(n)}return h}S.prototype.addListener=function(e,t){return it(this,e,t,!1)};S.prototype.on=S.prototype.addListener;S.prototype.prependListener=function(e,t){return it(this,e,t,!0)};function Nt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function rt(h,e,t){var s={fired:!1,wrapFn:void 0,target:h,type:e,listener:t},i=Nt.bind(s);return i.listener=t,s.wrapFn=i,i}S.prototype.once=function(e,t){return _e(t),this.on(e,rt(this,e,t)),this};S.prototype.prependOnceListener=function(e,t){return _e(t),this.prependListener(e,rt(this,e,t)),this};S.prototype.removeListener=function(e,t){var s,i,r,o,n;if(_e(t),i=this._events,i===void 0)return this;if(s=i[e],s===void 0)return this;if(s===t||s.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,s.listener||t));else if(typeof s!="function"){for(r=-1,o=s.length-1;o>=0;o--)if(s[o]===t||s[o].listener===t){n=s[o].listener,r=o;break}if(r<0)return this;r===0?s.shift():Ht(s,r),s.length===1&&(i[e]=s[0]),i.removeListener!==void 0&&this.emit("removeListener",e,n||t)}return this};S.prototype.off=S.prototype.removeListener;S.prototype.removeAllListeners=function(e){var t,s,i;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[e]),this;if(arguments.length===0){var r=Object.keys(s),o;for(i=0;i<r.length;++i)o=r[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=s[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function ot(h,e,t){var s=h._events;if(s===void 0)return[];var i=s[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t?It(i):at(i,i.length)}S.prototype.listeners=function(e){return ot(this,e,!0)};S.prototype.rawListeners=function(e){return ot(this,e,!1)};S.listenerCount=function(h,e){return typeof h.listenerCount=="function"?h.listenerCount(e):nt.call(h,e)};S.prototype.listenerCount=nt;function nt(h){var e=this._events;if(e!==void 0){var t=e[h];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}S.prototype.eventNames=function(){return this._eventsCount>0?pe(this._events):[]};function at(h,e){for(var t=new Array(e),s=0;s<e;++s)t[s]=h[s];return t}function Ht(h,e){for(;e+1<h.length;e++)h[e]=h[e+1];h.pop()}function It(h){for(var e=new Array(h.length),t=0;t<e.length;++t)e[t]=h[t].listener||h[t];return e}function jt(h,e){return new Promise(function(t,s){function i(o){h.removeListener(e,r),s(o)}function r(){typeof h.removeListener=="function"&&h.removeListener("error",i),t([].slice.call(arguments))}lt(h,e,r,{once:!0}),e!=="error"&&Bt(h,i,{once:!0})})}function Bt(h,e,t){typeof h.on=="function"&&lt(h,"error",e,t)}function lt(h,e,t,s){if(typeof h.on=="function")s.once?h.once(e,t):h.on(e,t);else if(typeof h.addEventListener=="function")h.addEventListener(e,function i(r){s.once&&h.removeEventListener(e,i),t(r)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof h)}var ge=Ae.exports;const Vt={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMappingExposure:1,alpha:!1,outputColorSpace:Pe.ColorSpace.sRGB,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,stencil:!1,depth:!1};class Yt{constructor(e){this.options=e;const{width:t,height:s,rendererParams:i}=e,{alpha:r,devicePixelRatio:o,antialias:n,powerPreference:a,toneMappingExposure:c,outputColorSpace:f,logarithmicDepthBuffer:m,preserveDrawingBuffer:C,stencil:p,depth:u}=i,g=new v.WebGLRenderer({alpha:r,antialias:n,powerPreference:a,logarithmicDepthBuffer:m,preserveDrawingBuffer:C,stencil:p,depth:u});g.setSize(t,s),g.setPixelRatio(o),g.toneMappingExposure=c,g.outputColorSpace=f,this.renderer=g}setSize(e,t){this.renderer.setSize(e,t)}setPixelRatio(e){this.renderer.setPixelRatio(e)}render(e,t){this.renderer.render(e,t)}setViewport(e){var a,c;const{x:t,y:s,width:i,height:r}=e,o=(a=e.scissor)!=null?a:!1,n=(c=e.scissorTest)!=null?c:!1;this.renderer.setViewport(t,s,i,r),o&&(this.renderer.setScissor(t,s,i,r),this.renderer.setScissorTest(n))}dispose(){var e,t;this.setSize(1,1),(e=this.renderer)==null||e.clear(),(t=this.renderer)==null||t.dispose()}}const Zt={antialias:!0,devicePixelRatio:window.devicePixelRatio};class qt{constructor(e){this.options=e;const{width:t,height:s,rendererParams:i,renderer:r}=e,{devicePixelRatio:o,antialias:n}=i,a=new r({antialias:n});a.setSize(t,s),a.setPixelRatio(o),this.renderer=a}setSize(e,t){this.renderer.setSize(e,t)}render(e,t){this.renderer.render(e,t)}dispose(){var e,t;this.setSize(1,1),(e=this.renderer)==null||e.clear(),(t=this.renderer)==null||t.dispose()}}let Wt=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}isEnabled(e){return(this.mask&(1<<e|0))!==0}};class J{constructor(){this.event=new ge.EventEmitter,this.controllerMap=new Map,this.activeIndex=-1,this.activeControllerSet=new Set}addController(e,t){const s=new Wt;return s.disableAll(),t!==void 0&&s.set(t),this.controllerMap.set(e,s),t===this.activeIndex&&this.activeControllerSet.add(e),e}removePage(e,t){this.controllerMap.forEach((s,i)=>{s.isEnabled(e)&&(s.disable(e),s.mask===0&&(t==null||t(i),this.controllerMap.delete(i),this.activeControllerSet.delete(i)))})}setPageActive(e,t){this.activeIndex=e,this.activeControllerSet.clear(),this.controller=(Array.from(this.controllerMap.entries()).find(([s,i])=>{const r=i.isEnabled(e);return r&&this.activeControllerSet.add(s),t==null||t(s,r),r})||[])[0],this.event.emit("pageChange",this.controller)}update(e,t){this.activeControllerSet.forEach(s=>{var i;(i=s.update)==null||i.call(s,e,t)})}dispose(){this.controllerMap.forEach((e,t)=>{e.set(0)}),this.removePage(0),this.controllerMap.clear(),this.event.removeAllListeners(),this.activeControllerSet.clear()}}const ht={fov:45,near:1,far:1e3,up:new v.Vector3(0,1,0)};class Kt extends J{constructor(e){super(),this.width=0,this.height=0,this.width=e.width,this.height=e.height}get camera(){return this.controller}addPerspectiveCamera(e=ht,t){const{fov:s,far:i,near:r,up:o,aspect:n}=e,a=n!=null?n:this.width/this.height,c=new v.PerspectiveCamera(s,a,r,i);return c.up=o,this.addController(c,t)}setPageActive(e){super.setPageActive(e,(t,s)=>{s&&this.setAspect(this.width/this.height,t)})}setSize(e,t){this.width=e,this.height=t,this.setAspect(e/t)}setAspect(e,t){const s=t||this.camera;s.aspect!==e&&(s.aspect=e,s.updateProjectionMatrix())}cloneCamera(e){const t=this.addPerspectiveCamera({fov:this.camera.fov,aspect:this.camera.aspect,near:this.camera.near,far:this.camera.far,up:this.camera.up},e);return t.position.copy(this.camera.position),t}sync(e){if(e.type==="PerspectiveCamera"){const t=e;(!this.camera.matrixWorld.equals(t.matrixWorld)||this.camera.far!==t.far||this.camera.near!==t.near||this.camera.fov!==t.fov||this.camera.aspect!==t.aspect)&&this.camera.copy(t)}else{const t=e,s=t.viewMatrix,i=t.inverseViewMatrix,r=new v.Matrix4(i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]),o=new v.Matrix4(s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]),{width:n,height:a}=this,c=n/a;(this.camera.fov!==t.fov||this.camera.aspect!==c||!this.camera.matrixWorld.equals(r)||!this.camera.matrixWorldInverse.equals(o))&&(this.camera.fov=t.fov,this.camera.updateProjectionMatrix(),this.camera.matrixAutoUpdate=!1,this.camera.matrixWorld.copy(r),this.camera.matrixWorldInverse.copy(o),this.camera.aspect=c,this.camera.updateProjectionMatrix())}}}const Gt={background:null};class Xt extends J{get scene(){return this.controller}constructor(e){super(),this.options=e}addScene(e,t){const s=new v.Scene;return e!=null&&e.background&&(s.background=e.background),this.addController(s,t)}removePage(e){super.removePage(e,t=>{const s=new B.ResourceTracker;s.track(t),s.dispose()})}setPageActive(e){super.setPageActive(e,(t,s)=>{t.visible=s})}}class $t{constructor(e){this.helpers={},this.options=e}add(e){const t=e.uuid,{sceneController:s}=this.options;let i=this.helpers[t];if(i===void 0){if(e.isScene)i=new v.AxesHelper(100);else if(e.isCamera)i=new v.CameraHelper(e);else if(e.isPointLight)i=new v.PointLightHelper(e,1);else if(e.isDirectionalLight)i=new v.DirectionalLightHelper(e,1);else if(e.isSpotLight)i=new v.SpotLightHelper(e);else if(e.isHemisphereLight)i=new v.HemisphereLightHelper(e,10);else if(e.isRectAreaLight)i=new Tt.RectAreaLightHelper(e);else{const r=new v.Box3;if(r.setFromObject(e,!0),r.isEmpty()===!1){i=new v.Box3Helper(r);const o=i.material;o.userData.object=e,o.depthTest=!1,o.transparent=!0}else return}s.scene.add(i),this.helpers[t]=i}}addViewHelper(){const{cameraController:e,container:t}=this.options,s=new wt.ViewHelper(e.camera,t);t.addEventListener("pointerdown",i=>{i.preventDefault(),s.handleClick(i)}),this.viewHelper=s}remove(e){var i;const t=e.uuid,{sceneController:s}=this.options;if(this.helpers[t]!==void 0){const r=this.helpers[t];s.scene.remove(r),delete this.helpers[t],(i=r.dispose)==null||i.call(r)}}removeAll(){Object.keys(this.helpers).forEach(e=>{this.remove({uuid:e})}),this.helpers={}}removeAllExcludeScene(){Object.keys(this.helpers).forEach(e=>{this.helpers[e]instanceof v.AxesHelper||this.remove({uuid:e})})}update(e,t,s){var r,o;const{cameraController:i}=this.options;Object.values(this.helpers).forEach(n=>{if(n.update&&n.update(),n instanceof v.Box3Helper){const a=n.material,{object:c}=a.userData;c&&n.box.setFromObject(c,!0)}}),((r=this.viewHelper)==null?void 0:r.animating)===!0&&(this.viewHelper.update(e),(o=t.cameraControls)==null||o.setPosition(...i.camera.position.toArray()),this.viewHelper.center.copy(s))}renderViewHelper(e){if(!this.viewHelper)return;const t=e.autoClear;e.autoClear=!1,this.viewHelper.render(e),e.autoClear=t}dispose(){var e;this.helpers={},(e=this.viewHelper)==null||e.dispose()}}class Qt extends J{constructor(e){super(),this.autoRotateSpeed=0,this.options=e;const t={Vector2:v.Vector2,Vector3:v.Vector3,Vector4:v.Vector4,Quaternion:v.Quaternion,Matrix4:v.Matrix4,Spherical:v.Spherical,Box3:v.Box3,Sphere:v.Sphere,Raycaster:v.Raycaster};Q.install({THREE:t})}get cameraControls(){return this.controller}addCameraControls(e,t){const{domElement:s}=this.options.controlsParams,i=new Q(e,s);return i.setLookAt(0,0,400,0,0,0,!1),this.addController(i,t)}setPageActive(e){super.setPageActive(e,(t,s)=>{t.enabled=s})}removePage(e){super.removePage(e,t=>{t.dispose()})}enable(){this.activeControllerSet.forEach(e=>{e.enabled=!0})}disable(){this.activeControllerSet.forEach(e=>{e.enabled=!1})}update(e,t){super.update(e,t),this.autoRotateSpeed&&this.cameraControls&&(this.cameraControls.azimuthAngle+=this.autoRotateSpeed*e*v.MathUtils.DEG2RAD)}}class Jt{constructor(e){this.event=new ge.EventEmitter;const{renderer:t,scene:s,camera:i}=e,r=new xt.TransformControls(i,t.domElement);if(r.getHelper){const o=r.getHelper();if(s.add(o),+v.REVISION<170){const n=r._root;n.dispose=()=>{n.traverse(a=>{a.geometry&&a.geometry.dispose(),a.material&&a.material.dispose()})},r.dispose=()=>{r.disconnect(),n.dispose()}}}else r instanceof v.Object3D&&s.add(r);this.controls=r,this.addEvent()}get detach(){return this.controls.detach.bind(this.controls)}get attach(){return this.controls.attach.bind(this.controls)}addEvent(){let e=null,t=null,s=null;const i=this.controls;i.addEventListener("change",()=>{const r=i.object;r!==void 0&&this.event.emit("change",r)}),i.addEventListener("mouseDown",()=>{const r=i.object;e=r.position.clone(),t=r.rotation.clone(),s=r.scale.clone(),this.event.emit("mouseDown",r)}),i.addEventListener("mouseUp",()=>{const r=i.object;if(r!==void 0)switch(i.getMode()){case"translate":e.equals(r.position)||this.event.emit("translate",r,r.position,e);break;case"rotate":t.equals(r.rotation)||this.event.emit("rotate",r,r.rotation,t);break;case"scale":s.equals(r.scale)||this.event.emit("scale",r,r.scale,s);break}this.event.emit("mouseUp")})}dispose(){var e;this.event.removeAllListeners(),(e=this.controls)==null||e.dispose()}}const Ze=new v.Vector3,es=new v.Quaternion,qe=new v.Vector3,I=new v.Matrix4,ts=new v.Matrix4;class ss{constructor(e={}){const t=this;let s,i,r,o;const n={camera:{style:""},objects:new WeakMap},a=e.element!==void 0?e.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a;const c=document.createElement("div");c.style.transformOrigin="0 0",c.style.pointerEvents="none",a.appendChild(c);const f=document.createElement("div");f.style.transformStyle="preserve-3d",c.appendChild(f),this.getSize=function(){return{width:s,height:i}},this.render=function(y,l){const _=l.projectionMatrix.elements[5]*o;l.view&&l.view.enabled?(c.style.transform=`translate( ${-l.view.offsetX*(s/l.view.width)}px, ${-l.view.offsetY*(i/l.view.height)}px )`,c.style.transform+=`scale( ${l.view.fullWidth/l.view.width}, ${l.view.fullHeight/l.view.height} )`):c.style.transform="",y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),l.parent===null&&l.matrixWorldAutoUpdate===!0&&l.updateMatrixWorld();let E,O;l.isOrthographicCamera&&(E=-(l.right+l.left)/2,O=(l.top+l.bottom)/2);const x=l.view&&l.view.enabled?l.view.height/l.view.fullHeight:1,T=l.isOrthographicCamera?`scale( ${x} )scale(`+_+")translate("+m(E)+"px,"+m(O)+"px)"+C(l.matrixWorldInverse):`scale( ${x} )translateZ(`+_+"px)"+C(l.matrixWorldInverse),D=(l.isPerspectiveCamera?"perspective("+_+"px) ":"")+T+"translate("+r+"px,"+o+"px)";n.camera.style!==D&&(f.style.transform=D,n.camera.style=D),g(y,y,l)},this.setSize=function(y,l){s=y,i=l,r=s/2,o=i/2,a.style.width=y+"px",a.style.height=l+"px",c.style.width=y+"px",c.style.height=l+"px",f.style.width=y+"px",f.style.height=l+"px"};function m(y){return Math.abs(y)<1e-10?0:y}function C(y){const l=y.elements;return"matrix3d("+m(l[0])+","+m(-l[1])+","+m(l[2])+","+m(l[3])+","+m(l[4])+","+m(-l[5])+","+m(l[6])+","+m(l[7])+","+m(l[8])+","+m(-l[9])+","+m(l[10])+","+m(l[11])+","+m(l[12])+","+m(-l[13])+","+m(l[14])+","+m(l[15])+")"}function p(y){const l=y.elements;return"translate(-50%,-50%)"+("matrix3d("+m(l[0])+","+m(l[1])+","+m(l[2])+","+m(l[3])+","+m(-l[4])+","+m(-l[5])+","+m(-l[6])+","+m(-l[7])+","+m(l[8])+","+m(l[9])+","+m(l[10])+","+m(l[11])+","+m(l[12])+","+m(l[13])+","+m(l[14])+","+m(l[15])+")")}function u(y){y.isCSS3DObject&&(y.element.style.display="none");for(let l=0,_=y.children.length;l<_;l++)u(y.children[l])}function g(y,l,_,E){if(y.visible===!1){u(y);return}if(y.isCSS3DObject){const O=y.layers.test(_.layers)===!0,x=y.element;if(x.style.display=O===!0?"":"none",O===!0){y.onBeforeRender(t,l,_);let T;y.isCSS3DSprite?(I.copy(_.matrixWorldInverse),I.transpose(),y.rotation2D!==0&&I.multiply(ts.makeRotationZ(y.rotation2D)),y.matrixWorld.decompose(Ze,es,qe),I.setPosition(Ze),I.scale(qe),I.elements[3]=0,I.elements[7]=0,I.elements[11]=0,I.elements[15]=1,T=p(I)):T=p(y.matrixWorld);const L=n.objects.get(y);if(L===void 0||L.style!==T){x.style.transform=T;const D={style:T};n.objects.set(y,D)}x.parentNode!==f&&f.appendChild(x),y.onAfterRender(t,l,_)}}for(let O=0,x=y.children.length;O<x;O++)g(y.children[O],l,_)}}}const X=new v.Vector3,We=new v.Matrix4,Ke=new v.Matrix4,Ge=new v.Vector3,Xe=new v.Vector3;class is{constructor(e={}){const t=this;let s,i,r,o;const n={objects:new WeakMap},a=e.element!==void 0?e.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a,this.getSize=function(){return{width:s,height:i}},this.render=function(u,g){u.matrixWorldAutoUpdate===!0&&u.updateMatrixWorld(),g.parent===null&&g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),We.copy(g.matrixWorldInverse),Ke.multiplyMatrices(g.projectionMatrix,We),f(u,u,g),p(u)},this.setSize=function(u,g){s=u,i=g,r=s/2,o=i/2,a.style.width=u+"px",a.style.height=g+"px"};function c(u){u.isCSS2DObject&&(u.element.style.display="none");for(let g=0,y=u.children.length;g<y;g++)c(u.children[g])}function f(u,g,y){if(u.visible===!1){c(u);return}if(u.isCSS2DObject){X.setFromMatrixPosition(u.matrixWorld),X.applyMatrix4(Ke);const l=X.z>=-1&&X.z<=1&&u.layers.test(y.layers)===!0,_=u.element;_.style.display=l===!0?"":"none",l===!0&&(u.onBeforeRender(t,g,y),_.style.transform="translate("+-100*u.center.x+"%,"+-100*u.center.y+"%)translate("+(X.x*r+r)+"px,"+(-X.y*o+o)+"px)",_.parentNode!==a&&a.appendChild(_),u.onAfterRender(t,g,y));const E={distanceToCameraSquared:m(y,u)};n.objects.set(u,E)}for(let l=0,_=u.children.length;l<_;l++)f(u.children[l],g,y)}function m(u,g){return Ge.setFromMatrixPosition(u.matrixWorld),Xe.setFromMatrixPosition(g.matrixWorld),Ge.distanceToSquared(Xe)}function C(u){const g=[];return u.traverseVisible(function(y){y.isCSS2DObject&&g.push(y)}),g}function p(u){const g=C(u).sort(function(l,_){if(l.renderOrder!==_.renderOrder)return _.renderOrder-l.renderOrder;const E=n.objects.get(l).distanceToCameraSquared,O=n.objects.get(_).distanceToCameraSquared;return E-O}),y=g.length;for(let l=0,_=g.length;l<_;l++)g[l].element.style.zIndex=y-l}}}const $e={zIndex:"auto"};class rs{constructor(e){this.container=e}addRenderer(e,t){const s=t.container||this.container,i=s.offsetWidth,r=s.offsetHeight,o=e==="css2d"?new is:new ss;o.domElement.style.position="absolute",o.domElement.style.top="0",o.domElement.style.pointerEvents="none",o.domElement.style.zIndex=t.zIndex,o.setSize(i,r),s.appendChild(o.domElement),e==="css2d"?this.css2Drenderer=o:e==="css3d"&&(this.css3Drenderer=o)}setSize(e,t){var s,i;(s=this.css2Drenderer)==null||s.setSize(e,t),(i=this.css3Drenderer)==null||i.setSize(e,t)}render(e,t){var s,i;(s=this.css2Drenderer)==null||s.render(e,t),(i=this.css3Drenderer)==null||i.render(e,t)}dispose(){var e,t;(e=this.css2Drenderer)==null||e.domElement.remove(),(t=this.css3Drenderer)==null||t.domElement.remove(),this.css2Drenderer=void 0,this.css3Drenderer=void 0}}const os={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1},premultiplieAlpha:{value:0}},vertexShader:`
1
+ "use strict";var ut=Object.defineProperty,ft=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var Se=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable;var Me=(h,e,t)=>e in h?ut(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t,z=(h,e)=>{for(var t in e||(e={}))gt.call(e,t)&&Me(h,t,e[t]);if(Se)for(var t of Se(e))yt.call(e,t)&&Me(h,t,e[t]);return h},ee=(h,e)=>ft(h,_t(e));var te=(h,e,t)=>new Promise((s,i)=>{var r=a=>{try{n(t.next(a))}catch(c){i(c)}},o=a=>{try{n(t.throw(a))}catch(c){i(c)}},n=a=>a.done?s(a.value):Promise.resolve(a.value).then(r,o);n((t=t.apply(h,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("three"),vt=require("three/examples/jsm/misc/Timer"),Ct=require("@tweenjs/tween.js"),Ot=require("deepmerge"),Et=require("stats-gl"),Pe=require("./isPlainObject.js"),B=require("./index2.js"),Tt=require("three/examples/jsm/helpers/RectAreaLightHelper"),wt=require("three/examples/jsm/helpers/ViewHelper"),xt=require("three/examples/jsm/controls/TransformControls"),Re=require("three/examples/jsm/postprocessing/EffectComposer"),bt=require("three/examples/jsm/postprocessing/RenderPass"),Lt=require("three/examples/jsm/postprocessing/SSAOPass"),De=require("three/examples/jsm/postprocessing/Pass"),Pt=require("three/examples/jsm/postprocessing/OutputPass"),At=require("three/examples/jsm/postprocessing/ShaderPass"),St=require("three/examples/jsm/postprocessing/UnrealBloomPass");require("three/examples/jsm/renderers/CSS2DRenderer");require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo");require("d3-geo-projection");require("three/examples/jsm/lights/RectAreaLightUniformsLib");require("three/examples/jsm/utils/BufferGeometryUtils");require("three/examples/jsm/lines/LineSegments2");require("three/examples/jsm/lines/LineSegmentsGeometry");require("three/examples/jsm/lines/LineMaterial");require("three-bvh-csg");const Ue=require("three/examples/jsm/loaders/GLTFLoader"),Mt=require("three/examples/jsm/loaders/DRACOLoader"),Rt=require("three/examples/jsm/loaders/EXRLoader"),Dt=require("three/examples/jsm/loaders/LottieLoader"),Le=require("esus-lite");function Ut(h){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>h[t]})}}return e.default=h,Object.freeze(e)}const ve=Ut(Ct),R={LEFT:1,RIGHT:2,MIDDLE:4},d=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768,SCREEN_PAN:65536,TOUCH_SCREEN_PAN:131072,TOUCH_DOLLY_SCREEN_PAN:262144,TOUCH_ZOOM_SCREEN_PAN:524288}),q={NONE:0,IN:1,OUT:-1};function Y(h){return h.isPerspectiveCamera}function j(h){return h.isOrthographicCamera}const W=Math.PI*2,ze=Math.PI/2,et=1e-5,se=Math.PI/180;function F(h,e,t){return Math.max(e,Math.min(t,h))}function M(h,e=et){return Math.abs(h)<e}function A(h,e,t=et){return M(h-e,t)}function ke(h,e){return Math.round(h/e)*e}function ie(h){return isFinite(h)?h:h<0?-Number.MAX_VALUE:Number.MAX_VALUE}function re(h){return Math.abs(h)<Number.MAX_VALUE?h:h*(1/0)}function le(h,e,t,s,i=1/0,r){s=Math.max(1e-4,s);const o=2/s,n=o*r,a=1/(1+n+.48*n*n+.235*n*n*n);let c=h-e;const f=e,m=i*s;c=F(c,-m,m),e=h-c;const C=(t.value+o*c)*r;t.value=(t.value-o*C)*a;let p=e+(c+C)*a;return f-h>0==p>f&&(p=f,t.value=(p-f)/r),p}function Fe(h,e,t,s,i=1/0,r,o){s=Math.max(1e-4,s);const n=2/s,a=n*r,c=1/(1+a+.48*a*a+.235*a*a*a);let f=e.x,m=e.y,C=e.z,p=h.x-f,u=h.y-m,g=h.z-C;const y=f,l=m,_=C,E=i*s,O=E*E,x=p*p+u*u+g*g;if(x>O){const ye=Math.sqrt(x);p=p/ye*E,u=u/ye*E,g=g/ye*E}f=h.x-p,m=h.y-u,C=h.z-g;const T=(t.x+n*p)*r,L=(t.y+n*u)*r,D=(t.z+n*g)*r;t.x=(t.x-n*T)*c,t.y=(t.y-n*L)*c,t.z=(t.z-n*D)*c,o.x=f+(p+T)*c,o.y=m+(u+L)*c,o.z=C+(g+D)*c;const V=y-h.x,ae=l-h.y,ct=_-h.z,dt=o.x-y,mt=o.y-l,pt=o.z-_;return V*dt+ae*mt+ct*pt>0&&(o.x=y,o.y=l,o.z=_,t.x=(o.x-y)/r,t.y=(o.y-l)/r,t.z=(o.z-_)/r),o}function Ce(h,e){e.set(0,0),h.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=h.length,e.y/=h.length}function Oe(h,e){return j(h)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class zt{constructor(){this._listeners={}}addEventListener(e,t){const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const s=this._listeners[e.type];if(s!==void 0){e.target=this;const i=s.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e)}}}const he=1/8,kt=/Mac/.test(navigator.platform);let w,Ne,ce,Ee,U,b,P,K,oe,N,H,Z,He,Ie,k,ne,G,je,Te,Be,we,xe,de;class Q extends zt{static install(e){w=e.THREE,Ne=Object.freeze(new w.Vector3(0,0,0)),ce=Object.freeze(new w.Vector3(0,1,0)),Ee=Object.freeze(new w.Vector3(0,0,1)),U=new w.Vector2,b=new w.Vector3,P=new w.Vector3,K=new w.Vector3,oe=new w.Vector3,N=new w.Vector3,H=new w.Vector3,Z=new w.Vector3,He=new w.Vector3,Ie=new w.Vector3,k=new w.Spherical,ne=new w.Spherical,G=new w.Box3,je=new w.Box3,Te=new w.Sphere,Be=new w.Quaternion,we=new w.Quaternion,xe=new w.Matrix4,de=new w.Raycaster}static get ACTION(){return d}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=d.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=q.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new w.Vector3,this._focalOffsetVelocity=new w.Vector3,this._zoomVelocity={value:0},this._truckInternal=(l,_,E,O)=>{let x,T;if(Y(this._camera)){const L=b.copy(this._camera.position).sub(this._target),D=this._camera.getEffectiveFOV()*se,V=L.length()*Math.tan(D*.5);x=this.truckSpeed*l*V/this._elementRect.height,T=this.truckSpeed*_*V/this._elementRect.height}else if(j(this._camera)){const L=this._camera;x=this.truckSpeed*l*(L.right-L.left)/L.zoom/this._elementRect.width,T=this.truckSpeed*_*(L.top-L.bottom)/L.zoom/this._elementRect.height}else return;O?(E?this.setFocalOffset(this._focalOffsetEnd.x+x,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(x,0,!0),this.forward(-T,!0)):E?this.setFocalOffset(this._focalOffsetEnd.x+x,this._focalOffsetEnd.y+T,this._focalOffsetEnd.z,!0):this.truck(x,T,!0)},this._rotateInternal=(l,_)=>{const E=W*this.azimuthRotateSpeed*l/this._elementRect.height,O=W*this.polarRotateSpeed*_/this._elementRect.height;this.rotate(E,O,!0)},this._dollyInternal=(l,_,E)=>{const O=Math.pow(.95,-l*this.dollySpeed),x=this._sphericalEnd.radius,T=this._sphericalEnd.radius*O,L=F(T,this.minDistance,this.maxDistance),D=L-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(D,!0),this._dollyToNoClamp(L,!0)):this._dollyToNoClamp(L,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:L)-x,this._dollyControlCoord.set(_,E)),this._lastDollyDirection=Math.sign(-l)},this._zoomInternal=(l,_,E)=>{const O=Math.pow(.95,l*this.dollySpeed),x=this._zoom,T=this._zoom*O;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-x,this._dollyControlCoord.set(_,E))},typeof w=="undefined"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new w.Quaternion().setFromUnitVectors(this._camera.up,ce),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=d.NONE,this._target=new w.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new w.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new w.Spherical().setFromVector3(b.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new w.Vector3,new w.Vector3,new w.Vector3,new w.Vector3],this._updateNearPlaneCorners(),this._boundary=new w.Box3(new w.Vector3(-1/0,-1/0,-1/0),new w.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new w.Vector2,this.mouseButtons={left:d.ROTATE,middle:d.DOLLY,right:d.TRUCK,wheel:Y(this._camera)?d.DOLLY:j(this._camera)?d.ZOOM:d.NONE},this.touches={one:d.TOUCH_ROTATE,two:Y(this._camera)?d.TOUCH_DOLLY_TRUCK:j(this._camera)?d.TOUCH_ZOOM_TRUCK:d.NONE,three:d.TOUCH_TRUCK};const s=new w.Vector2,i=new w.Vector2,r=new w.Vector2,o=l=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),x=(l.clientX-O.left)/(O.right-O.left),T=(l.clientY-O.top)/(O.bottom-O.top);if(x<this._interactiveArea.left||x>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const _=l.pointerType!=="mouse"?null:(l.buttons&R.LEFT)===R.LEFT?R.LEFT:(l.buttons&R.MIDDLE)===R.MIDDLE?R.MIDDLE:(l.buttons&R.RIGHT)===R.RIGHT?R.RIGHT:null;if(_!==null){const O=this._findPointerByMouseButton(_);O&&this._disposePointer(O)}if((l.buttons&R.LEFT)===R.LEFT&&this._lockedPointer)return;const E={pointerId:l.pointerId,clientX:l.clientX,clientY:l.clientY,deltaX:0,deltaY:0,mouseButton:_};this._activePointers.push(E),this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.ownerDocument.addEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",a),this._isDragging=!0,C(l)},n=l=>{l.cancelable&&l.preventDefault();const _=l.pointerId,E=this._lockedPointer||this._findPointerById(_);if(E){if(E.clientX=l.clientX,E.clientY=l.clientY,E.deltaX=l.movementX,E.deltaY=l.movementY,this._state=0,l.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(l.buttons&R.LEFT)===R.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(l.buttons&R.MIDDLE)===R.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(l.buttons&R.RIGHT)===R.RIGHT&&(this._state=this._state|this.mouseButtons.right);p()}},a=l=>{const _=this._findPointerById(l.pointerId);if(!(_&&_===this._lockedPointer)){if(_&&this._disposePointer(_),l.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=d.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=d.NONE;u()}};let c=-1;const f=l=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===d.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const T=this._domElement.getBoundingClientRect(),L=(l.clientX-T.left)/(T.right-T.left),D=(l.clientY-T.top)/(T.bottom-T.top);if(L<this._interactiveArea.left||L>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}if(l.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===d.ROTATE||this.mouseButtons.wheel===d.TRUCK){const T=performance.now();c-T<1e3&&this._getClientRect(this._elementRect),c=T}const _=kt?-1:-3,E=l.deltaMode===1||l.ctrlKey?l.deltaY/_:l.deltaY/(_*10),O=this.dollyToCursor?(l.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(l.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case d.ROTATE:{this._rotateInternal(l.deltaX,l.deltaY),this._isUserControllingRotate=!0;break}case d.TRUCK:{this._truckInternal(l.deltaX,l.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case d.SCREEN_PAN:{this._truckInternal(l.deltaX,l.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case d.OFFSET:{this._truckInternal(l.deltaX,l.deltaY,!0,!1),this._isUserControllingOffset=!0;break}case d.DOLLY:{this._dollyInternal(-E,O,x),this._isUserControllingDolly=!0;break}case d.ZOOM:{this._zoomInternal(-E,O,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=l=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Q.ACTION.NONE){const _=l instanceof PointerEvent?l.pointerId:0,E=this._findPointerById(_);E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a);return}l.preventDefault()}},C=l=>{if(!this._enabled)return;if(Ce(this._activePointers,U),this._getClientRect(this._elementRect),s.copy(U),i.copy(U),this._activePointers.length>=2){const E=U.x-this._activePointers[1].clientX,O=U.y-this._activePointers[1].clientY,x=Math.sqrt(E*E+O*O);r.set(0,x);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,L=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(T,L)}if(this._state=0,!l)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in l&&l.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(l.buttons&R.LEFT)===R.LEFT&&(this._state=this._state|this.mouseButtons.left),(l.buttons&R.MIDDLE)===R.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(l.buttons&R.RIGHT)===R.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&d.ROTATE)===d.ROTATE||(this._state&d.TOUCH_ROTATE)===d.TOUCH_ROTATE||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE||(this._state&d.TOUCH_ZOOM_ROTATE)===d.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&d.TRUCK)===d.TRUCK||(this._state&d.SCREEN_PAN)===d.SCREEN_PAN||(this._state&d.TOUCH_TRUCK)===d.TOUCH_TRUCK||(this._state&d.TOUCH_SCREEN_PAN)===d.TOUCH_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_ZOOM_TRUCK)===d.TOUCH_ZOOM_TRUCK||(this._state&d.TOUCH_ZOOM_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&d.DOLLY)===d.DOLLY||(this._state&d.TOUCH_DOLLY)===d.TOUCH_DOLLY||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&d.ZOOM)===d.ZOOM||(this._state&d.TOUCH_ZOOM)===d.TOUCH_ZOOM||(this._state&d.TOUCH_ZOOM_TRUCK)===d.TOUCH_ZOOM_TRUCK||(this._state&d.TOUCH_ZOOM_SCREEN_PAN)===d.TOUCH_ZOOM_SCREEN_PAN||(this._state&d.TOUCH_ZOOM_OFFSET)===d.TOUCH_ZOOM_OFFSET||(this._state&d.TOUCH_ZOOM_ROTATE)===d.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&d.OFFSET)===d.OFFSET||(this._state&d.TOUCH_OFFSET)===d.TOUCH_OFFSET||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET||(this._state&d.TOUCH_ZOOM_OFFSET)===d.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},p=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,Ce(this._activePointers,U);const _=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,E=_?-_.deltaX:i.x-U.x,O=_?-_.deltaY:i.y-U.y;if(i.copy(U),((this._state&d.ROTATE)===d.ROTATE||(this._state&d.TOUCH_ROTATE)===d.TOUCH_ROTATE||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE||(this._state&d.TOUCH_ZOOM_ROTATE)===d.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(E,O),this._isUserControllingRotate=!0),(this._state&d.DOLLY)===d.DOLLY||(this._state&d.ZOOM)===d.ZOOM){const x=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,L=this.dollyDragInverted?-1:1;(this._state&d.DOLLY)===d.DOLLY?(this._dollyInternal(L*O*he,x,T),this._isUserControllingDolly=!0):(this._zoomInternal(L*O*he,x,T),this._isUserControllingZoom=!0)}if((this._state&d.TOUCH_DOLLY)===d.TOUCH_DOLLY||(this._state&d.TOUCH_ZOOM)===d.TOUCH_ZOOM||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_ZOOM_TRUCK)===d.TOUCH_ZOOM_TRUCK||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_ZOOM_SCREEN_PAN)===d.TOUCH_ZOOM_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET||(this._state&d.TOUCH_ZOOM_OFFSET)===d.TOUCH_ZOOM_OFFSET||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE||(this._state&d.TOUCH_ZOOM_ROTATE)===d.TOUCH_ZOOM_ROTATE){const x=U.x-this._activePointers[1].clientX,T=U.y-this._activePointers[1].clientY,L=Math.sqrt(x*x+T*T),D=r.y-L;r.set(0,L);const V=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,ae=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&d.TOUCH_DOLLY)===d.TOUCH_DOLLY||(this._state&d.TOUCH_DOLLY_ROTATE)===d.TOUCH_DOLLY_ROTATE||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET?(this._dollyInternal(D*he,V,ae),this._isUserControllingDolly=!0):(this._zoomInternal(D*he,V,ae),this._isUserControllingZoom=!0)}((this._state&d.TRUCK)===d.TRUCK||(this._state&d.TOUCH_TRUCK)===d.TOUCH_TRUCK||(this._state&d.TOUCH_DOLLY_TRUCK)===d.TOUCH_DOLLY_TRUCK||(this._state&d.TOUCH_ZOOM_TRUCK)===d.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(E,O,!1,!1),this._isUserControllingTruck=!0),((this._state&d.SCREEN_PAN)===d.SCREEN_PAN||(this._state&d.TOUCH_SCREEN_PAN)===d.TOUCH_SCREEN_PAN||(this._state&d.TOUCH_DOLLY_SCREEN_PAN)===d.TOUCH_DOLLY_SCREEN_PAN||(this._state&d.TOUCH_ZOOM_SCREEN_PAN)===d.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(E,O,!1,!0),this._isUserControllingTruck=!0),((this._state&d.OFFSET)===d.OFFSET||(this._state&d.TOUCH_OFFSET)===d.TOUCH_OFFSET||(this._state&d.TOUCH_DOLLY_OFFSET)===d.TOUCH_DOLLY_OFFSET||(this._state&d.TOUCH_ZOOM_OFFSET)===d.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(E,O,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},u=()=>{Ce(this._activePointers,U),i.copy(U),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",g),this._domElement.ownerDocument.addEventListener("pointerlockerror",y),this._domElement.ownerDocument.addEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",a),C())},this.unlockPointer=()=>{var l,_,E;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(l=this._domElement)===null||l===void 0||l.ownerDocument.exitPointerLock(),(_=this._domElement)===null||_===void 0||_.ownerDocument.removeEventListener("pointerlockchange",g),(E=this._domElement)===null||E===void 0||E.ownerDocument.removeEventListener("pointerlockerror",y),this.cancel()};const g=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},y=()=>{this.unlockPointer()};this._addAllEventListeners=l=>{this._domElement=l,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",a),this._domElement.addEventListener("wheel",f,{passive:!1}),this._domElement.addEventListener("contextmenu",m)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",a),this._domElement.removeEventListener("wheel",f,{passive:!1}),this._domElement.removeEventListener("contextmenu",m),this._domElement.ownerDocument.removeEventListener("pointermove",n,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement.ownerDocument.removeEventListener("pointerlockerror",y))},this.cancel=()=>{this._state!==d.NONE&&(this._state=d.NONE,this._activePointers.length=0,u())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=F(e.width,0,1),this._interactiveArea.height=F(e.height,0,1),this._interactiveArea.x=F(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=F(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,s=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,s)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,s=!1){this._isUserControllingRotate=!1;const i=F(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=F(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!s||A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0,this._dollyToNoClamp(F(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),n=A(o,this._spherical.radius);if(!(s>e)&&n)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(oe).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=F(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||A(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(e,t,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,s)}truck(e,t,s=!1){this._camera.updateMatrix(),N.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),N.multiplyScalar(e),H.multiplyScalar(-t);const i=b.copy(N).add(H),r=P.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,s)}forward(e,t=!1){b.setFromMatrixColumn(this._camera.matrix,0),b.crossVectors(this._camera.up,b),b.multiplyScalar(e);const s=P.copy(this._targetEnd).add(b);return this.moveTo(s.x,s.y,s.z,t)}elevate(e,t=!1){return b.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+b.x,this._targetEnd.y+b.y,this._targetEnd.z+b.z,t)}moveTo(e,t,s,i=!1){this._isUserControllingTruck=!1;const r=b.set(e,t,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const o=!i||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,s,i=!1){const n=b.set(e,t,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(n.x,n.y,n.z,i)}fitToBox(e,t,{cover:s=!1,paddingLeft:i=0,paddingRight:r=0,paddingBottom:o=0,paddingTop:n=0}={}){const a=[],c=e.isBox3?G.copy(e):G.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const f=ke(this._sphericalEnd.theta,ze),m=ke(this._sphericalEnd.phi,ze);a.push(this.rotateTo(f,m,t));const C=b.setFromSpherical(this._sphericalEnd).normalize(),p=Be.setFromUnitVectors(C,Ee),u=A(Math.abs(C.y),1);u&&p.multiply(we.setFromAxisAngle(ce,f)),p.multiply(this._yAxisUpSpaceInverse);const g=je.makeEmpty();P.copy(c.min).applyQuaternion(p),g.expandByPoint(P),P.copy(c.min).setX(c.max.x).applyQuaternion(p),g.expandByPoint(P),P.copy(c.min).setY(c.max.y).applyQuaternion(p),g.expandByPoint(P),P.copy(c.max).setZ(c.min.z).applyQuaternion(p),g.expandByPoint(P),P.copy(c.min).setZ(c.max.z).applyQuaternion(p),g.expandByPoint(P),P.copy(c.max).setY(c.min.y).applyQuaternion(p),g.expandByPoint(P),P.copy(c.max).setX(c.min.x).applyQuaternion(p),g.expandByPoint(P),P.copy(c.max).applyQuaternion(p),g.expandByPoint(P),g.min.x-=i,g.min.y-=o,g.max.x+=r,g.max.y+=n,p.setFromUnitVectors(Ee,C),u&&p.premultiply(we.invert()),p.premultiply(this._yAxisUpSpace);const y=g.getSize(b),l=g.getCenter(P).applyQuaternion(p);if(Y(this._camera)){const _=this.getDistanceToFitBox(y.x,y.y,y.z,s);a.push(this.moveTo(l.x,l.y,l.z,t)),a.push(this.dollyTo(_,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(j(this._camera)){const _=this._camera,E=_.right-_.left,O=_.top-_.bottom,x=s?Math.max(E/y.x,O/y.y):Math.min(E/y.x,O/y.y);a.push(this.moveTo(l.x,l.y,l.z,t)),a.push(this.zoomTo(x,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const s=[],r="isObject3D"in e?Q.createBoundingSphere(e,Te):Te.copy(e);if(s.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),Y(this._camera)){const o=this.getDistanceToFitSphere(r.radius);s.push(this.dollyTo(o,t))}else if(j(this._camera)){const o=this._camera.right-this._camera.left,n=this._camera.top-this._camera.bottom,a=2*r.radius,c=Math.min(o/a,n/a);s.push(this.zoomTo(c,t))}return s.push(this.setFocalOffset(0,0,0,t)),Promise.all(s)}setLookAt(e,t,s,i,r,o,n=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0;const a=P.set(i,r,o),c=b.set(e,t,s);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(c.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,n||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const f=!n||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold)&&A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(f)}lerpLookAt(e,t,s,i,r,o,n,a,c,f,m,C,p,u=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0;const g=b.set(i,r,o),y=P.set(e,t,s);k.setFromVector3(y.sub(g).applyQuaternion(this._yAxisUpSpace));const l=K.set(f,m,C),_=P.set(n,a,c);ne.setFromVector3(_.sub(l).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(g.lerp(l,p));const E=ne.theta-k.theta,O=ne.phi-k.phi,x=ne.radius-k.radius;this._sphericalEnd.set(k.radius+x*p,k.phi+O*p,k.theta+E*p),this.normalizeRotations(),this._needsUpdate=!0,u||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!u||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold)&&A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}setPosition(e,t,s,i=!1){return this.setLookAt(e,t,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(e,t,s,i=!1){const r=this.getPosition(b),o=this.setLookAt(r.x,r.y,r.z,e,t,s,i);return this._sphericalEnd.phi=F(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,s,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,s),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const r=!i||A(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&A(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&A(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),N.setFromMatrixColumn(this._camera.matrixWorldInverse,0),H.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Z.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=b.set(e,t,s),r=i.distanceTo(this._camera.position),o=i.sub(this._camera.position);N.multiplyScalar(o.x),H.multiplyScalar(o.y),Z.multiplyScalar(o.z),b.copy(N).add(H).add(Z),b.z=b.z+r,this.dollyTo(r,!1),this.setFocalOffset(-b.x,b.y,-b.z,!1),this.moveTo(e,t,s,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,s,i){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new w.Vector4,typeof e=="number"?this._viewport.set(e,t,s,i):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,i=!1){if(Oe(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,o=this._camera.getEffectiveFOV()*se,n=this._camera.aspect;return((i?r>n:r<n)?t:e/n)*.5/Math.tan(o*.5)+s*.5}getDistanceToFitSphere(e){if(Oe(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*se,s=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,i=1<this._camera.aspect?t:s;return e/Math.sin(i*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new w.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new w.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new w.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new w.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%W,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=W),this._spherical.theta+=W*Math.round((this._sphericalEnd.theta-this._spherical.theta)/W)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!A(this._camera.up.x,this._cameraUp0.x)||!A(this._camera.up.y,this._cameraUp0.y)||!A(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(b);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,ce),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=b.subVectors(this._target,this._camera.position).normalize(),t=P.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(b);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,s=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,r=He.subVectors(this._targetEnd,this._target),o=Ie.subVectors(this._focalOffsetEnd,this._focalOffset),n=this._zoomEnd-this._zoom;if(M(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=le(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,e),this._needsUpdate=!0}if(M(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=le(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,e),this._needsUpdate=!0}if(M(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=le(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,e),this._needsUpdate=!0}if(M(r.x)&&M(r.y)&&M(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Fe(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(M(o.x)&&M(o.y)&&M(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Fe(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(M(n))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=le(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,e)}if(this.dollyToCursor){if(Y(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,C=this._camera,p=this._getCameraDirection(oe),u=b.copy(p).cross(C.up).normalize();u.lengthSq()===0&&(u.x=1);const g=P.crossVectors(u,p),y=this._sphericalEnd.radius*Math.tan(C.getEffectiveFOV()*se*.5),_=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=K.copy(this._targetEnd).add(u.multiplyScalar(this._dollyControlCoord.x*y*C.aspect)).add(g.multiplyScalar(this._dollyControlCoord.y*y)),O=b.copy(this._targetEnd).lerp(E,_),x=this._lastDollyDirection===q.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===q.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(x||T)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const D=P.copy(p).multiplyScalar(-m);O.add(D)}this._boundary.clampPoint(O,O);const L=P.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(L),this._changedDolly-=m,M(this._changedDolly)&&(this._changedDolly=0)}else if(j(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,C=this._camera,p=b.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(C.near+C.far)/(C.near-C.far)).unproject(C),u=P.set(0,0,-1).applyQuaternion(C.quaternion),g=K.copy(p).add(u.multiplyScalar(-p.dot(C.up))),l=-(this._zoom-m-this._zoom)/this._zoom,_=this._getCameraDirection(oe),E=this._targetEnd.dot(_),O=b.copy(this._targetEnd).lerp(g,l),x=O.dot(_),T=_.multiplyScalar(x-E);O.sub(T),this._boundary.clampPoint(O,O);const L=P.subVectors(O,this._targetEnd);this._targetEnd.copy(O),this._target.add(L),this._changedZoom-=m,M(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!M(this._focalOffset.x)||!M(this._focalOffset.y)||!M(this._focalOffset.z))&&(N.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),Z.setFromMatrixColumn(this._camera.matrix,2),N.multiplyScalar(this._focalOffset.x),H.multiplyScalar(-this._focalOffset.y),Z.multiplyScalar(this._focalOffset.z),b.copy(N).add(H).add(Z),this._camera.position.add(b),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),b.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const f=this._needsUpdate;return f&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):f?(this.dispatchEvent({type:"update"}),M(t,this.restThreshold)&&M(s,this.restThreshold)&&M(i,this.restThreshold)&&M(r.x,this.restThreshold)&&M(r.y,this.restThreshold)&&M(r.z,this.restThreshold)&&M(o.x,this.restThreshold)&&M(o.y,this.restThreshold)&&M(o.z,this.restThreshold)&&M(n,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!f&&this._updatedLastTime&&(this._hasRested||(this._hasRested=!0,this.dispatchEvent({type:"rest"})),this.dispatchEvent({type:"sleep"})),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=f,this._needsUpdate=!1,f}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ie(this.maxDistance),minZoom:this.minZoom,maxZoom:ie(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ie(this.maxPolarAngle),minAzimuthAngle:ie(this.minAzimuthAngle),maxAzimuthAngle:ie(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:b.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const s=JSON.parse(e);this.enabled=s.enabled,this.minDistance=s.minDistance,this.maxDistance=re(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=re(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=re(s.maxPolarAngle),this.minAzimuthAngle=re(s.minAzimuthAngle),this.maxAzimuthAngle=re(s.maxAzimuthAngle),this.smoothTime=s.smoothTime,this.draggingSmoothTime=s.draggingSmoothTime,this.dollySpeed=s.dollySpeed,this.truckSpeed=s.truckSpeed,this.dollyToCursor=s.dollyToCursor,this._target0.fromArray(s.target0),this._position0.fromArray(s.position0),this._zoom0=s.zoom0,this._focalOffset0.fromArray(s.focalOffset0),this.moveTo(s.target[0],s.target[1],s.target[2],t),k.setFromVector3(b.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(k.theta,k.phi,t),this.dollyTo(k.radius,t),this.zoomTo(s.zoom,t),this.setFocalOffset(s.focalOffset[0],s.focalOffset[1],s.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,s){const i=t.lengthSq();if(i===0)return e;const r=P.copy(t).add(e),n=this._boundary.clampPoint(r,K).sub(r),a=n.lengthSq();if(a===0)return e.add(t);if(a===i)return e;if(s===0)return e.add(t).add(n);{const c=1+s*a/t.dot(n);return e.add(P.copy(t).multiplyScalar(c)).add(n.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(Y(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*se,i=Math.tan(s*.5)*t,r=i*e.aspect;this._nearPlaneCorners[0].set(-r,-i,0),this._nearPlaneCorners[1].set(r,-i,0),this._nearPlaneCorners[2].set(r,i,0),this._nearPlaneCorners[3].set(-r,i,0)}else if(j(this._camera)){const e=this._camera,t=1/e.zoom,s=e.left*t,i=e.right*t,r=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(s,r,0),this._nearPlaneCorners[1].set(i,r,0),this._nearPlaneCorners[2].set(i,o,0),this._nearPlaneCorners[3].set(s,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Oe(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(oe);xe.lookAt(Ne,s,this._camera.up);for(let i=0;i<4;i++){const r=P.copy(this._nearPlaneCorners[i]);r.applyMatrix4(xe);const o=K.addVectors(this._target,r);de.set(o,s),de.far=this._spherical.radius+1;const n=de.intersectObjects(this.colliderMeshes);n.length!==0&&n[0].distance<e&&(e=n[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const s=()=>{this.removeEventListener("rest",s),t()};this.addEventListener("rest",s)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new w.Sphere){const s=t,i=s.center;G.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&G.expandByObject(o)}),G.getCenter(i);let r=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const n=o;if(!n.geometry)return;const a=n.geometry.clone();a.applyMatrix4(n.matrixWorld);const f=a.attributes.position;for(let m=0,C=f.count;m<C;m++)b.fromBufferAttribute(f,m),r=Math.max(r,i.distanceToSquared(b))}),s.radius=Math.sqrt(r),s}}var Ae={exports:{}},$=typeof Reflect=="object"?Reflect:null,Ve=$&&typeof $.apply=="function"?$.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)},pe;$&&typeof $.ownKeys=="function"?pe=$.ownKeys:Object.getOwnPropertySymbols?pe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pe=function(e){return Object.getOwnPropertyNames(e)};function Ft(h){console&&console.warn&&console.warn(h)}var tt=Number.isNaN||function(e){return e!==e};function S(){S.init.call(this)}Ae.exports=S;Ae.exports.once=jt;S.EventEmitter=S;S.prototype._events=void 0;S.prototype._eventsCount=0;S.prototype._maxListeners=void 0;var Ye=10;function _e(h){if(typeof h!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof h)}Object.defineProperty(S,"defaultMaxListeners",{enumerable:!0,get:function(){return Ye},set:function(h){if(typeof h!="number"||h<0||tt(h))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+h+".");Ye=h}});S.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};S.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||tt(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function st(h){return h._maxListeners===void 0?S.defaultMaxListeners:h._maxListeners}S.prototype.getMaxListeners=function(){return st(this)};S.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var i=e==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var n=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw n.context=o,n}var a=r[e];if(a===void 0)return!1;if(typeof a=="function")Ve(a,this,t);else for(var c=a.length,f=at(a,c),s=0;s<c;++s)Ve(f[s],this,t);return!0};function it(h,e,t,s){var i,r,o;if(_e(t),r=h._events,r===void 0?(r=h._events=Object.create(null),h._eventsCount=0):(r.newListener!==void 0&&(h.emit("newListener",e,t.listener?t.listener:t),r=h._events),o=r[e]),o===void 0)o=r[e]=t,++h._eventsCount;else if(typeof o=="function"?o=r[e]=s?[t,o]:[o,t]:s?o.unshift(t):o.push(t),i=st(h),i>0&&o.length>i&&!o.warned){o.warned=!0;var n=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");n.name="MaxListenersExceededWarning",n.emitter=h,n.type=e,n.count=o.length,Ft(n)}return h}S.prototype.addListener=function(e,t){return it(this,e,t,!1)};S.prototype.on=S.prototype.addListener;S.prototype.prependListener=function(e,t){return it(this,e,t,!0)};function Nt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function rt(h,e,t){var s={fired:!1,wrapFn:void 0,target:h,type:e,listener:t},i=Nt.bind(s);return i.listener=t,s.wrapFn=i,i}S.prototype.once=function(e,t){return _e(t),this.on(e,rt(this,e,t)),this};S.prototype.prependOnceListener=function(e,t){return _e(t),this.prependListener(e,rt(this,e,t)),this};S.prototype.removeListener=function(e,t){var s,i,r,o,n;if(_e(t),i=this._events,i===void 0)return this;if(s=i[e],s===void 0)return this;if(s===t||s.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,s.listener||t));else if(typeof s!="function"){for(r=-1,o=s.length-1;o>=0;o--)if(s[o]===t||s[o].listener===t){n=s[o].listener,r=o;break}if(r<0)return this;r===0?s.shift():Ht(s,r),s.length===1&&(i[e]=s[0]),i.removeListener!==void 0&&this.emit("removeListener",e,n||t)}return this};S.prototype.off=S.prototype.removeListener;S.prototype.removeAllListeners=function(e){var t,s,i;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[e]),this;if(arguments.length===0){var r=Object.keys(s),o;for(i=0;i<r.length;++i)o=r[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=s[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function ot(h,e,t){var s=h._events;if(s===void 0)return[];var i=s[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t?It(i):at(i,i.length)}S.prototype.listeners=function(e){return ot(this,e,!0)};S.prototype.rawListeners=function(e){return ot(this,e,!1)};S.listenerCount=function(h,e){return typeof h.listenerCount=="function"?h.listenerCount(e):nt.call(h,e)};S.prototype.listenerCount=nt;function nt(h){var e=this._events;if(e!==void 0){var t=e[h];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}S.prototype.eventNames=function(){return this._eventsCount>0?pe(this._events):[]};function at(h,e){for(var t=new Array(e),s=0;s<e;++s)t[s]=h[s];return t}function Ht(h,e){for(;e+1<h.length;e++)h[e]=h[e+1];h.pop()}function It(h){for(var e=new Array(h.length),t=0;t<e.length;++t)e[t]=h[t].listener||h[t];return e}function jt(h,e){return new Promise(function(t,s){function i(o){h.removeListener(e,r),s(o)}function r(){typeof h.removeListener=="function"&&h.removeListener("error",i),t([].slice.call(arguments))}lt(h,e,r,{once:!0}),e!=="error"&&Bt(h,i,{once:!0})})}function Bt(h,e,t){typeof h.on=="function"&&lt(h,"error",e,t)}function lt(h,e,t,s){if(typeof h.on=="function")s.once?h.once(e,t):h.on(e,t);else if(typeof h.addEventListener=="function")h.addEventListener(e,function i(r){s.once&&h.removeEventListener(e,i),t(r)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof h)}var ge=Ae.exports;const Vt={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMappingExposure:1,alpha:!1,outputColorSpace:Pe.ColorSpace.sRGB,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,stencil:!1,depth:!1};class Yt{constructor(e){this.options=e;const{width:t,height:s,rendererParams:i}=e,{alpha:r,devicePixelRatio:o,antialias:n,powerPreference:a,toneMappingExposure:c,outputColorSpace:f,logarithmicDepthBuffer:m,preserveDrawingBuffer:C,stencil:p,depth:u}=i,g=new v.WebGLRenderer({alpha:r,antialias:n,powerPreference:a,logarithmicDepthBuffer:m,preserveDrawingBuffer:C,stencil:p,depth:u});g.setSize(t,s),g.setPixelRatio(o),g.toneMappingExposure=c,g.outputColorSpace=f,this.renderer=g}setSize(e,t){this.renderer.setSize(e,t)}setPixelRatio(e){this.renderer.setPixelRatio(e)}render(e,t){this.renderer.render(e,t)}setViewport(e){var a,c;const{x:t,y:s,width:i,height:r}=e,o=(a=e.scissor)!=null?a:!1,n=(c=e.scissorTest)!=null?c:!1;this.renderer.setViewport(t,s,i,r),o&&(this.renderer.setScissor(t,s,i,r),this.renderer.setScissorTest(n))}dispose(){var e,t;this.setSize(1,1),(e=this.renderer)==null||e.clear(),(t=this.renderer)==null||t.dispose()}}const Zt={antialias:!0,devicePixelRatio:window.devicePixelRatio};class qt{constructor(e){this.options=e;const{width:t,height:s,rendererParams:i,renderer:r}=e,{devicePixelRatio:o,antialias:n}=i,a=new r({antialias:n});a.setSize(t,s),a.setPixelRatio(o),this.renderer=a}setSize(e,t){this.renderer.setSize(e,t)}render(e,t){this.renderer.render(e,t)}dispose(){var e,t;this.setSize(1,1),(e=this.renderer)==null||e.clear(),(t=this.renderer)==null||t.dispose()}}let Wt=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}isEnabled(e){return(this.mask&(1<<e|0))!==0}};class J{constructor(){this.event=new ge.EventEmitter,this.controllerMap=new Map,this.activeIndex=-1,this.activeControllerSet=new Set}addController(e,t){const s=new Wt;return s.disableAll(),t!==void 0&&s.set(t),this.controllerMap.set(e,s),t===this.activeIndex&&this.activeControllerSet.add(e),e}removePage(e,t){this.controllerMap.forEach((s,i)=>{s.isEnabled(e)&&(s.disable(e),s.mask===0&&(t==null||t(i),this.controllerMap.delete(i),this.activeControllerSet.delete(i)))})}setPageActive(e,t){this.activeIndex=e,this.activeControllerSet.clear();const s=Array.from(this.controllerMap.entries()).map(([i,r])=>{const o=r.isEnabled(e);if(t==null||t(i,o),o)return this.activeControllerSet.add(i),i}).filter(Boolean);this.controller=s[0],this.event.emit("pageChange",this.controller)}update(e,t){this.activeControllerSet.forEach(s=>{var i;(i=s.update)==null||i.call(s,e,t)})}dispose(){this.controllerMap.forEach((e,t)=>{e.set(0)}),this.removePage(0),this.controllerMap.clear(),this.event.removeAllListeners(),this.activeControllerSet.clear()}}const ht={fov:45,near:1,far:1e3,up:new v.Vector3(0,1,0)};class Kt extends J{constructor(e){super(),this.width=0,this.height=0,this.width=e.width,this.height=e.height}get camera(){return this.controller}addPerspectiveCamera(e=ht,t){const{fov:s,far:i,near:r,up:o,aspect:n}=e,a=n!=null?n:this.width/this.height,c=new v.PerspectiveCamera(s,a,r,i);return c.up=o,this.addController(c,t)}setPageActive(e){super.setPageActive(e,(t,s)=>{s&&this.setAspect(this.width/this.height,t)})}setSize(e,t){this.width=e,this.height=t,this.setAspect(e/t)}setAspect(e,t){const s=t||this.camera;s.aspect!==e&&(s.aspect=e,s.updateProjectionMatrix())}cloneCamera(e){const t=this.addPerspectiveCamera({fov:this.camera.fov,aspect:this.camera.aspect,near:this.camera.near,far:this.camera.far,up:this.camera.up},e);return t.position.copy(this.camera.position),t}sync(e){if(e.type==="PerspectiveCamera"){const t=e;(!this.camera.matrixWorld.equals(t.matrixWorld)||this.camera.far!==t.far||this.camera.near!==t.near||this.camera.fov!==t.fov||this.camera.aspect!==t.aspect)&&this.camera.copy(t)}else{const t=e,s=t.viewMatrix,i=t.inverseViewMatrix,r=new v.Matrix4(i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]),o=new v.Matrix4(s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]),{width:n,height:a}=this,c=n/a;(this.camera.fov!==t.fov||this.camera.aspect!==c||!this.camera.matrixWorld.equals(r)||!this.camera.matrixWorldInverse.equals(o))&&(this.camera.fov=t.fov,this.camera.updateProjectionMatrix(),this.camera.matrixAutoUpdate=!1,this.camera.matrixWorld.copy(r),this.camera.matrixWorldInverse.copy(o),this.camera.aspect=c,this.camera.updateProjectionMatrix())}}}const Gt={background:null};class Xt extends J{get scene(){return this.controller}constructor(e){super(),this.options=e}addScene(e,t){const s=new v.Scene;return e!=null&&e.background&&(s.background=e.background),this.addController(s,t)}removePage(e){super.removePage(e,t=>{const s=new B.ResourceTracker;s.track(t),s.dispose()})}setPageActive(e){super.setPageActive(e,(t,s)=>{t.visible=s})}}class $t{constructor(e){this.helpers={},this.options=e}add(e){const t=e.uuid,{sceneController:s}=this.options;let i=this.helpers[t];if(i===void 0){if(e.isScene)i=new v.AxesHelper(100);else if(e.isCamera)i=new v.CameraHelper(e);else if(e.isPointLight)i=new v.PointLightHelper(e,1);else if(e.isDirectionalLight)i=new v.DirectionalLightHelper(e,1);else if(e.isSpotLight)i=new v.SpotLightHelper(e);else if(e.isHemisphereLight)i=new v.HemisphereLightHelper(e,10);else if(e.isRectAreaLight)i=new Tt.RectAreaLightHelper(e);else{const r=new v.Box3;if(r.setFromObject(e,!0),r.isEmpty()===!1){i=new v.Box3Helper(r);const o=i.material;o.userData.object=e,o.depthTest=!1,o.transparent=!0}else return}s.scene.add(i),this.helpers[t]=i}}addViewHelper(){const{cameraController:e,container:t}=this.options,s=new wt.ViewHelper(e.camera,t);t.addEventListener("pointerdown",i=>{i.preventDefault(),s.handleClick(i)}),this.viewHelper=s}remove(e){var i;const t=e.uuid,{sceneController:s}=this.options;if(this.helpers[t]!==void 0){const r=this.helpers[t];s.scene.remove(r),delete this.helpers[t],(i=r.dispose)==null||i.call(r)}}removeAll(){Object.keys(this.helpers).forEach(e=>{this.remove({uuid:e})}),this.helpers={}}removeAllExcludeScene(){Object.keys(this.helpers).forEach(e=>{this.helpers[e]instanceof v.AxesHelper||this.remove({uuid:e})})}update(e,t,s){var r,o;const{cameraController:i}=this.options;Object.values(this.helpers).forEach(n=>{if(n.update&&n.update(),n instanceof v.Box3Helper){const a=n.material,{object:c}=a.userData;c&&n.box.setFromObject(c,!0)}}),((r=this.viewHelper)==null?void 0:r.animating)===!0&&(this.viewHelper.update(e),(o=t.cameraControls)==null||o.setPosition(...i.camera.position.toArray()),this.viewHelper.center.copy(s))}renderViewHelper(e){if(!this.viewHelper)return;const t=e.autoClear;e.autoClear=!1,this.viewHelper.render(e),e.autoClear=t}dispose(){var e;this.helpers={},(e=this.viewHelper)==null||e.dispose()}}class Qt extends J{constructor(e){super(),this.autoRotateSpeed=0,this.options=e;const t={Vector2:v.Vector2,Vector3:v.Vector3,Vector4:v.Vector4,Quaternion:v.Quaternion,Matrix4:v.Matrix4,Spherical:v.Spherical,Box3:v.Box3,Sphere:v.Sphere,Raycaster:v.Raycaster};Q.install({THREE:t})}get cameraControls(){return this.controller}addCameraControls(e,t){const{domElement:s}=this.options.controlsParams,i=new Q(e,s);return i.setLookAt(0,0,400,0,0,0,!1),this.addController(i,t)}setPageActive(e){super.setPageActive(e,(t,s)=>{t.enabled=s})}removePage(e){super.removePage(e,t=>{t.dispose()})}enable(){this.activeControllerSet.forEach(e=>{e.enabled=!0})}disable(){this.activeControllerSet.forEach(e=>{e.enabled=!1})}update(e,t){super.update(e,t),this.autoRotateSpeed&&this.cameraControls&&(this.cameraControls.azimuthAngle+=this.autoRotateSpeed*e*v.MathUtils.DEG2RAD)}}class Jt{constructor(e){this.event=new ge.EventEmitter;const{renderer:t,scene:s,camera:i}=e,r=new xt.TransformControls(i,t.domElement);if(r.getHelper){const o=r.getHelper();if(s.add(o),+v.REVISION<170){const n=r._root;n.dispose=()=>{n.traverse(a=>{a.geometry&&a.geometry.dispose(),a.material&&a.material.dispose()})},r.dispose=()=>{r.disconnect(),n.dispose()}}}else r instanceof v.Object3D&&s.add(r);this.controls=r,this.addEvent()}get detach(){return this.controls.detach.bind(this.controls)}get attach(){return this.controls.attach.bind(this.controls)}addEvent(){let e=null,t=null,s=null;const i=this.controls;i.addEventListener("change",()=>{const r=i.object;r!==void 0&&this.event.emit("change",r)}),i.addEventListener("mouseDown",()=>{const r=i.object;e=r.position.clone(),t=r.rotation.clone(),s=r.scale.clone(),this.event.emit("mouseDown",r)}),i.addEventListener("mouseUp",()=>{const r=i.object;if(r!==void 0)switch(i.getMode()){case"translate":e.equals(r.position)||this.event.emit("translate",r,r.position,e);break;case"rotate":t.equals(r.rotation)||this.event.emit("rotate",r,r.rotation,t);break;case"scale":s.equals(r.scale)||this.event.emit("scale",r,r.scale,s);break}this.event.emit("mouseUp")})}dispose(){var e;this.event.removeAllListeners(),(e=this.controls)==null||e.dispose()}}const Ze=new v.Vector3,es=new v.Quaternion,qe=new v.Vector3,I=new v.Matrix4,ts=new v.Matrix4;class ss{constructor(e={}){const t=this;let s,i,r,o;const n={camera:{style:""},objects:new WeakMap},a=e.element!==void 0?e.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a;const c=document.createElement("div");c.style.transformOrigin="0 0",c.style.pointerEvents="none",a.appendChild(c);const f=document.createElement("div");f.style.transformStyle="preserve-3d",c.appendChild(f),this.getSize=function(){return{width:s,height:i}},this.render=function(y,l){const _=l.projectionMatrix.elements[5]*o;l.view&&l.view.enabled?(c.style.transform=`translate( ${-l.view.offsetX*(s/l.view.width)}px, ${-l.view.offsetY*(i/l.view.height)}px )`,c.style.transform+=`scale( ${l.view.fullWidth/l.view.width}, ${l.view.fullHeight/l.view.height} )`):c.style.transform="",y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),l.parent===null&&l.matrixWorldAutoUpdate===!0&&l.updateMatrixWorld();let E,O;l.isOrthographicCamera&&(E=-(l.right+l.left)/2,O=(l.top+l.bottom)/2);const x=l.view&&l.view.enabled?l.view.height/l.view.fullHeight:1,T=l.isOrthographicCamera?`scale( ${x} )scale(`+_+")translate("+m(E)+"px,"+m(O)+"px)"+C(l.matrixWorldInverse):`scale( ${x} )translateZ(`+_+"px)"+C(l.matrixWorldInverse),D=(l.isPerspectiveCamera?"perspective("+_+"px) ":"")+T+"translate("+r+"px,"+o+"px)";n.camera.style!==D&&(f.style.transform=D,n.camera.style=D),g(y,y,l)},this.setSize=function(y,l){s=y,i=l,r=s/2,o=i/2,a.style.width=y+"px",a.style.height=l+"px",c.style.width=y+"px",c.style.height=l+"px",f.style.width=y+"px",f.style.height=l+"px"};function m(y){return Math.abs(y)<1e-10?0:y}function C(y){const l=y.elements;return"matrix3d("+m(l[0])+","+m(-l[1])+","+m(l[2])+","+m(l[3])+","+m(l[4])+","+m(-l[5])+","+m(l[6])+","+m(l[7])+","+m(l[8])+","+m(-l[9])+","+m(l[10])+","+m(l[11])+","+m(l[12])+","+m(-l[13])+","+m(l[14])+","+m(l[15])+")"}function p(y){const l=y.elements;return"translate(-50%,-50%)"+("matrix3d("+m(l[0])+","+m(l[1])+","+m(l[2])+","+m(l[3])+","+m(-l[4])+","+m(-l[5])+","+m(-l[6])+","+m(-l[7])+","+m(l[8])+","+m(l[9])+","+m(l[10])+","+m(l[11])+","+m(l[12])+","+m(l[13])+","+m(l[14])+","+m(l[15])+")")}function u(y){y.isCSS3DObject&&(y.element.style.display="none");for(let l=0,_=y.children.length;l<_;l++)u(y.children[l])}function g(y,l,_,E){if(y.visible===!1){u(y);return}if(y.isCSS3DObject){const O=y.layers.test(_.layers)===!0,x=y.element;if(x.style.display=O===!0?"":"none",O===!0){y.onBeforeRender(t,l,_);let T;y.isCSS3DSprite?(I.copy(_.matrixWorldInverse),I.transpose(),y.rotation2D!==0&&I.multiply(ts.makeRotationZ(y.rotation2D)),y.matrixWorld.decompose(Ze,es,qe),I.setPosition(Ze),I.scale(qe),I.elements[3]=0,I.elements[7]=0,I.elements[11]=0,I.elements[15]=1,T=p(I)):T=p(y.matrixWorld);const L=n.objects.get(y);if(L===void 0||L.style!==T){x.style.transform=T;const D={style:T};n.objects.set(y,D)}x.parentNode!==f&&f.appendChild(x),y.onAfterRender(t,l,_)}}for(let O=0,x=y.children.length;O<x;O++)g(y.children[O],l,_)}}}const X=new v.Vector3,We=new v.Matrix4,Ke=new v.Matrix4,Ge=new v.Vector3,Xe=new v.Vector3;class is{constructor(e={}){const t=this;let s,i,r,o;const n={objects:new WeakMap},a=e.element!==void 0?e.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a,this.getSize=function(){return{width:s,height:i}},this.render=function(u,g){u.matrixWorldAutoUpdate===!0&&u.updateMatrixWorld(),g.parent===null&&g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),We.copy(g.matrixWorldInverse),Ke.multiplyMatrices(g.projectionMatrix,We),f(u,u,g),p(u)},this.setSize=function(u,g){s=u,i=g,r=s/2,o=i/2,a.style.width=u+"px",a.style.height=g+"px"};function c(u){u.isCSS2DObject&&(u.element.style.display="none");for(let g=0,y=u.children.length;g<y;g++)c(u.children[g])}function f(u,g,y){if(u.visible===!1){c(u);return}if(u.isCSS2DObject){X.setFromMatrixPosition(u.matrixWorld),X.applyMatrix4(Ke);const l=X.z>=-1&&X.z<=1&&u.layers.test(y.layers)===!0,_=u.element;_.style.display=l===!0?"":"none",l===!0&&(u.onBeforeRender(t,g,y),_.style.transform="translate("+-100*u.center.x+"%,"+-100*u.center.y+"%)translate("+(X.x*r+r)+"px,"+(-X.y*o+o)+"px)",_.parentNode!==a&&a.appendChild(_),u.onAfterRender(t,g,y));const E={distanceToCameraSquared:m(y,u)};n.objects.set(u,E)}for(let l=0,_=u.children.length;l<_;l++)f(u.children[l],g,y)}function m(u,g){return Ge.setFromMatrixPosition(u.matrixWorld),Xe.setFromMatrixPosition(g.matrixWorld),Ge.distanceToSquared(Xe)}function C(u){const g=[];return u.traverseVisible(function(y){y.isCSS2DObject&&g.push(y)}),g}function p(u){const g=C(u).sort(function(l,_){if(l.renderOrder!==_.renderOrder)return _.renderOrder-l.renderOrder;const E=n.objects.get(l).distanceToCameraSquared,O=n.objects.get(_).distanceToCameraSquared;return E-O}),y=g.length;for(let l=0,_=g.length;l<_;l++)g[l].element.style.zIndex=y-l}}}const $e={zIndex:"auto"};class rs{constructor(e){this.container=e}addRenderer(e,t){const s=t.container||this.container,i=s.offsetWidth,r=s.offsetHeight,o=e==="css2d"?new is:new ss;o.domElement.style.position="absolute",o.domElement.style.top="0",o.domElement.style.pointerEvents="none",o.domElement.style.zIndex=t.zIndex,o.setSize(i,r),s.appendChild(o.domElement),e==="css2d"?this.css2Drenderer=o:e==="css3d"&&(this.css3Drenderer=o)}setSize(e,t){var s,i;(s=this.css2Drenderer)==null||s.setSize(e,t),(i=this.css3Drenderer)==null||i.setSize(e,t)}render(e,t){var s,i;(s=this.css2Drenderer)==null||s.render(e,t),(i=this.css3Drenderer)==null||i.render(e,t)}dispose(){var e,t;(e=this.css2Drenderer)==null||e.domElement.remove(),(t=this.css3Drenderer)==null||t.domElement.remove(),this.css2Drenderer=void 0,this.css3Drenderer=void 0}}const os={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1},premultiplieAlpha:{value:0}},vertexShader:`
2
2
  precision highp float;
3
3
 
4
4
  uniform mat4 modelViewMatrix;
@@ -2051,12 +2051,13 @@ class ee {
2051
2051
  });
2052
2052
  }
2053
2053
  setPageActive(e, t) {
2054
- this.activeIndex = e, this.activeControllerSet.clear(), this.controller = (Array.from(this.controllerMap.entries()).find(
2055
- ([s, i]) => {
2056
- const r = i.isEnabled(e);
2057
- return r && this.activeControllerSet.add(s), t == null || t(s, r), r;
2058
- }
2059
- ) || [])[0], this.event.emit("pageChange", this.controller);
2054
+ this.activeIndex = e, this.activeControllerSet.clear();
2055
+ const s = Array.from(this.controllerMap.entries()).map(([i, r]) => {
2056
+ const o = r.isEnabled(e);
2057
+ if (t == null || t(i, o), o)
2058
+ return this.activeControllerSet.add(i), i;
2059
+ }).filter(Boolean);
2060
+ this.controller = s[0], this.event.emit("pageChange", this.controller);
2060
2061
  }
2061
2062
  update(e, t) {
2062
2063
  this.activeControllerSet.forEach((s) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.15.7",
3
+ "version": "0.15.8",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",