gl-draw 0.11.26 → 0.11.28
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/core/Pencil.d.ts +2 -1
- package/dist/index.js +3 -3
- package/dist/index.module.js +36 -24
- package/package.json +1 -1
package/dist/core/Pencil.d.ts
CHANGED
|
@@ -158,8 +158,9 @@ export default class Pencil {
|
|
|
158
158
|
start(): void;
|
|
159
159
|
stop(): void;
|
|
160
160
|
autoRotate(speed: number): void;
|
|
161
|
-
|
|
161
|
+
setViewPadding(top?: number, right?: number, bottom?: number, left?: number): void;
|
|
162
162
|
private pipViewportState;
|
|
163
|
+
showPipViewport(state: typeof Pencil.prototype.pipViewportState): void;
|
|
163
164
|
private setViewportFull;
|
|
164
165
|
private setViewportPip;
|
|
165
166
|
dispose(): void;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Wt=Object.defineProperty,Gt=Object.defineProperties;var Xt=Object.getOwnPropertyDescriptors;var Ot=Object.getOwnPropertySymbols;var Kt=Object.prototype.hasOwnProperty,jt=Object.prototype.propertyIsEnumerable;var Et=(u,t,e)=>t in u?Wt(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,B=(u,t)=>{for(var e in t||(t={}))Kt.call(t,e)&&Et(u,e,t[e]);if(Ot)for(var e of Ot(t))jt.call(t,e)&&Et(u,e,t[e]);return u},mt=(u,t)=>Gt(u,Xt(t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const z=require("three"),Qt=require("@tweenjs/tween.js"),kt=require("./events.js"),$t=require("deepmerge"),Jt=require("stats-gl"),te=require("lil-gui"),ee=require("./colorCorrection.js"),se=require("./disposeMesh.js");require("idb-keyval");require("esus-lite");require("d3-geo");require("d3-geo-projection");const ie=require("three/examples/jsm/helpers/RectAreaLightHelper"),re=require("three/examples/jsm/helpers/ViewHelper"),oe=require("three/examples/jsm/controls/TransformControls"),Tt=require("three/examples/jsm/postprocessing/EffectComposer"),ne=require("three/examples/jsm/postprocessing/RenderPass"),ae=require("three/examples/jsm/postprocessing/SSAOPass"),he=require("three/examples/jsm/postprocessing/Pass"),le=require("three/examples/jsm/postprocessing/OutputPass"),ce=require("three/examples/jsm/postprocessing/ShaderPass"),de=require("three/examples/jsm/postprocessing/UnrealBloomPass"),me=require("./isPlainObject.js"),pe=require("./BaseObject.js");function Vt(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>u[e]})}}return t.default=u,Object.freeze(t)}const w=Vt(z),vt=Vt(Qt),A={LEFT:1,RIGHT:2,MIDDLE:4},h=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}),q={NONE:0,IN:1,OUT:-1};function N(u){return u.isPerspectiveCamera}function V(u){return u.isOrthographicCamera}const W=Math.PI*2,xt=Math.PI/2,Bt=1e-5,Q=Math.PI/180;function F(u,t,e){return Math.max(t,Math.min(e,u))}function U(u,t=Bt){return Math.abs(u)<t}function D(u,t,e=Bt){return U(u-t,e)}function wt(u,t){return Math.round(u/t)*t}function $(u){return isFinite(u)?u:u<0?-Number.MAX_VALUE:Number.MAX_VALUE}function J(u){return Math.abs(u)<Number.MAX_VALUE?u:u*(1/0)}function rt(u,t,e,s,i=1/0,r){s=Math.max(1e-4,s);const n=2/s,a=n*r,l=1/(1+a+.48*a*a+.235*a*a*a);let d=u-t;const y=t,c=i*s;d=F(d,-c,c),t=u-d;const E=(e.value+n*d)*r;e.value=(e.value-n*E)*l;let C=t+(d+E)*l;return y-u>0==C>y&&(C=y,e.value=(C-y)/r),C}function Pt(u,t,e,s,i=1/0,r,n){s=Math.max(1e-4,s);const a=2/s,l=a*r,d=1/(1+l+.48*l*l+.235*l*l*l);let y=t.x,c=t.y,E=t.z,C=u.x-y,f=u.y-c,p=u.z-E;const _=y,o=c,m=E,O=i*s,g=O*O,x=C*C+f*f+p*p;if(x>g){const dt=Math.sqrt(x);C=C/dt*O,f=f/dt*O,p=p/dt*O}y=u.x-C,c=u.y-f,E=u.z-p;const T=(e.x+a*C)*r,b=(e.y+a*f)*r,R=(e.z+a*p)*r;e.x=(e.x-a*T)*d,e.y=(e.y-a*b)*d,e.z=(e.z-a*R)*d,n.x=y+(C+T)*d,n.y=c+(f+b)*d,n.z=E+(p+R)*d;const st=_-u.x,it=o-u.y,Nt=m-u.z,Yt=n.x-_,Zt=n.y-o,qt=n.z-m;return st*Yt+it*Zt+Nt*qt>0&&(n.x=_,n.y=o,n.z=m,e.x=(n.x-_)/r,e.y=(n.y-o)/r,e.z=(n.z-m)/r),n}function pt(u,t){t.set(0,0),u.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=u.length,t.y/=u.length}function _t(u,t){return V(u)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}class _e{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 r=i.indexOf(e);r!==-1&&i.splice(r,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 r=0,n=i.length;r<n;r++)i[r].call(this,t)}}}const ot=1/8,ue=/Mac/.test(navigator.platform);let v,St,nt,ut,L,P,S,G,tt,H,I,Y,Dt,bt,M,et,X,Ut,ft,At,gt,yt,at;class Z extends _e{static install(t){v=t.THREE,St=Object.freeze(new v.Vector3(0,0,0)),nt=Object.freeze(new v.Vector3(0,1,0)),ut=Object.freeze(new v.Vector3(0,0,1)),L=new v.Vector2,P=new v.Vector3,S=new v.Vector3,G=new v.Vector3,tt=new v.Vector3,H=new v.Vector3,I=new v.Vector3,Y=new v.Vector3,Dt=new v.Vector3,bt=new v.Vector3,M=new v.Spherical,et=new v.Spherical,X=new v.Box3,Ut=new v.Box3,ft=new v.Sphere,At=new v.Quaternion,gt=new v.Quaternion,yt=new v.Matrix4,at=new v.Raycaster}static get ACTION(){return h}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=h.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=q.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new v.Vector3,this._focalOffsetVelocity=new v.Vector3,this._zoomVelocity={value:0},this._truckInternal=(o,m,O)=>{let g,x;if(N(this._camera)){const T=P.copy(this._camera.position).sub(this._target),b=this._camera.getEffectiveFOV()*Q,R=T.length()*Math.tan(b*.5);g=this.truckSpeed*o*R/this._elementRect.height,x=this.truckSpeed*m*R/this._elementRect.height}else if(V(this._camera)){const T=this._camera;g=o*(T.right-T.left)/T.zoom/this._elementRect.width,x=m*(T.top-T.bottom)/T.zoom/this._elementRect.height}else return;this.verticalDragToForward?(O?this.setFocalOffset(this._focalOffsetEnd.x+g,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(g,0,!0),this.forward(-x,!0)):O?this.setFocalOffset(this._focalOffsetEnd.x+g,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(g,x,!0)},this._rotateInternal=(o,m)=>{const O=W*this.azimuthRotateSpeed*o/this._elementRect.height,g=W*this.polarRotateSpeed*m/this._elementRect.height;this.rotate(O,g,!0)},this._dollyInternal=(o,m,O)=>{const g=Math.pow(.95,-o*this.dollySpeed),x=this._sphericalEnd.radius,T=this._sphericalEnd.radius*g,b=F(T,this.minDistance,this.maxDistance),R=b-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(R,!0),this._dollyToNoClamp(b,!0)):this._dollyToNoClamp(b,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:b)-x,this._dollyControlCoord.set(m,O)),this._lastDollyDirection=Math.sign(-o)},this._zoomInternal=(o,m,O)=>{const g=Math.pow(.95,o*this.dollySpeed),x=this._zoom,T=this._zoom*g;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-x,this._dollyControlCoord.set(m,O))},typeof v=="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 v.Quaternion().setFromUnitVectors(this._camera.up,nt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=h.NONE,this._target=new v.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new v.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new v.Spherical().setFromVector3(P.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 v.Vector3,new v.Vector3,new v.Vector3,new v.Vector3],this._updateNearPlaneCorners(),this._boundary=new v.Box3(new v.Vector3(-1/0,-1/0,-1/0),new v.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 v.Vector2,this.mouseButtons={left:h.ROTATE,middle:h.DOLLY,right:h.TRUCK,wheel:N(this._camera)?h.DOLLY:V(this._camera)?h.ZOOM:h.NONE},this.touches={one:h.TOUCH_ROTATE,two:N(this._camera)?h.TOUCH_DOLLY_TRUCK:V(this._camera)?h.TOUCH_ZOOM_TRUCK:h.NONE,three:h.TOUCH_TRUCK};const s=new v.Vector2,i=new v.Vector2,r=new v.Vector2,n=o=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const g=this._domElement.getBoundingClientRect(),x=(o.clientX-g.left)/(g.right-g.left),T=(o.clientY-g.top)/(g.bottom-g.top);if(x<this._interactiveArea.left||x>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const m=o.pointerType!=="mouse"?null:(o.buttons&A.LEFT)===A.LEFT?A.LEFT:(o.buttons&A.MIDDLE)===A.MIDDLE?A.MIDDLE:(o.buttons&A.RIGHT)===A.RIGHT?A.RIGHT:null;if(m!==null){const g=this._findPointerByMouseButton(m);g&&this._disposePointer(g)}if((o.buttons&A.LEFT)===A.LEFT&&this._lockedPointer)return;const O={pointerId:o.pointerId,clientX:o.clientX,clientY:o.clientY,deltaX:0,deltaY:0,mouseButton:m};this._activePointers.push(O),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,E(o)},a=o=>{o.cancelable&&o.preventDefault();const m=o.pointerId,O=this._lockedPointer||this._findPointerById(m);if(O){if(O.clientX=o.clientX,O.clientY=o.clientY,O.deltaX=o.movementX,O.deltaY=o.movementY,this._state=0,o.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&&(o.buttons&A.LEFT)===A.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(o.buttons&A.MIDDLE)===A.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(o.buttons&A.RIGHT)===A.RIGHT&&(this._state=this._state|this.mouseButtons.right);C()}},l=o=>{const m=this._findPointerById(o.pointerId);if(!(m&&m===this._lockedPointer)){if(m&&this._disposePointer(m),o.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=h.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=h.NONE;f()}};let d=-1;const y=o=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===h.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const T=this._domElement.getBoundingClientRect(),b=(o.clientX-T.left)/(T.right-T.left),R=(o.clientY-T.top)/(T.bottom-T.top);if(b<this._interactiveArea.left||b>this._interactiveArea.right||R<this._interactiveArea.top||R>this._interactiveArea.bottom)return}if(o.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===h.ROTATE||this.mouseButtons.wheel===h.TRUCK){const T=performance.now();d-T<1e3&&this._getClientRect(this._elementRect),d=T}const m=ue?-1:-3,O=o.deltaMode===1?o.deltaY/m:o.deltaY/(m*10),g=this.dollyToCursor?(o.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(o.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case h.ROTATE:{this._rotateInternal(o.deltaX,o.deltaY),this._isUserControllingRotate=!0;break}case h.TRUCK:{this._truckInternal(o.deltaX,o.deltaY,!1),this._isUserControllingTruck=!0;break}case h.OFFSET:{this._truckInternal(o.deltaX,o.deltaY,!0),this._isUserControllingOffset=!0;break}case h.DOLLY:{this._dollyInternal(-O,g,x),this._isUserControllingDolly=!0;break}case h.ZOOM:{this._zoomInternal(-O,g,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},c=o=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Z.ACTION.NONE){const m=o instanceof PointerEvent?o.pointerId:0,O=this._findPointerById(m);O&&this._disposePointer(O),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}o.preventDefault()}},E=o=>{if(!this._enabled)return;if(pt(this._activePointers,L),this._getClientRect(this._elementRect),s.copy(L),i.copy(L),this._activePointers.length>=2){const O=L.x-this._activePointers[1].clientX,g=L.y-this._activePointers[1].clientY,x=Math.sqrt(O*O+g*g);r.set(0,x);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,b=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(T,b)}if(this._state=0,!o)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in o&&o.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&&(o.buttons&A.LEFT)===A.LEFT&&(this._state=this._state|this.mouseButtons.left),(o.buttons&A.MIDDLE)===A.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(o.buttons&A.RIGHT)===A.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&h.ROTATE)===h.ROTATE||(this._state&h.TOUCH_ROTATE)===h.TOUCH_ROTATE||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE||(this._state&h.TOUCH_ZOOM_ROTATE)===h.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&h.TRUCK)===h.TRUCK||(this._state&h.TOUCH_TRUCK)===h.TOUCH_TRUCK||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_ZOOM_TRUCK)===h.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&h.DOLLY)===h.DOLLY||(this._state&h.TOUCH_DOLLY)===h.TOUCH_DOLLY||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&h.ZOOM)===h.ZOOM||(this._state&h.TOUCH_ZOOM)===h.TOUCH_ZOOM||(this._state&h.TOUCH_ZOOM_TRUCK)===h.TOUCH_ZOOM_TRUCK||(this._state&h.TOUCH_ZOOM_OFFSET)===h.TOUCH_ZOOM_OFFSET||(this._state&h.TOUCH_ZOOM_ROTATE)===h.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&h.OFFSET)===h.OFFSET||(this._state&h.TOUCH_OFFSET)===h.TOUCH_OFFSET||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET||(this._state&h.TOUCH_ZOOM_OFFSET)===h.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},C=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,pt(this._activePointers,L);const m=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,O=m?-m.deltaX:i.x-L.x,g=m?-m.deltaY:i.y-L.y;if(i.copy(L),((this._state&h.ROTATE)===h.ROTATE||(this._state&h.TOUCH_ROTATE)===h.TOUCH_ROTATE||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE||(this._state&h.TOUCH_ZOOM_ROTATE)===h.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(O,g),this._isUserControllingRotate=!0),(this._state&h.DOLLY)===h.DOLLY||(this._state&h.ZOOM)===h.ZOOM){const x=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,b=this.dollyDragInverted?-1:1;(this._state&h.DOLLY)===h.DOLLY?(this._dollyInternal(b*g*ot,x,T),this._isUserControllingDolly=!0):(this._zoomInternal(b*g*ot,x,T),this._isUserControllingZoom=!0)}if((this._state&h.TOUCH_DOLLY)===h.TOUCH_DOLLY||(this._state&h.TOUCH_ZOOM)===h.TOUCH_ZOOM||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_ZOOM_TRUCK)===h.TOUCH_ZOOM_TRUCK||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET||(this._state&h.TOUCH_ZOOM_OFFSET)===h.TOUCH_ZOOM_OFFSET||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE||(this._state&h.TOUCH_ZOOM_ROTATE)===h.TOUCH_ZOOM_ROTATE){const x=L.x-this._activePointers[1].clientX,T=L.y-this._activePointers[1].clientY,b=Math.sqrt(x*x+T*T),R=r.y-b;r.set(0,b);const st=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,it=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&h.TOUCH_DOLLY)===h.TOUCH_DOLLY||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET?(this._dollyInternal(R*ot,st,it),this._isUserControllingDolly=!0):(this._zoomInternal(R*ot,st,it),this._isUserControllingZoom=!0)}((this._state&h.TRUCK)===h.TRUCK||(this._state&h.TOUCH_TRUCK)===h.TOUCH_TRUCK||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_ZOOM_TRUCK)===h.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(O,g,!1),this._isUserControllingTruck=!0),((this._state&h.OFFSET)===h.OFFSET||(this._state&h.TOUCH_OFFSET)===h.TOUCH_OFFSET||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET||(this._state&h.TOUCH_ZOOM_OFFSET)===h.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(O,g,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},f=()=>{pt(this._activePointers,L),i.copy(L),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",p),this._domElement.ownerDocument.addEventListener("pointerlockerror",_),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),E())},this.unlockPointer=()=>{var o,m,O;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(o=this._domElement)===null||o===void 0||o.ownerDocument.exitPointerLock(),(m=this._domElement)===null||m===void 0||m.ownerDocument.removeEventListener("pointerlockchange",p),(O=this._domElement)===null||O===void 0||O.ownerDocument.removeEventListener("pointerlockerror",_),this.cancel()};const p=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},_=()=>{this.unlockPointer()};this._addAllEventListeners=o=>{this._domElement=o,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",n),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",y,{passive:!1}),this._domElement.addEventListener("contextmenu",c)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",n),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",y,{passive:!1}),this._domElement.removeEventListener("contextmenu",c),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",p),this._domElement.ownerDocument.removeEventListener("pointerlockerror",_))},this.cancel=()=>{this._state!==h.NONE&&(this._state=h.NONE,this._activePointers.length=0,f())},e&&this.connect(e),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=F(t.width,0,1),this._interactiveArea.height=F(t.height,0,1),this._interactiveArea.x=F(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=F(t.y,0,1-this._interactiveArea.height)}addEventListener(t,e){super.addEventListener(t,e)}removeEventListener(t,e){super.removeEventListener(t,e)}rotate(t,e,s=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+e,s)}rotateAzimuthTo(t,e=!1){return this.rotateTo(t,this._sphericalEnd.phi,e)}rotatePolarTo(t,e=!1){return this.rotateTo(this._sphericalEnd.theta,t,e)}rotateTo(t,e,s=!1){this._isUserControllingRotate=!1;const i=F(t,this.minAzimuthAngle,this.maxAzimuthAngle),r=F(e,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const n=!s||D(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&D(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(n)}dolly(t,e=!1){return this.dollyTo(this._sphericalEnd.radius-t,e)}dollyTo(t,e=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0,this._dollyToNoClamp(F(t,this.minDistance,this.maxDistance),e)}_dollyToNoClamp(t,e=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const n=this._collisionTest(),a=D(n,this._spherical.radius);if(!(s>t)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,n)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,e||(this._spherical.radius=this._sphericalEnd.radius);const r=!e||D(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection(tt).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const s=!e||D(this._target.x,this._targetEnd.x,this.restThreshold)&&D(this._target.y,this._targetEnd.y,this.restThreshold)&&D(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(t,e=!1){return this.zoomTo(this._zoomEnd+t,e)}zoomTo(t,e=!1){this._isUserControllingZoom=!1,this._zoomEnd=F(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const s=!e||D(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(t,e,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,e,s)}truck(t,e,s=!1){this._camera.updateMatrix(),H.setFromMatrixColumn(this._camera.matrix,0),I.setFromMatrixColumn(this._camera.matrix,1),H.multiplyScalar(t),I.multiplyScalar(-e);const i=P.copy(H).add(I),r=S.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,s)}forward(t,e=!1){P.setFromMatrixColumn(this._camera.matrix,0),P.crossVectors(this._camera.up,P),P.multiplyScalar(t);const s=S.copy(this._targetEnd).add(P);return this.moveTo(s.x,s.y,s.z,e)}elevate(t,e=!1){return P.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+P.x,this._targetEnd.y+P.y,this._targetEnd.z+P.z,e)}moveTo(t,e,s,i=!1){this._isUserControllingTruck=!1;const r=P.set(t,e,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const n=!i||D(this._target.x,this._targetEnd.x,this.restThreshold)&&D(this._target.y,this._targetEnd.y,this.restThreshold)&&D(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}lookInDirectionOf(t,e,s,i=!1){const a=P.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:r=0,paddingBottom:n=0,paddingTop:a=0}={}){const l=[],d=t.isBox3?X.copy(t):X.setFromObject(t);d.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const y=wt(this._sphericalEnd.theta,xt),c=wt(this._sphericalEnd.phi,xt);l.push(this.rotateTo(y,c,e));const E=P.setFromSpherical(this._sphericalEnd).normalize(),C=At.setFromUnitVectors(E,ut),f=D(Math.abs(E.y),1);f&&C.multiply(gt.setFromAxisAngle(nt,y)),C.multiply(this._yAxisUpSpaceInverse);const p=Ut.makeEmpty();S.copy(d.min).applyQuaternion(C),p.expandByPoint(S),S.copy(d.min).setX(d.max.x).applyQuaternion(C),p.expandByPoint(S),S.copy(d.min).setY(d.max.y).applyQuaternion(C),p.expandByPoint(S),S.copy(d.max).setZ(d.min.z).applyQuaternion(C),p.expandByPoint(S),S.copy(d.min).setZ(d.max.z).applyQuaternion(C),p.expandByPoint(S),S.copy(d.max).setY(d.min.y).applyQuaternion(C),p.expandByPoint(S),S.copy(d.max).setX(d.min.x).applyQuaternion(C),p.expandByPoint(S),S.copy(d.max).applyQuaternion(C),p.expandByPoint(S),p.min.x-=i,p.min.y-=n,p.max.x+=r,p.max.y+=a,C.setFromUnitVectors(ut,E),f&&C.premultiply(gt.invert()),C.premultiply(this._yAxisUpSpace);const _=p.getSize(P),o=p.getCenter(S).applyQuaternion(C);if(N(this._camera)){const m=this.getDistanceToFitBox(_.x,_.y,_.z,s);l.push(this.moveTo(o.x,o.y,o.z,e)),l.push(this.dollyTo(m,e)),l.push(this.setFocalOffset(0,0,0,e))}else if(V(this._camera)){const m=this._camera,O=m.right-m.left,g=m.top-m.bottom,x=s?Math.max(O/_.x,g/_.y):Math.min(O/_.x,g/_.y);l.push(this.moveTo(o.x,o.y,o.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=[],r="isObject3D"in t?Z.createBoundingSphere(t,ft):ft.copy(t);if(s.push(this.moveTo(r.center.x,r.center.y,r.center.z,e)),N(this._camera)){const n=this.getDistanceToFitSphere(r.radius);s.push(this.dollyTo(n,e))}else if(V(this._camera)){const n=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*r.radius,d=Math.min(n/l,a/l);s.push(this.zoomTo(d,e))}return s.push(this.setFocalOffset(0,0,0,e)),Promise.all(s)}setLookAt(t,e,s,i,r,n,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0;const l=S.set(i,r,n),d=P.set(t,e,s);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(d.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const y=!a||D(this._target.x,this._targetEnd.x,this.restThreshold)&&D(this._target.y,this._targetEnd.y,this.restThreshold)&&D(this._target.z,this._targetEnd.z,this.restThreshold)&&D(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&D(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&D(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(y)}lerpLookAt(t,e,s,i,r,n,a,l,d,y,c,E,C,f=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0;const p=P.set(i,r,n),_=S.set(t,e,s);M.setFromVector3(_.sub(p).applyQuaternion(this._yAxisUpSpace));const o=G.set(y,c,E),m=S.set(a,l,d);et.setFromVector3(m.sub(o).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(p.lerp(o,C));const O=et.theta-M.theta,g=et.phi-M.phi,x=et.radius-M.radius;this._sphericalEnd.set(M.radius+x*C,M.phi+g*C,M.theta+O*C),this.normalizeRotations(),this._needsUpdate=!0,f||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!f||D(this._target.x,this._targetEnd.x,this.restThreshold)&&D(this._target.y,this._targetEnd.y,this.restThreshold)&&D(this._target.z,this._targetEnd.z,this.restThreshold)&&D(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&D(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&D(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}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 r=this.getPosition(P),n=this.setLookAt(r.x,r.y,r.z,t,e,s,i);return this._sphericalEnd.phi=F(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),n}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 r=!i||D(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&D(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&D(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(t,e,s){this._camera.updateMatrixWorld(),H.setFromMatrixColumn(this._camera.matrixWorldInverse,0),I.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Y.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=P.set(t,e,s),r=i.distanceTo(this._camera.position),n=i.sub(this._camera.position);H.multiplyScalar(n.x),I.multiplyScalar(n.y),Y.multiplyScalar(n.z),P.copy(H).add(I).add(Y),P.z=P.z+r,this.dollyTo(r,!1),this.setFocalOffset(-P.x,P.y,-P.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 v.Vector4,typeof t=="number"?this._viewport.set(t,e,s,i):this._viewport.copy(t)}getDistanceToFitBox(t,e,s,i=!1){if(_t(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=t/e,n=this._camera.getEffectiveFOV()*Q,a=this._camera.aspect;return((i?r>a:r<a)?e:t/a)*.5/Math.tan(n*.5)+s*.5}getDistanceToFitSphere(t){if(_t(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*Q,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 v.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new v.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new v.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new v.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%W,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=W),this._spherical.theta+=W*Math.round((this._sphericalEnd.theta-this._spherical.theta)/W)}reset(t=!1){if(!D(this._camera.up.x,this._cameraUp0.x)||!D(this._camera.up.y,this._cameraUp0.y)||!D(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(P);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,nt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=P.subVectors(this._target,this._camera.position).normalize(),e=S.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(P);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,r=Dt.subVectors(this._targetEnd,this._target),n=bt.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(U(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const c=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=rt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,c,1/0,t),this._needsUpdate=!0}if(U(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const c=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=rt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,c,1/0,t),this._needsUpdate=!0}if(U(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const c=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=rt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,c,this.maxSpeed,t),this._needsUpdate=!0}if(U(r.x)&&U(r.y)&&U(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const c=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Pt(this._target,this._targetEnd,this._targetVelocity,c,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(U(n.x)&&U(n.y)&&U(n.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const c=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Pt(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,c,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(U(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const c=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=rt(this._zoom,this._zoomEnd,this._zoomVelocity,c,1/0,t)}if(this.dollyToCursor){if(N(this._camera)&&this._changedDolly!==0){const c=this._spherical.radius-this._lastDistance,E=this._camera,C=this._getCameraDirection(tt),f=P.copy(C).cross(E.up).normalize();f.lengthSq()===0&&(f.x=1);const p=S.crossVectors(f,C),_=this._sphericalEnd.radius*Math.tan(E.getEffectiveFOV()*Q*.5),m=(this._sphericalEnd.radius-c-this._sphericalEnd.radius)/this._sphericalEnd.radius,O=G.copy(this._targetEnd).add(f.multiplyScalar(this._dollyControlCoord.x*_*E.aspect)).add(p.multiplyScalar(this._dollyControlCoord.y*_)),g=P.copy(this._targetEnd).lerp(O,m),x=this._lastDollyDirection===q.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===q.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(x||T)){this._sphericalEnd.radius-=c,this._spherical.radius-=c;const R=S.copy(C).multiplyScalar(-c);g.add(R)}this._boundary.clampPoint(g,g);const b=S.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(b),this._changedDolly-=c,U(this._changedDolly)&&(this._changedDolly=0)}else if(V(this._camera)&&this._changedZoom!==0){const c=this._zoom-this._lastZoom,E=this._camera,C=P.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(E.near+E.far)/(E.near-E.far)).unproject(E),f=S.set(0,0,-1).applyQuaternion(E.quaternion),p=G.copy(C).add(f.multiplyScalar(-C.dot(E.up))),o=-(this._zoom-c-this._zoom)/this._zoom,m=this._getCameraDirection(tt),O=this._targetEnd.dot(m),g=P.copy(this._targetEnd).lerp(p,o),x=g.dot(m),T=m.multiplyScalar(x-O);g.sub(T),this._boundary.clampPoint(g,g);const b=S.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(b),this._changedZoom-=c,U(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const 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),(!U(this._focalOffset.x)||!U(this._focalOffset.y)||!U(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),H.setFromMatrixColumn(this._camera.matrix,0),I.setFromMatrixColumn(this._camera.matrix,1),Y.setFromMatrixColumn(this._camera.matrix,2),H.multiplyScalar(this._focalOffset.x),I.multiplyScalar(-this._focalOffset.y),Y.multiplyScalar(this._focalOffset.z),P.copy(H).add(I).add(Y),this._camera.position.add(P)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),P.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const y=this._needsUpdate;return y&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):y?(this.dispatchEvent({type:"update"}),U(e,this.restThreshold)&&U(s,this.restThreshold)&&U(i,this.restThreshold)&&U(r.x,this.restThreshold)&&U(r.y,this.restThreshold)&&U(r.z,this.restThreshold)&&U(n.x,this.restThreshold)&&U(n.y,this.restThreshold)&&U(n.z,this.restThreshold)&&U(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!y&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=y,this._needsUpdate=!1,y}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:$(this.maxDistance),minZoom:this.minZoom,maxZoom:$(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:$(this.maxPolarAngle),minAzimuthAngle:$(this.minAzimuthAngle),maxAzimuthAngle:$(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:P.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=J(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=J(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=J(s.maxPolarAngle),this.minAzimuthAngle=J(s.minAzimuthAngle),this.maxAzimuthAngle=J(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),M.setFromVector3(P.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(M.theta,M.phi,e),this.dollyTo(M.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 r=S.copy(e).add(t),a=this._boundary.clampPoint(r,G).sub(r),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 d=1+s*l/e.dot(a);return t.add(S.copy(e).multiplyScalar(d)).add(a.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(N(this._camera)){const t=this._camera,e=t.near,s=t.getEffectiveFOV()*Q,i=Math.tan(s*.5)*e,r=i*t.aspect;this._nearPlaneCorners[0].set(-r,-i,0),this._nearPlaneCorners[1].set(r,-i,0),this._nearPlaneCorners[2].set(r,i,0),this._nearPlaneCorners[3].set(-r,i,0)}else if(V(this._camera)){const t=this._camera,e=1/t.zoom,s=t.left*e,i=t.right*e,r=t.top*e,n=t.bottom*e;this._nearPlaneCorners[0].set(s,r,0),this._nearPlaneCorners[1].set(i,r,0),this._nearPlaneCorners[2].set(i,n,0),this._nearPlaneCorners[3].set(s,n,0)}}_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1)||_t(this._camera,"_collisionTest"))return t;const s=this._getTargetDirection(tt);yt.lookAt(St,s,this._camera.up);for(let i=0;i<4;i++){const r=S.copy(this._nearPlaneCorners[i]);r.applyMatrix4(yt);const n=G.addVectors(this._target,r);at.set(n,s),at.far=this._spherical.radius+1;const a=at.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 v.Sphere){const s=e,i=s.center;X.makeEmpty(),t.traverseVisible(n=>{n.isMesh&&X.expandByObject(n)}),X.getCenter(i);let r=0;return t.traverseVisible(n=>{if(!n.isMesh)return;const a=n,l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const y=l.attributes.position;for(let c=0,E=y.count;c<E;c++)P.fromBufferAttribute(y,c),r=Math.max(r,i.distanceToSquared(P))}),s.radius=Math.sqrt(r),s}}const fe={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMappingExposure:1,alpha:!1,outputColorSpace:ee.ColorSpace.sRGB,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,stencil:!1,depth:!1,physicallyCorrectLights:!1};class ge{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i}=t,{canvas:r,context:n,alpha:a,devicePixelRatio:l,antialias:d,powerPreference:y,toneMappingExposure:c,outputColorSpace:E,logarithmicDepthBuffer:C,preserveDrawingBuffer:f,stencil:p,depth:_,physicallyCorrectLights:o}=i,m=new w.WebGLRenderer({canvas:r,context:n,alpha:a,antialias:d,powerPreference:y,logarithmicDepthBuffer:C,preserveDrawingBuffer:f,stencil:p,depth:_});m.setSize(e,s),m.setPixelRatio(l),m.toneMappingExposure=c,m.outputColorSpace=E,+w.REVISION<155&&(m.useLegacyLights=o),this.renderer=m}setSize(t,e){this.renderer.setSize(t,e)}setPixelRatio(t){this.renderer.setPixelRatio(t)}render(t){const{scene:e,camera:s}=this.options;this.renderer.render(e,t||s)}dispose(){var t,e;this.setSize(1,1),(t=this.renderer)==null||t.clear(),(e=this.renderer)==null||e.dispose()}}const ye={antialias:!0,devicePixelRatio:window.devicePixelRatio};class Ce{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i,renderer:r}=t,{devicePixelRatio:n,antialias:a}=i,l=new r({antialias:a});l.setSize(e,s),l.setPixelRatio(n),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 ht{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(r=>{const{min:n,max:a,step:l,name:d,paramMap:y,items:c,value:E,target:C}=i[r],f=r.toLowerCase().indexOf("color")>-1;let p;const _=typeof E=="undefined"&&C,o=_?C():i[r],m=_?r:"value";c?p=s.add(o,m,c):f?p=s.addColor(o,m):p=s.add(o,m),p=p.name(d||r),typeof n!="undefined"&&(p=p.min(n)),typeof a!="undefined"&&(p=p.max(a)),typeof l!="undefined"&&(p=p.step(l)),p=p.onChange(()=>{this.setTargetValue(e,r,o[m],y)}),_&&p.listen()})})}setTargetValue(t,e,s,i){const{onChange:r,target:n,value:a}=this.guiParams[t][e],l=e.toLowerCase().indexOf("color")>-1;if(n&&!(typeof a=="undefined"&&n)){let y=n();Array.isArray(y)||(y=[y]),y.forEach(c=>{if(c)if(l)try{c[i||e].set(s)}catch(E){e!=="color"&&!i&&console.warn(`${e} is not a color,set paramMap`)}else c[i||e]=s})}r&&r(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 Oe={fov:45,near:1,far:1e3,up:new w.Vector3(0,1,0)};class Ee{constructor(t){this.customCamera=!1,this.options=t;const{width:e,height:s,cameraParams:i}=t;if(i instanceof w.Camera)this.camera=i,this.customCamera=!0;else{const{fov:r,far:n,near:a,up:l}=i,d=new w.PerspectiveCamera(r,e/s,a,n);d.position.set(0,0,400),d.lookAt(0,0,0),d.up=l,this.camera=d}}setSize(t,e){this.options.width=t,this.options.height=e,this.camera instanceof w.PerspectiveCamera&&(this.camera.aspect=t/e),this.camera.updateProjectionMatrix(),this.camera2&&(this.camera2.aspect=t/e,this.camera2.updateProjectionMatrix())}addCamera2(){const t=new w.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(t){if(t.type==="PerspectiveCamera"){const e=t;(!this.camera.matrixWorld.equals(e.matrixWorld)||this.camera.far!==e.far||this.camera.near!==e.near||this.camera.fov!==e.fov||this.camera.aspect!==e.aspect)&&this.camera.copy(e)}else{const e=t,s=e.viewMatrix,i=e.inverseViewMatrix,r=new w.Matrix4(i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]),n=new w.Matrix4(s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]),{width:a,height:l}=this.options,d=a/l;(this.camera.fov!==e.fov||this.camera.aspect!==d||!this.camera.matrixWorld.equals(r)||!this.camera.matrixWorldInverse.equals(n))&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix(),this.camera.matrixAutoUpdate=!1,this.camera.matrixWorld.copy(r),this.camera.matrixWorldInverse.copy(n),this.camera.aspect=d,this.camera.updateProjectionMatrix())}}setGui(t){const e=new ht({camera:mt(B({},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 w.PerspectiveCamera&&(e.guiParams.camera.fov={min:0,max:90,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}),e.showGui(t)}}const Te={background:null,addCamera:!0};class ve{constructor(t){this.overrideMaterial=!1,this.options=t;const{camera:e,sceneParams:s}=t,{background:i,addCamera:r}=s,n=new w.Scene;i&&(n.background=i),r&&n.add(e),this.scene=n}dispose(){var t;(t=this.scene)==null||t.traverse(e=>{se.disposeMesh(e)})}}class xe{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 w.AxesHelper(100);else if(t.isCamera)i=new w.CameraHelper(t);else if(t.isPointLight)i=new w.PointLightHelper(t,1);else if(t.isDirectionalLight)i=new w.DirectionalLightHelper(t,1);else if(t.isSpotLight)i=new w.SpotLightHelper(t);else if(t.isHemisphereLight)i=new w.HemisphereLightHelper(t,10);else if(t.isRectAreaLight)i=new ie.RectAreaLightHelper(t);else{const r=new w.Box3;if(r.setFromObject(t,!0),r.isEmpty()===!1){i=new w.Box3Helper(r);const n=i.material;n.userData.object=t,n.depthTest=!1,n.transparent=!0}else return}s.add(i),this.helpers[e]=i}}addViewHelper(){const{camera:t,container:e}=this.options,s=new re.ViewHelper(t,e);e.addEventListener("pointerdown",i=>{i.preventDefault(),s.handleClick(i)}),this.viewHelper=s}remove(t){var i;const e=t.uuid,{scene:s}=this.options;if(this.helpers[e]!==void 0){const r=this.helpers[e];s.remove(r),delete this.helpers[e],(i=r.dispose)==null||i.call(r)}}removeAll(){Object.keys(this.helpers).forEach(t=>{this.remove({uuid:t})}),this.helpers={}}removeAllExcludeScene(){Object.keys(this.helpers).forEach(t=>{this.helpers[t]instanceof w.AxesHelper||this.remove({uuid:t})})}update(t,e,s){var r,n;const{camera:i}=this.options;Object.values(this.helpers).forEach(a=>{if(a.update&&a.update(),a instanceof w.Box3Helper){const l=a.material,{object:d}=l.userData;d&&a.box.setFromObject(d,!0)}}),((r=this.viewHelper)==null?void 0:r.animating)===!0&&(this.viewHelper.update(t),(n=e.cameraControls)==null||n.setPosition(...i.position.toArray()),this.viewHelper.center.copy(s))}renderViewHelper(t){if(!this.viewHelper)return;const e=t.autoClear;t.autoClear=!1,this.viewHelper.render(t),t.autoClear=e}dispose(){var t;this.helpers={},(t=this.viewHelper)==null||t.dispose()}}class we{constructor(t){this.autoRotateSpeed=0,this.options=t;const{camera:e,controlsParams:s,customControls:i}=t,{domElement:r}=s;if(i){const n=new i(e,r);n.enableDamping=!0,n.dampingFactor=.063,n.autoRotate=!1,n.autoRotateSpeed=-60,n.enableZoom=!0,n.zoomSpeed=.2,this.customControls=n}else Z.install({THREE:w}),this.cameraControls=new Z(e,r)}addCameraControls2(t){const{controlsParams:e}=this.options,{domElement:s}=e;this.cameraControls2=new Z(t,s),this.cameraControls2.addEventListener("update",()=>{this.cameraControls.enabled=!1}),this.cameraControls2.addEventListener("sleep",()=>{this.cameraControls.enabled=!0})}enable(){this.customControls?this.customControls.enabled=!0:this.cameraControls&&(this.cameraControls.enabled=!0,this.cameraControls2&&(this.cameraControls2.enabled=!0))}disable(){this.customControls?this.customControls.enabled=!1:this.cameraControls&&(this.cameraControls.enabled=!1,this.cameraControls2&&(this.cameraControls2.enabled=!1))}update(t){var e,s,i;(e=this.customControls)==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*w.MathUtils.DEG2RAD)}dispose(){var t,e,s;(t=this.customControls)==null||t.dispose(),(e=this.cameraControls)==null||e.dispose(),(s=this.cameraControls2)==null||s.dispose()}}class Pe{constructor(t){this.event=new kt.eventsExports.EventEmitter;const{renderer:e,scene:s,camera:i}=t,r=new oe.TransformControls(i,e.domElement);if(r.getHelper){const n=r.getHelper();if(s.add(n),+w.REVISION<170){const a=r._root;a.dispose=()=>{a.traverse(l=>{l.geometry&&l.geometry.dispose(),l.material&&l.material.dispose()})},r.dispose=()=>{r.disconnect(),a.dispose()}}}else r instanceof w.Object3D&&s.add(r);this.controls=r,this.addEvent()}get detach(){return this.controls.detach.bind(this.controls)}get attach(){return this.controls.attach.bind(this.controls)}addEvent(){let t=null,e=null,s=null;const i=this.controls;i.addEventListener("change",()=>{const r=i.object;r!==void 0&&this.event.emit("change",r)}),i.addEventListener("mouseDown",()=>{const r=i.object;t=r.position.clone(),e=r.rotation.clone(),s=r.scale.clone(),this.event.emit("mouseDown",r)}),i.addEventListener("mouseUp",()=>{const r=i.object;if(r!==void 0)switch(i.getMode()){case"translate":t.equals(r.position)||this.event.emit("translate",r,r.position,t);break;case"rotate":e.equals(r.rotation)||this.event.emit("rotate",r,r.rotation,e);break;case"scale":s.equals(r.scale)||this.event.emit("scale",r,r.scale,s);break}this.event.emit("mouseUp")})}dispose(){var t;this.event.removeAllListeners(),(t=this.controls)==null||t.dispose()}}const Rt=new z.Vector3,Se=new z.Quaternion,Lt=new z.Vector3,k=new z.Matrix4,De=new z.Matrix4;class be{constructor(t={}){const e=this;let s,i,r,n;const a={camera:{style:""},objects:new WeakMap},l=t.element!==void 0?t.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l;const d=document.createElement("div");d.style.transformOrigin="0 0",d.style.pointerEvents="none",l.appendChild(d);const y=document.createElement("div");y.style.transformStyle="preserve-3d",d.appendChild(y),this.getSize=function(){return{width:s,height:i}},this.render=function(_,o){const m=o.projectionMatrix.elements[5]*n;o.view&&o.view.enabled?(d.style.transform=`translate( ${-o.view.offsetX*(s/o.view.width)}px, ${-o.view.offsetY*(i/o.view.height)}px )`,d.style.transform+=`scale( ${o.view.fullWidth/o.view.width}, ${o.view.fullHeight/o.view.height} )`):d.style.transform="",_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),o.parent===null&&o.matrixWorldAutoUpdate===!0&&o.updateMatrixWorld();let O,g;o.isOrthographicCamera&&(O=-(o.right+o.left)/2,g=(o.top+o.bottom)/2);const x=o.view&&o.view.enabled?o.view.height/o.view.fullHeight:1,T=o.isOrthographicCamera?`scale( ${x} )scale(`+m+")translate("+c(O)+"px,"+c(g)+"px)"+E(o.matrixWorldInverse):`scale( ${x} )translateZ(`+m+"px)"+E(o.matrixWorldInverse),R=(o.isPerspectiveCamera?"perspective("+m+"px) ":"")+T+"translate("+r+"px,"+n+"px)";a.camera.style!==R&&(y.style.transform=R,a.camera.style=R),p(_,_,o)},this.setSize=function(_,o){s=_,i=o,r=s/2,n=i/2,l.style.width=_+"px",l.style.height=o+"px",d.style.width=_+"px",d.style.height=o+"px",y.style.width=_+"px",y.style.height=o+"px"};function c(_){return Math.abs(_)<1e-10?0:_}function E(_){const o=_.elements;return"matrix3d("+c(o[0])+","+c(-o[1])+","+c(o[2])+","+c(o[3])+","+c(o[4])+","+c(-o[5])+","+c(o[6])+","+c(o[7])+","+c(o[8])+","+c(-o[9])+","+c(o[10])+","+c(o[11])+","+c(o[12])+","+c(-o[13])+","+c(o[14])+","+c(o[15])+")"}function C(_){const o=_.elements;return"translate(-50%,-50%)"+("matrix3d("+c(o[0])+","+c(o[1])+","+c(o[2])+","+c(o[3])+","+c(-o[4])+","+c(-o[5])+","+c(-o[6])+","+c(-o[7])+","+c(o[8])+","+c(o[9])+","+c(o[10])+","+c(o[11])+","+c(o[12])+","+c(o[13])+","+c(o[14])+","+c(o[15])+")")}function f(_){_.isCSS3DObject&&(_.element.style.display="none");for(let o=0,m=_.children.length;o<m;o++)f(_.children[o])}function p(_,o,m,O){if(_.visible===!1){f(_);return}if(_.isCSS3DObject){const g=_.layers.test(m.layers)===!0,x=_.element;if(x.style.display=g===!0?"":"none",g===!0){_.onBeforeRender(e,o,m);let T;_.isCSS3DSprite?(k.copy(m.matrixWorldInverse),k.transpose(),_.rotation2D!==0&&k.multiply(De.makeRotationZ(_.rotation2D)),_.matrixWorld.decompose(Rt,Se,Lt),k.setPosition(Rt),k.scale(Lt),k.elements[3]=0,k.elements[7]=0,k.elements[11]=0,k.elements[15]=1,T=C(k)):T=C(_.matrixWorld);const b=a.objects.get(_);if(b===void 0||b.style!==T){x.style.transform=T;const R={style:T};a.objects.set(_,R)}x.parentNode!==y&&y.appendChild(x),_.onAfterRender(e,o,m)}}for(let g=0,x=_.children.length;g<x;g++)p(_.children[g],o,m)}}}const K=new z.Vector3,zt=new z.Matrix4,Mt=new z.Matrix4,Ft=new z.Vector3,Ht=new z.Vector3;class Ue{constructor(t={}){const e=this;let s,i,r,n;const a={objects:new WeakMap},l=t.element!==void 0?t.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:s,height:i}},this.render=function(f,p){f.matrixWorldAutoUpdate===!0&&f.updateMatrixWorld(),p.parent===null&&p.matrixWorldAutoUpdate===!0&&p.updateMatrixWorld(),zt.copy(p.matrixWorldInverse),Mt.multiplyMatrices(p.projectionMatrix,zt),y(f,f,p),C(f)},this.setSize=function(f,p){s=f,i=p,r=s/2,n=i/2,l.style.width=f+"px",l.style.height=p+"px"};function d(f){f.isCSS2DObject&&(f.element.style.display="none");for(let p=0,_=f.children.length;p<_;p++)d(f.children[p])}function y(f,p,_){if(f.visible===!1){d(f);return}if(f.isCSS2DObject){K.setFromMatrixPosition(f.matrixWorld),K.applyMatrix4(Mt);const o=K.z>=-1&&K.z<=1&&f.layers.test(_.layers)===!0,m=f.element;m.style.display=o===!0?"":"none",o===!0&&(f.onBeforeRender(e,p,_),m.style.transform="translate("+-100*f.center.x+"%,"+-100*f.center.y+"%)translate("+(K.x*r+r)+"px,"+(-K.y*n+n)+"px)",m.parentNode!==l&&l.appendChild(m),f.onAfterRender(e,p,_));const O={distanceToCameraSquared:c(_,f)};a.objects.set(f,O)}for(let o=0,m=f.children.length;o<m;o++)y(f.children[o],p,_)}function c(f,p){return Ft.setFromMatrixPosition(f.matrixWorld),Ht.setFromMatrixPosition(p.matrixWorld),Ft.distanceToSquared(Ht)}function E(f){const p=[];return f.traverseVisible(function(_){_.isCSS2DObject&&p.push(_)}),p}function C(f){const p=E(f).sort(function(o,m){if(o.renderOrder!==m.renderOrder)return m.renderOrder-o.renderOrder;const O=a.objects.get(o).distanceToCameraSquared,g=a.objects.get(m).distanceToCameraSquared;return O-g}),_=p.length;for(let o=0,m=p.length;o<m;o++)p[o].element.style.zIndex=_-o}}}const It={zIndex:"auto"};class Ae{constructor(t){this.container=t}addRenderer(t,e){const s=e.container||this.container,i=s.offsetWidth,r=s.offsetHeight,n=t==="css2d"?new Ue:new be;n.domElement.style.position="absolute",n.domElement.style.top="0",n.domElement.style.pointerEvents="none",n.domElement.style.zIndex=e.zIndex,n.setSize(i,r),s.appendChild(n.domElement),t==="css2d"?this.css2Drenderer=n:t==="css3d"&&(this.css3Drenderer=n)}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 Re={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1},premultiplieAlpha:{value:0}},vertexShader:`
|
|
1
|
+
"use strict";var Wt=Object.defineProperty,Gt=Object.defineProperties;var Xt=Object.getOwnPropertyDescriptors;var Ot=Object.getOwnPropertySymbols;var jt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var Et=(u,t,e)=>t in u?Wt(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,B=(u,t)=>{for(var e in t||(t={}))jt.call(t,e)&&Et(u,e,t[e]);if(Ot)for(var e of Ot(t))Kt.call(t,e)&&Et(u,e,t[e]);return u},mt=(u,t)=>Gt(u,Xt(t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("three"),Qt=require("@tweenjs/tween.js"),kt=require("./events.js"),$t=require("deepmerge"),Jt=require("stats-gl"),te=require("lil-gui"),ee=require("./colorCorrection.js"),se=require("./disposeMesh.js");require("idb-keyval");require("esus-lite");require("d3-geo");require("d3-geo-projection");const ie=require("three/examples/jsm/helpers/RectAreaLightHelper"),re=require("three/examples/jsm/helpers/ViewHelper"),oe=require("three/examples/jsm/controls/TransformControls"),Tt=require("three/examples/jsm/postprocessing/EffectComposer"),ne=require("three/examples/jsm/postprocessing/RenderPass"),ae=require("three/examples/jsm/postprocessing/SSAOPass"),he=require("three/examples/jsm/postprocessing/Pass"),le=require("three/examples/jsm/postprocessing/OutputPass"),ce=require("three/examples/jsm/postprocessing/ShaderPass"),de=require("three/examples/jsm/postprocessing/UnrealBloomPass"),me=require("./isPlainObject.js"),pe=require("./BaseObject.js");function Vt(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>u[e]})}}return t.default=u,Object.freeze(t)}const w=Vt(M),vt=Vt(Qt),A={LEFT:1,RIGHT:2,MIDDLE:4},h=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}),q={NONE:0,IN:1,OUT:-1};function N(u){return u.isPerspectiveCamera}function V(u){return u.isOrthographicCamera}const W=Math.PI*2,xt=Math.PI/2,Bt=1e-5,Q=Math.PI/180;function F(u,t,e){return Math.max(t,Math.min(e,u))}function U(u,t=Bt){return Math.abs(u)<t}function D(u,t,e=Bt){return U(u-t,e)}function wt(u,t){return Math.round(u/t)*t}function $(u){return isFinite(u)?u:u<0?-Number.MAX_VALUE:Number.MAX_VALUE}function J(u){return Math.abs(u)<Number.MAX_VALUE?u:u*(1/0)}function rt(u,t,e,s,i=1/0,r){s=Math.max(1e-4,s);const n=2/s,a=n*r,l=1/(1+a+.48*a*a+.235*a*a*a);let d=u-t;const y=t,c=i*s;d=F(d,-c,c),t=u-d;const E=(e.value+n*d)*r;e.value=(e.value-n*E)*l;let C=t+(d+E)*l;return y-u>0==C>y&&(C=y,e.value=(C-y)/r),C}function Pt(u,t,e,s,i=1/0,r,n){s=Math.max(1e-4,s);const a=2/s,l=a*r,d=1/(1+l+.48*l*l+.235*l*l*l);let y=t.x,c=t.y,E=t.z,C=u.x-y,f=u.y-c,p=u.z-E;const _=y,o=c,m=E,O=i*s,g=O*O,x=C*C+f*f+p*p;if(x>g){const dt=Math.sqrt(x);C=C/dt*O,f=f/dt*O,p=p/dt*O}y=u.x-C,c=u.y-f,E=u.z-p;const T=(e.x+a*C)*r,b=(e.y+a*f)*r,R=(e.z+a*p)*r;e.x=(e.x-a*T)*d,e.y=(e.y-a*b)*d,e.z=(e.z-a*R)*d,n.x=y+(C+T)*d,n.y=c+(f+b)*d,n.z=E+(p+R)*d;const st=_-u.x,it=o-u.y,Nt=m-u.z,Yt=n.x-_,Zt=n.y-o,qt=n.z-m;return st*Yt+it*Zt+Nt*qt>0&&(n.x=_,n.y=o,n.z=m,e.x=(n.x-_)/r,e.y=(n.y-o)/r,e.z=(n.z-m)/r),n}function pt(u,t){t.set(0,0),u.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=u.length,t.y/=u.length}function _t(u,t){return V(u)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}class _e{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 r=i.indexOf(e);r!==-1&&i.splice(r,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 r=0,n=i.length;r<n;r++)i[r].call(this,t)}}}const ot=1/8,ue=/Mac/.test(navigator.platform);let v,St,nt,ut,L,P,S,G,tt,H,I,Y,Dt,bt,z,et,X,Ut,ft,At,gt,yt,at;class Z extends _e{static install(t){v=t.THREE,St=Object.freeze(new v.Vector3(0,0,0)),nt=Object.freeze(new v.Vector3(0,1,0)),ut=Object.freeze(new v.Vector3(0,0,1)),L=new v.Vector2,P=new v.Vector3,S=new v.Vector3,G=new v.Vector3,tt=new v.Vector3,H=new v.Vector3,I=new v.Vector3,Y=new v.Vector3,Dt=new v.Vector3,bt=new v.Vector3,z=new v.Spherical,et=new v.Spherical,X=new v.Box3,Ut=new v.Box3,ft=new v.Sphere,At=new v.Quaternion,gt=new v.Quaternion,yt=new v.Matrix4,at=new v.Raycaster}static get ACTION(){return h}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=h.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=q.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new v.Vector3,this._focalOffsetVelocity=new v.Vector3,this._zoomVelocity={value:0},this._truckInternal=(o,m,O)=>{let g,x;if(N(this._camera)){const T=P.copy(this._camera.position).sub(this._target),b=this._camera.getEffectiveFOV()*Q,R=T.length()*Math.tan(b*.5);g=this.truckSpeed*o*R/this._elementRect.height,x=this.truckSpeed*m*R/this._elementRect.height}else if(V(this._camera)){const T=this._camera;g=o*(T.right-T.left)/T.zoom/this._elementRect.width,x=m*(T.top-T.bottom)/T.zoom/this._elementRect.height}else return;this.verticalDragToForward?(O?this.setFocalOffset(this._focalOffsetEnd.x+g,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(g,0,!0),this.forward(-x,!0)):O?this.setFocalOffset(this._focalOffsetEnd.x+g,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(g,x,!0)},this._rotateInternal=(o,m)=>{const O=W*this.azimuthRotateSpeed*o/this._elementRect.height,g=W*this.polarRotateSpeed*m/this._elementRect.height;this.rotate(O,g,!0)},this._dollyInternal=(o,m,O)=>{const g=Math.pow(.95,-o*this.dollySpeed),x=this._sphericalEnd.radius,T=this._sphericalEnd.radius*g,b=F(T,this.minDistance,this.maxDistance),R=b-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(R,!0),this._dollyToNoClamp(b,!0)):this._dollyToNoClamp(b,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:b)-x,this._dollyControlCoord.set(m,O)),this._lastDollyDirection=Math.sign(-o)},this._zoomInternal=(o,m,O)=>{const g=Math.pow(.95,o*this.dollySpeed),x=this._zoom,T=this._zoom*g;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-x,this._dollyControlCoord.set(m,O))},typeof v=="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 v.Quaternion().setFromUnitVectors(this._camera.up,nt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=h.NONE,this._target=new v.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new v.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new v.Spherical().setFromVector3(P.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 v.Vector3,new v.Vector3,new v.Vector3,new v.Vector3],this._updateNearPlaneCorners(),this._boundary=new v.Box3(new v.Vector3(-1/0,-1/0,-1/0),new v.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 v.Vector2,this.mouseButtons={left:h.ROTATE,middle:h.DOLLY,right:h.TRUCK,wheel:N(this._camera)?h.DOLLY:V(this._camera)?h.ZOOM:h.NONE},this.touches={one:h.TOUCH_ROTATE,two:N(this._camera)?h.TOUCH_DOLLY_TRUCK:V(this._camera)?h.TOUCH_ZOOM_TRUCK:h.NONE,three:h.TOUCH_TRUCK};const s=new v.Vector2,i=new v.Vector2,r=new v.Vector2,n=o=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const g=this._domElement.getBoundingClientRect(),x=(o.clientX-g.left)/(g.right-g.left),T=(o.clientY-g.top)/(g.bottom-g.top);if(x<this._interactiveArea.left||x>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const m=o.pointerType!=="mouse"?null:(o.buttons&A.LEFT)===A.LEFT?A.LEFT:(o.buttons&A.MIDDLE)===A.MIDDLE?A.MIDDLE:(o.buttons&A.RIGHT)===A.RIGHT?A.RIGHT:null;if(m!==null){const g=this._findPointerByMouseButton(m);g&&this._disposePointer(g)}if((o.buttons&A.LEFT)===A.LEFT&&this._lockedPointer)return;const O={pointerId:o.pointerId,clientX:o.clientX,clientY:o.clientY,deltaX:0,deltaY:0,mouseButton:m};this._activePointers.push(O),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,E(o)},a=o=>{o.cancelable&&o.preventDefault();const m=o.pointerId,O=this._lockedPointer||this._findPointerById(m);if(O){if(O.clientX=o.clientX,O.clientY=o.clientY,O.deltaX=o.movementX,O.deltaY=o.movementY,this._state=0,o.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&&(o.buttons&A.LEFT)===A.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(o.buttons&A.MIDDLE)===A.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(o.buttons&A.RIGHT)===A.RIGHT&&(this._state=this._state|this.mouseButtons.right);C()}},l=o=>{const m=this._findPointerById(o.pointerId);if(!(m&&m===this._lockedPointer)){if(m&&this._disposePointer(m),o.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=h.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=h.NONE;f()}};let d=-1;const y=o=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===h.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const T=this._domElement.getBoundingClientRect(),b=(o.clientX-T.left)/(T.right-T.left),R=(o.clientY-T.top)/(T.bottom-T.top);if(b<this._interactiveArea.left||b>this._interactiveArea.right||R<this._interactiveArea.top||R>this._interactiveArea.bottom)return}if(o.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===h.ROTATE||this.mouseButtons.wheel===h.TRUCK){const T=performance.now();d-T<1e3&&this._getClientRect(this._elementRect),d=T}const m=ue?-1:-3,O=o.deltaMode===1?o.deltaY/m:o.deltaY/(m*10),g=this.dollyToCursor?(o.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(o.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case h.ROTATE:{this._rotateInternal(o.deltaX,o.deltaY),this._isUserControllingRotate=!0;break}case h.TRUCK:{this._truckInternal(o.deltaX,o.deltaY,!1),this._isUserControllingTruck=!0;break}case h.OFFSET:{this._truckInternal(o.deltaX,o.deltaY,!0),this._isUserControllingOffset=!0;break}case h.DOLLY:{this._dollyInternal(-O,g,x),this._isUserControllingDolly=!0;break}case h.ZOOM:{this._zoomInternal(-O,g,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},c=o=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Z.ACTION.NONE){const m=o instanceof PointerEvent?o.pointerId:0,O=this._findPointerById(m);O&&this._disposePointer(O),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}o.preventDefault()}},E=o=>{if(!this._enabled)return;if(pt(this._activePointers,L),this._getClientRect(this._elementRect),s.copy(L),i.copy(L),this._activePointers.length>=2){const O=L.x-this._activePointers[1].clientX,g=L.y-this._activePointers[1].clientY,x=Math.sqrt(O*O+g*g);r.set(0,x);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,b=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(T,b)}if(this._state=0,!o)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in o&&o.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&&(o.buttons&A.LEFT)===A.LEFT&&(this._state=this._state|this.mouseButtons.left),(o.buttons&A.MIDDLE)===A.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(o.buttons&A.RIGHT)===A.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&h.ROTATE)===h.ROTATE||(this._state&h.TOUCH_ROTATE)===h.TOUCH_ROTATE||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE||(this._state&h.TOUCH_ZOOM_ROTATE)===h.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&h.TRUCK)===h.TRUCK||(this._state&h.TOUCH_TRUCK)===h.TOUCH_TRUCK||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_ZOOM_TRUCK)===h.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&h.DOLLY)===h.DOLLY||(this._state&h.TOUCH_DOLLY)===h.TOUCH_DOLLY||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&h.ZOOM)===h.ZOOM||(this._state&h.TOUCH_ZOOM)===h.TOUCH_ZOOM||(this._state&h.TOUCH_ZOOM_TRUCK)===h.TOUCH_ZOOM_TRUCK||(this._state&h.TOUCH_ZOOM_OFFSET)===h.TOUCH_ZOOM_OFFSET||(this._state&h.TOUCH_ZOOM_ROTATE)===h.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&h.OFFSET)===h.OFFSET||(this._state&h.TOUCH_OFFSET)===h.TOUCH_OFFSET||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET||(this._state&h.TOUCH_ZOOM_OFFSET)===h.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},C=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,pt(this._activePointers,L);const m=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,O=m?-m.deltaX:i.x-L.x,g=m?-m.deltaY:i.y-L.y;if(i.copy(L),((this._state&h.ROTATE)===h.ROTATE||(this._state&h.TOUCH_ROTATE)===h.TOUCH_ROTATE||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE||(this._state&h.TOUCH_ZOOM_ROTATE)===h.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(O,g),this._isUserControllingRotate=!0),(this._state&h.DOLLY)===h.DOLLY||(this._state&h.ZOOM)===h.ZOOM){const x=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,b=this.dollyDragInverted?-1:1;(this._state&h.DOLLY)===h.DOLLY?(this._dollyInternal(b*g*ot,x,T),this._isUserControllingDolly=!0):(this._zoomInternal(b*g*ot,x,T),this._isUserControllingZoom=!0)}if((this._state&h.TOUCH_DOLLY)===h.TOUCH_DOLLY||(this._state&h.TOUCH_ZOOM)===h.TOUCH_ZOOM||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_ZOOM_TRUCK)===h.TOUCH_ZOOM_TRUCK||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET||(this._state&h.TOUCH_ZOOM_OFFSET)===h.TOUCH_ZOOM_OFFSET||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE||(this._state&h.TOUCH_ZOOM_ROTATE)===h.TOUCH_ZOOM_ROTATE){const x=L.x-this._activePointers[1].clientX,T=L.y-this._activePointers[1].clientY,b=Math.sqrt(x*x+T*T),R=r.y-b;r.set(0,b);const st=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,it=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&h.TOUCH_DOLLY)===h.TOUCH_DOLLY||(this._state&h.TOUCH_DOLLY_ROTATE)===h.TOUCH_DOLLY_ROTATE||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET?(this._dollyInternal(R*ot,st,it),this._isUserControllingDolly=!0):(this._zoomInternal(R*ot,st,it),this._isUserControllingZoom=!0)}((this._state&h.TRUCK)===h.TRUCK||(this._state&h.TOUCH_TRUCK)===h.TOUCH_TRUCK||(this._state&h.TOUCH_DOLLY_TRUCK)===h.TOUCH_DOLLY_TRUCK||(this._state&h.TOUCH_ZOOM_TRUCK)===h.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(O,g,!1),this._isUserControllingTruck=!0),((this._state&h.OFFSET)===h.OFFSET||(this._state&h.TOUCH_OFFSET)===h.TOUCH_OFFSET||(this._state&h.TOUCH_DOLLY_OFFSET)===h.TOUCH_DOLLY_OFFSET||(this._state&h.TOUCH_ZOOM_OFFSET)===h.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(O,g,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},f=()=>{pt(this._activePointers,L),i.copy(L),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",p),this._domElement.ownerDocument.addEventListener("pointerlockerror",_),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),E())},this.unlockPointer=()=>{var o,m,O;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(o=this._domElement)===null||o===void 0||o.ownerDocument.exitPointerLock(),(m=this._domElement)===null||m===void 0||m.ownerDocument.removeEventListener("pointerlockchange",p),(O=this._domElement)===null||O===void 0||O.ownerDocument.removeEventListener("pointerlockerror",_),this.cancel()};const p=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},_=()=>{this.unlockPointer()};this._addAllEventListeners=o=>{this._domElement=o,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",n),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",y,{passive:!1}),this._domElement.addEventListener("contextmenu",c)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",n),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",y,{passive:!1}),this._domElement.removeEventListener("contextmenu",c),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",p),this._domElement.ownerDocument.removeEventListener("pointerlockerror",_))},this.cancel=()=>{this._state!==h.NONE&&(this._state=h.NONE,this._activePointers.length=0,f())},e&&this.connect(e),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=F(t.width,0,1),this._interactiveArea.height=F(t.height,0,1),this._interactiveArea.x=F(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=F(t.y,0,1-this._interactiveArea.height)}addEventListener(t,e){super.addEventListener(t,e)}removeEventListener(t,e){super.removeEventListener(t,e)}rotate(t,e,s=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+e,s)}rotateAzimuthTo(t,e=!1){return this.rotateTo(t,this._sphericalEnd.phi,e)}rotatePolarTo(t,e=!1){return this.rotateTo(this._sphericalEnd.theta,t,e)}rotateTo(t,e,s=!1){this._isUserControllingRotate=!1;const i=F(t,this.minAzimuthAngle,this.maxAzimuthAngle),r=F(e,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const n=!s||D(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&D(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(n)}dolly(t,e=!1){return this.dollyTo(this._sphericalEnd.radius-t,e)}dollyTo(t,e=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0,this._dollyToNoClamp(F(t,this.minDistance,this.maxDistance),e)}_dollyToNoClamp(t,e=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const n=this._collisionTest(),a=D(n,this._spherical.radius);if(!(s>t)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,n)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,e||(this._spherical.radius=this._sphericalEnd.radius);const r=!e||D(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection(tt).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const s=!e||D(this._target.x,this._targetEnd.x,this.restThreshold)&&D(this._target.y,this._targetEnd.y,this.restThreshold)&&D(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(t,e=!1){return this.zoomTo(this._zoomEnd+t,e)}zoomTo(t,e=!1){this._isUserControllingZoom=!1,this._zoomEnd=F(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const s=!e||D(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(t,e,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,e,s)}truck(t,e,s=!1){this._camera.updateMatrix(),H.setFromMatrixColumn(this._camera.matrix,0),I.setFromMatrixColumn(this._camera.matrix,1),H.multiplyScalar(t),I.multiplyScalar(-e);const i=P.copy(H).add(I),r=S.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,s)}forward(t,e=!1){P.setFromMatrixColumn(this._camera.matrix,0),P.crossVectors(this._camera.up,P),P.multiplyScalar(t);const s=S.copy(this._targetEnd).add(P);return this.moveTo(s.x,s.y,s.z,e)}elevate(t,e=!1){return P.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+P.x,this._targetEnd.y+P.y,this._targetEnd.z+P.z,e)}moveTo(t,e,s,i=!1){this._isUserControllingTruck=!1;const r=P.set(t,e,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const n=!i||D(this._target.x,this._targetEnd.x,this.restThreshold)&&D(this._target.y,this._targetEnd.y,this.restThreshold)&&D(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}lookInDirectionOf(t,e,s,i=!1){const a=P.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:r=0,paddingBottom:n=0,paddingTop:a=0}={}){const l=[],d=t.isBox3?X.copy(t):X.setFromObject(t);d.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const y=wt(this._sphericalEnd.theta,xt),c=wt(this._sphericalEnd.phi,xt);l.push(this.rotateTo(y,c,e));const E=P.setFromSpherical(this._sphericalEnd).normalize(),C=At.setFromUnitVectors(E,ut),f=D(Math.abs(E.y),1);f&&C.multiply(gt.setFromAxisAngle(nt,y)),C.multiply(this._yAxisUpSpaceInverse);const p=Ut.makeEmpty();S.copy(d.min).applyQuaternion(C),p.expandByPoint(S),S.copy(d.min).setX(d.max.x).applyQuaternion(C),p.expandByPoint(S),S.copy(d.min).setY(d.max.y).applyQuaternion(C),p.expandByPoint(S),S.copy(d.max).setZ(d.min.z).applyQuaternion(C),p.expandByPoint(S),S.copy(d.min).setZ(d.max.z).applyQuaternion(C),p.expandByPoint(S),S.copy(d.max).setY(d.min.y).applyQuaternion(C),p.expandByPoint(S),S.copy(d.max).setX(d.min.x).applyQuaternion(C),p.expandByPoint(S),S.copy(d.max).applyQuaternion(C),p.expandByPoint(S),p.min.x-=i,p.min.y-=n,p.max.x+=r,p.max.y+=a,C.setFromUnitVectors(ut,E),f&&C.premultiply(gt.invert()),C.premultiply(this._yAxisUpSpace);const _=p.getSize(P),o=p.getCenter(S).applyQuaternion(C);if(N(this._camera)){const m=this.getDistanceToFitBox(_.x,_.y,_.z,s);l.push(this.moveTo(o.x,o.y,o.z,e)),l.push(this.dollyTo(m,e)),l.push(this.setFocalOffset(0,0,0,e))}else if(V(this._camera)){const m=this._camera,O=m.right-m.left,g=m.top-m.bottom,x=s?Math.max(O/_.x,g/_.y):Math.min(O/_.x,g/_.y);l.push(this.moveTo(o.x,o.y,o.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=[],r="isObject3D"in t?Z.createBoundingSphere(t,ft):ft.copy(t);if(s.push(this.moveTo(r.center.x,r.center.y,r.center.z,e)),N(this._camera)){const n=this.getDistanceToFitSphere(r.radius);s.push(this.dollyTo(n,e))}else if(V(this._camera)){const n=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*r.radius,d=Math.min(n/l,a/l);s.push(this.zoomTo(d,e))}return s.push(this.setFocalOffset(0,0,0,e)),Promise.all(s)}setLookAt(t,e,s,i,r,n,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0;const l=S.set(i,r,n),d=P.set(t,e,s);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(d.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const y=!a||D(this._target.x,this._targetEnd.x,this.restThreshold)&&D(this._target.y,this._targetEnd.y,this.restThreshold)&&D(this._target.z,this._targetEnd.z,this.restThreshold)&&D(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&D(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&D(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(y)}lerpLookAt(t,e,s,i,r,n,a,l,d,y,c,E,C,f=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=q.NONE,this._changedDolly=0;const p=P.set(i,r,n),_=S.set(t,e,s);z.setFromVector3(_.sub(p).applyQuaternion(this._yAxisUpSpace));const o=G.set(y,c,E),m=S.set(a,l,d);et.setFromVector3(m.sub(o).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(p.lerp(o,C));const O=et.theta-z.theta,g=et.phi-z.phi,x=et.radius-z.radius;this._sphericalEnd.set(z.radius+x*C,z.phi+g*C,z.theta+O*C),this.normalizeRotations(),this._needsUpdate=!0,f||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!f||D(this._target.x,this._targetEnd.x,this.restThreshold)&&D(this._target.y,this._targetEnd.y,this.restThreshold)&&D(this._target.z,this._targetEnd.z,this.restThreshold)&&D(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&D(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&D(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}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 r=this.getPosition(P),n=this.setLookAt(r.x,r.y,r.z,t,e,s,i);return this._sphericalEnd.phi=F(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),n}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 r=!i||D(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&D(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&D(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(t,e,s){this._camera.updateMatrixWorld(),H.setFromMatrixColumn(this._camera.matrixWorldInverse,0),I.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Y.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=P.set(t,e,s),r=i.distanceTo(this._camera.position),n=i.sub(this._camera.position);H.multiplyScalar(n.x),I.multiplyScalar(n.y),Y.multiplyScalar(n.z),P.copy(H).add(I).add(Y),P.z=P.z+r,this.dollyTo(r,!1),this.setFocalOffset(-P.x,P.y,-P.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 v.Vector4,typeof t=="number"?this._viewport.set(t,e,s,i):this._viewport.copy(t)}getDistanceToFitBox(t,e,s,i=!1){if(_t(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=t/e,n=this._camera.getEffectiveFOV()*Q,a=this._camera.aspect;return((i?r>a:r<a)?e:t/a)*.5/Math.tan(n*.5)+s*.5}getDistanceToFitSphere(t){if(_t(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*Q,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 v.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new v.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new v.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new v.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%W,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=W),this._spherical.theta+=W*Math.round((this._sphericalEnd.theta-this._spherical.theta)/W)}reset(t=!1){if(!D(this._camera.up.x,this._cameraUp0.x)||!D(this._camera.up.y,this._cameraUp0.y)||!D(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(P);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,nt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=P.subVectors(this._target,this._camera.position).normalize(),e=S.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(P);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,r=Dt.subVectors(this._targetEnd,this._target),n=bt.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(U(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const c=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=rt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,c,1/0,t),this._needsUpdate=!0}if(U(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const c=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=rt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,c,1/0,t),this._needsUpdate=!0}if(U(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const c=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=rt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,c,this.maxSpeed,t),this._needsUpdate=!0}if(U(r.x)&&U(r.y)&&U(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const c=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Pt(this._target,this._targetEnd,this._targetVelocity,c,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(U(n.x)&&U(n.y)&&U(n.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const c=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Pt(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,c,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(U(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const c=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=rt(this._zoom,this._zoomEnd,this._zoomVelocity,c,1/0,t)}if(this.dollyToCursor){if(N(this._camera)&&this._changedDolly!==0){const c=this._spherical.radius-this._lastDistance,E=this._camera,C=this._getCameraDirection(tt),f=P.copy(C).cross(E.up).normalize();f.lengthSq()===0&&(f.x=1);const p=S.crossVectors(f,C),_=this._sphericalEnd.radius*Math.tan(E.getEffectiveFOV()*Q*.5),m=(this._sphericalEnd.radius-c-this._sphericalEnd.radius)/this._sphericalEnd.radius,O=G.copy(this._targetEnd).add(f.multiplyScalar(this._dollyControlCoord.x*_*E.aspect)).add(p.multiplyScalar(this._dollyControlCoord.y*_)),g=P.copy(this._targetEnd).lerp(O,m),x=this._lastDollyDirection===q.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===q.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(x||T)){this._sphericalEnd.radius-=c,this._spherical.radius-=c;const R=S.copy(C).multiplyScalar(-c);g.add(R)}this._boundary.clampPoint(g,g);const b=S.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(b),this._changedDolly-=c,U(this._changedDolly)&&(this._changedDolly=0)}else if(V(this._camera)&&this._changedZoom!==0){const c=this._zoom-this._lastZoom,E=this._camera,C=P.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(E.near+E.far)/(E.near-E.far)).unproject(E),f=S.set(0,0,-1).applyQuaternion(E.quaternion),p=G.copy(C).add(f.multiplyScalar(-C.dot(E.up))),o=-(this._zoom-c-this._zoom)/this._zoom,m=this._getCameraDirection(tt),O=this._targetEnd.dot(m),g=P.copy(this._targetEnd).lerp(p,o),x=g.dot(m),T=m.multiplyScalar(x-O);g.sub(T),this._boundary.clampPoint(g,g);const b=S.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(b),this._changedZoom-=c,U(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const 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),(!U(this._focalOffset.x)||!U(this._focalOffset.y)||!U(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),H.setFromMatrixColumn(this._camera.matrix,0),I.setFromMatrixColumn(this._camera.matrix,1),Y.setFromMatrixColumn(this._camera.matrix,2),H.multiplyScalar(this._focalOffset.x),I.multiplyScalar(-this._focalOffset.y),Y.multiplyScalar(this._focalOffset.z),P.copy(H).add(I).add(Y),this._camera.position.add(P)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),P.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const y=this._needsUpdate;return y&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):y?(this.dispatchEvent({type:"update"}),U(e,this.restThreshold)&&U(s,this.restThreshold)&&U(i,this.restThreshold)&&U(r.x,this.restThreshold)&&U(r.y,this.restThreshold)&&U(r.z,this.restThreshold)&&U(n.x,this.restThreshold)&&U(n.y,this.restThreshold)&&U(n.z,this.restThreshold)&&U(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!y&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=y,this._needsUpdate=!1,y}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:$(this.maxDistance),minZoom:this.minZoom,maxZoom:$(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:$(this.maxPolarAngle),minAzimuthAngle:$(this.minAzimuthAngle),maxAzimuthAngle:$(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:P.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=J(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=J(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=J(s.maxPolarAngle),this.minAzimuthAngle=J(s.minAzimuthAngle),this.maxAzimuthAngle=J(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(P.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 r=S.copy(e).add(t),a=this._boundary.clampPoint(r,G).sub(r),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 d=1+s*l/e.dot(a);return t.add(S.copy(e).multiplyScalar(d)).add(a.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(N(this._camera)){const t=this._camera,e=t.near,s=t.getEffectiveFOV()*Q,i=Math.tan(s*.5)*e,r=i*t.aspect;this._nearPlaneCorners[0].set(-r,-i,0),this._nearPlaneCorners[1].set(r,-i,0),this._nearPlaneCorners[2].set(r,i,0),this._nearPlaneCorners[3].set(-r,i,0)}else if(V(this._camera)){const t=this._camera,e=1/t.zoom,s=t.left*e,i=t.right*e,r=t.top*e,n=t.bottom*e;this._nearPlaneCorners[0].set(s,r,0),this._nearPlaneCorners[1].set(i,r,0),this._nearPlaneCorners[2].set(i,n,0),this._nearPlaneCorners[3].set(s,n,0)}}_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1)||_t(this._camera,"_collisionTest"))return t;const s=this._getTargetDirection(tt);yt.lookAt(St,s,this._camera.up);for(let i=0;i<4;i++){const r=S.copy(this._nearPlaneCorners[i]);r.applyMatrix4(yt);const n=G.addVectors(this._target,r);at.set(n,s),at.far=this._spherical.radius+1;const a=at.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 v.Sphere){const s=e,i=s.center;X.makeEmpty(),t.traverseVisible(n=>{n.isMesh&&X.expandByObject(n)}),X.getCenter(i);let r=0;return t.traverseVisible(n=>{if(!n.isMesh)return;const a=n,l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const y=l.attributes.position;for(let c=0,E=y.count;c<E;c++)P.fromBufferAttribute(y,c),r=Math.max(r,i.distanceToSquared(P))}),s.radius=Math.sqrt(r),s}}const fe={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMappingExposure:1,alpha:!1,outputColorSpace:ee.ColorSpace.sRGB,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,stencil:!1,depth:!1,physicallyCorrectLights:!1};class ge{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i}=t,{canvas:r,context:n,alpha:a,devicePixelRatio:l,antialias:d,powerPreference:y,toneMappingExposure:c,outputColorSpace:E,logarithmicDepthBuffer:C,preserveDrawingBuffer:f,stencil:p,depth:_,physicallyCorrectLights:o}=i,m=new w.WebGLRenderer({canvas:r,context:n,alpha:a,antialias:d,powerPreference:y,logarithmicDepthBuffer:C,preserveDrawingBuffer:f,stencil:p,depth:_});m.setSize(e,s),m.setPixelRatio(l),m.toneMappingExposure=c,m.outputColorSpace=E,+w.REVISION<155&&(m.useLegacyLights=o),this.renderer=m}setSize(t,e){this.renderer.setSize(t,e)}setPixelRatio(t){this.renderer.setPixelRatio(t)}render(t){const{scene:e,camera:s}=this.options;this.renderer.render(e,t||s)}dispose(){var t,e;this.setSize(1,1),(t=this.renderer)==null||t.clear(),(e=this.renderer)==null||e.dispose()}}const ye={antialias:!0,devicePixelRatio:window.devicePixelRatio};class Ce{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i,renderer:r}=t,{devicePixelRatio:n,antialias:a}=i,l=new r({antialias:a});l.setSize(e,s),l.setPixelRatio(n),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 ht{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(r=>{const{min:n,max:a,step:l,name:d,paramMap:y,items:c,value:E,target:C}=i[r],f=r.toLowerCase().indexOf("color")>-1;let p;const _=typeof E=="undefined"&&C,o=_?C():i[r],m=_?r:"value";c?p=s.add(o,m,c):f?p=s.addColor(o,m):p=s.add(o,m),p=p.name(d||r),typeof n!="undefined"&&(p=p.min(n)),typeof a!="undefined"&&(p=p.max(a)),typeof l!="undefined"&&(p=p.step(l)),p=p.onChange(()=>{this.setTargetValue(e,r,o[m],y)}),_&&p.listen()})})}setTargetValue(t,e,s,i){const{onChange:r,target:n,value:a}=this.guiParams[t][e],l=e.toLowerCase().indexOf("color")>-1;if(n&&!(typeof a=="undefined"&&n)){let y=n();Array.isArray(y)||(y=[y]),y.forEach(c=>{if(c)if(l)try{c[i||e].set(s)}catch(E){e!=="color"&&!i&&console.warn(`${e} is not a color,set paramMap`)}else c[i||e]=s})}r&&r(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 Oe={fov:45,near:1,far:1e3,up:new w.Vector3(0,1,0)};class Ee{constructor(t){this.customCamera=!1,this.options=t;const{width:e,height:s,cameraParams:i}=t;if(i instanceof w.Camera)this.camera=i,this.customCamera=!0;else{const{fov:r,far:n,near:a,up:l}=i,d=new w.PerspectiveCamera(r,e/s,a,n);d.position.set(0,0,400),d.lookAt(0,0,0),d.up=l,this.camera=d}}setSize(t,e){this.options.width=t,this.options.height=e,this.camera instanceof w.PerspectiveCamera&&(this.camera.aspect=t/e),this.camera.updateProjectionMatrix(),this.camera2&&(this.camera2.aspect=t/e,this.camera2.updateProjectionMatrix())}addCamera2(){const t=new w.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(t){if(t.type==="PerspectiveCamera"){const e=t;(!this.camera.matrixWorld.equals(e.matrixWorld)||this.camera.far!==e.far||this.camera.near!==e.near||this.camera.fov!==e.fov||this.camera.aspect!==e.aspect)&&this.camera.copy(e)}else{const e=t,s=e.viewMatrix,i=e.inverseViewMatrix,r=new w.Matrix4(i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]),n=new w.Matrix4(s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]),{width:a,height:l}=this.options,d=a/l;(this.camera.fov!==e.fov||this.camera.aspect!==d||!this.camera.matrixWorld.equals(r)||!this.camera.matrixWorldInverse.equals(n))&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix(),this.camera.matrixAutoUpdate=!1,this.camera.matrixWorld.copy(r),this.camera.matrixWorldInverse.copy(n),this.camera.aspect=d,this.camera.updateProjectionMatrix())}}setGui(t){const e=new ht({camera:mt(B({},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 w.PerspectiveCamera&&(e.guiParams.camera.fov={min:0,max:90,step:1,target:()=>this.camera,onChange:s=>{this.camera.updateProjectionMatrix()}}),e.showGui(t)}}const Te={background:null,addCamera:!0};class ve{constructor(t){this.overrideMaterial=!1,this.options=t;const{camera:e,sceneParams:s}=t,{background:i,addCamera:r}=s,n=new w.Scene;i&&(n.background=i),r&&n.add(e),this.scene=n}dispose(){var t;(t=this.scene)==null||t.traverse(e=>{se.disposeMesh(e)})}}class xe{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 w.AxesHelper(100);else if(t.isCamera)i=new w.CameraHelper(t);else if(t.isPointLight)i=new w.PointLightHelper(t,1);else if(t.isDirectionalLight)i=new w.DirectionalLightHelper(t,1);else if(t.isSpotLight)i=new w.SpotLightHelper(t);else if(t.isHemisphereLight)i=new w.HemisphereLightHelper(t,10);else if(t.isRectAreaLight)i=new ie.RectAreaLightHelper(t);else{const r=new w.Box3;if(r.setFromObject(t,!0),r.isEmpty()===!1){i=new w.Box3Helper(r);const n=i.material;n.userData.object=t,n.depthTest=!1,n.transparent=!0}else return}s.add(i),this.helpers[e]=i}}addViewHelper(){const{camera:t,container:e}=this.options,s=new re.ViewHelper(t,e);e.addEventListener("pointerdown",i=>{i.preventDefault(),s.handleClick(i)}),this.viewHelper=s}remove(t){var i;const e=t.uuid,{scene:s}=this.options;if(this.helpers[e]!==void 0){const r=this.helpers[e];s.remove(r),delete this.helpers[e],(i=r.dispose)==null||i.call(r)}}removeAll(){Object.keys(this.helpers).forEach(t=>{this.remove({uuid:t})}),this.helpers={}}removeAllExcludeScene(){Object.keys(this.helpers).forEach(t=>{this.helpers[t]instanceof w.AxesHelper||this.remove({uuid:t})})}update(t,e,s){var r,n;const{camera:i}=this.options;Object.values(this.helpers).forEach(a=>{if(a.update&&a.update(),a instanceof w.Box3Helper){const l=a.material,{object:d}=l.userData;d&&a.box.setFromObject(d,!0)}}),((r=this.viewHelper)==null?void 0:r.animating)===!0&&(this.viewHelper.update(t),(n=e.cameraControls)==null||n.setPosition(...i.position.toArray()),this.viewHelper.center.copy(s))}renderViewHelper(t){if(!this.viewHelper)return;const e=t.autoClear;t.autoClear=!1,this.viewHelper.render(t),t.autoClear=e}dispose(){var t;this.helpers={},(t=this.viewHelper)==null||t.dispose()}}class we{constructor(t){this.autoRotateSpeed=0,this.options=t;const{camera:e,controlsParams:s,customControls:i}=t,{domElement:r}=s;if(i){const n=new i(e,r);n.enableDamping=!0,n.dampingFactor=.063,n.autoRotate=!1,n.autoRotateSpeed=-60,n.enableZoom=!0,n.zoomSpeed=.2,this.customControls=n}else Z.install({THREE:w}),this.cameraControls=new Z(e,r)}addCameraControls2(t){const{controlsParams:e}=this.options,{domElement:s}=e;this.cameraControls2=new Z(t,s),this.cameraControls2.addEventListener("update",()=>{this.cameraControls.enabled=!1}),this.cameraControls2.addEventListener("sleep",()=>{this.cameraControls.enabled=!0})}enable(){this.customControls?this.customControls.enabled=!0:this.cameraControls&&(this.cameraControls.enabled=!0,this.cameraControls2&&(this.cameraControls2.enabled=!0))}disable(){this.customControls?this.customControls.enabled=!1:this.cameraControls&&(this.cameraControls.enabled=!1,this.cameraControls2&&(this.cameraControls2.enabled=!1))}update(t){var e,s,i;(e=this.customControls)==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*w.MathUtils.DEG2RAD)}dispose(){var t,e,s;(t=this.customControls)==null||t.dispose(),(e=this.cameraControls)==null||e.dispose(),(s=this.cameraControls2)==null||s.dispose()}}class Pe{constructor(t){this.event=new kt.eventsExports.EventEmitter;const{renderer:e,scene:s,camera:i}=t,r=new oe.TransformControls(i,e.domElement);if(r.getHelper){const n=r.getHelper();if(s.add(n),+w.REVISION<170){const a=r._root;a.dispose=()=>{a.traverse(l=>{l.geometry&&l.geometry.dispose(),l.material&&l.material.dispose()})},r.dispose=()=>{r.disconnect(),a.dispose()}}}else r instanceof w.Object3D&&s.add(r);this.controls=r,this.addEvent()}get detach(){return this.controls.detach.bind(this.controls)}get attach(){return this.controls.attach.bind(this.controls)}addEvent(){let t=null,e=null,s=null;const i=this.controls;i.addEventListener("change",()=>{const r=i.object;r!==void 0&&this.event.emit("change",r)}),i.addEventListener("mouseDown",()=>{const r=i.object;t=r.position.clone(),e=r.rotation.clone(),s=r.scale.clone(),this.event.emit("mouseDown",r)}),i.addEventListener("mouseUp",()=>{const r=i.object;if(r!==void 0)switch(i.getMode()){case"translate":t.equals(r.position)||this.event.emit("translate",r,r.position,t);break;case"rotate":e.equals(r.rotation)||this.event.emit("rotate",r,r.rotation,e);break;case"scale":s.equals(r.scale)||this.event.emit("scale",r,r.scale,s);break}this.event.emit("mouseUp")})}dispose(){var t;this.event.removeAllListeners(),(t=this.controls)==null||t.dispose()}}const Rt=new M.Vector3,Se=new M.Quaternion,Lt=new M.Vector3,k=new M.Matrix4,De=new M.Matrix4;class be{constructor(t={}){const e=this;let s,i,r,n;const a={camera:{style:""},objects:new WeakMap},l=t.element!==void 0?t.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l;const d=document.createElement("div");d.style.transformOrigin="0 0",d.style.pointerEvents="none",l.appendChild(d);const y=document.createElement("div");y.style.transformStyle="preserve-3d",d.appendChild(y),this.getSize=function(){return{width:s,height:i}},this.render=function(_,o){const m=o.projectionMatrix.elements[5]*n;o.view&&o.view.enabled?(d.style.transform=`translate( ${-o.view.offsetX*(s/o.view.width)}px, ${-o.view.offsetY*(i/o.view.height)}px )`,d.style.transform+=`scale( ${o.view.fullWidth/o.view.width}, ${o.view.fullHeight/o.view.height} )`):d.style.transform="",_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),o.parent===null&&o.matrixWorldAutoUpdate===!0&&o.updateMatrixWorld();let O,g;o.isOrthographicCamera&&(O=-(o.right+o.left)/2,g=(o.top+o.bottom)/2);const x=o.view&&o.view.enabled?o.view.height/o.view.fullHeight:1,T=o.isOrthographicCamera?`scale( ${x} )scale(`+m+")translate("+c(O)+"px,"+c(g)+"px)"+E(o.matrixWorldInverse):`scale( ${x} )translateZ(`+m+"px)"+E(o.matrixWorldInverse),R=(o.isPerspectiveCamera?"perspective("+m+"px) ":"")+T+"translate("+r+"px,"+n+"px)";a.camera.style!==R&&(y.style.transform=R,a.camera.style=R),p(_,_,o)},this.setSize=function(_,o){s=_,i=o,r=s/2,n=i/2,l.style.width=_+"px",l.style.height=o+"px",d.style.width=_+"px",d.style.height=o+"px",y.style.width=_+"px",y.style.height=o+"px"};function c(_){return Math.abs(_)<1e-10?0:_}function E(_){const o=_.elements;return"matrix3d("+c(o[0])+","+c(-o[1])+","+c(o[2])+","+c(o[3])+","+c(o[4])+","+c(-o[5])+","+c(o[6])+","+c(o[7])+","+c(o[8])+","+c(-o[9])+","+c(o[10])+","+c(o[11])+","+c(o[12])+","+c(-o[13])+","+c(o[14])+","+c(o[15])+")"}function C(_){const o=_.elements;return"translate(-50%,-50%)"+("matrix3d("+c(o[0])+","+c(o[1])+","+c(o[2])+","+c(o[3])+","+c(-o[4])+","+c(-o[5])+","+c(-o[6])+","+c(-o[7])+","+c(o[8])+","+c(o[9])+","+c(o[10])+","+c(o[11])+","+c(o[12])+","+c(o[13])+","+c(o[14])+","+c(o[15])+")")}function f(_){_.isCSS3DObject&&(_.element.style.display="none");for(let o=0,m=_.children.length;o<m;o++)f(_.children[o])}function p(_,o,m,O){if(_.visible===!1){f(_);return}if(_.isCSS3DObject){const g=_.layers.test(m.layers)===!0,x=_.element;if(x.style.display=g===!0?"":"none",g===!0){_.onBeforeRender(e,o,m);let T;_.isCSS3DSprite?(k.copy(m.matrixWorldInverse),k.transpose(),_.rotation2D!==0&&k.multiply(De.makeRotationZ(_.rotation2D)),_.matrixWorld.decompose(Rt,Se,Lt),k.setPosition(Rt),k.scale(Lt),k.elements[3]=0,k.elements[7]=0,k.elements[11]=0,k.elements[15]=1,T=C(k)):T=C(_.matrixWorld);const b=a.objects.get(_);if(b===void 0||b.style!==T){x.style.transform=T;const R={style:T};a.objects.set(_,R)}x.parentNode!==y&&y.appendChild(x),_.onAfterRender(e,o,m)}}for(let g=0,x=_.children.length;g<x;g++)p(_.children[g],o,m)}}}const j=new M.Vector3,Mt=new M.Matrix4,zt=new M.Matrix4,Ft=new M.Vector3,Ht=new M.Vector3;class Ue{constructor(t={}){const e=this;let s,i,r,n;const a={objects:new WeakMap},l=t.element!==void 0?t.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:s,height:i}},this.render=function(f,p){f.matrixWorldAutoUpdate===!0&&f.updateMatrixWorld(),p.parent===null&&p.matrixWorldAutoUpdate===!0&&p.updateMatrixWorld(),Mt.copy(p.matrixWorldInverse),zt.multiplyMatrices(p.projectionMatrix,Mt),y(f,f,p),C(f)},this.setSize=function(f,p){s=f,i=p,r=s/2,n=i/2,l.style.width=f+"px",l.style.height=p+"px"};function d(f){f.isCSS2DObject&&(f.element.style.display="none");for(let p=0,_=f.children.length;p<_;p++)d(f.children[p])}function y(f,p,_){if(f.visible===!1){d(f);return}if(f.isCSS2DObject){j.setFromMatrixPosition(f.matrixWorld),j.applyMatrix4(zt);const o=j.z>=-1&&j.z<=1&&f.layers.test(_.layers)===!0,m=f.element;m.style.display=o===!0?"":"none",o===!0&&(f.onBeforeRender(e,p,_),m.style.transform="translate("+-100*f.center.x+"%,"+-100*f.center.y+"%)translate("+(j.x*r+r)+"px,"+(-j.y*n+n)+"px)",m.parentNode!==l&&l.appendChild(m),f.onAfterRender(e,p,_));const O={distanceToCameraSquared:c(_,f)};a.objects.set(f,O)}for(let o=0,m=f.children.length;o<m;o++)y(f.children[o],p,_)}function c(f,p){return Ft.setFromMatrixPosition(f.matrixWorld),Ht.setFromMatrixPosition(p.matrixWorld),Ft.distanceToSquared(Ht)}function E(f){const p=[];return f.traverseVisible(function(_){_.isCSS2DObject&&p.push(_)}),p}function C(f){const p=E(f).sort(function(o,m){if(o.renderOrder!==m.renderOrder)return m.renderOrder-o.renderOrder;const O=a.objects.get(o).distanceToCameraSquared,g=a.objects.get(m).distanceToCameraSquared;return O-g}),_=p.length;for(let o=0,m=p.length;o<m;o++)p[o].element.style.zIndex=_-o}}}const It={zIndex:"auto"};class Ae{constructor(t){this.container=t}addRenderer(t,e){const s=e.container||this.container,i=s.offsetWidth,r=s.offsetHeight,n=t==="css2d"?new Ue:new be;n.domElement.style.position="absolute",n.domElement.style.top="0",n.domElement.style.pointerEvents="none",n.domElement.style.zIndex=e.zIndex,n.setSize(i,r),s.appendChild(n.domElement),t==="css2d"?this.css2Drenderer=n:t==="css3d"&&(this.css3Drenderer=n)}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 Re={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1},premultiplieAlpha:{value:0}},vertexShader:`
|
|
2
2
|
precision highp float;
|
|
3
3
|
|
|
4
4
|
uniform mat4 modelViewMatrix;
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
|
|
71
71
|
#endif
|
|
72
72
|
|
|
73
|
-
}`};class Le extends le.OutputPass{constructor(){super();const t=Re;this.uniforms=
|
|
73
|
+
}`};class Le extends le.OutputPass{constructor(){super();const t=Re;this.uniforms=M.UniformsUtils.clone(t.uniforms),this.material=new M.RawShaderMaterial({name:t.name,uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.fsQuad=new he.FullScreenQuad(this.material)}}const Me=u=>{const t=new ce.ShaderPass(new w.ShaderMaterial({uniforms:{baseTexture:{value:null},bloomTexture:{value:u.renderTarget2.texture},bloomAlphaType:{value:0}},vertexShader:`
|
|
74
74
|
varying vec2 vUv;
|
|
75
75
|
void main() {
|
|
76
76
|
vUv = uv;
|
|
@@ -91,4 +91,4 @@
|
|
|
91
91
|
gl_FragColor = ( base_color + vec4( 1.0 ) * bloom_color );
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
`,defines:{}}),"baseTexture");return t.needsSwap=!0,t},Ct=1,j=!1,Me=new w.MeshBasicMaterial({color:"black"}),Fe=new w.SpriteMaterial({color:"black",sizeAttenuation:!0}),He=new w.SpriteMaterial({color:"black",sizeAttenuation:!1}),Ie={kernelRadius:8,minDistance:.005,maxDistance:.1},ke={threshold:0,strength:.4,radius:.1,bloomAlphaType:0},Ve={multisampling:4,premultiplieAlpha:!1};class Be{constructor(t){this.bloomComposerActive=!1,this.active=!0,this.bloomSelection=new Set,this.bloomLayer=new w.Layers,this.bloomMaterials={},this.bloomVisible={},this.options=t;const{renderer:e,scene:s,camera:i,composerParams:r}=t,{multisampling:n}=r,{maxSamples:a}=e.capabilities,l=e.getDrawingBufferSize(new w.Vector2),d=new w.WebGLRenderTarget(l.width,l.height,{samples:Math.min(n,a),type:w.HalfFloatType}),y=new ne.RenderPass(s,i),c=new Tt.EffectComposer(e,d);c.addPass(y),this.renderer=e,this.scene=s,this.camera=i,this.finalComposer=c,this.renderPass=y;const E=e.getSize(new w.Vector2);this.setSize(E.width,E.height)}setRenderPassCamera(t){this.renderPass.camera=t}resetRenderPassCamera(){this.renderPass.camera=this.camera}addOutputPass(){const{premultiplieAlpha:t}=this.options.composerParams,e=new Le;this.outputPass=e,this.setPremultiplieAlpha(t),this.finalComposer.addPass(e)}setPremultiplieAlpha(t){this.outputPass&&(this.outputPass.uniforms.premultiplieAlpha.value=t?1:0)}addSSAOPass(t){const{scene:e,camera:s,renderer:i}=this,r=i.getSize(new w.Vector2),n=r.width,a=r.height,l=new ae.SSAOPass(e,s,n,a);l.kernelRadius=t.kernelRadius,l.minDistance=t.minDistance,l.maxDistance=t.maxDistance,this.ssaoPass=l,this.finalComposer.addPass(l)}addSSAOGui(t){if(!this.ssaoPass)return;new ht({ssao:{kernelRadius:{min:0,max:32,target:()=>this.ssaoPass},minDistance:{min:.001,max:.02,target:()=>this.ssaoPass},maxDistance:{min:.01,max:.3,target:()=>this.ssaoPass}}}).showGui(t)}addBloomPass(t){const{renderer:e}=this,{threshold:s,strength:i,radius:r,bloomAlphaType:n}=t,a=new de.UnrealBloomPass(new w.Vector2(window.innerWidth,window.innerHeight),i,r,s);this.bloomPass=a;const l=new Tt.EffectComposer(e);l.renderToScreen=!1,l.addPass(this.renderPass),l.addPass(a),this.bloomComposer=l;const d=ze(l);d.uniforms.bloomAlphaType.value=n,this.bloomComposer=l,this.finalComposer.addPass(d),this.mixPass=d,this.bloomLayer.set(Ct)}addBloomGui(t){if(!this.bloomComposer)return;new ht({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(Ct)):(this.bloomSelection.delete(s),s.layers.disable(Ct)),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)}setPixelRatio(t){var e;(e=this.bloomComposer)==null||e.setPixelRatio(t),this.finalComposer.setPixelRatio(t)}darkenNonBloomed(){const t=[],e=[];this.scene.children.forEach(s=>{s.isTransformControls||s.isTransformControlsRoot||s.type==="RectAreaLightHelper"?t.push(s):e.push(s)}),t.forEach(s=>{this.bloomVisible[s.uuid]=s.visible,s.visible=!1}),e.forEach(s=>{s.traverse(i=>{const r=i,n=i;r.material&&this.bloomLayer.test(r.layers)===!1&&(this.bloomMaterials[r.uuid]=r.material,n.isSprite?n.material.sizeAttenuation?n.material=Fe:n.material=He:r.material=Me)})})}restoreNonBloomed(){this.scene.traverse(t=>{const e=t;this.bloomMaterials[e.uuid]?(e.material=this.bloomMaterials[e.uuid],delete this.bloomMaterials[e.uuid]):this.bloomVisible[e.uuid]!==void 0&&(e.visible=this.bloomVisible[e.uuid],delete this.bloomVisible[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.bloomVisible={},this.bloomSelection.clear(),this.finalComposer.dispose(),(t=this.bloomComposer)==null||t.dispose()}}const ct=class ct{constructor(t,e){this.raycaster=new w.Raycaster,this.maxBackufferArea=5760*5760,this.installPlugins=new Map,this._cameraPositon=new w.Vector3,this._cameraTarget=new w.Vector3,this.event=new kt.eventsExports.EventEmitter,this.clock=new w.Clock,this.userData={},this.dprCache=1,this.pipViewportState=!1,this.options=$t(ct.options,t,{isMergeableObject:me.isPlainObject}),this.dprCache=this.options.renderer.devicePixelRatio,this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:r,resizeObserver:n}=this.options;if(r){const a=new te;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(),n&&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 controls(){return this.controlsController.cameraControls}get cameraPositon(){return this.controls.getPosition(this._cameraPositon,!1)}get cameraTarget(){return this.controls.getTarget(this._cameraTarget,!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,viewHelper:r,renderer:n,scene:a,camera:l,controls:d}=this.options,{width:y,height:c}=this.getSize(),E=new Ee({isdev:e,width:y,height:c,cameraParams:l,cameraControls:d===!0});this.gui&&E.setGui(this.gui);const C=E.camera,f=new ve({camera:C,sceneParams:a}),p=f.scene,_=s?new Ce({width:y,height:c,scene:p,camera:C,isdev:e,renderer:s.WebGPURenderer,rendererParams:ye}):new ge({width:y,height:c,scene:p,camera:C,isdev:e,rendererParams:mt(B({},n),{antialias:!1})});if(i){const o=new xe({container:t,scene:p,camera:C});o.add(p),this.helperController=o,r&&o.addViewHelper()}this.sceneController=f,this.rendererController=_,this.cameraController=E,t.appendChild(_.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,ssao:s,ssaoParams:i,composer:r}=this.options,n=new Be({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:r});this.composerController=n,t&&(n.addBloomPass(B({},e)),this.gui&&n.addBloomGui(this.gui)),s&&(n.addSSAOPass(B({},i)),this.gui&&n.addSSAOGui(this.gui)),n.addOutputPass()}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:r}=this.options;if(e||s){const n=new Ae(t);e&&n.addRenderer("css2d",i),s&&n.addRenderer("css3d",r),this.cssRendererController=n}}initControls(){const{controls:t,controlsParams:e,transformControls:s}=this.options;if(t){const i=new we({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControls:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new Pe({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var r;(r=this.controlsController)==null||r.disable()}),i.event.on("mouseUp",()=>{var r;(r=this.controlsController)==null||r.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=new ResizeObserver(s=>{for(const i of s){const r=i.contentRect;this.handeleResize(r.width,r.height),this.checkBackufferArea()}});e.observe(t),this.resizeObserver=e}checkBackufferArea(t=this.maxBackufferArea){t>this.maxBackufferArea&&(t=this.maxBackufferArea);const e=this.dprCache,{width:s,height:i}=this.getSize();let r=Math.sqrt(t/(s*i));r=(r*100|0)/100;const n=Math.min(e,r);this.setDevicePixelRatio(n),this.dprCache=e,n!==e&&console.warn("maxBackufferArea:",t," the pixel ratio is set to",n)}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:r,composerController:n,cssRendererController:a}=this,l=this.renderer.getSize(new w.Vector2);l.x===t&&l.y===e||(r==null||r.setSize(t,e),i==null||i.setSize(t,e),n==null||n.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(d=>{var y;(y=d.setSize)==null||y.call(d,t,e)}),this.render(),s&&this.event.emit("resize",{width:t,height:e}))}setDevicePixelRatio(t){var s;const e=this.renderer.getPixelRatio();t!==e&&(this.dprCache=t,this.rendererController.setPixelRatio(t),(s=this.composerController)==null||s.setPixelRatio(t))}pick(t,e,s=!0){const{raycaster:i,options:r}=this,{container:n}=r,a=new w.Vector2,l=n.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 d=i.intersectObjects(e||this.scene.children,s);if(d.length)return{object:d[0].object,intersects:d}}}render(){var n,a,l,d,y,c,E;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),r=s.getElapsedTime();vt.update(),(n=this.controlsController)==null||n.update(i),this.installPlugins.forEach(C=>{var f;(f=C.update)==null||f.call(C,i,r)}),(a=this.helperController)==null||a.update(i,this.controlsController,this.cameraTarget),(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():(d=this.rendererController)==null||d.render(),(y=this.helperController)==null||y.renderViewHelper(this.renderer),(c=this.cssRendererController)==null||c.render(t,e),(E=this.stats)==null||E.update(),this.event.emit("render",{delta:i,elapsed:r})}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,r=s/e.height,n=1-i,a=1-r;t={left:n,top:a,width:i,height:r}}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,r=t.height,n=i/r;this.camera.aspect!==n&&(this.camera.aspect=n,this.camera.updateProjectionMatrix()),this.renderer.setViewport(e,s,i,r),this.renderer.setScissor(e,s,i,r),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,r=e.width*t.width,n=e.height*t.height,a=r/n,l=this.cameraController.camera2;l&&l.aspect!==a&&(l.aspect=a,l.updateProjectionMatrix()),this.renderer.setViewport(s,i,r,n),this.renderer.setScissor(s,i,r,n),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,r,n,a,l,d,y,c;this.stop(),vt.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(E=>{var C;(C=E.dispose)==null||C.call(E)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(r=this.sceneController)==null||r.dispose(),(n=this.helperController)==null||n.dispose(),(a=this.composerController)==null||a.dispose(),(l=this.rendererController)==null||l.dispose(),this.cssRendererController=void 0,(d=this.gui)==null||d.destroy(),this.installPlugins.clear(),(y=this.stats)==null||y.dom.remove(),(c=this.renderer)==null||c.domElement.remove()}};ct.options={isdev:j,stats:j,gui:j,helper:j,viewHelper:j,controls:!0,transformControls:j,resizeObserver:!0,renderer:fe,composer:Ve,scene:Te,camera:Oe,bloom:!1,bloomParams:ke,ssao:!1,ssaoParams:Ie,css2DRenderer:!1,css2DRendererParams:B({},It),css3DRenderer:!1,css3DRendererParams:B({},It)};let lt=ct;const Ne=Z.ACTION;exports.BaseObject=pe.BaseObject;exports.GUIObject=ht;exports.Pencil=lt;exports.cameraControlsAction=Ne;exports.default=lt;
|
|
94
|
+
`,defines:{}}),"baseTexture");return t.needsSwap=!0,t},Ct=1,K=!1,ze=new w.MeshBasicMaterial({color:"black"}),Fe=new w.SpriteMaterial({color:"black",sizeAttenuation:!0}),He=new w.SpriteMaterial({color:"black",sizeAttenuation:!1}),Ie={kernelRadius:8,minDistance:.005,maxDistance:.1},ke={threshold:0,strength:.4,radius:.1,bloomAlphaType:0},Ve={multisampling:4,premultiplieAlpha:!1};class Be{constructor(t){this.bloomComposerActive=!1,this.active=!0,this.bloomSelection=new Set,this.bloomLayer=new w.Layers,this.bloomMaterials={},this.bloomVisible={},this.options=t;const{renderer:e,scene:s,camera:i,composerParams:r}=t,{multisampling:n}=r,{maxSamples:a}=e.capabilities,l=e.getDrawingBufferSize(new w.Vector2),d=new w.WebGLRenderTarget(l.width,l.height,{samples:Math.min(n,a),type:w.HalfFloatType}),y=new ne.RenderPass(s,i),c=new Tt.EffectComposer(e,d);c.addPass(y),this.renderer=e,this.scene=s,this.camera=i,this.finalComposer=c,this.renderPass=y;const E=e.getSize(new w.Vector2);this.setSize(E.width,E.height)}setRenderPassCamera(t){this.renderPass.camera=t}resetRenderPassCamera(){this.renderPass.camera=this.camera}addOutputPass(){const{premultiplieAlpha:t}=this.options.composerParams,e=new Le;this.outputPass=e,this.setPremultiplieAlpha(t),this.finalComposer.addPass(e)}setPremultiplieAlpha(t){this.outputPass&&(this.outputPass.uniforms.premultiplieAlpha.value=t?1:0)}addSSAOPass(t){const{scene:e,camera:s,renderer:i}=this,r=i.getSize(new w.Vector2),n=r.width,a=r.height,l=new ae.SSAOPass(e,s,n,a);l.kernelRadius=t.kernelRadius,l.minDistance=t.minDistance,l.maxDistance=t.maxDistance,this.ssaoPass=l,this.finalComposer.addPass(l)}addSSAOGui(t){if(!this.ssaoPass)return;new ht({ssao:{kernelRadius:{min:0,max:32,target:()=>this.ssaoPass},minDistance:{min:.001,max:.02,target:()=>this.ssaoPass},maxDistance:{min:.01,max:.3,target:()=>this.ssaoPass}}}).showGui(t)}addBloomPass(t){const{renderer:e}=this,{threshold:s,strength:i,radius:r,bloomAlphaType:n}=t,a=new de.UnrealBloomPass(new w.Vector2(window.innerWidth,window.innerHeight),i,r,s);this.bloomPass=a;const l=new Tt.EffectComposer(e);l.renderToScreen=!1,l.addPass(this.renderPass),l.addPass(a),this.bloomComposer=l;const d=Me(l);d.uniforms.bloomAlphaType.value=n,this.bloomComposer=l,this.finalComposer.addPass(d),this.mixPass=d,this.bloomLayer.set(Ct)}addBloomGui(t){if(!this.bloomComposer)return;new ht({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.traverse(r=>{r.layers.enable(Ct)})):(this.bloomSelection.delete(s),s.traverse(r=>{r.layers.disable(Ct)})),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)}setPixelRatio(t){var e;(e=this.bloomComposer)==null||e.setPixelRatio(t),this.finalComposer.setPixelRatio(t)}darkenNonBloomed(){const t=[],e=[];this.scene.children.forEach(s=>{s.isTransformControls||s.isTransformControlsRoot||s.type==="RectAreaLightHelper"?t.push(s):e.push(s)}),t.forEach(s=>{this.bloomVisible[s.uuid]=s.visible,s.visible=!1}),e.forEach(s=>{s.traverse(i=>{const r=i,n=i;r.material&&this.bloomLayer.test(r.layers)===!1&&(this.bloomMaterials[r.uuid]=r.material,n.isSprite?n.material.sizeAttenuation?n.material=Fe:n.material=He:r.material=ze)})})}restoreNonBloomed(){this.scene.traverse(t=>{const e=t;this.bloomMaterials[e.uuid]?(e.material=this.bloomMaterials[e.uuid],delete this.bloomMaterials[e.uuid]):this.bloomVisible[e.uuid]!==void 0&&(e.visible=this.bloomVisible[e.uuid],delete this.bloomVisible[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.bloomVisible={},this.bloomSelection.clear(),this.finalComposer.dispose(),(t=this.bloomComposer)==null||t.dispose()}}const ct=class ct{constructor(t,e){this.raycaster=new w.Raycaster,this.maxBackufferArea=5760*5760,this.installPlugins=new Map,this._cameraPositon=new w.Vector3,this._cameraTarget=new w.Vector3,this.event=new kt.eventsExports.EventEmitter,this.clock=new w.Clock,this.userData={},this.dprCache=1,this.pipViewportState=null,this.options=$t(ct.options,t,{isMergeableObject:me.isPlainObject}),this.dprCache=this.options.renderer.devicePixelRatio,this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:r,resizeObserver:n}=this.options;if(r){const a=new te;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(),n&&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 controls(){return this.controlsController.cameraControls}get cameraPositon(){return this.controls.getPosition(this._cameraPositon,!1)}get cameraTarget(){return this.controls.getTarget(this._cameraTarget,!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,viewHelper:r,renderer:n,scene:a,camera:l,controls:d}=this.options,{width:y,height:c}=this.getSize(),E=new Ee({isdev:e,width:y,height:c,cameraParams:l,cameraControls:d===!0});this.gui&&E.setGui(this.gui);const C=E.camera,f=new ve({camera:C,sceneParams:a}),p=f.scene,_=s?new Ce({width:y,height:c,scene:p,camera:C,isdev:e,renderer:s.WebGPURenderer,rendererParams:ye}):new ge({width:y,height:c,scene:p,camera:C,isdev:e,rendererParams:mt(B({},n),{antialias:!1})});if(i){const o=new xe({container:t,scene:p,camera:C});o.add(p),this.helperController=o,r&&o.addViewHelper()}this.sceneController=f,this.rendererController=_,this.cameraController=E,t.appendChild(_.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,ssao:s,ssaoParams:i,composer:r}=this.options,n=new Be({renderer:this.renderer,scene:this.scene,camera:this.camera,composerParams:r});this.composerController=n,t&&(n.addBloomPass(B({},e)),this.gui&&n.addBloomGui(this.gui)),s&&(n.addSSAOPass(B({},i)),this.gui&&n.addSSAOGui(this.gui)),n.addOutputPass()}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:i,css3DRendererParams:r}=this.options;if(e||s){const n=new Ae(t);e&&n.addRenderer("css2d",i),s&&n.addRenderer("css3d",r),this.cssRendererController=n}}initControls(){const{controls:t,controlsParams:e,transformControls:s}=this.options;if(t){const i=new we({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControls:typeof t=="boolean"?void 0:t});this.controlsController=i}if(s){const i=new Pe({camera:this.camera,renderer:this.renderer,scene:this.scene});i.event.on("mouseDown",()=>{var r;(r=this.controlsController)==null||r.disable()}),i.event.on("mouseUp",()=>{var r;(r=this.controlsController)==null||r.enable()}),this.transformController=i}}getSize(){const{container:t}=this.options;return{width:t.offsetWidth,height:t.offsetHeight}}initResizeObserver(){const{container:t}=this.options;if(this.resizeObserver)return;const e=new ResizeObserver(s=>{for(const i of s){const r=i.contentRect;this.handeleResize(r.width,r.height),this.checkBackufferArea()}});e.observe(t),this.resizeObserver=e}checkBackufferArea(t=this.maxBackufferArea){t>this.maxBackufferArea&&(t=this.maxBackufferArea);const e=this.dprCache,{width:s,height:i}=this.getSize();let r=Math.sqrt(t/(s*i));r=(r*100|0)/100;const n=Math.min(e,r);this.setDevicePixelRatio(n),this.dprCache=e,n!==e&&console.warn("maxBackufferArea:",t," the pixel ratio is set to",n)}handeleResize(t,e,s=!0){const{rendererController:i,cameraController:r,composerController:n,cssRendererController:a}=this,l=this.renderer.getSize(new w.Vector2);l.x===t&&l.y===e||(r==null||r.setSize(t,e),i==null||i.setSize(t,e),n==null||n.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(d=>{var y;(y=d.setSize)==null||y.call(d,t,e)}),this.render(),s&&this.event.emit("resize",{width:t,height:e}))}setDevicePixelRatio(t){var s;const e=this.renderer.getPixelRatio();t!==e&&(this.dprCache=t,this.rendererController.setPixelRatio(t),(s=this.composerController)==null||s.setPixelRatio(t))}pick(t,e,s=!0){const{raycaster:i,options:r}=this,{container:n}=r,a=new w.Vector2,l=n.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 d=i.intersectObjects(e||this.scene.children,s);if(d.length)return{object:d[0].object,intersects:d}}}render(){var n,a,l,d,y,c,E;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),r=s.getElapsedTime();vt.update(),(n=this.controlsController)==null||n.update(i),this.installPlugins.forEach(C=>{var f;(f=C.update)==null||f.call(C,i,r)}),(a=this.helperController)==null||a.update(i,this.controlsController,this.cameraTarget),(l=this.composerController)!=null&&l.active?this.cameraController.camera2?(this.composerController.resetRenderPassCamera(),this.setViewportFull(),this.composerController.render(),this.pipViewportState&&(this.setViewportPip(this.pipViewportState),this.composerController.setRenderPassCamera(this.cameraController.camera2),this.composerController.render())):this.composerController.render():(d=this.rendererController)==null||d.render(),(y=this.helperController)==null||y.renderViewHelper(this.renderer),(c=this.cssRendererController)==null||c.render(t,e),(E=this.stats)==null||E.update(),this.event.emit("render",{delta:i,elapsed:r})}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}setViewPadding(t=0,e=0,s=0,i=0){const{width:r,height:n}=this.getSize(),a={x:i,y:s,width:r-i-e,height:n-t-s};this.renderer.setViewport(a.x,a.y,a.width,a.height);const l=a.width/a.height;this.camera.aspect!==l&&(this.camera.aspect=l,this.camera.updateProjectionMatrix())}showPipViewport(t){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 i=this.cameraController.addCamera2();this.controlsController.addCameraControls2(i)}const{width:e,height:s}=this.getSize();this.controlsController.cameraControls2.interactiveArea=new DOMRect(t.x/e,(s-t.y-t.height)/s,t.width/e,t.height/s)}else this.controlsController.cameraControls2&&(this.controlsController.cameraControls2.enabled=!1)}setViewportFull(){const t=this.getSize(),e=t.width,s=t.height,i=e/s;this.camera.aspect!==i&&(this.camera.aspect=i,this.camera.updateProjectionMatrix()),this.renderer.setViewport(0,0,e,s),this.renderer.setScissor(0,0,e,s),this.renderer.setScissorTest(!1)}setViewportPip(t){if(!t)return;const{width:e,height:s,x:i,y:r}=t,n=e/s,a=this.cameraController.camera2;a&&a.aspect!==n&&(a.aspect=n,a.updateProjectionMatrix()),this.renderer.setViewport(i,r,e,s),this.renderer.setScissor(i,r,e,s),this.renderer.setScissorTest(!0)}dispose(){var t,e,s,i,r,n,a,l,d,y,c;this.stop(),vt.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(E=>{var C;(C=E.dispose)==null||C.call(E)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(i=this.cssRendererController)==null||i.dispose(),(r=this.sceneController)==null||r.dispose(),(n=this.helperController)==null||n.dispose(),(a=this.composerController)==null||a.dispose(),(l=this.rendererController)==null||l.dispose(),this.cssRendererController=void 0,(d=this.gui)==null||d.destroy(),this.installPlugins.clear(),(y=this.stats)==null||y.dom.remove(),(c=this.renderer)==null||c.domElement.remove()}};ct.options={isdev:K,stats:K,gui:K,helper:K,viewHelper:K,controls:!0,transformControls:K,resizeObserver:!0,renderer:fe,composer:Ve,scene:Te,camera:Oe,bloom:!1,bloomParams:ke,ssao:!1,ssaoParams:Ie,css2DRenderer:!1,css2DRendererParams:B({},It),css3DRenderer:!1,css3DRendererParams:B({},It)};let lt=ct;const Ne=Z.ACTION;exports.BaseObject=pe.BaseObject;exports.GUIObject=ht;exports.Pencil=lt;exports.cameraControlsAction=Ne;exports.default=lt;
|
package/dist/index.module.js
CHANGED
|
@@ -2597,7 +2597,11 @@ class Ne {
|
|
|
2597
2597
|
if (!s)
|
|
2598
2598
|
return;
|
|
2599
2599
|
let i = e;
|
|
2600
|
-
e === void 0 && (i = !this.bloomSelection.has(s)), i ? (this.bloomSelection.add(s), s.
|
|
2600
|
+
e === void 0 && (i = !this.bloomSelection.has(s)), i ? (this.bloomSelection.add(s), s.traverse((o) => {
|
|
2601
|
+
o.layers.enable(yt);
|
|
2602
|
+
})) : (this.bloomSelection.delete(s), s.traverse((o) => {
|
|
2603
|
+
o.layers.disable(yt);
|
|
2604
|
+
})), this.bloomSelection.size === 0 ? this.bloomComposerActive = !1 : this.bloomComposerActive = !0;
|
|
2601
2605
|
}
|
|
2602
2606
|
enable() {
|
|
2603
2607
|
this.active || (this.active = !0);
|
|
@@ -2645,7 +2649,7 @@ class Ne {
|
|
|
2645
2649
|
}
|
|
2646
2650
|
const ht = class ht {
|
|
2647
2651
|
constructor(t, e) {
|
|
2648
|
-
this.raycaster = new w.Raycaster(), this.maxBackufferArea = 5760 * 5760, this.installPlugins = /* @__PURE__ */ new Map(), this._cameraPositon = new w.Vector3(), this._cameraTarget = new w.Vector3(), this.event = new Vt.EventEmitter(), this.clock = new w.Clock(), this.userData = {}, this.dprCache = 1, this.pipViewportState =
|
|
2652
|
+
this.raycaster = new w.Raycaster(), this.maxBackufferArea = 5760 * 5760, this.installPlugins = /* @__PURE__ */ new Map(), this._cameraPositon = new w.Vector3(), this._cameraTarget = new w.Vector3(), this.event = new Vt.EventEmitter(), this.clock = new w.Clock(), this.userData = {}, this.dprCache = 1, this.pipViewportState = null, this.options = te(ht.options, t, {
|
|
2649
2653
|
isMergeableObject: _e
|
|
2650
2654
|
}), this.dprCache = this.options.renderer.devicePixelRatio, this.event.setMaxListeners(1 / 0);
|
|
2651
2655
|
const {
|
|
@@ -2875,7 +2879,7 @@ const ht = class ht {
|
|
|
2875
2879
|
i,
|
|
2876
2880
|
this.controlsController,
|
|
2877
2881
|
this.cameraTarget
|
|
2878
|
-
), (l = this.composerController) != null && l.active ? this.cameraController.camera2 ? (this.composerController.resetRenderPassCamera(), this.setViewportFull(), this.composerController.render(), this.pipViewportState && (this.setViewportPip(), this.composerController.setRenderPassCamera(
|
|
2882
|
+
), (l = this.composerController) != null && l.active ? this.cameraController.camera2 ? (this.composerController.resetRenderPassCamera(), this.setViewportFull(), this.composerController.render(), this.pipViewportState && (this.setViewportPip(this.pipViewportState), this.composerController.setRenderPassCamera(
|
|
2879
2883
|
this.cameraController.camera2
|
|
2880
2884
|
), this.composerController.render())) : this.composerController.render() : (d = this.rendererController) == null || d.render(), (y = this.helperController) == null || y.renderViewHelper(this.renderer), (c = this.cssRendererController) == null || c.render(t, e), (E = this.stats) == null || E.update(), this.event.emit("render", { delta: i, elapsed: o });
|
|
2881
2885
|
}
|
|
@@ -2888,42 +2892,50 @@ const ht = class ht {
|
|
|
2888
2892
|
autoRotate(t) {
|
|
2889
2893
|
this.controlsController.autoRotateSpeed = t;
|
|
2890
2894
|
}
|
|
2895
|
+
setViewPadding(t = 0, e = 0, s = 0, i = 0) {
|
|
2896
|
+
const { width: o, height: n } = this.getSize(), a = {
|
|
2897
|
+
x: i,
|
|
2898
|
+
y: s,
|
|
2899
|
+
width: o - i - e,
|
|
2900
|
+
height: n - t - s
|
|
2901
|
+
};
|
|
2902
|
+
this.renderer.setViewport(
|
|
2903
|
+
a.x,
|
|
2904
|
+
a.y,
|
|
2905
|
+
a.width,
|
|
2906
|
+
a.height
|
|
2907
|
+
);
|
|
2908
|
+
const l = a.width / a.height;
|
|
2909
|
+
this.camera.aspect !== l && (this.camera.aspect = l, this.camera.updateProjectionMatrix());
|
|
2910
|
+
}
|
|
2891
2911
|
showPipViewport(t) {
|
|
2892
|
-
if (t === !0) {
|
|
2893
|
-
const e = this.getSize(), s = 240, i = s / e.width, o = s / e.height, n = 1 - i, a = 1 - o;
|
|
2894
|
-
t = {
|
|
2895
|
-
left: n,
|
|
2896
|
-
top: a,
|
|
2897
|
-
width: i,
|
|
2898
|
-
height: o
|
|
2899
|
-
};
|
|
2900
|
-
}
|
|
2901
2912
|
if (this.pipViewportState = t, t) {
|
|
2902
2913
|
if (this.controlsController.cameraControls2)
|
|
2903
2914
|
this.controlsController.cameraControls2.enabled = !0, this.cameraController.camera2.position.copy(
|
|
2904
2915
|
this.cameraController.camera.position
|
|
2905
2916
|
);
|
|
2906
2917
|
else {
|
|
2907
|
-
const
|
|
2908
|
-
this.controlsController.addCameraControls2(
|
|
2918
|
+
const i = this.cameraController.addCamera2();
|
|
2919
|
+
this.controlsController.addCameraControls2(i);
|
|
2909
2920
|
}
|
|
2921
|
+
const { width: e, height: s } = this.getSize();
|
|
2910
2922
|
this.controlsController.cameraControls2.interactiveArea = new DOMRect(
|
|
2911
|
-
t.
|
|
2912
|
-
t.
|
|
2913
|
-
t.width,
|
|
2914
|
-
t.height
|
|
2923
|
+
t.x / e,
|
|
2924
|
+
(s - t.y - t.height) / s,
|
|
2925
|
+
t.width / e,
|
|
2926
|
+
t.height / s
|
|
2915
2927
|
);
|
|
2916
2928
|
} else
|
|
2917
2929
|
this.controlsController.cameraControls2 && (this.controlsController.cameraControls2.enabled = !1);
|
|
2918
2930
|
}
|
|
2919
2931
|
setViewportFull() {
|
|
2920
|
-
const t = this.getSize(), e =
|
|
2921
|
-
this.camera.aspect !==
|
|
2932
|
+
const t = this.getSize(), e = t.width, s = t.height, i = e / s;
|
|
2933
|
+
this.camera.aspect !== i && (this.camera.aspect = i, this.camera.updateProjectionMatrix()), this.renderer.setViewport(0, 0, e, s), this.renderer.setScissor(0, 0, e, s), this.renderer.setScissorTest(!1);
|
|
2922
2934
|
}
|
|
2923
|
-
setViewportPip() {
|
|
2924
|
-
if (!
|
|
2925
|
-
const
|
|
2926
|
-
|
|
2935
|
+
setViewportPip(t) {
|
|
2936
|
+
if (!t) return;
|
|
2937
|
+
const { width: e, height: s, x: i, y: o } = t, n = e / s, a = this.cameraController.camera2;
|
|
2938
|
+
a && a.aspect !== n && (a.aspect = n, a.updateProjectionMatrix()), this.renderer.setViewport(i, o, e, s), this.renderer.setScissor(i, o, e, s), this.renderer.setScissorTest(!0);
|
|
2927
2939
|
}
|
|
2928
2940
|
dispose() {
|
|
2929
2941
|
var t, e, s, i, o, n, a, l, d, y, c;
|