gl-draw 0.9.43 → 0.9.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.module.js +2 -2
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +16 -10
- package/package.json +1 -1
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),R={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,A=(e.z+a*g)*o;e.x=(e.x-a*O)*c,e.y=(e.y-a*L)*c,e.z=(e.z-a*A)*c,r.x=p+(u+O)*c,r.y=m+(D+L)*c,r.z=E+(g+A)*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,Rt,ft,At,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,Rt=new C.Box3,ft=new C.Sphere,At=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,A=O.length()*Math.tan(L*.5);f=this.truckSpeed*l*A/this._elementRect.height,v=this.truckSpeed*_*A/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),A=L-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(A,!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&R.LEFT)===R.LEFT?R.LEFT:(l.buttons&R.MIDDLE)===R.MIDDLE?R.MIDDLE:(l.buttons&R.RIGHT)===R.RIGHT?R.RIGHT:null;if(_!==null){const f=this._findPointerByMouseButton(_);f&&this._disposePointer(f)}if((l.buttons&R.LEFT)===R.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&R.LEFT)===R.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(l.buttons&R.MIDDLE)===R.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(l.buttons&R.RIGHT)===R.RIGHT&&(this._state=this._state|this.mouseButtons.right);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),A=(l.clientY-O.top)/(O.bottom-O.top);if(L<this._interactiveArea.left||L>this._interactiveArea.right||A<this._interactiveArea.top||A>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&R.LEFT)===R.LEFT&&(this._state=this._state|this.mouseButtons.left),(l.buttons&R.MIDDLE)===R.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(l.buttons&R.RIGHT)===R.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&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),A=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(A*nt,et,st),this._isUserControllingDolly=!0):(this._zoomInternal(A*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=At.setFromUnitVectors(E,ut),D=w(Math.abs(E.y),1);D&&u.multiply(gt.setFromAxisAngle(at,p)),u.multiply(this._yAxisUpSpaceInverse);const g=Rt.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 A=P.copy(u).multiplyScalar(-m);f.add(A)}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;(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};class me{constructor(t){this.overrideMaterial=!1,this.options=t;const{camera:e,sceneParams:s}=t,{background:i,om:o}=s,r=o?new x.Scene:new Proxy(new x.Scene,{set:(a,h,c)=>Reflect.set(a,h,c),get:(a,h)=>{if(h==="overrideMaterial"){const c=Reflect.get(a,h);return this.overrideMaterial=!!c,vt.meshLineMaterialArr.forEach(p=>{this.overrideMaterial?p.useDepth=1:p.useDepth=0}),null}return Reflect.get(a,h)}});i&&(r.background=i),r.add(e),this.scene=r}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.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};class me{constructor(t){this.overrideMaterial=!1,this.options=t;const{camera:e,sceneParams:s}=t,{background:i,om:o}=s,r=o?new x.Scene:new Proxy(new x.Scene,{set:(a,h,c)=>Reflect.set(a,h,c),get:(a,h)=>{if(h==="overrideMaterial"){const c=Reflect.get(a,h);return this.overrideMaterial=!!c,vt.meshLineMaterialArr.forEach(p=>{this.overrideMaterial?p.useDepth=1:p.useDepth=0}),null}return Reflect.get(a,h)}});i&&(r.background=i),r.add(e),this.scene=r}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=new ResizeObserver(s=>{const i=this.getSize();for(const o of s){const r=o.contentRect;(r.width!==i.width||r.height!==i.height)&&(this.handeleResize(r.width,r.height),this.render())}});e.observe(t),this.resizeObserver=e}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.handeleResize(0,0,!1),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=new ResizeObserver(s=>{const i=this.getSize();for(const o of s){const r=o.contentRect;(r.width!==i.width||r.height!==i.height)&&(this.handeleResize(r.width,r.height),this.render())}});e.observe(t),this.resizeObserver=e}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;
|
package/dist/index.module.js
CHANGED
|
@@ -1766,7 +1766,7 @@ class fe {
|
|
|
1766
1766
|
}
|
|
1767
1767
|
dispose() {
|
|
1768
1768
|
var t, e;
|
|
1769
|
-
(t = this.renderer) == null || t.clear(), (e = this.renderer) == null || e.dispose();
|
|
1769
|
+
this.setSize(1, 1), (t = this.renderer) == null || t.clear(), (e = this.renderer) == null || e.dispose();
|
|
1770
1770
|
}
|
|
1771
1771
|
}
|
|
1772
1772
|
class gt {
|
|
@@ -2636,7 +2636,7 @@ const Ue = () => {
|
|
|
2636
2636
|
}
|
|
2637
2637
|
dispose() {
|
|
2638
2638
|
var t, e, s, i, o, r, a, h, c, p, m;
|
|
2639
|
-
this.stop(), vt.removeAll(), this.event.removeAllListeners(), (t = this.resizeObserver) == null || t.unobserve(this.options.container), this.
|
|
2639
|
+
this.stop(), vt.removeAll(), this.event.removeAllListeners(), (t = this.resizeObserver) == null || t.unobserve(this.options.container), this.installPlugins.forEach((E) => {
|
|
2640
2640
|
var u;
|
|
2641
2641
|
(u = E.dispose) == null || u.call(E);
|
|
2642
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();
|