gl-draw 0.13.13 → 0.13.14

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