gl-draw 0.10.16 → 0.10.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var 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 b(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 C=(e.value+r*c)*o;e.value=(e.value-r*C)*l;let p=t+(c+C)*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,C=t.z,p=d.x-g,P=d.y-_,f=d.z-C;const S=g,h=_,m=C,y=i*s,u=y*y,x=p*p+P*P+f*f;if(x>u){const at=Math.sqrt(x);p=p/at*y,P=P/at*y,f=f/at*y}g=d.x-p,_=d.y-P,C=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=C+(f+R)*c;const $=S-d.x,tt=h-d.y,At=m-d.z,zt=r.x-S,Mt=r.y-h,Ft=r.z-m;return $*zt+tt*Mt+At*Ft>0&&(r.x=S,r.y=h,r.z=m,e.x=(r.x-S)/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,w,j,W,F,H,V,Pt,wt,z,Q,q,St,mt,bt,_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,w=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,wt=new E.Vector3,z=new E.Spherical,Q=new E.Spherical,q=new E.Box3,St=new E.Box3,mt=new E.Sphere,bt=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,y)=>{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?(y?this.setFocalOffset(this._focalOffsetEnd.x+u,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(u,0,!0),this.forward(-x,!0)):y?this.setFocalOffset(this._focalOffsetEnd.x+u,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(u,x,!0)},this._rotateInternal=(h,m)=>{const y=N*this.azimuthRotateSpeed*h/this._elementRect.height,u=N*this.polarRotateSpeed*m/this._elementRect.height;this.rotate(y,u,!0)},this._dollyInternal=(h,m,y)=>{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,y)),this._lastDollyDirection=Math.sign(-h)},this._zoomInternal=(h,m,y)=>{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,y))},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 y={pointerId:h.pointerId,clientX:h.clientX,clientY:h.clientY,deltaX:0,deltaY:0,mouseButton:m};this._activePointers.push(y),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,C(h)},a=h=>{h.cancelable&&h.preventDefault();const m=h.pointerId,y=this._lockedPointer||this._findPointerById(m);if(y){if(y.clientX=h.clientX,y.clientY=h.clientY,y.deltaX=h.movementX,y.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,y=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(-y,u,x),this._isUserControllingDolly=!0;break}case n.ZOOM:{this._zoomInternal(-y,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,y=this._findPointerById(m);y&&this._disposePointer(y),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}h.preventDefault()}},C=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 y=A.x-this._activePointers[1].clientX,u=A.y-this._activePointers[1].clientY,x=Math.sqrt(y*y+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,y=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(y,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(y,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(y,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",S),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),C())},this.unlockPointer=()=>{var h,m,y;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),(y=this._domElement)===null||y===void 0||y.ownerDocument.removeEventListener("pointerlockerror",S),this.cancel()};const f=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},S=()=>{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",S))},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||b(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&b(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=b(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||b(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||b(this._target.x,this._targetEnd.x,this.restThreshold)&&b(this._target.y,this._targetEnd.y,this.restThreshold)&&b(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||b(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=w.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=w.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||b(this._target.x,this._targetEnd.x,this.restThreshold)&&b(this._target.y,this._targetEnd.y,this.restThreshold)&&b(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 C=T.setFromSpherical(this._sphericalEnd).normalize(),p=bt.setFromUnitVectors(C,dt),P=b(Math.abs(C.y),1);P&&p.multiply(_t.setFromAxisAngle(it,g)),p.multiply(this._yAxisUpSpaceInverse);const f=St.makeEmpty();w.copy(c.min).applyQuaternion(p),f.expandByPoint(w),w.copy(c.min).setX(c.max.x).applyQuaternion(p),f.expandByPoint(w),w.copy(c.min).setY(c.max.y).applyQuaternion(p),f.expandByPoint(w),w.copy(c.max).setZ(c.min.z).applyQuaternion(p),f.expandByPoint(w),w.copy(c.min).setZ(c.max.z).applyQuaternion(p),f.expandByPoint(w),w.copy(c.max).setY(c.min.y).applyQuaternion(p),f.expandByPoint(w),w.copy(c.max).setX(c.min.x).applyQuaternion(p),f.expandByPoint(w),w.copy(c.max).applyQuaternion(p),f.expandByPoint(w),f.min.x-=i,f.min.y-=r,f.max.x+=o,f.max.y+=a,p.setFromUnitVectors(dt,C),P&&p.premultiply(_t.invert()),p.premultiply(this._yAxisUpSpace);const S=f.getSize(T),h=f.getCenter(w).applyQuaternion(p);if(k(this._camera)){const m=this.getDistanceToFitBox(S.x,S.y,S.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,y=m.right-m.left,u=m.top-m.bottom,x=s?Math.max(y/S.x,u/S.y):Math.min(y/S.x,u/S.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=w.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||b(this._target.x,this._targetEnd.x,this.restThreshold)&&b(this._target.y,this._targetEnd.y,this.restThreshold)&&b(this._target.z,this._targetEnd.z,this.restThreshold)&&b(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&b(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&b(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(g)}lerpLookAt(t,e,s,i,o,r,a,l,c,g,_,C,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),S=w.set(t,e,s);z.setFromVector3(S.sub(f).applyQuaternion(this._yAxisUpSpace));const h=j.set(g,_,C),m=w.set(a,l,c);Q.setFromVector3(m.sub(h).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(h,p));const y=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+y*p),this.normalizeRotations(),this._needsUpdate=!0,P||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!P||b(this._target.x,this._targetEnd.x,this.restThreshold)&&b(this._target.y,this._targetEnd.y,this.restThreshold)&&b(this._target.z,this._targetEnd.z,this.restThreshold)&&b(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&b(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&b(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||b(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&b(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&b(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(!b(this._camera.up.x,this._cameraUp0.x)||!b(this._camera.up.y,this._cameraUp0.y)||!b(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=w.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=wt.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,C=this._camera,p=this._getCameraDirection(W),P=T.copy(p).cross(C.up).normalize();P.lengthSq()===0&&(P.x=1);const f=w.crossVectors(P,p),S=this._sphericalEnd.radius*Math.tan(C.getEffectiveFOV()*K*.5),m=(this._sphericalEnd.radius-_-this._sphericalEnd.radius)/this._sphericalEnd.radius,y=j.copy(this._targetEnd).add(P.multiplyScalar(this._dollyControlCoord.x*S*C.aspect)).add(f.multiplyScalar(this._dollyControlCoord.y*S)),u=T.copy(this._targetEnd).lerp(y,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=w.copy(p).multiplyScalar(-_);u.add(R)}this._boundary.clampPoint(u,u);const U=w.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,C=this._camera,p=T.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(C.near+C.far)/(C.near-C.far)).unproject(C),P=w.set(0,0,-1).applyQuaternion(C.quaternion),f=j.copy(p).add(P.multiplyScalar(-p.dot(C.up))),h=-(this._zoom-_-this._zoom)/this._zoom,m=this._getCameraDirection(W),y=this._targetEnd.dot(m),u=T.copy(this._targetEnd).lerp(f,h),x=u.dot(m),O=m.multiplyScalar(x-y);u.sub(O),this._boundary.clampPoint(u,u);const U=w.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=w.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(w.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=w.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,C=g.count;_<C;_++)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:C,logarithmicDepthBuffer:p,preserveDrawingBuffer:P,stencil:f,depth:S,physicallyCorrectLights:h}=i,m=new v.WebGLRenderer({canvas:o,context:r,alpha:a,antialias:c,powerPreference:g,logarithmicDepthBuffer:p,preserveDrawingBuffer:P,stencil:f,depth:S});m.setSize(e,s),m.setPixelRatio(l),m.toneMappingExposure=_,m.outputColorSpace=C,+v.REVISION<155&&(m.useLegacyLights=h),this.renderer=m}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()}}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:C,target:p}=i[o],P=o.toLowerCase().indexOf("color")>-1;let f;const S=typeof C=="undefined"&&p,h=S?p():i[o],m=S?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)}),S&&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(C){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}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)}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:`
2
2
  varying vec2 vUv;
3
3
  void main() {
4
4
  vUv = uv;
@@ -17,9 +17,15 @@
17
17
  gl_FragColor = vec4(base_color.rgb + bloom_color.rgb, max(base_color.a, lum));
18
18
  }else if( bloomAlphaType == 0.5){
19
19
  gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
20
- gl_FragColor.a = base_color.a;
20
+ if(base_color.a == 0.0){
21
+ if( bloom_color.r == 0.0 && bloom_color.g == 0.0 && bloom_color.b == 0.0){
22
+ gl_FragColor.a = 0.0;
23
+ }else{
24
+ gl_FragColor.a = 0.002;
25
+ }
26
+ }
21
27
  }else{
22
28
  gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
23
29
  }
24
30
  }
25
- `,defines:{}}),"baseTexture");c.needsSwap=!0,this.bloomComposer=l,this.finalComposer.addPass(c),this.mixPass=c,this.bloomLayer.set(ut)}addBloomGui(t){if(!this.bloomComposer)return;new ft({bloom:{threshold:{min:0,max:1,step:.01,target:()=>this.bloomPass},radius:{min:0,max:1,step:.001,target:()=>this.bloomPass},strength:{min:0,max:10,step:.001,target:()=>this.bloomPass}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomComposer){console.warn("err:pencil.options.bloom");return}const{object3d:s}=t;if(!s)return;let i=e;e===void 0&&(i=!this.bloomSelection.has(s)),i?(this.bloomSelection.add(s),s.layers.enable(ut)):(this.bloomSelection.delete(s),s.layers.disable(ut)),this.bloomSelection.size===0?this.bloomComposerActive=!1:this.bloomComposerActive=!0}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){var s;(s=this.bloomComposer)==null||s.setSize(t,e),this.finalComposer.setSize(t,e)}darkenNonBloomed(){const t=this.scene.children.find(e=>e.isTransformControls);t&&(this.transformControlsVisible=t.visible,this.transformControlsVisible&&(t.visible=!1)),this.scene.traverse(e=>{const s=e,i=e;t&&t.getObjectById(s.id)||s.material&&this.bloomLayer.test(s.layers)===!1&&(this.bloomMaterials[s.uuid]=s.material,s.material=i.isSprite?Ee:Ce)})}restoreNonBloomed(){if(this.transformControlsVisible){const t=this.scene.children.find(e=>e.isTransformControls);t&&(t.visible=!0)}this.scene.traverse(t=>{const e=t;this.bloomMaterials[e.uuid]&&(e.material=this.bloomMaterials[e.uuid],delete this.bloomMaterials[e.uuid])})}render(){this.active&&(this.bloomComposerActive&&this.bloomComposer?(this.mixPass.enabled=!0,this.darkenNonBloomed(),this.bloomComposer.render(),this.restoreNonBloomed()):this.mixPass&&(this.mixPass.enabled=!1),this.finalComposer.render())}render2(){this.active}dispose(){var t;this.bloomMaterials={},this.bloomSelection.clear(),this.finalComposer.dispose(),(t=this.bloomComposer)==null||t.dispose()}}const nt=class nt{constructor(t,e){this.raycaster=new v.Raycaster,this.installPlugins=new Map,this.event=new Ut.eventsExports.EventEmitter,this.clock=new v.Clock,this.userData={},this.pipViewportState=!1,this.options=Nt(nt.options,t,{isMergeableObject:ie.isPlainObject}),this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:o,resizeObserver:r}=this.options;if(o){const a=new qt;a.open(!1),this.gui=a}if(this.init(),i){const a=new jt({horizontal:!1});a.init(this.renderer),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}this.options.WebGPUTHREE||this.initComposer(),this.initCSSRenderer(),this.initControls(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime(),e&&(Array.isArray(e)||(e=[e]),e.forEach(a=>{Array.isArray(a)||(a=[a]),this.use(a[0],a[1])}))}getPlugin(t){return this.installPlugins.get(t)}get renderer(){return this.rendererController.renderer}get maxAnisotropy(){return this.options.WebGPUTHREE?0:this.renderer.capabilities.getMaxAnisotropy()}get cameraControls(){return this.controlsController.cameraControls}get cameraPositon(){return this.cameraControls.getPosition(new v.Vector3,!1)}get cameraTarget(){return this.cameraControls.getTarget(new v.Vector3,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(t,...e){this.installPlugins.has(t.pluginName)?console.log("plugin already installed"):typeof t.install=="function"&&(t.install(this,...e),this.installPlugins.set(t.pluginName,t))}init(){const{container:t,isdev:e,WebGPUTHREE:s,helper:i,renderer:o,scene:r,camera:a,control:l}=this.options,{width:c,height:g}=this.getSize(),_=new me({isdev:e,width:c,height:g,cameraParams:a,cameraControls:l===!0});this.gui&&_.setGui(this.gui);const C=_.camera,p=new pe({camera:C,sceneParams:r}),P=p.scene,f=s?new ce({width:c,height:g,scene:P,camera:C,isdev:e,renderer:s.WebGPURenderer,rendererParams:le}):new he({width:c,height:g,scene:P,camera:C,isdev:e,rendererParams:ht(Y({},o),{antialias:!1})});if(i){const S=new ue({scene:P});S.add(P),this.helperController=S}this.sceneController=p,this.rendererController=f,this.cameraController=_,t.appendChild(f.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,multisampling:s}=this.options,i=new Te({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:s}});this.composerController=i,t&&(i.addBloomPass(Y({},e)),this.gui&&i.addBloomGui(this.gui)),i.addOutputPass()}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new ye(t);e&&r.addRenderer("css2d",i),s&&r.addRenderer("css3d",o),this.cssRendererController=r}}initControls(){const{control:t,controlParams:e,transformControls:s}=this.options;if(t){const i=new fe({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new ge({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var o;(o=this.controlsController)==null||o.disable()}),i.event.on("mouseUp",()=>{var o;(o=this.controlsController)==null||o.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=this.getSize(),s=new ResizeObserver(i=>{for(const o of i){const r=o.contentRect;(r.width!==e.width||r.height!==e.height)&&(e.width=r.width,e.height=r.height,this.handeleResize(r.width,r.height),this.render())}});s.observe(t),this.resizeObserver=s}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:o,composerController:r,cssRendererController:a}=this;o==null||o.setSize(t,e),i==null||i.setSize(t,e),r==null||r.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(l=>{var c;(c=l.setSize)==null||c.call(l,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!0){const{raycaster:i,options:o}=this,{container:r}=o,a=new v.Vector2,l=r.getBoundingClientRect();if(a.x=(t.clientX-l.left)/(l.right-l.left)*2-1,a.y=-((t.clientY-l.top)/(l.bottom-l.top))*2+1,this.camera&&this.scene){i.setFromCamera(a,this.camera);const c=i.intersectObjects(e||this.scene.children,s);if(c.length)return{object:c[0].object,intersects:c}}}render(){var r,a,l,c,g,_;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Et.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(C=>{var p;(p=C.update)==null||p.call(C,i,o)}),(a=this.helperController)==null||a.update(),this.cameraController.sync(),(l=this.composerController)!=null&&l.active?this.cameraController.camera2?(this.composerController.resetRenderPassCamera(),this.setViewportFull(),this.composerController.render(),this.pipViewportState&&(this.setViewportPip(),this.composerController.setRenderPassCamera(this.cameraController.camera2),this.composerController.render())):this.composerController.render():(c=this.rendererController)==null||c.render(),(g=this.cssRendererController)==null||g.render(t,e),(_=this.stats)==null||_.update(),this.event.emit("render",{delta:i,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(t){this.controlsController.autoRotateSpeed=t}showPipViewport(t){if(t===!0){const e=this.getSize(),s=240,i=s/e.width,o=s/e.height,r=1-i,a=1-o;t={left:r,top:a,width:i,height:o}}if(this.pipViewportState=t,t){if(this.controlsController.cameraControls2)this.controlsController.cameraControls2.enabled=!0,this.cameraController.camera2.position.copy(this.cameraController.camera.position);else{const e=this.cameraController.addCamera2();this.controlsController.addCameraControls2(e)}this.controlsController.cameraControls2.interactiveArea=new DOMRect(t.left,t.top,t.width,t.height)}else this.controlsController.cameraControls2&&(this.controlsController.cameraControls2.enabled=!1)}setViewportFull(){const t=this.getSize(),e=0,s=0,i=t.width,o=t.height,r=i/o;this.camera.aspect!==r&&(this.camera.aspect=r,this.camera.updateProjectionMatrix()),this.renderer.setViewport(e,s,i,o),this.renderer.setScissor(e,s,i,o),this.renderer.setScissorTest(!0)}setViewportPip(){if(!this.pipViewportState)return;const t=this.pipViewportState,e=this.getSize(),s=e.width*t.left,i=(1-(t.top+t.height))*e.height,o=e.width*t.width,r=e.height*t.height,a=o/r,l=this.cameraController.camera2;l&&l.aspect!==a&&(l.aspect=a,l.updateProjectionMatrix()),this.renderer.setViewport(s,i,o,r),this.renderer.setScissor(s,i,o,r),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,o,r,a,l,c,g,_;this.stop(),Et.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(C=>{var p;(p=C.dispose)==null||p.call(C)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(o=this.sceneController)==null||o.dispose(),(r=this.helperController)==null||r.dispose(),(a=this.composerController)==null||a.dispose(),(l=this.rendererController)==null||l.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(g=this.stats)==null||g.dom.remove(),(_=this.renderer)==null||_.domElement.remove()}};nt.options={isdev:J,stats:J,gui:J,helper:J,control:!0,transformControls:J,resizeObserver:!0,renderer:ae,multisampling:4,scene:_e,camera:de,bloom:!1,bloomParams:Oe,css2DRenderer:!1,css2DRendererParams:Y({},Dt),css3DRenderer:!1,css3DRendererParams:Y({},Dt)};let rt=nt;const ve=B.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=ft;exports.Pencil=rt;exports.cameraControlsAction=ve;exports.default=rt;
31
+ `,defines:{}}),"baseTexture");c.needsSwap=!0,this.bloomComposer=l,this.finalComposer.addPass(c),this.mixPass=c,this.bloomLayer.set(ut)}addBloomGui(t){if(!this.bloomComposer)return;new ft({bloom:{threshold:{min:0,max:1,step:.01,target:()=>this.bloomPass},radius:{min:0,max:1,step:.001,target:()=>this.bloomPass},strength:{min:0,max:10,step:.001,target:()=>this.bloomPass}}}).showGui(t)}toggleBloomSelection(t,e){if(!this.bloomComposer){console.warn("err:pencil.options.bloom");return}const{object3d:s}=t;if(!s)return;let i=e;e===void 0&&(i=!this.bloomSelection.has(s)),i?(this.bloomSelection.add(s),s.layers.enable(ut)):(this.bloomSelection.delete(s),s.layers.disable(ut)),this.bloomSelection.size===0?this.bloomComposerActive=!1:this.bloomComposerActive=!0}enable(){this.active||(this.active=!0)}disable(){this.active&&(this.active=!1)}setSize(t,e){var s;(s=this.bloomComposer)==null||s.setSize(t,e),this.finalComposer.setSize(t,e)}darkenNonBloomed(){const t=this.scene.children.find(e=>e.isTransformControls);t&&(this.transformControlsVisible=t.visible,this.transformControlsVisible&&(t.visible=!1)),this.scene.traverse(e=>{const s=e,i=e;t&&t.getObjectById(s.id)||s.material&&this.bloomLayer.test(s.layers)===!1&&(this.bloomMaterials[s.uuid]=s.material,s.material=i.isSprite?Ee:Ce)})}restoreNonBloomed(){if(this.transformControlsVisible){const t=this.scene.children.find(e=>e.isTransformControls);t&&(t.visible=!0)}this.scene.traverse(t=>{const e=t;this.bloomMaterials[e.uuid]&&(e.material=this.bloomMaterials[e.uuid],delete this.bloomMaterials[e.uuid])})}render(){this.active&&(this.bloomComposerActive&&this.bloomComposer?(this.mixPass.enabled=!0,this.darkenNonBloomed(),this.bloomComposer.render(),this.restoreNonBloomed()):this.mixPass&&(this.mixPass.enabled=!1),this.finalComposer.render())}render2(){this.active}dispose(){var t;this.bloomMaterials={},this.bloomSelection.clear(),this.finalComposer.dispose(),(t=this.bloomComposer)==null||t.dispose()}}const nt=class nt{constructor(t,e){this.raycaster=new v.Raycaster,this.installPlugins=new Map,this.event=new Ut.eventsExports.EventEmitter,this.clock=new v.Clock,this.userData={},this.pipViewportState=!1,this.options=Nt(nt.options,t,{isMergeableObject:ie.isPlainObject}),this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:o,resizeObserver:r}=this.options;if(o){const a=new qt;a.open(!1),this.gui=a}if(this.init(),i){const a=new jt({horizontal:!1});a.init(this.renderer),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}this.options.WebGPUTHREE||this.initComposer(),this.initCSSRenderer(),this.initControls(),r&&this.initResizeObserver(),this.clock.getDelta(),this.clock.getElapsedTime(),e&&(Array.isArray(e)||(e=[e]),e.forEach(a=>{Array.isArray(a)||(a=[a]),this.use(a[0],a[1])}))}getPlugin(t){return this.installPlugins.get(t)}get renderer(){return this.rendererController.renderer}get maxAnisotropy(){return this.options.WebGPUTHREE?0:this.renderer.capabilities.getMaxAnisotropy()}get cameraControls(){return this.controlsController.cameraControls}get cameraPositon(){return this.cameraControls.getPosition(new v.Vector3,!1)}get cameraTarget(){return this.cameraControls.getTarget(new v.Vector3,!1)}get camera(){return this.cameraController.camera}get scene(){return this.sceneController.scene}use(t,...e){this.installPlugins.has(t.pluginName)?console.log("plugin already installed"):typeof t.install=="function"&&(t.install(this,...e),this.installPlugins.set(t.pluginName,t))}init(){const{container:t,isdev:e,WebGPUTHREE:s,helper:i,renderer:o,scene:r,camera:a,control:l}=this.options,{width:c,height:g}=this.getSize(),_=new me({isdev:e,width:c,height:g,cameraParams:a,cameraControls:l===!0});this.gui&&_.setGui(this.gui);const y=_.camera,p=new pe({camera:y,sceneParams:r}),P=p.scene,f=s?new ce({width:c,height:g,scene:P,camera:y,isdev:e,renderer:s.WebGPURenderer,rendererParams:le}):new he({width:c,height:g,scene:P,camera:y,isdev:e,rendererParams:ht(Y({},o),{antialias:!1})});if(i){const w=new ue({scene:P});w.add(P),this.helperController=w}this.sceneController=p,this.rendererController=f,this.cameraController=_,t.appendChild(f.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,multisampling:s}=this.options,i=new Te({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:{multisampling:s}});this.composerController=i,t&&(i.addBloomPass(Y({},e)),this.gui&&i.addBloomGui(this.gui)),i.addOutputPass()}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:o}=this.options;if(e||s){const r=new ye(t);e&&r.addRenderer("css2d",i),s&&r.addRenderer("css3d",o),this.cssRendererController=r}}initControls(){const{control:t,controlParams:e,transformControls:s}=this.options;if(t){const i=new fe({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControl:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new ge({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var o;(o=this.controlsController)==null||o.disable()}),i.event.on("mouseUp",()=>{var o;(o=this.controlsController)==null||o.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=this.getSize(),s=new ResizeObserver(i=>{for(const o of i){const r=o.contentRect;(r.width!==e.width||r.height!==e.height)&&(e.width=r.width,e.height=r.height,this.handeleResize(r.width,r.height),this.render())}});s.observe(t),this.resizeObserver=s}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:o,composerController:r,cssRendererController:a}=this;o==null||o.setSize(t,e),i==null||i.setSize(t,e),r==null||r.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(l=>{var c;(c=l.setSize)==null||c.call(l,t,e)}),s&&this.event.emit("resize",{width:t,height:e})}pick(t,e,s=!0){const{raycaster:i,options:o}=this,{container:r}=o,a=new v.Vector2,l=r.getBoundingClientRect();if(a.x=(t.clientX-l.left)/(l.right-l.left)*2-1,a.y=-((t.clientY-l.top)/(l.bottom-l.top))*2+1,this.camera&&this.scene){i.setFromCamera(a,this.camera);const c=i.intersectObjects(e||this.scene.children,s);if(c.length)return{object:c[0].object,intersects:c}}}render(){var r,a,l,c,g,_;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),o=s.getElapsedTime();Et.update(),(r=this.controlsController)==null||r.update(i),this.installPlugins.forEach(y=>{var p;(p=y.update)==null||p.call(y,i,o)}),(a=this.helperController)==null||a.update(),this.cameraController.sync(),(l=this.composerController)!=null&&l.active?this.cameraController.camera2?(this.composerController.resetRenderPassCamera(),this.setViewportFull(),this.composerController.render(),this.pipViewportState&&(this.setViewportPip(),this.composerController.setRenderPassCamera(this.cameraController.camera2),this.composerController.render())):this.composerController.render():(c=this.rendererController)==null||c.render(),(g=this.cssRendererController)==null||g.render(t,e),(_=this.stats)==null||_.update(),this.event.emit("render",{delta:i,elapsed:o})}start(){this.renderer.setAnimationLoop(this.render.bind(this)),this.event.emit("start")}stop(){this.renderer.setAnimationLoop(null),this.event.emit("stop")}autoRotate(t){this.controlsController.autoRotateSpeed=t}showPipViewport(t){if(t===!0){const e=this.getSize(),s=240,i=s/e.width,o=s/e.height,r=1-i,a=1-o;t={left:r,top:a,width:i,height:o}}if(this.pipViewportState=t,t){if(this.controlsController.cameraControls2)this.controlsController.cameraControls2.enabled=!0,this.cameraController.camera2.position.copy(this.cameraController.camera.position);else{const e=this.cameraController.addCamera2();this.controlsController.addCameraControls2(e)}this.controlsController.cameraControls2.interactiveArea=new DOMRect(t.left,t.top,t.width,t.height)}else this.controlsController.cameraControls2&&(this.controlsController.cameraControls2.enabled=!1)}setViewportFull(){const t=this.getSize(),e=0,s=0,i=t.width,o=t.height,r=i/o;this.camera.aspect!==r&&(this.camera.aspect=r,this.camera.updateProjectionMatrix()),this.renderer.setViewport(e,s,i,o),this.renderer.setScissor(e,s,i,o),this.renderer.setScissorTest(!0)}setViewportPip(){if(!this.pipViewportState)return;const t=this.pipViewportState,e=this.getSize(),s=e.width*t.left,i=(1-(t.top+t.height))*e.height,o=e.width*t.width,r=e.height*t.height,a=o/r,l=this.cameraController.camera2;l&&l.aspect!==a&&(l.aspect=a,l.updateProjectionMatrix()),this.renderer.setViewport(s,i,o,r),this.renderer.setScissor(s,i,o,r),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,o,r,a,l,c,g,_;this.stop(),Et.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(y=>{var p;(p=y.dispose)==null||p.call(y)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(o=this.sceneController)==null||o.dispose(),(r=this.helperController)==null||r.dispose(),(a=this.composerController)==null||a.dispose(),(l=this.rendererController)==null||l.dispose(),this.cssRendererController=void 0,(c=this.gui)==null||c.destroy(),this.installPlugins.clear(),(g=this.stats)==null||g.dom.remove(),(_=this.renderer)==null||_.domElement.remove()}};nt.options={isdev:J,stats:J,gui:J,helper:J,control:!0,transformControls:J,resizeObserver:!0,renderer:ae,multisampling:4,scene:_e,camera:de,bloom:!1,bloomParams:Oe,css2DRenderer:!1,css2DRendererParams:Y({},Dt),css3DRenderer:!1,css3DRendererParams:Y({},Dt)};let rt=nt;const ve=B.ACTION;exports.BaseObject=oe.BaseObject;exports.GUIObject=ft;exports.Pencil=rt;exports.cameraControlsAction=ve;exports.default=rt;
@@ -90,23 +90,23 @@ function et(_, t, e, s, i = 1 / 0, o) {
90
90
  let c = _ - t;
91
91
  const g = t, m = i * s;
92
92
  c = M(c, -m, m), t = _ - c;
93
- const C = (e.value + r * c) * o;
94
- e.value = (e.value - r * C) * l;
95
- let p = t + (c + C) * l;
93
+ const y = (e.value + r * c) * o;
94
+ e.value = (e.value - r * y) * l;
95
+ let p = t + (c + y) * l;
96
96
  return g - _ > 0 == p > g && (p = g, e.value = (p - g) / o), p;
97
97
  }
98
98
  function Ot(_, t, e, s, i = 1 / 0, o, r) {
99
99
  s = Math.max(1e-4, s);
100
100
  const a = 2 / s, l = a * o, c = 1 / (1 + l + 0.48 * l * l + 0.235 * l * l * l);
101
- let g = t.x, m = t.y, C = t.z, p = _.x - g, P = _.y - m, f = _.z - C;
102
- const D = g, h = m, d = C, y = i * s, u = y * y, x = p * p + P * P + f * f;
101
+ let g = t.x, m = t.y, y = t.z, p = _.x - g, w = _.y - m, f = _.z - y;
102
+ const D = g, h = m, d = y, C = i * s, u = C * C, x = p * p + w * w + f * f;
103
103
  if (x > u) {
104
104
  const nt = Math.sqrt(x);
105
- p = p / nt * y, P = P / nt * y, f = f / nt * y;
105
+ p = p / nt * C, w = w / nt * C, f = f / nt * C;
106
106
  }
107
- g = _.x - p, m = _.y - P, C = _.z - f;
108
- const O = (e.x + a * p) * o, U = (e.y + a * P) * o, R = (e.z + a * f) * o;
109
- 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 = m + (P + U) * c, r.z = C + (f + R) * c;
107
+ g = _.x - p, m = _.y - w, y = _.z - f;
108
+ const O = (e.x + a * p) * o, U = (e.y + a * w) * o, R = (e.z + a * f) * o;
109
+ 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 = m + (w + U) * c, r.z = y + (f + R) * c;
110
110
  const $ = D - _.x, tt = h - _.y, Rt = d - _.z, At = r.x - D, zt = r.y - h, Mt = r.z - d;
111
111
  return $ * At + tt * zt + Rt * Mt > 0 && (r.x = D, r.y = h, r.z = d, e.x = (r.x - D) / o, e.y = (r.y - h) / o, e.z = (r.z - d) / o), r;
112
112
  }
@@ -183,7 +183,7 @@ class ee {
183
183
  }
184
184
  }
185
185
  const st = 1 / 8, se = /Mac/.test(navigator.platform);
186
- let E, Tt, it, ct, A, T, w, K, W, F, H, V, vt, xt, z, q, X, Pt, dt, wt, mt, _t, ot;
186
+ let E, Tt, it, ct, A, T, P, K, W, F, H, V, vt, xt, z, q, X, wt, dt, Pt, mt, _t, ot;
187
187
  class Y extends ee {
188
188
  /**
189
189
  * Injects THREE as the dependency. You can then proceed to use CameraControls.
@@ -226,7 +226,7 @@ class Y extends ee {
226
226
  * @category Statics
227
227
  */
228
228
  static install(t) {
229
- E = t.THREE, Tt = Object.freeze(new E.Vector3(0, 0, 0)), it = Object.freeze(new E.Vector3(0, 1, 0)), ct = Object.freeze(new E.Vector3(0, 0, 1)), A = new E.Vector2(), T = new E.Vector3(), w = new E.Vector3(), K = new E.Vector3(), W = new E.Vector3(), F = new E.Vector3(), H = new E.Vector3(), V = new E.Vector3(), vt = new E.Vector3(), xt = new E.Vector3(), z = new E.Spherical(), q = new E.Spherical(), X = new E.Box3(), Pt = new E.Box3(), dt = new E.Sphere(), wt = new E.Quaternion(), mt = new E.Quaternion(), _t = new E.Matrix4(), ot = new E.Raycaster();
229
+ E = t.THREE, Tt = Object.freeze(new E.Vector3(0, 0, 0)), it = Object.freeze(new E.Vector3(0, 1, 0)), ct = Object.freeze(new E.Vector3(0, 0, 1)), A = new E.Vector2(), T = new E.Vector3(), P = new E.Vector3(), K = new E.Vector3(), W = new E.Vector3(), F = new E.Vector3(), H = new E.Vector3(), V = new E.Vector3(), vt = new E.Vector3(), xt = new E.Vector3(), z = new E.Spherical(), q = new E.Spherical(), X = new E.Box3(), wt = new E.Box3(), dt = new E.Sphere(), Pt = new E.Quaternion(), mt = new E.Quaternion(), _t = new E.Matrix4(), ot = new E.Raycaster();
230
230
  }
231
231
  /**
232
232
  * list all ACTIONs
@@ -254,7 +254,7 @@ class Y extends ee {
254
254
  */
255
255
  constructor(t, e) {
256
256
  super(), this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.minDistance = Number.EPSILON, this.maxDistance = 1 / 0, this.infinityDolly = !1, this.minZoom = 0.01, this.maxZoom = 1 / 0, this.smoothTime = 0.25, this.draggingSmoothTime = 0.125, this.maxSpeed = 1 / 0, this.azimuthRotateSpeed = 1, this.polarRotateSpeed = 1, this.dollySpeed = 1, this.dollyDragInverted = !1, this.truckSpeed = 2, this.dollyToCursor = !1, this.dragToOffset = !1, this.verticalDragToForward = !1, this.boundaryFriction = 0, this.restThreshold = 0.01, this.colliderMeshes = [], this.cancel = () => {
257
- }, 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, d, y) => {
257
+ }, 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, d, C) => {
258
258
  let u, x;
259
259
  if (k(this._camera)) {
260
260
  const O = T.copy(this._camera.position).sub(this._target), U = this._camera.getEffectiveFOV() * j, R = O.length() * Math.tan(U * 0.5);
@@ -264,30 +264,30 @@ class Y extends ee {
264
264
  u = h * (O.right - O.left) / O.zoom / this._elementRect.width, x = d * (O.top - O.bottom) / O.zoom / this._elementRect.height;
265
265
  } else
266
266
  return;
267
- this.verticalDragToForward ? (y ? this.setFocalOffset(
267
+ this.verticalDragToForward ? (C ? this.setFocalOffset(
268
268
  this._focalOffsetEnd.x + u,
269
269
  this._focalOffsetEnd.y,
270
270
  this._focalOffsetEnd.z,
271
271
  !0
272
- ) : this.truck(u, 0, !0), this.forward(-x, !0)) : y ? this.setFocalOffset(
272
+ ) : this.truck(u, 0, !0), this.forward(-x, !0)) : C ? this.setFocalOffset(
273
273
  this._focalOffsetEnd.x + u,
274
274
  this._focalOffsetEnd.y + x,
275
275
  this._focalOffsetEnd.z,
276
276
  !0
277
277
  ) : this.truck(u, x, !0);
278
278
  }, this._rotateInternal = (h, d) => {
279
- const y = N * this.azimuthRotateSpeed * h / this._elementRect.height, u = N * this.polarRotateSpeed * d / this._elementRect.height;
280
- this.rotate(y, u, !0);
281
- }, this._dollyInternal = (h, d, y) => {
279
+ const C = N * this.azimuthRotateSpeed * h / this._elementRect.height, u = N * this.polarRotateSpeed * d / this._elementRect.height;
280
+ this.rotate(C, u, !0);
281
+ }, this._dollyInternal = (h, d, C) => {
282
282
  const u = Math.pow(0.95, -h * this.dollySpeed), x = this._sphericalEnd.radius, O = this._sphericalEnd.radius * u, U = M(
283
283
  O,
284
284
  this.minDistance,
285
285
  this.maxDistance
286
286
  ), R = U - O;
287
- 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(d, y)), this._lastDollyDirection = Math.sign(-h);
288
- }, this._zoomInternal = (h, d, y) => {
287
+ 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(d, C)), this._lastDollyDirection = Math.sign(-h);
288
+ }, this._zoomInternal = (h, d, C) => {
289
289
  const u = Math.pow(0.95, h * this.dollySpeed), x = this._zoom, O = this._zoom * u;
290
- this.zoomTo(O, !0), this.dollyToCursor && (this._changedZoom += O - x, this._dollyControlCoord.set(d, y));
290
+ this.zoomTo(O, !0), this.dollyToCursor && (this._changedZoom += O - x, this._dollyControlCoord.set(d, C));
291
291
  }, typeof E == "undefined" && console.error(
292
292
  "camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."
293
293
  ), this._camera = t, this._yAxisUpSpace = new E.Quaternion().setFromUnitVectors(
@@ -327,7 +327,7 @@ class Y extends ee {
327
327
  }
328
328
  if ((h.buttons & L.LEFT) === L.LEFT && this._lockedPointer)
329
329
  return;
330
- const y = {
330
+ const C = {
331
331
  pointerId: h.pointerId,
332
332
  clientX: h.clientX,
333
333
  clientY: h.clientY,
@@ -335,7 +335,7 @@ class Y extends ee {
335
335
  deltaY: 0,
336
336
  mouseButton: d
337
337
  };
338
- this._activePointers.push(y), this._domElement.ownerDocument.removeEventListener(
338
+ this._activePointers.push(C), this._domElement.ownerDocument.removeEventListener(
339
339
  "pointermove",
340
340
  a,
341
341
  { passive: !1 }
@@ -346,12 +346,12 @@ class Y extends ee {
346
346
  "pointermove",
347
347
  a,
348
348
  { passive: !1 }
349
- ), this._domElement.ownerDocument.addEventListener("pointerup", l), this._isDragging = !0, C(h);
349
+ ), this._domElement.ownerDocument.addEventListener("pointerup", l), this._isDragging = !0, y(h);
350
350
  }, a = (h) => {
351
351
  h.cancelable && h.preventDefault();
352
- const d = h.pointerId, y = this._lockedPointer || this._findPointerById(d);
353
- if (y) {
354
- if (y.clientX = h.clientX, y.clientY = h.clientY, y.deltaX = h.movementX, y.deltaY = h.movementY, this._state = 0, h.pointerType === "touch")
352
+ const d = h.pointerId, C = this._lockedPointer || this._findPointerById(d);
353
+ if (C) {
354
+ if (C.clientX = h.clientX, C.clientY = h.clientY, C.deltaX = h.movementX, C.deltaY = h.movementY, this._state = 0, h.pointerType === "touch")
355
355
  switch (this._activePointers.length) {
356
356
  case 1:
357
357
  this._state = this.touches.one;
@@ -387,7 +387,7 @@ class Y extends ee {
387
387
  }
388
388
  else
389
389
  this._state = n.NONE;
390
- P();
390
+ w();
391
391
  }
392
392
  };
393
393
  let c = -1;
@@ -402,7 +402,7 @@ class Y extends ee {
402
402
  const O = performance.now();
403
403
  c - O < 1e3 && this._getClientRect(this._elementRect), c = O;
404
404
  }
405
- const d = se ? -1 : -3, y = h.deltaMode === 1 ? h.deltaY / d : h.deltaY / (d * 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;
405
+ const d = se ? -1 : -3, C = h.deltaMode === 1 ? h.deltaY / d : h.deltaY / (d * 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;
406
406
  switch (this.mouseButtons.wheel) {
407
407
  case n.ROTATE: {
408
408
  this._rotateInternal(h.deltaX, h.deltaY), this._isUserControllingRotate = !0;
@@ -417,11 +417,11 @@ class Y extends ee {
417
417
  break;
418
418
  }
419
419
  case n.DOLLY: {
420
- this._dollyInternal(-y, u, x), this._isUserControllingDolly = !0;
420
+ this._dollyInternal(-C, u, x), this._isUserControllingDolly = !0;
421
421
  break;
422
422
  }
423
423
  case n.ZOOM: {
424
- this._zoomInternal(-y, u, x), this._isUserControllingZoom = !0;
424
+ this._zoomInternal(-C, u, x), this._isUserControllingZoom = !0;
425
425
  break;
426
426
  }
427
427
  }
@@ -429,8 +429,8 @@ class Y extends ee {
429
429
  }, m = (h) => {
430
430
  if (!(!this._domElement || !this._enabled)) {
431
431
  if (this.mouseButtons.right === Y.ACTION.NONE) {
432
- const d = h instanceof PointerEvent ? h.pointerId : 0, y = this._findPointerById(d);
433
- y && this._disposePointer(y), this._domElement.ownerDocument.removeEventListener(
432
+ const d = h instanceof PointerEvent ? h.pointerId : 0, C = this._findPointerById(d);
433
+ C && this._disposePointer(C), this._domElement.ownerDocument.removeEventListener(
434
434
  "pointermove",
435
435
  a,
436
436
  { passive: !1 }
@@ -442,10 +442,10 @@ class Y extends ee {
442
442
  }
443
443
  h.preventDefault();
444
444
  }
445
- }, C = (h) => {
445
+ }, y = (h) => {
446
446
  if (!this._enabled) return;
447
447
  if (ht(this._activePointers, A), this._getClientRect(this._elementRect), s.copy(A), i.copy(A), this._activePointers.length >= 2) {
448
- const y = A.x - this._activePointers[1].clientX, u = A.y - this._activePointers[1].clientY, x = Math.sqrt(y * y + u * u);
448
+ const C = A.x - this._activePointers[1].clientX, u = A.y - this._activePointers[1].clientY, x = Math.sqrt(C * C + u * u);
449
449
  o.set(0, x);
450
450
  const O = (this._activePointers[0].clientX + this._activePointers[1].clientX) * 0.5, U = (this._activePointers[0].clientY + this._activePointers[1].clientY) * 0.5;
451
451
  i.set(O, U);
@@ -470,8 +470,8 @@ class Y extends ee {
470
470
  }, p = () => {
471
471
  if (!this._enabled || !this._dragNeedsUpdate) return;
472
472
  this._dragNeedsUpdate = !1, ht(this._activePointers, A);
473
- const d = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, y = d ? -d.deltaX : i.x - A.x, u = d ? -d.deltaY : i.y - A.y;
474
- 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(y, u), this._isUserControllingRotate = !0), (this._state & n.DOLLY) === n.DOLLY || (this._state & n.ZOOM) === n.ZOOM) {
473
+ const d = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, C = d ? -d.deltaX : i.x - A.x, u = d ? -d.deltaY : i.y - A.y;
474
+ 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) {
475
475
  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;
476
476
  (this._state & n.DOLLY) === n.DOLLY ? (this._dollyInternal(
477
477
  U * u * st,
@@ -489,8 +489,8 @@ class Y extends ee {
489
489
  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;
490
490
  (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);
491
491
  }
492
- ((this._state & n.TRUCK) === n.TRUCK || (this._state & n.TOUCH_TRUCK) === n.TOUCH_TRUCK || (this._state & n.TOUCH_DOLLY_TRUCK) === n.TOUCH_DOLLY_TRUCK || (this._state & n.TOUCH_ZOOM_TRUCK) === n.TOUCH_ZOOM_TRUCK) && (this._truckInternal(y, 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(y, u, !0), this._isUserControllingOffset = !0), this.dispatchEvent({ type: "control" });
493
- }, P = () => {
492
+ ((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" });
493
+ }, w = () => {
494
494
  ht(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(
495
495
  "pointermove",
496
496
  a,
@@ -525,13 +525,13 @@ class Y extends ee {
525
525
  "pointermove",
526
526
  a,
527
527
  { passive: !1 }
528
- ), this._domElement.ownerDocument.addEventListener("pointerup", l), C());
528
+ ), this._domElement.ownerDocument.addEventListener("pointerup", l), y());
529
529
  }, this.unlockPointer = () => {
530
- var h, d, y;
530
+ var h, d, C;
531
531
  this._lockedPointer !== null && (this._disposePointer(this._lockedPointer), this._lockedPointer = null), (h = this._domElement) === null || h === void 0 || h.ownerDocument.exitPointerLock(), (d = this._domElement) === null || d === void 0 || d.ownerDocument.removeEventListener(
532
532
  "pointerlockchange",
533
533
  f
534
- ), (y = this._domElement) === null || y === void 0 || y.ownerDocument.removeEventListener(
534
+ ), (C = this._domElement) === null || C === void 0 || C.ownerDocument.removeEventListener(
535
535
  "pointerlockerror",
536
536
  D
537
537
  ), this.cancel();
@@ -563,7 +563,7 @@ class Y extends ee {
563
563
  D
564
564
  ));
565
565
  }, this.cancel = () => {
566
- this._state !== n.NONE && (this._state = n.NONE, this._activePointers.length = 0, P());
566
+ this._state !== n.NONE && (this._state = n.NONE, this._activePointers.length = 0, w());
567
567
  }, e && this.connect(e), this.update(0);
568
568
  }
569
569
  /**
@@ -907,7 +907,7 @@ class Y extends ee {
907
907
  */
908
908
  truck(t, e, s = !1) {
909
909
  this._camera.updateMatrix(), F.setFromMatrixColumn(this._camera.matrix, 0), H.setFromMatrixColumn(this._camera.matrix, 1), F.multiplyScalar(t), H.multiplyScalar(-e);
910
- const i = T.copy(F).add(H), o = w.copy(this._targetEnd).add(i);
910
+ const i = T.copy(F).add(H), o = P.copy(this._targetEnd).add(i);
911
911
  return this.moveTo(o.x, o.y, o.z, s);
912
912
  }
913
913
  /**
@@ -918,7 +918,7 @@ class Y extends ee {
918
918
  */
919
919
  forward(t, e = !1) {
920
920
  T.setFromMatrixColumn(this._camera.matrix, 0), T.crossVectors(this._camera.up, T), T.multiplyScalar(t);
921
- const s = w.copy(this._targetEnd).add(T);
921
+ const s = P.copy(this._targetEnd).add(T);
922
922
  return this.moveTo(s.x, s.y, s.z, e);
923
923
  }
924
924
  /**
@@ -994,11 +994,11 @@ class Y extends ee {
994
994
  ), Promise.resolve());
995
995
  const g = Et(this._sphericalEnd.theta, Ct), m = Et(this._sphericalEnd.phi, Ct);
996
996
  l.push(this.rotateTo(g, m, e));
997
- const C = T.setFromSpherical(this._sphericalEnd).normalize(), p = wt.setFromUnitVectors(C, ct), P = S(Math.abs(C.y), 1);
998
- P && p.multiply(mt.setFromAxisAngle(it, g)), p.multiply(this._yAxisUpSpaceInverse);
999
- const f = Pt.makeEmpty();
1000
- w.copy(c.min).applyQuaternion(p), f.expandByPoint(w), w.copy(c.min).setX(c.max.x).applyQuaternion(p), f.expandByPoint(w), w.copy(c.min).setY(c.max.y).applyQuaternion(p), f.expandByPoint(w), w.copy(c.max).setZ(c.min.z).applyQuaternion(p), f.expandByPoint(w), w.copy(c.min).setZ(c.max.z).applyQuaternion(p), f.expandByPoint(w), w.copy(c.max).setY(c.min.y).applyQuaternion(p), f.expandByPoint(w), w.copy(c.max).setX(c.min.x).applyQuaternion(p), f.expandByPoint(w), w.copy(c.max).applyQuaternion(p), f.expandByPoint(w), f.min.x -= i, f.min.y -= r, f.max.x += o, f.max.y += a, p.setFromUnitVectors(ct, C), P && p.premultiply(mt.invert()), p.premultiply(this._yAxisUpSpace);
1001
- const D = f.getSize(T), h = f.getCenter(w).applyQuaternion(p);
997
+ const y = T.setFromSpherical(this._sphericalEnd).normalize(), p = Pt.setFromUnitVectors(y, ct), w = S(Math.abs(y.y), 1);
998
+ w && p.multiply(mt.setFromAxisAngle(it, g)), p.multiply(this._yAxisUpSpaceInverse);
999
+ const f = wt.makeEmpty();
1000
+ P.copy(c.min).applyQuaternion(p), f.expandByPoint(P), P.copy(c.min).setX(c.max.x).applyQuaternion(p), f.expandByPoint(P), P.copy(c.min).setY(c.max.y).applyQuaternion(p), f.expandByPoint(P), P.copy(c.max).setZ(c.min.z).applyQuaternion(p), f.expandByPoint(P), P.copy(c.min).setZ(c.max.z).applyQuaternion(p), f.expandByPoint(P), P.copy(c.max).setY(c.min.y).applyQuaternion(p), f.expandByPoint(P), P.copy(c.max).setX(c.min.x).applyQuaternion(p), f.expandByPoint(P), P.copy(c.max).applyQuaternion(p), f.expandByPoint(P), f.min.x -= i, f.min.y -= r, f.max.x += o, f.max.y += a, p.setFromUnitVectors(ct, y), w && p.premultiply(mt.invert()), p.premultiply(this._yAxisUpSpace);
1001
+ const D = f.getSize(T), h = f.getCenter(P).applyQuaternion(p);
1002
1002
  if (k(this._camera)) {
1003
1003
  const d = this.getDistanceToFitBox(
1004
1004
  D.x,
@@ -1010,7 +1010,7 @@ class Y extends ee {
1010
1010
  this.moveTo(h.x, h.y, h.z, e)
1011
1011
  ), l.push(this.dollyTo(d, e)), l.push(this.setFocalOffset(0, 0, 0, e));
1012
1012
  } else if (I(this._camera)) {
1013
- const d = this._camera, y = d.right - d.left, u = d.top - d.bottom, x = s ? Math.max(y / D.x, u / D.y) : Math.min(y / D.x, u / D.y);
1013
+ const d = this._camera, C = d.right - d.left, u = d.top - d.bottom, x = s ? Math.max(C / D.x, u / D.y) : Math.min(C / D.x, u / D.y);
1014
1014
  l.push(
1015
1015
  this.moveTo(h.x, h.y, h.z, e)
1016
1016
  ), l.push(this.zoomTo(x, e)), l.push(this.setFocalOffset(0, 0, 0, e));
@@ -1054,7 +1054,7 @@ class Y extends ee {
1054
1054
  */
1055
1055
  setLookAt(t, e, s, i, o, r, a = !1) {
1056
1056
  this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._lastDollyDirection = Z.NONE, this._changedDolly = 0;
1057
- const l = w.set(i, o, r), c = T.set(t, e, s);
1057
+ const l = P.set(i, o, r), c = T.set(t, e, s);
1058
1058
  this._targetEnd.copy(l), this._sphericalEnd.setFromVector3(
1059
1059
  c.sub(l).applyQuaternion(this._yAxisUpSpace)
1060
1060
  ), this.normalizeRotations(), this._needsUpdate = !0, a || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
@@ -1091,23 +1091,23 @@ class Y extends ee {
1091
1091
  * @param enableTransition
1092
1092
  * @category Methods
1093
1093
  */
1094
- lerpLookAt(t, e, s, i, o, r, a, l, c, g, m, C, p, P = !1) {
1094
+ lerpLookAt(t, e, s, i, o, r, a, l, c, g, m, y, p, w = !1) {
1095
1095
  this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._lastDollyDirection = Z.NONE, this._changedDolly = 0;
1096
- const f = T.set(i, o, r), D = w.set(t, e, s);
1096
+ const f = T.set(i, o, r), D = P.set(t, e, s);
1097
1097
  z.setFromVector3(
1098
1098
  D.sub(f).applyQuaternion(this._yAxisUpSpace)
1099
1099
  );
1100
- const h = K.set(g, m, C), d = w.set(a, l, c);
1100
+ const h = K.set(g, m, y), d = P.set(a, l, c);
1101
1101
  q.setFromVector3(
1102
1102
  d.sub(h).applyQuaternion(this._yAxisUpSpace)
1103
1103
  ), this._targetEnd.copy(f.lerp(h, p));
1104
- const y = q.theta - z.theta, u = q.phi - z.phi, x = q.radius - z.radius;
1104
+ const C = q.theta - z.theta, u = q.phi - z.phi, x = q.radius - z.radius;
1105
1105
  this._sphericalEnd.set(
1106
1106
  z.radius + x * p,
1107
1107
  z.phi + u * p,
1108
- z.theta + y * p
1109
- ), this.normalizeRotations(), this._needsUpdate = !0, P || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
1110
- 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(
1108
+ z.theta + C * p
1109
+ ), this.normalizeRotations(), this._needsUpdate = !0, w || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
1110
+ const O = !w || 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(
1111
1111
  this._spherical.theta,
1112
1112
  this._sphericalEnd.theta,
1113
1113
  this.restThreshold
@@ -1356,7 +1356,7 @@ class Y extends ee {
1356
1356
  * @category Methods
1357
1357
  */
1358
1358
  applyCameraUp() {
1359
- const t = T.subVectors(this._target, this._camera.position).normalize(), e = w.crossVectors(t, this._camera.up);
1359
+ const t = T.subVectors(this._target, this._camera.position).normalize(), e = P.crossVectors(t, this._camera.up);
1360
1360
  this._camera.up.crossVectors(e, t).normalize(), this._camera.updateMatrixWorld();
1361
1361
  const s = this.getPosition(T);
1362
1362
  this.updateCameraUp(), this.setPosition(s.x, s.y, s.z);
@@ -1455,33 +1455,33 @@ class Y extends ee {
1455
1455
  }
1456
1456
  if (this.dollyToCursor) {
1457
1457
  if (k(this._camera) && this._changedDolly !== 0) {
1458
- const m = this._spherical.radius - this._lastDistance, C = this._camera, p = this._getCameraDirection(W), P = T.copy(p).cross(C.up).normalize();
1459
- P.lengthSq() === 0 && (P.x = 1);
1460
- const f = w.crossVectors(P, p), D = this._sphericalEnd.radius * Math.tan(C.getEffectiveFOV() * j * 0.5), d = (this._sphericalEnd.radius - m - this._sphericalEnd.radius) / this._sphericalEnd.radius, y = K.copy(this._targetEnd).add(
1461
- P.multiplyScalar(
1462
- this._dollyControlCoord.x * D * C.aspect
1458
+ const m = this._spherical.radius - this._lastDistance, y = this._camera, p = this._getCameraDirection(W), w = T.copy(p).cross(y.up).normalize();
1459
+ w.lengthSq() === 0 && (w.x = 1);
1460
+ const f = P.crossVectors(w, p), D = this._sphericalEnd.radius * Math.tan(y.getEffectiveFOV() * j * 0.5), d = (this._sphericalEnd.radius - m - this._sphericalEnd.radius) / this._sphericalEnd.radius, C = K.copy(this._targetEnd).add(
1461
+ w.multiplyScalar(
1462
+ this._dollyControlCoord.x * D * y.aspect
1463
1463
  )
1464
1464
  ).add(
1465
1465
  f.multiplyScalar(this._dollyControlCoord.y * D)
1466
- ), u = T.copy(this._targetEnd).lerp(y, d), x = this._lastDollyDirection === Z.IN && this._spherical.radius <= this.minDistance, O = this._lastDollyDirection === Z.OUT && this.maxDistance <= this._spherical.radius;
1466
+ ), u = T.copy(this._targetEnd).lerp(C, d), x = this._lastDollyDirection === Z.IN && this._spherical.radius <= this.minDistance, O = this._lastDollyDirection === Z.OUT && this.maxDistance <= this._spherical.radius;
1467
1467
  if (this.infinityDolly && (x || O)) {
1468
1468
  this._sphericalEnd.radius -= m, this._spherical.radius -= m;
1469
- const R = w.copy(p).multiplyScalar(-m);
1469
+ const R = P.copy(p).multiplyScalar(-m);
1470
1470
  u.add(R);
1471
1471
  }
1472
1472
  this._boundary.clampPoint(u, u);
1473
- const U = w.subVectors(u, this._targetEnd);
1473
+ const U = P.subVectors(u, this._targetEnd);
1474
1474
  this._targetEnd.copy(u), this._target.add(U), this._changedDolly -= m, b(this._changedDolly) && (this._changedDolly = 0);
1475
1475
  } else if (I(this._camera) && this._changedZoom !== 0) {
1476
- const m = this._zoom - this._lastZoom, C = this._camera, p = T.set(
1476
+ const m = this._zoom - this._lastZoom, y = this._camera, p = T.set(
1477
1477
  this._dollyControlCoord.x,
1478
1478
  this._dollyControlCoord.y,
1479
- (C.near + C.far) / (C.near - C.far)
1480
- ).unproject(C), P = w.set(0, 0, -1).applyQuaternion(C.quaternion), f = K.copy(p).add(P.multiplyScalar(-p.dot(C.up))), h = -(this._zoom - m - this._zoom) / this._zoom, d = this._getCameraDirection(W), y = this._targetEnd.dot(d), u = T.copy(this._targetEnd).lerp(f, h), x = u.dot(d), O = d.multiplyScalar(
1481
- x - y
1479
+ (y.near + y.far) / (y.near - y.far)
1480
+ ).unproject(y), w = P.set(0, 0, -1).applyQuaternion(y.quaternion), f = K.copy(p).add(w.multiplyScalar(-p.dot(y.up))), h = -(this._zoom - m - this._zoom) / this._zoom, d = this._getCameraDirection(W), C = this._targetEnd.dot(d), u = T.copy(this._targetEnd).lerp(f, h), x = u.dot(d), O = d.multiplyScalar(
1481
+ x - C
1482
1482
  );
1483
1483
  u.sub(O), this._boundary.clampPoint(u, u);
1484
- const U = w.subVectors(u, this._targetEnd);
1484
+ const U = P.subVectors(u, this._targetEnd);
1485
1485
  this._targetEnd.copy(u), this._target.add(U), this._changedZoom -= m, b(this._changedZoom) && (this._changedZoom = 0);
1486
1486
  }
1487
1487
  }
@@ -1592,7 +1592,7 @@ class Y extends ee {
1592
1592
  const i = e.lengthSq();
1593
1593
  if (i === 0)
1594
1594
  return t;
1595
- const o = w.copy(e).add(t), a = this._boundary.clampPoint(o, K).sub(o), l = a.lengthSq();
1595
+ const o = P.copy(e).add(t), a = this._boundary.clampPoint(o, K).sub(o), l = a.lengthSq();
1596
1596
  if (l === 0)
1597
1597
  return t.add(e);
1598
1598
  if (l === i)
@@ -1601,7 +1601,7 @@ class Y extends ee {
1601
1601
  return t.add(e).add(a);
1602
1602
  {
1603
1603
  const c = 1 + s * l / e.dot(a);
1604
- return t.add(w.copy(e).multiplyScalar(c)).add(a.multiplyScalar(1 - s));
1604
+ return t.add(P.copy(e).multiplyScalar(c)).add(a.multiplyScalar(1 - s));
1605
1605
  }
1606
1606
  }
1607
1607
  _updateNearPlaneCorners() {
@@ -1621,7 +1621,7 @@ class Y extends ee {
1621
1621
  const s = this._getTargetDirection(W);
1622
1622
  _t.lookAt(Tt, s, this._camera.up);
1623
1623
  for (let i = 0; i < 4; i++) {
1624
- const o = w.copy(this._nearPlaneCorners[i]);
1624
+ const o = P.copy(this._nearPlaneCorners[i]);
1625
1625
  o.applyMatrix4(_t);
1626
1626
  const r = K.addVectors(this._target, o);
1627
1627
  ot.set(r, s), ot.far = this._spherical.radius + 1;
@@ -1702,7 +1702,7 @@ class Y extends ee {
1702
1702
  const a = r, l = a.geometry.clone();
1703
1703
  l.applyMatrix4(a.matrixWorld);
1704
1704
  const g = l.attributes.position;
1705
- for (let m = 0, C = g.count; m < C; m++)
1705
+ for (let m = 0, y = g.count; m < y; m++)
1706
1706
  T.fromBufferAttribute(g, m), o = Math.max(o, i.distanceToSquared(T));
1707
1707
  }), s.radius = Math.sqrt(o), s;
1708
1708
  }
@@ -1731,9 +1731,9 @@ class oe {
1731
1731
  antialias: c,
1732
1732
  powerPreference: g,
1733
1733
  toneMappingExposure: m,
1734
- outputColorSpace: C,
1734
+ outputColorSpace: y,
1735
1735
  logarithmicDepthBuffer: p,
1736
- preserveDrawingBuffer: P,
1736
+ preserveDrawingBuffer: w,
1737
1737
  stencil: f,
1738
1738
  depth: D,
1739
1739
  physicallyCorrectLights: h
@@ -1744,11 +1744,11 @@ class oe {
1744
1744
  antialias: c,
1745
1745
  powerPreference: g,
1746
1746
  logarithmicDepthBuffer: p,
1747
- preserveDrawingBuffer: P,
1747
+ preserveDrawingBuffer: w,
1748
1748
  stencil: f,
1749
1749
  depth: D
1750
1750
  });
1751
- d.setSize(e, s), d.setPixelRatio(l), d.toneMappingExposure = m, d.outputColorSpace = C, +v.REVISION < 155 && (d.useLegacyLights = h), this.renderer = d;
1751
+ d.setSize(e, s), d.setPixelRatio(l), d.toneMappingExposure = m, d.outputColorSpace = y, +v.REVISION < 155 && (d.useLegacyLights = h), this.renderer = d;
1752
1752
  }
1753
1753
  setSize(t, e) {
1754
1754
  this.renderer.setSize(t, e);
@@ -1801,12 +1801,12 @@ class Lt {
1801
1801
  name: c,
1802
1802
  paramMap: g,
1803
1803
  items: m,
1804
- value: C,
1804
+ value: y,
1805
1805
  target: p
1806
- } = i[o], P = o.toLowerCase().indexOf("color") > -1;
1806
+ } = i[o], w = o.toLowerCase().indexOf("color") > -1;
1807
1807
  let f;
1808
- const D = typeof C == "undefined" && p, h = D ? p() : i[o], d = D ? o : "value";
1809
- m ? f = s.add(h, d, m) : P ? f = s.addColor(h, d) : f = s.add(h, d), 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(() => {
1808
+ const D = typeof y == "undefined" && p, h = D ? p() : i[o], d = D ? o : "value";
1809
+ m ? f = s.add(h, d, m) : w ? f = s.addColor(h, d) : f = s.add(h, d), 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(() => {
1810
1810
  this.setTargetValue(e, o, h[d], g);
1811
1811
  }), D && f.listen();
1812
1812
  });
@@ -1825,7 +1825,7 @@ class Lt {
1825
1825
  if (l)
1826
1826
  try {
1827
1827
  m[i || e].set(s);
1828
- } catch (C) {
1828
+ } catch (y) {
1829
1829
  e !== "color" && !i && console.warn(`${e} is not a color,set paramMap`);
1830
1830
  }
1831
1831
  else
@@ -2139,11 +2139,19 @@ const pt = 1, J = !1, ue = new v.MeshBasicMaterial({ color: "black" }), fe = new
2139
2139
  class ye {
2140
2140
  constructor(t) {
2141
2141
  this.bloomComposerActive = !1, this.active = !0, this.bloomSelection = /* @__PURE__ */ new Set(), this.bloomLayer = new v.Layers(), this.bloomMaterials = {}, this.transformControlsVisible = !1, this.options = t;
2142
- 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, {
2143
- samples: Math.min(r, a),
2144
- type: v.HalfFloatType
2145
- }), g = new Wt(s, i), m = new yt(e, c);
2142
+ const { renderer: e, scene: s, camera: i, composerParams: o } = t, { multisampling: r } = o, { maxSamples: a } = e.capabilities, l = e.getDrawingBufferSize(
2143
+ new v.Vector2()
2144
+ ), c = new v.WebGLRenderTarget(
2145
+ l.width,
2146
+ l.height,
2147
+ {
2148
+ samples: Math.min(r, a),
2149
+ type: v.HalfFloatType
2150
+ }
2151
+ ), g = new Wt(s, i), m = new yt(e, c);
2146
2152
  m.addPass(g), this.renderer = e, this.scene = s, this.camera = i, this.finalComposer = m, this.renderPass = g;
2153
+ const y = e.getSize(new v.Vector2());
2154
+ this.setSize(y.width, y.height);
2147
2155
  }
2148
2156
  setRenderPassCamera(t) {
2149
2157
  this.renderPass.camera = t;
@@ -2192,7 +2200,13 @@ class ye {
2192
2200
  gl_FragColor = vec4(base_color.rgb + bloom_color.rgb, max(base_color.a, lum));
2193
2201
  }else if( bloomAlphaType == 0.5){
2194
2202
  gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
2195
- gl_FragColor.a = base_color.a;
2203
+ if(base_color.a == 0.0){
2204
+ if( bloom_color.r == 0.0 && bloom_color.g == 0.0 && bloom_color.b == 0.0){
2205
+ gl_FragColor.a = 0.0;
2206
+ }else{
2207
+ gl_FragColor.a = 0.002;
2208
+ }
2209
+ }
2196
2210
  }else{
2197
2211
  gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
2198
2212
  }
@@ -2350,22 +2364,22 @@ const rt = class rt {
2350
2364
  cameraControls: l === !0
2351
2365
  });
2352
2366
  this.gui && m.setGui(this.gui);
2353
- const C = m.camera, p = new ce({
2354
- camera: C,
2367
+ const y = m.camera, p = new ce({
2368
+ camera: y,
2355
2369
  sceneParams: r
2356
- }), P = p.scene, f = s ? new ne({
2370
+ }), w = p.scene, f = s ? new ne({
2357
2371
  width: c,
2358
2372
  height: g,
2359
- scene: P,
2360
- camera: C,
2373
+ scene: w,
2374
+ camera: y,
2361
2375
  isdev: e,
2362
2376
  renderer: s.WebGPURenderer,
2363
2377
  rendererParams: re
2364
2378
  }) : new oe({
2365
2379
  width: c,
2366
2380
  height: g,
2367
- scene: P,
2368
- camera: C,
2381
+ scene: w,
2382
+ camera: y,
2369
2383
  isdev: e,
2370
2384
  rendererParams: at(B({}, o), {
2371
2385
  antialias: !1
@@ -2373,9 +2387,9 @@ const rt = class rt {
2373
2387
  });
2374
2388
  if (i) {
2375
2389
  const D = new de({
2376
- scene: P
2390
+ scene: w
2377
2391
  });
2378
- D.add(P), this.helperController = D;
2392
+ D.add(w), this.helperController = D;
2379
2393
  }
2380
2394
  this.sceneController = p, this.rendererController = f, this.cameraController = m, t.appendChild(f.renderer.domElement);
2381
2395
  }
@@ -2482,9 +2496,9 @@ const rt = class rt {
2482
2496
  render() {
2483
2497
  var r, a, l, c, g, m;
2484
2498
  const { scene: t, camera: e, clock: s } = this, i = s.getDelta(), o = s.getElapsedTime();
2485
- gt.update(), (r = this.controlsController) == null || r.update(i), this.installPlugins.forEach((C) => {
2499
+ gt.update(), (r = this.controlsController) == null || r.update(i), this.installPlugins.forEach((y) => {
2486
2500
  var p;
2487
- (p = C.update) == null || p.call(C, i, o);
2501
+ (p = y.update) == null || p.call(y, i, o);
2488
2502
  }), (a = this.helperController) == null || a.update(), this.cameraController.sync(), (l = this.composerController) != null && l.active ? this.cameraController.camera2 ? (this.composerController.resetRenderPassCamera(), this.setViewportFull(), this.composerController.render(), this.pipViewportState && (this.setViewportPip(), this.composerController.setRenderPassCamera(
2489
2503
  this.cameraController.camera2
2490
2504
  ), this.composerController.render())) : this.composerController.render() : (c = this.rendererController) == null || c.render(), (g = this.cssRendererController) == null || g.render(t, e), (m = this.stats) == null || m.update(), this.event.emit("render", { delta: i, elapsed: o });
@@ -2537,9 +2551,9 @@ const rt = class rt {
2537
2551
  }
2538
2552
  dispose() {
2539
2553
  var t, e, s, i, o, r, a, l, c, g, m;
2540
- this.stop(), gt.removeAll(), this.event.removeAllListeners(), (t = this.resizeObserver) == null || t.unobserve(this.options.container), this.installPlugins.forEach((C) => {
2554
+ this.stop(), gt.removeAll(), this.event.removeAllListeners(), (t = this.resizeObserver) == null || t.unobserve(this.options.container), this.installPlugins.forEach((y) => {
2541
2555
  var p;
2542
- (p = C.dispose) == null || p.call(C);
2556
+ (p = y.dispose) == null || p.call(y);
2543
2557
  }), (e = this.controlsController) == null || e.dispose(), (s = this.transformController) == null || s.dispose(), (i = this.cssRendererController) == null || i.dispose(), (o = this.sceneController) == null || o.dispose(), (r = this.helperController) == null || r.dispose(), (a = this.composerController) == null || a.dispose(), (l = this.rendererController) == null || l.dispose(), this.cssRendererController = void 0, (c = this.gui) == null || c.destroy(), this.installPlugins.clear(), (g = this.stats) == null || g.dom.remove(), (m = this.renderer) == null || m.domElement.remove();
2544
2558
  }
2545
2559
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.10.16",
3
+ "version": "0.10.18",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",