gl-draw 0.9.49 → 0.9.51

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.
@@ -27,6 +27,7 @@ export default class {
27
27
  constructor(options: Options);
28
28
  setSize(width: number, height: number): void;
29
29
  addCamera2(): THREE.PerspectiveCamera;
30
+ syncCamera: THREE.PerspectiveCamera | null;
30
31
  setGui(gui: GUI): void;
31
32
  }
32
33
  export {};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Nt=Object.defineProperty,qt=Object.defineProperties;var Xt=Object.getOwnPropertyDescriptors;var it=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable;var yt=(d,t,e)=>t in d?Nt(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,I=(d,t)=>{for(var e in t||(t={}))Ct.call(t,e)&&yt(d,e,t[e]);if(it)for(var e of it(t))Ot.call(t,e)&&yt(d,e,t[e]);return d},ot=(d,t)=>qt(d,Xt(t));var Tt=(d,t)=>{var e={};for(var s in d)Ct.call(d,s)&&t.indexOf(s)<0&&(e[s]=d[s]);if(d!=null&&it)for(var s of it(d))t.indexOf(s)<0&&Ot.call(d,s)&&(e[s]=d[s]);return e};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const tt=require("three"),Kt=require("@tweenjs/tween.js"),Ft=require("./events.js"),jt=require("deepmerge"),Gt=require("three/examples/jsm/libs/stats.module"),Qt=require("lil-gui"),Wt=require("./colorCorrection.js"),Jt=require("./disposeMesh.js");require("idb-keyval");require("esus-lite");require("d3-geo");const vt=require("./MeshLineMaterial.js"),$t=require("three/examples/jsm/helpers/RectAreaLightHelper"),te=require("three/examples/jsm/controls/TransformControls"),ee=require("three/examples/jsm/renderers/CSS3DRenderer"),se=require("three/examples/jsm/renderers/CSS2DRenderer"),b=require("postprocessing"),ie=require("./isPlainObject.js"),oe=require("./BaseObject.js");function It(d){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return t.default=d,Object.freeze(t)}const x=It(tt),Pt=It(Kt),A={LEFT:1,RIGHT:2,MIDDLE:4},n=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}),N={NONE:0,IN:1,OUT:-1};function V(d){return d.isPerspectiveCamera}function B(d){return d.isOrthographicCamera}const q=Math.PI*2,xt=Math.PI/2,Ht=1e-5,j=Math.PI/180;function F(d,t,e){return Math.max(t,Math.min(e,d))}function U(d,t=Ht){return Math.abs(d)<t}function w(d,t,e=Ht){return U(d-t,e)}function Dt(d,t){return Math.round(d/t)*t}function G(d){return isFinite(d)?d:d<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Q(d){return Math.abs(d)<Number.MAX_VALUE?d:d*(1/0)}function rt(d,t,e,s,i=1/0,o){s=Math.max(1e-4,s);const r=2/s,a=r*o,h=1/(1+a+.48*a*a+.235*a*a*a);let c=d-t;const p=t,m=i*s;c=F(c,-m,m),t=d-c;const E=(e.value+r*c)*o;e.value=(e.value-r*E)*h;let u=t+(c+E)*h;return p-d>0==u>p&&(u=p,e.value=(u-p)/o),u}function wt(d,t,e,s,i=1/0,o,r){s=Math.max(1e-4,s);const a=2/s,h=a*o,c=1/(1+h+.48*h*h+.235*h*h*h);let p=t.x,m=t.y,E=t.z,u=d.x-p,D=d.y-m,g=d.z-E;const S=p,l=m,_=E,y=i*s,f=y*y,v=u*u+D*D+g*g;if(v>f){const mt=Math.sqrt(v);u=u/mt*y,D=D/mt*y,g=g/mt*y}p=d.x-u,m=d.y-D,E=d.z-g;const O=(e.x+a*u)*o,L=(e.y+a*D)*o,R=(e.z+a*g)*o;e.x=(e.x-a*O)*c,e.y=(e.y-a*L)*c,e.z=(e.z-a*R)*c,r.x=p+(u+O)*c,r.y=m+(D+L)*c,r.z=E+(g+R)*c;const et=S-d.x,st=l-d.y,Bt=_-d.z,Vt=r.x-S,Yt=r.y-l,Zt=r.z-_;return et*Vt+st*Yt+Bt*Zt>0&&(r.x=S,r.y=l,r.z=_,e.x=(r.x-S)/o,e.y=(r.y-l)/o,e.z=(r.z-_)/o),r}function _t(d,t){t.set(0,0),d.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=d.length,t.y/=d.length}function pt(d,t){return B(d)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}class re{constructor(){this._listeners={}}addEventListener(t,e){const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners[t];if(i!==void 0){const o=i.indexOf(e);o!==-1&&i.splice(o,1)}}removeAllEventListeners(t){if(!t){this._listeners={};return}Array.isArray(this._listeners[t])&&(this._listeners[t].length=0)}dispatchEvent(t){const s=this._listeners[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let o=0,r=i.length;o<r;o++)i[o].call(this,t)}}}const nt=1/8,ne=/Mac/.test(navigator.platform);let C,St,at,ut,M,T,P,X,W,H,k,Y,Ut,Lt,z,J,K,At,ft,Rt,gt,Et,ht;class Z extends re{static install(t){C=t.THREE,St=Object.freeze(new C.Vector3(0,0,0)),at=Object.freeze(new C.Vector3(0,1,0)),ut=Object.freeze(new C.Vector3(0,0,1)),M=new C.Vector2,T=new C.Vector3,P=new C.Vector3,X=new C.Vector3,W=new C.Vector3,H=new C.Vector3,k=new C.Vector3,Y=new C.Vector3,Ut=new C.Vector3,Lt=new C.Vector3,z=new C.Spherical,J=new C.Spherical,K=new C.Box3,At=new C.Box3,ft=new C.Sphere,Rt=new C.Quaternion,gt=new C.Quaternion,Et=new C.Matrix4,ht=new C.Raycaster}static get ACTION(){return n}constructor(t,e){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=n.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=N.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new C.Vector3,this._focalOffsetVelocity=new C.Vector3,this._zoomVelocity={value:0},this._truckInternal=(l,_,y)=>{let f,v;if(V(this._camera)){const O=T.copy(this._camera.position).sub(this._target),L=this._camera.getEffectiveFOV()*j,R=O.length()*Math.tan(L*.5);f=this.truckSpeed*l*R/this._elementRect.height,v=this.truckSpeed*_*R/this._elementRect.height}else if(B(this._camera)){const O=this._camera;f=l*(O.right-O.left)/O.zoom/this._elementRect.width,v=_*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(y?this.setFocalOffset(this._focalOffsetEnd.x+f,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(f,0,!0),this.forward(-v,!0)):y?this.setFocalOffset(this._focalOffsetEnd.x+f,this._focalOffsetEnd.y+v,this._focalOffsetEnd.z,!0):this.truck(f,v,!0)},this._rotateInternal=(l,_)=>{const y=q*this.azimuthRotateSpeed*l/this._elementRect.height,f=q*this.polarRotateSpeed*_/this._elementRect.height;this.rotate(y,f,!0)},this._dollyInternal=(l,_,y)=>{const f=Math.pow(.95,-l*this.dollySpeed),v=this._sphericalEnd.radius,O=this._sphericalEnd.radius*f,L=F(O,this.minDistance,this.maxDistance),R=L-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(R,!0),this._dollyToNoClamp(L,!0)):this._dollyToNoClamp(L,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:L)-v,this._dollyControlCoord.set(_,y)),this._lastDollyDirection=Math.sign(-l)},this._zoomInternal=(l,_,y)=>{const f=Math.pow(.95,l*this.dollySpeed),v=this._zoom,O=this._zoom*f;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-v,this._dollyControlCoord.set(_,y))},typeof C=="undefined"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=new C.Quaternion().setFromUnitVectors(this._camera.up,at),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=n.NONE,this._target=new C.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new C.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new C.Spherical().setFromVector3(T.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 C.Vector3,new C.Vector3,new C.Vector3,new C.Vector3],this._updateNearPlaneCorners(),this._boundary=new C.Box3(new C.Vector3(-1/0,-1/0,-1/0),new C.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 C.Vector2,this.mouseButtons={left:n.ROTATE,middle:n.DOLLY,right:n.TRUCK,wheel:V(this._camera)?n.DOLLY:B(this._camera)?n.ZOOM:n.NONE},this.touches={one:n.TOUCH_ROTATE,two:V(this._camera)?n.TOUCH_DOLLY_TRUCK:B(this._camera)?n.TOUCH_ZOOM_TRUCK:n.NONE,three:n.TOUCH_TRUCK};const s=new C.Vector2,i=new C.Vector2,o=new C.Vector2,r=l=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const f=this._domElement.getBoundingClientRect(),v=(l.clientX-f.left)/(f.right-f.left),O=(l.clientY-f.top)/(f.bottom-f.top);if(v<this._interactiveArea.left||v>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const _=l.pointerType!=="mouse"?null:(l.buttons&A.LEFT)===A.LEFT?A.LEFT:(l.buttons&A.MIDDLE)===A.MIDDLE?A.MIDDLE:(l.buttons&A.RIGHT)===A.RIGHT?A.RIGHT:null;if(_!==null){const f=this._findPointerByMouseButton(_);f&&this._disposePointer(f)}if((l.buttons&A.LEFT)===A.LEFT&&this._lockedPointer)return;const y={pointerId:l.pointerId,clientX:l.clientX,clientY:l.clientY,deltaX:0,deltaY:0,mouseButton:_};this._activePointers.push(y),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(l)},a=l=>{l.cancelable&&l.preventDefault();const _=l.pointerId,y=this._lockedPointer||this._findPointerById(_);if(y){if(y.clientX=l.clientX,y.clientY=l.clientY,y.deltaX=l.movementX,y.deltaY=l.movementY,this._state=0,l.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(l.buttons&A.LEFT)===A.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(l.buttons&A.MIDDLE)===A.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(l.buttons&A.RIGHT)===A.RIGHT&&(this._state=this._state|this.mouseButtons.right);u()}},h=l=>{const _=this._findPointerById(l.pointerId);if(!(_&&_===this._lockedPointer)){if(_&&this._disposePointer(_),l.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=n.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=n.NONE;D()}};let c=-1;const p=l=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===n.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),L=(l.clientX-O.left)/(O.right-O.left),R=(l.clientY-O.top)/(O.bottom-O.top);if(L<this._interactiveArea.left||L>this._interactiveArea.right||R<this._interactiveArea.top||R>this._interactiveArea.bottom)return}if(l.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===n.ROTATE||this.mouseButtons.wheel===n.TRUCK){const O=performance.now();c-O<1e3&&this._getClientRect(this._elementRect),c=O}const _=ne?-1:-3,y=l.deltaMode===1?l.deltaY/_:l.deltaY/(_*10),f=this.dollyToCursor?(l.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,v=this.dollyToCursor?(l.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case n.ROTATE:{this._rotateInternal(l.deltaX,l.deltaY),this._isUserControllingRotate=!0;break}case n.TRUCK:{this._truckInternal(l.deltaX,l.deltaY,!1),this._isUserControllingTruck=!0;break}case n.OFFSET:{this._truckInternal(l.deltaX,l.deltaY,!0),this._isUserControllingOffset=!0;break}case n.DOLLY:{this._dollyInternal(-y,f,v),this._isUserControllingDolly=!0;break}case n.ZOOM:{this._zoomInternal(-y,f,v),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=l=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Z.ACTION.NONE){const _=l instanceof PointerEvent?l.pointerId:0,y=this._findPointerById(_);y&&this._disposePointer(y),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h);return}l.preventDefault()}},E=l=>{if(!this._enabled)return;if(_t(this._activePointers,M),this._getClientRect(this._elementRect),s.copy(M),i.copy(M),this._activePointers.length>=2){const y=M.x-this._activePointers[1].clientX,f=M.y-this._activePointers[1].clientY,v=Math.sqrt(y*y+f*f);o.set(0,v);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,L=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(O,L)}if(this._state=0,!l)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in l&&l.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(l.buttons&A.LEFT)===A.LEFT&&(this._state=this._state|this.mouseButtons.left),(l.buttons&A.MIDDLE)===A.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(l.buttons&A.RIGHT)===A.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&n.ROTATE)===n.ROTATE||(this._state&n.TOUCH_ROTATE)===n.TOUCH_ROTATE||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE||(this._state&n.TOUCH_ZOOM_ROTATE)===n.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&n.TRUCK)===n.TRUCK||(this._state&n.TOUCH_TRUCK)===n.TOUCH_TRUCK||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_ZOOM_TRUCK)===n.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&n.DOLLY)===n.DOLLY||(this._state&n.TOUCH_DOLLY)===n.TOUCH_DOLLY||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&n.ZOOM)===n.ZOOM||(this._state&n.TOUCH_ZOOM)===n.TOUCH_ZOOM||(this._state&n.TOUCH_ZOOM_TRUCK)===n.TOUCH_ZOOM_TRUCK||(this._state&n.TOUCH_ZOOM_OFFSET)===n.TOUCH_ZOOM_OFFSET||(this._state&n.TOUCH_ZOOM_ROTATE)===n.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&n.OFFSET)===n.OFFSET||(this._state&n.TOUCH_OFFSET)===n.TOUCH_OFFSET||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET||(this._state&n.TOUCH_ZOOM_OFFSET)===n.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},u=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,_t(this._activePointers,M);const _=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,y=_?-_.deltaX:i.x-M.x,f=_?-_.deltaY:i.y-M.y;if(i.copy(M),((this._state&n.ROTATE)===n.ROTATE||(this._state&n.TOUCH_ROTATE)===n.TOUCH_ROTATE||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE||(this._state&n.TOUCH_ZOOM_ROTATE)===n.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(y,f),this._isUserControllingRotate=!0),(this._state&n.DOLLY)===n.DOLLY||(this._state&n.ZOOM)===n.ZOOM){const v=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,L=this.dollyDragInverted?-1:1;(this._state&n.DOLLY)===n.DOLLY?(this._dollyInternal(L*f*nt,v,O),this._isUserControllingDolly=!0):(this._zoomInternal(L*f*nt,v,O),this._isUserControllingZoom=!0)}if((this._state&n.TOUCH_DOLLY)===n.TOUCH_DOLLY||(this._state&n.TOUCH_ZOOM)===n.TOUCH_ZOOM||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_ZOOM_TRUCK)===n.TOUCH_ZOOM_TRUCK||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET||(this._state&n.TOUCH_ZOOM_OFFSET)===n.TOUCH_ZOOM_OFFSET||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE||(this._state&n.TOUCH_ZOOM_ROTATE)===n.TOUCH_ZOOM_ROTATE){const v=M.x-this._activePointers[1].clientX,O=M.y-this._activePointers[1].clientY,L=Math.sqrt(v*v+O*O),R=o.y-L;o.set(0,L);const et=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,st=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&n.TOUCH_DOLLY)===n.TOUCH_DOLLY||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET?(this._dollyInternal(R*nt,et,st),this._isUserControllingDolly=!0):(this._zoomInternal(R*nt,et,st),this._isUserControllingZoom=!0)}((this._state&n.TRUCK)===n.TRUCK||(this._state&n.TOUCH_TRUCK)===n.TOUCH_TRUCK||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_ZOOM_TRUCK)===n.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(y,f,!1),this._isUserControllingTruck=!0),((this._state&n.OFFSET)===n.OFFSET||(this._state&n.TOUCH_OFFSET)===n.TOUCH_OFFSET||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET||(this._state&n.TOUCH_ZOOM_OFFSET)===n.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(y,f,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},D=()=>{_t(this._activePointers,M),i.copy(M),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",g),this._domElement.ownerDocument.addEventListener("pointerlockerror",S),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),E())},this.unlockPointer=()=>{var l,_,y;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(l=this._domElement)===null||l===void 0||l.ownerDocument.exitPointerLock(),(_=this._domElement)===null||_===void 0||_.ownerDocument.removeEventListener("pointerlockchange",g),(y=this._domElement)===null||y===void 0||y.ownerDocument.removeEventListener("pointerlockerror",S),this.cancel()};const g=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},S=()=>{this.unlockPointer()};this._addAllEventListeners=l=>{this._domElement=l,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",m)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",m),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement.ownerDocument.removeEventListener("pointerlockerror",S))},this.cancel=()=>{this._state!==n.NONE&&(this._state=n.NONE,this._activePointers.length=0,D())},e&&this.connect(e),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(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(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=F(t.width,0,1),this._interactiveArea.height=F(t.height,0,1),this._interactiveArea.x=F(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=F(t.y,0,1-this._interactiveArea.height)}addEventListener(t,e){super.addEventListener(t,e)}removeEventListener(t,e){super.removeEventListener(t,e)}rotate(t,e,s=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+e,s)}rotateAzimuthTo(t,e=!1){return this.rotateTo(t,this._sphericalEnd.phi,e)}rotatePolarTo(t,e=!1){return this.rotateTo(this._sphericalEnd.theta,t,e)}rotateTo(t,e,s=!1){this._isUserControllingRotate=!1;const i=F(t,this.minAzimuthAngle,this.maxAzimuthAngle),o=F(e,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=o,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!s||w(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&w(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(t,e=!1){return this.dollyTo(this._sphericalEnd.radius-t,e)}dollyTo(t,e=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=N.NONE,this._changedDolly=0,this._dollyToNoClamp(F(t,this.minDistance,this.maxDistance),e)}_dollyToNoClamp(t,e=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),a=w(r,this._spherical.radius);if(!(s>t)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,r)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,e||(this._spherical.radius=this._sphericalEnd.radius);const o=!e||w(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(o)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection(W).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const s=!e||w(this._target.x,this._targetEnd.x,this.restThreshold)&&w(this._target.y,this._targetEnd.y,this.restThreshold)&&w(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(t,e=!1){return this.zoomTo(this._zoomEnd+t,e)}zoomTo(t,e=!1){this._isUserControllingZoom=!1,this._zoomEnd=F(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const s=!e||w(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(t,e,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,e,s)}truck(t,e,s=!1){this._camera.updateMatrix(),H.setFromMatrixColumn(this._camera.matrix,0),k.setFromMatrixColumn(this._camera.matrix,1),H.multiplyScalar(t),k.multiplyScalar(-e);const i=T.copy(H).add(k),o=P.copy(this._targetEnd).add(i);return this.moveTo(o.x,o.y,o.z,s)}forward(t,e=!1){T.setFromMatrixColumn(this._camera.matrix,0),T.crossVectors(this._camera.up,T),T.multiplyScalar(t);const s=P.copy(this._targetEnd).add(T);return this.moveTo(s.x,s.y,s.z,e)}elevate(t,e=!1){return T.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+T.x,this._targetEnd.y+T.y,this._targetEnd.z+T.z,e)}moveTo(t,e,s,i=!1){this._isUserControllingTruck=!1;const o=T.set(t,e,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,o,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const r=!i||w(this._target.x,this._targetEnd.x,this.restThreshold)&&w(this._target.y,this._targetEnd.y,this.restThreshold)&&w(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(t,e,s,i=!1){const a=T.set(t,e,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,i)}fitToBox(t,e,{cover:s=!1,paddingLeft:i=0,paddingRight:o=0,paddingBottom:r=0,paddingTop:a=0}={}){const h=[],c=t.isBox3?K.copy(t):K.setFromObject(t);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=Dt(this._sphericalEnd.theta,xt),m=Dt(this._sphericalEnd.phi,xt);h.push(this.rotateTo(p,m,e));const E=T.setFromSpherical(this._sphericalEnd).normalize(),u=Rt.setFromUnitVectors(E,ut),D=w(Math.abs(E.y),1);D&&u.multiply(gt.setFromAxisAngle(at,p)),u.multiply(this._yAxisUpSpaceInverse);const g=At.makeEmpty();P.copy(c.min).applyQuaternion(u),g.expandByPoint(P),P.copy(c.min).setX(c.max.x).applyQuaternion(u),g.expandByPoint(P),P.copy(c.min).setY(c.max.y).applyQuaternion(u),g.expandByPoint(P),P.copy(c.max).setZ(c.min.z).applyQuaternion(u),g.expandByPoint(P),P.copy(c.min).setZ(c.max.z).applyQuaternion(u),g.expandByPoint(P),P.copy(c.max).setY(c.min.y).applyQuaternion(u),g.expandByPoint(P),P.copy(c.max).setX(c.min.x).applyQuaternion(u),g.expandByPoint(P),P.copy(c.max).applyQuaternion(u),g.expandByPoint(P),g.min.x-=i,g.min.y-=r,g.max.x+=o,g.max.y+=a,u.setFromUnitVectors(ut,E),D&&u.premultiply(gt.invert()),u.premultiply(this._yAxisUpSpace);const S=g.getSize(T),l=g.getCenter(P).applyQuaternion(u);if(V(this._camera)){const _=this.getDistanceToFitBox(S.x,S.y,S.z,s);h.push(this.moveTo(l.x,l.y,l.z,e)),h.push(this.dollyTo(_,e)),h.push(this.setFocalOffset(0,0,0,e))}else if(B(this._camera)){const _=this._camera,y=_.right-_.left,f=_.top-_.bottom,v=s?Math.max(y/S.x,f/S.y):Math.min(y/S.x,f/S.y);h.push(this.moveTo(l.x,l.y,l.z,e)),h.push(this.zoomTo(v,e)),h.push(this.setFocalOffset(0,0,0,e))}return Promise.all(h)}fitToSphere(t,e){const s=[],o="isObject3D"in t?Z.createBoundingSphere(t,ft):ft.copy(t);if(s.push(this.moveTo(o.center.x,o.center.y,o.center.z,e)),V(this._camera)){const r=this.getDistanceToFitSphere(o.radius);s.push(this.dollyTo(r,e))}else if(B(this._camera)){const r=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,h=2*o.radius,c=Math.min(r/h,a/h);s.push(this.zoomTo(c,e))}return s.push(this.setFocalOffset(0,0,0,e)),Promise.all(s)}setLookAt(t,e,s,i,o,r,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=N.NONE,this._changedDolly=0;const h=P.set(i,o,r),c=T.set(t,e,s);this._targetEnd.copy(h),this._sphericalEnd.setFromVector3(c.sub(h).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!a||w(this._target.x,this._targetEnd.x,this.restThreshold)&&w(this._target.y,this._targetEnd.y,this.restThreshold)&&w(this._target.z,this._targetEnd.z,this.restThreshold)&&w(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&w(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&w(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(t,e,s,i,o,r,a,h,c,p,m,E,u,D=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=N.NONE,this._changedDolly=0;const g=T.set(i,o,r),S=P.set(t,e,s);z.setFromVector3(S.sub(g).applyQuaternion(this._yAxisUpSpace));const l=X.set(p,m,E),_=P.set(a,h,c);J.setFromVector3(_.sub(l).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(g.lerp(l,u));const y=J.theta-z.theta,f=J.phi-z.phi,v=J.radius-z.radius;this._sphericalEnd.set(z.radius+v*u,z.phi+f*u,z.theta+y*u),this.normalizeRotations(),this._needsUpdate=!0,D||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!D||w(this._target.x,this._targetEnd.x,this.restThreshold)&&w(this._target.y,this._targetEnd.y,this.restThreshold)&&w(this._target.z,this._targetEnd.z,this.restThreshold)&&w(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&w(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&w(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(O)}setPosition(t,e,s,i=!1){return this.setLookAt(t,e,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(t,e,s,i=!1){const o=this.getPosition(T),r=this.setLookAt(o.x,o.y,o.z,t,e,s,i);return this._sphericalEnd.phi=F(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(t,e,s,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(t,e,s),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const o=!i||w(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&w(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&w(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}setOrbitPoint(t,e,s){this._camera.updateMatrixWorld(),H.setFromMatrixColumn(this._camera.matrixWorldInverse,0),k.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Y.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=T.set(t,e,s),o=i.distanceTo(this._camera.position),r=i.sub(this._camera.position);H.multiplyScalar(r.x),k.multiplyScalar(r.y),Y.multiplyScalar(r.z),T.copy(H).add(k).add(Y),T.z=T.z+o,this.dollyTo(o,!1),this.setFocalOffset(-T.x,T.y,-T.z,!1),this.moveTo(t,e,s,!1)}setBoundary(t){if(!t){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(t),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(t,e,s,i){if(t===null){this._viewport=null;return}this._viewport=this._viewport||new C.Vector4,typeof t=="number"?this._viewport.set(t,e,s,i):this._viewport.copy(t)}getDistanceToFitBox(t,e,s,i=!1){if(pt(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=t/e,r=this._camera.getEffectiveFOV()*j,a=this._camera.aspect;return((i?o>a:o<a)?e:t/a)*.5/Math.tan(r*.5)+s*.5}getDistanceToFitSphere(t){if(pt(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*j,s=Math.atan(Math.tan(e*.5)*this._camera.aspect)*2,i=1<this._camera.aspect?e:s;return t/Math.sin(i*.5)}getTarget(t,e=!0){return(t&&t.isVector3?t:new C.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new C.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new C.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new C.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%q,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=q),this._spherical.theta+=q*Math.round((this._sphericalEnd.theta-this._spherical.theta)/q)}reset(t=!1){if(!w(this._camera.up.x,this._cameraUp0.x)||!w(this._camera.up.y,this._cameraUp0.y)||!w(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(T);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}const e=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,t),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,t),this.zoomTo(this._zoom0,t)];return Promise.all(e)}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,at),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=T.subVectors(this._target,this._camera.position).normalize(),e=P.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(T);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}update(t){const e=this._sphericalEnd.theta-this._spherical.theta,s=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,o=Ut.subVectors(this._targetEnd,this._target),r=Lt.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(U(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=rt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,t),this._needsUpdate=!0}if(U(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=rt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,t),this._needsUpdate=!0}if(U(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=rt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,t),this._needsUpdate=!0}if(U(o.x)&&U(o.y)&&U(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;wt(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(U(r.x)&&U(r.y)&&U(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;wt(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(U(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=rt(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,t)}if(this.dollyToCursor){if(V(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,E=this._camera,u=this._getCameraDirection(W),D=T.copy(u).cross(E.up).normalize();D.lengthSq()===0&&(D.x=1);const g=P.crossVectors(D,u),S=this._sphericalEnd.radius*Math.tan(E.getEffectiveFOV()*j*.5),_=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,y=X.copy(this._targetEnd).add(D.multiplyScalar(this._dollyControlCoord.x*S*E.aspect)).add(g.multiplyScalar(this._dollyControlCoord.y*S)),f=T.copy(this._targetEnd).lerp(y,_),v=this._lastDollyDirection===N.IN&&this._spherical.radius<=this.minDistance,O=this._lastDollyDirection===N.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(v||O)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const R=P.copy(u).multiplyScalar(-m);f.add(R)}this._boundary.clampPoint(f,f);const L=P.subVectors(f,this._targetEnd);this._targetEnd.copy(f),this._target.add(L),this._changedDolly-=m,U(this._changedDolly)&&(this._changedDolly=0)}else if(B(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,E=this._camera,u=T.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(E.near+E.far)/(E.near-E.far)).unproject(E),D=P.set(0,0,-1).applyQuaternion(E.quaternion),g=X.copy(u).add(D.multiplyScalar(-u.dot(E.up))),l=-(this._zoom-m-this._zoom)/this._zoom,_=this._getCameraDirection(W),y=this._targetEnd.dot(_),f=T.copy(this._targetEnd).lerp(g,l),v=f.dot(_),O=_.multiplyScalar(v-y);f.sub(O),this._boundary.clampPoint(f,f);const L=P.subVectors(f,this._targetEnd);this._targetEnd.copy(f),this._target.add(L),this._changedZoom-=m,U(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),(!U(this._focalOffset.x)||!U(this._focalOffset.y)||!U(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),H.setFromMatrixColumn(this._camera.matrix,0),k.setFromMatrixColumn(this._camera.matrix,1),Y.setFromMatrixColumn(this._camera.matrix,2),H.multiplyScalar(this._focalOffset.x),k.multiplyScalar(-this._focalOffset.y),Y.multiplyScalar(this._focalOffset.z),T.copy(H).add(k).add(Y),this._camera.position.add(T)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),T.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),U(e,this.restThreshold)&&U(s,this.restThreshold)&&U(i,this.restThreshold)&&U(o.x,this.restThreshold)&&U(o.y,this.restThreshold)&&U(o.z,this.restThreshold)&&U(r.x,this.restThreshold)&&U(r.y,this.restThreshold)&&U(r.z,this.restThreshold)&&U(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:G(this.maxDistance),minZoom:this.minZoom,maxZoom:G(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:G(this.maxPolarAngle),minAzimuthAngle:G(this.minAzimuthAngle),maxAzimuthAngle:G(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:T.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(t,e=!1){const s=JSON.parse(t);this.enabled=s.enabled,this.minDistance=s.minDistance,this.maxDistance=Q(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=Q(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=Q(s.maxPolarAngle),this.minAzimuthAngle=Q(s.minAzimuthAngle),this.maxAzimuthAngle=Q(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],e),z.setFromVector3(T.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(z.theta,z.phi,e),this.dollyTo(z.radius,e),this.zoomTo(s.zoom,e),this.setFocalOffset(s.focalOffset[0],s.focalOffset[1],s.focalOffset[2],e),this._needsUpdate=!0}connect(t){if(this._domElement){console.warn("camera-controls is already connected.");return}this._addAllEventListeners(t),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(t){return t.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(t){return this._getTargetDirection(t).negate()}_findPointerById(t){return this._activePointers.find(e=>e.pointerId===t)}_findPointerByMouseButton(t){return this._activePointers.find(e=>e.mouseButton===t)}_disposePointer(t){this._activePointers.splice(this._activePointers.indexOf(t),1)}_encloseToBoundary(t,e,s){const i=e.lengthSq();if(i===0)return t;const o=P.copy(e).add(t),a=this._boundary.clampPoint(o,X).sub(o),h=a.lengthSq();if(h===0)return t.add(e);if(h===i)return t;if(s===0)return t.add(e).add(a);{const c=1+s*h/e.dot(a);return t.add(P.copy(e).multiplyScalar(c)).add(a.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(V(this._camera)){const t=this._camera,e=t.near,s=t.getEffectiveFOV()*j,i=Math.tan(s*.5)*e,o=i*t.aspect;this._nearPlaneCorners[0].set(-o,-i,0),this._nearPlaneCorners[1].set(o,-i,0),this._nearPlaneCorners[2].set(o,i,0),this._nearPlaneCorners[3].set(-o,i,0)}else if(B(this._camera)){const t=this._camera,e=1/t.zoom,s=t.left*e,i=t.right*e,o=t.top*e,r=t.bottom*e;this._nearPlaneCorners[0].set(s,o,0),this._nearPlaneCorners[1].set(i,o,0),this._nearPlaneCorners[2].set(i,r,0),this._nearPlaneCorners[3].set(s,r,0)}}_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1)||pt(this._camera,"_collisionTest"))return t;const s=this._getTargetDirection(W);Et.lookAt(St,s,this._camera.up);for(let i=0;i<4;i++){const o=P.copy(this._nearPlaneCorners[i]);o.applyMatrix4(Et);const r=X.addVectors(this._target,o);ht.set(r,s),ht.far=this._spherical.radius+1;const a=ht.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<t&&(t=a[0].distance)}return t}_getClientRect(t){if(!this._domElement)return;const e=this._domElement.getBoundingClientRect();return t.x=e.left,t.y=e.top,this._viewport?(t.x+=this._viewport.x,t.y+=e.height-this._viewport.w-this._viewport.y,t.width=this._viewport.z,t.height=this._viewport.w):(t.width=e.width,t.height=e.height),t}_createOnRestPromise(t){return t?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(e=>{const s=()=>{this.removeEventListener("rest",s),e()};this.addEventListener("rest",s)}))}_addAllEventListeners(t){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(t){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(t){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(t,e=new C.Sphere){const s=e,i=s.center;K.makeEmpty(),t.traverseVisible(r=>{r.isMesh&&K.expandByObject(r)}),K.getCenter(i);let o=0;return t.traverseVisible(r=>{if(!r.isMesh)return;const a=r,h=a.geometry.clone();h.applyMatrix4(a.matrixWorld);const p=h.attributes.position;for(let m=0,E=p.count;m<E;m++)T.fromBufferAttribute(p,m),o=Math.max(o,i.distanceToSquared(T))}),s.radius=Math.sqrt(o),s}}const ae={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMappingExposure:1,alpha:!1,outputColorSpace:Wt.ColorSpace.sRGB,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,stencil:!1,depth:!1,physicallyCorrectLights:!1};class he{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i}=t,{canvas:o,context:r,alpha:a,devicePixelRatio:h,antialias:c,powerPreference:p,toneMappingExposure:m,outputColorSpace:E,logarithmicDepthBuffer:u,preserveDrawingBuffer:D,stencil:g,depth:S,physicallyCorrectLights:l}=i,_=new x.WebGLRenderer({canvas:o,context:r,alpha:a,antialias:c,powerPreference:p,logarithmicDepthBuffer:u,preserveDrawingBuffer:D,stencil:g,depth:S});_.setSize(e,s),_.setPixelRatio(h),_.toneMappingExposure=m,_.outputColorSpace=E,+x.REVISION<155&&(_.useLegacyLights=l),this.renderer=_}setSize(t,e){this.renderer.setSize(t,e)}render(t){const{scene:e,camera:s}=this.options;this.renderer.render(e,t||s)}dispose(){var t,e;this.setSize(1,1),(t=this.renderer)==null||t.clear(),(e=this.renderer)==null||e.dispose()}}class lt{constructor(t){this.guiParams={},t&&(this.guiParams=t)}showGui(t){t&&Object.keys(this.guiParams).forEach(e=>{const s=t.addFolder(e),i=this.guiParams[e];Object.keys(i).forEach(o=>{const{min:r,max:a,step:h,name:c,paramMap:p,items:m,value:E,target:u}=i[o],D=o.toLowerCase().indexOf("color")>-1;let g;const S=typeof E=="undefined"&&u,l=S?u():i[o],_=S?o:"value";m?g=s.add(l,_,m):D?g=s.addColor(l,_):g=s.add(l,_),g=g.name(c||o),typeof r!="undefined"&&(g=g.min(r)),typeof a!="undefined"&&(g=g.max(a)),typeof h!="undefined"&&(g=g.step(h)),g=g.onChange(()=>{this.setTargetValue(e,o,l[_],p)}),S&&g.listen()})})}setTargetValue(t,e,s,i){const{onChange:o,target:r,value:a}=this.guiParams[t][e],h=e.toLowerCase().indexOf("color")>-1;if(r&&!(typeof a=="undefined"&&r)){let p=r();Array.isArray(p)||(p=[p]),p.forEach(m=>{if(m)if(h)try{m[i||e].set(s)}catch(E){e!=="color"&&!i&&console.warn(`${e} is not a color,set paramMap`)}else m[i||e]=s})}o&&o(s)}setTargetValueByParams(){Object.keys(this.guiParams).forEach(t=>{Object.keys(this.guiParams[t]).forEach(e=>{const s=this.guiParams[t][e];typeof s.value!="undefined"&&this.setTargetValue(t,e,s.value,s.paramMap)})})}}const le={fov:45,near:1,far:1e3,up:new x.Vector3(0,1,0)};class ce{constructor(t){this.customCamera=!1,this.options=t;const{width:e,height:s,cameraParams:i}=t;if(i instanceof x.Camera)this.camera=i,this.customCamera=!0;else{const{fov:o,far:r,near:a,up:h}=i,c=new x.PerspectiveCamera(o,e/s,a,r);c.position.set(0,0,400),c.lookAt(0,0,0),c.up=h,this.camera=c}}setSize(t,e){this.camera instanceof x.PerspectiveCamera&&(this.camera.aspect=t/e),this.camera.updateProjectionMatrix(),this.camera2&&(this.camera2.aspect=t/e,this.camera2.updateProjectionMatrix())}addCamera2(){const t=new x.PerspectiveCamera(this.camera.fov,this.camera.aspect,this.camera.near,this.camera.far);return t.position.copy(this.camera.position),this.camera2=t,t}setGui(t){const e=new lt({camera:ot(I({},this.options.cameraControls?{}:{x:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},y:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},z:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position}}),{near:{min:0,max:1e3,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}},far:{min:0,max:2e4,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}})});this.camera instanceof x.PerspectiveCamera&&(e.guiParams.camera.fov={min:0,max:90,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}),e.showGui(t)}}const de={background:null,om:!0,addCamera:!0};class me{constructor(t){this.overrideMaterial=!1,this.options=t;const{camera:e,sceneParams:s}=t,{background:i,om:o,addCamera:r}=s,a=o?new x.Scene:new Proxy(new x.Scene,{set:(h,c,p)=>Reflect.set(h,c,p),get:(h,c)=>{if(c==="overrideMaterial"){const p=Reflect.get(h,c);return this.overrideMaterial=!!p,vt.meshLineMaterialArr.forEach(m=>{this.overrideMaterial?m.useDepth=1:m.useDepth=0}),null}return Reflect.get(h,c)}});i&&(a.background=i),r&&a.add(e),this.scene=a}dispose(){var t;(t=this.scene)==null||t.traverse(e=>{Jt.disposeMesh(e)}),vt.meshLineMaterialArr.length=0}}class _e{constructor(t){this.helpers={},this.options=t}add(t){const e=t.uuid,{scene:s}=this.options;let i=this.helpers[e];if(i===void 0){if(t.isScene)i=new x.AxesHelper(100);else if(t.isCamera)i=new x.CameraHelper(t);else if(t.isPointLight)i=new x.PointLightHelper(t,1);else if(t.isDirectionalLight)i=new x.DirectionalLightHelper(t,1);else if(t.isSpotLight)i=new x.SpotLightHelper(t);else if(t.isHemisphereLight)i=new x.HemisphereLightHelper(t,10);else if(t.isRectAreaLight)i=new $t.RectAreaLightHelper(t);else{const o=new x.Box3;if(o.setFromObject(t,!0),o.isEmpty()===!1){i=new x.Box3Helper(o);const r=i.material;r.userData.object=t,r.depthTest=!1,r.transparent=!0}else return}s.add(i),this.helpers[e]=i}}remove(t){const e=t.uuid,{scene:s}=this.options;if(this.helpers[e]!==void 0){const i=this.helpers[e];s.remove(i),delete this.helpers[e],i instanceof x.Box3Helper&&i.dispose()}}removeAll(){Object.keys(this.helpers).forEach(t=>{this.remove({uuid:t})}),this.helpers={}}removeAllExcludeScene(){Object.keys(this.helpers).forEach(t=>{this.helpers[t]instanceof x.AxesHelper||this.remove({uuid:t})})}update(){Object.values(this.helpers).forEach(t=>{if(t.update&&t.update(),t instanceof x.Box3Helper){const e=t.material,{object:s}=e.userData;s&&t.box.setFromObject(s,!0)}})}dispose(){this.helpers={}}}class pe{constructor(t){this.autoRotateSpeed=0,this.options=t;const{camera:e,controlsParams:s,customControl:i}=t,{domElement:o}=s;if(i){const r=new i(e,o);r.enableDamping=!0,r.dampingFactor=.063,r.autoRotate=!1,r.autoRotateSpeed=-60,r.enableZoom=!0,r.zoomSpeed=.2,this.controls=r}else Z.install({THREE:x}),this.cameraControls=new Z(e,o)}addCameraControls2(t){const{controlsParams:e}=this.options,{domElement:s}=e;this.cameraControls2=new Z(t,s),this.cameraControls2.addEventListener("update",()=>{this.cameraControls.enabled=!1}),this.cameraControls2.addEventListener("sleep",()=>{this.cameraControls.enabled=!0})}enable(){this.controls?this.controls.enabled=!0:this.cameraControls&&(this.cameraControls.enabled=!0,this.cameraControls2&&(this.cameraControls2.enabled=!0))}disable(){this.controls?this.controls.enabled=!1:this.cameraControls&&(this.cameraControls.enabled=!1,this.cameraControls2&&(this.cameraControls2.enabled=!1))}update(t){var e,s,i;(e=this.controls)==null||e.update(),(s=this.cameraControls)==null||s.update(t),(i=this.cameraControls2)==null||i.update(t),this.autoRotateSpeed&&this.cameraControls&&(this.cameraControls.azimuthAngle+=this.autoRotateSpeed*t*x.MathUtils.DEG2RAD)}dispose(){var t,e,s;(t=this.controls)==null||t.dispose(),(e=this.cameraControls)==null||e.dispose(),(s=this.cameraControls2)==null||s.dispose()}}class ue{constructor(t){this.event=new Ft.eventsExports.EventEmitter;const{renderer:e,scene:s,camera:i}=t,o=new te.TransformControls(i,e.domElement);s.add(o),this.controls=o,this.addEvent()}get detach(){return this.controls.detach.bind(this.controls)}get attach(){return this.controls.attach.bind(this.controls)}addEvent(){let t=null,e=null,s=null;const i=this.controls;i.addEventListener("change",()=>{const o=i.object;o!==void 0&&this.event.emit("change",o)}),i.addEventListener("mouseDown",()=>{const o=i.object;t=o.position.clone(),e=o.rotation.clone(),s=o.scale.clone(),this.event.emit("mouseDown",o)}),i.addEventListener("mouseUp",()=>{const o=i.object;if(o!==void 0)switch(i.getMode()){case"translate":t.equals(o.position)||this.event.emit("translate",o,o.position,t);break;case"rotate":e.equals(o.rotation)||this.event.emit("rotate",o,o.rotation,e);break;case"scale":s.equals(o.scale)||this.event.emit("scale",o,o.scale,s);break}this.event.emit("mouseUp")})}dispose(){var t;this.event.removeAllListeners(),(t=this.controls)==null||t.dispose()}}const bt={zIndex:"auto"};class fe{constructor(t){this.container=t}addRenderer(t,e){const s=e.container||this.container,i=s.offsetWidth,o=s.offsetHeight,r=t==="css2d"?new se.CSS2DRenderer:new ee.CSS3DRenderer;r.domElement.style.position="absolute",r.domElement.style.top="0",r.domElement.style.pointerEvents="none",r.domElement.style.zIndex=e.zIndex,r.setSize(i,o),s.appendChild(r.domElement),t==="css2d"?this.css2Drenderer=r:t==="css3d"&&(this.css3Drenderer=r)}setSize(t,e){var s,i;(s=this.css2Drenderer)==null||s.setSize(t,e),(i=this.css3Drenderer)==null||i.setSize(t,e)}render(t,e){var s,i;(s=this.css2Drenderer)==null||s.render(t,e),(i=this.css3Drenderer)==null||i.render(t,e)}dispose(){var t,e;(t=this.css2Drenderer)==null||t.domElement.remove(),(e=this.css3Drenderer)==null||e.domElement.remove(),this.css2Drenderer=void 0,this.css3Drenderer=void 0}}const Mt=["encodings_fragment","colorspace_fragment"];class ge extends tt.ShaderMaterial{constructor(){super({uniforms:{inputBuffer:new tt.Uniform(null),ratio:new tt.Uniform(1)},fragmentShader:`
1
+ "use strict";var Nt=Object.defineProperty,qt=Object.defineProperties;var Xt=Object.getOwnPropertyDescriptors;var it=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable;var yt=(d,t,e)=>t in d?Nt(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,I=(d,t)=>{for(var e in t||(t={}))Ct.call(t,e)&&yt(d,e,t[e]);if(it)for(var e of it(t))Ot.call(t,e)&&yt(d,e,t[e]);return d},ot=(d,t)=>qt(d,Xt(t));var Tt=(d,t)=>{var e={};for(var s in d)Ct.call(d,s)&&t.indexOf(s)<0&&(e[s]=d[s]);if(d!=null&&it)for(var s of it(d))t.indexOf(s)<0&&Ot.call(d,s)&&(e[s]=d[s]);return e};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const tt=require("three"),Kt=require("@tweenjs/tween.js"),Ft=require("./events.js"),jt=require("deepmerge"),Gt=require("three/examples/jsm/libs/stats.module"),Qt=require("lil-gui"),Wt=require("./colorCorrection.js"),Jt=require("./disposeMesh.js");require("idb-keyval");require("esus-lite");require("d3-geo");const vt=require("./MeshLineMaterial.js"),$t=require("three/examples/jsm/helpers/RectAreaLightHelper"),te=require("three/examples/jsm/controls/TransformControls"),ee=require("three/examples/jsm/renderers/CSS3DRenderer"),se=require("three/examples/jsm/renderers/CSS2DRenderer"),b=require("postprocessing"),ie=require("./isPlainObject.js"),oe=require("./BaseObject.js");function It(d){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>d[e]})}}return t.default=d,Object.freeze(t)}const x=It(tt),Pt=It(Kt),A={LEFT:1,RIGHT:2,MIDDLE:4},n=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}),N={NONE:0,IN:1,OUT:-1};function V(d){return d.isPerspectiveCamera}function B(d){return d.isOrthographicCamera}const q=Math.PI*2,xt=Math.PI/2,Ht=1e-5,j=Math.PI/180;function F(d,t,e){return Math.max(t,Math.min(e,d))}function U(d,t=Ht){return Math.abs(d)<t}function w(d,t,e=Ht){return U(d-t,e)}function Dt(d,t){return Math.round(d/t)*t}function G(d){return isFinite(d)?d:d<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Q(d){return Math.abs(d)<Number.MAX_VALUE?d:d*(1/0)}function rt(d,t,e,s,i=1/0,o){s=Math.max(1e-4,s);const r=2/s,a=r*o,h=1/(1+a+.48*a*a+.235*a*a*a);let c=d-t;const p=t,m=i*s;c=F(c,-m,m),t=d-c;const E=(e.value+r*c)*o;e.value=(e.value-r*E)*h;let u=t+(c+E)*h;return p-d>0==u>p&&(u=p,e.value=(u-p)/o),u}function wt(d,t,e,s,i=1/0,o,r){s=Math.max(1e-4,s);const a=2/s,h=a*o,c=1/(1+h+.48*h*h+.235*h*h*h);let p=t.x,m=t.y,E=t.z,u=d.x-p,D=d.y-m,g=d.z-E;const S=p,l=m,_=E,y=i*s,f=y*y,v=u*u+D*D+g*g;if(v>f){const mt=Math.sqrt(v);u=u/mt*y,D=D/mt*y,g=g/mt*y}p=d.x-u,m=d.y-D,E=d.z-g;const O=(e.x+a*u)*o,L=(e.y+a*D)*o,R=(e.z+a*g)*o;e.x=(e.x-a*O)*c,e.y=(e.y-a*L)*c,e.z=(e.z-a*R)*c,r.x=p+(u+O)*c,r.y=m+(D+L)*c,r.z=E+(g+R)*c;const et=S-d.x,st=l-d.y,Bt=_-d.z,Vt=r.x-S,Yt=r.y-l,Zt=r.z-_;return et*Vt+st*Yt+Bt*Zt>0&&(r.x=S,r.y=l,r.z=_,e.x=(r.x-S)/o,e.y=(r.y-l)/o,e.z=(r.z-_)/o),r}function _t(d,t){t.set(0,0),d.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=d.length,t.y/=d.length}function pt(d,t){return B(d)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}class re{constructor(){this._listeners={}}addEventListener(t,e){const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners[t];if(i!==void 0){const o=i.indexOf(e);o!==-1&&i.splice(o,1)}}removeAllEventListeners(t){if(!t){this._listeners={};return}Array.isArray(this._listeners[t])&&(this._listeners[t].length=0)}dispatchEvent(t){const s=this._listeners[t.type];if(s!==void 0){t.target=this;const i=s.slice(0);for(let o=0,r=i.length;o<r;o++)i[o].call(this,t)}}}const nt=1/8,ne=/Mac/.test(navigator.platform);let C,St,at,ut,M,T,P,X,W,H,k,Y,Ut,Lt,z,J,K,At,ft,Rt,gt,Et,ht;class Z extends re{static install(t){C=t.THREE,St=Object.freeze(new C.Vector3(0,0,0)),at=Object.freeze(new C.Vector3(0,1,0)),ut=Object.freeze(new C.Vector3(0,0,1)),M=new C.Vector2,T=new C.Vector3,P=new C.Vector3,X=new C.Vector3,W=new C.Vector3,H=new C.Vector3,k=new C.Vector3,Y=new C.Vector3,Ut=new C.Vector3,Lt=new C.Vector3,z=new C.Spherical,J=new C.Spherical,K=new C.Box3,At=new C.Box3,ft=new C.Sphere,Rt=new C.Quaternion,gt=new C.Quaternion,Et=new C.Matrix4,ht=new C.Raycaster}static get ACTION(){return n}constructor(t,e){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=n.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=N.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new C.Vector3,this._focalOffsetVelocity=new C.Vector3,this._zoomVelocity={value:0},this._truckInternal=(l,_,y)=>{let f,v;if(V(this._camera)){const O=T.copy(this._camera.position).sub(this._target),L=this._camera.getEffectiveFOV()*j,R=O.length()*Math.tan(L*.5);f=this.truckSpeed*l*R/this._elementRect.height,v=this.truckSpeed*_*R/this._elementRect.height}else if(B(this._camera)){const O=this._camera;f=l*(O.right-O.left)/O.zoom/this._elementRect.width,v=_*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(y?this.setFocalOffset(this._focalOffsetEnd.x+f,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(f,0,!0),this.forward(-v,!0)):y?this.setFocalOffset(this._focalOffsetEnd.x+f,this._focalOffsetEnd.y+v,this._focalOffsetEnd.z,!0):this.truck(f,v,!0)},this._rotateInternal=(l,_)=>{const y=q*this.azimuthRotateSpeed*l/this._elementRect.height,f=q*this.polarRotateSpeed*_/this._elementRect.height;this.rotate(y,f,!0)},this._dollyInternal=(l,_,y)=>{const f=Math.pow(.95,-l*this.dollySpeed),v=this._sphericalEnd.radius,O=this._sphericalEnd.radius*f,L=F(O,this.minDistance,this.maxDistance),R=L-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(R,!0),this._dollyToNoClamp(L,!0)):this._dollyToNoClamp(L,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:L)-v,this._dollyControlCoord.set(_,y)),this._lastDollyDirection=Math.sign(-l)},this._zoomInternal=(l,_,y)=>{const f=Math.pow(.95,l*this.dollySpeed),v=this._zoom,O=this._zoom*f;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-v,this._dollyControlCoord.set(_,y))},typeof C=="undefined"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=new C.Quaternion().setFromUnitVectors(this._camera.up,at),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=n.NONE,this._target=new C.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new C.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new C.Spherical().setFromVector3(T.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 C.Vector3,new C.Vector3,new C.Vector3,new C.Vector3],this._updateNearPlaneCorners(),this._boundary=new C.Box3(new C.Vector3(-1/0,-1/0,-1/0),new C.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 C.Vector2,this.mouseButtons={left:n.ROTATE,middle:n.DOLLY,right:n.TRUCK,wheel:V(this._camera)?n.DOLLY:B(this._camera)?n.ZOOM:n.NONE},this.touches={one:n.TOUCH_ROTATE,two:V(this._camera)?n.TOUCH_DOLLY_TRUCK:B(this._camera)?n.TOUCH_ZOOM_TRUCK:n.NONE,three:n.TOUCH_TRUCK};const s=new C.Vector2,i=new C.Vector2,o=new C.Vector2,r=l=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const f=this._domElement.getBoundingClientRect(),v=(l.clientX-f.left)/(f.right-f.left),O=(l.clientY-f.top)/(f.bottom-f.top);if(v<this._interactiveArea.left||v>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const _=l.pointerType!=="mouse"?null:(l.buttons&A.LEFT)===A.LEFT?A.LEFT:(l.buttons&A.MIDDLE)===A.MIDDLE?A.MIDDLE:(l.buttons&A.RIGHT)===A.RIGHT?A.RIGHT:null;if(_!==null){const f=this._findPointerByMouseButton(_);f&&this._disposePointer(f)}if((l.buttons&A.LEFT)===A.LEFT&&this._lockedPointer)return;const y={pointerId:l.pointerId,clientX:l.clientX,clientY:l.clientY,deltaX:0,deltaY:0,mouseButton:_};this._activePointers.push(y),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(l)},a=l=>{l.cancelable&&l.preventDefault();const _=l.pointerId,y=this._lockedPointer||this._findPointerById(_);if(y){if(y.clientX=l.clientX,y.clientY=l.clientY,y.deltaX=l.movementX,y.deltaY=l.movementY,this._state=0,l.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(l.buttons&A.LEFT)===A.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(l.buttons&A.MIDDLE)===A.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(l.buttons&A.RIGHT)===A.RIGHT&&(this._state=this._state|this.mouseButtons.right);u()}},h=l=>{const _=this._findPointerById(l.pointerId);if(!(_&&_===this._lockedPointer)){if(_&&this._disposePointer(_),l.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=n.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=n.NONE;D()}};let c=-1;const p=l=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===n.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),L=(l.clientX-O.left)/(O.right-O.left),R=(l.clientY-O.top)/(O.bottom-O.top);if(L<this._interactiveArea.left||L>this._interactiveArea.right||R<this._interactiveArea.top||R>this._interactiveArea.bottom)return}if(l.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===n.ROTATE||this.mouseButtons.wheel===n.TRUCK){const O=performance.now();c-O<1e3&&this._getClientRect(this._elementRect),c=O}const _=ne?-1:-3,y=l.deltaMode===1?l.deltaY/_:l.deltaY/(_*10),f=this.dollyToCursor?(l.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,v=this.dollyToCursor?(l.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case n.ROTATE:{this._rotateInternal(l.deltaX,l.deltaY),this._isUserControllingRotate=!0;break}case n.TRUCK:{this._truckInternal(l.deltaX,l.deltaY,!1),this._isUserControllingTruck=!0;break}case n.OFFSET:{this._truckInternal(l.deltaX,l.deltaY,!0),this._isUserControllingOffset=!0;break}case n.DOLLY:{this._dollyInternal(-y,f,v),this._isUserControllingDolly=!0;break}case n.ZOOM:{this._zoomInternal(-y,f,v),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},m=l=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Z.ACTION.NONE){const _=l instanceof PointerEvent?l.pointerId:0,y=this._findPointerById(_);y&&this._disposePointer(y),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h);return}l.preventDefault()}},E=l=>{if(!this._enabled)return;if(_t(this._activePointers,M),this._getClientRect(this._elementRect),s.copy(M),i.copy(M),this._activePointers.length>=2){const y=M.x-this._activePointers[1].clientX,f=M.y-this._activePointers[1].clientY,v=Math.sqrt(y*y+f*f);o.set(0,v);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,L=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(O,L)}if(this._state=0,!l)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in l&&l.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(l.buttons&A.LEFT)===A.LEFT&&(this._state=this._state|this.mouseButtons.left),(l.buttons&A.MIDDLE)===A.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(l.buttons&A.RIGHT)===A.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&n.ROTATE)===n.ROTATE||(this._state&n.TOUCH_ROTATE)===n.TOUCH_ROTATE||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE||(this._state&n.TOUCH_ZOOM_ROTATE)===n.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&n.TRUCK)===n.TRUCK||(this._state&n.TOUCH_TRUCK)===n.TOUCH_TRUCK||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_ZOOM_TRUCK)===n.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&n.DOLLY)===n.DOLLY||(this._state&n.TOUCH_DOLLY)===n.TOUCH_DOLLY||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&n.ZOOM)===n.ZOOM||(this._state&n.TOUCH_ZOOM)===n.TOUCH_ZOOM||(this._state&n.TOUCH_ZOOM_TRUCK)===n.TOUCH_ZOOM_TRUCK||(this._state&n.TOUCH_ZOOM_OFFSET)===n.TOUCH_ZOOM_OFFSET||(this._state&n.TOUCH_ZOOM_ROTATE)===n.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&n.OFFSET)===n.OFFSET||(this._state&n.TOUCH_OFFSET)===n.TOUCH_OFFSET||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET||(this._state&n.TOUCH_ZOOM_OFFSET)===n.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},u=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,_t(this._activePointers,M);const _=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,y=_?-_.deltaX:i.x-M.x,f=_?-_.deltaY:i.y-M.y;if(i.copy(M),((this._state&n.ROTATE)===n.ROTATE||(this._state&n.TOUCH_ROTATE)===n.TOUCH_ROTATE||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE||(this._state&n.TOUCH_ZOOM_ROTATE)===n.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(y,f),this._isUserControllingRotate=!0),(this._state&n.DOLLY)===n.DOLLY||(this._state&n.ZOOM)===n.ZOOM){const v=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,L=this.dollyDragInverted?-1:1;(this._state&n.DOLLY)===n.DOLLY?(this._dollyInternal(L*f*nt,v,O),this._isUserControllingDolly=!0):(this._zoomInternal(L*f*nt,v,O),this._isUserControllingZoom=!0)}if((this._state&n.TOUCH_DOLLY)===n.TOUCH_DOLLY||(this._state&n.TOUCH_ZOOM)===n.TOUCH_ZOOM||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_ZOOM_TRUCK)===n.TOUCH_ZOOM_TRUCK||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET||(this._state&n.TOUCH_ZOOM_OFFSET)===n.TOUCH_ZOOM_OFFSET||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE||(this._state&n.TOUCH_ZOOM_ROTATE)===n.TOUCH_ZOOM_ROTATE){const v=M.x-this._activePointers[1].clientX,O=M.y-this._activePointers[1].clientY,L=Math.sqrt(v*v+O*O),R=o.y-L;o.set(0,L);const et=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,st=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&n.TOUCH_DOLLY)===n.TOUCH_DOLLY||(this._state&n.TOUCH_DOLLY_ROTATE)===n.TOUCH_DOLLY_ROTATE||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET?(this._dollyInternal(R*nt,et,st),this._isUserControllingDolly=!0):(this._zoomInternal(R*nt,et,st),this._isUserControllingZoom=!0)}((this._state&n.TRUCK)===n.TRUCK||(this._state&n.TOUCH_TRUCK)===n.TOUCH_TRUCK||(this._state&n.TOUCH_DOLLY_TRUCK)===n.TOUCH_DOLLY_TRUCK||(this._state&n.TOUCH_ZOOM_TRUCK)===n.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(y,f,!1),this._isUserControllingTruck=!0),((this._state&n.OFFSET)===n.OFFSET||(this._state&n.TOUCH_OFFSET)===n.TOUCH_OFFSET||(this._state&n.TOUCH_DOLLY_OFFSET)===n.TOUCH_DOLLY_OFFSET||(this._state&n.TOUCH_ZOOM_OFFSET)===n.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(y,f,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},D=()=>{_t(this._activePointers,M),i.copy(M),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",g),this._domElement.ownerDocument.addEventListener("pointerlockerror",S),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),E())},this.unlockPointer=()=>{var l,_,y;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(l=this._domElement)===null||l===void 0||l.ownerDocument.exitPointerLock(),(_=this._domElement)===null||_===void 0||_.ownerDocument.removeEventListener("pointerlockchange",g),(y=this._domElement)===null||y===void 0||y.ownerDocument.removeEventListener("pointerlockerror",S),this.cancel()};const g=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},S=()=>{this.unlockPointer()};this._addAllEventListeners=l=>{this._domElement=l,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",m)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",m),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement.ownerDocument.removeEventListener("pointerlockerror",S))},this.cancel=()=>{this._state!==n.NONE&&(this._state=n.NONE,this._activePointers.length=0,D())},e&&this.connect(e),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(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(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=F(t.width,0,1),this._interactiveArea.height=F(t.height,0,1),this._interactiveArea.x=F(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=F(t.y,0,1-this._interactiveArea.height)}addEventListener(t,e){super.addEventListener(t,e)}removeEventListener(t,e){super.removeEventListener(t,e)}rotate(t,e,s=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+e,s)}rotateAzimuthTo(t,e=!1){return this.rotateTo(t,this._sphericalEnd.phi,e)}rotatePolarTo(t,e=!1){return this.rotateTo(this._sphericalEnd.theta,t,e)}rotateTo(t,e,s=!1){this._isUserControllingRotate=!1;const i=F(t,this.minAzimuthAngle,this.maxAzimuthAngle),o=F(e,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=o,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!s||w(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&w(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(t,e=!1){return this.dollyTo(this._sphericalEnd.radius-t,e)}dollyTo(t,e=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=N.NONE,this._changedDolly=0,this._dollyToNoClamp(F(t,this.minDistance,this.maxDistance),e)}_dollyToNoClamp(t,e=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),a=w(r,this._spherical.radius);if(!(s>t)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,r)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,e||(this._spherical.radius=this._sphericalEnd.radius);const o=!e||w(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(o)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection(W).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const s=!e||w(this._target.x,this._targetEnd.x,this.restThreshold)&&w(this._target.y,this._targetEnd.y,this.restThreshold)&&w(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(t,e=!1){return this.zoomTo(this._zoomEnd+t,e)}zoomTo(t,e=!1){this._isUserControllingZoom=!1,this._zoomEnd=F(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const s=!e||w(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(t,e,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,e,s)}truck(t,e,s=!1){this._camera.updateMatrix(),H.setFromMatrixColumn(this._camera.matrix,0),k.setFromMatrixColumn(this._camera.matrix,1),H.multiplyScalar(t),k.multiplyScalar(-e);const i=T.copy(H).add(k),o=P.copy(this._targetEnd).add(i);return this.moveTo(o.x,o.y,o.z,s)}forward(t,e=!1){T.setFromMatrixColumn(this._camera.matrix,0),T.crossVectors(this._camera.up,T),T.multiplyScalar(t);const s=P.copy(this._targetEnd).add(T);return this.moveTo(s.x,s.y,s.z,e)}elevate(t,e=!1){return T.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+T.x,this._targetEnd.y+T.y,this._targetEnd.z+T.z,e)}moveTo(t,e,s,i=!1){this._isUserControllingTruck=!1;const o=T.set(t,e,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,o,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const r=!i||w(this._target.x,this._targetEnd.x,this.restThreshold)&&w(this._target.y,this._targetEnd.y,this.restThreshold)&&w(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(t,e,s,i=!1){const a=T.set(t,e,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,i)}fitToBox(t,e,{cover:s=!1,paddingLeft:i=0,paddingRight:o=0,paddingBottom:r=0,paddingTop:a=0}={}){const h=[],c=t.isBox3?K.copy(t):K.setFromObject(t);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=Dt(this._sphericalEnd.theta,xt),m=Dt(this._sphericalEnd.phi,xt);h.push(this.rotateTo(p,m,e));const E=T.setFromSpherical(this._sphericalEnd).normalize(),u=Rt.setFromUnitVectors(E,ut),D=w(Math.abs(E.y),1);D&&u.multiply(gt.setFromAxisAngle(at,p)),u.multiply(this._yAxisUpSpaceInverse);const g=At.makeEmpty();P.copy(c.min).applyQuaternion(u),g.expandByPoint(P),P.copy(c.min).setX(c.max.x).applyQuaternion(u),g.expandByPoint(P),P.copy(c.min).setY(c.max.y).applyQuaternion(u),g.expandByPoint(P),P.copy(c.max).setZ(c.min.z).applyQuaternion(u),g.expandByPoint(P),P.copy(c.min).setZ(c.max.z).applyQuaternion(u),g.expandByPoint(P),P.copy(c.max).setY(c.min.y).applyQuaternion(u),g.expandByPoint(P),P.copy(c.max).setX(c.min.x).applyQuaternion(u),g.expandByPoint(P),P.copy(c.max).applyQuaternion(u),g.expandByPoint(P),g.min.x-=i,g.min.y-=r,g.max.x+=o,g.max.y+=a,u.setFromUnitVectors(ut,E),D&&u.premultiply(gt.invert()),u.premultiply(this._yAxisUpSpace);const S=g.getSize(T),l=g.getCenter(P).applyQuaternion(u);if(V(this._camera)){const _=this.getDistanceToFitBox(S.x,S.y,S.z,s);h.push(this.moveTo(l.x,l.y,l.z,e)),h.push(this.dollyTo(_,e)),h.push(this.setFocalOffset(0,0,0,e))}else if(B(this._camera)){const _=this._camera,y=_.right-_.left,f=_.top-_.bottom,v=s?Math.max(y/S.x,f/S.y):Math.min(y/S.x,f/S.y);h.push(this.moveTo(l.x,l.y,l.z,e)),h.push(this.zoomTo(v,e)),h.push(this.setFocalOffset(0,0,0,e))}return Promise.all(h)}fitToSphere(t,e){const s=[],o="isObject3D"in t?Z.createBoundingSphere(t,ft):ft.copy(t);if(s.push(this.moveTo(o.center.x,o.center.y,o.center.z,e)),V(this._camera)){const r=this.getDistanceToFitSphere(o.radius);s.push(this.dollyTo(r,e))}else if(B(this._camera)){const r=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,h=2*o.radius,c=Math.min(r/h,a/h);s.push(this.zoomTo(c,e))}return s.push(this.setFocalOffset(0,0,0,e)),Promise.all(s)}setLookAt(t,e,s,i,o,r,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=N.NONE,this._changedDolly=0;const h=P.set(i,o,r),c=T.set(t,e,s);this._targetEnd.copy(h),this._sphericalEnd.setFromVector3(c.sub(h).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!a||w(this._target.x,this._targetEnd.x,this.restThreshold)&&w(this._target.y,this._targetEnd.y,this.restThreshold)&&w(this._target.z,this._targetEnd.z,this.restThreshold)&&w(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&w(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&w(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(t,e,s,i,o,r,a,h,c,p,m,E,u,D=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=N.NONE,this._changedDolly=0;const g=T.set(i,o,r),S=P.set(t,e,s);z.setFromVector3(S.sub(g).applyQuaternion(this._yAxisUpSpace));const l=X.set(p,m,E),_=P.set(a,h,c);J.setFromVector3(_.sub(l).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(g.lerp(l,u));const y=J.theta-z.theta,f=J.phi-z.phi,v=J.radius-z.radius;this._sphericalEnd.set(z.radius+v*u,z.phi+f*u,z.theta+y*u),this.normalizeRotations(),this._needsUpdate=!0,D||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!D||w(this._target.x,this._targetEnd.x,this.restThreshold)&&w(this._target.y,this._targetEnd.y,this.restThreshold)&&w(this._target.z,this._targetEnd.z,this.restThreshold)&&w(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&w(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&w(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(O)}setPosition(t,e,s,i=!1){return this.setLookAt(t,e,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(t,e,s,i=!1){const o=this.getPosition(T),r=this.setLookAt(o.x,o.y,o.z,t,e,s,i);return this._sphericalEnd.phi=F(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(t,e,s,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(t,e,s),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const o=!i||w(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&w(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&w(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}setOrbitPoint(t,e,s){this._camera.updateMatrixWorld(),H.setFromMatrixColumn(this._camera.matrixWorldInverse,0),k.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Y.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=T.set(t,e,s),o=i.distanceTo(this._camera.position),r=i.sub(this._camera.position);H.multiplyScalar(r.x),k.multiplyScalar(r.y),Y.multiplyScalar(r.z),T.copy(H).add(k).add(Y),T.z=T.z+o,this.dollyTo(o,!1),this.setFocalOffset(-T.x,T.y,-T.z,!1),this.moveTo(t,e,s,!1)}setBoundary(t){if(!t){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(t),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(t,e,s,i){if(t===null){this._viewport=null;return}this._viewport=this._viewport||new C.Vector4,typeof t=="number"?this._viewport.set(t,e,s,i):this._viewport.copy(t)}getDistanceToFitBox(t,e,s,i=!1){if(pt(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=t/e,r=this._camera.getEffectiveFOV()*j,a=this._camera.aspect;return((i?o>a:o<a)?e:t/a)*.5/Math.tan(r*.5)+s*.5}getDistanceToFitSphere(t){if(pt(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*j,s=Math.atan(Math.tan(e*.5)*this._camera.aspect)*2,i=1<this._camera.aspect?e:s;return t/Math.sin(i*.5)}getTarget(t,e=!0){return(t&&t.isVector3?t:new C.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new C.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new C.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new C.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%q,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=q),this._spherical.theta+=q*Math.round((this._sphericalEnd.theta-this._spherical.theta)/q)}reset(t=!1){if(!w(this._camera.up.x,this._cameraUp0.x)||!w(this._camera.up.y,this._cameraUp0.y)||!w(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(T);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}const e=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,t),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,t),this.zoomTo(this._zoom0,t)];return Promise.all(e)}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,at),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=T.subVectors(this._target,this._camera.position).normalize(),e=P.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(T);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}update(t){const e=this._sphericalEnd.theta-this._spherical.theta,s=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,o=Ut.subVectors(this._targetEnd,this._target),r=Lt.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(U(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=rt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,m,1/0,t),this._needsUpdate=!0}if(U(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const m=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=rt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,m,1/0,t),this._needsUpdate=!0}if(U(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const m=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=rt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,m,this.maxSpeed,t),this._needsUpdate=!0}if(U(o.x)&&U(o.y)&&U(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const m=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;wt(this._target,this._targetEnd,this._targetVelocity,m,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(U(r.x)&&U(r.y)&&U(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const m=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;wt(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,m,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(U(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const m=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=rt(this._zoom,this._zoomEnd,this._zoomVelocity,m,1/0,t)}if(this.dollyToCursor){if(V(this._camera)&&this._changedDolly!==0){const m=this._spherical.radius-this._lastDistance,E=this._camera,u=this._getCameraDirection(W),D=T.copy(u).cross(E.up).normalize();D.lengthSq()===0&&(D.x=1);const g=P.crossVectors(D,u),S=this._sphericalEnd.radius*Math.tan(E.getEffectiveFOV()*j*.5),_=(this._sphericalEnd.radius-m-this._sphericalEnd.radius)/this._sphericalEnd.radius,y=X.copy(this._targetEnd).add(D.multiplyScalar(this._dollyControlCoord.x*S*E.aspect)).add(g.multiplyScalar(this._dollyControlCoord.y*S)),f=T.copy(this._targetEnd).lerp(y,_),v=this._lastDollyDirection===N.IN&&this._spherical.radius<=this.minDistance,O=this._lastDollyDirection===N.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(v||O)){this._sphericalEnd.radius-=m,this._spherical.radius-=m;const R=P.copy(u).multiplyScalar(-m);f.add(R)}this._boundary.clampPoint(f,f);const L=P.subVectors(f,this._targetEnd);this._targetEnd.copy(f),this._target.add(L),this._changedDolly-=m,U(this._changedDolly)&&(this._changedDolly=0)}else if(B(this._camera)&&this._changedZoom!==0){const m=this._zoom-this._lastZoom,E=this._camera,u=T.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(E.near+E.far)/(E.near-E.far)).unproject(E),D=P.set(0,0,-1).applyQuaternion(E.quaternion),g=X.copy(u).add(D.multiplyScalar(-u.dot(E.up))),l=-(this._zoom-m-this._zoom)/this._zoom,_=this._getCameraDirection(W),y=this._targetEnd.dot(_),f=T.copy(this._targetEnd).lerp(g,l),v=f.dot(_),O=_.multiplyScalar(v-y);f.sub(O),this._boundary.clampPoint(f,f);const L=P.subVectors(f,this._targetEnd);this._targetEnd.copy(f),this._target.add(L),this._changedZoom-=m,U(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),(!U(this._focalOffset.x)||!U(this._focalOffset.y)||!U(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),H.setFromMatrixColumn(this._camera.matrix,0),k.setFromMatrixColumn(this._camera.matrix,1),Y.setFromMatrixColumn(this._camera.matrix,2),H.multiplyScalar(this._focalOffset.x),k.multiplyScalar(-this._focalOffset.y),Y.multiplyScalar(this._focalOffset.z),T.copy(H).add(k).add(Y),this._camera.position.add(T)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),T.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),U(e,this.restThreshold)&&U(s,this.restThreshold)&&U(i,this.restThreshold)&&U(o.x,this.restThreshold)&&U(o.y,this.restThreshold)&&U(o.z,this.restThreshold)&&U(r.x,this.restThreshold)&&U(r.y,this.restThreshold)&&U(r.z,this.restThreshold)&&U(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:G(this.maxDistance),minZoom:this.minZoom,maxZoom:G(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:G(this.maxPolarAngle),minAzimuthAngle:G(this.minAzimuthAngle),maxAzimuthAngle:G(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:T.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(t,e=!1){const s=JSON.parse(t);this.enabled=s.enabled,this.minDistance=s.minDistance,this.maxDistance=Q(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=Q(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=Q(s.maxPolarAngle),this.minAzimuthAngle=Q(s.minAzimuthAngle),this.maxAzimuthAngle=Q(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],e),z.setFromVector3(T.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(z.theta,z.phi,e),this.dollyTo(z.radius,e),this.zoomTo(s.zoom,e),this.setFocalOffset(s.focalOffset[0],s.focalOffset[1],s.focalOffset[2],e),this._needsUpdate=!0}connect(t){if(this._domElement){console.warn("camera-controls is already connected.");return}this._addAllEventListeners(t),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(t){return t.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(t){return this._getTargetDirection(t).negate()}_findPointerById(t){return this._activePointers.find(e=>e.pointerId===t)}_findPointerByMouseButton(t){return this._activePointers.find(e=>e.mouseButton===t)}_disposePointer(t){this._activePointers.splice(this._activePointers.indexOf(t),1)}_encloseToBoundary(t,e,s){const i=e.lengthSq();if(i===0)return t;const o=P.copy(e).add(t),a=this._boundary.clampPoint(o,X).sub(o),h=a.lengthSq();if(h===0)return t.add(e);if(h===i)return t;if(s===0)return t.add(e).add(a);{const c=1+s*h/e.dot(a);return t.add(P.copy(e).multiplyScalar(c)).add(a.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(V(this._camera)){const t=this._camera,e=t.near,s=t.getEffectiveFOV()*j,i=Math.tan(s*.5)*e,o=i*t.aspect;this._nearPlaneCorners[0].set(-o,-i,0),this._nearPlaneCorners[1].set(o,-i,0),this._nearPlaneCorners[2].set(o,i,0),this._nearPlaneCorners[3].set(-o,i,0)}else if(B(this._camera)){const t=this._camera,e=1/t.zoom,s=t.left*e,i=t.right*e,o=t.top*e,r=t.bottom*e;this._nearPlaneCorners[0].set(s,o,0),this._nearPlaneCorners[1].set(i,o,0),this._nearPlaneCorners[2].set(i,r,0),this._nearPlaneCorners[3].set(s,r,0)}}_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1)||pt(this._camera,"_collisionTest"))return t;const s=this._getTargetDirection(W);Et.lookAt(St,s,this._camera.up);for(let i=0;i<4;i++){const o=P.copy(this._nearPlaneCorners[i]);o.applyMatrix4(Et);const r=X.addVectors(this._target,o);ht.set(r,s),ht.far=this._spherical.radius+1;const a=ht.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<t&&(t=a[0].distance)}return t}_getClientRect(t){if(!this._domElement)return;const e=this._domElement.getBoundingClientRect();return t.x=e.left,t.y=e.top,this._viewport?(t.x+=this._viewport.x,t.y+=e.height-this._viewport.w-this._viewport.y,t.width=this._viewport.z,t.height=this._viewport.w):(t.width=e.width,t.height=e.height),t}_createOnRestPromise(t){return t?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(e=>{const s=()=>{this.removeEventListener("rest",s),e()};this.addEventListener("rest",s)}))}_addAllEventListeners(t){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(t){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(t){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(t,e=new C.Sphere){const s=e,i=s.center;K.makeEmpty(),t.traverseVisible(r=>{r.isMesh&&K.expandByObject(r)}),K.getCenter(i);let o=0;return t.traverseVisible(r=>{if(!r.isMesh)return;const a=r,h=a.geometry.clone();h.applyMatrix4(a.matrixWorld);const p=h.attributes.position;for(let m=0,E=p.count;m<E;m++)T.fromBufferAttribute(p,m),o=Math.max(o,i.distanceToSquared(T))}),s.radius=Math.sqrt(o),s}}const ae={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMappingExposure:1,alpha:!1,outputColorSpace:Wt.ColorSpace.sRGB,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,stencil:!1,depth:!1,physicallyCorrectLights:!1};class he{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i}=t,{canvas:o,context:r,alpha:a,devicePixelRatio:h,antialias:c,powerPreference:p,toneMappingExposure:m,outputColorSpace:E,logarithmicDepthBuffer:u,preserveDrawingBuffer:D,stencil:g,depth:S,physicallyCorrectLights:l}=i,_=new x.WebGLRenderer({canvas:o,context:r,alpha:a,antialias:c,powerPreference:p,logarithmicDepthBuffer:u,preserveDrawingBuffer:D,stencil:g,depth:S});_.setSize(e,s),_.setPixelRatio(h),_.toneMappingExposure=m,_.outputColorSpace=E,+x.REVISION<155&&(_.useLegacyLights=l),this.renderer=_}setSize(t,e){this.renderer.setSize(t,e)}render(t){const{scene:e,camera:s}=this.options;this.renderer.render(e,t||s)}dispose(){var t,e;this.setSize(1,1),(t=this.renderer)==null||t.clear(),(e=this.renderer)==null||e.dispose()}}class lt{constructor(t){this.guiParams={},t&&(this.guiParams=t)}showGui(t){t&&Object.keys(this.guiParams).forEach(e=>{const s=t.addFolder(e),i=this.guiParams[e];Object.keys(i).forEach(o=>{const{min:r,max:a,step:h,name:c,paramMap:p,items:m,value:E,target:u}=i[o],D=o.toLowerCase().indexOf("color")>-1;let g;const S=typeof E=="undefined"&&u,l=S?u():i[o],_=S?o:"value";m?g=s.add(l,_,m):D?g=s.addColor(l,_):g=s.add(l,_),g=g.name(c||o),typeof r!="undefined"&&(g=g.min(r)),typeof a!="undefined"&&(g=g.max(a)),typeof h!="undefined"&&(g=g.step(h)),g=g.onChange(()=>{this.setTargetValue(e,o,l[_],p)}),S&&g.listen()})})}setTargetValue(t,e,s,i){const{onChange:o,target:r,value:a}=this.guiParams[t][e],h=e.toLowerCase().indexOf("color")>-1;if(r&&!(typeof a=="undefined"&&r)){let p=r();Array.isArray(p)||(p=[p]),p.forEach(m=>{if(m)if(h)try{m[i||e].set(s)}catch(E){e!=="color"&&!i&&console.warn(`${e} is not a color,set paramMap`)}else m[i||e]=s})}o&&o(s)}setTargetValueByParams(){Object.keys(this.guiParams).forEach(t=>{Object.keys(this.guiParams[t]).forEach(e=>{const s=this.guiParams[t][e];typeof s.value!="undefined"&&this.setTargetValue(t,e,s.value,s.paramMap)})})}}const le={fov:45,near:1,far:1e3,up:new x.Vector3(0,1,0)};class ce{constructor(t){this.customCamera=!1,this.syncCamera=null,this.options=t;const{width:e,height:s,cameraParams:i}=t;if(i instanceof x.Camera)this.camera=i,this.customCamera=!0;else{const{fov:o,far:r,near:a,up:h}=i,c=new x.PerspectiveCamera(o,e/s,a,r);c.position.set(0,0,400),c.lookAt(0,0,0),c.up=h,this.camera=c}}setSize(t,e){this.camera instanceof x.PerspectiveCamera&&(this.camera.aspect=t/e),this.camera.updateProjectionMatrix(),this.camera2&&(this.camera2.aspect=t/e,this.camera2.updateProjectionMatrix())}addCamera2(){const t=new x.PerspectiveCamera(this.camera.fov,this.camera.aspect,this.camera.near,this.camera.far);return t.position.copy(this.camera.position),this.camera2=t,t}setGui(t){const e=new lt({camera:ot(I({},this.options.cameraControls?{}:{x:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},y:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position},z:{min:-1e4,max:1e4,step:1,target:()=>this.camera.position}}),{near:{min:0,max:1e3,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}},far:{min:0,max:2e4,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}})});this.camera instanceof x.PerspectiveCamera&&(e.guiParams.camera.fov={min:0,max:90,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}),e.showGui(t)}}const de={background:null,om:!0,addCamera:!0};class me{constructor(t){this.overrideMaterial=!1,this.options=t;const{camera:e,sceneParams:s}=t,{background:i,om:o,addCamera:r}=s,a=o?new x.Scene:new Proxy(new x.Scene,{set:(h,c,p)=>Reflect.set(h,c,p),get:(h,c)=>{if(c==="overrideMaterial"){const p=Reflect.get(h,c);return this.overrideMaterial=!!p,vt.meshLineMaterialArr.forEach(m=>{this.overrideMaterial?m.useDepth=1:m.useDepth=0}),null}return Reflect.get(h,c)}});i&&(a.background=i),r&&a.add(e),this.scene=a}dispose(){var t;(t=this.scene)==null||t.traverse(e=>{Jt.disposeMesh(e)}),vt.meshLineMaterialArr.length=0}}class _e{constructor(t){this.helpers={},this.options=t}add(t){const e=t.uuid,{scene:s}=this.options;let i=this.helpers[e];if(i===void 0){if(t.isScene)i=new x.AxesHelper(100);else if(t.isCamera)i=new x.CameraHelper(t);else if(t.isPointLight)i=new x.PointLightHelper(t,1);else if(t.isDirectionalLight)i=new x.DirectionalLightHelper(t,1);else if(t.isSpotLight)i=new x.SpotLightHelper(t);else if(t.isHemisphereLight)i=new x.HemisphereLightHelper(t,10);else if(t.isRectAreaLight)i=new $t.RectAreaLightHelper(t);else{const o=new x.Box3;if(o.setFromObject(t,!0),o.isEmpty()===!1){i=new x.Box3Helper(o);const r=i.material;r.userData.object=t,r.depthTest=!1,r.transparent=!0}else return}s.add(i),this.helpers[e]=i}}remove(t){const e=t.uuid,{scene:s}=this.options;if(this.helpers[e]!==void 0){const i=this.helpers[e];s.remove(i),delete this.helpers[e],i instanceof x.Box3Helper&&i.dispose()}}removeAll(){Object.keys(this.helpers).forEach(t=>{this.remove({uuid:t})}),this.helpers={}}removeAllExcludeScene(){Object.keys(this.helpers).forEach(t=>{this.helpers[t]instanceof x.AxesHelper||this.remove({uuid:t})})}update(){Object.values(this.helpers).forEach(t=>{if(t.update&&t.update(),t instanceof x.Box3Helper){const e=t.material,{object:s}=e.userData;s&&t.box.setFromObject(s,!0)}})}dispose(){this.helpers={}}}class pe{constructor(t){this.autoRotateSpeed=0,this.options=t;const{camera:e,controlsParams:s,customControl:i}=t,{domElement:o}=s;if(i){const r=new i(e,o);r.enableDamping=!0,r.dampingFactor=.063,r.autoRotate=!1,r.autoRotateSpeed=-60,r.enableZoom=!0,r.zoomSpeed=.2,this.controls=r}else Z.install({THREE:x}),this.cameraControls=new Z(e,o)}addCameraControls2(t){const{controlsParams:e}=this.options,{domElement:s}=e;this.cameraControls2=new Z(t,s),this.cameraControls2.addEventListener("update",()=>{this.cameraControls.enabled=!1}),this.cameraControls2.addEventListener("sleep",()=>{this.cameraControls.enabled=!0})}enable(){this.controls?this.controls.enabled=!0:this.cameraControls&&(this.cameraControls.enabled=!0,this.cameraControls2&&(this.cameraControls2.enabled=!0))}disable(){this.controls?this.controls.enabled=!1:this.cameraControls&&(this.cameraControls.enabled=!1,this.cameraControls2&&(this.cameraControls2.enabled=!1))}update(t){var e,s,i;(e=this.controls)==null||e.update(),(s=this.cameraControls)==null||s.update(t),(i=this.cameraControls2)==null||i.update(t),this.autoRotateSpeed&&this.cameraControls&&(this.cameraControls.azimuthAngle+=this.autoRotateSpeed*t*x.MathUtils.DEG2RAD)}dispose(){var t,e,s;(t=this.controls)==null||t.dispose(),(e=this.cameraControls)==null||e.dispose(),(s=this.cameraControls2)==null||s.dispose()}}class ue{constructor(t){this.event=new Ft.eventsExports.EventEmitter;const{renderer:e,scene:s,camera:i}=t,o=new te.TransformControls(i,e.domElement);s.add(o),this.controls=o,this.addEvent()}get detach(){return this.controls.detach.bind(this.controls)}get attach(){return this.controls.attach.bind(this.controls)}addEvent(){let t=null,e=null,s=null;const i=this.controls;i.addEventListener("change",()=>{const o=i.object;o!==void 0&&this.event.emit("change",o)}),i.addEventListener("mouseDown",()=>{const o=i.object;t=o.position.clone(),e=o.rotation.clone(),s=o.scale.clone(),this.event.emit("mouseDown",o)}),i.addEventListener("mouseUp",()=>{const o=i.object;if(o!==void 0)switch(i.getMode()){case"translate":t.equals(o.position)||this.event.emit("translate",o,o.position,t);break;case"rotate":e.equals(o.rotation)||this.event.emit("rotate",o,o.rotation,e);break;case"scale":s.equals(o.scale)||this.event.emit("scale",o,o.scale,s);break}this.event.emit("mouseUp")})}dispose(){var t;this.event.removeAllListeners(),(t=this.controls)==null||t.dispose()}}const bt={zIndex:"auto"};class fe{constructor(t){this.container=t}addRenderer(t,e){const s=e.container||this.container,i=s.offsetWidth,o=s.offsetHeight,r=t==="css2d"?new se.CSS2DRenderer:new ee.CSS3DRenderer;r.domElement.style.position="absolute",r.domElement.style.top="0",r.domElement.style.pointerEvents="none",r.domElement.style.zIndex=e.zIndex,r.setSize(i,o),s.appendChild(r.domElement),t==="css2d"?this.css2Drenderer=r:t==="css3d"&&(this.css3Drenderer=r)}setSize(t,e){var s,i;(s=this.css2Drenderer)==null||s.setSize(t,e),(i=this.css3Drenderer)==null||i.setSize(t,e)}render(t,e){var s,i;(s=this.css2Drenderer)==null||s.render(t,e),(i=this.css3Drenderer)==null||i.render(t,e)}dispose(){var t,e;(t=this.css2Drenderer)==null||t.domElement.remove(),(e=this.css3Drenderer)==null||e.domElement.remove(),this.css2Drenderer=void 0,this.css3Drenderer=void 0}}const Mt=["encodings_fragment","colorspace_fragment"];class ge extends tt.ShaderMaterial{constructor(){super({uniforms:{inputBuffer:new tt.Uniform(null),ratio:new tt.Uniform(1)},fragmentShader:`
2
2
  uniform sampler2D inputBuffer;
3
3
  uniform float ratio;
4
4
  varying vec2 vUv;
@@ -15,4 +15,4 @@
15
15
  vUv = position.xy * 0.5 + 0.5;
16
16
  gl_Position = vec4(position.xy, 1.0, 1.0);
17
17
  }
