gl-draw 0.12.16 → 0.12.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,20 +15,19 @@ export declare const defaultCameraParams: {
15
15
  interface Options {
16
16
  width: number;
17
17
  height: number;
18
- cameraParams: CameraParams | THREE.PerspectiveCamera;
19
- cameraControls?: boolean;
20
18
  }
21
19
  export default class {
22
20
  event: EventEmitter;
23
- options: Options;
24
21
  cameraArr: THREE.PerspectiveCamera[];
25
22
  cameraActiveIndex: number;
26
23
  get camera(): THREE.PerspectiveCamera;
27
24
  customCamera: boolean;
25
+ width: number;
26
+ height: number;
28
27
  constructor(options: Options);
29
28
  addPerspectiveCamera(cameraParams: {
30
29
  fov: number;
31
- aspect: number;
30
+ aspect?: number;
32
31
  near: number;
33
32
  far: number;
34
33
  up: THREE.Vector3;
@@ -6,14 +6,11 @@ export interface ControlsParams {
6
6
  }
7
7
  export declare const defaultControlsParams: {};
8
8
  interface Options {
9
- camera: THREE.PerspectiveCamera | THREE.OrthographicCamera;
10
9
  controlsParams: ControlsParams;
11
- customControls?: any;
12
10
  }
13
11
  export default class {
14
12
  event: EventEmitter;
15
13
  options: Options;
16
- customControls?: any;
17
14
  cameraControlsArr: CameraControls[];
18
15
  cameraControlsActiveIndex: number;
19
16
  get cameraControls(): CameraControls;
@@ -24,7 +24,6 @@ interface Options {
24
24
  controls?: boolean | any;
25
25
  controlsParams?: Partial<ControlsParams>;
26
26
  transformControls?: boolean;
27
- resizeObserver?: boolean;
28
27
  renderer?: Partial<RendererParams>;
29
28
  composer?: Partial<ComposerParams>;
30
29
  scene?: Partial<SceneParams>;
@@ -85,7 +84,6 @@ export default class Pencil {
85
84
  viewHelper: boolean;
86
85
  controls: boolean;
87
86
  transformControls: boolean;
88
- resizeObserver: boolean;
89
87
  renderer: {
90
88
  antialias: boolean;
91
89
  devicePixelRatio: number;
@@ -105,7 +103,6 @@ export default class Pencil {
105
103
  };
106
104
  scene: {
107
105
  background: null;
108
- addCamera: boolean;
109
106
  };
110
107
  camera: {
111
108
  fov: number;
@@ -137,10 +134,16 @@ export default class Pencil {
137
134
  };
138
135
  constructor(options: Options, plugin?: any);
139
136
  use(plugin: any, ...args: any[]): void;
137
+ pageActiveIndex: number;
138
+ addPage({ sceneOptions, cameraOptions, }: {
139
+ sceneOptions?: SceneParams;
140
+ cameraOptions: CameraParams;
141
+ }): number;
142
+ showPage(index: number): void;
140
143
  private init;
141
144
  private initComposer;
142
145
  private initCSSRenderer;
143
- private initControls;
146
+ private initTransformControls;
144
147
  getSize(): {
145
148
  width: number;
146
149
  height: number;
@@ -1,7 +1,5 @@
1
1
  import * as THREE from 'three';
2
2
  import { ColorSpace } from "../utils/colorCorrection";
3
- import SceneController from './Scene';
4
- import CameraController from './Camera';
5
3
  export interface RendererParams {
6
4
  antialias: boolean;
7
5
  devicePixelRatio: number;
@@ -33,8 +31,6 @@ export declare const defaultRendererParams: {
33
31
  interface Options {
34
32
  width: number;
35
33
  height: number;
36
- sceneController: SceneController;
37
- cameraController: CameraController;
38
34
  rendererParams: RendererParams;
39
35
  }
40
36
  export default class {
@@ -43,7 +39,7 @@ export default class {
43
39
  constructor(options: Options);
44
40
  setSize(width: number, height: number): void;
45
41
  setPixelRatio(ratio: number): void;
46
- render(): void;
42
+ render(scene: THREE.Scene, camera: THREE.Camera): void;
47
43
  setViewport(op: {
48
44
  x: number;
49
45
  y: number;
@@ -1,17 +1,12 @@
1
1
  import * as THREE from 'three';
2
2
  import { EventEmitter } from 'events';
3
- import CameraController from './Camera';
4
3
  export interface SceneParams {
5
4
  background: THREE.Scene['background'];
6
- addCamera?: boolean;
7
5
  }
8
6
  export declare const defaultSceneParams: {
9
7
  background: null;
10
- addCamera: boolean;
11
8
  };
12
9
  interface Options {
13
- cameraController: CameraController;
14
- sceneParams: SceneParams;
15
10
  }
16
11
  export default class {
17
12
  options: Options;
@@ -21,7 +16,7 @@ export default class {
21
16
  get scene(): THREE.Scene;
22
17
  overrideMaterial: boolean;
23
18
  constructor(options: Options);
24
- addScene(): THREE.Scene;
19
+ addScene(sceneParams?: SceneParams): THREE.Scene;
25
20
  setSceneActive(index: number): void;
26
21
  dispose(): void;
27
22
  }
@@ -1,5 +1,4 @@
1
- import SceneController from './Scene';
2
- import CameraController from './Camera';
1
+ import * as THREE from 'three';
3
2
  export interface WebGPURendererParams {
4
3
  antialias: boolean;
5
4
  devicePixelRatio: number;
@@ -11,8 +10,6 @@ export declare const defaultWebGPURendererParams: {
11
10
  interface Options {
12
11
  width: number;
13
12
  height: number;
14
- sceneController: SceneController;
15
- cameraController: CameraController;
16
13
  renderer: any;
17
14
  rendererParams: WebGPURendererParams;
18
15
  }
@@ -21,7 +18,7 @@ export default class {
21
18
  options: Options;
22
19
  constructor(options: Options);
23
20
  setSize(width: number, height: number): void;
24
- render(): void;
21
+ render(scene: THREE.Scene, camera: THREE.Camera): void;
25
22
  dispose(): void;
26
23
  }
27
24
  export {};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Gt=Object.defineProperty,Xt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Ot=Object.getOwnPropertySymbols;var jt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Tt=(f,t,e)=>t in f?Gt(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e,V=(f,t)=>{for(var e in t||(t={}))jt.call(t,e)&&Tt(f,e,t[e]);if(Ot)for(var e of Ot(t))Qt.call(t,e)&&Tt(f,e,t[e]);return f},ot=(f,t)=>Xt(f,Kt(t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const z=require("three"),$t=require("@tweenjs/tween.js"),st=require("./events.js"),Jt=require("deepmerge"),te=require("stats-gl"),ee=require("lil-gui"),se=require("./colorCorrection.js"),ie=require("./parseVector.js");require("idb-keyval");require("esus-lite");require("d3-geo");require("d3-geo-projection");const re=require("three/examples/jsm/helpers/RectAreaLightHelper"),oe=require("three/examples/jsm/helpers/ViewHelper"),ne=require("three/examples/jsm/controls/TransformControls"),vt=require("three/examples/jsm/postprocessing/EffectComposer"),ae=require("three/examples/jsm/postprocessing/RenderPass"),he=require("three/examples/jsm/postprocessing/SSAOPass"),le=require("three/examples/jsm/postprocessing/Pass"),ce=require("three/examples/jsm/postprocessing/OutputPass"),de=require("three/examples/jsm/postprocessing/ShaderPass"),me=require("three/examples/jsm/postprocessing/UnrealBloomPass");require("three/examples/jsm/renderers/CSS2DRenderer");require("three/examples/jsm/renderers/CSS3DRenderer");require("three/examples/jsm/lights/RectAreaLightUniformsLib");require("three/examples/jsm/lines/LineSegments2");const Vt=require("./index2.js");require("three/examples/jsm/lines/LineSegmentsGeometry");require("three/examples/jsm/lines/LineMaterial");require("three-bvh-csg");const pe=require("./isPlainObject.js"),_e=require("./BaseObject.js");function Bt(f){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const e in f)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(f,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>f[e]})}}return t.default=f,Object.freeze(t)}const w=Bt(z),xt=Bt($t),U={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}),Z={NONE:0,IN:1,OUT:-1};function N(f){return f.isPerspectiveCamera}function B(f){return f.isOrthographicCamera}const q=Math.PI*2,wt=Math.PI/2,Nt=1e-5,Q=Math.PI/180;function F(f,t,e){return Math.max(t,Math.min(e,f))}function b(f,t=Nt){return Math.abs(f)<t}function A(f,t,e=Nt){return b(f-t,e)}function St(f,t){return Math.round(f/t)*t}function $(f){return isFinite(f)?f:f<0?-Number.MAX_VALUE:Number.MAX_VALUE}function J(f){return Math.abs(f)<Number.MAX_VALUE?f:f*(1/0)}function nt(f,t,e,s,r=1/0,i){s=Math.max(1e-4,s);const n=2/s,a=n*i,l=1/(1+a+.48*a*a+.235*a*a*a);let d=f-t;const g=t,c=r*s;d=F(d,-c,c),t=f-d;const E=(e.value+n*d)*i;e.value=(e.value-n*E)*l;let y=t+(d+E)*l;return g-f>0==y>g&&(y=g,e.value=(y-g)/i),y}function Pt(f,t,e,s,r=1/0,i,n){s=Math.max(1e-4,s);const a=2/s,l=a*i,d=1/(1+l+.48*l*l+.235*l*l*l);let g=t.x,c=t.y,E=t.z,y=f.x-g,u=f.y-c,p=f.z-E;const _=g,o=c,m=E,O=r*s,C=O*O,x=y*y+u*u+p*p;if(x>C){const mt=Math.sqrt(x);y=y/mt*O,u=u/mt*O,p=p/mt*O}g=f.x-y,c=f.y-u,E=f.z-p;const T=(e.x+a*y)*i,D=(e.y+a*u)*i,R=(e.z+a*p)*i;e.x=(e.x-a*T)*d,e.y=(e.y-a*D)*d,e.z=(e.z-a*R)*d,n.x=g+(y+T)*d,n.y=c+(u+D)*d,n.z=E+(p+R)*d;const it=_-f.x,rt=o-f.y,Yt=m-f.z,Zt=n.x-_,qt=n.y-o,Wt=n.z-m;return it*Zt+rt*qt+Yt*Wt>0&&(n.x=_,n.y=o,n.z=m,e.x=(n.x-_)/i,e.y=(n.y-o)/i,e.z=(n.z-m)/i),n}function pt(f,t){t.set(0,0),f.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=f.length,t.y/=f.length}function _t(f,t){return B(f)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}class ue{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 r=this._listeners[t];if(r!==void 0){const i=r.indexOf(e);i!==-1&&r.splice(i,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 r=s.slice(0);for(let i=0,n=r.length;i<n;i++)r[i].call(this,t)}}}const at=1/8,fe=/Mac/.test(navigator.platform);let v,At,ht,ut,L,S,P,W,tt,H,I,Y,Dt,bt,M,et,G,Ut,ft,Rt,gt,Ct,lt;class j extends ue{static install(t){v=t.THREE,At=Object.freeze(new v.Vector3(0,0,0)),ht=Object.freeze(new v.Vector3(0,1,0)),ut=Object.freeze(new v.Vector3(0,0,1)),L=new v.Vector2,S=new v.Vector3,P=new v.Vector3,W=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,G=new v.Box3,Ut=new v.Box3,ft=new v.Sphere,Rt=new v.Quaternion,gt=new v.Quaternion,Ct=new v.Matrix4,lt=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=Z.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 C,x;if(N(this._camera)){const T=S.copy(this._camera.position).sub(this._target),D=this._camera.getEffectiveFOV()*Q,R=T.length()*Math.tan(D*.5);C=this.truckSpeed*o*R/this._elementRect.height,x=this.truckSpeed*m*R/this._elementRect.height}else if(B(this._camera)){const T=this._camera;C=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+C,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(C,0,!0),this.forward(-x,!0)):O?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(C,x,!0)},this._rotateInternal=(o,m)=>{const O=q*this.azimuthRotateSpeed*o/this._elementRect.height,C=q*this.polarRotateSpeed*m/this._elementRect.height;this.rotate(O,C,!0)},this._dollyInternal=(o,m,O)=>{const C=Math.pow(.95,-o*this.dollySpeed),x=this._sphericalEnd.radius,T=this._sphericalEnd.radius*C,D=F(T,this.minDistance,this.maxDistance),R=D-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(R,!0),this._dollyToNoClamp(D,!0)):this._dollyToNoClamp(D,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:D)-x,this._dollyControlCoord.set(m,O)),this._lastDollyDirection=Math.sign(-o)},this._zoomInternal=(o,m,O)=>{const C=Math.pow(.95,o*this.dollySpeed),x=this._zoom,T=this._zoom*C;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,ht),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(S.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:B(this._camera)?h.ZOOM:h.NONE},this.touches={one:h.TOUCH_ROTATE,two:N(this._camera)?h.TOUCH_DOLLY_TRUCK:B(this._camera)?h.TOUCH_ZOOM_TRUCK:h.NONE,three:h.TOUCH_TRUCK};const s=new v.Vector2,r=new v.Vector2,i=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 C=this._domElement.getBoundingClientRect(),x=(o.clientX-C.left)/(C.right-C.left),T=(o.clientY-C.top)/(C.bottom-C.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&U.LEFT)===U.LEFT?U.LEFT:(o.buttons&U.MIDDLE)===U.MIDDLE?U.MIDDLE:(o.buttons&U.RIGHT)===U.RIGHT?U.RIGHT:null;if(m!==null){const C=this._findPointerByMouseButton(m);C&&this._disposePointer(C)}if((o.buttons&U.LEFT)===U.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&U.LEFT)===U.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(o.buttons&U.MIDDLE)===U.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(o.buttons&U.RIGHT)===U.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},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;u()}};let d=-1;const g=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(),D=(o.clientX-T.left)/(T.right-T.left),R=(o.clientY-T.top)/(T.bottom-T.top);if(D<this._interactiveArea.left||D>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=fe?-1:-3,O=o.deltaMode===1?o.deltaY/m:o.deltaY/(m*10),C=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,C,x),this._isUserControllingDolly=!0;break}case h.ZOOM:{this._zoomInternal(-O,C,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},c=o=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===j.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),r.copy(L),this._activePointers.length>=2){const O=L.x-this._activePointers[1].clientX,C=L.y-this._activePointers[1].clientY,x=Math.sqrt(O*O+C*C);i.set(0,x);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,D=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;r.set(T,D)}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&U.LEFT)===U.LEFT&&(this._state=this._state|this.mouseButtons.left),(o.buttons&U.MIDDLE)===U.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(o.buttons&U.RIGHT)===U.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"})},y=()=>{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:r.x-L.x,C=m?-m.deltaY:r.y-L.y;if(r.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,C),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,D=this.dollyDragInverted?-1:1;(this._state&h.DOLLY)===h.DOLLY?(this._dollyInternal(D*C*at,x,T),this._isUserControllingDolly=!0):(this._zoomInternal(D*C*at,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,D=Math.sqrt(x*x+T*T),R=i.y-D;i.set(0,D);const it=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,rt=this.dollyToCursor?(r.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*at,it,rt),this._isUserControllingDolly=!0):(this._zoomInternal(R*at,it,rt),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,C,!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,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},u=()=>{pt(this._activePointers,L),r.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",g,{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",g,{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,u())},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 r=F(t,this.minAzimuthAngle,this.maxAzimuthAngle),i=F(e,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=i,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const n=!s||A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(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=Z.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=A(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 i=!e||A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(i)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection(tt).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const s=!e||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(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||A(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 r=S.copy(H).add(I),i=P.copy(this._targetEnd).add(r);return this.moveTo(i.x,i.y,i.z,s)}forward(t,e=!1){S.setFromMatrixColumn(this._camera.matrix,0),S.crossVectors(this._camera.up,S),S.multiplyScalar(t);const s=P.copy(this._targetEnd).add(S);return this.moveTo(s.x,s.y,s.z,e)}elevate(t,e=!1){return S.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+S.x,this._targetEnd.y+S.y,this._targetEnd.z+S.z,e)}moveTo(t,e,s,r=!1){this._isUserControllingTruck=!1;const i=S.set(t,e,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,i,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);const n=!r||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}lookInDirectionOf(t,e,s,r=!1){const a=S.set(t,e,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,r)}fitToBox(t,e,{cover:s=!1,paddingLeft:r=0,paddingRight:i=0,paddingBottom:n=0,paddingTop:a=0}={}){const l=[],d=t.isBox3?G.copy(t):G.setFromObject(t);d.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const g=St(this._sphericalEnd.theta,wt),c=St(this._sphericalEnd.phi,wt);l.push(this.rotateTo(g,c,e));const E=S.setFromSpherical(this._sphericalEnd).normalize(),y=Rt.setFromUnitVectors(E,ut),u=A(Math.abs(E.y),1);u&&y.multiply(gt.setFromAxisAngle(ht,g)),y.multiply(this._yAxisUpSpaceInverse);const p=Ut.makeEmpty();P.copy(d.min).applyQuaternion(y),p.expandByPoint(P),P.copy(d.min).setX(d.max.x).applyQuaternion(y),p.expandByPoint(P),P.copy(d.min).setY(d.max.y).applyQuaternion(y),p.expandByPoint(P),P.copy(d.max).setZ(d.min.z).applyQuaternion(y),p.expandByPoint(P),P.copy(d.min).setZ(d.max.z).applyQuaternion(y),p.expandByPoint(P),P.copy(d.max).setY(d.min.y).applyQuaternion(y),p.expandByPoint(P),P.copy(d.max).setX(d.min.x).applyQuaternion(y),p.expandByPoint(P),P.copy(d.max).applyQuaternion(y),p.expandByPoint(P),p.min.x-=r,p.min.y-=n,p.max.x+=i,p.max.y+=a,y.setFromUnitVectors(ut,E),u&&y.premultiply(gt.invert()),y.premultiply(this._yAxisUpSpace);const _=p.getSize(S),o=p.getCenter(P).applyQuaternion(y);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(B(this._camera)){const m=this._camera,O=m.right-m.left,C=m.top-m.bottom,x=s?Math.max(O/_.x,C/_.y):Math.min(O/_.x,C/_.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=[],i="isObject3D"in t?j.createBoundingSphere(t,ft):ft.copy(t);if(s.push(this.moveTo(i.center.x,i.center.y,i.center.z,e)),N(this._camera)){const n=this.getDistanceToFitSphere(i.radius);s.push(this.dollyTo(n,e))}else if(B(this._camera)){const n=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*i.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,r,i,n,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Z.NONE,this._changedDolly=0;const l=P.set(r,i,n),d=S.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 g=!a||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold)&&A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(g)}lerpLookAt(t,e,s,r,i,n,a,l,d,g,c,E,y,u=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Z.NONE,this._changedDolly=0;const p=S.set(r,i,n),_=P.set(t,e,s);M.setFromVector3(_.sub(p).applyQuaternion(this._yAxisUpSpace));const o=W.set(g,c,E),m=P.set(a,l,d);et.setFromVector3(m.sub(o).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(p.lerp(o,y));const O=et.theta-M.theta,C=et.phi-M.phi,x=et.radius-M.radius;this._sphericalEnd.set(M.radius+x*y,M.phi+C*y,M.theta+O*y),this.normalizeRotations(),this._needsUpdate=!0,u||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!u||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold)&&A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}setPosition(t,e,s,r=!1){return this.setLookAt(t,e,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(t,e,s,r=!1){const i=this.getPosition(S),n=this.setLookAt(i.x,i.y,i.z,t,e,s,r);return this._sphericalEnd.phi=F(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),n}setFocalOffset(t,e,s,r=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(t,e,s),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd);const i=!r||A(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&A(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&A(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}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 r=S.set(t,e,s),i=r.distanceTo(this._camera.position),n=r.sub(this._camera.position);H.multiplyScalar(n.x),I.multiplyScalar(n.y),Y.multiplyScalar(n.z),S.copy(H).add(I).add(Y),S.z=S.z+i,this.dollyTo(i,!1),this.setFocalOffset(-S.x,S.y,-S.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,r){if(t===null){this._viewport=null;return}this._viewport=this._viewport||new v.Vector4,typeof t=="number"?this._viewport.set(t,e,s,r):this._viewport.copy(t)}getDistanceToFitBox(t,e,s,r=!1){if(_t(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const i=t/e,n=this._camera.getEffectiveFOV()*Q,a=this._camera.aspect;return((r?i>a:i<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,r=1<this._camera.aspect?e:s;return t/Math.sin(r*.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%q,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=q),this._spherical.theta+=q*Math.round((this._sphericalEnd.theta-this._spherical.theta)/q)}reset(t=!1){if(!A(this._camera.up.x,this._cameraUp0.x)||!A(this._camera.up.y,this._cameraUp0.y)||!A(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(S);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,ht),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=S.subVectors(this._target,this._camera.position).normalize(),e=P.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(S);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,r=this._sphericalEnd.radius-this._spherical.radius,i=Dt.subVectors(this._targetEnd,this._target),n=bt.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(b(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const c=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=nt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,c,1/0,t),this._needsUpdate=!0}if(b(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const c=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=nt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,c,1/0,t),this._needsUpdate=!0}if(b(r))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const c=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=nt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,c,this.maxSpeed,t),this._needsUpdate=!0}if(b(i.x)&&b(i.y)&&b(i.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(b(n.x)&&b(n.y)&&b(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(b(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const c=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=nt(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,y=this._getCameraDirection(tt),u=S.copy(y).cross(E.up).normalize();u.lengthSq()===0&&(u.x=1);const p=P.crossVectors(u,y),_=this._sphericalEnd.radius*Math.tan(E.getEffectiveFOV()*Q*.5),m=(this._sphericalEnd.radius-c-this._sphericalEnd.radius)/this._sphericalEnd.radius,O=W.copy(this._targetEnd).add(u.multiplyScalar(this._dollyControlCoord.x*_*E.aspect)).add(p.multiplyScalar(this._dollyControlCoord.y*_)),C=S.copy(this._targetEnd).lerp(O,m),x=this._lastDollyDirection===Z.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===Z.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(x||T)){this._sphericalEnd.radius-=c,this._spherical.radius-=c;const R=P.copy(y).multiplyScalar(-c);C.add(R)}this._boundary.clampPoint(C,C);const D=P.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(D),this._changedDolly-=c,b(this._changedDolly)&&(this._changedDolly=0)}else if(B(this._camera)&&this._changedZoom!==0){const c=this._zoom-this._lastZoom,E=this._camera,y=S.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(E.near+E.far)/(E.near-E.far)).unproject(E),u=P.set(0,0,-1).applyQuaternion(E.quaternion),p=W.copy(y).add(u.multiplyScalar(-y.dot(E.up))),o=-(this._zoom-c-this._zoom)/this._zoom,m=this._getCameraDirection(tt),O=this._targetEnd.dot(m),C=S.copy(this._targetEnd).lerp(p,o),x=C.dot(m),T=m.multiplyScalar(x-O);C.sub(T),this._boundary.clampPoint(C,C);const D=P.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(D),this._changedZoom-=c,b(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),(!b(this._focalOffset.x)||!b(this._focalOffset.y)||!b(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),S.copy(H).add(I).add(Y),this._camera.position.add(S)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),S.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const g=this._needsUpdate;return g&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):g?(this.dispatchEvent({type:"update"}),b(e,this.restThreshold)&&b(s,this.restThreshold)&&b(r,this.restThreshold)&&b(i.x,this.restThreshold)&&b(i.y,this.restThreshold)&&b(i.z,this.restThreshold)&&b(n.x,this.restThreshold)&&b(n.y,this.restThreshold)&&b(n.z,this.restThreshold)&&b(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!g&&this._updatedLastTime&&(this._hasRested||(this._hasRested=!0,this.dispatchEvent({type:"rest"})),this.dispatchEvent({type:"sleep"})),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=g,this._needsUpdate=!1,g}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:$(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:S.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(S.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 r=e.lengthSq();if(r===0)return t;const i=P.copy(e).add(t),a=this._boundary.clampPoint(i,W).sub(i),l=a.lengthSq();if(l===0)return t.add(e);if(l===r)return t;if(s===0)return t.add(e).add(a);{const d=1+s*l/e.dot(a);return t.add(P.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,r=Math.tan(s*.5)*e,i=r*t.aspect;this._nearPlaneCorners[0].set(-i,-r,0),this._nearPlaneCorners[1].set(i,-r,0),this._nearPlaneCorners[2].set(i,r,0),this._nearPlaneCorners[3].set(-i,r,0)}else if(B(this._camera)){const t=this._camera,e=1/t.zoom,s=t.left*e,r=t.right*e,i=t.top*e,n=t.bottom*e;this._nearPlaneCorners[0].set(s,i,0),this._nearPlaneCorners[1].set(r,i,0),this._nearPlaneCorners[2].set(r,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);Ct.lookAt(At,s,this._camera.up);for(let r=0;r<4;r++){const i=P.copy(this._nearPlaneCorners[r]);i.applyMatrix4(Ct);const n=W.addVectors(this._target,i);lt.set(n,s),lt.far=this._spherical.radius+1;const a=lt.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,r=s.center;G.makeEmpty(),t.traverseVisible(n=>{n.isMesh&&G.expandByObject(n)}),G.getCenter(r);let i=0;return t.traverseVisible(n=>{if(!n.isMesh)return;const a=n,l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const g=l.attributes.position;for(let c=0,E=g.count;c<E;c++)S.fromBufferAttribute(g,c),i=Math.max(i,r.distanceToSquared(S))}),s.radius=Math.sqrt(i),s}}const ge={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMappingExposure:1,alpha:!1,outputColorSpace:se.ColorSpace.sRGB,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,stencil:!1,depth:!1,physicallyCorrectLights:!1};class Ce{constructor(t){this.options=t;const{width:e,height:s,rendererParams:r}=t,{canvas:i,context:n,alpha:a,devicePixelRatio:l,antialias:d,powerPreference:g,toneMappingExposure:c,outputColorSpace:E,logarithmicDepthBuffer:y,preserveDrawingBuffer:u,stencil:p,depth:_,physicallyCorrectLights:o}=r,m=new w.WebGLRenderer({canvas:i,context:n,alpha:a,antialias:d,powerPreference:g,logarithmicDepthBuffer:y,preserveDrawingBuffer:u,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(){const{sceneController:t,cameraController:e}=this.options;this.renderer.render(t.scene,e.camera)}setViewport(t){var g,c;const{cameraController:e}=this.options,{x:s,y:r,width:i,height:n}=t,a=(g=t.scissor)!=null?g:!1,l=(c=t.scissorTest)!=null?c:!1,d=i/n;e.camera.aspect!==d&&(e.camera.aspect=d,e.camera.updateProjectionMatrix()),this.renderer.setViewport(s,r,i,n),a&&(this.renderer.setScissor(s,r,i,n),this.renderer.setScissorTest(l))}setViewPadding(t=0,e=0,s=0,r=0){const{width:i,height:n}=this.renderer.getSize(new w.Vector2),a={x:r,y:s,width:i-r-e,height:n-t-s};this.setViewport(a)}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 Ee{constructor(t){this.options=t;const{width:e,height:s,rendererParams:r,renderer:i}=t,{devicePixelRatio:n,antialias:a}=r,l=new i({antialias:a});l.setSize(e,s),l.setPixelRatio(n),this.renderer=l}setSize(t,e){this.renderer.setSize(t,e)}render(){const{sceneController:t,cameraController:e}=this.options;this.renderer.render(t.scene,e.camera)}dispose(){var t,e;this.setSize(1,1),(t=this.renderer)==null||t.clear(),(e=this.renderer)==null||e.dispose()}}const Oe={fov:45,near:1,far:1e3,up:new w.Vector3(0,1,0)};class Te{constructor(t){this.event=new st.eventsExports.EventEmitter,this.cameraArr=[],this.cameraActiveIndex=0,this.customCamera=!1,this.options=t;const{cameraParams:e,width:s,height:r}=t;if(e instanceof w.Camera)this.cameraArr.push(e),this.customCamera=!0;else{const i=this.addPerspectiveCamera(ot(V({},e),{aspect:s/r}));i.position.set(0,0,400),i.lookAt(0,0,0)}}get camera(){return this.cameraArr[this.cameraActiveIndex]}addPerspectiveCamera(t){const{fov:e,far:s,near:r,up:i,aspect:n}=t,a=new w.PerspectiveCamera(e,n,r,s);return a.up=i,this.cameraArr.push(a),a}setCameraActive(t){this.cameraActiveIndex=t,this.event.emit("cameraChange",this.camera)}setSize(t,e){this.options.width=t,this.options.height=e,this.cameraArr.forEach(s=>{s instanceof w.PerspectiveCamera&&(s.aspect=t/e),s.updateProjectionMatrix()})}cloneCamera(){const t=this.addPerspectiveCamera({fov:this.camera.fov,aspect:this.camera.aspect,near:this.camera.near,far:this.camera.far,up:this.camera.up});return t.position.copy(this.camera.position),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,r=e.inverseViewMatrix,i=new w.Matrix4(r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14],r[3],r[7],r[11],r[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(i)||!this.camera.matrixWorldInverse.equals(n))&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix(),this.camera.matrixAutoUpdate=!1,this.camera.matrixWorld.copy(i),this.camera.matrixWorldInverse.copy(n),this.camera.aspect=d,this.camera.updateProjectionMatrix())}}}const ve={background:null,addCamera:!0};class xe{constructor(t){this.event=new st.eventsExports.EventEmitter,this.sceneArr=[],this.sceneActiveIndex=0,this.overrideMaterial=!1,this.options=t;const{cameraController:e,sceneParams:s}=t,{addCamera:r}=s;this.addScene(),r&&this.scene.add(e.camera)}get scene(){return this.sceneArr[this.sceneActiveIndex]}addScene(){const{sceneParams:t}=this.options,{background:e}=t,s=new w.Scene;return e&&(s.background=e),this.sceneArr.push(s),s}setSceneActive(t){this.sceneActiveIndex=t,this.event.emit("sceneChange",this.scene)}dispose(){this.sceneArr.forEach(t=>{t.traverse(e=>{ie.disposeMesh(e)})})}}class we{constructor(t){this.helpers={},this.options=t}add(t){const e=t.uuid,{sceneController:s}=this.options;let r=this.helpers[e];if(r===void 0){if(t.isScene)r=new w.AxesHelper(100);else if(t.isCamera)r=new w.CameraHelper(t);else if(t.isPointLight)r=new w.PointLightHelper(t,1);else if(t.isDirectionalLight)r=new w.DirectionalLightHelper(t,1);else if(t.isSpotLight)r=new w.SpotLightHelper(t);else if(t.isHemisphereLight)r=new w.HemisphereLightHelper(t,10);else if(t.isRectAreaLight)r=new re.RectAreaLightHelper(t);else{const i=new w.Box3;if(i.setFromObject(t,!0),i.isEmpty()===!1){r=new w.Box3Helper(i);const n=r.material;n.userData.object=t,n.depthTest=!1,n.transparent=!0}else return}s.scene.add(r),this.helpers[e]=r}}addViewHelper(){const{cameraController:t,container:e}=this.options,s=new oe.ViewHelper(t.camera,e);e.addEventListener("pointerdown",r=>{r.preventDefault(),s.handleClick(r)}),this.viewHelper=s}remove(t){var r;const e=t.uuid,{sceneController:s}=this.options;if(this.helpers[e]!==void 0){const i=this.helpers[e];s.scene.remove(i),delete this.helpers[e],(r=i.dispose)==null||r.call(i)}}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 i,n;const{cameraController:r}=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)}}),((i=this.viewHelper)==null?void 0:i.animating)===!0&&(this.viewHelper.update(t),(n=e.cameraControls)==null||n.setPosition(...r.camera.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 Se{constructor(t){this.event=new st.eventsExports.EventEmitter,this.cameraControlsArr=[],this.cameraControlsActiveIndex=0,this.autoRotateSpeed=0,this.options=t;const{camera:e,controlsParams:s,customControls:r}=t,{domElement:i}=s;if(r){const n=new r(e,i);n.enableDamping=!0,n.dampingFactor=.063,n.autoRotate=!1,n.autoRotateSpeed=-60,n.enableZoom=!0,n.zoomSpeed=.2,this.customControls=n}else j.install({THREE:w}),this.addCameraControls(e)}get cameraControls(){return this.cameraControlsArr[this.cameraControlsActiveIndex]}addCameraControls(t,e){const{controlsParams:s}=this.options,{domElement:r}=s,i=new j(t,r);return e&&(i.interactiveArea=e,i.addEventListener("update",()=>{this.cameraControlsArr.forEach(n=>{n!==i&&(n.enabled=!1)})}),i.addEventListener("sleep",()=>{this.cameraControlsArr.forEach(n=>{n!==i&&(n.enabled=!0)})})),this.cameraControlsArr.push(i),i}setCameraControlsActive(t){this.cameraControlsActiveIndex=t}enable(){this.customControls?this.customControls.enabled=!0:this.cameraControls&&this.cameraControlsArr.forEach(t=>{t.enabled=!0})}disable(){this.customControls?this.customControls.enabled=!1:this.cameraControls&&this.cameraControlsArr.forEach(t=>{t.enabled=!1})}update(t){var e;(e=this.customControls)==null||e.update(),this.cameraControlsArr.forEach(s=>{s.update(t)}),this.autoRotateSpeed&&this.cameraControls&&(this.cameraControls.azimuthAngle+=this.autoRotateSpeed*t*w.MathUtils.DEG2RAD)}dispose(){var t;(t=this.customControls)==null||t.dispose(),this.cameraControlsArr.forEach(e=>{e.dispose()})}}class Pe{constructor(t){this.event=new st.eventsExports.EventEmitter;const{renderer:e,scene:s,camera:r}=t,i=new ne.TransformControls(r,e.domElement);if(i.getHelper){const n=i.getHelper();if(s.add(n),+w.REVISION<170){const a=i._root;a.dispose=()=>{a.traverse(l=>{l.geometry&&l.geometry.dispose(),l.material&&l.material.dispose()})},i.dispose=()=>{i.disconnect(),a.dispose()}}}else i instanceof w.Object3D&&s.add(i);this.controls=i,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 r=this.controls;r.addEventListener("change",()=>{const i=r.object;i!==void 0&&this.event.emit("change",i)}),r.addEventListener("mouseDown",()=>{const i=r.object;t=i.position.clone(),e=i.rotation.clone(),s=i.scale.clone(),this.event.emit("mouseDown",i)}),r.addEventListener("mouseUp",()=>{const i=r.object;if(i!==void 0)switch(r.getMode()){case"translate":t.equals(i.position)||this.event.emit("translate",i,i.position,t);break;case"rotate":e.equals(i.rotation)||this.event.emit("rotate",i,i.rotation,e);break;case"scale":s.equals(i.scale)||this.event.emit("scale",i,i.scale,s);break}this.event.emit("mouseUp")})}dispose(){var t;this.event.removeAllListeners(),(t=this.controls)==null||t.dispose()}}const Lt=new z.Vector3,Ae=new z.Quaternion,zt=new z.Vector3,k=new z.Matrix4,De=new z.Matrix4;class be{constructor(t={}){const e=this;let s,r,i,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 g=document.createElement("div");g.style.transformStyle="preserve-3d",d.appendChild(g),this.getSize=function(){return{width:s,height:r}},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*(r/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,C;o.isOrthographicCamera&&(O=-(o.right+o.left)/2,C=(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(C)+"px)"+E(o.matrixWorldInverse):`scale( ${x} )translateZ(`+m+"px)"+E(o.matrixWorldInverse),R=(o.isPerspectiveCamera?"perspective("+m+"px) ":"")+T+"translate("+i+"px,"+n+"px)";a.camera.style!==R&&(g.style.transform=R,a.camera.style=R),p(_,_,o)},this.setSize=function(_,o){s=_,r=o,i=s/2,n=r/2,l.style.width=_+"px",l.style.height=o+"px",d.style.width=_+"px",d.style.height=o+"px",g.style.width=_+"px",g.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 y(_){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 u(_){_.isCSS3DObject&&(_.element.style.display="none");for(let o=0,m=_.children.length;o<m;o++)u(_.children[o])}function p(_,o,m,O){if(_.visible===!1){u(_);return}if(_.isCSS3DObject){const C=_.layers.test(m.layers)===!0,x=_.element;if(x.style.display=C===!0?"":"none",C===!0){_.onBeforeRender(e,o,m);let T;_.isCSS3DSprite?(k.copy(m.matrixWorldInverse),k.transpose(),_.rotation2D!==0&&k.multiply(De.makeRotationZ(_.rotation2D)),_.matrixWorld.decompose(Lt,Ae,zt),k.setPosition(Lt),k.scale(zt),k.elements[3]=0,k.elements[7]=0,k.elements[11]=0,k.elements[15]=1,T=y(k)):T=y(_.matrixWorld);const D=a.objects.get(_);if(D===void 0||D.style!==T){x.style.transform=T;const R={style:T};a.objects.set(_,R)}x.parentNode!==g&&g.appendChild(x),_.onAfterRender(e,o,m)}}for(let C=0,x=_.children.length;C<x;C++)p(_.children[C],o,m)}}}const X=new z.Vector3,Mt=new z.Matrix4,Ft=new z.Matrix4,Ht=new z.Vector3,It=new z.Vector3;class Ue{constructor(t={}){const e=this;let s,r,i,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:r}},this.render=function(u,p){u.matrixWorldAutoUpdate===!0&&u.updateMatrixWorld(),p.parent===null&&p.matrixWorldAutoUpdate===!0&&p.updateMatrixWorld(),Mt.copy(p.matrixWorldInverse),Ft.multiplyMatrices(p.projectionMatrix,Mt),g(u,u,p),y(u)},this.setSize=function(u,p){s=u,r=p,i=s/2,n=r/2,l.style.width=u+"px",l.style.height=p+"px"};function d(u){u.isCSS2DObject&&(u.element.style.display="none");for(let p=0,_=u.children.length;p<_;p++)d(u.children[p])}function g(u,p,_){if(u.visible===!1){d(u);return}if(u.isCSS2DObject){X.setFromMatrixPosition(u.matrixWorld),X.applyMatrix4(Ft);const o=X.z>=-1&&X.z<=1&&u.layers.test(_.layers)===!0,m=u.element;m.style.display=o===!0?"":"none",o===!0&&(u.onBeforeRender(e,p,_),m.style.transform="translate("+-100*u.center.x+"%,"+-100*u.center.y+"%)translate("+(X.x*i+i)+"px,"+(-X.y*n+n)+"px)",m.parentNode!==l&&l.appendChild(m),u.onAfterRender(e,p,_));const O={distanceToCameraSquared:c(_,u)};a.objects.set(u,O)}for(let o=0,m=u.children.length;o<m;o++)g(u.children[o],p,_)}function c(u,p){return Ht.setFromMatrixPosition(u.matrixWorld),It.setFromMatrixPosition(p.matrixWorld),Ht.distanceToSquared(It)}function E(u){const p=[];return u.traverseVisible(function(_){_.isCSS2DObject&&p.push(_)}),p}function y(u){const p=E(u).sort(function(o,m){if(o.renderOrder!==m.renderOrder)return m.renderOrder-o.renderOrder;const O=a.objects.get(o).distanceToCameraSquared,C=a.objects.get(m).distanceToCameraSquared;return O-C}),_=p.length;for(let o=0,m=p.length;o<m;o++)p[o].element.style.zIndex=_-o}}}const kt={zIndex:"auto"};class Re{constructor(t){this.container=t}addRenderer(t,e){const s=e.container||this.container,r=s.offsetWidth,i=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(r,i),s.appendChild(n.domElement),t==="css2d"?this.css2Drenderer=n:t==="css3d"&&(this.css3Drenderer=n)}setSize(t,e){var s,r;(s=this.css2Drenderer)==null||s.setSize(t,e),(r=this.css3Drenderer)==null||r.setSize(t,e)}render(t,e){var s,r;(s=this.css2Drenderer)==null||s.render(t,e),(r=this.css3Drenderer)==null||r.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}}class Et{constructor(t){this.guiParams={},t&&(this.guiParams=t)}showGui(t){t&&Object.keys(this.guiParams).forEach(e=>{const s=t.addFolder(e),r=this.guiParams[e];Object.keys(r).forEach(i=>{const{min:n,max:a,step:l,name:d,paramMap:g,items:c,value:E,target:y}=r[i],u=i.toLowerCase().indexOf("color")>-1;let p;const _=typeof E=="undefined"&&y,o=_?y():r[i],m=_?i:"value";c?p=s.add(o,m,c):u?p=s.addColor(o,m):p=s.add(o,m),p=p.name(d||i),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,i,o[m],g)}),_&&p.listen()})})}setTargetValue(t,e,s,r){const{onChange:i,target:n,value:a}=this.guiParams[t][e],l=e.toLowerCase().indexOf("color")>-1;if(n&&!(typeof a=="undefined"&&n)){let g=n();Array.isArray(g)||(g=[g]),g.forEach(c=>{if(c)if(l)try{c[r||e].set(s)}catch(E){e!=="color"&&!r&&console.warn(`${e} is not a color,set paramMap`)}else c[r||e]=s})}i&&i(s)}setTargetValueByParams(){Object.keys(this.guiParams).forEach(t=>{Object.keys(this.guiParams[t]).forEach(e=>{const s=this.guiParams[t][e];typeof s.value!="undefined"&&this.setTargetValue(t,e,s.value,s.paramMap)})})}}const Le={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1},premultiplieAlpha:{value:0}},vertexShader:`
1
+ "use strict";var Gt=Object.defineProperty,Xt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Ot=Object.getOwnPropertySymbols;var jt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Tt=(f,t,e)=>t in f?Gt(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e,B=(f,t)=>{for(var e in t||(t={}))jt.call(t,e)&&Tt(f,e,t[e]);if(Ot)for(var e of Ot(t))Qt.call(t,e)&&Tt(f,e,t[e]);return f},mt=(f,t)=>Xt(f,Kt(t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const z=require("three"),$t=require("@tweenjs/tween.js"),st=require("./events.js"),Jt=require("deepmerge"),te=require("stats-gl"),ee=require("lil-gui"),se=require("./colorCorrection.js"),ie=require("./parseVector.js");require("idb-keyval");require("esus-lite");require("d3-geo");require("d3-geo-projection");const re=require("three/examples/jsm/helpers/RectAreaLightHelper"),oe=require("three/examples/jsm/helpers/ViewHelper"),ne=require("three/examples/jsm/controls/TransformControls"),vt=require("three/examples/jsm/postprocessing/EffectComposer"),ae=require("three/examples/jsm/postprocessing/RenderPass"),he=require("three/examples/jsm/postprocessing/SSAOPass"),le=require("three/examples/jsm/postprocessing/Pass"),ce=require("three/examples/jsm/postprocessing/OutputPass"),de=require("three/examples/jsm/postprocessing/ShaderPass"),me=require("three/examples/jsm/postprocessing/UnrealBloomPass");require("three/examples/jsm/renderers/CSS2DRenderer");require("three/examples/jsm/renderers/CSS3DRenderer");require("three/examples/jsm/lights/RectAreaLightUniformsLib");require("three/examples/jsm/lines/LineSegments2");const Vt=require("./index2.js");require("three/examples/jsm/lines/LineSegmentsGeometry");require("three/examples/jsm/lines/LineMaterial");require("three-bvh-csg");const pe=require("./isPlainObject.js"),_e=require("./BaseObject.js");function Bt(f){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const e in f)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(f,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>f[e]})}}return t.default=f,Object.freeze(t)}const w=Bt(z),xt=Bt($t),U={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}),Z={NONE:0,IN:1,OUT:-1};function N(f){return f.isPerspectiveCamera}function V(f){return f.isOrthographicCamera}const q=Math.PI*2,wt=Math.PI/2,Nt=1e-5,Q=Math.PI/180;function F(f,t,e){return Math.max(t,Math.min(e,f))}function b(f,t=Nt){return Math.abs(f)<t}function A(f,t,e=Nt){return b(f-t,e)}function St(f,t){return Math.round(f/t)*t}function $(f){return isFinite(f)?f:f<0?-Number.MAX_VALUE:Number.MAX_VALUE}function J(f){return Math.abs(f)<Number.MAX_VALUE?f:f*(1/0)}function ot(f,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=f-t;const C=t,c=i*s;d=F(d,-c,c),t=f-d;const T=(e.value+n*d)*r;e.value=(e.value-n*T)*l;let y=t+(d+T)*l;return C-f>0==y>C&&(y=C,e.value=(y-C)/r),y}function Pt(f,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 C=t.x,c=t.y,T=t.z,y=f.x-C,u=f.y-c,p=f.z-T;const _=C,o=c,m=T,E=i*s,g=E*E,x=y*y+u*u+p*p;if(x>g){const dt=Math.sqrt(x);y=y/dt*E,u=u/dt*E,p=p/dt*E}C=f.x-y,c=f.y-u,T=f.z-p;const O=(e.x+a*y)*r,D=(e.y+a*u)*r,R=(e.z+a*p)*r;e.x=(e.x-a*O)*d,e.y=(e.y-a*D)*d,e.z=(e.z-a*R)*d,n.x=C+(y+O)*d,n.y=c+(u+D)*d,n.z=T+(p+R)*d;const it=_-f.x,rt=o-f.y,Yt=m-f.z,Zt=n.x-_,qt=n.y-o,Wt=n.z-m;return it*Zt+rt*qt+Yt*Wt>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(f,t){t.set(0,0),f.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=f.length,t.y/=f.length}function _t(f,t){return V(f)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}class ue{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 nt=1/8,fe=/Mac/.test(navigator.platform);let v,At,at,ut,L,S,P,W,tt,I,H,Y,Dt,bt,M,et,G,Ut,ft,Rt,gt,yt,ht;class j extends ue{static install(t){v=t.THREE,At=Object.freeze(new v.Vector3(0,0,0)),at=Object.freeze(new v.Vector3(0,1,0)),ut=Object.freeze(new v.Vector3(0,0,1)),L=new v.Vector2,S=new v.Vector3,P=new v.Vector3,W=new v.Vector3,tt=new v.Vector3,I=new v.Vector3,H=new v.Vector3,Y=new v.Vector3,Dt=new v.Vector3,bt=new v.Vector3,M=new v.Spherical,et=new v.Spherical,G=new v.Box3,Ut=new v.Box3,ft=new v.Sphere,Rt=new v.Quaternion,gt=new v.Quaternion,yt=new v.Matrix4,ht=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=Z.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,E)=>{let g,x;if(N(this._camera)){const O=S.copy(this._camera.position).sub(this._target),D=this._camera.getEffectiveFOV()*Q,R=O.length()*Math.tan(D*.5);g=this.truckSpeed*o*R/this._elementRect.height,x=this.truckSpeed*m*R/this._elementRect.height}else if(V(this._camera)){const O=this._camera;g=o*(O.right-O.left)/O.zoom/this._elementRect.width,x=m*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(E?this.setFocalOffset(this._focalOffsetEnd.x+g,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(g,0,!0),this.forward(-x,!0)):E?this.setFocalOffset(this._focalOffsetEnd.x+g,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(g,x,!0)},this._rotateInternal=(o,m)=>{const E=q*this.azimuthRotateSpeed*o/this._elementRect.height,g=q*this.polarRotateSpeed*m/this._elementRect.height;this.rotate(E,g,!0)},this._dollyInternal=(o,m,E)=>{const g=Math.pow(.95,-o*this.dollySpeed),x=this._sphericalEnd.radius,O=this._sphericalEnd.radius*g,D=F(O,this.minDistance,this.maxDistance),R=D-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(R,!0),this._dollyToNoClamp(D,!0)):this._dollyToNoClamp(D,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:D)-x,this._dollyControlCoord.set(m,E)),this._lastDollyDirection=Math.sign(-o)},this._zoomInternal=(o,m,E)=>{const g=Math.pow(.95,o*this.dollySpeed),x=this._zoom,O=this._zoom*g;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-x,this._dollyControlCoord.set(m,E))},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,at),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(S.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),O=(o.clientY-g.top)/(g.bottom-g.top);if(x<this._interactiveArea.left||x>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const m=o.pointerType!=="mouse"?null:(o.buttons&U.LEFT)===U.LEFT?U.LEFT:(o.buttons&U.MIDDLE)===U.MIDDLE?U.MIDDLE:(o.buttons&U.RIGHT)===U.RIGHT?U.RIGHT:null;if(m!==null){const g=this._findPointerByMouseButton(m);g&&this._disposePointer(g)}if((o.buttons&U.LEFT)===U.LEFT&&this._lockedPointer)return;const E={pointerId:o.pointerId,clientX:o.clientX,clientY:o.clientY,deltaX:0,deltaY:0,mouseButton:m};this._activePointers.push(E),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,T(o)},a=o=>{o.cancelable&&o.preventDefault();const m=o.pointerId,E=this._lockedPointer||this._findPointerById(m);if(E){if(E.clientX=o.clientX,E.clientY=o.clientY,E.deltaX=o.movementX,E.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&U.LEFT)===U.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(o.buttons&U.MIDDLE)===U.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(o.buttons&U.RIGHT)===U.RIGHT&&(this._state=this._state|this.mouseButtons.right);y()}},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;u()}};let d=-1;const C=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 O=this._domElement.getBoundingClientRect(),D=(o.clientX-O.left)/(O.right-O.left),R=(o.clientY-O.top)/(O.bottom-O.top);if(D<this._interactiveArea.left||D>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 O=performance.now();d-O<1e3&&this._getClientRect(this._elementRect),d=O}const m=fe?-1:-3,E=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(-E,g,x),this._isUserControllingDolly=!0;break}case h.ZOOM:{this._zoomInternal(-E,g,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},c=o=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===j.ACTION.NONE){const m=o instanceof PointerEvent?o.pointerId:0,E=this._findPointerById(m);E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}o.preventDefault()}},T=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 E=L.x-this._activePointers[1].clientX,g=L.y-this._activePointers[1].clientY,x=Math.sqrt(E*E+g*g);r.set(0,x);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,D=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(O,D)}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&U.LEFT)===U.LEFT&&(this._state=this._state|this.mouseButtons.left),(o.buttons&U.MIDDLE)===U.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(o.buttons&U.RIGHT)===U.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"})},y=()=>{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,E=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(E,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,O=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,D=this.dollyDragInverted?-1:1;(this._state&h.DOLLY)===h.DOLLY?(this._dollyInternal(D*g*nt,x,O),this._isUserControllingDolly=!0):(this._zoomInternal(D*g*nt,x,O),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,O=L.y-this._activePointers[1].clientY,D=Math.sqrt(x*x+O*O),R=r.y-D;r.set(0,D);const it=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,rt=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*nt,it,rt),this._isUserControllingDolly=!0):(this._zoomInternal(R*nt,it,rt),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(E,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(E,g,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},u=()=>{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),T())},this.unlockPointer=()=>{var o,m,E;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),(E=this._domElement)===null||E===void 0||E.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",C,{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",C,{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,u())},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||A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(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=Z.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=A(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||A(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||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(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||A(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(),I.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),I.multiplyScalar(t),H.multiplyScalar(-e);const i=S.copy(I).add(H),r=P.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,s)}forward(t,e=!1){S.setFromMatrixColumn(this._camera.matrix,0),S.crossVectors(this._camera.up,S),S.multiplyScalar(t);const s=P.copy(this._targetEnd).add(S);return this.moveTo(s.x,s.y,s.z,e)}elevate(t,e=!1){return S.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+S.x,this._targetEnd.y+S.y,this._targetEnd.z+S.z,e)}moveTo(t,e,s,i=!1){this._isUserControllingTruck=!1;const r=S.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||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}lookInDirectionOf(t,e,s,i=!1){const a=S.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?G.copy(t):G.setFromObject(t);d.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const C=St(this._sphericalEnd.theta,wt),c=St(this._sphericalEnd.phi,wt);l.push(this.rotateTo(C,c,e));const T=S.setFromSpherical(this._sphericalEnd).normalize(),y=Rt.setFromUnitVectors(T,ut),u=A(Math.abs(T.y),1);u&&y.multiply(gt.setFromAxisAngle(at,C)),y.multiply(this._yAxisUpSpaceInverse);const p=Ut.makeEmpty();P.copy(d.min).applyQuaternion(y),p.expandByPoint(P),P.copy(d.min).setX(d.max.x).applyQuaternion(y),p.expandByPoint(P),P.copy(d.min).setY(d.max.y).applyQuaternion(y),p.expandByPoint(P),P.copy(d.max).setZ(d.min.z).applyQuaternion(y),p.expandByPoint(P),P.copy(d.min).setZ(d.max.z).applyQuaternion(y),p.expandByPoint(P),P.copy(d.max).setY(d.min.y).applyQuaternion(y),p.expandByPoint(P),P.copy(d.max).setX(d.min.x).applyQuaternion(y),p.expandByPoint(P),P.copy(d.max).applyQuaternion(y),p.expandByPoint(P),p.min.x-=i,p.min.y-=n,p.max.x+=r,p.max.y+=a,y.setFromUnitVectors(ut,T),u&&y.premultiply(gt.invert()),y.premultiply(this._yAxisUpSpace);const _=p.getSize(S),o=p.getCenter(P).applyQuaternion(y);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,E=m.right-m.left,g=m.top-m.bottom,x=s?Math.max(E/_.x,g/_.y):Math.min(E/_.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?j.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=Z.NONE,this._changedDolly=0;const l=P.set(i,r,n),d=S.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 C=!a||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold)&&A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(C)}lerpLookAt(t,e,s,i,r,n,a,l,d,C,c,T,y,u=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Z.NONE,this._changedDolly=0;const p=S.set(i,r,n),_=P.set(t,e,s);M.setFromVector3(_.sub(p).applyQuaternion(this._yAxisUpSpace));const o=W.set(C,c,T),m=P.set(a,l,d);et.setFromVector3(m.sub(o).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(p.lerp(o,y));const E=et.theta-M.theta,g=et.phi-M.phi,x=et.radius-M.radius;this._sphericalEnd.set(M.radius+x*y,M.phi+g*y,M.theta+E*y),this.normalizeRotations(),this._needsUpdate=!0,u||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const O=!u||A(this._target.x,this._targetEnd.x,this.restThreshold)&&A(this._target.y,this._targetEnd.y,this.restThreshold)&&A(this._target.z,this._targetEnd.z,this.restThreshold)&&A(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&A(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&A(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(O)}setPosition(t,e,s,i=!1){return this.setLookAt(t,e,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(t,e,s,i=!1){const r=this.getPosition(S),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||A(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&A(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&A(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(t,e,s){this._camera.updateMatrixWorld(),I.setFromMatrixColumn(this._camera.matrixWorldInverse,0),H.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Y.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=S.set(t,e,s),r=i.distanceTo(this._camera.position),n=i.sub(this._camera.position);I.multiplyScalar(n.x),H.multiplyScalar(n.y),Y.multiplyScalar(n.z),S.copy(I).add(H).add(Y),S.z=S.z+r,this.dollyTo(r,!1),this.setFocalOffset(-S.x,S.y,-S.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%q,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=q),this._spherical.theta+=q*Math.round((this._sphericalEnd.theta-this._spherical.theta)/q)}reset(t=!1){if(!A(this._camera.up.x,this._cameraUp0.x)||!A(this._camera.up.y,this._cameraUp0.y)||!A(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(S);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}const e=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,t),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,t),this.zoomTo(this._zoom0,t)];return Promise.all(e)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,at),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=S.subVectors(this._target,this._camera.position).normalize(),e=P.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(S);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(b(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const c=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=ot(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,c,1/0,t),this._needsUpdate=!0}if(b(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const c=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=ot(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,c,1/0,t),this._needsUpdate=!0}if(b(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const c=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=ot(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,c,this.maxSpeed,t),this._needsUpdate=!0}if(b(r.x)&&b(r.y)&&b(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(b(n.x)&&b(n.y)&&b(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(b(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const c=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=ot(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,T=this._camera,y=this._getCameraDirection(tt),u=S.copy(y).cross(T.up).normalize();u.lengthSq()===0&&(u.x=1);const p=P.crossVectors(u,y),_=this._sphericalEnd.radius*Math.tan(T.getEffectiveFOV()*Q*.5),m=(this._sphericalEnd.radius-c-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=W.copy(this._targetEnd).add(u.multiplyScalar(this._dollyControlCoord.x*_*T.aspect)).add(p.multiplyScalar(this._dollyControlCoord.y*_)),g=S.copy(this._targetEnd).lerp(E,m),x=this._lastDollyDirection===Z.IN&&this._spherical.radius<=this.minDistance,O=this._lastDollyDirection===Z.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(x||O)){this._sphericalEnd.radius-=c,this._spherical.radius-=c;const R=P.copy(y).multiplyScalar(-c);g.add(R)}this._boundary.clampPoint(g,g);const D=P.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(D),this._changedDolly-=c,b(this._changedDolly)&&(this._changedDolly=0)}else if(V(this._camera)&&this._changedZoom!==0){const c=this._zoom-this._lastZoom,T=this._camera,y=S.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(T.near+T.far)/(T.near-T.far)).unproject(T),u=P.set(0,0,-1).applyQuaternion(T.quaternion),p=W.copy(y).add(u.multiplyScalar(-y.dot(T.up))),o=-(this._zoom-c-this._zoom)/this._zoom,m=this._getCameraDirection(tt),E=this._targetEnd.dot(m),g=S.copy(this._targetEnd).lerp(p,o),x=g.dot(m),O=m.multiplyScalar(x-E);g.sub(O),this._boundary.clampPoint(g,g);const D=P.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(D),this._changedZoom-=c,b(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),(!b(this._focalOffset.x)||!b(this._focalOffset.y)||!b(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),I.setFromMatrixColumn(this._camera.matrix,0),H.setFromMatrixColumn(this._camera.matrix,1),Y.setFromMatrixColumn(this._camera.matrix,2),I.multiplyScalar(this._focalOffset.x),H.multiplyScalar(-this._focalOffset.y),Y.multiplyScalar(this._focalOffset.z),S.copy(I).add(H).add(Y),this._camera.position.add(S)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),S.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const C=this._needsUpdate;return C&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):C?(this.dispatchEvent({type:"update"}),b(e,this.restThreshold)&&b(s,this.restThreshold)&&b(i,this.restThreshold)&&b(r.x,this.restThreshold)&&b(r.y,this.restThreshold)&&b(r.z,this.restThreshold)&&b(n.x,this.restThreshold)&&b(n.y,this.restThreshold)&&b(n.z,this.restThreshold)&&b(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!C&&this._updatedLastTime&&(this._hasRested||(this._hasRested=!0,this.dispatchEvent({type:"rest"})),this.dispatchEvent({type:"sleep"})),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=C,this._needsUpdate=!1,C}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:S.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(S.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=P.copy(e).add(t),a=this._boundary.clampPoint(r,W).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(P.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(At,s,this._camera.up);for(let i=0;i<4;i++){const r=P.copy(this._nearPlaneCorners[i]);r.applyMatrix4(yt);const n=W.addVectors(this._target,r);ht.set(n,s),ht.far=this._spherical.radius+1;const a=ht.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<t&&(t=a[0].distance)}return t}_getClientRect(t){if(!this._domElement)return;const e=this._domElement.getBoundingClientRect();return t.x=e.left,t.y=e.top,this._viewport?(t.x+=this._viewport.x,t.y+=e.height-this._viewport.w-this._viewport.y,t.width=this._viewport.z,t.height=this._viewport.w):(t.width=e.width,t.height=e.height),t}_createOnRestPromise(t){return t?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(e=>{const s=()=>{this.removeEventListener("rest",s),e()};this.addEventListener("rest",s)}))}_addAllEventListeners(t){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(t){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(t){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(t,e=new v.Sphere){const s=e,i=s.center;G.makeEmpty(),t.traverseVisible(n=>{n.isMesh&&G.expandByObject(n)}),G.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 C=l.attributes.position;for(let c=0,T=C.count;c<T;c++)S.fromBufferAttribute(C,c),r=Math.max(r,i.distanceToSquared(S))}),s.radius=Math.sqrt(r),s}}const ge={antialias:!1,devicePixelRatio:window.devicePixelRatio,powerPreference:"high-performance",toneMappingExposure:1,alpha:!1,outputColorSpace:se.ColorSpace.sRGB,logarithmicDepthBuffer:!1,preserveDrawingBuffer:!1,stencil:!1,depth:!1,physicallyCorrectLights:!1};class ye{constructor(t){this.options=t;const{width:e,height:s,rendererParams:i}=t,{canvas:r,context:n,alpha:a,devicePixelRatio:l,antialias:d,powerPreference:C,toneMappingExposure:c,outputColorSpace:T,logarithmicDepthBuffer:y,preserveDrawingBuffer:u,stencil:p,depth:_,physicallyCorrectLights:o}=i,m=new w.WebGLRenderer({canvas:r,context:n,alpha:a,antialias:d,powerPreference:C,logarithmicDepthBuffer:y,preserveDrawingBuffer:u,stencil:p,depth:_});m.setSize(e,s),m.setPixelRatio(l),m.toneMappingExposure=c,m.outputColorSpace=T,+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,e){this.renderer.render(t,e)}setViewport(t){var l,d;const{x:e,y:s,width:i,height:r}=t,n=(l=t.scissor)!=null?l:!1,a=(d=t.scissorTest)!=null?d:!1;this.renderer.setViewport(e,s,i,r),n&&(this.renderer.setScissor(e,s,i,r),this.renderer.setScissorTest(a))}setViewPadding(t=0,e=0,s=0,i=0){const{width:r,height:n}=this.renderer.getSize(new w.Vector2),a={x:i,y:s,width:r-i-e,height:n-t-s};this.setViewport(a)}dispose(){var t,e;this.setSize(1,1),(t=this.renderer)==null||t.clear(),(e=this.renderer)==null||e.dispose()}}const Ce={antialias:!0,devicePixelRatio:window.devicePixelRatio};class Ee{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,e){this.renderer.render(t,e)}dispose(){var t,e;this.setSize(1,1),(t=this.renderer)==null||t.clear(),(e=this.renderer)==null||e.dispose()}}const Oe={fov:45,near:1,far:1e3,up:new w.Vector3(0,1,0)};class Te{constructor(t){this.event=new st.eventsExports.EventEmitter,this.cameraArr=[],this.cameraActiveIndex=0,this.customCamera=!1,this.width=0,this.height=0,this.width=t.width,this.height=t.height}get camera(){return this.cameraArr[this.cameraActiveIndex]}addPerspectiveCamera(t){const{fov:e,far:s,near:i,up:r,aspect:n}=t,a=n!=null?n:this.width/this.height,l=new w.PerspectiveCamera(e,a,i,s);return l.up=r,this.cameraArr.push(l),l}setCameraActive(t){this.cameraActiveIndex=t,this.event.emit("cameraChange",this.camera)}setSize(t,e){this.width=t,this.height=e,this.cameraArr.forEach(s=>{s instanceof w.PerspectiveCamera&&(s.aspect=t/e),s.updateProjectionMatrix()})}cloneCamera(){const t=this.addPerspectiveCamera({fov:this.camera.fov,aspect:this.camera.aspect,near:this.camera.near,far:this.camera.far,up:this.camera.up});return t.position.copy(this.camera.position),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,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())}}}const ve={background:null},xe=new w.Scene;class we{constructor(t){this.event=new st.eventsExports.EventEmitter,this.sceneArr=[],this.sceneActiveIndex=0,this.overrideMaterial=!1,this.options=t}get scene(){return this.sceneActiveIndex==-1?xe:this.sceneArr[this.sceneActiveIndex]}addScene(t){const e=new w.Scene;return t!=null&&t.background&&(e.background=t.background),this.sceneArr.push(e),e}setSceneActive(t){this.sceneActiveIndex=t,this.event.emit("sceneChange",this.scene)}dispose(){this.sceneArr.forEach(t=>{t.traverse(e=>{ie.disposeMesh(e)})})}}class Se{constructor(t){this.helpers={},this.options=t}add(t){const e=t.uuid,{sceneController: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 re.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.scene.add(i),this.helpers[e]=i}}addViewHelper(){const{cameraController:t,container:e}=this.options,s=new oe.ViewHelper(t.camera,e);e.addEventListener("pointerdown",i=>{i.preventDefault(),s.handleClick(i)}),this.viewHelper=s}remove(t){var i;const e=t.uuid,{sceneController:s}=this.options;if(this.helpers[e]!==void 0){const r=this.helpers[e];s.scene.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{cameraController: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.camera.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 Pe{constructor(t){this.event=new st.eventsExports.EventEmitter,this.cameraControlsArr=[],this.cameraControlsActiveIndex=0,this.autoRotateSpeed=0,this.options=t,j.install({THREE:w})}get cameraControls(){return this.cameraControlsArr[this.cameraControlsActiveIndex]}addCameraControls(t,e){const{domElement:s}=this.options.controlsParams,i=new j(t,s);return e&&(i.interactiveArea=e,i.addEventListener("update",()=>{this.cameraControlsArr.forEach(r=>{r!==i&&(r.enabled=!1)})}),i.addEventListener("sleep",()=>{this.cameraControlsArr.forEach(r=>{r!==i&&(r.enabled=!0)})})),this.cameraControlsArr.push(i),i}setCameraControlsActive(t){this.cameraControlsActiveIndex=t}enable(){this.cameraControlsArr.forEach(t=>{t.enabled=!0})}disable(){this.cameraControlsArr.forEach(t=>{t.enabled=!1})}update(t){this.cameraControlsArr.forEach(e=>{e.update(t)}),this.autoRotateSpeed&&this.cameraControls&&(this.cameraControls.azimuthAngle+=this.autoRotateSpeed*t*w.MathUtils.DEG2RAD)}dispose(){this.cameraControlsArr.forEach(t=>{t.dispose()})}}class Ae{constructor(t){this.event=new st.eventsExports.EventEmitter;const{renderer:e,scene:s,camera:i}=t,r=new ne.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 Lt=new z.Vector3,De=new z.Quaternion,zt=new z.Vector3,k=new z.Matrix4,be=new z.Matrix4;class Ue{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 C=document.createElement("div");C.style.transformStyle="preserve-3d",d.appendChild(C),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 E,g;o.isOrthographicCamera&&(E=-(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,O=o.isOrthographicCamera?`scale( ${x} )scale(`+m+")translate("+c(E)+"px,"+c(g)+"px)"+T(o.matrixWorldInverse):`scale( ${x} )translateZ(`+m+"px)"+T(o.matrixWorldInverse),R=(o.isPerspectiveCamera?"perspective("+m+"px) ":"")+O+"translate("+r+"px,"+n+"px)";a.camera.style!==R&&(C.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",C.style.width=_+"px",C.style.height=o+"px"};function c(_){return Math.abs(_)<1e-10?0:_}function T(_){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 y(_){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 u(_){_.isCSS3DObject&&(_.element.style.display="none");for(let o=0,m=_.children.length;o<m;o++)u(_.children[o])}function p(_,o,m,E){if(_.visible===!1){u(_);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 O;_.isCSS3DSprite?(k.copy(m.matrixWorldInverse),k.transpose(),_.rotation2D!==0&&k.multiply(be.makeRotationZ(_.rotation2D)),_.matrixWorld.decompose(Lt,De,zt),k.setPosition(Lt),k.scale(zt),k.elements[3]=0,k.elements[7]=0,k.elements[11]=0,k.elements[15]=1,O=y(k)):O=y(_.matrixWorld);const D=a.objects.get(_);if(D===void 0||D.style!==O){x.style.transform=O;const R={style:O};a.objects.set(_,R)}x.parentNode!==C&&C.appendChild(x),_.onAfterRender(e,o,m)}}for(let g=0,x=_.children.length;g<x;g++)p(_.children[g],o,m)}}}const X=new z.Vector3,Mt=new z.Matrix4,Ft=new z.Matrix4,It=new z.Vector3,Ht=new z.Vector3;class Re{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(u,p){u.matrixWorldAutoUpdate===!0&&u.updateMatrixWorld(),p.parent===null&&p.matrixWorldAutoUpdate===!0&&p.updateMatrixWorld(),Mt.copy(p.matrixWorldInverse),Ft.multiplyMatrices(p.projectionMatrix,Mt),C(u,u,p),y(u)},this.setSize=function(u,p){s=u,i=p,r=s/2,n=i/2,l.style.width=u+"px",l.style.height=p+"px"};function d(u){u.isCSS2DObject&&(u.element.style.display="none");for(let p=0,_=u.children.length;p<_;p++)d(u.children[p])}function C(u,p,_){if(u.visible===!1){d(u);return}if(u.isCSS2DObject){X.setFromMatrixPosition(u.matrixWorld),X.applyMatrix4(Ft);const o=X.z>=-1&&X.z<=1&&u.layers.test(_.layers)===!0,m=u.element;m.style.display=o===!0?"":"none",o===!0&&(u.onBeforeRender(e,p,_),m.style.transform="translate("+-100*u.center.x+"%,"+-100*u.center.y+"%)translate("+(X.x*r+r)+"px,"+(-X.y*n+n)+"px)",m.parentNode!==l&&l.appendChild(m),u.onAfterRender(e,p,_));const E={distanceToCameraSquared:c(_,u)};a.objects.set(u,E)}for(let o=0,m=u.children.length;o<m;o++)C(u.children[o],p,_)}function c(u,p){return It.setFromMatrixPosition(u.matrixWorld),Ht.setFromMatrixPosition(p.matrixWorld),It.distanceToSquared(Ht)}function T(u){const p=[];return u.traverseVisible(function(_){_.isCSS2DObject&&p.push(_)}),p}function y(u){const p=T(u).sort(function(o,m){if(o.renderOrder!==m.renderOrder)return m.renderOrder-o.renderOrder;const E=a.objects.get(o).distanceToCameraSquared,g=a.objects.get(m).distanceToCameraSquared;return E-g}),_=p.length;for(let o=0,m=p.length;o<m;o++)p[o].element.style.zIndex=_-o}}}const kt={zIndex:"auto"};class Le{constructor(t){this.container=t}addRenderer(t,e){const s=e.container||this.container,i=s.offsetWidth,r=s.offsetHeight,n=t==="css2d"?new Re:new Ue;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}}class Et{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:C,items:c,value:T,target:y}=i[r],u=r.toLowerCase().indexOf("color")>-1;let p;const _=typeof T=="undefined"&&y,o=_?y():i[r],m=_?r:"value";c?p=s.add(o,m,c):u?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],C)}),_&&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 C=n();Array.isArray(C)||(C=[C]),C.forEach(c=>{if(c)if(l)try{c[i||e].set(s)}catch(T){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 ze={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 ze extends ce.OutputPass{constructor(){super();const t=Le;this.uniforms=z.UniformsUtils.clone(t.uniforms),this.material=new z.RawShaderMaterial({name:t.name,uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.fsQuad=new le.FullScreenQuad(this.material)}}const Me=f=>{const t=new de.ShaderPass(new w.ShaderMaterial({uniforms:{baseTexture:{value:null},bloomTexture:{value:f.renderTarget2.texture},bloomAlphaType:{value:0}},vertexShader:`
73
+ }`};class Me extends ce.OutputPass{constructor(){super();const t=ze;this.uniforms=z.UniformsUtils.clone(t.uniforms),this.material=new z.RawShaderMaterial({name:t.name,uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.fsQuad=new le.FullScreenQuad(this.material)}}const Fe=f=>{const t=new de.ShaderPass(new w.ShaderMaterial({uniforms:{baseTexture:{value:null},bloomTexture:{value:f.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},yt=1,K=!1,Fe=new w.MeshBasicMaterial({color:"black"}),He=new w.PointsMaterial({color:"black",sizeAttenuation:!1}),Ie=new w.PointsMaterial({color:"black",sizeAttenuation:!0}),ke=new w.SpriteMaterial({color:"black",sizeAttenuation:!0}),Ve=new w.SpriteMaterial({color:"black",sizeAttenuation:!1}),Be=new Vt.MeshLineMaterial({color:"black",sizeAttenuation:0,lineWidth:0}),Ne={kernelRadius:8,minDistance:.005,maxDistance:.1},Ye={threshold:0,strength:.4,radius:.1,bloomAlphaType:0},Ze={multisampling:4,premultiplieAlpha:!1};class qe{constructor(t){this.bloomComposerActive=!1,this.active=!0,this.bloomSelection=new Set,this.bloomLayer=new w.Layers,this.bloomMaterials={},this.bloomVisible={},this.pipViewportState=null,this.options=t;const{rendererController:e,sceneController:s,cameraController:r,composerParams:i}=t,{renderer:n}=e,{multisampling:a}=i,{maxSamples:l}=n.capabilities,d=n.getDrawingBufferSize(new w.Vector2),g=new w.WebGLRenderTarget(d.width,d.height,{samples:Math.min(a,l),type:w.HalfFloatType}),c=new ae.RenderPass(s.scene,r.camera),E=new vt.EffectComposer(n,g);E.addPass(c),this.renderer=n,this.scene=s.scene,this.camera=r.camera,this.finalComposer=E,this.renderPass=c;const y=this.getSize();this.setSize(y.width,y.height),r.event.on("cameraChange",u=>{this.changeCamera(u)}),s.event.on("sceneChange",u=>{this.changeScene(u)})}changeCamera(t){this.renderPass.camera=t,this.camera=t}changeScene(t){this.renderPass.scene=t,this.ssaoPass&&(this.ssaoPass.scene=t),this.scene=t}addOutputPass(){const{premultiplieAlpha:t}=this.options.composerParams,e=new ze;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:r}=this,i=r.getSize(new w.Vector2),n=i.width,a=i.height,l=new he.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 Et({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:r,radius:i,bloomAlphaType:n}=t,a=new me.UnrealBloomPass(new w.Vector2(window.innerWidth,window.innerHeight),r,i,s);this.bloomPass=a;const l=new vt.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(yt)}addBloomGui(t){if(!this.bloomComposer)return;new Et({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 r=e;e===void 0&&(r=!this.bloomSelection.has(s)),r?(this.bloomSelection.add(s),s.traverse(i=>{i.layers.enable(yt)})):(this.bloomSelection.delete(s),s.traverse(i=>{i.layers.disable(yt)})),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(r=>{const i=r,n=r,a=r;i.material&&this.bloomLayer.test(i.layers)===!1&&(this.bloomMaterials[i.uuid]=i.material,n.isSprite?n.material.sizeAttenuation?n.material=ke:n.material=Ve:i.material instanceof Vt.MeshLineMaterial?i.material=Be:a.isPoints?a.material.sizeAttenuation?a.material=Ie:a.material=He:i.material=Fe)})})}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])})}finalComposerRender(){this.bloomComposerActive&&this.bloomComposer?(this.mixPass.enabled=!0,this.darkenNonBloomed(),this.bloomComposer.render(),this.restoreNonBloomed()):this.mixPass&&(this.mixPass.enabled=!1),this.finalComposer.render()}getSize(){return this.renderer.getSize(new w.Vector2)}render(){if(!this.active)return;const{cameraController:t,rendererController:e}=this.options;if(this.pipViewportState){t.setCameraActive(0);const s=this.getSize();e.setViewport({x:0,y:0,width:s.width,height:s.height,scissor:!0,scissorTest:!1}),this.finalComposerRender(),t.setCameraActive(1),e.setViewport(ot(V({},this.pipViewportState),{scissor:!0,scissorTest:!0})),this.finalComposerRender()}else this.finalComposerRender()}dispose(){var t;this.bloomMaterials={},this.bloomVisible={},this.bloomSelection.clear(),this.finalComposer.dispose(),(t=this.bloomComposer)==null||t.dispose()}}const dt=class dt{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 st.eventsExports.EventEmitter,this.clock=new w.Clock,this.userData={},this.dprCache=1,this.options=Jt(dt.options,t,{isMergeableObject:pe.isPlainObject}),this.dprCache=this.options.renderer.devicePixelRatio,this.event.setMaxListeners(1/0);const{container:s,stats:r,gui:i,resizeObserver:n}=this.options;if(i){const a=new ee;a.open(!1),this.gui=a}if(this.init(),r){const a=new te({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,WebGPUTHREE:e,helper:s,viewHelper:r,renderer:i,scene:n,camera:a,controls:l}=this.options,{width:d,height:g}=this.getSize(),c=new Te({width:d,height:g,cameraParams:a,cameraControls:l===!0}),E=new xe({cameraController:c,sceneParams:n}),y=e?new Ee({width:d,height:g,sceneController:E,cameraController:c,renderer:e.WebGPURenderer,rendererParams:ye}):new Ce({width:d,height:g,sceneController:E,cameraController:c,rendererParams:ot(V({},i),{antialias:!1})});if(s){const u=new we({container:t,sceneController:E,cameraController:c});u.add(E.scene),this.helperController=u,r&&u.addViewHelper()}this.sceneController=E,this.rendererController=y,this.cameraController=c,t.appendChild(y.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,ssao:s,ssaoParams:r,composer:i}=this.options,n=new qe({rendererController:this.rendererController,sceneController:this.sceneController,cameraController:this.cameraController,composerParams:i});this.composerController=n,t&&(n.addBloomPass(V({},e)),this.gui&&n.addBloomGui(this.gui)),s&&(n.addSSAOPass(V({},r)),this.gui&&n.addSSAOGui(this.gui)),n.addOutputPass()}initCSSRenderer(){const{container:t,css2DRenderer:e,css3DRenderer:s,css2DRendererParams:r,css3DRendererParams:i}=this.options;if(e||s){const n=new Re(t);e&&n.addRenderer("css2d",r),s&&n.addRenderer("css3d",i),this.cssRendererController=n}}initControls(){const{controls:t,controlsParams:e,transformControls:s}=this.options;if(t){const r=new Se({camera:this.camera,controlsParams:{domElement:(e==null?void 0:e.domElement)||this.renderer.domElement},customControls:typeof t=="boolean"?void 0:t});this.controlsController=r}if(s){const r=new Pe({camera:this.camera,renderer:this.renderer,scene:this.scene});r.event.on("mouseDown",()=>{var i;(i=this.controlsController)==null||i.disable()}),r.event.on("mouseUp",()=>{var i;(i=this.controlsController)==null||i.enable()}),this.transformController=r}}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 r of s){const i=r.contentRect;this.handeleResize(i.width,i.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:r}=this.getSize();let i=Math.sqrt(t/(s*r));i=(i*100|0)/100;const n=Math.min(e,i);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:r,cameraController:i,composerController:n,cssRendererController:a}=this,l=this.renderer.getSize(new w.Vector2);l.x===t&&l.y===e||(i==null||i.setSize(t,e),r==null||r.setSize(t,e),n==null||n.setSize(t,e),a==null||a.setSize(t,e),this.installPlugins.forEach(d=>{var g;(g=d.setSize)==null||g.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:r,options:i}=this,{container:n}=i,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){r.setFromCamera(a,this.camera);const d=r.intersectObjects(e||this.scene.children,s);if(d.length)return{object:d[0].object,index:d[0].index,intersects:d}}}render(){var n,a,l,d,g,c,E;const{scene:t,camera:e,clock:s}=this,r=s.getDelta(),i=s.getElapsedTime();xt.update(),(n=this.controlsController)==null||n.update(r),this.installPlugins.forEach(y=>{var u;(u=y.update)==null||u.call(y,r,i)}),(a=this.helperController)==null||a.update(r,this.controlsController,this.cameraTarget),(l=this.composerController)!=null&&l.active?this.composerController.render():(d=this.rendererController)==null||d.render(),(g=this.helperController)==null||g.renderViewHelper(this.renderer),(c=this.cssRendererController)==null||c.render(t,e),(E=this.stats)==null||E.update(),this.event.emit("render",{delta:r,elapsed:i})}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){this.composerController.pipViewportState=t;let e=this.controlsController.cameraControlsArr[1];if(t){const{width:s,height:r}=this.getSize(),i=new DOMRect(t.x/s,(r-t.y-t.height)/r,t.width/s,t.height/r);if(e)e.enabled=!0,this.cameraController.cameraArr[1].position.copy(this.cameraController.camera.position);else{const n=this.cameraController.cloneCamera();e=this.controlsController.addCameraControls(n,i)}e.interactiveArea=i}else if(e){this.cameraController.setCameraActive(0);const s=this.getSize();this.rendererController.setViewport({x:0,y:0,width:s.width,height:s.height,scissor:!0,scissorTest:!1}),e.enabled=!1}}dispose(){var t,e,s,r,i,n,a,l,d,g,c;this.stop(),xt.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(E=>{var y;(y=E.dispose)==null||y.call(E)}),(e=this.controlsController)==null||e.dispose(),(s=this.transformController)==null||s.dispose(),(r=this.cssRendererController)==null||r.dispose(),(i=this.sceneController)==null||i.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(),(g=this.stats)==null||g.dom.remove(),(c=this.renderer)==null||c.domElement.remove()}};dt.options={isdev:K,stats:K,gui:K,helper:K,viewHelper:K,controls:!0,transformControls:K,resizeObserver:!0,renderer:ge,composer:Ze,scene:ve,camera:Oe,bloom:!1,bloomParams:Ye,ssao:!1,ssaoParams:Ne,css2DRenderer:!1,css2DRendererParams:V({},kt),css3DRenderer:!1,css3DRendererParams:V({},kt)};let ct=dt;const We=j.ACTION;exports.BaseObject=_e.BaseObject;exports.GUIObject=Et;exports.Pencil=ct;exports.cameraControlsAction=We;exports.default=ct;
94
+ `,defines:{}}),"baseTexture");return t.needsSwap=!0,t},Ct=1,K=!1,Ie=new w.MeshBasicMaterial({color:"black"}),He=new w.PointsMaterial({color:"black",sizeAttenuation:!1}),ke=new w.PointsMaterial({color:"black",sizeAttenuation:!0}),Ve=new w.SpriteMaterial({color:"black",sizeAttenuation:!0}),Be=new w.SpriteMaterial({color:"black",sizeAttenuation:!1}),Ne=new Vt.MeshLineMaterial({color:"black",sizeAttenuation:0,lineWidth:0}),Ye={kernelRadius:8,minDistance:.005,maxDistance:.1},Ze={threshold:0,strength:.4,radius:.1,bloomAlphaType:0},qe={multisampling:4,premultiplieAlpha:!1};class We{constructor(t){this.bloomComposerActive=!1,this.active=!0,this.bloomSelection=new Set,this.bloomLayer=new w.Layers,this.bloomMaterials={},this.bloomVisible={},this.pipViewportState=null,this.options=t;const{rendererController:e,sceneController:s,cameraController:i,composerParams:r}=t,{renderer:n}=e,{multisampling:a}=r,{maxSamples:l}=n.capabilities,d=n.getDrawingBufferSize(new w.Vector2),C=new w.WebGLRenderTarget(d.width,d.height,{samples:Math.min(a,l),type:w.HalfFloatType}),c=new ae.RenderPass(s.scene,i.camera),T=new vt.EffectComposer(n,C);T.addPass(c),this.renderer=n,this.scene=s.scene,this.camera=i.camera,this.finalComposer=T,this.renderPass=c;const y=this.getSize();this.setSize(y.width,y.height),i.event.on("cameraChange",u=>{this.changeCamera(u)}),s.event.on("sceneChange",u=>{this.changeScene(u)})}changeCamera(t){this.renderPass.camera=t,this.camera=t}changeScene(t){this.renderPass.scene=t,this.ssaoPass&&(this.ssaoPass.scene=t),this.scene=t}addOutputPass(){const{premultiplieAlpha:t}=this.options.composerParams,e=new Me;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 he.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 Et({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 me.UnrealBloomPass(new w.Vector2(window.innerWidth,window.innerHeight),i,r,s);this.bloomPass=a;const l=new vt.EffectComposer(e);l.renderToScreen=!1,l.addPass(this.renderPass),l.addPass(a),this.bloomComposer=l;const d=Fe(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 Et({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,a=i;r.material&&this.bloomLayer.test(r.layers)===!1&&(this.bloomMaterials[r.uuid]=r.material,n.isSprite?n.material.sizeAttenuation?n.material=Ve:n.material=Be:r.material instanceof Vt.MeshLineMaterial?r.material=Ne:a.isPoints?a.material.sizeAttenuation?a.material=ke:a.material=He:r.material=Ie)})})}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])})}finalComposerRender(){this.bloomComposerActive&&this.bloomComposer?(this.mixPass.enabled=!0,this.darkenNonBloomed(),this.bloomComposer.render(),this.restoreNonBloomed()):this.mixPass&&(this.mixPass.enabled=!1),this.finalComposer.render()}getSize(){return this.renderer.getSize(new w.Vector2)}render(){if(!this.active)return;const{cameraController:t,rendererController:e}=this.options;if(this.pipViewportState){t.setCameraActive(0);const s=this.getSize();e.setViewport({x:0,y:0,width:s.width,height:s.height,scissor:!0,scissorTest:!1}),this.finalComposerRender(),t.setCameraActive(1),e.setViewport(mt(B({},this.pipViewportState),{scissor:!0,scissorTest:!0})),this.finalComposerRender()}else this.finalComposerRender()}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 st.eventsExports.EventEmitter,this.clock=new w.Clock,this.userData={},this.pageActiveIndex=-1,this.dprCache=1,this.options=Jt(ct.options,t,{isMergeableObject:pe.isPlainObject}),this.dprCache=this.options.renderer.devicePixelRatio,this.event.setMaxListeners(1/0);const{container:s,stats:i,gui:r,transformControls:n}=this.options;if(this.init(),this.options.WebGPUTHREE||this.initComposer(),this.initCSSRenderer(),n&&this.initTransformControls(),i){const a=new te({horizontal:!1});a.init(this.renderer),a.dom.style.position="absolute",s.appendChild(a.dom),this.stats=a}if(r){const a=new ee;a.open(!1),this.gui=a}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))}addPage({sceneOptions:t,cameraOptions:e}){const s=this.cameraController.addPerspectiveCamera(e);return this.sceneController.addScene(t).add(s),this.controlsController.addCameraControls(s),this.sceneController.sceneArr.length-1}showPage(t){if(t!==this.pageActiveIndex){if(t!==-1&&!this.sceneController.sceneArr[t]){console.warn("addPage before showPage");return}this.sceneController.setSceneActive(t),this.controls.enabled=!1,t!==-1&&(this.cameraController.setCameraActive(t),this.controlsController.setCameraControlsActive(t),this.controls.enabled=!0),this.pageActiveIndex=t}}init(){const{container:t,WebGPUTHREE:e,helper:s,viewHelper:i,renderer:r,controlsParams:n}=this.options,{width:a,height:l}=this.getSize(),d=e?new Ee({width:a,height:l,renderer:e.WebGPURenderer,rendererParams:Ce}):new ye({width:a,height:l,rendererParams:mt(B({},r),{antialias:!1})}),C=new Te({width:a,height:l}),c=new we({}),T=new Pe({controlsParams:{domElement:(n==null?void 0:n.domElement)||d.renderer.domElement}});this.sceneController=c,this.cameraController=C,this.controlsController=T,this.rendererController=d;const y=this.addPage({sceneOptions:this.options.scene,cameraOptions:this.options.camera});if(this.pageActiveIndex=y,this.controls.setLookAt(0,0,400,0,0,0,!1),s){const u=new Se({container:t,sceneController:c,cameraController:C});u.add(c.scene),this.helperController=u,i&&u.addViewHelper()}t.appendChild(d.renderer.domElement)}initComposer(){const{bloom:t,bloomParams:e,ssao:s,ssaoParams:i,composer:r}=this.options,n=new We({rendererController:this.rendererController,sceneController:this.sceneController,cameraController:this.cameraController,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 Le(t);e&&n.addRenderer("css2d",i),s&&n.addRenderer("css3d",r),this.cssRendererController=n}}initTransformControls(){const t=new Ae({camera:this.camera,renderer:this.renderer,scene:this.scene});t.event.on("mouseDown",()=>{var e;(e=this.controlsController)==null||e.disable()}),t.event.on("mouseUp",()=>{var e;(e=this.controlsController)==null||e.enable()}),this.transformController=t}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 C;(C=d.setSize)==null||C.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,index:d[0].index,intersects:d}}}render(){var n,a,l,d,C,c,T;const{scene:t,camera:e,clock:s}=this,i=s.getDelta(),r=s.getElapsedTime();xt.update(),(n=this.controlsController)==null||n.update(i),this.installPlugins.forEach(y=>{var u;(u=y.update)==null||u.call(y,i,r)}),(a=this.helperController)==null||a.update(i,this.controlsController,this.cameraTarget),(l=this.composerController)!=null&&l.active?this.composerController.render():(d=this.rendererController)==null||d.render(this.scene,this.camera),(C=this.helperController)==null||C.renderViewHelper(this.renderer),(c=this.cssRendererController)==null||c.render(t,e),(T=this.stats)==null||T.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){this.composerController.pipViewportState=t;let e=this.controlsController.cameraControlsArr[1];if(t){const{width:s,height:i}=this.getSize(),r=new DOMRect(t.x/s,(i-t.y-t.height)/i,t.width/s,t.height/i);if(e)e.enabled=!0,this.cameraController.cameraArr[1].position.copy(this.cameraController.camera.position);else{const n=this.cameraController.cloneCamera();e=this.controlsController.addCameraControls(n,r)}e.interactiveArea=r}else if(e){this.cameraController.setCameraActive(0);const s=this.getSize();this.rendererController.setViewport({x:0,y:0,width:s.width,height:s.height,scissor:!0,scissorTest:!1});const i=s.width/s.height;this.cameraController.camera.aspect!==i&&(this.cameraController.camera.aspect=i,this.cameraController.camera.updateProjectionMatrix()),e.enabled=!1}}dispose(){var t,e,s,i,r,n,a,l,d,C,c;this.stop(),xt.removeAll(),this.event.removeAllListeners(),(t=this.resizeObserver)==null||t.unobserve(this.options.container),this.installPlugins.forEach(T=>{var y;(y=T.dispose)==null||y.call(T)}),(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(),(C=this.stats)==null||C.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,renderer:ge,composer:qe,scene:ve,camera:Oe,bloom:!1,bloomParams:Ze,ssao:!1,ssaoParams:Ye,css2DRenderer:!1,css2DRendererParams:B({},kt),css3DRenderer:!1,css3DRendererParams:B({},kt)};let lt=ct;const Ge=j.ACTION;exports.BaseObject=_e.BaseObject;exports.GUIObject=Et;exports.Pencil=lt;exports.cameraControlsAction=Ge;exports.default=lt;