gl-draw 0.10.23 → 0.10.25
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 +1 -1
- package/dist/index.module.js +3 -2
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +52 -48
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ht=Object.defineProperty,It=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var gt=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var yt=(d,t,e)=>t in d?Ht(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Y=(d,t)=>{for(var e in t||(t={}))Vt.call(t,e)&&yt(d,e,t[e]);if(gt)for(var e of gt(t))Bt.call(t,e)&&yt(d,e,t[e]);return d},ht=(d,t)=>It(d,kt(t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Yt=require("three"),Zt=require("@tweenjs/tween.js"),Ut=require("./events.js"),Nt=require("deepmerge"),jt=require("stats-gl"),qt=require("lil-gui"),Kt=require("./colorCorrection.js"),Xt=require("./disposeMesh.js");require("idb-keyval");require("esus-lite");require("d3-geo");const Gt=require("three/examples/jsm/helpers/RectAreaLightHelper"),Wt=require("three/examples/jsm/controls/TransformControls"),Qt=require("three/examples/jsm/renderers/CSS3DRenderer"),Jt=require("three/examples/jsm/renderers/CSS2DRenderer"),Ct=require("three/examples/jsm/postprocessing/EffectComposer"),$t=require("three/examples/jsm/postprocessing/RenderPass"),te=require("three/examples/jsm/postprocessing/OutputPass"),ee=require("three/examples/jsm/postprocessing/ShaderPass"),se=require("three/examples/jsm/postprocessing/UnrealBloomPass"),ie=require("./isPlainObject.js"),oe=require("./BaseObject.js");function Lt(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 v=Lt(Yt),Et=Lt(Zt),L={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}),Z={NONE:0,IN:1,OUT:-1};function k(d){return d.isPerspectiveCamera}function I(d){return d.isOrthographicCamera}const N=Math.PI*2,Ot=Math.PI/2,Rt=1e-5,K=Math.PI/180;function M(d,t,e){return Math.max(t,Math.min(e,d))}function D(d,t=Rt){return Math.abs(d)<t}function S(d,t,e=Rt){return D(d-t,e)}function Tt(d,t){return Math.round(d/t)*t}function X(d){return isFinite(d)?d:d<0?-Number.MAX_VALUE:Number.MAX_VALUE}function G(d){return Math.abs(d)<Number.MAX_VALUE?d:d*(1/0)}function et(d,t,e,s,i=1/0,o){s=Math.max(1e-4,s);const r=2/s,a=r*o,l=1/(1+a+.48*a*a+.235*a*a*a);let c=d-t;const g=t,_=i*s;c=M(c,-_,_),t=d-c;const y=(e.value+r*c)*o;e.value=(e.value-r*y)*l;let p=t+(c+y)*l;return g-d>0==p>g&&(p=g,e.value=(p-g)/o),p}function vt(d,t,e,s,i=1/0,o,r){s=Math.max(1e-4,s);const a=2/s,l=a*o,c=1/(1+l+.48*l*l+.235*l*l*l);let g=t.x,_=t.y,y=t.z,p=d.x-g,P=d.y-_,f=d.z-y;const w=g,h=_,m=y,C=i*s,u=C*C,x=p*p+P*P+f*f;if(x>u){const at=Math.sqrt(x);p=p/at*C,P=P/at*C,f=f/at*C}g=d.x-p,_=d.y-P,y=d.z-f;const O=(e.x+a*p)*o,U=(e.y+a*P)*o,R=(e.z+a*f)*o;e.x=(e.x-a*O)*c,e.y=(e.y-a*U)*c,e.z=(e.z-a*R)*c,r.x=g+(p+O)*c,r.y=_+(P+U)*c,r.z=y+(f+R)*c;const $=w-d.x,tt=h-d.y,At=m-d.z,zt=r.x-w,Mt=r.y-h,Ft=r.z-m;return $*zt+tt*Mt+At*Ft>0&&(r.x=w,r.y=h,r.z=m,e.x=(r.x-w)/o,e.y=(r.y-h)/o,e.z=(r.z-m)/o),r}function lt(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 ct(d,t){return I(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 st=1/8,ne=/Mac/.test(navigator.platform);let E,xt,it,dt,A,T,b,j,W,F,H,V,Pt,bt,z,Q,q,wt,mt,St,_t,pt,ot;class B extends re{static install(t){E=t.THREE,xt=Object.freeze(new E.Vector3(0,0,0)),it=Object.freeze(new E.Vector3(0,1,0)),dt=Object.freeze(new E.Vector3(0,0,1)),A=new E.Vector2,T=new E.Vector3,b=new E.Vector3,j=new E.Vector3,W=new E.Vector3,F=new E.Vector3,H=new E.Vector3,V=new E.Vector3,Pt=new E.Vector3,bt=new E.Vector3,z=new E.Spherical,Q=new E.Spherical,q=new E.Box3,wt=new E.Box3,mt=new E.Sphere,St=new E.Quaternion,_t=new E.Quaternion,pt=new E.Matrix4,ot=new E.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=Z.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new E.Vector3,this._focalOffsetVelocity=new E.Vector3,this._zoomVelocity={value:0},this._truckInternal=(h,m,C)=>{let u,x;if(k(this._camera)){const O=T.copy(this._camera.position).sub(this._target),U=this._camera.getEffectiveFOV()*K,R=O.length()*Math.tan(U*.5);u=this.truckSpeed*h*R/this._elementRect.height,x=this.truckSpeed*m*R/this._elementRect.height}else if(I(this._camera)){const O=this._camera;u=h*(O.right-O.left)/O.zoom/this._elementRect.width,x=m*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(C?this.setFocalOffset(this._focalOffsetEnd.x+u,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(u,0,!0),this.forward(-x,!0)):C?this.setFocalOffset(this._focalOffsetEnd.x+u,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(u,x,!0)},this._rotateInternal=(h,m)=>{const C=N*this.azimuthRotateSpeed*h/this._elementRect.height,u=N*this.polarRotateSpeed*m/this._elementRect.height;this.rotate(C,u,!0)},this._dollyInternal=(h,m,C)=>{const u=Math.pow(.95,-h*this.dollySpeed),x=this._sphericalEnd.radius,O=this._sphericalEnd.radius*u,U=M(O,this.minDistance,this.maxDistance),R=U-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(R,!0),this._dollyToNoClamp(U,!0)):this._dollyToNoClamp(U,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:U)-x,this._dollyControlCoord.set(m,C)),this._lastDollyDirection=Math.sign(-h)},this._zoomInternal=(h,m,C)=>{const u=Math.pow(.95,h*this.dollySpeed),x=this._zoom,O=this._zoom*u;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-x,this._dollyControlCoord.set(m,C))},typeof E=="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 E.Quaternion().setFromUnitVectors(this._camera.up,it),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=n.NONE,this._target=new E.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new E.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new E.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 E.Vector3,new E.Vector3,new E.Vector3,new E.Vector3],this._updateNearPlaneCorners(),this._boundary=new E.Box3(new E.Vector3(-1/0,-1/0,-1/0),new E.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 E.Vector2,this.mouseButtons={left:n.ROTATE,middle:n.DOLLY,right:n.TRUCK,wheel:k(this._camera)?n.DOLLY:I(this._camera)?n.ZOOM:n.NONE},this.touches={one:n.TOUCH_ROTATE,two:k(this._camera)?n.TOUCH_DOLLY_TRUCK:I(this._camera)?n.TOUCH_ZOOM_TRUCK:n.NONE,three:n.TOUCH_TRUCK};const s=new E.Vector2,i=new E.Vector2,o=new E.Vector2,r=h=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const u=this._domElement.getBoundingClientRect(),x=(h.clientX-u.left)/(u.right-u.left),O=(h.clientY-u.top)/(u.bottom-u.top);if(x<this._interactiveArea.left||x>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const m=h.pointerType!=="mouse"?null:(h.buttons&L.LEFT)===L.LEFT?L.LEFT:(h.buttons&L.MIDDLE)===L.MIDDLE?L.MIDDLE:(h.buttons&L.RIGHT)===L.RIGHT?L.RIGHT:null;if(m!==null){const u=this._findPointerByMouseButton(m);u&&this._disposePointer(u)}if((h.buttons&L.LEFT)===L.LEFT&&this._lockedPointer)return;const C={pointerId:h.pointerId,clientX:h.clientX,clientY:h.clientY,deltaX:0,deltaY:0,mouseButton:m};this._activePointers.push(C),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,y(h)},a=h=>{h.cancelable&&h.preventDefault();const m=h.pointerId,C=this._lockedPointer||this._findPointerById(m);if(C){if(C.clientX=h.clientX,C.clientY=h.clientY,C.deltaX=h.movementX,C.deltaY=h.movementY,this._state=0,h.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&&(h.buttons&L.LEFT)===L.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(h.buttons&L.MIDDLE)===L.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(h.buttons&L.RIGHT)===L.RIGHT&&(this._state=this._state|this.mouseButtons.right);p()}},l=h=>{const m=this._findPointerById(h.pointerId);if(!(m&&m===this._lockedPointer)){if(m&&this._disposePointer(m),h.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;P()}};let c=-1;const g=h=>{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(),U=(h.clientX-O.left)/(O.right-O.left),R=(h.clientY-O.top)/(O.bottom-O.top);if(U<this._interactiveArea.left||U>this._interactiveArea.right||R<this._interactiveArea.top||R>this._interactiveArea.bottom)return}if(h.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 m=ne?-1:-3,C=h.deltaMode===1?h.deltaY/m:h.deltaY/(m*10),u=this.dollyToCursor?(h.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(h.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case n.ROTATE:{this._rotateInternal(h.deltaX,h.deltaY),this._isUserControllingRotate=!0;break}case n.TRUCK:{this._truckInternal(h.deltaX,h.deltaY,!1),this._isUserControllingTruck=!0;break}case n.OFFSET:{this._truckInternal(h.deltaX,h.deltaY,!0),this._isUserControllingOffset=!0;break}case n.DOLLY:{this._dollyInternal(-C,u,x),this._isUserControllingDolly=!0;break}case n.ZOOM:{this._zoomInternal(-C,u,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},_=h=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===B.ACTION.NONE){const m=h instanceof PointerEvent?h.pointerId:0,C=this._findPointerById(m);C&&this._disposePointer(C),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}h.preventDefault()}},y=h=>{if(!this._enabled)return;if(lt(this._activePointers,A),this._getClientRect(this._elementRect),s.copy(A),i.copy(A),this._activePointers.length>=2){const C=A.x-this._activePointers[1].clientX,u=A.y-this._activePointers[1].clientY,x=Math.sqrt(C*C+u*u);o.set(0,x);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,U=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(O,U)}if(this._state=0,!h)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in h&&h.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&&(h.buttons&L.LEFT)===L.LEFT&&(this._state=this._state|this.mouseButtons.left),(h.buttons&L.MIDDLE)===L.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(h.buttons&L.RIGHT)===L.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"})},p=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,lt(this._activePointers,A);const m=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,C=m?-m.deltaX:i.x-A.x,u=m?-m.deltaY:i.y-A.y;if(i.copy(A),((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(C,u),this._isUserControllingRotate=!0),(this._state&n.DOLLY)===n.DOLLY||(this._state&n.ZOOM)===n.ZOOM){const x=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,U=this.dollyDragInverted?-1:1;(this._state&n.DOLLY)===n.DOLLY?(this._dollyInternal(U*u*st,x,O),this._isUserControllingDolly=!0):(this._zoomInternal(U*u*st,x,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 x=A.x-this._activePointers[1].clientX,O=A.y-this._activePointers[1].clientY,U=Math.sqrt(x*x+O*O),R=o.y-U;o.set(0,U);const $=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,tt=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*st,$,tt),this._isUserControllingDolly=!0):(this._zoomInternal(R*st,$,tt),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(C,u,!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(C,u,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},P=()=>{lt(this._activePointers,A),i.copy(A),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",l),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",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",f),this._domElement.ownerDocument.addEventListener("pointerlockerror",w),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),y())},this.unlockPointer=()=>{var h,m,C;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(h=this._domElement)===null||h===void 0||h.ownerDocument.exitPointerLock(),(m=this._domElement)===null||m===void 0||m.ownerDocument.removeEventListener("pointerlockchange",f),(C=this._domElement)===null||C===void 0||C.ownerDocument.removeEventListener("pointerlockerror",w),this.cancel()};const f=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},w=()=>{this.unlockPointer()};this._addAllEventListeners=h=>{this._domElement=h,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",g,{passive:!1}),this._domElement.addEventListener("contextmenu",_)},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",l),this._domElement.removeEventListener("wheel",g,{passive:!1}),this._domElement.removeEventListener("contextmenu",_),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",f),this._domElement.ownerDocument.removeEventListener("pointerlockerror",w))},this.cancel=()=>{this._state!==n.NONE&&(this._state=n.NONE,this._activePointers.length=0,P())},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=M(t.width,0,1),this._interactiveArea.height=M(t.height,0,1),this._interactiveArea.x=M(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=M(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=M(t,this.minAzimuthAngle,this.maxAzimuthAngle),o=M(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||S(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&S(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=Z.NONE,this._changedDolly=0,this._dollyToNoClamp(M(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=S(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||S(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||S(this._target.x,this._targetEnd.x,this.restThreshold)&&S(this._target.y,this._targetEnd.y,this.restThreshold)&&S(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=M(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const s=!e||S(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(),F.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),F.multiplyScalar(t),H.multiplyScalar(-e);const i=T.copy(F).add(H),o=b.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=b.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||S(this._target.x,this._targetEnd.x,this.restThreshold)&&S(this._target.y,this._targetEnd.y,this.restThreshold)&&S(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 l=[],c=t.isBox3?q.copy(t):q.setFromObject(t);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const g=Tt(this._sphericalEnd.theta,Ot),_=Tt(this._sphericalEnd.phi,Ot);l.push(this.rotateTo(g,_,e));const y=T.setFromSpherical(this._sphericalEnd).normalize(),p=St.setFromUnitVectors(y,dt),P=S(Math.abs(y.y),1);P&&p.multiply(_t.setFromAxisAngle(it,g)),p.multiply(this._yAxisUpSpaceInverse);const f=wt.makeEmpty();b.copy(c.min).applyQuaternion(p),f.expandByPoint(b),b.copy(c.min).setX(c.max.x).applyQuaternion(p),f.expandByPoint(b),b.copy(c.min).setY(c.max.y).applyQuaternion(p),f.expandByPoint(b),b.copy(c.max).setZ(c.min.z).applyQuaternion(p),f.expandByPoint(b),b.copy(c.min).setZ(c.max.z).applyQuaternion(p),f.expandByPoint(b),b.copy(c.max).setY(c.min.y).applyQuaternion(p),f.expandByPoint(b),b.copy(c.max).setX(c.min.x).applyQuaternion(p),f.expandByPoint(b),b.copy(c.max).applyQuaternion(p),f.expandByPoint(b),f.min.x-=i,f.min.y-=r,f.max.x+=o,f.max.y+=a,p.setFromUnitVectors(dt,y),P&&p.premultiply(_t.invert()),p.premultiply(this._yAxisUpSpace);const w=f.getSize(T),h=f.getCenter(b).applyQuaternion(p);if(k(this._camera)){const m=this.getDistanceToFitBox(w.x,w.y,w.z,s);l.push(this.moveTo(h.x,h.y,h.z,e)),l.push(this.dollyTo(m,e)),l.push(this.setFocalOffset(0,0,0,e))}else if(I(this._camera)){const m=this._camera,C=m.right-m.left,u=m.top-m.bottom,x=s?Math.max(C/w.x,u/w.y):Math.min(C/w.x,u/w.y);l.push(this.moveTo(h.x,h.y,h.z,e)),l.push(this.zoomTo(x,e)),l.push(this.setFocalOffset(0,0,0,e))}return Promise.all(l)}fitToSphere(t,e){const s=[],o="isObject3D"in t?B.createBoundingSphere(t,mt):mt.copy(t);if(s.push(this.moveTo(o.center.x,o.center.y,o.center.z,e)),k(this._camera)){const r=this.getDistanceToFitSphere(o.radius);s.push(this.dollyTo(r,e))}else if(I(this._camera)){const r=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*o.radius,c=Math.min(r/l,a/l);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=Z.NONE,this._changedDolly=0;const l=b.set(i,o,r),c=T.set(t,e,s);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const g=!a||S(this._target.x,this._targetEnd.x,this.restThreshold)&&S(this._target.y,this._targetEnd.y,this.restThreshold)&&S(this._target.z,this._targetEnd.z,this.restThreshold)&&S(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&S(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&S(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(g)}lerpLookAt(t,e,s,i,o,r,a,l,c,g,_,y,p,P=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Z.NONE,this._changedDolly=0;const f=T.set(i,o,r),w=b.set(t,e,s);z.setFromVector3(w.sub(f).applyQuaternion(this._yAxisUpSpace));const h=j.set(g,_,y),m=b.set(a,l,c);Q.setFromVector3(m.sub(h).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(h,p));const C=Q.theta-z.theta,u=Q.phi-z.phi,x=Q.radius-z.radius;this._sphericalEnd.set(z.radius+x*p,z.phi+u*p,z.theta+C*p),this.normalizeRotations(),this._needsUpdate=!0,P||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!P||S(this._target.x,this._targetEnd.x,this.restThreshold)&&S(this._target.y,this._targetEnd.y,this.restThreshold)&&S(this._target.z,this._targetEnd.z,this.restThreshold)&&S(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&S(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&S(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=M(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||S(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&S(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&S(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}setOrbitPoint(t,e,s){this._camera.updateMatrixWorld(),F.setFromMatrixColumn(this._camera.matrixWorldInverse,0),H.setFromMatrixColumn(this._camera.matrixWorldInverse,1),V.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=T.set(t,e,s),o=i.distanceTo(this._camera.position),r=i.sub(this._camera.position);F.multiplyScalar(r.x),H.multiplyScalar(r.y),V.multiplyScalar(r.z),T.copy(F).add(H).add(V),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 E.Vector4,typeof t=="number"?this._viewport.set(t,e,s,i):this._viewport.copy(t)}getDistanceToFitBox(t,e,s,i=!1){if(ct(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=t/e,r=this._camera.getEffectiveFOV()*K,a=this._camera.aspect;return((i?o>a:o<a)?e:t/a)*.5/Math.tan(r*.5)+s*.5}getDistanceToFitSphere(t){if(ct(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*K,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 E.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new E.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new E.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new E.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%N,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=N),this._spherical.theta+=N*Math.round((this._sphericalEnd.theta-this._spherical.theta)/N)}reset(t=!1){if(!S(this._camera.up.x,this._cameraUp0.x)||!S(this._camera.up.y,this._cameraUp0.y)||!S(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,it),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=T.subVectors(this._target,this._camera.position).normalize(),e=b.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=Pt.subVectors(this._targetEnd,this._target),r=bt.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(D(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const _=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=et(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,_,1/0,t),this._needsUpdate=!0}if(D(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const _=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=et(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,_,1/0,t),this._needsUpdate=!0}if(D(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const _=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=et(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,_,this.maxSpeed,t),this._needsUpdate=!0}if(D(o.x)&&D(o.y)&&D(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const _=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;vt(this._target,this._targetEnd,this._targetVelocity,_,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(D(r.x)&&D(r.y)&&D(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const _=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;vt(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,_,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(D(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const _=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=et(this._zoom,this._zoomEnd,this._zoomVelocity,_,1/0,t)}if(this.dollyToCursor){if(k(this._camera)&&this._changedDolly!==0){const _=this._spherical.radius-this._lastDistance,y=this._camera,p=this._getCameraDirection(W),P=T.copy(p).cross(y.up).normalize();P.lengthSq()===0&&(P.x=1);const f=b.crossVectors(P,p),w=this._sphericalEnd.radius*Math.tan(y.getEffectiveFOV()*K*.5),m=(this._sphericalEnd.radius-_-this._sphericalEnd.radius)/this._sphericalEnd.radius,C=j.copy(this._targetEnd).add(P.multiplyScalar(this._dollyControlCoord.x*w*y.aspect)).add(f.multiplyScalar(this._dollyControlCoord.y*w)),u=T.copy(this._targetEnd).lerp(C,m),x=this._lastDollyDirection===Z.IN&&this._spherical.radius<=this.minDistance,O=this._lastDollyDirection===Z.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(x||O)){this._sphericalEnd.radius-=_,this._spherical.radius-=_;const R=b.copy(p).multiplyScalar(-_);u.add(R)}this._boundary.clampPoint(u,u);const U=b.subVectors(u,this._targetEnd);this._targetEnd.copy(u),this._target.add(U),this._changedDolly-=_,D(this._changedDolly)&&(this._changedDolly=0)}else if(I(this._camera)&&this._changedZoom!==0){const _=this._zoom-this._lastZoom,y=this._camera,p=T.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(y.near+y.far)/(y.near-y.far)).unproject(y),P=b.set(0,0,-1).applyQuaternion(y.quaternion),f=j.copy(p).add(P.multiplyScalar(-p.dot(y.up))),h=-(this._zoom-_-this._zoom)/this._zoom,m=this._getCameraDirection(W),C=this._targetEnd.dot(m),u=T.copy(this._targetEnd).lerp(f,h),x=u.dot(m),O=m.multiplyScalar(x-C);u.sub(O),this._boundary.clampPoint(u,u);const U=b.subVectors(u,this._targetEnd);this._targetEnd.copy(u),this._target.add(U),this._changedZoom-=_,D(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 l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!D(this._focalOffset.x)||!D(this._focalOffset.y)||!D(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),F.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),V.setFromMatrixColumn(this._camera.matrix,2),F.multiplyScalar(this._focalOffset.x),H.multiplyScalar(-this._focalOffset.y),V.multiplyScalar(this._focalOffset.z),T.copy(F).add(H).add(V),this._camera.position.add(T)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),T.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const g=this._needsUpdate;return g&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):g?(this.dispatchEvent({type:"update"}),D(e,this.restThreshold)&&D(s,this.restThreshold)&&D(i,this.restThreshold)&&D(o.x,this.restThreshold)&&D(o.y,this.restThreshold)&&D(o.z,this.restThreshold)&&D(r.x,this.restThreshold)&&D(r.y,this.restThreshold)&&D(r.z,this.restThreshold)&&D(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!g&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=g,this._needsUpdate=!1,g}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:X(this.maxDistance),minZoom:this.minZoom,maxZoom:X(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:X(this.maxPolarAngle),minAzimuthAngle:X(this.minAzimuthAngle),maxAzimuthAngle:X(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=G(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=G(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=G(s.maxPolarAngle),this.minAzimuthAngle=G(s.minAzimuthAngle),this.maxAzimuthAngle=G(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=b.copy(e).add(t),a=this._boundary.clampPoint(o,j).sub(o),l=a.lengthSq();if(l===0)return t.add(e);if(l===i)return t;if(s===0)return t.add(e).add(a);{const c=1+s*l/e.dot(a);return t.add(b.copy(e).multiplyScalar(c)).add(a.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(k(this._camera)){const t=this._camera,e=t.near,s=t.getEffectiveFOV()*K,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(I(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)||ct(this._camera,"_collisionTest"))return t;const s=this._getTargetDirection(W);pt.lookAt(xt,s,this._camera.up);for(let i=0;i<4;i++){const o=b.copy(this._nearPlaneCorners[i]);o.applyMatrix4(pt);const r=j.addVectors(this._target,o);ot.set(r,s),ot.far=this._spherical.radius+1;const a=ot.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 E.Sphere){const s=e,i=s.center;q.makeEmpty(),t.traverseVisible(r=>{r.isMesh&&q.expandByObject(r)}),q.getCenter(i);let o=0;return t.traverseVisible(r=>{if(!r.isMesh)return;const a=r,l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const g=l.attributes.position;for(let _=0,y=g.count;_<y;_++)T.fromBufferAttribute(g,_),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:Kt.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:l,antialias:c,powerPreference:g,toneMappingExposure:_,outputColorSpace:y,logarithmicDepthBuffer:p,preserveDrawingBuffer:P,stencil:f,depth:w,physicallyCorrectLights:h}=i,m=new v.WebGLRenderer({canvas:o,context:r,alpha:a,antialias:c,powerPreference:g,logarithmicDepthBuffer:p,preserveDrawingBuffer:P,stencil:f,depth:w});m.setSize(e,s),m.setPixelRatio(l),m.toneMappingExposure=_,m.outputColorSpace=y,+v.REVISION<155&&(m.useLegacyLights=h),this.renderer=m}setSize(t,e){this.renderer.setSize(t,e)}setPixelRatio(t){this.renderer.setPixelRatio(t)}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()}}const le={antialias:!0,devicePixelRatio:window.devicePixelRatio};class ce{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i,renderer:o}=t,{devicePixelRatio:r,antialias:a}=i,l=new o({antialias:a});l.setSize(e,s),l.setPixelRatio(r),this.renderer=l}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 ft{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:l,name:c,paramMap:g,items:_,value:y,target:p}=i[o],P=o.toLowerCase().indexOf("color")>-1;let f;const w=typeof y=="undefined"&&p,h=w?p():i[o],m=w?o:"value";_?f=s.add(h,m,_):P?f=s.addColor(h,m):f=s.add(h,m),f=f.name(c||o),typeof r!="undefined"&&(f=f.min(r)),typeof a!="undefined"&&(f=f.max(a)),typeof l!="undefined"&&(f=f.step(l)),f=f.onChange(()=>{this.setTargetValue(e,o,h[m],g)}),w&&f.listen()})})}setTargetValue(t,e,s,i){const{onChange:o,target:r,value:a}=this.guiParams[t][e],l=e.toLowerCase().indexOf("color")>-1;if(r&&!(typeof a=="undefined"&&r)){let g=r();Array.isArray(g)||(g=[g]),g.forEach(_=>{if(_)if(l)try{_[i||e].set(s)}catch(y){e!=="color"&&!i&&console.warn(`${e} is not a color,set paramMap`)}else _[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 de={fov:45,near:1,far:1e3,up:new v.Vector3(0,1,0)};class me{constructor(t){this.customCamera=!1,this.syncCamera=null,this.options=t;const{width:e,height:s,cameraParams:i}=t;if(i instanceof v.Camera)this.camera=i,this.customCamera=!0;else{const{fov:o,far:r,near:a,up:l}=i,c=new v.PerspectiveCamera(o,e/s,a,r);c.position.set(0,0,400),c.lookAt(0,0,0),c.up=l,this.camera=c}}setSize(t,e){this.camera instanceof v.PerspectiveCamera&&(this.camera.aspect=t/e),this.camera.updateProjectionMatrix(),this.camera2&&(this.camera2.aspect=t/e,this.camera2.updateProjectionMatrix())}addCamera2(){const t=new v.PerspectiveCamera(this.camera.fov,this.camera.aspect,this.camera.near,this.camera.far);return t.position.copy(this.camera.position),this.camera2=t,t}sync(){this.syncCamera&&!(this.camera.matrixWorld.equals(this.syncCamera.matrixWorld)&&this.camera.far===this.syncCamera.far&&this.camera.near===this.syncCamera.near&&this.camera.fov===this.syncCamera.fov&&this.camera.aspect===this.syncCamera.aspect)&&this.camera.copy(this.syncCamera)}setGui(t){const e=new ft({camera:ht(Y({},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 v.PerspectiveCamera&&(e.guiParams.camera.fov={min:0,max:90,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}),e.showGui(t)}}const _e={background:null,addCamera:!0};class pe{constructor(t){this.overrideMaterial=!1,this.options=t;const{camera:e,sceneParams:s}=t,{background:i,addCamera:o}=s,r=new v.Scene;i&&(r.background=i),o&&r.add(e),this.scene=r}dispose(){var t;(t=this.scene)==null||t.traverse(e=>{Xt.disposeMesh(e)})}}class ue{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 v.AxesHelper(100);else if(t.isCamera)i=new v.CameraHelper(t);else if(t.isPointLight)i=new v.PointLightHelper(t,1);else if(t.isDirectionalLight)i=new v.DirectionalLightHelper(t,1);else if(t.isSpotLight)i=new v.SpotLightHelper(t);else if(t.isHemisphereLight)i=new v.HemisphereLightHelper(t,10);else if(t.isRectAreaLight)i=new Gt.RectAreaLightHelper(t);else{const o=new v.Box3;if(o.setFromObject(t,!0),o.isEmpty()===!1){i=new v.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 v.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 v.AxesHelper||this.remove({uuid:t})})}update(){Object.values(this.helpers).forEach(t=>{if(t.update&&t.update(),t instanceof v.Box3Helper){const e=t.material,{object:s}=e.userData;s&&t.box.setFromObject(s,!0)}})}dispose(){this.helpers={}}}class fe{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 B.install({THREE:v}),this.cameraControls=new B(e,o)}addCameraControls2(t){const{controlsParams:e}=this.options,{domElement:s}=e;this.cameraControls2=new B(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*v.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 ge{constructor(t){this.event=new Ut.eventsExports.EventEmitter;const{renderer:e,scene:s,camera:i}=t,o=new Wt.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 Dt={zIndex:"auto"};class ye{constructor(t){this.container=t}addRenderer(t,e){const s=e.container||this.container,i=s.offsetWidth,o=s.offsetHeight,r=t==="css2d"?new Jt.CSS2DRenderer:new Qt.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 ut=1,J=!1,Ce=new v.MeshBasicMaterial({color:"black"}),Ee=new v.SpriteMaterial({color:"black"}),Oe={threshold:0,strength:.4,radius:.1,bloomAlphaType:.5};class Te{constructor(t){this.bloomComposerActive=!1,this.active=!0,this.bloomSelection=new Set,this.bloomLayer=new v.Layers,this.bloomMaterials={},this.transformControlsVisible=!1,this.options=t;const{renderer:e,scene:s,camera:i,composerParams:o}=t,{multisampling:r}=o,{maxSamples:a}=e.capabilities,l=e.getDrawingBufferSize(new v.Vector2),c=new v.WebGLRenderTarget(l.width,l.height,{samples:Math.min(r,a),type:v.HalfFloatType}),g=new $t.RenderPass(s,i),_=new Ct.EffectComposer(e,c);_.addPass(g),this.renderer=e,this.scene=s,this.camera=i,this.finalComposer=_,this.renderPass=g;const y=e.getSize(new v.Vector2);this.setSize(y.width,y.height)}setRenderPassCamera(t){this.renderPass.camera=t}resetRenderPassCamera(){this.renderPass.camera=this.camera}addOutputPass(){const t=new te.OutputPass;this.outputPass=t,this.finalComposer.addPass(t)}addBloomPass(t){const{renderer:e}=this,{threshold:s,strength:i,radius:o,bloomAlphaType:r}=t,a=new se.UnrealBloomPass(new v.Vector2(window.innerWidth,window.innerHeight),i,o,s);this.bloomPass=a;const l=new Ct.EffectComposer(e);l.renderToScreen=!1,l.addPass(this.renderPass),l.addPass(a),this.bloomComposer=l;const c=new ee.ShaderPass(new v.ShaderMaterial({uniforms:{baseTexture:{value:null},bloomTexture:{value:l.renderTarget2.texture},bloomAlphaType:{value:r}},vertexShader:`
|
|
1
|
+
"use strict";var Ht=Object.defineProperty,It=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var gt=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var yt=(d,t,e)=>t in d?Ht(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,Y=(d,t)=>{for(var e in t||(t={}))Vt.call(t,e)&&yt(d,e,t[e]);if(gt)for(var e of gt(t))Bt.call(t,e)&&yt(d,e,t[e]);return d},ht=(d,t)=>It(d,kt(t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Yt=require("three"),Zt=require("@tweenjs/tween.js"),Ut=require("./events.js"),Nt=require("deepmerge"),jt=require("stats-gl"),qt=require("lil-gui"),Kt=require("./colorCorrection.js"),Xt=require("./disposeMesh.js");require("idb-keyval");require("esus-lite");require("d3-geo");const Gt=require("three/examples/jsm/helpers/RectAreaLightHelper"),Wt=require("three/examples/jsm/controls/TransformControls"),Qt=require("three/examples/jsm/renderers/CSS3DRenderer"),Jt=require("three/examples/jsm/renderers/CSS2DRenderer"),Ct=require("three/examples/jsm/postprocessing/EffectComposer"),$t=require("three/examples/jsm/postprocessing/RenderPass"),te=require("three/examples/jsm/postprocessing/OutputPass"),ee=require("three/examples/jsm/postprocessing/ShaderPass"),se=require("three/examples/jsm/postprocessing/UnrealBloomPass"),ie=require("./isPlainObject.js"),oe=require("./BaseObject.js");function Lt(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 v=Lt(Yt),Et=Lt(Zt),L={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}),Z={NONE:0,IN:1,OUT:-1};function k(d){return d.isPerspectiveCamera}function I(d){return d.isOrthographicCamera}const N=Math.PI*2,Ot=Math.PI/2,Rt=1e-5,K=Math.PI/180;function M(d,t,e){return Math.max(t,Math.min(e,d))}function D(d,t=Rt){return Math.abs(d)<t}function S(d,t,e=Rt){return D(d-t,e)}function Tt(d,t){return Math.round(d/t)*t}function X(d){return isFinite(d)?d:d<0?-Number.MAX_VALUE:Number.MAX_VALUE}function G(d){return Math.abs(d)<Number.MAX_VALUE?d:d*(1/0)}function et(d,t,e,s,i=1/0,o){s=Math.max(1e-4,s);const r=2/s,a=r*o,l=1/(1+a+.48*a*a+.235*a*a*a);let c=d-t;const g=t,_=i*s;c=M(c,-_,_),t=d-c;const y=(e.value+r*c)*o;e.value=(e.value-r*y)*l;let p=t+(c+y)*l;return g-d>0==p>g&&(p=g,e.value=(p-g)/o),p}function vt(d,t,e,s,i=1/0,o,r){s=Math.max(1e-4,s);const a=2/s,l=a*o,c=1/(1+l+.48*l*l+.235*l*l*l);let g=t.x,_=t.y,y=t.z,p=d.x-g,P=d.y-_,f=d.z-y;const w=g,h=_,m=y,C=i*s,u=C*C,x=p*p+P*P+f*f;if(x>u){const at=Math.sqrt(x);p=p/at*C,P=P/at*C,f=f/at*C}g=d.x-p,_=d.y-P,y=d.z-f;const O=(e.x+a*p)*o,U=(e.y+a*P)*o,R=(e.z+a*f)*o;e.x=(e.x-a*O)*c,e.y=(e.y-a*U)*c,e.z=(e.z-a*R)*c,r.x=g+(p+O)*c,r.y=_+(P+U)*c,r.z=y+(f+R)*c;const $=w-d.x,tt=h-d.y,At=m-d.z,zt=r.x-w,Mt=r.y-h,Ft=r.z-m;return $*zt+tt*Mt+At*Ft>0&&(r.x=w,r.y=h,r.z=m,e.x=(r.x-w)/o,e.y=(r.y-h)/o,e.z=(r.z-m)/o),r}function lt(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 ct(d,t){return I(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 st=1/8,ne=/Mac/.test(navigator.platform);let E,xt,it,dt,A,T,b,j,W,F,H,V,Pt,bt,z,Q,q,wt,mt,St,_t,pt,ot;class B extends re{static install(t){E=t.THREE,xt=Object.freeze(new E.Vector3(0,0,0)),it=Object.freeze(new E.Vector3(0,1,0)),dt=Object.freeze(new E.Vector3(0,0,1)),A=new E.Vector2,T=new E.Vector3,b=new E.Vector3,j=new E.Vector3,W=new E.Vector3,F=new E.Vector3,H=new E.Vector3,V=new E.Vector3,Pt=new E.Vector3,bt=new E.Vector3,z=new E.Spherical,Q=new E.Spherical,q=new E.Box3,wt=new E.Box3,mt=new E.Sphere,St=new E.Quaternion,_t=new E.Quaternion,pt=new E.Matrix4,ot=new E.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=Z.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new E.Vector3,this._focalOffsetVelocity=new E.Vector3,this._zoomVelocity={value:0},this._truckInternal=(h,m,C)=>{let u,x;if(k(this._camera)){const O=T.copy(this._camera.position).sub(this._target),U=this._camera.getEffectiveFOV()*K,R=O.length()*Math.tan(U*.5);u=this.truckSpeed*h*R/this._elementRect.height,x=this.truckSpeed*m*R/this._elementRect.height}else if(I(this._camera)){const O=this._camera;u=h*(O.right-O.left)/O.zoom/this._elementRect.width,x=m*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(C?this.setFocalOffset(this._focalOffsetEnd.x+u,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(u,0,!0),this.forward(-x,!0)):C?this.setFocalOffset(this._focalOffsetEnd.x+u,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(u,x,!0)},this._rotateInternal=(h,m)=>{const C=N*this.azimuthRotateSpeed*h/this._elementRect.height,u=N*this.polarRotateSpeed*m/this._elementRect.height;this.rotate(C,u,!0)},this._dollyInternal=(h,m,C)=>{const u=Math.pow(.95,-h*this.dollySpeed),x=this._sphericalEnd.radius,O=this._sphericalEnd.radius*u,U=M(O,this.minDistance,this.maxDistance),R=U-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(R,!0),this._dollyToNoClamp(U,!0)):this._dollyToNoClamp(U,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:U)-x,this._dollyControlCoord.set(m,C)),this._lastDollyDirection=Math.sign(-h)},this._zoomInternal=(h,m,C)=>{const u=Math.pow(.95,h*this.dollySpeed),x=this._zoom,O=this._zoom*u;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-x,this._dollyControlCoord.set(m,C))},typeof E=="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 E.Quaternion().setFromUnitVectors(this._camera.up,it),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=n.NONE,this._target=new E.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new E.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new E.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 E.Vector3,new E.Vector3,new E.Vector3,new E.Vector3],this._updateNearPlaneCorners(),this._boundary=new E.Box3(new E.Vector3(-1/0,-1/0,-1/0),new E.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 E.Vector2,this.mouseButtons={left:n.ROTATE,middle:n.DOLLY,right:n.TRUCK,wheel:k(this._camera)?n.DOLLY:I(this._camera)?n.ZOOM:n.NONE},this.touches={one:n.TOUCH_ROTATE,two:k(this._camera)?n.TOUCH_DOLLY_TRUCK:I(this._camera)?n.TOUCH_ZOOM_TRUCK:n.NONE,three:n.TOUCH_TRUCK};const s=new E.Vector2,i=new E.Vector2,o=new E.Vector2,r=h=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const u=this._domElement.getBoundingClientRect(),x=(h.clientX-u.left)/(u.right-u.left),O=(h.clientY-u.top)/(u.bottom-u.top);if(x<this._interactiveArea.left||x>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const m=h.pointerType!=="mouse"?null:(h.buttons&L.LEFT)===L.LEFT?L.LEFT:(h.buttons&L.MIDDLE)===L.MIDDLE?L.MIDDLE:(h.buttons&L.RIGHT)===L.RIGHT?L.RIGHT:null;if(m!==null){const u=this._findPointerByMouseButton(m);u&&this._disposePointer(u)}if((h.buttons&L.LEFT)===L.LEFT&&this._lockedPointer)return;const C={pointerId:h.pointerId,clientX:h.clientX,clientY:h.clientY,deltaX:0,deltaY:0,mouseButton:m};this._activePointers.push(C),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,y(h)},a=h=>{h.cancelable&&h.preventDefault();const m=h.pointerId,C=this._lockedPointer||this._findPointerById(m);if(C){if(C.clientX=h.clientX,C.clientY=h.clientY,C.deltaX=h.movementX,C.deltaY=h.movementY,this._state=0,h.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&&(h.buttons&L.LEFT)===L.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(h.buttons&L.MIDDLE)===L.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(h.buttons&L.RIGHT)===L.RIGHT&&(this._state=this._state|this.mouseButtons.right);p()}},l=h=>{const m=this._findPointerById(h.pointerId);if(!(m&&m===this._lockedPointer)){if(m&&this._disposePointer(m),h.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;P()}};let c=-1;const g=h=>{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(),U=(h.clientX-O.left)/(O.right-O.left),R=(h.clientY-O.top)/(O.bottom-O.top);if(U<this._interactiveArea.left||U>this._interactiveArea.right||R<this._interactiveArea.top||R>this._interactiveArea.bottom)return}if(h.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 m=ne?-1:-3,C=h.deltaMode===1?h.deltaY/m:h.deltaY/(m*10),u=this.dollyToCursor?(h.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(h.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case n.ROTATE:{this._rotateInternal(h.deltaX,h.deltaY),this._isUserControllingRotate=!0;break}case n.TRUCK:{this._truckInternal(h.deltaX,h.deltaY,!1),this._isUserControllingTruck=!0;break}case n.OFFSET:{this._truckInternal(h.deltaX,h.deltaY,!0),this._isUserControllingOffset=!0;break}case n.DOLLY:{this._dollyInternal(-C,u,x),this._isUserControllingDolly=!0;break}case n.ZOOM:{this._zoomInternal(-C,u,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},_=h=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===B.ACTION.NONE){const m=h instanceof PointerEvent?h.pointerId:0,C=this._findPointerById(m);C&&this._disposePointer(C),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}h.preventDefault()}},y=h=>{if(!this._enabled)return;if(lt(this._activePointers,A),this._getClientRect(this._elementRect),s.copy(A),i.copy(A),this._activePointers.length>=2){const C=A.x-this._activePointers[1].clientX,u=A.y-this._activePointers[1].clientY,x=Math.sqrt(C*C+u*u);o.set(0,x);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,U=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(O,U)}if(this._state=0,!h)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in h&&h.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&&(h.buttons&L.LEFT)===L.LEFT&&(this._state=this._state|this.mouseButtons.left),(h.buttons&L.MIDDLE)===L.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(h.buttons&L.RIGHT)===L.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"})},p=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,lt(this._activePointers,A);const m=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,C=m?-m.deltaX:i.x-A.x,u=m?-m.deltaY:i.y-A.y;if(i.copy(A),((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(C,u),this._isUserControllingRotate=!0),(this._state&n.DOLLY)===n.DOLLY||(this._state&n.ZOOM)===n.ZOOM){const x=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,U=this.dollyDragInverted?-1:1;(this._state&n.DOLLY)===n.DOLLY?(this._dollyInternal(U*u*st,x,O),this._isUserControllingDolly=!0):(this._zoomInternal(U*u*st,x,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 x=A.x-this._activePointers[1].clientX,O=A.y-this._activePointers[1].clientY,U=Math.sqrt(x*x+O*O),R=o.y-U;o.set(0,U);const $=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,tt=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*st,$,tt),this._isUserControllingDolly=!0):(this._zoomInternal(R*st,$,tt),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(C,u,!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(C,u,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},P=()=>{lt(this._activePointers,A),i.copy(A),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",l),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",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",f),this._domElement.ownerDocument.addEventListener("pointerlockerror",w),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),y())},this.unlockPointer=()=>{var h,m,C;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(h=this._domElement)===null||h===void 0||h.ownerDocument.exitPointerLock(),(m=this._domElement)===null||m===void 0||m.ownerDocument.removeEventListener("pointerlockchange",f),(C=this._domElement)===null||C===void 0||C.ownerDocument.removeEventListener("pointerlockerror",w),this.cancel()};const f=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},w=()=>{this.unlockPointer()};this._addAllEventListeners=h=>{this._domElement=h,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",g,{passive:!1}),this._domElement.addEventListener("contextmenu",_)},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",l),this._domElement.removeEventListener("wheel",g,{passive:!1}),this._domElement.removeEventListener("contextmenu",_),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",f),this._domElement.ownerDocument.removeEventListener("pointerlockerror",w))},this.cancel=()=>{this._state!==n.NONE&&(this._state=n.NONE,this._activePointers.length=0,P())},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=M(t.width,0,1),this._interactiveArea.height=M(t.height,0,1),this._interactiveArea.x=M(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=M(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=M(t,this.minAzimuthAngle,this.maxAzimuthAngle),o=M(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||S(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&S(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=Z.NONE,this._changedDolly=0,this._dollyToNoClamp(M(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=S(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||S(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||S(this._target.x,this._targetEnd.x,this.restThreshold)&&S(this._target.y,this._targetEnd.y,this.restThreshold)&&S(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=M(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const s=!e||S(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(),F.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),F.multiplyScalar(t),H.multiplyScalar(-e);const i=T.copy(F).add(H),o=b.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=b.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||S(this._target.x,this._targetEnd.x,this.restThreshold)&&S(this._target.y,this._targetEnd.y,this.restThreshold)&&S(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 l=[],c=t.isBox3?q.copy(t):q.setFromObject(t);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const g=Tt(this._sphericalEnd.theta,Ot),_=Tt(this._sphericalEnd.phi,Ot);l.push(this.rotateTo(g,_,e));const y=T.setFromSpherical(this._sphericalEnd).normalize(),p=St.setFromUnitVectors(y,dt),P=S(Math.abs(y.y),1);P&&p.multiply(_t.setFromAxisAngle(it,g)),p.multiply(this._yAxisUpSpaceInverse);const f=wt.makeEmpty();b.copy(c.min).applyQuaternion(p),f.expandByPoint(b),b.copy(c.min).setX(c.max.x).applyQuaternion(p),f.expandByPoint(b),b.copy(c.min).setY(c.max.y).applyQuaternion(p),f.expandByPoint(b),b.copy(c.max).setZ(c.min.z).applyQuaternion(p),f.expandByPoint(b),b.copy(c.min).setZ(c.max.z).applyQuaternion(p),f.expandByPoint(b),b.copy(c.max).setY(c.min.y).applyQuaternion(p),f.expandByPoint(b),b.copy(c.max).setX(c.min.x).applyQuaternion(p),f.expandByPoint(b),b.copy(c.max).applyQuaternion(p),f.expandByPoint(b),f.min.x-=i,f.min.y-=r,f.max.x+=o,f.max.y+=a,p.setFromUnitVectors(dt,y),P&&p.premultiply(_t.invert()),p.premultiply(this._yAxisUpSpace);const w=f.getSize(T),h=f.getCenter(b).applyQuaternion(p);if(k(this._camera)){const m=this.getDistanceToFitBox(w.x,w.y,w.z,s);l.push(this.moveTo(h.x,h.y,h.z,e)),l.push(this.dollyTo(m,e)),l.push(this.setFocalOffset(0,0,0,e))}else if(I(this._camera)){const m=this._camera,C=m.right-m.left,u=m.top-m.bottom,x=s?Math.max(C/w.x,u/w.y):Math.min(C/w.x,u/w.y);l.push(this.moveTo(h.x,h.y,h.z,e)),l.push(this.zoomTo(x,e)),l.push(this.setFocalOffset(0,0,0,e))}return Promise.all(l)}fitToSphere(t,e){const s=[],o="isObject3D"in t?B.createBoundingSphere(t,mt):mt.copy(t);if(s.push(this.moveTo(o.center.x,o.center.y,o.center.z,e)),k(this._camera)){const r=this.getDistanceToFitSphere(o.radius);s.push(this.dollyTo(r,e))}else if(I(this._camera)){const r=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*o.radius,c=Math.min(r/l,a/l);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=Z.NONE,this._changedDolly=0;const l=b.set(i,o,r),c=T.set(t,e,s);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const g=!a||S(this._target.x,this._targetEnd.x,this.restThreshold)&&S(this._target.y,this._targetEnd.y,this.restThreshold)&&S(this._target.z,this._targetEnd.z,this.restThreshold)&&S(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&S(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&S(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(g)}lerpLookAt(t,e,s,i,o,r,a,l,c,g,_,y,p,P=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Z.NONE,this._changedDolly=0;const f=T.set(i,o,r),w=b.set(t,e,s);z.setFromVector3(w.sub(f).applyQuaternion(this._yAxisUpSpace));const h=j.set(g,_,y),m=b.set(a,l,c);Q.setFromVector3(m.sub(h).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(h,p));const C=Q.theta-z.theta,u=Q.phi-z.phi,x=Q.radius-z.radius;this._sphericalEnd.set(z.radius+x*p,z.phi+u*p,z.theta+C*p),this.normalizeRotations(),this._needsUpdate=!0,P||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!P||S(this._target.x,this._targetEnd.x,this.restThreshold)&&S(this._target.y,this._targetEnd.y,this.restThreshold)&&S(this._target.z,this._targetEnd.z,this.restThreshold)&&S(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&S(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&S(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=M(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||S(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&S(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&S(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}setOrbitPoint(t,e,s){this._camera.updateMatrixWorld(),F.setFromMatrixColumn(this._camera.matrixWorldInverse,0),H.setFromMatrixColumn(this._camera.matrixWorldInverse,1),V.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=T.set(t,e,s),o=i.distanceTo(this._camera.position),r=i.sub(this._camera.position);F.multiplyScalar(r.x),H.multiplyScalar(r.y),V.multiplyScalar(r.z),T.copy(F).add(H).add(V),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 E.Vector4,typeof t=="number"?this._viewport.set(t,e,s,i):this._viewport.copy(t)}getDistanceToFitBox(t,e,s,i=!1){if(ct(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=t/e,r=this._camera.getEffectiveFOV()*K,a=this._camera.aspect;return((i?o>a:o<a)?e:t/a)*.5/Math.tan(r*.5)+s*.5}getDistanceToFitSphere(t){if(ct(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*K,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 E.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new E.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new E.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new E.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%N,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=N),this._spherical.theta+=N*Math.round((this._sphericalEnd.theta-this._spherical.theta)/N)}reset(t=!1){if(!S(this._camera.up.x,this._cameraUp0.x)||!S(this._camera.up.y,this._cameraUp0.y)||!S(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,it),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=T.subVectors(this._target,this._camera.position).normalize(),e=b.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=Pt.subVectors(this._targetEnd,this._target),r=bt.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(D(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const _=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=et(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,_,1/0,t),this._needsUpdate=!0}if(D(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const _=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=et(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,_,1/0,t),this._needsUpdate=!0}if(D(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const _=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=et(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,_,this.maxSpeed,t),this._needsUpdate=!0}if(D(o.x)&&D(o.y)&&D(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const _=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;vt(this._target,this._targetEnd,this._targetVelocity,_,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(D(r.x)&&D(r.y)&&D(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const _=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;vt(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,_,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(D(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const _=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=et(this._zoom,this._zoomEnd,this._zoomVelocity,_,1/0,t)}if(this.dollyToCursor){if(k(this._camera)&&this._changedDolly!==0){const _=this._spherical.radius-this._lastDistance,y=this._camera,p=this._getCameraDirection(W),P=T.copy(p).cross(y.up).normalize();P.lengthSq()===0&&(P.x=1);const f=b.crossVectors(P,p),w=this._sphericalEnd.radius*Math.tan(y.getEffectiveFOV()*K*.5),m=(this._sphericalEnd.radius-_-this._sphericalEnd.radius)/this._sphericalEnd.radius,C=j.copy(this._targetEnd).add(P.multiplyScalar(this._dollyControlCoord.x*w*y.aspect)).add(f.multiplyScalar(this._dollyControlCoord.y*w)),u=T.copy(this._targetEnd).lerp(C,m),x=this._lastDollyDirection===Z.IN&&this._spherical.radius<=this.minDistance,O=this._lastDollyDirection===Z.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(x||O)){this._sphericalEnd.radius-=_,this._spherical.radius-=_;const R=b.copy(p).multiplyScalar(-_);u.add(R)}this._boundary.clampPoint(u,u);const U=b.subVectors(u,this._targetEnd);this._targetEnd.copy(u),this._target.add(U),this._changedDolly-=_,D(this._changedDolly)&&(this._changedDolly=0)}else if(I(this._camera)&&this._changedZoom!==0){const _=this._zoom-this._lastZoom,y=this._camera,p=T.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(y.near+y.far)/(y.near-y.far)).unproject(y),P=b.set(0,0,-1).applyQuaternion(y.quaternion),f=j.copy(p).add(P.multiplyScalar(-p.dot(y.up))),h=-(this._zoom-_-this._zoom)/this._zoom,m=this._getCameraDirection(W),C=this._targetEnd.dot(m),u=T.copy(this._targetEnd).lerp(f,h),x=u.dot(m),O=m.multiplyScalar(x-C);u.sub(O),this._boundary.clampPoint(u,u);const U=b.subVectors(u,this._targetEnd);this._targetEnd.copy(u),this._target.add(U),this._changedZoom-=_,D(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 l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!D(this._focalOffset.x)||!D(this._focalOffset.y)||!D(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),F.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),V.setFromMatrixColumn(this._camera.matrix,2),F.multiplyScalar(this._focalOffset.x),H.multiplyScalar(-this._focalOffset.y),V.multiplyScalar(this._focalOffset.z),T.copy(F).add(H).add(V),this._camera.position.add(T)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),T.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const g=this._needsUpdate;return g&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):g?(this.dispatchEvent({type:"update"}),D(e,this.restThreshold)&&D(s,this.restThreshold)&&D(i,this.restThreshold)&&D(o.x,this.restThreshold)&&D(o.y,this.restThreshold)&&D(o.z,this.restThreshold)&&D(r.x,this.restThreshold)&&D(r.y,this.restThreshold)&&D(r.z,this.restThreshold)&&D(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!g&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=g,this._needsUpdate=!1,g}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:X(this.maxDistance),minZoom:this.minZoom,maxZoom:X(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:X(this.maxPolarAngle),minAzimuthAngle:X(this.minAzimuthAngle),maxAzimuthAngle:X(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=G(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=G(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=G(s.maxPolarAngle),this.minAzimuthAngle=G(s.minAzimuthAngle),this.maxAzimuthAngle=G(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=b.copy(e).add(t),a=this._boundary.clampPoint(o,j).sub(o),l=a.lengthSq();if(l===0)return t.add(e);if(l===i)return t;if(s===0)return t.add(e).add(a);{const c=1+s*l/e.dot(a);return t.add(b.copy(e).multiplyScalar(c)).add(a.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(k(this._camera)){const t=this._camera,e=t.near,s=t.getEffectiveFOV()*K,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(I(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)||ct(this._camera,"_collisionTest"))return t;const s=this._getTargetDirection(W);pt.lookAt(xt,s,this._camera.up);for(let i=0;i<4;i++){const o=b.copy(this._nearPlaneCorners[i]);o.applyMatrix4(pt);const r=j.addVectors(this._target,o);ot.set(r,s),ot.far=this._spherical.radius+1;const a=ot.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 E.Sphere){const s=e,i=s.center;q.makeEmpty(),t.traverseVisible(r=>{r.isMesh&&q.expandByObject(r)}),q.getCenter(i);let o=0;return t.traverseVisible(r=>{if(!r.isMesh)return;const a=r,l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const g=l.attributes.position;for(let _=0,y=g.count;_<y;_++)T.fromBufferAttribute(g,_),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:Kt.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:l,antialias:c,powerPreference:g,toneMappingExposure:_,outputColorSpace:y,logarithmicDepthBuffer:p,preserveDrawingBuffer:P,stencil:f,depth:w,physicallyCorrectLights:h}=i,m=new v.WebGLRenderer({canvas:o,context:r,alpha:a,antialias:c,powerPreference:g,logarithmicDepthBuffer:p,preserveDrawingBuffer:P,stencil:f,depth:w});m.setSize(e,s),m.setPixelRatio(l),m.toneMappingExposure=_,m.outputColorSpace=y,+v.REVISION<155&&(m.useLegacyLights=h),this.renderer=m}setSize(t,e){this.renderer.setSize(t,e)}setPixelRatio(t){this.renderer.setPixelRatio(t)}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()}}const le={antialias:!0,devicePixelRatio:window.devicePixelRatio};class ce{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i,renderer:o}=t,{devicePixelRatio:r,antialias:a}=i,l=new o({antialias:a});l.setSize(e,s),l.setPixelRatio(r),this.renderer=l}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 ft{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:l,name:c,paramMap:g,items:_,value:y,target:p}=i[o],P=o.toLowerCase().indexOf("color")>-1;let f;const w=typeof y=="undefined"&&p,h=w?p():i[o],m=w?o:"value";_?f=s.add(h,m,_):P?f=s.addColor(h,m):f=s.add(h,m),f=f.name(c||o),typeof r!="undefined"&&(f=f.min(r)),typeof a!="undefined"&&(f=f.max(a)),typeof l!="undefined"&&(f=f.step(l)),f=f.onChange(()=>{this.setTargetValue(e,o,h[m],g)}),w&&f.listen()})})}setTargetValue(t,e,s,i){const{onChange:o,target:r,value:a}=this.guiParams[t][e],l=e.toLowerCase().indexOf("color")>-1;if(r&&!(typeof a=="undefined"&&r)){let g=r();Array.isArray(g)||(g=[g]),g.forEach(_=>{if(_)if(l)try{_[i||e].set(s)}catch(y){e!=="color"&&!i&&console.warn(`${e} is not a color,set paramMap`)}else _[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 de={fov:45,near:1,far:1e3,up:new v.Vector3(0,1,0)};class me{constructor(t){this.customCamera=!1,this.syncCamera=null,this.options=t;const{width:e,height:s,cameraParams:i}=t;if(i instanceof v.Camera)this.camera=i,this.customCamera=!0;else{const{fov:o,far:r,near:a,up:l}=i,c=new v.PerspectiveCamera(o,e/s,a,r);c.position.set(0,0,400),c.lookAt(0,0,0),c.up=l,this.camera=c}}setSize(t,e){this.camera instanceof v.PerspectiveCamera&&(this.camera.aspect=t/e),this.camera.updateProjectionMatrix(),this.camera2&&(this.camera2.aspect=t/e,this.camera2.updateProjectionMatrix())}addCamera2(){const t=new v.PerspectiveCamera(this.camera.fov,this.camera.aspect,this.camera.near,this.camera.far);return t.position.copy(this.camera.position),this.camera2=t,t}sync(){this.syncCamera&&!(this.camera.matrixWorld.equals(this.syncCamera.matrixWorld)&&this.camera.far===this.syncCamera.far&&this.camera.near===this.syncCamera.near&&this.camera.fov===this.syncCamera.fov&&this.camera.aspect===this.syncCamera.aspect)&&this.camera.copy(this.syncCamera)}setGui(t){const e=new ft({camera:ht(Y({},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 v.PerspectiveCamera&&(e.guiParams.camera.fov={min:0,max:90,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}),e.showGui(t)}}const _e={background:null,addCamera:!0};class pe{constructor(t){this.overrideMaterial=!1,this.options=t;const{camera:e,sceneParams:s}=t,{background:i,addCamera:o}=s,r=new v.Scene;i&&(r.background=i),o&&r.add(e),this.scene=r}dispose(){var t;(t=this.scene)==null||t.traverse(e=>{Xt.disposeMesh(e)})}}class ue{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 v.AxesHelper(100);else if(t.isCamera)i=new v.CameraHelper(t);else if(t.isPointLight)i=new v.PointLightHelper(t,1);else if(t.isDirectionalLight)i=new v.DirectionalLightHelper(t,1);else if(t.isSpotLight)i=new v.SpotLightHelper(t);else if(t.isHemisphereLight)i=new v.HemisphereLightHelper(t,10);else if(t.isRectAreaLight)i=new Gt.RectAreaLightHelper(t);else{const o=new v.Box3;if(o.setFromObject(t,!0),o.isEmpty()===!1){i=new v.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){var i;const e=t.uuid,{scene:s}=this.options;if(this.helpers[e]!==void 0){const o=this.helpers[e];s.remove(o),delete this.helpers[e],(i=o.dispose)==null||i.call(o)}}removeAll(){Object.keys(this.helpers).forEach(t=>{this.remove({uuid:t})}),this.helpers={}}removeAllExcludeScene(){Object.keys(this.helpers).forEach(t=>{this.helpers[t]instanceof v.AxesHelper||this.remove({uuid:t})})}update(){Object.values(this.helpers).forEach(t=>{if(t.update&&t.update(),t instanceof v.Box3Helper){const e=t.material,{object:s}=e.userData;s&&t.box.setFromObject(s,!0)}})}dispose(){this.helpers={}}}class fe{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 B.install({THREE:v}),this.cameraControls=new B(e,o)}addCameraControls2(t){const{controlsParams:e}=this.options,{domElement:s}=e;this.cameraControls2=new B(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*v.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 ge{constructor(t){this.event=new Ut.eventsExports.EventEmitter;const{renderer:e,scene:s,camera:i}=t,o=new Wt.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 Dt={zIndex:"auto"};class ye{constructor(t){this.container=t}addRenderer(t,e){const s=e.container||this.container,i=s.offsetWidth,o=s.offsetHeight,r=t==="css2d"?new Jt.CSS2DRenderer:new Qt.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 ut=1,J=!1,Ce=new v.MeshBasicMaterial({color:"black"}),Ee=new v.SpriteMaterial({color:"black"}),Oe={threshold:0,strength:.4,radius:.1,bloomAlphaType:.5};class Te{constructor(t){this.bloomComposerActive=!1,this.active=!0,this.bloomSelection=new Set,this.bloomLayer=new v.Layers,this.bloomMaterials={},this.transformControlsVisible=!1,this.options=t;const{renderer:e,scene:s,camera:i,composerParams:o}=t,{multisampling:r}=o,{maxSamples:a}=e.capabilities,l=e.getDrawingBufferSize(new v.Vector2),c=new v.WebGLRenderTarget(l.width,l.height,{samples:Math.min(r,a),type:v.HalfFloatType}),g=new $t.RenderPass(s,i),_=new Ct.EffectComposer(e,c);_.addPass(g),this.renderer=e,this.scene=s,this.camera=i,this.finalComposer=_,this.renderPass=g;const y=e.getSize(new v.Vector2);this.setSize(y.width,y.height)}setRenderPassCamera(t){this.renderPass.camera=t}resetRenderPassCamera(){this.renderPass.camera=this.camera}addOutputPass(){const t=new te.OutputPass;this.outputPass=t,this.finalComposer.addPass(t)}addBloomPass(t){const{renderer:e}=this,{threshold:s,strength:i,radius:o,bloomAlphaType:r}=t,a=new se.UnrealBloomPass(new v.Vector2(window.innerWidth,window.innerHeight),i,o,s);this.bloomPass=a;const l=new Ct.EffectComposer(e);l.renderToScreen=!1,l.addPass(this.renderPass),l.addPass(a),this.bloomComposer=l;const c=new ee.ShaderPass(new v.ShaderMaterial({uniforms:{baseTexture:{value:null},bloomTexture:{value:l.renderTarget2.texture},bloomAlphaType:{value:r}},vertexShader:`
|
|
2
2
|
varying vec2 vUv;
|
|
3
3
|
void main() {
|
|
4
4
|
vUv = uv;
|
package/dist/index.module.js
CHANGED
|
@@ -1988,10 +1988,11 @@ class de {
|
|
|
1988
1988
|
}
|
|
1989
1989
|
}
|
|
1990
1990
|
remove(t) {
|
|
1991
|
+
var i;
|
|
1991
1992
|
const e = t.uuid, { scene: s } = this.options;
|
|
1992
1993
|
if (this.helpers[e] !== void 0) {
|
|
1993
|
-
const
|
|
1994
|
-
s.remove(
|
|
1994
|
+
const o = this.helpers[e];
|
|
1995
|
+
s.remove(o), delete this.helpers[e], (i = o.dispose) == null || i.call(o);
|
|
1995
1996
|
}
|
|
1996
1997
|
}
|
|
1997
1998
|
removeAll() {
|