18
- `,toneMapped:!1,depthWrite:!1,depthTest:!1})}}class Ee extends b.Pass{constructor(){super("CrossFadePass"),this.fullscreenMaterial=new ge}render(t,e,s){const i=this.fullscreenMaterial;i.uniforms.inputBuffer.value=e.texture,t.setRenderTarget(this.renderToScreen?null:s),t.render(this.scene,this.camera)}}const kt={luminancePass:!1,luminanceThreshold:.4,luminanceSmoothing:.3,mipmapBlur:!0,intensity:3,mipmapBlurPassRadius:.85,blendFunction:b.BlendFunction.ADD,ignoreBackground:!0,epsilon:.001},ye={mode:b.ToneMappingMode.REINHARD2_ADAPTIVE,resolution:256,whitePoint:16,middleGrey:.6,minLuminance:.01,averageLuminance:.01,adaptationRate:1};class Ce{constructor(t){this.active=!0,this.options=t;const{renderer:e,scene:s,camera:i,composerParams:o}=t,{multisampling:r,frameBufferType:a}=o,{maxSamples:h}=e.capabilities,c=new b.EffectComposer(e,{multisampling:Math.min(r,h),frameBufferType:a});this.renderPass=new b.RenderPass(s,i),c.addPass(this.renderPass),this.finalComposer=c,this.renderer=e,this.scene=s,this.camera=i}setRenderPassCamera(t){this.renderPass.mainCamera=t}resetRenderPassCamera(){this.renderPass.mainCamera=this.camera}addCopyPass(){const t=new b.CopyPass;this.finalComposer.addPass(t),this.copyPass=t}addCrossFadePass(){const t=new Ee;this.finalComposer.addPass(t),this.crossFadePass=t}addFXAAPass(){const{camera:t}=this,e=new b.FXAAEffect({blendFunction:b.BlendFunction.NORMAL}),s=new b.EffectPass(t,e);this.finalComposer.addPass(s),this.fxaaPass=s}addToneMappingPass(t){const{camera:e}=this,s=new b.ToneMappingEffect(I({},t));this.toneMappingEffect=s;const i=new b.EffectPass(e,s);this.finalComposer.addPass(i),this.toneMappingPass=i}addToneMappingGui(t){if(!this.toneMappingEffect)return;new lt({toneMapping:{blendFunction:{value:this.toneMappingEffect.mode,items:b.ToneMappingMode,onChange:s=>{this.toneMappingEffect.mode=Number(s)}},exposure:{min:0,max:2,value:this.renderer.toneMappingExposure,step:.001,onChange:s=>{this.renderer.toneMappingExposure=s}}},"Reinhard (Modified)":{whitePoint:{min:2,max:32,step:.001,target:()=>this.toneMappingEffect},middleGrey:{min:0,max:1,step:1e-4,target:()=>this.toneMappingEffect},averageLuminance:{min:1e-4,max:1,step:1e-4,target:()=>this.toneMappingEffect}}}).showGui(t)}addBloomPass(t){const{camera:e,scene:s}=this,p=I(I({},kt),t),{epsilon:i,ignoreBackground:o,mipmapBlurPassRadius:r}=p,a=Tt(p,["epsilon","ignoreBackground","mipmapBlurPassRadius"]),h=new b.SelectiveBloomEffect(s,e,I({},a));o&&(h.ignoreBackground=o),r&&(h.mipmapBlurPass.radius=r),h.depthMaskMaterial.epsilon=i,h.luminancePass.enabled=!1,h.luminancePass.enabled=t.luminancePass;const c=new b.EffectPass(e,h);this.finalComposer.addPass(c),this.bloomPass=c,this.bloomEffect=h}addBloomGui(t){if(!this.bloomEffect)return;new lt({bloom:{intensity:{min:0,max:10,step:.01,target:()=>this.bloomEffect},radius:{min:0,max:1,step:.001,target:()=>this.bloomEffect.mipmapBlurPass},blendFunction:{value:this.bloomEffect.blendMode.blendFunction,items:b.BlendFunction,onChange:s=>{this.bloomEffect.blendMode.blendFunction=Number(s)}},ignoreBackground:{value:this.bloomEffect.ignoreBackground,onChange:s=>{this.bloomEffect.ignoreBackground=s}}},bloomLuminanceFilter:{enabled:{value:this.bloomEffect.luminancePass.enabled,onChange:s=>{this.bloomEffect.luminancePass.enabled=s}},threshold:{min:0,max:1,step:.01,target:()=>this.bloomEffect.luminanceMaterial},smoothing:{min:0,max:1,step:.01,target:()=>this.bloomEffect.luminanceMaterial}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomEffect||!this.bloomPass){console.warn("err:pencil.options.bloom");return}t?e===!0?this.bloomEffect.selection.add(t):e===!1?this.bloomEffect.selection.delete(t):this.bloomEffect.selection.toggle(t):this.bloomEffect.selection.clear()}getSize(){const{renderer:t}=this.options;return t.getSize(new x.Vector2)}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){this.finalComposer.setSize(t,e)}render(){this.active&&this.finalComposer.render()}render2(){this.active}dispose(){this.finalComposer.dispose()}}const Oe=()=>{try{const d=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&d.getContext("webgl2"))}catch(d){return!1}},$=!1,zt=Oe()!==!1,dt=class dt{constructor(t,e){this.raycaster=new x.Raycaster,this.installPlugins=new Map,this.event=new Ft.eventsExports.EventEmitter,this.clock=new x.Clock,this.userData={},this.pipViewportState=!1,this.options=jt(dt.options,t,{isMergeableObject:ie.isPlainObject}),this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:o,resizeObserver:r}=this.options;if(o){const a=new Qt;a.open(!1),this.gui=a}if(i){const a=new Gt;a.showPanel(0),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}this.init(),this.initComposer(),this.initCSSRenderer(),this.initControls(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime(),e&&(Array.isArray(e)||(e=[e]),e.forEach(a=>{Array.isArray(a)||(a=[a]),this.use(a[0],a[1])}))}getPlugin(t){return this.installPlugins.get(t)}get renderer(){return this.rendererController.renderer}get maxAnisotropy(){return this.renderer.capabilities.getMaxAnisotropy()}get cameraControls(){return this.controlsController.cameraControls}get cameraPositon(){return this.cameraControls.getPosition(new x.Vector3,!1)}get cameraTarget(){return this.cameraControls.getTarget(new x.Vector3,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(t,...e){this.installPlugins.has(t.pluginName)?console.log("plugin already installed"):typeof t.install=="function"&&(t.install(this,...e),this.installPlugins.set(t.pluginName,t))}init(){const{container:t,isdev:e,helper:s,renderer:i,scene:o,camera:r,control:a}=this.options,{width:h,height:c}=this.getSize(),p=new ce({isdev:e,width:h,height:c,cameraParams:r,cameraControls:a===!0});this.gui&&p.setGui(this.gui);const m=p.camera,E=new me({camera:m,sceneParams:o}),u=E.scene,D=new he({width:h,height:c,scene:u,camera:m,isdev:e,rendererParams:ot(I({},i),{antialias:!1})});if(s){const g=new _e({scene:u});g.add(u),this.helperController=g}this.sceneController=E,this.rendererController=D,this.cameraController=p,t.appendChild(D.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,toneMapping:s,toneMappingParams:i,crossOpacity:o,renderer:r,multisampling:a,frameBufferType:h,passes:c}=this.options;let{antialias:p}=r;p==="msaa"&&!zt&&(p=!1,console.warn("MSAA is not supported on this browser"));const m=new Ce({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:p==="msaa"?a:0,frameBufferType:s?x.HalfFloatType:h}});this.composerController=m,t&&(m.addBloomPass(e),this.gui&&m.addBloomGui(this.gui)),s&&(m.addToneMappingPass(i),this.gui&&m.addToneMappingGui(this.gui)),p==="fxaa"&&m.addFXAAPass(),o&&m.addCrossFadePass(),c&&c.forEach(E=>{m.finalComposer.addPass(E)}),m.finalComposer.passes.length===1&&m.addCopyPass()}get opacity(){const{crossFadePass:t}=this.composerController;return t?t.fullscreenMaterial.uniforms.ratio.value:1}set opacity(t){const{crossFadePass:e}=this.composerController;if(!e){console.warn("err:pencil.options.crossOpacity");return}e.fullscreenMaterial.uniforms.ratio.value=t}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new fe(t);e&&r.addRenderer("css2d",i),s&&r.addRenderer("css3d",o),this.cssRendererController=r}}initControls(){const{control:t,controlParams:e,transformControls:s}=this.options;if(t){const i=new pe({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new ue({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var o;(o=this.controlsController)==null||o.disable()}),i.event.on("mouseUp",()=>{var o;(o=this.controlsController)==null||o.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=this.getSize(),s=new ResizeObserver(i=>{for(const o of i){const r=o.contentRect;(r.width!==e.width||r.height!==e.height)&&(e.width=r.width,e.height=r.height,this.handeleResize(r.width,r.height),this.render())}});s.observe(t),this.resizeObserver=s}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:o,composerController:r,cssRendererController:a}=this;o==null||o.setSize(t,e),i==null||i.setSize(t,e),r==null||r.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(h=>{var c;(c=h.setSize)==null||c.call(h,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!1){const{raycaster:i,options:o}=this,{container:r}=o,a=new x.Vector2,h=r.getBoundingClientRect();if(a.x=(t.clientX-h.left)/(h.right-h.left)*2-1,a.y=-((t.clientY-h.top)/(h.bottom-h.top))*2+1,this.camera&&this.scene){i.setFromCamera(a,this.camera);const c=i.intersectObjects(e||this.scene.children,s);if(c.length)return{object:c[0].object,intersects:c}}}render(){var r,a,h,c,p,m;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Pt.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(E=>{var u;(u=E.update)==null||u.call(E,i,o)}),(a=this.helperController)==null||a.update(),(h=this.composerController)!=null&&h.active?this.cameraController.camera2?(this.composerController.resetRenderPassCamera(),this.setViewportFull(),this.composerController.render(),this.pipViewportState&&(this.setViewportPip(),this.composerController.setRenderPassCamera(this.cameraController.camera2),this.composerController.render())):this.composerController.render():(c=this.rendererController)==null||c.render(),(p=this.cssRendererController)==null||p.render(t,e),(m=this.stats)==null||m.update(),this.event.emit("render",{delta:i,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(t){this.controlsController.autoRotateSpeed=t}showPipViewport(t){if(t===!0){const e=this.getSize(),s=240,i=s/e.width,o=s/e.height,r=1-i,a=1-o;t={left:r,top:a,width:i,height:o}}if(this.pipViewportState=t,t){if(this.controlsController.cameraControls2)this.controlsController.cameraControls2.enabled=!0,this.cameraController.camera2.position.copy(this.cameraController.camera.position);else{const e=this.cameraController.addCamera2();this.controlsController.addCameraControls2(e)}this.controlsController.cameraControls2.interactiveArea=new DOMRect(t.left,t.top,t.width,t.height)}else this.controlsController.cameraControls2&&(this.controlsController.cameraControls2.enabled=!1)}setViewportFull(){const t=this.getSize(),e=0,s=0,i=t.width,o=t.height,r=i/o;this.camera.aspect!==r&&(this.camera.aspect=r,this.camera.updateProjectionMatrix()),this.renderer.setViewport(e,s,i,o),this.renderer.setScissor(e,s,i,o),this.renderer.setScissorTest(!0)}setViewportPip(){if(!this.pipViewportState)return;const t=this.pipViewportState,e=this.getSize(),s=e.width*t.left,i=(1-(t.top+t.height))*e.height,o=e.width*t.width,r=e.height*t.height,a=o/r,h=this.cameraController.camera2;h&&h.aspect!==a&&(h.aspect=a,h.updateProjectionMatrix()),this.renderer.setViewport(s,i,o,r),this.renderer.setScissor(s,i,o,r),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,o,r,a,h,c,p,m;this.stop(),Pt.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(E=>{var u;(u=E.dispose)==null||u.call(E)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(o=this.sceneController)==null||o.dispose(),(r=this.helperController)==null||r.dispose(),(a=this.composerController)==null||a.dispose(),(h=this.rendererController)==null||h.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(p=this.stats)==null||p.dom.remove(),(m=this.renderer)==null||m.domElement.remove()}};dt.options={isdev:$,stats:$,gui:$,helper:$,control:!0,transformControls:$,resizeObserver:!0,renderer:ot(I({},ae),{antialias:zt?"msaa":"fxaa"}),multisampling:4,frameBufferType:x.UnsignedByteType,scene:de,camera:le,bloom:!1,bloomParams:kt,toneMapping:!1,toneMappingParams:ye,crossOpacity:!1,css2DRenderer:!1,css2DRendererParams:I({},bt),css3DRenderer:!1,css3DRendererParams:I({},bt)};let ct=dt;const Te=Z.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=lt;exports.Pencil=ct;exports.cameraControlsAction=Te;exports.default=ct;
18
+ `,toneMapped:!1,depthWrite:!1,depthTest:!1})}}class Ee extends b.Pass{constructor(){super("CrossFadePass"),this.fullscreenMaterial=new ge}render(t,e,s){const i=this.fullscreenMaterial;i.uniforms.inputBuffer.value=e.texture,t.setRenderTarget(this.renderToScreen?null:s),t.render(this.scene,this.camera)}}const kt={luminancePass:!1,luminanceThreshold:.4,luminanceSmoothing:.3,mipmapBlur:!0,intensity:3,mipmapBlurPassRadius:.85,blendFunction:b.BlendFunction.ADD,ignoreBackground:!0,epsilon:.001},ye={mode:b.ToneMappingMode.REINHARD2_ADAPTIVE,resolution:256,whitePoint:16,middleGrey:.6,minLuminance:.01,averageLuminance:.01,adaptationRate:1};class Ce{constructor(t){this.active=!0,this.options=t;const{renderer:e,scene:s,camera:i,composerParams:o}=t,{multisampling:r,frameBufferType:a}=o,{maxSamples:h}=e.capabilities,c=new b.EffectComposer(e,{multisampling:Math.min(r,h),frameBufferType:a});this.renderPass=new b.RenderPass(s,i),c.addPass(this.renderPass),this.finalComposer=c,this.renderer=e,this.scene=s,this.camera=i}setRenderPassCamera(t){this.renderPass.mainCamera=t}resetRenderPassCamera(){this.renderPass.mainCamera=this.camera}addCopyPass(){const t=new b.CopyPass;this.finalComposer.addPass(t),this.copyPass=t}addCrossFadePass(){const t=new Ee;this.finalComposer.addPass(t),this.crossFadePass=t}addFXAAPass(){const{camera:t}=this,e=new b.FXAAEffect({blendFunction:b.BlendFunction.NORMAL}),s=new b.EffectPass(t,e);this.finalComposer.addPass(s),this.fxaaPass=s}addToneMappingPass(t){const{camera:e}=this,s=new b.ToneMappingEffect(I({},t));this.toneMappingEffect=s;const i=new b.EffectPass(e,s);this.finalComposer.addPass(i),this.toneMappingPass=i}addToneMappingGui(t){if(!this.toneMappingEffect)return;new lt({toneMapping:{blendFunction:{value:this.toneMappingEffect.mode,items:b.ToneMappingMode,onChange:s=>{this.toneMappingEffect.mode=Number(s)}},exposure:{min:0,max:2,value:this.renderer.toneMappingExposure,step:.001,onChange:s=>{this.renderer.toneMappingExposure=s}}},"Reinhard (Modified)":{whitePoint:{min:2,max:32,step:.001,target:()=>this.toneMappingEffect},middleGrey:{min:0,max:1,step:1e-4,target:()=>this.toneMappingEffect},averageLuminance:{min:1e-4,max:1,step:1e-4,target:()=>this.toneMappingEffect}}}).showGui(t)}addBloomPass(t){const{camera:e,scene:s}=this,p=I(I({},kt),t),{epsilon:i,ignoreBackground:o,mipmapBlurPassRadius:r}=p,a=Tt(p,["epsilon","ignoreBackground","mipmapBlurPassRadius"]),h=new b.SelectiveBloomEffect(s,e,I({},a));o&&(h.ignoreBackground=o),r&&(h.mipmapBlurPass.radius=r),h.depthMaskMaterial.epsilon=i,h.luminancePass.enabled=!1,h.luminancePass.enabled=t.luminancePass;const c=new b.EffectPass(e,h);this.finalComposer.addPass(c),this.bloomPass=c,this.bloomEffect=h}addBloomGui(t){if(!this.bloomEffect)return;new lt({bloom:{intensity:{min:0,max:10,step:.01,target:()=>this.bloomEffect},radius:{min:0,max:1,step:.001,target:()=>this.bloomEffect.mipmapBlurPass},blendFunction:{value:this.bloomEffect.blendMode.blendFunction,items:b.BlendFunction,onChange:s=>{this.bloomEffect.blendMode.blendFunction=Number(s)}},ignoreBackground:{value:this.bloomEffect.ignoreBackground,onChange:s=>{this.bloomEffect.ignoreBackground=s}}},bloomLuminanceFilter:{enabled:{value:this.bloomEffect.luminancePass.enabled,onChange:s=>{this.bloomEffect.luminancePass.enabled=s}},threshold:{min:0,max:1,step:.01,target:()=>this.bloomEffect.luminanceMaterial},smoothing:{min:0,max:1,step:.01,target:()=>this.bloomEffect.luminanceMaterial}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomEffect||!this.bloomPass){console.warn("err:pencil.options.bloom");return}t?e===!0?this.bloomEffect.selection.add(t):e===!1?this.bloomEffect.selection.delete(t):this.bloomEffect.selection.toggle(t):this.bloomEffect.selection.clear()}getSize(){const{renderer:t}=this.options;return t.getSize(new x.Vector2)}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){this.finalComposer.setSize(t,e)}render(){this.active&&this.finalComposer.render()}render2(){this.active}dispose(){this.finalComposer.dispose()}}const Oe=()=>{try{const d=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&d.getContext("webgl2"))}catch(d){return!1}},$=!1,zt=Oe()!==!1,dt=class dt{constructor(t,e){this.raycaster=new x.Raycaster,this.installPlugins=new Map,this.event=new Ft.eventsExports.EventEmitter,this.clock=new x.Clock,this.userData={},this.pipViewportState=!1,this.options=jt(dt.options,t,{isMergeableObject:ie.isPlainObject}),this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:o,resizeObserver:r}=this.options;if(o){const a=new Qt;a.open(!1),this.gui=a}if(i){const a=new Gt;a.showPanel(0),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}this.init(),this.initComposer(),this.initCSSRenderer(),this.initControls(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime(),e&&(Array.isArray(e)||(e=[e]),e.forEach(a=>{Array.isArray(a)||(a=[a]),this.use(a[0],a[1])}))}getPlugin(t){return this.installPlugins.get(t)}get renderer(){return this.rendererController.renderer}get maxAnisotropy(){return this.renderer.capabilities.getMaxAnisotropy()}get cameraControls(){return this.controlsController.cameraControls}get cameraPositon(){return this.cameraControls.getPosition(new x.Vector3,!1)}get cameraTarget(){return this.cameraControls.getTarget(new x.Vector3,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(t,...e){this.installPlugins.has(t.pluginName)?console.log("plugin already installed"):typeof t.install=="function"&&(t.install(this,...e),this.installPlugins.set(t.pluginName,t))}init(){const{container:t,isdev:e,helper:s,renderer:i,scene:o,camera:r,control:a}=this.options,{width:h,height:c}=this.getSize(),p=new ce({isdev:e,width:h,height:c,cameraParams:r,cameraControls:a===!0});this.gui&&p.setGui(this.gui);const m=p.camera,E=new me({camera:m,sceneParams:o}),u=E.scene,D=new he({width:h,height:c,scene:u,camera:m,isdev:e,rendererParams:ot(I({},i),{antialias:!1})});if(s){const g=new _e({scene:u});g.add(u),this.helperController=g}this.sceneController=E,this.rendererController=D,this.cameraController=p,t.appendChild(D.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,toneMapping:s,toneMappingParams:i,crossOpacity:o,renderer:r,multisampling:a,frameBufferType:h,passes:c}=this.options;let{antialias:p}=r;p==="msaa"&&!zt&&(p=!1,console.warn("MSAA is not supported on this browser"));const m=new Ce({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:p==="msaa"?a:0,frameBufferType:s?x.HalfFloatType:h}});this.composerController=m,t&&(m.addBloomPass(e),this.gui&&m.addBloomGui(this.gui)),s&&(m.addToneMappingPass(i),this.gui&&m.addToneMappingGui(this.gui)),p==="fxaa"&&m.addFXAAPass(),o&&m.addCrossFadePass(),c&&c.forEach(E=>{m.finalComposer.addPass(E)}),m.finalComposer.passes.length===1&&m.addCopyPass()}get opacity(){const{crossFadePass:t}=this.composerController;return t?t.fullscreenMaterial.uniforms.ratio.value:1}set opacity(t){const{crossFadePass:e}=this.composerController;if(!e){console.warn("err:pencil.options.crossOpacity");return}e.fullscreenMaterial.uniforms.ratio.value=t}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new fe(t);e&&r.addRenderer("css2d",i),s&&r.addRenderer("css3d",o),this.cssRendererController=r}}initControls(){const{control:t,controlParams:e,transformControls:s}=this.options;if(t){const i=new pe({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new ue({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var o;(o=this.controlsController)==null||o.disable()}),i.event.on("mouseUp",()=>{var o;(o=this.controlsController)==null||o.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=this.getSize(),s=new ResizeObserver(i=>{for(const o of i){const r=o.contentRect;(r.width!==e.width||r.height!==e.height)&&(e.width=r.width,e.height=r.height,this.handeleResize(r.width,r.height),this.render())}});s.observe(t),this.resizeObserver=s}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:o,composerController:r,cssRendererController:a}=this;o==null||o.setSize(t,e),i==null||i.setSize(t,e),r==null||r.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(h=>{var c;(c=h.setSize)==null||c.call(h,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!1){const{raycaster:i,options:o}=this,{container:r}=o,a=new x.Vector2,h=r.getBoundingClientRect();if(a.x=(t.clientX-h.left)/(h.right-h.left)*2-1,a.y=-((t.clientY-h.top)/(h.bottom-h.top))*2+1,this.camera&&this.scene){i.setFromCamera(a,this.camera);const c=i.intersectObjects(e||this.scene.children,s);if(c.length)return{object:c[0].object,intersects:c}}}render(){var r,a,h,c,p,m;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Pt.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(E=>{var u;(u=E.update)==null||u.call(E,i,o)}),(a=this.helperController)==null||a.update(),this.cameraController.syncCamera&&!(this.camera.matrixWorld.equals(this.cameraController.syncCamera.matrixWorld)&&this.camera.far===this.cameraController.syncCamera.far&&this.camera.near===this.cameraController.syncCamera.near&&this.camera.fov===this.cameraController.syncCamera.fov&&this.camera.aspect===this.cameraController.syncCamera.aspect)&&this.camera.copy(this.cameraController.syncCamera),(h=this.composerController)!=null&&h.active?this.cameraController.camera2?(this.composerController.resetRenderPassCamera(),this.setViewportFull(),this.composerController.render(),this.pipViewportState&&(this.setViewportPip(),this.composerController.setRenderPassCamera(this.cameraController.camera2),this.composerController.render())):this.composerController.render():(c=this.rendererController)==null||c.render(),(p=this.cssRendererController)==null||p.render(t,e),(m=this.stats)==null||m.update(),this.event.emit("render",{delta:i,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(t){this.controlsController.autoRotateSpeed=t}showPipViewport(t){if(t===!0){const e=this.getSize(),s=240,i=s/e.width,o=s/e.height,r=1-i,a=1-o;t={left:r,top:a,width:i,height:o}}if(this.pipViewportState=t,t){if(this.controlsController.cameraControls2)this.controlsController.cameraControls2.enabled=!0,this.cameraController.camera2.position.copy(this.cameraController.camera.position);else{const e=this.cameraController.addCamera2();this.controlsController.addCameraControls2(e)}this.controlsController.cameraControls2.interactiveArea=new DOMRect(t.left,t.top,t.width,t.height)}else this.controlsController.cameraControls2&&(this.controlsController.cameraControls2.enabled=!1)}setViewportFull(){const t=this.getSize(),e=0,s=0,i=t.width,o=t.height,r=i/o;this.camera.aspect!==r&&(this.camera.aspect=r,this.camera.updateProjectionMatrix()),this.renderer.setViewport(e,s,i,o),this.renderer.setScissor(e,s,i,o),this.renderer.setScissorTest(!0)}setViewportPip(){if(!this.pipViewportState)return;const t=this.pipViewportState,e=this.getSize(),s=e.width*t.left,i=(1-(t.top+t.height))*e.height,o=e.width*t.width,r=e.height*t.height,a=o/r,h=this.cameraController.camera2;h&&h.aspect!==a&&(h.aspect=a,h.updateProjectionMatrix()),this.renderer.setViewport(s,i,o,r),this.renderer.setScissor(s,i,o,r),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,o,r,a,h,c,p,m;this.stop(),Pt.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(E=>{var u;(u=E.dispose)==null||u.call(E)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(o=this.sceneController)==null||o.dispose(),(r=this.helperController)==null||r.dispose(),(a=this.composerController)==null||a.dispose(),(h=this.rendererController)==null||h.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(p=this.stats)==null||p.dom.remove(),(m=this.renderer)==null||m.domElement.remove()}};dt.options={isdev:$,stats:$,gui:$,helper:$,control:!0,transformControls:$,resizeObserver:!0,renderer:ot(I({},ae),{antialias:zt?"msaa":"fxaa"}),multisampling:4,frameBufferType:x.UnsignedByteType,scene:de,camera:le,bloom:!1,bloomParams:kt,toneMapping:!1,toneMappingParams:ye,crossOpacity:!1,css2DRenderer:!1,css2DRendererParams:I({},bt),css3DRenderer:!1,css3DRendererParams:I({},bt)};let ct=dt;const Te=Z.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=lt;exports.Pencil=ct;exports.cameraControlsAction=Te;exports.default=ct;
@@ -95,27 +95,27 @@ function it(d, t, e, s, i = 1 / 0, o) {
95
95
  s = Math.max(1e-4, s);
96
96
  const r = 2 / s, a = r * o, h = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
97
97
  let c = d - t;
98
- const p = t, m = i * s;
98
+ const _ = t, m = i * s;
99
99
  c = M(c, -m, m), t = d - c;
100
100
  const E = (e.value + r * c) * o;
101
101
  e.value = (e.value - r * E) * h;
102
102
  let u = t + (c + E) * h;
103
- return p - d > 0 == u > p && (u = p, e.value = (u - p) / o), u;
103
+ return _ - d > 0 == u > _ && (u = _, e.value = (u - _) / o), u;
104
104
  }
105
105
  function Dt(d, t, e, s, i = 1 / 0, o, r) {
106
106
  s = Math.max(1e-4, s);
107
107
  const a = 2 / s, h = a * o, c = 1 / (1 + h + 0.48 * h * h + 0.235 * h * h * h);
108
- let p = t.x, m = t.y, E = t.z, u = d.x - p, w = d.y - m, g = d.z - E;
109
- const S = p, l = m, _ = E, y = i * s, f = y * y, v = u * u + w * w + g * g;
108
+ let _ = t.x, m = t.y, E = t.z, u = d.x - _, w = d.y - m, g = d.z - E;
109
+ const S = _, l = m, p = E, y = i * s, f = y * y, v = u * u + w * w + g * g;
110
110
  if (v > f) {
111
111
  const ht = Math.sqrt(v);
112
112
  u = u / ht * y, w = w / ht * y, g = g / ht * y;
113
113
  }
114
- p = d.x - u, m = d.y - w, E = d.z - g;
114
+ _ = d.x - u, m = d.y - w, E = d.z - g;
115
115
  const O = (e.x + a * u) * o, L = (e.y + a * w) * o, R = (e.z + a * g) * o;
116
- e.x = (e.x - a * O) * c, e.y = (e.y - a * L) * c, e.z = (e.z - a * R) * c, r.x = p + (u + O) * c, r.y = m + (w + L) * c, r.z = E + (g + R) * c;
117
- const $ = S - d.x, tt = l - d.y, Vt = _ - d.z, Yt = r.x - S, Zt = r.y - l, Nt = r.z - _;
118
- return $ * Yt + tt * Zt + Vt * Nt > 0 && (r.x = S, r.y = l, r.z = _, e.x = (r.x - S) / o, e.y = (r.y - l) / o, e.z = (r.z - _) / o), r;
116
+ e.x = (e.x - a * O) * c, e.y = (e.y - a * L) * c, e.z = (e.z - a * R) * c, r.x = _ + (u + O) * c, r.y = m + (w + L) * c, r.z = E + (g + R) * c;
117
+ const $ = S - d.x, tt = l - d.y, Vt = p - d.z, Yt = r.x - S, Zt = r.y - l, Nt = r.z - p;
118
+ return $ * Yt + tt * Zt + Vt * Nt > 0 && (r.x = S, r.y = l, r.z = p, e.x = (r.x - S) / o, e.y = (r.y - l) / o, e.z = (r.z - p) / o), r;
119
119
  }
120
120
  function ct(d, t) {
121
121
  t.set(0, 0), d.forEach((e) => {
@@ -125,7 +125,7 @@ function ct(d, t) {
125
125
  function dt(d, t) {
126
126
  return k(d) ? (console.warn(`${t} is not supported in OrthographicCamera`), !0) : !1;
127
127
  }
128
- class _e {
128
+ class pe {
129
129
  constructor() {
130
130
  this._listeners = {};
131
131
  }
@@ -189,9 +189,9 @@ class _e {
189
189
  }
190
190
  }
191
191
  }
192
- const ot = 1 / 8, pe = /Mac/.test(navigator.platform);
193
- let C, St, rt, mt, b, T, x, X, q, I, H, V, Ut, Lt, z, W, K, At, _t, Rt, pt, ut, nt;
194
- class Y extends _e {
192
+ const ot = 1 / 8, _e = /Mac/.test(navigator.platform);
193
+ let C, St, rt, mt, b, T, x, X, q, I, H, V, Ut, Lt, z, W, K, At, pt, Rt, _t, ut, nt;
194
+ class Y extends pe {
195
195
  /**
196
196
  * Injects THREE as the dependency. You can then proceed to use CameraControls.
197
197
  *
@@ -233,7 +233,7 @@ class Y extends _e {
233
233
  * @category Statics
234
234
  */
235
235
  static install(t) {
236
- C = t.THREE, St = Object.freeze(new C.Vector3(0, 0, 0)), rt = Object.freeze(new C.Vector3(0, 1, 0)), mt = Object.freeze(new C.Vector3(0, 0, 1)), b = new C.Vector2(), T = new C.Vector3(), x = new C.Vector3(), X = new C.Vector3(), q = new C.Vector3(), I = new C.Vector3(), H = new C.Vector3(), V = new C.Vector3(), Ut = new C.Vector3(), Lt = new C.Vector3(), z = new C.Spherical(), W = new C.Spherical(), K = new C.Box3(), At = new C.Box3(), _t = new C.Sphere(), Rt = new C.Quaternion(), pt = new C.Quaternion(), ut = new C.Matrix4(), nt = new C.Raycaster();
236
+ C = t.THREE, St = Object.freeze(new C.Vector3(0, 0, 0)), rt = Object.freeze(new C.Vector3(0, 1, 0)), mt = Object.freeze(new C.Vector3(0, 0, 1)), b = new C.Vector2(), T = new C.Vector3(), x = new C.Vector3(), X = new C.Vector3(), q = new C.Vector3(), I = new C.Vector3(), H = new C.Vector3(), V = new C.Vector3(), Ut = new C.Vector3(), Lt = new C.Vector3(), z = new C.Spherical(), W = new C.Spherical(), K = new C.Box3(), At = new C.Box3(), pt = new C.Sphere(), Rt = new C.Quaternion(), _t = new C.Quaternion(), ut = new C.Matrix4(), nt = new C.Raycaster();
237
237
  }
238
238
  /**
239
239
  * list all ACTIONs
@@ -261,14 +261,14 @@ class Y extends _e {
261
261
  */
262
262
  constructor(t, e) {
263
263
  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 = 0.01, this.maxZoom = 1 / 0, this.smoothTime = 0.25, this.draggingSmoothTime = 0.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 = 0.01, this.colliderMeshes = [], this.cancel = () => {
264
- }, this._enabled = !0, this._state = n.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 = Z.NONE, this._thetaVelocity = { value: 0 }, this._phiVelocity = { value: 0 }, this._radiusVelocity = { value: 0 }, this._targetVelocity = new C.Vector3(), this._focalOffsetVelocity = new C.Vector3(), this._zoomVelocity = { value: 0 }, this._truckInternal = (l, _, y) => {
264
+ }, this._enabled = !0, this._state = n.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 = Z.NONE, this._thetaVelocity = { value: 0 }, this._phiVelocity = { value: 0 }, this._radiusVelocity = { value: 0 }, this._targetVelocity = new C.Vector3(), this._focalOffsetVelocity = new C.Vector3(), this._zoomVelocity = { value: 0 }, this._truckInternal = (l, p, y) => {
265
265
  let f, v;
266
266
  if (B(this._camera)) {
267
267
  const O = T.copy(this._camera.position).sub(this._target), L = this._camera.getEffectiveFOV() * G, R = O.length() * Math.tan(L * 0.5);
268
- f = this.truckSpeed * l * R / this._elementRect.height, v = this.truckSpeed * _ * R / this._elementRect.height;
268
+ f = this.truckSpeed * l * R / this._elementRect.height, v = this.truckSpeed * p * R / this._elementRect.height;
269
269
  } else if (k(this._camera)) {
270
270
  const O = this._camera;
271
- f = l * (O.right - O.left) / O.zoom / this._elementRect.width, v = _ * (O.top - O.bottom) / O.zoom / this._elementRect.height;
271
+ f = l * (O.right - O.left) / O.zoom / this._elementRect.width, v = p * (O.top - O.bottom) / O.zoom / this._elementRect.height;
272
272
  } else
273
273
  return;
274
274
  this.verticalDragToForward ? (y ? this.setFocalOffset(
@@ -282,19 +282,19 @@ class Y extends _e {
282
282
  this._focalOffsetEnd.z,
283
283
  !0
284
284
  ) : this.truck(f, v, !0);
285
- }, this._rotateInternal = (l, _) => {
286
- const y = N * this.azimuthRotateSpeed * l / this._elementRect.height, f = N * this.polarRotateSpeed * _ / this._elementRect.height;
285
+ }, this._rotateInternal = (l, p) => {
286
+ const y = N * this.azimuthRotateSpeed * l / this._elementRect.height, f = N * this.polarRotateSpeed * p / this._elementRect.height;
287
287
  this.rotate(y, f, !0);
288
- }, this._dollyInternal = (l, _, y) => {
288
+ }, this._dollyInternal = (l, p, y) => {
289
289
  const f = Math.pow(0.95, -l * this.dollySpeed), v = this._sphericalEnd.radius, O = this._sphericalEnd.radius * f, L = M(
290
290
  O,
291
291
  this.minDistance,
292
292
  this.maxDistance
293
293
  ), R = L - O;
294
- this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(O, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(R, !0), this._dollyToNoClamp(L, !0)) : this._dollyToNoClamp(L, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? O : L) - v, this._dollyControlCoord.set(_, y)), this._lastDollyDirection = Math.sign(-l);
295
- }, this._zoomInternal = (l, _, y) => {
294
+ this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(O, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(R, !0), this._dollyToNoClamp(L, !0)) : this._dollyToNoClamp(L, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? O : L) - v, this._dollyControlCoord.set(p, y)), this._lastDollyDirection = Math.sign(-l);
295
+ }, this._zoomInternal = (l, p, y) => {
296
296
  const f = Math.pow(0.95, l * this.dollySpeed), v = this._zoom, O = this._zoom * f;
297
- this.zoomTo(O, !0), this.dollyToCursor && (this._changedZoom += O - v, this._dollyControlCoord.set(_, y));
297
+ this.zoomTo(O, !0), this.dollyToCursor && (this._changedZoom += O - v, this._dollyControlCoord.set(p, y));
298
298
  }, typeof C == "undefined" && console.error(
299
299
  "camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."
300
300
  ), this._camera = t, this._yAxisUpSpace = new C.Quaternion().setFromUnitVectors(
@@ -327,9 +327,9 @@ class Y extends _e {
327
327
  if (v < this._interactiveArea.left || v > this._interactiveArea.right || O < this._interactiveArea.top || O > this._interactiveArea.bottom)
328
328
  return;
329
329
  }
330
- const _ = l.pointerType !== "mouse" ? null : (l.buttons & A.LEFT) === A.LEFT ? A.LEFT : (l.buttons & A.MIDDLE) === A.MIDDLE ? A.MIDDLE : (l.buttons & A.RIGHT) === A.RIGHT ? A.RIGHT : null;
331
- if (_ !== null) {
332
- const f = this._findPointerByMouseButton(_);
330
+ const p = l.pointerType !== "mouse" ? null : (l.buttons & A.LEFT) === A.LEFT ? A.LEFT : (l.buttons & A.MIDDLE) === A.MIDDLE ? A.MIDDLE : (l.buttons & A.RIGHT) === A.RIGHT ? A.RIGHT : null;
331
+ if (p !== null) {
332
+ const f = this._findPointerByMouseButton(p);
333
333
  f && this._disposePointer(f);
334
334
  }
335
335
  if ((l.buttons & A.LEFT) === A.LEFT && this._lockedPointer)
@@ -340,7 +340,7 @@ class Y extends _e {
340
340
  clientY: l.clientY,
341
341
  deltaX: 0,
342
342
  deltaY: 0,
343
- mouseButton: _
343
+ mouseButton: p
344
344
  };
345
345
  this._activePointers.push(y), this._domElement.ownerDocument.removeEventListener(
346
346
  "pointermove",
@@ -356,7 +356,7 @@ class Y extends _e {
356
356
  ), this._domElement.ownerDocument.addEventListener("pointerup", h), this._isDragging = !0, E(l);
357
357
  }, a = (l) => {
358
358
  l.cancelable && l.preventDefault();
359
- const _ = l.pointerId, y = this._lockedPointer || this._findPointerById(_);
359
+ const p = l.pointerId, y = this._lockedPointer || this._findPointerById(p);
360
360
  if (y) {
361
361
  if (y.clientX = l.clientX, y.clientY = l.clientY, y.deltaX = l.movementX, y.deltaY = l.movementY, this._state = 0, l.pointerType === "touch")
362
362
  switch (this._activePointers.length) {
@@ -375,9 +375,9 @@ class Y extends _e {
375
375
  u();
376
376
  }
377
377
  }, h = (l) => {
378
- const _ = this._findPointerById(l.pointerId);
379
- if (!(_ && _ === this._lockedPointer)) {
380
- if (_ && this._disposePointer(_), l.pointerType === "touch")
378
+ const p = this._findPointerById(l.pointerId);
379
+ if (!(p && p === this._lockedPointer)) {
380
+ if (p && this._disposePointer(p), l.pointerType === "touch")
381
381
  switch (this._activePointers.length) {
382
382
  case 0:
383
383
  this._state = n.NONE;
@@ -398,7 +398,7 @@ class Y extends _e {
398
398
  }
399
399
  };
400
400
  let c = -1;
401
- const p = (l) => {
401
+ const _ = (l) => {
402
402
  if (!this._domElement || !this._enabled || this.mouseButtons.wheel === n.NONE) return;
403
403
  if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
404
404
  const O = this._domElement.getBoundingClientRect(), L = (l.clientX - O.left) / (O.right - O.left), R = (l.clientY - O.top) / (O.bottom - O.top);
@@ -409,7 +409,7 @@ class Y extends _e {
409
409
  const O = performance.now();
410
410
  c - O < 1e3 && this._getClientRect(this._elementRect), c = O;
411
411
  }
412
- const _ = pe ? -1 : -3, y = l.deltaMode === 1 ? l.deltaY / _ : l.deltaY / (_ * 10), f = this.dollyToCursor ? (l.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, v = this.dollyToCursor ? (l.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
412
+ const p = _e ? -1 : -3, y = l.deltaMode === 1 ? l.deltaY / p : l.deltaY / (p * 10), f = this.dollyToCursor ? (l.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, v = this.dollyToCursor ? (l.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
413
413
  switch (this.mouseButtons.wheel) {
414
414
  case n.ROTATE: {
415
415
  this._rotateInternal(l.deltaX, l.deltaY), this._isUserControllingRotate = !0;
@@ -436,7 +436,7 @@ class Y extends _e {
436
436
  }, m = (l) => {
437
437
  if (!(!this._domElement || !this._enabled)) {
438
438
  if (this.mouseButtons.right === Y.ACTION.NONE) {
439
- const _ = l instanceof PointerEvent ? l.pointerId : 0, y = this._findPointerById(_);
439
+ const p = l instanceof PointerEvent ? l.pointerId : 0, y = this._findPointerById(p);
440
440
  y && this._disposePointer(y), this._domElement.ownerDocument.removeEventListener(
441
441
  "pointermove",
442
442
  a,
@@ -477,7 +477,7 @@ class Y extends _e {
477
477
  }, u = () => {
478
478
  if (!this._enabled || !this._dragNeedsUpdate) return;
479
479
  this._dragNeedsUpdate = !1, ct(this._activePointers, b);
480
- const _ = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, y = _ ? -_.deltaX : i.x - b.x, f = _ ? -_.deltaY : i.y - b.y;
480
+ const p = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, y = p ? -p.deltaX : i.x - b.x, f = p ? -p.deltaY : i.y - b.y;
481
481
  if (i.copy(b), ((this._state & n.ROTATE) === n.ROTATE || (this._state & n.TOUCH_ROTATE) === n.TOUCH_ROTATE || (this._state & n.TOUCH_DOLLY_ROTATE) === n.TOUCH_DOLLY_ROTATE || (this._state & n.TOUCH_ZOOM_ROTATE) === n.TOUCH_ZOOM_ROTATE) && (this._rotateInternal(y, f), this._isUserControllingRotate = !0), (this._state & n.DOLLY) === n.DOLLY || (this._state & n.ZOOM) === n.ZOOM) {
482
482
  const v = 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, L = this.dollyDragInverted ? -1 : 1;
483
483
  (this._state & n.DOLLY) === n.DOLLY ? (this._dollyInternal(
@@ -534,8 +534,8 @@ class Y extends _e {
534
534
  { passive: !1 }
535
535
  ), this._domElement.ownerDocument.addEventListener("pointerup", h), E());
536
536
  }, this.unlockPointer = () => {
537
- var l, _, y;
538
- this._lockedPointer !== null && (this._disposePointer(this._lockedPointer), this._lockedPointer = null), (l = this._domElement) === null || l === void 0 || l.ownerDocument.exitPointerLock(), (_ = this._domElement) === null || _ === void 0 || _.ownerDocument.removeEventListener(
537
+ var l, p, y;
538
+ this._lockedPointer !== null && (this._disposePointer(this._lockedPointer), this._lockedPointer = null), (l = this._domElement) === null || l === void 0 || l.ownerDocument.exitPointerLock(), (p = this._domElement) === null || p === void 0 || p.ownerDocument.removeEventListener(
539
539
  "pointerlockchange",
540
540
  g
541
541
  ), (y = this._domElement) === null || y === void 0 || y.ownerDocument.removeEventListener(
@@ -549,11 +549,11 @@ class Y extends _e {
549
549
  this.unlockPointer();
550
550
  };
551
551
  this._addAllEventListeners = (l) => {
552
- this._domElement = l, this._domElement.style.touchAction = "none", this._domElement.style.userSelect = "none", this._domElement.style.webkitUserSelect = "none", this._domElement.addEventListener("pointerdown", r), this._domElement.addEventListener("pointercancel", h), this._domElement.addEventListener("wheel", p, {
552
+ this._domElement = l, this._domElement.style.touchAction = "none", this._domElement.style.userSelect = "none", this._domElement.style.webkitUserSelect = "none", this._domElement.addEventListener("pointerdown", r), this._domElement.addEventListener("pointercancel", h), this._domElement.addEventListener("wheel", _, {
553
553
  passive: !1
554
554
  }), this._domElement.addEventListener("contextmenu", m);
555
555
  }, this._removeAllEventListeners = () => {
556
- this._domElement && (this._domElement.style.touchAction = "", this._domElement.style.userSelect = "", this._domElement.style.webkitUserSelect = "", this._domElement.removeEventListener("pointerdown", r), this._domElement.removeEventListener("pointercancel", h), this._domElement.removeEventListener("wheel", p, {
556
+ this._domElement && (this._domElement.style.touchAction = "", this._domElement.style.userSelect = "", this._domElement.style.webkitUserSelect = "", this._domElement.removeEventListener("pointerdown", r), this._domElement.removeEventListener("pointercancel", h), this._domElement.removeEventListener("wheel", _, {
557
557
  passive: !1
558
558
  }), this._domElement.removeEventListener("contextmenu", m), this._domElement.ownerDocument.removeEventListener(
559
559
  "pointermove",
@@ -999,15 +999,15 @@ class Y extends _e {
999
999
  c.isEmpty() && (console.warn(
1000
1000
  "camera-controls: fitTo() cannot be used with an empty box. Aborting"
1001
1001
  ), Promise.resolve());
1002
- const p = wt(this._sphericalEnd.theta, Pt), m = wt(this._sphericalEnd.phi, Pt);
1003
- h.push(this.rotateTo(p, m, e));
1002
+ const _ = wt(this._sphericalEnd.theta, Pt), m = wt(this._sphericalEnd.phi, Pt);
1003
+ h.push(this.rotateTo(_, m, e));
1004
1004
  const E = T.setFromSpherical(this._sphericalEnd).normalize(), u = Rt.setFromUnitVectors(E, mt), w = D(Math.abs(E.y), 1);
1005
- w && u.multiply(pt.setFromAxisAngle(rt, p)), u.multiply(this._yAxisUpSpaceInverse);
1005
+ w && u.multiply(_t.setFromAxisAngle(rt, _)), u.multiply(this._yAxisUpSpaceInverse);
1006
1006
  const g = At.makeEmpty();
1007
- x.copy(c.min).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setX(c.max.x).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setY(c.max.y).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setZ(c.min.z).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setZ(c.max.z).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setY(c.min.y).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setX(c.min.x).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).applyQuaternion(u), g.expandByPoint(x), g.min.x -= i, g.min.y -= r, g.max.x += o, g.max.y += a, u.setFromUnitVectors(mt, E), w && u.premultiply(pt.invert()), u.premultiply(this._yAxisUpSpace);
1007
+ x.copy(c.min).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setX(c.max.x).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setY(c.max.y).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setZ(c.min.z).applyQuaternion(u), g.expandByPoint(x), x.copy(c.min).setZ(c.max.z).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setY(c.min.y).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).setX(c.min.x).applyQuaternion(u), g.expandByPoint(x), x.copy(c.max).applyQuaternion(u), g.expandByPoint(x), g.min.x -= i, g.min.y -= r, g.max.x += o, g.max.y += a, u.setFromUnitVectors(mt, E), w && u.premultiply(_t.invert()), u.premultiply(this._yAxisUpSpace);
1008
1008
  const S = g.getSize(T), l = g.getCenter(x).applyQuaternion(u);
1009
1009
  if (B(this._camera)) {
1010
- const _ = this.getDistanceToFitBox(
1010
+ const p = this.getDistanceToFitBox(
1011
1011
  S.x,
1012
1012
  S.y,
1013
1013
  S.z,
@@ -1015,9 +1015,9 @@ class Y extends _e {
1015
1015
  );
1016
1016
  h.push(
1017
1017
  this.moveTo(l.x, l.y, l.z, e)
1018
- ), h.push(this.dollyTo(_, e)), h.push(this.setFocalOffset(0, 0, 0, e));
1018
+ ), h.push(this.dollyTo(p, e)), h.push(this.setFocalOffset(0, 0, 0, e));
1019
1019
  } else if (k(this._camera)) {
1020
- const _ = this._camera, y = _.right - _.left, f = _.top - _.bottom, v = s ? Math.max(y / S.x, f / S.y) : Math.min(y / S.x, f / S.y);
1020
+ const p = this._camera, y = p.right - p.left, f = p.top - p.bottom, v = s ? Math.max(y / S.x, f / S.y) : Math.min(y / S.x, f / S.y);
1021
1021
  h.push(
1022
1022
  this.moveTo(l.x, l.y, l.z, e)
1023
1023
  ), h.push(this.zoomTo(v, e)), h.push(this.setFocalOffset(0, 0, 0, e));
@@ -1031,7 +1031,7 @@ class Y extends _e {
1031
1031
  * @category Methods
1032
1032
  */
1033
1033
  fitToSphere(t, e) {
1034
- const s = [], o = "isObject3D" in t ? Y.createBoundingSphere(t, _t) : _t.copy(t);
1034
+ const s = [], o = "isObject3D" in t ? Y.createBoundingSphere(t, pt) : pt.copy(t);
1035
1035
  if (s.push(
1036
1036
  this.moveTo(
1037
1037
  o.center.x,
@@ -1065,7 +1065,7 @@ class Y extends _e {
1065
1065
  this._targetEnd.copy(h), this._sphericalEnd.setFromVector3(
1066
1066
  c.sub(h).applyQuaternion(this._yAxisUpSpace)
1067
1067
  ), this.normalizeRotations(), this._needsUpdate = !0, a || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
1068
- const p = !a || D(this._target.x, this._targetEnd.x, this.restThreshold) && D(this._target.y, this._targetEnd.y, this.restThreshold) && D(this._target.z, this._targetEnd.z, this.restThreshold) && D(
1068
+ const _ = !a || D(this._target.x, this._targetEnd.x, this.restThreshold) && D(this._target.y, this._targetEnd.y, this.restThreshold) && D(this._target.z, this._targetEnd.z, this.restThreshold) && D(
1069
1069
  this._spherical.theta,
1070
1070
  this._sphericalEnd.theta,
1071
1071
  this.restThreshold
@@ -1078,7 +1078,7 @@ class Y extends _e {
1078
1078
  this._sphericalEnd.radius,
1079
1079
  this.restThreshold
1080
1080
  );
1081
- return this._createOnRestPromise(p);
1081
+ return this._createOnRestPromise(_);
1082
1082
  }
1083
1083
  /**
1084
1084
  * Similar to setLookAt, but it interpolates between two states.
@@ -1098,15 +1098,15 @@ class Y extends _e {
1098
1098
  * @param enableTransition
1099
1099
  * @category Methods
1100
1100
  */
1101
- lerpLookAt(t, e, s, i, o, r, a, h, c, p, m, E, u, w = !1) {
1101
+ lerpLookAt(t, e, s, i, o, r, a, h, c, _, m, E, u, w = !1) {
1102
1102
  this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._lastDollyDirection = Z.NONE, this._changedDolly = 0;
1103
1103
  const g = T.set(i, o, r), S = x.set(t, e, s);
1104
1104
  z.setFromVector3(
1105
1105
  S.sub(g).applyQuaternion(this._yAxisUpSpace)
1106
1106
  );
1107
- const l = X.set(p, m, E), _ = x.set(a, h, c);
1107
+ const l = X.set(_, m, E), p = x.set(a, h, c);
1108
1108
  W.setFromVector3(
1109
- _.sub(l).applyQuaternion(this._yAxisUpSpace)
1109
+ p.sub(l).applyQuaternion(this._yAxisUpSpace)
1110
1110
  ), this._targetEnd.copy(g.lerp(l, u));
1111
1111
  const y = W.theta - z.theta, f = W.phi - z.phi, v = W.radius - z.radius;
1112
1112
  this._sphericalEnd.set(
@@ -1464,13 +1464,13 @@ class Y extends _e {
1464
1464
  if (B(this._camera) && this._changedDolly !== 0) {
1465
1465
  const m = this._spherical.radius - this._lastDistance, E = this._camera, u = this._getCameraDirection(q), w = T.copy(u).cross(E.up).normalize();
1466
1466
  w.lengthSq() === 0 && (w.x = 1);
1467
- const g = x.crossVectors(w, u), S = this._sphericalEnd.radius * Math.tan(E.getEffectiveFOV() * G * 0.5), _ = (this._sphericalEnd.radius - m - this._sphericalEnd.radius) / this._sphericalEnd.radius, y = X.copy(this._targetEnd).add(
1467
+ const g = x.crossVectors(w, u), S = this._sphericalEnd.radius * Math.tan(E.getEffectiveFOV() * G * 0.5), p = (this._sphericalEnd.radius - m - this._sphericalEnd.radius) / this._sphericalEnd.radius, y = X.copy(this._targetEnd).add(
1468
1468
  w.multiplyScalar(
1469
1469
  this._dollyControlCoord.x * S * E.aspect
1470
1470
  )
1471
1471
  ).add(
1472
1472
  g.multiplyScalar(this._dollyControlCoord.y * S)
1473
- ), f = T.copy(this._targetEnd).lerp(y, _), v = this._lastDollyDirection === Z.IN && this._spherical.radius <= this.minDistance, O = this._lastDollyDirection === Z.OUT && this.maxDistance <= this._spherical.radius;
1473
+ ), f = T.copy(this._targetEnd).lerp(y, p), v = this._lastDollyDirection === Z.IN && this._spherical.radius <= this.minDistance, O = this._lastDollyDirection === Z.OUT && this.maxDistance <= this._spherical.radius;
1474
1474
  if (this.infinityDolly && (v || O)) {
1475
1475
  this._sphericalEnd.radius -= m, this._spherical.radius -= m;
1476
1476
  const R = x.copy(u).multiplyScalar(-m);
@@ -1484,7 +1484,7 @@ class Y extends _e {
1484
1484
  this._dollyControlCoord.x,
1485
1485
  this._dollyControlCoord.y,
1486
1486
  (E.near + E.far) / (E.near - E.far)
1487
- ).unproject(E), w = x.set(0, 0, -1).applyQuaternion(E.quaternion), g = X.copy(u).add(w.multiplyScalar(-u.dot(E.up))), l = -(this._zoom - m - this._zoom) / this._zoom, _ = this._getCameraDirection(q), y = this._targetEnd.dot(_), f = T.copy(this._targetEnd).lerp(g, l), v = f.dot(_), O = _.multiplyScalar(
1487
+ ).unproject(E), w = x.set(0, 0, -1).applyQuaternion(E.quaternion), g = X.copy(u).add(w.multiplyScalar(-u.dot(E.up))), l = -(this._zoom - m - this._zoom) / this._zoom, p = this._getCameraDirection(q), y = this._targetEnd.dot(p), f = T.copy(this._targetEnd).lerp(g, l), v = f.dot(p), O = p.multiplyScalar(
1488
1488
  v - y
1489
1489
  );
1490
1490
  f.sub(O), this._boundary.clampPoint(f, f);
@@ -1499,8 +1499,8 @@ class Y extends _e {
1499
1499
  T.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),
1500
1500
  1
1501
1501
  );
1502
- const p = this._needsUpdate;
1503
- return p && !this._updatedLastTime ? (this._hasRested = !1, this.dispatchEvent({ type: "wake" }), this.dispatchEvent({ type: "update" })) : p ? (this.dispatchEvent({ type: "update" }), U(e, this.restThreshold) && U(s, this.restThreshold) && U(i, this.restThreshold) && U(o.x, this.restThreshold) && U(o.y, this.restThreshold) && U(o.z, this.restThreshold) && U(r.x, this.restThreshold) && U(r.y, this.restThreshold) && U(r.z, this.restThreshold) && U(a, this.restThreshold) && !this._hasRested && (this._hasRested = !0, this.dispatchEvent({ type: "rest" }))) : !p && this._updatedLastTime && this.dispatchEvent({ type: "sleep" }), this._lastDistance = this._spherical.radius, this._lastZoom = this._zoom, this._updatedLastTime = p, this._needsUpdate = !1, p;
1502
+ const _ = this._needsUpdate;
1503
+ return _ && !this._updatedLastTime ? (this._hasRested = !1, this.dispatchEvent({ type: "wake" }), this.dispatchEvent({ type: "update" })) : _ ? (this.dispatchEvent({ type: "update" }), U(e, this.restThreshold) && U(s, this.restThreshold) && U(i, this.restThreshold) && U(o.x, this.restThreshold) && U(o.y, this.restThreshold) && U(o.z, this.restThreshold) && U(r.x, this.restThreshold) && U(r.y, this.restThreshold) && U(r.z, this.restThreshold) && U(a, this.restThreshold) && !this._hasRested && (this._hasRested = !0, this.dispatchEvent({ type: "rest" }))) : !_ && this._updatedLastTime && this.dispatchEvent({ type: "sleep" }), this._lastDistance = this._spherical.radius, this._lastZoom = this._zoom, this._updatedLastTime = _, this._needsUpdate = !1, _;
1504
1504
  }
1505
1505
  /**
1506
1506
  * Get all state in JSON string
@@ -1708,9 +1708,9 @@ class Y extends _e {
1708
1708
  if (!r.isMesh) return;
1709
1709
  const a = r, h = a.geometry.clone();
1710
1710
  h.applyMatrix4(a.matrixWorld);
1711
- const p = h.attributes.position;
1712
- for (let m = 0, E = p.count; m < E; m++)
1713
- T.fromBufferAttribute(p, m), o = Math.max(o, i.distanceToSquared(T));
1711
+ const _ = h.attributes.position;
1712
+ for (let m = 0, E = _.count; m < E; m++)
1713
+ T.fromBufferAttribute(_, m), o = Math.max(o, i.distanceToSquared(T));
1714
1714
  }), s.radius = Math.sqrt(o), s;
1715
1715
  }
1716
1716
  }
@@ -1736,7 +1736,7 @@ class fe {
1736
1736
  alpha: a,
1737
1737
  devicePixelRatio: h,
1738
1738
  antialias: c,
1739
- powerPreference: p,
1739
+ powerPreference: _,
1740
1740
  toneMappingExposure: m,
1741
1741
  outputColorSpace: E,
1742
1742
  logarithmicDepthBuffer: u,
@@ -1744,18 +1744,18 @@ class fe {
1744
1744
  stencil: g,
1745
1745
  depth: S,
1746
1746
  physicallyCorrectLights: l
1747
- } = i, _ = new P.WebGLRenderer({
1747
+ } = i, p = new P.WebGLRenderer({
1748
1748
  canvas: o,
1749
1749
  context: r,
1750
1750
  alpha: a,
1751
1751
  antialias: c,
1752
- powerPreference: p,
1752
+ powerPreference: _,
1753
1753
  logarithmicDepthBuffer: u,
1754
1754
  preserveDrawingBuffer: w,
1755
1755
  stencil: g,
1756
1756
  depth: S
1757
1757
  });
1758
- _.setSize(e, s), _.setPixelRatio(h), _.toneMappingExposure = m, _.outputColorSpace = E, +P.REVISION < 155 && (_.useLegacyLights = l), this.renderer = _;
1758
+ p.setSize(e, s), p.setPixelRatio(h), p.toneMappingExposure = m, p.outputColorSpace = E, +P.REVISION < 155 && (p.useLegacyLights = l), this.renderer = p;
1759
1759
  }
1760
1760
  setSize(t, e) {
1761
1761
  this.renderer.setSize(t, e);
@@ -1782,15 +1782,15 @@ class gt {
1782
1782
  max: a,
1783
1783
  step: h,
1784
1784
  name: c,
1785
- paramMap: p,
1785
+ paramMap: _,
1786
1786
  items: m,
1787
1787
  value: E,
1788
1788
  target: u
1789
1789
  } = i[o], w = o.toLowerCase().indexOf("color") > -1;
1790
1790
  let g;
1791
- const S = typeof E == "undefined" && u, l = S ? u() : i[o], _ = S ? o : "value";
1792
- m ? g = s.add(l, _, m) : w ? g = s.addColor(l, _) : g = s.add(l, _), g = g.name(c || o), typeof r != "undefined" && (g = g.min(r)), typeof a != "undefined" && (g = g.max(a)), typeof h != "undefined" && (g = g.step(h)), g = g.onChange(() => {
1793
- this.setTargetValue(e, o, l[_], p);
1791
+ const S = typeof E == "undefined" && u, l = S ? u() : i[o], p = S ? o : "value";
1792
+ m ? g = s.add(l, p, m) : w ? g = s.addColor(l, p) : g = s.add(l, p), g = g.name(c || o), typeof r != "undefined" && (g = g.min(r)), typeof a != "undefined" && (g = g.max(a)), typeof h != "undefined" && (g = g.step(h)), g = g.onChange(() => {
1793
+ this.setTargetValue(e, o, l[p], _);
1794
1794
  }), S && g.listen();
1795
1795
  });
1796
1796
  });
@@ -1802,8 +1802,8 @@ class gt {
1802
1802
  value: a
1803
1803
  } = this.guiParams[t][e], h = e.toLowerCase().indexOf("color") > -1;
1804
1804
  if (r && !(typeof a == "undefined" && r)) {
1805
- let p = r();
1806
- Array.isArray(p) || (p = [p]), p.forEach((m) => {
1805
+ let _ = r();
1806
+ Array.isArray(_) || (_ = [_]), _.forEach((m) => {
1807
1807
  if (m)
1808
1808
  if (h)
1809
1809
  try {
@@ -1834,7 +1834,7 @@ const ge = {
1834
1834
  };
1835
1835
  class Ee {
1836
1836
  constructor(t) {
1837
- this.customCamera = !1, this.options = t;
1837
+ this.customCamera = !1, this.syncCamera = null, this.options = t;
1838
1838
  const { width: e, height: s, cameraParams: i } = t;
1839
1839
  if (i instanceof P.Camera)
1840
1840
  this.camera = i, this.customCamera = !0;
@@ -1922,11 +1922,11 @@ class Ce {
1922
1922
  constructor(t) {
1923
1923
  this.overrideMaterial = !1, this.options = t;
1924
1924
  const { camera: e, sceneParams: s } = t, { background: i, om: o, addCamera: r } = s, a = o ? new P.Scene() : new Proxy(new P.Scene(), {
1925
- set: (h, c, p) => Reflect.set(h, c, p),
1925
+ set: (h, c, _) => Reflect.set(h, c, _),
1926
1926
  get: (h, c) => {
1927
1927
  if (c === "overrideMaterial") {
1928
- const p = Reflect.get(h, c);
1929
- return this.overrideMaterial = !!p, xt.forEach((m) => {
1928
+ const _ = Reflect.get(h, c);
1929
+ return this.overrideMaterial = !!_, xt.forEach((m) => {
1930
1930
  this.overrideMaterial ? m.useDepth = 1 : m.useDepth = 0;
1931
1931
  }), null;
1932
1932
  }
@@ -2260,7 +2260,7 @@ class Se {
2260
2260
  }).showGui(t);
2261
2261
  }
2262
2262
  addBloomPass(t) {
2263
- const { camera: e, scene: s } = this, p = F(F({}, Bt), t), { epsilon: i, ignoreBackground: o, mipmapBlurPassRadius: r } = p, a = Ot(p, ["epsilon", "ignoreBackground", "mipmapBlurPassRadius"]), h = new de(s, e, F({}, a));
2263
+ const { camera: e, scene: s } = this, _ = F(F({}, Bt), t), { epsilon: i, ignoreBackground: o, mipmapBlurPassRadius: r } = _, a = Ot(_, ["epsilon", "ignoreBackground", "mipmapBlurPassRadius"]), h = new de(s, e, F({}, a));
2264
2264
  o && (h.ignoreBackground = o), r && (h.mipmapBlurPass.radius = r), h.depthMaskMaterial.epsilon = i, h.luminancePass.enabled = !1, h.luminancePass.enabled = t.luminancePass;
2265
2265
  const c = new lt(e, h);
2266
2266
  this.finalComposer.addPass(c), this.bloomPass = c, this.bloomEffect = h;
@@ -2421,15 +2421,15 @@ const Ue = () => {
2421
2421
  scene: o,
2422
2422
  camera: r,
2423
2423
  control: a
2424
- } = this.options, { width: h, height: c } = this.getSize(), p = new Ee({
2424
+ } = this.options, { width: h, height: c } = this.getSize(), _ = new Ee({
2425
2425
  isdev: e,
2426
2426
  width: h,
2427
2427
  height: c,
2428
2428
  cameraParams: r,
2429
2429
  cameraControls: a === !0
2430
2430
  });
2431
- this.gui && p.setGui(this.gui);
2432
- const m = p.camera, E = new Ce({
2431
+ this.gui && _.setGui(this.gui);
2432
+ const m = _.camera, E = new Ce({
2433
2433
  camera: m,
2434
2434
  sceneParams: o
2435
2435
  }), u = E.scene, w = new fe({
@@ -2448,7 +2448,7 @@ const Ue = () => {
2448
2448
  });
2449
2449
  g.add(u), this.helperController = g;
2450
2450
  }
2451
- this.sceneController = E, this.rendererController = w, this.cameraController = p, t.appendChild(w.renderer.domElement);
2451
+ this.sceneController = E, this.rendererController = w, this.cameraController = _, t.appendChild(w.renderer.domElement);
2452
2452
  }
2453
2453
  initComposer() {
2454
2454
  const {
@@ -2462,18 +2462,18 @@ const Ue = () => {
2462
2462
  frameBufferType: h,
2463
2463
  passes: c
2464
2464
  } = this.options;
2465
- let { antialias: p } = r;
2466
- p === "msaa" && !Mt && (p = !1, console.warn("MSAA is not supported on this browser"));
2465
+ let { antialias: _ } = r;
2466
+ _ === "msaa" && !Mt && (_ = !1, console.warn("MSAA is not supported on this browser"));
2467
2467
  const m = new Se({
2468
2468
  renderer: this.renderer,
2469
2469
  scene: this.scene,
2470
2470
  camera: this.camera,
2471
2471
  composerParams: {
2472
- multisampling: p === "msaa" ? a : 0,
2472
+ multisampling: _ === "msaa" ? a : 0,
2473
2473
  frameBufferType: s ? P.HalfFloatType : h
2474
2474
  }
2475
2475
  });
2476
- this.composerController = m, t && (m.addBloomPass(e), this.gui && m.addBloomGui(this.gui)), s && (m.addToneMappingPass(i), this.gui && m.addToneMappingGui(this.gui)), p === "fxaa" && m.addFXAAPass(), o && m.addCrossFadePass(), c && c.forEach((E) => {
2476
+ this.composerController = m, t && (m.addBloomPass(e), this.gui && m.addBloomGui(this.gui)), s && (m.addToneMappingPass(i), this.gui && m.addToneMappingGui(this.gui)), _ === "fxaa" && m.addFXAAPass(), o && m.addCrossFadePass(), c && c.forEach((E) => {
2477
2477
  m.finalComposer.addPass(E);
2478
2478
  }), m.finalComposer.passes.length === 1 && m.addCopyPass();
2479
2479
  }
@@ -2579,14 +2579,16 @@ const Ue = () => {
2579
2579
  }
2580
2580
  }
2581
2581
  render() {
2582
- var r, a, h, c, p, m;
2582
+ var r, a, h, c, _, m;
2583
2583
  const { scene: t, camera: e, clock: s } = this, i = s.getDelta(), o = s.getElapsedTime();
2584
2584
  vt.update(), (r = this.controlsController) == null || r.update(i), this.installPlugins.forEach((E) => {
2585
2585
  var u;
2586
2586
  (u = E.update) == null || u.call(E, i, o);
2587
- }), (a = this.helperController) == null || a.update(), (h = this.composerController) != null && h.active ? this.cameraController.camera2 ? (this.composerController.resetRenderPassCamera(), this.setViewportFull(), this.composerController.render(), this.pipViewportState && (this.setViewportPip(), this.composerController.setRenderPassCamera(
2587
+ }), (a = this.helperController) == null || a.update(), this.cameraController.syncCamera && !(this.camera.matrixWorld.equals(
2588
+ this.cameraController.syncCamera.matrixWorld
2589
+ ) && this.camera.far === this.cameraController.syncCamera.far && this.camera.near === this.cameraController.syncCamera.near && this.camera.fov === this.cameraController.syncCamera.fov && this.camera.aspect === this.cameraController.syncCamera.aspect) && this.camera.copy(this.cameraController.syncCamera), (h = this.composerController) != null && h.active ? this.cameraController.camera2 ? (this.composerController.resetRenderPassCamera(), this.setViewportFull(), this.composerController.render(), this.pipViewportState && (this.setViewportPip(), this.composerController.setRenderPassCamera(
2588
2590
  this.cameraController.camera2
2589
- ), this.composerController.render())) : this.composerController.render() : (c = this.rendererController) == null || c.render(), (p = this.cssRendererController) == null || p.render(t, e), (m = this.stats) == null || m.update(), this.event.emit("render", { delta: i, elapsed: o });
2591
+ ), this.composerController.render())) : this.composerController.render() : (c = this.rendererController) == null || c.render(), (_ = this.cssRendererController) == null || _.render(t, e), (m = this.stats) == null || m.update(), this.event.emit("render", { delta: i, elapsed: o });
2590
2592
  }
2591
2593
  start() {
2592
2594
  this.renderer.setAnimationLoop(this.render.bind(this)), this.event.emit("start");
@@ -2635,11 +2637,11 @@ const Ue = () => {
2635
2637
  h && h.aspect !== a && (h.aspect = a, h.updateProjectionMatrix()), this.renderer.setViewport(s, i, o, r), this.renderer.setScissor(s, i, o, r), this.renderer.setScissorTest(!0);
2636
2638
  }
2637
2639
  dispose() {
2638
- var t, e, s, i, o, r, a, h, c, p, m;
2640
+ var t, e, s, i, o, r, a, h, c, _, m;
2639
2641
  this.stop(), vt.removeAll(), this.event.removeAllListeners(), (t = this.resizeObserver) == null || t.unobserve(this.options.container), this.installPlugins.forEach((E) => {
2640
2642
  var u;
2641
2643
  (u = E.dispose) == null || u.call(E);
2642
- }), (e = this.controlsController) == null || e.dispose(), (s = this.transformController) == null || s.dispose(), (i = this.cssRendererController) == null || i.dispose(), (o = this.sceneController) == null || o.dispose(), (r = this.helperController) == null || r.dispose(), (a = this.composerController) == null || a.dispose(), (h = this.rendererController) == null || h.dispose(), this.cssRendererController = void 0, (c = this.gui) == null || c.destroy(), this.installPlugins.clear(), (p = this.stats) == null || p.dom.remove(), (m = this.renderer) == null || m.domElement.remove();
2644
+ }), (e = this.controlsController) == null || e.dispose(), (s = this.transformController) == null || s.dispose(), (i = this.cssRendererController) == null || i.dispose(), (o = this.sceneController) == null || o.dispose(), (r = this.helperController) == null || r.dispose(), (a = this.composerController) == null || a.dispose(), (h = this.rendererController) == null || h.dispose(), this.cssRendererController = void 0, (c = this.gui) == null || c.destroy(), this.installPlugins.clear(), (_ = this.stats) == null || _.dom.remove(), (m = this.renderer) == null || m.domElement.remove();
2643
2645
  }
2644
2646
  };
2645
2647
  at.options = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.9.49",
3
+ "version": "0.9.51",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",