@yschindel/ara3d-webgl 1.3.7 → 1.3.8

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.
@@ -4032,7 +4032,7 @@ data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAACAvzbMAAAAAXNSR0IArs
4032
4032
  *
4033
4033
  * Copyright Kees C. Bakker / KeesTalksTech
4034
4034
  * Released under the MIT license
4035
- */Object.defineProperty(r,"__esModule",{value:!0}),r.SignalList=r.SignalHandlingBase=r.SignalDispatcher=void 0;const e=bo;Object.defineProperty(r,"SignalDispatcher",{enumerable:!0,get:function(){return e.SignalDispatcher}});const t=gl;Object.defineProperty(r,"SignalHandlingBase",{enumerable:!0,get:function(){return t.SignalHandlingBase}});const n=To;Object.defineProperty(r,"SignalList",{enumerable:!0,get:function(){return n.SignalList}})}(Ms);class Yw{constructor(e){$(this,"camera");this.camera=e}applySettings(e){this.camera.fov=e.camera.fov,this.camera.zoom=e.camera.zoom,this.camera.near=e.camera.near,this.camera.far=e.camera.far,this.camera.updateProjectionMatrix()}updateProjection(e){this.camera.aspect=e,this.camera.updateProjectionMatrix()}frustrumSizeAt(e){const n=this.camera.position.distanceTo(e)*Math.tan(this.camera.fov/2*(Math.PI/180));return new he(n,n)}}class Qw{constructor(e){$(this,"camera");this.camera=e}applySettings(e){this.camera.zoom=e.camera.zoom,this.camera.near=-e.camera.far,this.camera.far=e.camera.far,this.camera.updateProjectionMatrix()}updateProjection(e,t){const n=Math.max(e.x,e.y);this.camera.left=-n*t,this.camera.right=n*t,this.camera.top=n,this.camera.bottom=-n,this.camera.updateProjectionMatrix()}}class Bm{constructor(e){$(this,"_camera");this._camera=e}move2(e,t){const n=t==="XY"?new U(-e.x,e.y,0):t==="XZ"?new U(-e.x,0,e.y):void 0;n&&this.move3(n)}move1(e,t){const n=new U(t==="X"?-e:0,t==="Y"?e:0,t==="Z"?e:0);this.move3(n)}orbitTowards(e){const t=this._camera.forward,n=t.clone().setY(0),i=e.clone().setY(0),s=n.angleTo(i)*Math.sign(n.cross(i).y),o=Math.asin(e.y)-Math.asin(t.y),a=new he(o,s);a.multiplyScalar(180/Math.PI),this.orbit(a)}frame(e,t){e instanceof Gt&&(e=e.getBoundingSphere(new Pt)),e instanceof Pt&&this.frameSphere(e,t??this._camera.forward)}frameSphere(e,t){const n=this._camera.camPerspective.camera.fov*Math.PI/180,i=e.radius*1.2/Math.tan(n/2),s=t.clone().multiplyScalar(-i).add(e.center);this.set(s,e.center)}}class Kw extends Bm{constructor(t,n){super(t);$(this,"_movement");$(this,"_clock",new el);$(this,"onProgress");$(this,"_duration",1);this._movement=n}init(t){this.cancel(),this._duration=t,this._clock.start(),this.animate()}cancel(){this._clock.stop(),this.onProgress=void 0}animate(){this._clock.running&&(this.update(),requestAnimationFrame(()=>this.animate()))}easeOutCubic(t){return 1-Math.pow(1-t,3)}update(){let t=this._clock.getElapsedTime()/this._duration;t=this.easeOutCubic(t),t>=1&&(t=1,this._clock.stop(),this.onProgress=void 0),this.onProgress?.(t)}move3(t){const n=t.clone();n.applyQuaternion(this._camera.quaternion);const i=this._camera.position.clone(),s=this._camera.position.clone().add(n),o=new U;this.onProgress=a=>{o.copy(i),o.lerp(s,a),this._movement.move3(o)}}rotate(t){const n=new Zt(0,0,0,"YXZ");n.setFromQuaternion(this._camera.quaternion),n.x+=t.x,n.y+=t.y,n.z=0;const i=Math.PI*.48;n.x=Math.max(-i,Math.min(i,n.x));const s=this._camera.quaternion.clone(),o=new wt().setFromEuler(n),a=new wt;this.onProgress=c=>{a.copy(s),a.slerp(o,c),this._movement.applyRotation(a)}}zoom(t){const n=this._camera.orbitDistance*t;this.setDistance(n)}setDistance(t){const n=this._camera.position.clone(),i=this._camera.target.clone().lerp(n,t/this._camera.orbitDistance);this.onProgress=s=>{this._camera.position.copy(n),this._camera.position.lerp(i,s)}}orbit(t){const n=this._camera.position.clone(),i=this._camera.target.clone(),s=new he;this.onProgress=o=>{s.set(0,0),s.lerp(t,o),this._movement.set(n,i),this._movement.orbit(s)}}target(t){const i=t.clone().sub(this._camera.position),s=this._camera.quaternion.clone(),o=new wt().setFromUnitVectors(new U(0,0,-1),i.normalize());this.onProgress=a=>{const c=s.clone().slerp(o,a);this._movement.applyRotation(c)}}reset(){this.set(this._camera._savedPosition,this._camera._savedTarget)}set(t,n){const i=n??this._camera.target,s=this._camera.position.clone(),o=this._camera.target.clone();this.onProgress=a=>{this._movement.set(s.clone().lerp(t,a),o.clone().lerp(i,a))}}}class jw extends Bm{zoom(e){const t=this._camera.orbitDistance*e;this.setDistance(t)}reset(){this.set(this._camera._savedPosition,this._camera._savedTarget)}setDistance(e){const t=this._camera.target.clone().sub(this._camera.forward.multiplyScalar(e));this.set(t,this._camera.target)}rotate(e){const t=e.clone().multiply(this._camera.allowedRotation),n=this.predictRotate(t);this.applyRotation(n)}applyRotation(e){this._camera.quaternion.copy(e);const t=this._camera.forward.multiplyScalar(this._camera.orbitDistance).add(this._camera.position);this.set(this._camera.position,t)}target(e){this.set(this._camera.position,e)}orbit(e){const t=e.clone().multiply(this._camera.allowedRotation),n=this.predictOrbit(t);this.set(n)}move3(e){const t=e.clone();t.applyQuaternion(this._camera.quaternion);const n=this.lockVector(t,new U),i=this._camera.position.clone().add(n),s=this._camera.target.clone().add(n);this.set(i,s)}set(e,t){const n=this.lockVector(e,this._camera.position);this._camera.position.copy(n),t=t??this._camera.target,this._camera.target.copy(t),this._camera.camPerspective.camera.lookAt(t),this._camera.camPerspective.camera.up.set(0,1,0)}lockVector(e,t){const n=this._camera.allowedMovement.x===0?t.x:e.x,i=this._camera.allowedMovement.y===0?t.y:e.y,s=this._camera.allowedMovement.z===0?t.z:e.z;return new U(n,i,s)}predictOrbit(e){const t=this.predictRotate(e),n=new U(0,0,1).applyQuaternion(t).multiplyScalar(this._camera.orbitDistance);return this._camera.target.clone().add(n)}predictRotate(e){const t=new Zt(0,0,0,"YXZ");t.setFromQuaternion(this._camera.quaternion),t.x+=e.x*Math.PI/180,t.y+=e.y*Math.PI/180,t.z=0;const n=Math.PI*.4999;return t.x=Math.max(-n,Math.min(n,t.x)),new wt().setFromEuler(t)}}class Jw{constructor(e,t){$(this,"camPerspective");$(this,"camOrthographic");$(this,"_viewport");$(this,"_lerp");$(this,"_movement");$(this,"_inputVelocity",new U);$(this,"_velocity",new U);$(this,"_speed",0);$(this,"_orthographic",!1);$(this,"_target",new U);$(this,"_lastPosition",new U);$(this,"_lastQuaternion",new wt);$(this,"_lastTarget",new U);$(this,"_savedPosition",new U(0,0,-5));$(this,"_savedTarget",new U(0,0,0));$(this,"_onValueChanged",new Ms.SignalDispatcher);$(this,"_hasMoved");$(this,"_onMoved",new Ms.SignalDispatcher);$(this,"_force",!1);$(this,"_allowedMovement",new U(1,1,1));$(this,"_allowedRotation",new he(1,1));$(this,"_defaultForward",new U(0,0,1));$(this,"_velocityBlendFactor",1e-4);$(this,"_moveSpeed",1);this.camPerspective=new Yw(new kt),this.camOrthographic=new Qw(new ur),this._movement=new jw(this),this._lerp=new Kw(this,this._movement),this._viewport=e,this.applySettings(t),this.do().orbitTowards(this._defaultForward),this.do().setDistance(-1e3)}get onValueChanged(){return this._onValueChanged.asEvent()}get hasMoved(){return this._hasMoved}get onMoved(){return this._onMoved.asEvent()}get allowedMovement(){return this._force?new U(1,1,1):this._allowedMovement}set allowedMovement(e){this._allowedMovement.copy(e),this._allowedMovement.x=this._allowedMovement.x===0?0:1,this._allowedMovement.y=this._allowedMovement.y===0?0:1,this._allowedMovement.z=this._allowedMovement.z===0?0:1}get allowedRotation(){return this._force?new he(1,1):this._allowedRotation}set allowedRotation(e){this._allowedRotation.copy(e),this._allowedRotation.x=this._allowedRotation.x===0?0:1,this._allowedRotation.y=this._allowedRotation.y===0?0:1}get defaultForward(){return this._defaultForward}set defaultForward(e){e.x===0&&e.y===0&&e.z===0?this._defaultForward.set(0,0,1):this._defaultForward.copy(e)}do(e=!1){return this._force=e,this._lerp.cancel(),this._movement}lerp(e=1,t=!1){return this.stop(),this._force=t,this._lerp.init(e),this._lerp}frustrumSizeAt(e){return this.camPerspective.frustrumSizeAt(e)}notifyMovement(){this._hasMoved=!0,this._onMoved.dispatch()}get three(){return this._orthographic?this.camOrthographic.camera:this.camPerspective.camera}get quaternion(){return this.camPerspective.camera.quaternion}get position(){return this.camPerspective.camera.position}get matrix(){return this.camPerspective.camera.updateMatrix(),this.camPerspective.camera.matrix}get forward(){return this.camPerspective.camera.getWorldDirection(new U)}get speed(){return this._speed}set speed(e){this._speed=Mw(e,-25,25),this._onValueChanged.dispatch()}get localVelocity(){const e=this._velocity.clone();return e.applyQuaternion(this.quaternion.clone().invert()),e.setZ(-e.z),e}set localVelocity(e){this._lerp.cancel(),this._inputVelocity.copy(e),this._inputVelocity.setZ(-this._inputVelocity.z)}stop(){this._inputVelocity.set(0,0,0),this._velocity.set(0,0,0)}get target(){return this._target}applySettings(e){this._defaultForward=new U().copy(e.camera.forward),this._orthographic=e.camera.orthographic,this.allowedMovement=e.camera.allowedMovement,this.allowedRotation=e.camera.allowedRotation,this.camPerspective.applySettings(e),this.camOrthographic.applySettings(e),this._moveSpeed=e.camera.controls.moveSpeed,this._onValueChanged.dispatch()}get orbitDistance(){return this.position.distanceTo(this._target)}save(){this._lerp.cancel(),this._savedPosition.copy(this.position),this._savedTarget.copy(this._target)}updateProjection(){const e=this._viewport.getAspectRatio();this.camPerspective.updateProjection(e);const t=this.camPerspective.frustrumSizeAt(this.target);this.camOrthographic.updateProjection(t,e)}get orthographic(){return this._orthographic}set orthographic(e){e!==this._orthographic&&(this._orthographic=e,this._onValueChanged.dispatch())}update(e){this.applyVelocity(e)&&this.updateOrthographic();const t=this.checkForMovement();return t&&(this.camOrthographic.camera.position.copy(this.position),this.camOrthographic.camera.quaternion.copy(this.quaternion)),this.updateProjection(),t}applyVelocity(e){if(this._inputVelocity.x===0&&this._inputVelocity.y===0&&this._inputVelocity.z===0&&this._velocity.x===0&&this._velocity.y===0&&this._velocity.z===0)return!1;const t=Math.pow(this._velocityBlendFactor,e),n=1-t;this._velocity.multiplyScalar(t);const i=this._inputVelocity.clone().multiplyScalar(n);if(this._velocity.add(i),this._velocity.lengthSq()<e/10)return this._velocity.set(0,0,0),!1;const s=this._velocity.clone().multiplyScalar(e*this.getVelocityMultiplier());return this.do().move3(s),!0}updateOrthographic(){if(this.orthographic){const t=this._lastTarget.clone().sub(this.position).dot(this.forward);this.target.copy(this.forward).multiplyScalar(t).add(this.position);const n=this._lastPosition.clone().sub(this._target),i=this.position.clone().sub(this._target);(n.dot(i)<0||i.lengthSq()<1)&&this.position.copy(this._target).add(this.forward.multiplyScalar(-1))}}getVelocityMultiplier(){const t=!this._lastQuaternion.equals(this.quaternion)?1:1.66;return Math.pow(1.25,this.speed)*this._moveSpeed*t*100}checkForMovement(){return this._hasMoved=!1,(!this._lastPosition.equals(this.position)||!this._lastQuaternion.equals(this.quaternion)||!this._lastTarget.equals(this._target))&&(this._hasMoved=!0,this._onMoved.dispatch()),this._lastPosition.copy(this.position),this._lastQuaternion.copy(this.quaternion),this._lastTarget.copy(this._target),this._hasMoved}}class zu{constructor(e){$(this,"_viewer");$(this,"_unregisters",[]);$(this,"reg",(e,t,n)=>{e.addEventListener(t,n),this._unregisters.push(()=>e.removeEventListener(t,n))});this._viewer=e}register(){this._unregisters.length>0||this.addListeners()}addListeners(){}unregister(){this._unregisters.forEach(e=>e()),this._unregisters.length=0,this.reset()}reset(){}}const At={KEY_0:48,KEY_1:49,KEY_2:50,KEY_3:51,KEY_4:52,KEY_5:53,KEY_6:54,KEY_7:55,KEY_8:56,KEY_9:57,KEY_LEFT:37,KEY_RIGHT:39,KEY_UP:38,KEY_DOWN:40,KEY_CTRL:17,KEY_SHIFT:16,KEY_ENTER:13,KEY_SPACE:32,KEY_TAB:9,KEY_ESCAPE:27,KEY_BACKSPACE:8,KEY_HOME:36,KEY_END:35,KEY_INSERT:45,KEY_DELETE:46,KEY_ALT:18,KEY_F1:112,KEY_F2:113,KEY_F3:114,KEY_F4:115,KEY_F5:116,KEY_F6:117,KEY_F7:118,KEY_F8:119,KEY_F9:120,KEY_F10:121,KEY_F11:122,KEY_F12:123,KEY_NUMPAD0:96,KEY_NUMPAD1:97,KEY_NUMPAD2:98,KEY_NUMPAD3:99,KEY_NUMPAD4:100,KEY_NUMPAD5:101,KEY_NUMPAD6:102,KEY_NUMPAD7:103,KEY_NUMPAD8:104,KEY_NUMPAD9:105,KEY_ADD:107,KEY_SUBTRACT:109,KEY_MULTIPLY:106,KEY_DIVIDE:111,KEY_SEPARATOR:108,KEY_DECIMAL:110,KEY_OEM_PLUS:187,KEY_OEM_MINUS:189,KEY_A:65,KEY_B:66,KEY_C:67,KEY_D:68,KEY_E:69,KEY_F:70,KEY_G:71,KEY_H:72,KEY_I:73,KEY_J:74,KEY_K:75,KEY_L:76,KEY_M:77,KEY_N:78,KEY_O:79,KEY_P:80,KEY_Q:81,KEY_R:82,KEY_S:83,KEY_T:84,KEY_U:85,KEY_V:86,KEY_W:87,KEY_X:88,KEY_Y:89,KEY_Z:90},$w=new Set(Object.values(At));class eS extends zu{constructor(){super(...arguments);$(this,"SHIFT_MULTIPLIER",3);$(this,"isUpPressed",!1);$(this,"isDownPressed",!1);$(this,"isLeftPressed",!1);$(this,"isRightPressed",!1);$(this,"isEPressed",!1);$(this,"isQPressed",!1);$(this,"isShiftPressed",!1);$(this,"isCtrlPressed",!1);$(this,"arrowsEnabled",!0)}addListeners(){this.reg(document,"keydown",t=>this.onKeyDown(t)),this.reg(document,"keyup",t=>this.onKeyUp(t)),this.reg(this._viewer.viewport.canvas,"focusout",()=>this.reset()),this.reg(window,"resize",()=>this.reset())}reset(){this.isUpPressed=!1,this.isDownPressed=!1,this.isLeftPressed=!1,this.isRightPressed=!1,this.isEPressed=!1,this.isQPressed=!1,this.isShiftPressed=!1,this.isCtrlPressed=!1,this.applyMove()}get camera(){return this._viewer.camera}onKeyUp(t){this.onKey(t,!1)}onKeyDown(t){this.onKey(t,!0)}onKey(t,n){switch(!n&&$w.has(t.keyCode)&&this._viewer.inputs.KeyAction(t.keyCode)&&t.preventDefault(),t.keyCode){case At.KEY_W:case At.KEY_UP:this.isUpPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_S:case At.KEY_DOWN:this.isDownPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_D:case At.KEY_RIGHT:this.isRightPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_A:case At.KEY_LEFT:this.isLeftPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_E:this.isEPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_Q:this.isQPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_SHIFT:this.isShiftPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_CTRL:this.isCtrlPressed=n,t.preventDefault();break}}applyMove(){const t=new U((this.isRightPressed?1:0)-(this.isLeftPressed?1:0),(this.isEPressed?1:0)-(this.isQPressed?1:0),(this.isUpPressed?1:0)-(this.isDownPressed?1:0)),n=this.isShiftPressed?this.SHIFT_MULTIPLIER:1;t.multiplyScalar(n),this.arrowsEnabled&&(this.camera.localVelocity=t)}}class tS extends zu{constructor(t){super(t);$(this,"TAP_DURATION_MS",500);$(this,"DOUBLE_TAP_DELAY_MS",500);$(this,"TAP_MAX_MOVE_PIXEL",5);$(this,"ZOOM_SPEED",1);$(this,"MOVE_SPEED",100);$(this,"rotateSpeed",1);$(this,"orbitSpeed",1);$(this,"_touch");$(this,"_touch1");$(this,"_touch2");$(this,"_touchStartTime");$(this,"_lastTapMs");$(this,"_touchStart");$(this,"reset",()=>{this._touch=this._touch1=this._touch2=this._touchStartTime=void 0});$(this,"onTap",t=>{const n=new Date().getTime();this._lastTapMs&&n-this._lastTapMs<this.DOUBLE_TAP_DELAY_MS,this._lastTapMs=new Date().getTime()});$(this,"onTouchStart",t=>{t.preventDefault(),!(!t||!t.touches||!t.touches.length)&&(this._touchStartTime=new Date().getTime(),t.touches.length===1?(this._touch=this.touchToVector(t.touches[0]),this._touch1=this._touch2=void 0):t.touches.length===2&&(this._touch1=this.touchToVector(t.touches[0]),this._touch2=this.touchToVector(t.touches[1]),this._touch=this.average(this._touch1,this._touch2)),this._touchStart=this._touch)});$(this,"onDrag",t=>{this._viewer.inputs.pointerActive==="orbit"?this.camera.do().orbit(this.toRotation(t,this.orbitSpeed)):this.camera.do().rotate(this.toRotation(t,this.rotateSpeed))});$(this,"onDoubleDrag",t=>{const n=t.clone().multiplyScalar(this.MOVE_SPEED);this.camera.do().move2(n,"XY")});$(this,"onPinchOrSpread",t=>{this._viewer.inputs.pointerActive==="orbit"?this.camera.do().zoom(1+t*this.ZOOM_SPEED):this.camera.do().move1(t*this.ZOOM_SPEED,"Z")});$(this,"onTouchMove",t=>{if(t.preventDefault(),!(!t||!t.touches||!t.touches.length)&&!!this._touch){if(t.touches.length===1){const n=this.touchToVector(t.touches[0]),i=this.viewport.getSize(),s=n.clone().sub(this._touch).multiply(new he(1/i.x,1/i.y));this._touch=n,this.onDrag(s);return}if(!(!this._touch1||!this._touch2)&&t.touches.length>=2){const n=this.touchToVector(t.touches[0]),i=this.touchToVector(t.touches[1]),s=this.average(n,i),o=this.viewport.getSize(),a=this._touch.clone().sub(s).multiply(new he(-1/o.x,-1/o.y)),c=n.distanceTo(i),l=this._touch1.distanceTo(this._touch2),h=Math.min(o.x,o.y),u=(c-l)/-h;this._touch=s,this._touch1=n,this._touch2=i,a.length()>Math.abs(u)?this.onDoubleDrag(a):this.onPinchOrSpread(u)}}});$(this,"onTouchEnd",t=>{if(this.isSingleTouch()&&this._touchStart&&this._touch){const n=new Date().getTime()-this._touchStartTime,i=this._touch.distanceTo(this._touchStart);n<this.TAP_DURATION_MS&&i<this.TAP_MAX_MOVE_PIXEL&&this.onTap(this._touch)}this.reset()});this.rotateSpeed=t.settings.camera.controls.rotateSpeed,this.orbitSpeed=t.settings.camera.controls.orbitSpeed}get camera(){return this._viewer.camera}get viewport(){return this._viewer.viewport}addListeners(){const t=this.viewport.canvas;this.reg(t,"touchstart",this.onTouchStart),this.reg(t,"touchend",this.onTouchEnd),this.reg(t,"touchmove",this.onTouchMove)}toRotation(t,n){const i=new he;return i.x=t.y,i.y=t.x,i.multiplyScalar(-180*n),i}isSingleTouch(){return this._touch!==void 0&&this._touchStartTime!==void 0&&this._touch1===void 0&&this._touch2===void 0}touchToVector(t){return new he(t.pageX,t.pageY)}average(t,n){return t.clone().lerp(n,.5)}}class nS extends zu{constructor(t){super(t);$(this,"_idleDelayMs",150);$(this,"zoomSpeed",1);$(this,"panSpeed",100);$(this,"rotateSpeed",1);$(this,"orbitSpeed",1);$(this,"_buttonDown");$(this,"_hasMouseMoved",!1);$(this,"_hasCameraMoved",!1);$(this,"_idleTimeout");$(this,"_idlePosition");$(this,"_lastPosition");$(this,"_downPosition");$(this,"reset",()=>{this._buttonDown=void 0,this._hasMouseMoved=!1,this._lastPosition=this._downPosition=void 0,clearTimeout(this._idleTimeout)});$(this,"onMouseOut",t=>{t.stopImmediatePropagation(),this._buttonDown=void 0,this._hasMouseMoved=!1,this._lastPosition=void 0,this.resetIdle()});$(this,"onCameraMoved",()=>{this.resetIdle(),this._hasCameraMoved=!0});$(this,"onMouseMove",t=>{t.stopImmediatePropagation(),this._lastPosition=new he(t.offsetX,t.offsetY),(!this._idlePosition||this._lastPosition.distanceTo(this._idlePosition)>5)&&this.resetIdle(),this._buttonDown&&this.onMouseDrag(t)});$(this,"onMouseDown",t=>{if(t.stopImmediatePropagation(),t.preventDefault(),this._buttonDown)return;this.inputs.ContextMenu(void 0),this._hasCameraMoved=!1,this._downPosition=new he(t.offsetX,t.offsetY),this._hasMouseMoved=!1,this.viewport.canvas.focus(),this._buttonDown=this.getButton(t);const n=this._buttonDown==="middle"?"pan":this._buttonDown==="right"?"look":void 0;this.inputs.pointerOverride=n});$(this,"onMouseWheel",t=>{t.preventDefault(),t.stopImmediatePropagation();const n=Math.sign(t.deltaY);if(t.ctrlKey)this.camera.speed-=n;else{const i=Math.pow(1.3,n);this.camera.lerp(.3).zoom(i)}});$(this,"onMouseUp",t=>{t.stopImmediatePropagation(),this.resetIdle(),this.getButton(t)!==this._buttonDown&&(t.preventDefault(),this._buttonDown&&(t.button===2&&!this._hasMouseMoved&&this.inputs.ContextMenu(new he(t.clientX,t.clientY)),this._buttonDown=void 0,this.inputs.pointerOverride=void 0))});this.rotateSpeed=t.settings.camera.controls.rotateSpeed,this.orbitSpeed=t.settings.camera.controls.orbitSpeed}get camera(){return this._viewer.camera}get viewport(){return this._viewer.viewport}get canvas(){return this.viewport.canvas}get inputs(){return this._viewer.inputs}addListeners(){this.reg(this.canvas,"mousedown",this.onMouseDown),this.reg(this.canvas,"wheel",this.onMouseWheel),this.reg(this.canvas,"mousemove",this.onMouseMove),this.reg(this.canvas,"mouseup",this.onMouseUp),this.reg(this.canvas,"mouseout",this.onMouseOut),this.reg(this.canvas,"contextmenu",t=>t.preventDefault()),this._unregisters.push(this.camera.onMoved.subscribe(()=>this.onCameraMoved()))}resetIdle(){this._idlePosition&&(this._idlePosition=void 0),clearTimeout(this._idleTimeout)}onMouseDrag(t){t.stopImmediatePropagation(),t.preventDefault();const n=t.movementX||t.mozMovementX||t.webkitMovementX||0,i=t.movementY||t.mozMovementY||t.webkitMovementY||0,s=this.viewport.getSize(),o=new he(n/s.x,i/s.y),a=new he(t.offsetX,t.offsetY);switch(this._hasMouseMoved=this._hasMouseMoved||this._downPosition&&this._downPosition?.distanceTo(a)>4,this._buttonDown){case"main":this.onMouseMainDrag(o);break;case"middle":this.onMouseMiddleDrag(o);break;case"right":this.onMouseRightDrag(o);break}}toRotation(t,n){const i=t.clone();return i.x=-t.y,i.y=-t.x,i.multiplyScalar(180*n),i}onMouseMainDrag(t){switch(this.inputs.pointerActive){case"orbit":this.camera.do().orbit(this.toRotation(t,this.orbitSpeed));break;case"look":this.camera.do().rotate(this.toRotation(t,this.rotateSpeed));break;case"pan":this.camera.do().move2(t.multiplyScalar(this.panSpeed),"XY");break;case"zoom":this.camera.do().zoom(1+t.y*this.zoomSpeed);break}}onMouseMiddleDrag(t){this.camera.do().move2(t.multiplyScalar(100),"XY")}onMouseRightDrag(t){this.camera.do().rotate(this.toRotation(t,this.rotateSpeed))}getButton(t){return t.buttons&1?"main":t.buttons&2?"right":t.buttons&4?"middle":void 0}getModifier(t){return t.ctrlKey?"ctrl":t.shiftKey?"shift":"none"}}var Om={},Ts={};Object.defineProperty(Ts,"__esModule",{value:!0}),Ts.SimpleEventDispatcher=void 0;const Fm=br;class iS extends Fm.DispatcherBase{constructor(){super()}dispatch(e){const t=this._dispatch(!1,this,arguments);if(t==null)throw new Fm.DispatchError("Got `null` back from dispatch.");return t}dispatchAsync(e){this._dispatch(!0,this,arguments)}asEvent(){return super.asEvent()}}Ts.SimpleEventDispatcher=iS;var _l={},Co={};Object.defineProperty(Co,"__esModule",{value:!0}),Co.SimpleEventList=void 0;const rS=br,sS=Ts;class oS extends rS.EventListBase{constructor(){super()}createDispatcher(){return new sS.SimpleEventDispatcher}}Co.SimpleEventList=oS,Object.defineProperty(_l,"__esModule",{value:!0}),_l.SimpleEventHandlingBase=void 0;const aS=br,cS=Co;class lS extends aS.HandlingBase{constructor(){super(new cS.SimpleEventList)}}_l.SimpleEventHandlingBase=lS;var vl={};Object.defineProperty(vl,"__esModule",{value:!0}),vl.NonUniformSimpleEventList=void 0;const hS=Ts;class uS{constructor(){this._events={}}get(e){if(this._events[e])return this._events[e];const t=this.createDispatcher();return this._events[e]=t,t}remove(e){delete this._events[e]}createDispatcher(){return new hS.SimpleEventDispatcher}}vl.NonUniformSimpleEventList=uS,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.NonUniformSimpleEventList=r.SimpleEventList=r.SimpleEventHandlingBase=r.SimpleEventDispatcher=void 0;const e=Ts;Object.defineProperty(r,"SimpleEventDispatcher",{enumerable:!0,get:function(){return e.SimpleEventDispatcher}});const t=_l;Object.defineProperty(r,"SimpleEventHandlingBase",{enumerable:!0,get:function(){return t.SimpleEventHandlingBase}});const n=vl;Object.defineProperty(r,"NonUniformSimpleEventList",{enumerable:!0,get:function(){return n.NonUniformSimpleEventList}});const i=Co;Object.defineProperty(r,"SimpleEventList",{enumerable:!0,get:function(){return i.SimpleEventList}})}(Om);class zm{constructor(e){$(this,"_viewer");this._viewer=e}onKeyAction(e){const t=this._viewer.camera;switch(e){case At.KEY_P:return t.orthographic=!t.orthographic,!0;case At.KEY_ADD:case At.KEY_OEM_PLUS:return t.speed+=1,!0;case At.KEY_SUBTRACT:case At.KEY_OEM_MINUS:return t.speed-=1,!0;case At.KEY_F8:case At.KEY_SPACE:return this._viewer.inputs.pointerActive=this._viewer.inputs.pointerFallback,!0;case At.KEY_HOME:return t.lerp(1).reset(),!0;case At.KEY_ESCAPE:return!0;case At.KEY_Z:case At.KEY_F:return t.lerp(1).frame("all"),!0;default:return!1}}}class fS{constructor(e){$(this,"_viewer");$(this,"_scheme");$(this,"touch");$(this,"mouse");$(this,"keyboard");$(this,"_pointerActive","orbit");$(this,"_pointerFallback","look");$(this,"_pointerOverride");$(this,"_onPointerModeChanged",new Ms.SignalDispatcher);$(this,"_onPointerOverrideChanged",new Ms.SignalDispatcher);$(this,"_onContextMenu",new Om.SimpleEventDispatcher);$(this,"unregisterAll",()=>{this.mouse.unregister(),this.keyboard.unregister(),this.touch.unregister()});this._viewer=e,this._scheme=new zm(e),this.keyboard=new eS(e),this.mouse=new nS(e),this.touch=new tS(e),this.pointerActive=e.settings.camera.controls.orbit?"orbit":"look",this._pointerFallback=e.settings.camera.controls.orbit?"look":"orbit"}get pointerFallback(){return this._pointerFallback}get pointerActive(){return this._pointerActive}get pointerOverride(){return this._pointerOverride}set pointerOverride(e){e!==this._pointerOverride&&(this._pointerOverride=e,this._onPointerOverrideChanged.dispatch())}set pointerActive(e){e!==this._pointerActive&&(e==="look"?this._pointerFallback="orbit":e==="orbit"&&(this._pointerFallback="look"),this._pointerActive=e,this._onPointerModeChanged.dispatch())}get onPointerModeChanged(){return this._onPointerModeChanged.asEvent()}get onPointerOverrideChanged(){return this._onPointerOverrideChanged.asEvent()}get onContextMenu(){return this._onContextMenu.asEvent()}get scheme(){return this._scheme}KeyAction(e){return this._scheme.onKeyAction(e)}ContextMenu(e){this._onContextMenu.dispatch(e)}registerAll(){this.keyboard.register(),this.mouse.register(),this.touch.register()}resetAll(){this.mouse.reset(),this.keyboard.reset(),this.touch.reset()}}class dS{constructor(){$(this,"mesh");$(this,"_source");$(this,"_size",1);$(this,"_geometry");$(this,"_material");$(this,"_texture");this._geometry=new rr,this._material=new un({transparent:!0,depthTest:!0,depthWrite:!1}),this.mesh=new St(this._geometry,this._material),this.mesh.renderOrder=-1}applyViewerSettings(e){this._size=e.groundPlane.size,this.mesh.visible=e.groundPlane.visible,this.applyTexture(e.groundPlane.encoding,e.groundPlane.texture),this._material.color.copy(e.groundPlane.color),this._material.opacity=e.groundPlane.opacity}adaptToContent(e){const t=e.getCenter(new U),n=new U(t.x,e.min.y-Math.abs(e.min.y)*.01,t.z);this.mesh.position.copy(n),this.mesh.quaternion.copy(new wt().setFromEuler(new Zt(1.5*Math.PI,0,0)));const s=(e?.getBoundingSphere(new Pt)?.radius??1)*this._size,o=new U(1,1,1).multiplyScalar(s);this.mesh.scale.copy(o)}applyTexture(e,t){if(t!==this._source&&(this._source=t,this._texture?.dispose(),this._texture=void 0,!(!t||!e))){if(e==="url"){const n=new lu;this._texture=n.load(t)}if(e==="base64"){const n=new Image;n.src=t;const i=new xt;this._texture=i,this._texture.image=n,n.onload=()=>{i.needsUpdate=!0}}if(!this._texture){console.error("Failed to load texture: "+t);return}this._material.map=this._texture}}dispose(){this._geometry?.dispose(),this._material?.dispose(),this._texture?.dispose(),this._texture=void 0}}class pS{constructor(e){$(this,"skyLight");$(this,"ambientLight");$(this,"sunLights");$(this,"_groundPlane");this._groundPlane=new dS,this.skyLight=new hu,this.ambientLight=new mu,this.sunLights=[],this.applySettings(e)}get groundPlane(){return this._groundPlane.mesh}loadGroundTexture(e,t){this._groundPlane.applyTexture(e,t)}getObjects(){return[this._groundPlane.mesh,this.skyLight,this.ambientLight,...this.sunLights]}applySettings(e){this._groundPlane.applyViewerSettings(e),this.skyLight.color.copy(e.skylight.skyColor),this.skyLight.groundColor.copy(e.skylight.groundColor),this.skyLight.intensity=e.skylight.intensity,this.ambientLight.color.copy(e.ambientLight.color),this.ambientLight.intensity=e.ambientLight.intensity;const t=e.sunLights.length;for(let n=0;n<t;n++){this.sunLights[n]||(this.sunLights[n]=new jc);const i=e.sunLights[n].color,s=e.sunLights[n].position,o=e.sunLights[n].intensity;i&&this.sunLights[n].color.copy(i),s&&this.sunLights[n].position.copy(s),o&&(this.sunLights[n].intensity=o)}}adaptToContent(e){this._groundPlane.adaptToContent(e)}dispose(){this.sunLights.forEach(e=>e.dispose()),this.skyLight.dispose(),this.ambientLight.dispose(),this._groundPlane.dispose()}}class mS{constructor(e,t,n,i){$(this,"_renderer");$(this,"_camera");$(this,"_inputs");$(this,"_size",1);$(this,"_fov",50);$(this,"_color",new xe("blue"));$(this,"_opacity",.2);$(this,"_opacityAlways",.5);$(this,"_fadeDurationMs",200);$(this,"_showDurationMs",1e3);$(this,"_box");$(this,"_wireframe");$(this,"_material");$(this,"_materialAlways");$(this,"_gizmos");$(this,"_disconnectCamera");$(this,"_timeout");$(this,"_fadeEnd",0);$(this,"_active",!0);$(this,"_animation",0);this._renderer=e,this._camera=t,this._inputs=n,this.applySettings(i),this.connect()}connect(){const e=this._inputs.onPointerModeChanged.subscribe(()=>this.onUpdate()),t=this._camera.onMoved.subscribe(()=>this.onUpdate()),n=this._camera.onValueChanged.subscribe(()=>this.onUpdate());this._disconnectCamera=()=>{e(),t(),n()}}onUpdate(){this.updateScale(),this.setPosition(this._camera.target),this.show(!0)}dispose(){cancelAnimationFrame(this._animation),clearTimeout(this._timeout),this._box?.dispose(),this._wireframe?.dispose(),this._material?.dispose(),this._materialAlways?.dispose(),this._disconnectCamera?.(),this._box=void 0,this._wireframe=void 0,this._material=void 0,this._materialAlways=void 0,this._disconnectCamera=void 0,this._gizmos&&(this._renderer.remove(this._gizmos),this._gizmos=void 0)}get enabled(){return this._active}set enabled(e){this._active=e}show(e=!0){!this._active||(this._gizmos||this.createGizmo(),clearTimeout(this._timeout),this._gizmos.visible=e,e&&(this._timeout=setTimeout(()=>this.fadeOut(),this._showDurationMs)))}fadeOut(e){const t=new Date().getTime();if(e||(this._fadeEnd=t+this._fadeDurationMs),t>this._fadeEnd)this._gizmos.visible=!1,this._material.opacity=this._opacity,this._materialAlways.opacity=this._opacityAlways;else{this._animation=requestAnimationFrame(()=>this.fadeOut(!0));const n=Math.pow((this._fadeEnd-t)/this._fadeDurationMs,4);this._material.opacity=ka.lerp(0,this._opacity,n),this._materialAlways.opacity=ka.lerp(0,this._opacityAlways,n)}this._renderer.needsUpdate=!0}setPosition(e){this._gizmos?.position.copy(e),this.updateScale()}setSize(e){this._size=e}setOpacity(e,t){this._opacity=e,this._opacityAlways=t,this._gizmos&&(this._material.opacity=e,this._materialAlways.opacity=t)}setColor(e){this._color=e,this._gizmos&&(this._material.color=e,this._materialAlways.color=e)}applySettings(e){this._active=e.camera.gizmo.enable,this._fov=e.camera.fov,this.setColor(e.camera.gizmo.color),this.setSize(e.camera.gizmo.size),this.setOpacity(e.camera.gizmo.opacity,e.camera.gizmo.opacityAlways)}updateScale(){if(!this._gizmos)return;const e=this._camera.frustrumSizeAt(this._gizmos.position),n=Math.min(e.x,e.y)*this._size;this._gizmos.scale.set(n,n,n)}createGizmo(){this._box=new ms(1),this._wireframe=new eu(this._box),this._wireframe.addGroup(0,1/0,0),this._wireframe.addGroup(0,1/0,1),this._material=new qt({depthTest:!0,opacity:this._opacity,color:this._color,transparent:!0}),this._materialAlways=new qt({depthTest:!1,opacity:this._opacityAlways,color:this._color,transparent:!0}),this._gizmos=new In(this._wireframe,[this._material,this._materialAlways]),this._renderer.add(this._gizmos),this.updateScale()}}const Cs=new U,km=new We,Vm=new We,Hm=new U,Gm=new U;class gS{constructor(e={}){const t=this;let n,i,s,o;const a={objects:new WeakMap},c=e.element!==void 0?e.element:document.createElement("div");c.style.overflow="hidden",this.domElement=c,this.sortObjects=!0,this.getSize=function(){return{width:n,height:i}},this.render=function(g,_){g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),_.parent===null&&_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),km.copy(_.matrixWorldInverse),Vm.multiplyMatrices(_.projectionMatrix,km),h(g,g,_),this.sortObjects&&d(g)},this.setSize=function(g,_){n=g,i=_,s=n/2,o=i/2,c.style.width=g+"px",c.style.height=_+"px"};function l(g){g.isCSS2DObject&&(g.element.style.display="none");for(let _=0,m=g.children.length;_<m;_++)l(g.children[_])}function h(g,_,m){if(g.visible===!1){l(g);return}if(g.isCSS2DObject){Cs.setFromMatrixPosition(g.matrixWorld),Cs.applyMatrix4(Vm);const p=Cs.z>=-1&&Cs.z<=1&&g.layers.test(m.layers)===!0,v=g.element;v.style.display=p===!0?"":"none",p===!0&&(g.onBeforeRender(t,_,m),v.style.transform="translate("+-100*g.center.x+"%,"+-100*g.center.y+"%)translate("+(Cs.x*s+s)+"px,"+(-Cs.y*o+o)+"px)",v.parentNode!==c&&c.appendChild(v),g.onAfterRender(t,_,m));const y={distanceToCameraSquared:u(m,g)};a.objects.set(g,y)}for(let p=0,v=g.children.length;p<v;p++)h(g.children[p],_,m)}function u(g,_){return Hm.setFromMatrixPosition(g.matrixWorld),Gm.setFromMatrixPosition(_.matrixWorld),Hm.distanceToSquared(Gm)}function f(g){const _=[];return g.traverseVisible(function(m){m.isCSS2DObject&&_.push(m)}),_}function d(g){const _=f(g).sort(function(p,v){if(p.renderOrder!==v.renderOrder)return v.renderOrder-p.renderOrder;const y=a.objects.get(p).distanceToCameraSquared,x=a.objects.get(v).distanceToCameraSquared;return y-x}),m=_.length;for(let p=0,v=_.length;p<v;p++)_[p].element.style.zIndex=m-p}}}class ku{constructor(e){$(this,"canvas");$(this,"text");$(this,"_unregisterResize");$(this,"_ownedCanvas");$(this,"_onResize",new Ms.SignalDispatcher);const[t,n]=ku.getOrCreateCanvas(e.canvas.id);this.canvas=t,this._ownedCanvas=n,this.watchResize(e.canvas.resizeDelay)}get onResize(){return this._onResize.asEvent()}static getOrCreateCanvas(e){let t=e?document.getElementById(e):void 0;return t?[t,!1]:(t=document.createElement("canvas"),t.className="ara3d-canvas",t.tabIndex=0,t.style.backgroundColor="black",document.body.appendChild(t),[t,!0])}createTextRenderer(){if(console.log("Creating text renderer"),!this.canvas.parentElement)throw new Error("Cannot create text renderer without a canvas");const e=this.getParentSize(),t=new gS;return t.setSize(e.x,e.y),this.text=t.domElement,this.text.className="ara3d-text-renderer",this.text.style.position="absolute",this.text.style.top="0px",this.text.style.pointerEvents="none",this.canvas.parentElement.append(this.text),t}dispose(){this._unregisterResize?.(),this._unregisterResize=void 0,this._ownedCanvas&&this.canvas.remove()}getParentSize(){return new he(this.canvas.parentElement?.clientWidth??this.canvas.clientWidth,this.canvas.parentElement?.clientHeight??this.canvas.clientHeight)}getSize(){return new he(this.canvas.clientWidth,this.canvas.clientHeight)}getAspectRatio(){const e=this.getParentSize();return e.x/e.y}ResizeToParent(){this._onResize.dispatch()}watchResize(e){let t;const n=()=>{t!==void 0&&(clearTimeout(t),t=void 0),t=setTimeout(()=>{t=void 0,this._onResize.dispatch()},e)};window.addEventListener("resize",n),this._unregisterResize=()=>window.removeEventListener("resize",n)}}class _S{constructor(e,t,n,i){$(this,"renderer");$(this,"antialias",!0);$(this,"scene");$(this,"viewport");$(this,"camera");$(this,"needsUpdate");$(this,"_lastSize",new he);$(this,"fitViewport",()=>{const e=this.viewport.getParentSize();if(e.x===this._lastSize.x&&e.y===this._lastSize.y)return;this._lastSize.copy(e);const t=1.5;this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,t)),this.renderer.setSize(e.x,e.y),this.needsUpdate=!0});this.viewport=t,this.scene=e,this.camera=n,this.renderer=new Cm({canvas:t.canvas,antialias:!0,precision:"highp",alpha:!0,stencil:!1,powerPreference:"high-performance",logarithmicDepthBuffer:!0}),this.fitViewport(),this.viewport.onResize.subscribe(()=>this.fitViewport()),this.camera.onValueChanged.sub(()=>{this.needsUpdate=!0}),this.background=i.background.color,this.applyRenderingSettings(i)}applyRenderingSettings(e){this.renderer.toneMapping=e.rendering.toneMapping,this.renderer.toneMappingExposure=e.rendering.toneMappingExposure}dispose(){this.clear(),this.renderer.clear(),this.renderer.forceContextLoss(),this.renderer.dispose()}get background(){return this.scene.background}set background(e){this.scene.background=e,e===null?this.renderer.setClearColor(0,0):this.renderer.setClearColor(0,1),this.needsUpdate=!0}render(){!this.needsUpdate&&!this.camera.hasMoved||this.renderer.render(this.scene,this.camera.camPerspective.camera)}add(e){return this.scene.add(e),this.needsUpdate=!0,!0}remove(e){this.scene.remove(e),this.needsUpdate=!0}clear(){this.scene.clear(),this.needsUpdate=!0}}class vS{constructor(e){$(this,"settings");$(this,"renderer");$(this,"viewport");$(this,"inputs");$(this,"camera");$(this,"environment");$(this,"gizmoOrbit");$(this,"running",!1);$(this,"updateId",null);$(this,"clock",new el);$(this,"scene",new Ch);$(this,"animate",()=>{if(!this.running)return;this.updateId=requestAnimationFrame(this.animate);const e=this.clock.getDelta(),t=this.camera.update(e);this.renderer.needsUpdate=this.renderer.needsUpdate||t,this.renderer.render()});this.settings=Dm(e),this.viewport=new ku(this.settings),this.camera=new Jw(this.viewport,this.settings),this.renderer=new _S(this.scene,this.viewport,this.camera,this.settings),this.inputs=new fS(this),this.settings.camera.gizmo.enable&&(this.gizmoOrbit=new mS(this.renderer,this.camera,this.inputs,this.settings)),this.environment=new pS(this.settings),this.environment.getObjects().forEach(t=>this.renderer.add(t)),this.inputs.registerAll(),this.start()}start(){this.running||(this.running=!0,this.clock.start(),this.animate())}stop(){this.running=!1,this.updateId!==null&&(cancelAnimationFrame(this.updateId),this.updateId=null)}add(e,t=!0){if(console.log("Adding object"),this.renderer.needsUpdate=!0,!this.renderer.add(e))throw new Error("Could not load object")}clear(){this.renderer.clear()}dispose(){cancelAnimationFrame(this.updateId),this.environment.dispose(),this.gizmoOrbit.dispose(),this.viewport.dispose(),this.renderer.dispose(),this.inputs.unregisterAll()}}function Wm(r,e){if(e===Zf)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===Oa||e===eh){let t=r.getIndex();if(t===null){const o=[],a=r.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===Oa)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}class yS extends Jt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new SS(t)}),this.register(function(t){return new MS(t)}),this.register(function(t){return new NS(t)}),this.register(function(t){return new US(t)}),this.register(function(t){return new BS(t)}),this.register(function(t){return new TS(t)}),this.register(function(t){return new CS(t)}),this.register(function(t){return new IS(t)}),this.register(function(t){return new RS(t)}),this.register(function(t){return new wS(t)}),this.register(function(t){return new PS(t)}),this.register(function(t){return new ES(t)}),this.register(function(t){return new LS(t)}),this.register(function(t){return new DS(t)}),this.register(function(t){return new AS(t)}),this.register(function(t){return new OS(t)}),this.register(function(t){return new FS(t)})}load(e,t,n,i){const s=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=Li.extractUrlBase(e);o=Li.resolveURL(l,this.path)}else o=Li.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){i?i(l):console.error(l),s.manager.itemError(e),s.manager.itemEnd(e)},c=new An(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{s.parse(l,o,function(h){t(h),s.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const o={},a={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===qm){try{o[at.KHR_BINARY_GLTF]=new zS(e)}catch(u){i&&i(u);return}s=JSON.parse(o[at.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new JS(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const u=s.extensionsUsed[h],f=s.extensionsRequired||[];switch(u){case at.KHR_MATERIALS_UNLIT:o[u]=new bS;break;case at.KHR_DRACO_MESH_COMPRESSION:o[u]=new kS(s,this.dracoLoader);break;case at.KHR_TEXTURE_TRANSFORM:o[u]=new VS;break;case at.KHR_MESH_QUANTIZATION:o[u]=new HS;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function xS(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const at={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class AS{constructor(e){this.parser=e,this.name=at.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let l;const h=new xe(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],Xt);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new jc(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new pu(h),l.distance=u;break;case"spot":l=new du(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),ti(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),i=Promise.resolve(l),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}}class bS{constructor(){this.name=at.KHR_MATERIALS_UNLIT}getMaterialType(){return un}extendParams(e,t,n){const i=[];e.color=new xe(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],Xt),e.opacity=o[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,Tt))}return Promise.all(i)}}class wS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class SS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new he(a,a)}return Promise.all(s)}}class MS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class ES{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}}class TS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new xe(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],Xt)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,Tt)),o.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class CS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}}class IS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new xe().setRGB(a[0],a[1],a[2],Xt),Promise.all(s)}}class RS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class PS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new xe().setRGB(a[0],a[1],a[2],Xt),o.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,Tt)),Promise.all(s)}}class DS{constructor(e){this.parser=e,this.name=at.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}}class LS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}}class NS{constructor(e){this.parser=e,this.name=at.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class US{constructor(e){this.parser=e,this.name=at.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,o.source,c)}}class BS{constructor(e){this.parser=e,this.name=at.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,o.source,c)}}class OS{constructor(e){this.name=at.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const c=i.byteOffset||0,l=i.byteLength||0,h=i.count,u=i.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,i.mode,i.filter).then(function(d){return d.buffer}):o.ready.then(function(){const d=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,i.mode,i.filter),d})})}else return null}}class FS{constructor(e){this.name=at.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const l of i.primitives)if(l.mode!==Dn.TRIANGLES&&l.mode!==Dn.TRIANGLE_STRIP&&l.mode!==Dn.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],c={};for(const l in o)a.push(this.parser.getDependency("accessor",o[l]).then(h=>(c[l]=h,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,d=[];for(const g of u){const _=new We,m=new U,p=new wt,v=new U(1,1,1),y=new _c(g.geometry,g.material,f);for(let x=0;x<f;x++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,x),c.SCALE&&v.fromBufferAttribute(c.SCALE,x),y.setMatrixAt(x,_.compose(m,p,v));for(const x in c)if(x==="_COLOR_0"){const A=c[x];y.instanceColor=new Ji(A.array,A.itemSize,A.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&g.geometry.setAttribute(x,c[x]);ct.prototype.copy.call(y,g),this.parser.assignFinalMaterial(y),d.push(y)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}}const qm="glTF",Io=12,Xm={JSON:1313821514,BIN:5130562};class zS{constructor(e){this.name=at.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Io),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==qm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Io,s=new DataView(e,Io);let o=0;for(;o<i;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,c===Xm.JSON){const l=new Uint8Array(e,Io+o,a);this.content=n.decode(l)}else if(c===Xm.BIN){const l=Io+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class kS{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=at.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(const h in o){const u=Hu[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=Hu[h]||h.toLowerCase();if(o[h]!==void 0){const f=n.accessors[e.attributes[h]],d=Is[f.componentType];l[u]=d.name,c[u]=f.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(u,f){i.decodeDracoFile(h,function(d){for(const g in d.attributes){const _=d.attributes[g],m=c[g];m!==void 0&&(_.normalized=m)}u(d)},a,l,Xt,f)})})}}class VS{constructor(){this.name=at.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class HS{constructor(){this.name=at.KHR_MESH_QUANTIZATION}}class Zm extends _s{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[s+o];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=i-t,u=(n-t)/h,f=u*u,d=f*u,g=e*l,_=g-l,m=-2*d+3*f,p=d-f,v=1-m,y=p-f+u;for(let x=0;x!==a;x++){const A=o[_+x+a],E=o[_+x+c]*h,I=o[g+x+a],D=o[g+x]*h;s[x]=v*A+y*E+m*I+p*D}return s}}const GS=new wt;class WS extends Zm{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return GS.fromArray(s).normalize().toArray(s),s}}const Dn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Is={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ym={9728:Mt,9729:pt,9984:Ko,9985:Ur,9986:Hi,9987:Mn},Qm={33071:tn,33648:Nr,10497:yi},Vu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Hu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Bi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},qS={CUBICSPLINE:void 0,LINEAR:zr,STEP:Fr},Gu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function XS(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new gs({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Wn})),r.DefaultMaterial}function Sr(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ti(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ZS(r,e,t){let n=!1,i=!1,s=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(r);const o=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(n){const f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):r.attributes.position;o.push(f)}if(i){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;a.push(f)}if(s){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):r.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],f=l[2];return n&&(r.morphAttributes.position=h),i&&(r.morphAttributes.normal=u),s&&(r.morphAttributes.color=f),r.morphTargetsRelative=!0,r})}function YS(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function QS(r){let e;const t=r.extensions&&r.extensions[at.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Wu(t.attributes):e=r.indices+":"+Wu(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+Wu(r.targets[n]);return e}function Wu(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function qu(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function KS(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const jS=new We;class JS{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new xS,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,s=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);i=n&&c?parseInt(c[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&o<98?this.textureLoader=new lu(this.options.manager):this.textureLoader=new Up(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new An(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return Sr(s,a,i),ti(a,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const o=t[i].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(o,a)=>{const c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(const[l,h]of o.children.entries())s(h,a.children[l])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[at.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,o){n.load(Li.resolveURL(t.uri,i.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=Vu[i.type],a=Is[i.componentType],c=i.normalized===!0,l=new a(i.count*o);return Promise.resolve(new ot(l,o,c))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(o){const a=o[0],c=Vu[i.type],l=Is[i.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,f=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let _,m;if(d&&d!==u){const p=Math.floor(f/d),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let y=t.cache.get(v);y||(_=new l(a,p*d,i.count*d/h),y=new os(_,d/h),t.cache.add(v,y)),m=new fi(y,c,f%d/h,g)}else a===null?_=new l(i.count*c):_=new l(a,f,i.count*c),m=new ot(_,c,g);if(i.sparse!==void 0){const p=Vu.SCALAR,v=Is[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,A=new v(o[1],y,i.sparse.count*p),E=new l(o[2],x,i.sparse.count*c);a!==null&&(m=new ot(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let I=0,D=A.length;I<D;I++){const b=A[I];if(m.setX(b,E[I*c]),c>=2&&m.setY(b,E[I*c+1]),c>=3&&m.setZ(b,E[I*c+2]),c>=4&&m.setW(b,E[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(s.samplers||{})[o.sampler]||{};return h.magFilter=Ym[f.magFilter]||pt,h.minFilter=Ym[f.minFilter]||Mn,h.wrapS=Qm[f.wrapS]||yi,h.wrapT=Qm[f.wrapT]||yi,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Mt&&h.minFilter!==pt,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(u){l=!0;const f=new Blob([u],{type:o.mimeType});return c=a.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(f,d){let g=f;t.isImageBitmapLoader===!0&&(g=function(_){const m=new xt(_);m.needsUpdate=!0,f(m)}),t.load(Li.resolveURL(u,s.path),g,void 0,d)})}).then(function(u){return l===!0&&a.revokeObjectURL(c),ti(u,o),u.userData.mimeType=o.mimeType||KS(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[at.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[at.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=s.associations.get(o);o=s.extensions[at.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,c)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new Ec,zt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new qt,zt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),s&&(c.vertexColors=!0),o&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return gs}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},c=s.extensions||{},l=[];if(c[at.KHR_MATERIALS_UNLIT]){const u=i[at.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),l.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new xe(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],Xt),a.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,Tt)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Sn);const h=s.alphaMode||Gu.OPAQUE;if(h===Gu.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Gu.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==un&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new he(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&o!==un&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==un){const u=s.emissiveFactor;a.emissive=new xe().setRGB(u[0],u[1],u[2],Xt)}return s.emissiveTexture!==void 0&&o!==un&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Tt)),Promise.all(l).then(function(){const u=new o(a);return s.name&&(u.name=s.name),ti(u,s),t.associations.set(u,{materials:e}),s.extensions&&Sr(i,u,s),u})}createUniqueName(e){const t=lt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[at.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Km(c,a,t)})}const o=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],h=QS(l),u=i[h];if(u)o.push(u.promise);else{let f;l.extensions&&l.extensions[at.KHR_DRACO_MESH_COMPRESSION]?f=s(l):f=Km(new Ke,l,t),i[h]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let c=0,l=o.length;c<l;c++){const h=o[c].material===void 0?XS(this.cache):this.getDependency("material",o[c].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let d=0,g=h.length;d<g;d++){const _=h[d],m=o[d];let p;const v=l[d];if(m.mode===Dn.TRIANGLES||m.mode===Dn.TRIANGLE_STRIP||m.mode===Dn.TRIANGLE_FAN||m.mode===void 0)p=s.isSkinnedMesh===!0?new Lh(_,v):new St(_,v),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),m.mode===Dn.TRIANGLE_STRIP?p.geometry=Wm(p.geometry,eh):m.mode===Dn.TRIANGLE_FAN&&(p.geometry=Wm(p.geometry,Oa));else if(m.mode===Dn.LINES)p=new In(_,v);else if(m.mode===Dn.LINE_STRIP)p=new di(_,v);else if(m.mode===Dn.LINE_LOOP)p=new Fh(_,v);else if(m.mode===Dn.POINTS)p=new kh(_,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&YS(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),ti(p,s),m.extensions&&Sr(i,p,m),t.assignFinalMaterial(p),u.push(p)}for(let d=0,g=u.length;d<g;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return s.extensions&&Sr(i,u[0],s),u[0];const f=new Kn;s.extensions&&Sr(i,f,s),t.associations.set(f,{meshes:e});for(let d=0,g=u.length;d<g;d++)f.add(u[d]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new kt(ka.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new ur(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ti(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),o=i,a=[],c=[];for(let l=0,h=o.length;l<h;l++){const u=o[l];if(u){a.push(u);const f=new We;s!==null&&f.fromArray(s.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new no(a,c)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,o=[],a=[],c=[],l=[],h=[];for(let u=0,f=i.channels.length;u<f;u++){const d=i.channels[u],g=i.samplers[d.sampler],_=d.target,m=_.node,p=i.parameters!==void 0?i.parameters[g.input]:g.input,v=i.parameters!==void 0?i.parameters[g.output]:g.output;_.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",v)),l.push(g),h.push(_))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const f=u[0],d=u[1],g=u[2],_=u[3],m=u[4],p=[];for(let y=0,x=f.length;y<x;y++){const A=f[y],E=d[y],I=g[y],D=_[y],b=m[y];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();const C=n._createAnimationTracks(A,E,I,D,b);if(C)for(let B=0;B<C.length;B++)p.push(C[B])}const v=new vs(s,void 0,p);return ti(v,i),v})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const o=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&o.traverse(function(a){if(!!a.isMesh)for(let c=0,l=i.weights.length;c<l;c++)a.morphTargetInfluences[c]=i.weights[c]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),o=[],a=i.children||[];for(let l=0,h=a.length;l<h;l++)o.push(n.getDependency("node",a[l]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(o),c]).then(function(l){const h=l[0],u=l[1],f=l[2];f!==null&&h.traverse(function(d){!d.isSkinnedMesh||d.bind(f,jS)});for(let d=0,g=u.length;d<g;d++)h.add(u[d]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],o=s.name?i.createUniqueName(s.name):"",a=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(l){return i._getNodeRef(i.cameraCache,s.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(s.isBone===!0?h=new mc:l.length>1?h=new Kn:l.length===1?h=l[0]:h=new ct,h!==l[0])for(let u=0,f=l.length;u<f;u++)h.add(l[u]);if(s.name&&(h.userData.name=s.name,h.name=o),ti(h,s),s.extensions&&Sr(n,h,s),s.matrix!==void 0){const u=new We;u.fromArray(s.matrix),h.applyMatrix4(u)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const u=i.associations.get(h);i.associations.set(h,{...u})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new Kn;n.name&&(s.name=i.createUniqueName(n.name)),ti(s,n),n.extensions&&Sr(t,s,n);const o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(i.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let h=0,u=c.length;h<u;h++)s.add(c[h]);const l=h=>{const u=new Map;for(const[f,d]of i.associations)(f instanceof zt||f instanceof xt)&&u.set(f,d);return h.traverse(f=>{const d=i.associations.get(f);d!=null&&u.set(f,d)}),u};return i.associations=l(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,c=[];Bi[s.path]===Bi.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(Bi[s.path]){case Bi.weights:l=ar;break;case Bi.rotation:l=cr;break;case Bi.translation:case Bi.scale:l=hr;break;default:switch(n.itemSize){case 1:l=ar;break;case 2:case 3:default:l=hr;break}break}const h=i.interpolation!==void 0?qS[i.interpolation]:zr,u=this._getArrayFromAccessor(n);for(let f=0,d=c.length;f<d;f++){const g=new l(c[f]+"."+Bi[s.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=qu(t.constructor),i=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof cr?WS:Zm;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function $S(r,e,t){const n=e.attributes,i=new Gt;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(i.set(new U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){const h=qu(Is[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new U,c=new U;for(let l=0,h=s.length;l<h;l++){const u=s[l];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],d=f.min,g=f.max;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),f.normalized){const _=qu(Is[f.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}r.boundingBox=i;const o=new Pt;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=o}function Km(r,e,t){const n=e.attributes,i=[];function s(o,a){return t.getDependency("accessor",o).then(function(c){r.setAttribute(a,c)})}for(const o in n){const a=Hu[o]||o.toLowerCase();a in r.attributes||i.push(s(n[o],a))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(a){r.setIndex(a)});i.push(o)}return rt.workingColorSpace!==Xt&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${rt.workingColorSpace}" not supported.`),ti(r,e),$S(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?ZS(r,e.targets,t):r})}const Xu=new WeakMap;class eM extends Jt{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new An(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Tt,n).catch(n)}decodeDracoFile(e,t,n,i,s=Xt,o=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Xu.has(e)){const c=Xu.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(c=>(i=c,new Promise((l,h)=>{i._callbacks[s]={resolve:l,reject:h},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Xu.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new Ke;e.index&&t.setIndex(new ot(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:o,stride:a,vertexColorSpace:c}=e.attributes[n];let l;if(o===a)l=new ot(s,o);else{const h=new os(s,a);l=new fi(h,o,0)}i==="color"&&(this._assignVertexColorSpace(l,c),l.normalized=!(s instanceof Float32Array)),t.setAttribute(i,l)}return t}_assignVertexColorSpace(e,t){if(t!==Tt)return;const n=new xe;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),rt.colorSpaceToWorking(n,Tt),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new An(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=tM.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
4035
+ */Object.defineProperty(r,"__esModule",{value:!0}),r.SignalList=r.SignalHandlingBase=r.SignalDispatcher=void 0;const e=bo;Object.defineProperty(r,"SignalDispatcher",{enumerable:!0,get:function(){return e.SignalDispatcher}});const t=gl;Object.defineProperty(r,"SignalHandlingBase",{enumerable:!0,get:function(){return t.SignalHandlingBase}});const n=To;Object.defineProperty(r,"SignalList",{enumerable:!0,get:function(){return n.SignalList}})}(Ms);class Yw{constructor(e){$(this,"camera");this.camera=e}applySettings(e){this.camera.fov=e.camera.fov,this.camera.zoom=e.camera.zoom,this.camera.near=e.camera.near,this.camera.far=e.camera.far,this.camera.updateProjectionMatrix()}updateProjection(e){this.camera.aspect=e,this.camera.updateProjectionMatrix()}frustrumSizeAt(e){const n=this.camera.position.distanceTo(e)*Math.tan(this.camera.fov/2*(Math.PI/180));return new he(n,n)}}class Qw{constructor(e){$(this,"camera");this.camera=e}applySettings(e){this.camera.zoom=e.camera.zoom,this.camera.near=-e.camera.far,this.camera.far=e.camera.far,this.camera.updateProjectionMatrix()}updateProjection(e,t){const n=Math.max(e.x,e.y);this.camera.left=-n*t,this.camera.right=n*t,this.camera.top=n,this.camera.bottom=-n,this.camera.updateProjectionMatrix()}}class Bm{constructor(e){$(this,"_camera");this._camera=e}move2(e,t){const n=t==="XY"?new U(-e.x,e.y,0):t==="XZ"?new U(-e.x,0,e.y):void 0;n&&this.move3(n)}move1(e,t){const n=new U(t==="X"?-e:0,t==="Y"?e:0,t==="Z"?e:0);this.move3(n)}orbitTowards(e){const t=this._camera.forward,n=t.clone().setY(0),i=e.clone().setY(0),s=n.angleTo(i)*Math.sign(n.cross(i).y),o=Math.asin(e.y)-Math.asin(t.y),a=new he(o,s);a.multiplyScalar(180/Math.PI),this.orbit(a)}frame(e,t){e instanceof Gt&&(e=e.getBoundingSphere(new Pt)),e instanceof Pt&&this.frameSphere(e,t??this._camera.forward)}frameSphere(e,t){const n=this._camera.camPerspective.camera.fov*Math.PI/180,i=e.radius*1.2/Math.tan(n/2),s=t.clone().multiplyScalar(-i).add(e.center);this.set(s,e.center)}}class Kw extends Bm{constructor(t,n){super(t);$(this,"_movement");$(this,"_clock",new el);$(this,"onProgress");$(this,"_duration",1);this._movement=n}init(t){this.cancel(),this._duration=t,this._clock.start(),this.animate()}cancel(){this._clock.stop(),this.onProgress=void 0}animate(){this._clock.running&&(this.update(),requestAnimationFrame(()=>this.animate()))}easeOutCubic(t){return 1-Math.pow(1-t,3)}update(){let t=this._clock.getElapsedTime()/this._duration;t=this.easeOutCubic(t),t>=1&&(t=1,this._clock.stop(),this.onProgress=void 0),this.onProgress?.(t)}move3(t){const n=t.clone();n.applyQuaternion(this._camera.quaternion);const i=this._camera.position.clone(),s=this._camera.position.clone().add(n),o=new U;this.onProgress=a=>{o.copy(i),o.lerp(s,a),this._movement.move3(o)}}rotate(t){const n=new Zt(0,0,0,"YXZ");n.setFromQuaternion(this._camera.quaternion),n.x+=t.x,n.y+=t.y,n.z=0;const i=Math.PI*.48;n.x=Math.max(-i,Math.min(i,n.x));const s=this._camera.quaternion.clone(),o=new wt().setFromEuler(n),a=new wt;this.onProgress=c=>{a.copy(s),a.slerp(o,c),this._movement.applyRotation(a)}}zoom(t){const n=this._camera.orbitDistance*t;this.setDistance(n)}setDistance(t){const n=this._camera.position.clone(),i=this._camera.target.clone().lerp(n,t/this._camera.orbitDistance);this.onProgress=s=>{this._camera.position.copy(n),this._camera.position.lerp(i,s)}}orbit(t){const n=this._camera.position.clone(),i=this._camera.target.clone(),s=new he;this.onProgress=o=>{s.set(0,0),s.lerp(t,o),this._movement.set(n,i),this._movement.orbit(s)}}target(t){const i=t.clone().sub(this._camera.position),s=this._camera.quaternion.clone(),o=new wt().setFromUnitVectors(new U(0,0,-1),i.normalize());this.onProgress=a=>{const c=s.clone().slerp(o,a);this._movement.applyRotation(c)}}reset(){this.set(this._camera._savedPosition,this._camera._savedTarget)}set(t,n){const i=n??this._camera.target,s=this._camera.position.clone(),o=this._camera.target.clone();this.onProgress=a=>{this._movement.set(s.clone().lerp(t,a),o.clone().lerp(i,a))}}}class jw extends Bm{zoom(e){const t=this._camera.orbitDistance*e;this.setDistance(t)}reset(){this.set(this._camera._savedPosition,this._camera._savedTarget)}setDistance(e){const t=this._camera.target.clone().sub(this._camera.forward.multiplyScalar(e));this.set(t,this._camera.target)}rotate(e){const t=e.clone().multiply(this._camera.allowedRotation),n=this.predictRotate(t);this.applyRotation(n)}applyRotation(e){this._camera.quaternion.copy(e);const t=this._camera.forward.multiplyScalar(this._camera.orbitDistance).add(this._camera.position);this.set(this._camera.position,t)}target(e){this.set(this._camera.position,e)}orbit(e){const t=e.clone().multiply(this._camera.allowedRotation),n=this.predictOrbit(t);this.set(n)}move3(e){const t=e.clone();t.applyQuaternion(this._camera.quaternion);const n=this.lockVector(t,new U),i=this._camera.position.clone().add(n),s=this._camera.target.clone().add(n);this.set(i,s)}set(e,t){const n=this.lockVector(e,this._camera.position);this._camera.position.copy(n),t=t??this._camera.target,this._camera.target.copy(t),this._camera.camPerspective.camera.lookAt(t),this._camera.camPerspective.camera.up.set(0,1,0)}lockVector(e,t){const n=this._camera.allowedMovement.x===0?t.x:e.x,i=this._camera.allowedMovement.y===0?t.y:e.y,s=this._camera.allowedMovement.z===0?t.z:e.z;return new U(n,i,s)}predictOrbit(e){const t=this.predictRotate(e),n=new U(0,0,1).applyQuaternion(t).multiplyScalar(this._camera.orbitDistance);return this._camera.target.clone().add(n)}predictRotate(e){const t=new Zt(0,0,0,"YXZ");t.setFromQuaternion(this._camera.quaternion),t.x+=e.x*Math.PI/180,t.y+=e.y*Math.PI/180,t.z=0;const n=Math.PI*.4999;return t.x=Math.max(-n,Math.min(n,t.x)),new wt().setFromEuler(t)}}class Jw{constructor(e,t){$(this,"camPerspective");$(this,"camOrthographic");$(this,"_viewport");$(this,"_lerp");$(this,"_movement");$(this,"_inputVelocity",new U);$(this,"_velocity",new U);$(this,"_speed",0);$(this,"_orthographic",!1);$(this,"_target",new U);$(this,"_lastPosition",new U);$(this,"_lastQuaternion",new wt);$(this,"_lastTarget",new U);$(this,"_savedPosition",new U(0,0,-5));$(this,"_savedTarget",new U(0,0,0));$(this,"_onValueChanged",new Ms.SignalDispatcher);$(this,"_hasMoved");$(this,"_onMoved",new Ms.SignalDispatcher);$(this,"_force",!1);$(this,"_allowedMovement",new U(1,1,1));$(this,"_allowedRotation",new he(1,1));$(this,"_defaultForward",new U(0,0,1));$(this,"_velocityBlendFactor",1e-4);$(this,"_moveSpeed",1);this.camPerspective=new Yw(new kt),this.camOrthographic=new Qw(new ur),this._movement=new jw(this),this._lerp=new Kw(this,this._movement),this._viewport=e,this.applySettings(t),this.do().orbitTowards(this._defaultForward),this.do().setDistance(-1e3)}get onValueChanged(){return this._onValueChanged.asEvent()}get hasMoved(){return this._hasMoved}get onMoved(){return this._onMoved.asEvent()}get allowedMovement(){return this._force?new U(1,1,1):this._allowedMovement}set allowedMovement(e){this._allowedMovement.copy(e),this._allowedMovement.x=this._allowedMovement.x===0?0:1,this._allowedMovement.y=this._allowedMovement.y===0?0:1,this._allowedMovement.z=this._allowedMovement.z===0?0:1}get allowedRotation(){return this._force?new he(1,1):this._allowedRotation}set allowedRotation(e){this._allowedRotation.copy(e),this._allowedRotation.x=this._allowedRotation.x===0?0:1,this._allowedRotation.y=this._allowedRotation.y===0?0:1}get defaultForward(){return this._defaultForward}set defaultForward(e){e.x===0&&e.y===0&&e.z===0?this._defaultForward.set(0,0,1):this._defaultForward.copy(e)}do(e=!1){return this._force=e,this._lerp.cancel(),this._movement}lerp(e=1,t=!1){return this.stop(),this._force=t,this._lerp.init(e),this._lerp}frustrumSizeAt(e){return this.camPerspective.frustrumSizeAt(e)}notifyMovement(){this._hasMoved=!0,this._onMoved.dispatch()}get three(){return this._orthographic?this.camOrthographic.camera:this.camPerspective.camera}get quaternion(){return this.camPerspective.camera.quaternion}get position(){return this.camPerspective.camera.position}get matrix(){return this.camPerspective.camera.updateMatrix(),this.camPerspective.camera.matrix}get forward(){return this.camPerspective.camera.getWorldDirection(new U)}get speed(){return this._speed}set speed(e){this._speed=Mw(e,-25,25),this._onValueChanged.dispatch()}get localVelocity(){const e=this._velocity.clone();return e.applyQuaternion(this.quaternion.clone().invert()),e.setZ(-e.z),e}set localVelocity(e){this._lerp.cancel(),this._inputVelocity.copy(e),this._inputVelocity.setZ(-this._inputVelocity.z)}stop(){this._inputVelocity.set(0,0,0),this._velocity.set(0,0,0)}get target(){return this._target}applySettings(e){this._defaultForward=new U().copy(e.camera.forward),this._orthographic=e.camera.orthographic,this.allowedMovement=e.camera.allowedMovement,this.allowedRotation=e.camera.allowedRotation,this.camPerspective.applySettings(e),this.camOrthographic.applySettings(e),this._moveSpeed=e.camera.controls.moveSpeed,this._onValueChanged.dispatch()}get orbitDistance(){return this.position.distanceTo(this._target)}save(){this._lerp.cancel(),this._savedPosition.copy(this.position),this._savedTarget.copy(this._target)}updateProjection(){const e=this._viewport.getAspectRatio();this.camPerspective.updateProjection(e);const t=this.camPerspective.frustrumSizeAt(this.target);this.camOrthographic.updateProjection(t,e)}get orthographic(){return this._orthographic}set orthographic(e){e!==this._orthographic&&(this._orthographic=e,this._onValueChanged.dispatch())}update(e){this.applyVelocity(e)&&this.updateOrthographic();const t=this.checkForMovement();return t&&(this.camOrthographic.camera.position.copy(this.position),this.camOrthographic.camera.quaternion.copy(this.quaternion)),this.updateProjection(),t}applyVelocity(e){if(this._inputVelocity.x===0&&this._inputVelocity.y===0&&this._inputVelocity.z===0&&this._velocity.x===0&&this._velocity.y===0&&this._velocity.z===0)return!1;const t=Math.pow(this._velocityBlendFactor,e),n=1-t;this._velocity.multiplyScalar(t);const i=this._inputVelocity.clone().multiplyScalar(n);if(this._velocity.add(i),this._velocity.lengthSq()<e/10)return this._velocity.set(0,0,0),!1;const s=this._velocity.clone().multiplyScalar(e*this.getVelocityMultiplier());return this.do().move3(s),!0}updateOrthographic(){if(this.orthographic){const t=this._lastTarget.clone().sub(this.position).dot(this.forward);this.target.copy(this.forward).multiplyScalar(t).add(this.position);const n=this._lastPosition.clone().sub(this._target),i=this.position.clone().sub(this._target);(n.dot(i)<0||i.lengthSq()<1)&&this.position.copy(this._target).add(this.forward.multiplyScalar(-1))}}getVelocityMultiplier(){const t=!this._lastQuaternion.equals(this.quaternion)?1:1.66;return Math.pow(1.25,this.speed)*this._moveSpeed*t*100}checkForMovement(){return this._hasMoved=!1,(!this._lastPosition.equals(this.position)||!this._lastQuaternion.equals(this.quaternion)||!this._lastTarget.equals(this._target))&&(this._hasMoved=!0,this._onMoved.dispatch()),this._lastPosition.copy(this.position),this._lastQuaternion.copy(this.quaternion),this._lastTarget.copy(this._target),this._hasMoved}}class zu{constructor(e){$(this,"_viewer");$(this,"_unregisters",[]);$(this,"reg",(e,t,n)=>{e.addEventListener(t,n),this._unregisters.push(()=>e.removeEventListener(t,n))});this._viewer=e}register(){this._unregisters.length>0||this.addListeners()}addListeners(){}unregister(){this._unregisters.forEach(e=>e()),this._unregisters.length=0,this.reset()}reset(){}}const At={KEY_0:48,KEY_1:49,KEY_2:50,KEY_3:51,KEY_4:52,KEY_5:53,KEY_6:54,KEY_7:55,KEY_8:56,KEY_9:57,KEY_LEFT:37,KEY_RIGHT:39,KEY_UP:38,KEY_DOWN:40,KEY_CTRL:17,KEY_SHIFT:16,KEY_ENTER:13,KEY_SPACE:32,KEY_TAB:9,KEY_ESCAPE:27,KEY_BACKSPACE:8,KEY_HOME:36,KEY_END:35,KEY_INSERT:45,KEY_DELETE:46,KEY_ALT:18,KEY_F1:112,KEY_F2:113,KEY_F3:114,KEY_F4:115,KEY_F5:116,KEY_F6:117,KEY_F7:118,KEY_F8:119,KEY_F9:120,KEY_F10:121,KEY_F11:122,KEY_F12:123,KEY_NUMPAD0:96,KEY_NUMPAD1:97,KEY_NUMPAD2:98,KEY_NUMPAD3:99,KEY_NUMPAD4:100,KEY_NUMPAD5:101,KEY_NUMPAD6:102,KEY_NUMPAD7:103,KEY_NUMPAD8:104,KEY_NUMPAD9:105,KEY_ADD:107,KEY_SUBTRACT:109,KEY_MULTIPLY:106,KEY_DIVIDE:111,KEY_SEPARATOR:108,KEY_DECIMAL:110,KEY_OEM_PLUS:187,KEY_OEM_MINUS:189,KEY_A:65,KEY_B:66,KEY_C:67,KEY_D:68,KEY_E:69,KEY_F:70,KEY_G:71,KEY_H:72,KEY_I:73,KEY_J:74,KEY_K:75,KEY_L:76,KEY_M:77,KEY_N:78,KEY_O:79,KEY_P:80,KEY_Q:81,KEY_R:82,KEY_S:83,KEY_T:84,KEY_U:85,KEY_V:86,KEY_W:87,KEY_X:88,KEY_Y:89,KEY_Z:90},$w=new Set(Object.values(At));class eS extends zu{constructor(){super(...arguments);$(this,"SHIFT_MULTIPLIER",3);$(this,"isUpPressed",!1);$(this,"isDownPressed",!1);$(this,"isLeftPressed",!1);$(this,"isRightPressed",!1);$(this,"isEPressed",!1);$(this,"isQPressed",!1);$(this,"isShiftPressed",!1);$(this,"isCtrlPressed",!1);$(this,"arrowsEnabled",!0)}addListeners(){this.reg(document,"keydown",t=>this.onKeyDown(t)),this.reg(document,"keyup",t=>this.onKeyUp(t)),this.reg(this._viewer.viewport.canvas,"focusout",()=>this.reset()),this.reg(window,"resize",()=>this.reset())}reset(){this.isUpPressed=!1,this.isDownPressed=!1,this.isLeftPressed=!1,this.isRightPressed=!1,this.isEPressed=!1,this.isQPressed=!1,this.isShiftPressed=!1,this.isCtrlPressed=!1,this.applyMove()}get camera(){return this._viewer.camera}onKeyUp(t){this.onKey(t,!1)}onKeyDown(t){this.onKey(t,!0)}onKey(t,n){switch(!n&&$w.has(t.keyCode)&&this._viewer.inputs.KeyAction(t.keyCode)&&t.preventDefault(),t.keyCode){case At.KEY_W:case At.KEY_UP:this.isUpPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_S:case At.KEY_DOWN:this.isDownPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_D:case At.KEY_RIGHT:this.isRightPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_A:case At.KEY_LEFT:this.isLeftPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_E:this.isEPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_Q:this.isQPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_SHIFT:this.isShiftPressed=n,this.applyMove(),t.preventDefault();break;case At.KEY_CTRL:this.isCtrlPressed=n,t.preventDefault();break}}applyMove(){const t=new U((this.isRightPressed?1:0)-(this.isLeftPressed?1:0),(this.isEPressed?1:0)-(this.isQPressed?1:0),(this.isUpPressed?1:0)-(this.isDownPressed?1:0)),n=this.isShiftPressed?this.SHIFT_MULTIPLIER:1;t.multiplyScalar(n),this.arrowsEnabled&&(this.camera.localVelocity=t)}}class tS extends zu{constructor(t){super(t);$(this,"TAP_DURATION_MS",500);$(this,"DOUBLE_TAP_DELAY_MS",500);$(this,"TAP_MAX_MOVE_PIXEL",5);$(this,"ZOOM_SPEED",1);$(this,"MOVE_SPEED",100);$(this,"rotateSpeed",1);$(this,"orbitSpeed",1);$(this,"_touch");$(this,"_touch1");$(this,"_touch2");$(this,"_touchStartTime");$(this,"_lastTapMs");$(this,"_touchStart");$(this,"reset",()=>{this._touch=this._touch1=this._touch2=this._touchStartTime=void 0});$(this,"onTap",t=>{const n=new Date().getTime();this._lastTapMs&&n-this._lastTapMs<this.DOUBLE_TAP_DELAY_MS,this._lastTapMs=new Date().getTime()});$(this,"onTouchStart",t=>{t.preventDefault(),!(!t||!t.touches||!t.touches.length)&&(this._touchStartTime=new Date().getTime(),t.touches.length===1?(this._touch=this.touchToVector(t.touches[0]),this._touch1=this._touch2=void 0):t.touches.length===2&&(this._touch1=this.touchToVector(t.touches[0]),this._touch2=this.touchToVector(t.touches[1]),this._touch=this.average(this._touch1,this._touch2)),this._touchStart=this._touch)});$(this,"onDrag",t=>{this._viewer.inputs.pointerActive==="orbit"?this.camera.do().orbit(this.toRotation(t,this.orbitSpeed)):this.camera.do().rotate(this.toRotation(t,this.rotateSpeed))});$(this,"onDoubleDrag",t=>{const n=t.clone().multiplyScalar(this.MOVE_SPEED);this.camera.do().move2(n,"XY")});$(this,"onPinchOrSpread",t=>{this._viewer.inputs.pointerActive==="orbit"?this.camera.do().zoom(1+t*this.ZOOM_SPEED):this.camera.do().move1(t*this.ZOOM_SPEED,"Z")});$(this,"onTouchMove",t=>{if(t.preventDefault(),!(!t||!t.touches||!t.touches.length)&&!!this._touch){if(t.touches.length===1){const n=this.touchToVector(t.touches[0]),i=this.viewport.getSize(),s=n.clone().sub(this._touch).multiply(new he(1/i.x,1/i.y));this._touch=n,this.onDrag(s);return}if(!(!this._touch1||!this._touch2)&&t.touches.length>=2){const n=this.touchToVector(t.touches[0]),i=this.touchToVector(t.touches[1]),s=this.average(n,i),o=this.viewport.getSize(),a=this._touch.clone().sub(s).multiply(new he(-1/o.x,-1/o.y)),c=n.distanceTo(i),l=this._touch1.distanceTo(this._touch2),h=Math.min(o.x,o.y),u=(c-l)/-h;this._touch=s,this._touch1=n,this._touch2=i,a.length()>Math.abs(u)?this.onDoubleDrag(a):this.onPinchOrSpread(u)}}});$(this,"onTouchEnd",t=>{if(this.isSingleTouch()&&this._touchStart&&this._touch){const n=new Date().getTime()-this._touchStartTime,i=this._touch.distanceTo(this._touchStart);n<this.TAP_DURATION_MS&&i<this.TAP_MAX_MOVE_PIXEL&&this.onTap(this._touch)}this.reset()});this.rotateSpeed=t.settings.camera.controls.rotateSpeed,this.orbitSpeed=t.settings.camera.controls.orbitSpeed}get camera(){return this._viewer.camera}get viewport(){return this._viewer.viewport}addListeners(){const t=this.viewport.canvas;this.reg(t,"touchstart",this.onTouchStart),this.reg(t,"touchend",this.onTouchEnd),this.reg(t,"touchmove",this.onTouchMove)}toRotation(t,n){const i=new he;return i.x=t.y,i.y=t.x,i.multiplyScalar(-180*n),i}isSingleTouch(){return this._touch!==void 0&&this._touchStartTime!==void 0&&this._touch1===void 0&&this._touch2===void 0}touchToVector(t){return new he(t.pageX,t.pageY)}average(t,n){return t.clone().lerp(n,.5)}}class nS extends zu{constructor(t){super(t);$(this,"_idleDelayMs",150);$(this,"zoomSpeed",1);$(this,"panSpeed",100);$(this,"rotateSpeed",1);$(this,"orbitSpeed",1);$(this,"_buttonDown");$(this,"_hasMouseMoved",!1);$(this,"_hasCameraMoved",!1);$(this,"_idleTimeout");$(this,"_idlePosition");$(this,"_lastPosition");$(this,"_downPosition");$(this,"reset",()=>{this._buttonDown=void 0,this._hasMouseMoved=!1,this._lastPosition=this._downPosition=void 0,clearTimeout(this._idleTimeout)});$(this,"onMouseOut",t=>{t.stopImmediatePropagation(),this._buttonDown=void 0,this._hasMouseMoved=!1,this._lastPosition=void 0,this.resetIdle()});$(this,"onCameraMoved",()=>{this.resetIdle(),this._hasCameraMoved=!0});$(this,"onMouseMove",t=>{t.stopImmediatePropagation(),this._lastPosition=new he(t.offsetX,t.offsetY),(!this._idlePosition||this._lastPosition.distanceTo(this._idlePosition)>5)&&this.resetIdle(),this._buttonDown&&this.onMouseDrag(t)});$(this,"onMouseDown",t=>{if(t.stopImmediatePropagation(),t.preventDefault(),this._buttonDown)return;this.inputs.ContextMenu(void 0),this._hasCameraMoved=!1,this._downPosition=new he(t.offsetX,t.offsetY),this._hasMouseMoved=!1,this.viewport.canvas.focus(),this._buttonDown=this.getButton(t);const n=this._buttonDown==="middle"?"pan":this._buttonDown==="right"?"look":void 0;this.inputs.pointerOverride=n});$(this,"onMouseWheel",t=>{t.preventDefault(),t.stopImmediatePropagation();const n=Math.sign(t.deltaY);if(t.ctrlKey)this.camera.speed-=n;else{const i=Math.pow(1.3,n);this.camera.lerp(.15).zoom(i)}});$(this,"onMouseUp",t=>{t.stopImmediatePropagation(),this.resetIdle(),this.getButton(t)!==this._buttonDown&&(t.preventDefault(),this._buttonDown&&(t.button===2&&!this._hasMouseMoved&&this.inputs.ContextMenu(new he(t.clientX,t.clientY)),this._buttonDown=void 0,this.inputs.pointerOverride=void 0))});this.rotateSpeed=t.settings.camera.controls.rotateSpeed,this.orbitSpeed=t.settings.camera.controls.orbitSpeed}get camera(){return this._viewer.camera}get viewport(){return this._viewer.viewport}get canvas(){return this.viewport.canvas}get inputs(){return this._viewer.inputs}addListeners(){this.reg(this.canvas,"mousedown",this.onMouseDown),this.reg(this.canvas,"wheel",this.onMouseWheel),this.reg(this.canvas,"mousemove",this.onMouseMove),this.reg(this.canvas,"mouseup",this.onMouseUp),this.reg(this.canvas,"mouseout",this.onMouseOut),this.reg(this.canvas,"contextmenu",t=>t.preventDefault()),this._unregisters.push(this.camera.onMoved.subscribe(()=>this.onCameraMoved()))}resetIdle(){this._idlePosition&&(this._idlePosition=void 0),clearTimeout(this._idleTimeout)}onMouseDrag(t){t.stopImmediatePropagation(),t.preventDefault();const n=t.movementX||t.mozMovementX||t.webkitMovementX||0,i=t.movementY||t.mozMovementY||t.webkitMovementY||0,s=this.viewport.getSize(),o=new he(n/s.x,i/s.y),a=new he(t.offsetX,t.offsetY);switch(this._hasMouseMoved=this._hasMouseMoved||this._downPosition&&this._downPosition?.distanceTo(a)>4,this._buttonDown){case"main":this.onMouseMainDrag(o);break;case"middle":this.onMouseMiddleDrag(o);break;case"right":this.onMouseRightDrag(o);break}}toRotation(t,n){const i=t.clone();return i.x=-t.y,i.y=-t.x,i.multiplyScalar(180*n),i}onMouseMainDrag(t){switch(this.inputs.pointerActive){case"orbit":this.camera.do().orbit(this.toRotation(t,this.orbitSpeed));break;case"look":this.camera.do().rotate(this.toRotation(t,this.rotateSpeed));break;case"pan":this.camera.do().move2(t.multiplyScalar(this.panSpeed),"XY");break;case"zoom":this.camera.do().zoom(1+t.y*this.zoomSpeed);break}}onMouseMiddleDrag(t){this.camera.do().move2(t.multiplyScalar(100),"XY")}onMouseRightDrag(t){this.camera.do().rotate(this.toRotation(t,this.rotateSpeed))}getButton(t){return t.buttons&1?"main":t.buttons&2?"right":t.buttons&4?"middle":void 0}getModifier(t){return t.ctrlKey?"ctrl":t.shiftKey?"shift":"none"}}var Om={},Ts={};Object.defineProperty(Ts,"__esModule",{value:!0}),Ts.SimpleEventDispatcher=void 0;const Fm=br;class iS extends Fm.DispatcherBase{constructor(){super()}dispatch(e){const t=this._dispatch(!1,this,arguments);if(t==null)throw new Fm.DispatchError("Got `null` back from dispatch.");return t}dispatchAsync(e){this._dispatch(!0,this,arguments)}asEvent(){return super.asEvent()}}Ts.SimpleEventDispatcher=iS;var _l={},Co={};Object.defineProperty(Co,"__esModule",{value:!0}),Co.SimpleEventList=void 0;const rS=br,sS=Ts;class oS extends rS.EventListBase{constructor(){super()}createDispatcher(){return new sS.SimpleEventDispatcher}}Co.SimpleEventList=oS,Object.defineProperty(_l,"__esModule",{value:!0}),_l.SimpleEventHandlingBase=void 0;const aS=br,cS=Co;class lS extends aS.HandlingBase{constructor(){super(new cS.SimpleEventList)}}_l.SimpleEventHandlingBase=lS;var vl={};Object.defineProperty(vl,"__esModule",{value:!0}),vl.NonUniformSimpleEventList=void 0;const hS=Ts;class uS{constructor(){this._events={}}get(e){if(this._events[e])return this._events[e];const t=this.createDispatcher();return this._events[e]=t,t}remove(e){delete this._events[e]}createDispatcher(){return new hS.SimpleEventDispatcher}}vl.NonUniformSimpleEventList=uS,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.NonUniformSimpleEventList=r.SimpleEventList=r.SimpleEventHandlingBase=r.SimpleEventDispatcher=void 0;const e=Ts;Object.defineProperty(r,"SimpleEventDispatcher",{enumerable:!0,get:function(){return e.SimpleEventDispatcher}});const t=_l;Object.defineProperty(r,"SimpleEventHandlingBase",{enumerable:!0,get:function(){return t.SimpleEventHandlingBase}});const n=vl;Object.defineProperty(r,"NonUniformSimpleEventList",{enumerable:!0,get:function(){return n.NonUniformSimpleEventList}});const i=Co;Object.defineProperty(r,"SimpleEventList",{enumerable:!0,get:function(){return i.SimpleEventList}})}(Om);class zm{constructor(e){$(this,"_viewer");this._viewer=e}onKeyAction(e){const t=this._viewer.camera;switch(e){case At.KEY_P:return t.orthographic=!t.orthographic,!0;case At.KEY_ADD:case At.KEY_OEM_PLUS:return t.speed+=1,!0;case At.KEY_SUBTRACT:case At.KEY_OEM_MINUS:return t.speed-=1,!0;case At.KEY_F8:case At.KEY_SPACE:return this._viewer.inputs.pointerActive=this._viewer.inputs.pointerFallback,!0;case At.KEY_HOME:return t.lerp(1).reset(),!0;case At.KEY_ESCAPE:return!0;case At.KEY_Z:case At.KEY_F:return t.lerp(1).frame("all"),!0;default:return!1}}}class fS{constructor(e){$(this,"_viewer");$(this,"_scheme");$(this,"touch");$(this,"mouse");$(this,"keyboard");$(this,"_pointerActive","orbit");$(this,"_pointerFallback","look");$(this,"_pointerOverride");$(this,"_onPointerModeChanged",new Ms.SignalDispatcher);$(this,"_onPointerOverrideChanged",new Ms.SignalDispatcher);$(this,"_onContextMenu",new Om.SimpleEventDispatcher);$(this,"unregisterAll",()=>{this.mouse.unregister(),this.keyboard.unregister(),this.touch.unregister()});this._viewer=e,this._scheme=new zm(e),this.keyboard=new eS(e),this.mouse=new nS(e),this.touch=new tS(e),this.pointerActive=e.settings.camera.controls.orbit?"orbit":"look",this._pointerFallback=e.settings.camera.controls.orbit?"look":"orbit"}get pointerFallback(){return this._pointerFallback}get pointerActive(){return this._pointerActive}get pointerOverride(){return this._pointerOverride}set pointerOverride(e){e!==this._pointerOverride&&(this._pointerOverride=e,this._onPointerOverrideChanged.dispatch())}set pointerActive(e){e!==this._pointerActive&&(e==="look"?this._pointerFallback="orbit":e==="orbit"&&(this._pointerFallback="look"),this._pointerActive=e,this._onPointerModeChanged.dispatch())}get onPointerModeChanged(){return this._onPointerModeChanged.asEvent()}get onPointerOverrideChanged(){return this._onPointerOverrideChanged.asEvent()}get onContextMenu(){return this._onContextMenu.asEvent()}get scheme(){return this._scheme}KeyAction(e){return this._scheme.onKeyAction(e)}ContextMenu(e){this._onContextMenu.dispatch(e)}registerAll(){this.keyboard.register(),this.mouse.register(),this.touch.register()}resetAll(){this.mouse.reset(),this.keyboard.reset(),this.touch.reset()}}class dS{constructor(){$(this,"mesh");$(this,"_source");$(this,"_size",1);$(this,"_geometry");$(this,"_material");$(this,"_texture");this._geometry=new rr,this._material=new un({transparent:!0,depthTest:!0,depthWrite:!1}),this.mesh=new St(this._geometry,this._material),this.mesh.renderOrder=-1}applyViewerSettings(e){this._size=e.groundPlane.size,this.mesh.visible=e.groundPlane.visible,this.applyTexture(e.groundPlane.encoding,e.groundPlane.texture),this._material.color.copy(e.groundPlane.color),this._material.opacity=e.groundPlane.opacity}adaptToContent(e){const t=e.getCenter(new U),n=new U(t.x,e.min.y-Math.abs(e.min.y)*.01,t.z);this.mesh.position.copy(n),this.mesh.quaternion.copy(new wt().setFromEuler(new Zt(1.5*Math.PI,0,0)));const s=(e?.getBoundingSphere(new Pt)?.radius??1)*this._size,o=new U(1,1,1).multiplyScalar(s);this.mesh.scale.copy(o)}applyTexture(e,t){if(t!==this._source&&(this._source=t,this._texture?.dispose(),this._texture=void 0,!(!t||!e))){if(e==="url"){const n=new lu;this._texture=n.load(t)}if(e==="base64"){const n=new Image;n.src=t;const i=new xt;this._texture=i,this._texture.image=n,n.onload=()=>{i.needsUpdate=!0}}if(!this._texture){console.error("Failed to load texture: "+t);return}this._material.map=this._texture}}dispose(){this._geometry?.dispose(),this._material?.dispose(),this._texture?.dispose(),this._texture=void 0}}class pS{constructor(e){$(this,"skyLight");$(this,"ambientLight");$(this,"sunLights");$(this,"_groundPlane");this._groundPlane=new dS,this.skyLight=new hu,this.ambientLight=new mu,this.sunLights=[],this.applySettings(e)}get groundPlane(){return this._groundPlane.mesh}loadGroundTexture(e,t){this._groundPlane.applyTexture(e,t)}getObjects(){return[this._groundPlane.mesh,this.skyLight,this.ambientLight,...this.sunLights]}applySettings(e){this._groundPlane.applyViewerSettings(e),this.skyLight.color.copy(e.skylight.skyColor),this.skyLight.groundColor.copy(e.skylight.groundColor),this.skyLight.intensity=e.skylight.intensity,this.ambientLight.color.copy(e.ambientLight.color),this.ambientLight.intensity=e.ambientLight.intensity;const t=e.sunLights.length;for(let n=0;n<t;n++){this.sunLights[n]||(this.sunLights[n]=new jc);const i=e.sunLights[n].color,s=e.sunLights[n].position,o=e.sunLights[n].intensity;i&&this.sunLights[n].color.copy(i),s&&this.sunLights[n].position.copy(s),o&&(this.sunLights[n].intensity=o)}}adaptToContent(e){this._groundPlane.adaptToContent(e)}dispose(){this.sunLights.forEach(e=>e.dispose()),this.skyLight.dispose(),this.ambientLight.dispose(),this._groundPlane.dispose()}}class mS{constructor(e,t,n,i){$(this,"_renderer");$(this,"_camera");$(this,"_inputs");$(this,"_size",1);$(this,"_fov",50);$(this,"_color",new xe("blue"));$(this,"_opacity",.2);$(this,"_opacityAlways",.5);$(this,"_fadeDurationMs",200);$(this,"_showDurationMs",1e3);$(this,"_box");$(this,"_wireframe");$(this,"_material");$(this,"_materialAlways");$(this,"_gizmos");$(this,"_disconnectCamera");$(this,"_timeout");$(this,"_fadeEnd",0);$(this,"_active",!0);$(this,"_animation",0);this._renderer=e,this._camera=t,this._inputs=n,this.applySettings(i),this.connect()}connect(){const e=this._inputs.onPointerModeChanged.subscribe(()=>this.onUpdate()),t=this._camera.onMoved.subscribe(()=>this.onUpdate()),n=this._camera.onValueChanged.subscribe(()=>this.onUpdate());this._disconnectCamera=()=>{e(),t(),n()}}onUpdate(){this.updateScale(),this.setPosition(this._camera.target),this.show(!0)}dispose(){cancelAnimationFrame(this._animation),clearTimeout(this._timeout),this._box?.dispose(),this._wireframe?.dispose(),this._material?.dispose(),this._materialAlways?.dispose(),this._disconnectCamera?.(),this._box=void 0,this._wireframe=void 0,this._material=void 0,this._materialAlways=void 0,this._disconnectCamera=void 0,this._gizmos&&(this._renderer.remove(this._gizmos),this._gizmos=void 0)}get enabled(){return this._active}set enabled(e){this._active=e}show(e=!0){!this._active||(this._gizmos||this.createGizmo(),clearTimeout(this._timeout),this._gizmos.visible=e,e&&(this._timeout=setTimeout(()=>this.fadeOut(),this._showDurationMs)))}fadeOut(e){const t=new Date().getTime();if(e||(this._fadeEnd=t+this._fadeDurationMs),t>this._fadeEnd)this._gizmos.visible=!1,this._material.opacity=this._opacity,this._materialAlways.opacity=this._opacityAlways;else{this._animation=requestAnimationFrame(()=>this.fadeOut(!0));const n=Math.pow((this._fadeEnd-t)/this._fadeDurationMs,4);this._material.opacity=ka.lerp(0,this._opacity,n),this._materialAlways.opacity=ka.lerp(0,this._opacityAlways,n)}this._renderer.needsUpdate=!0}setPosition(e){this._gizmos?.position.copy(e),this.updateScale()}setSize(e){this._size=e}setOpacity(e,t){this._opacity=e,this._opacityAlways=t,this._gizmos&&(this._material.opacity=e,this._materialAlways.opacity=t)}setColor(e){this._color=e,this._gizmos&&(this._material.color=e,this._materialAlways.color=e)}applySettings(e){this._active=e.camera.gizmo.enable,this._fov=e.camera.fov,this.setColor(e.camera.gizmo.color),this.setSize(e.camera.gizmo.size),this.setOpacity(e.camera.gizmo.opacity,e.camera.gizmo.opacityAlways)}updateScale(){if(!this._gizmos)return;const e=this._camera.frustrumSizeAt(this._gizmos.position),n=Math.min(e.x,e.y)*this._size;this._gizmos.scale.set(n,n,n)}createGizmo(){this._box=new ms(1),this._wireframe=new eu(this._box),this._wireframe.addGroup(0,1/0,0),this._wireframe.addGroup(0,1/0,1),this._material=new qt({depthTest:!0,opacity:this._opacity,color:this._color,transparent:!0}),this._materialAlways=new qt({depthTest:!1,opacity:this._opacityAlways,color:this._color,transparent:!0}),this._gizmos=new In(this._wireframe,[this._material,this._materialAlways]),this._renderer.add(this._gizmos),this.updateScale()}}const Cs=new U,km=new We,Vm=new We,Hm=new U,Gm=new U;class gS{constructor(e={}){const t=this;let n,i,s,o;const a={objects:new WeakMap},c=e.element!==void 0?e.element:document.createElement("div");c.style.overflow="hidden",this.domElement=c,this.sortObjects=!0,this.getSize=function(){return{width:n,height:i}},this.render=function(g,_){g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),_.parent===null&&_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),km.copy(_.matrixWorldInverse),Vm.multiplyMatrices(_.projectionMatrix,km),h(g,g,_),this.sortObjects&&d(g)},this.setSize=function(g,_){n=g,i=_,s=n/2,o=i/2,c.style.width=g+"px",c.style.height=_+"px"};function l(g){g.isCSS2DObject&&(g.element.style.display="none");for(let _=0,m=g.children.length;_<m;_++)l(g.children[_])}function h(g,_,m){if(g.visible===!1){l(g);return}if(g.isCSS2DObject){Cs.setFromMatrixPosition(g.matrixWorld),Cs.applyMatrix4(Vm);const p=Cs.z>=-1&&Cs.z<=1&&g.layers.test(m.layers)===!0,v=g.element;v.style.display=p===!0?"":"none",p===!0&&(g.onBeforeRender(t,_,m),v.style.transform="translate("+-100*g.center.x+"%,"+-100*g.center.y+"%)translate("+(Cs.x*s+s)+"px,"+(-Cs.y*o+o)+"px)",v.parentNode!==c&&c.appendChild(v),g.onAfterRender(t,_,m));const y={distanceToCameraSquared:u(m,g)};a.objects.set(g,y)}for(let p=0,v=g.children.length;p<v;p++)h(g.children[p],_,m)}function u(g,_){return Hm.setFromMatrixPosition(g.matrixWorld),Gm.setFromMatrixPosition(_.matrixWorld),Hm.distanceToSquared(Gm)}function f(g){const _=[];return g.traverseVisible(function(m){m.isCSS2DObject&&_.push(m)}),_}function d(g){const _=f(g).sort(function(p,v){if(p.renderOrder!==v.renderOrder)return v.renderOrder-p.renderOrder;const y=a.objects.get(p).distanceToCameraSquared,x=a.objects.get(v).distanceToCameraSquared;return y-x}),m=_.length;for(let p=0,v=_.length;p<v;p++)_[p].element.style.zIndex=m-p}}}class ku{constructor(e){$(this,"canvas");$(this,"text");$(this,"_unregisterResize");$(this,"_ownedCanvas");$(this,"_onResize",new Ms.SignalDispatcher);const[t,n]=ku.getOrCreateCanvas(e.canvas.id);this.canvas=t,this._ownedCanvas=n,this.watchResize(e.canvas.resizeDelay)}get onResize(){return this._onResize.asEvent()}static getOrCreateCanvas(e){let t=e?document.getElementById(e):void 0;return t?[t,!1]:(t=document.createElement("canvas"),t.className="ara3d-canvas",t.tabIndex=0,t.style.backgroundColor="black",document.body.appendChild(t),[t,!0])}createTextRenderer(){if(console.log("Creating text renderer"),!this.canvas.parentElement)throw new Error("Cannot create text renderer without a canvas");const e=this.getParentSize(),t=new gS;return t.setSize(e.x,e.y),this.text=t.domElement,this.text.className="ara3d-text-renderer",this.text.style.position="absolute",this.text.style.top="0px",this.text.style.pointerEvents="none",this.canvas.parentElement.append(this.text),t}dispose(){this._unregisterResize?.(),this._unregisterResize=void 0,this._ownedCanvas&&this.canvas.remove()}getParentSize(){return new he(this.canvas.parentElement?.clientWidth??this.canvas.clientWidth,this.canvas.parentElement?.clientHeight??this.canvas.clientHeight)}getSize(){return new he(this.canvas.clientWidth,this.canvas.clientHeight)}getAspectRatio(){const e=this.getParentSize();return e.x/e.y}ResizeToParent(){this._onResize.dispatch()}watchResize(e){let t;const n=()=>{t!==void 0&&(clearTimeout(t),t=void 0),t=setTimeout(()=>{t=void 0,this._onResize.dispatch()},e)};window.addEventListener("resize",n),this._unregisterResize=()=>window.removeEventListener("resize",n)}}class _S{constructor(e,t,n,i){$(this,"renderer");$(this,"antialias",!0);$(this,"scene");$(this,"viewport");$(this,"camera");$(this,"needsUpdate");$(this,"_lastSize",new he);$(this,"fitViewport",()=>{const e=this.viewport.getParentSize();if(e.x===this._lastSize.x&&e.y===this._lastSize.y)return;this._lastSize.copy(e);const t=1.5;this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,t)),this.renderer.setSize(e.x,e.y),this.needsUpdate=!0});this.viewport=t,this.scene=e,this.camera=n,this.renderer=new Cm({canvas:t.canvas,antialias:!0,precision:"highp",alpha:!0,stencil:!1,powerPreference:"high-performance",logarithmicDepthBuffer:!0}),this.fitViewport(),this.viewport.onResize.subscribe(()=>this.fitViewport()),this.camera.onValueChanged.sub(()=>{this.needsUpdate=!0}),this.background=i.background.color,this.applyRenderingSettings(i)}applyRenderingSettings(e){this.renderer.toneMapping=e.rendering.toneMapping,this.renderer.toneMappingExposure=e.rendering.toneMappingExposure}dispose(){this.clear(),this.renderer.clear(),this.renderer.forceContextLoss(),this.renderer.dispose()}get background(){return this.scene.background}set background(e){this.scene.background=e,e===null?this.renderer.setClearColor(0,0):this.renderer.setClearColor(0,1),this.needsUpdate=!0}render(){!this.needsUpdate&&!this.camera.hasMoved||this.renderer.render(this.scene,this.camera.camPerspective.camera)}add(e){return this.scene.add(e),this.needsUpdate=!0,!0}remove(e){this.scene.remove(e),this.needsUpdate=!0}clear(){this.scene.clear(),this.needsUpdate=!0}}class vS{constructor(e){$(this,"settings");$(this,"renderer");$(this,"viewport");$(this,"inputs");$(this,"camera");$(this,"environment");$(this,"gizmoOrbit");$(this,"running",!1);$(this,"updateId",null);$(this,"clock",new el);$(this,"scene",new Ch);$(this,"animate",()=>{if(!this.running)return;this.updateId=requestAnimationFrame(this.animate);const e=this.clock.getDelta(),t=this.camera.update(e);this.renderer.needsUpdate=this.renderer.needsUpdate||t,this.renderer.render()});this.settings=Dm(e),this.viewport=new ku(this.settings),this.camera=new Jw(this.viewport,this.settings),this.renderer=new _S(this.scene,this.viewport,this.camera,this.settings),this.inputs=new fS(this),this.settings.camera.gizmo.enable&&(this.gizmoOrbit=new mS(this.renderer,this.camera,this.inputs,this.settings)),this.environment=new pS(this.settings),this.environment.getObjects().forEach(t=>this.renderer.add(t)),this.inputs.registerAll(),this.start()}start(){this.running||(this.running=!0,this.clock.start(),this.animate())}stop(){this.running=!1,this.updateId!==null&&(cancelAnimationFrame(this.updateId),this.updateId=null)}add(e,t=!0){if(console.log("Adding object"),this.renderer.needsUpdate=!0,!this.renderer.add(e))throw new Error("Could not load object")}clear(){this.renderer.clear()}dispose(){cancelAnimationFrame(this.updateId),this.environment.dispose(),this.gizmoOrbit.dispose(),this.viewport.dispose(),this.renderer.dispose(),this.inputs.unregisterAll()}}function Wm(r,e){if(e===Zf)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===Oa||e===eh){let t=r.getIndex();if(t===null){const o=[],a=r.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===Oa)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}class yS extends Jt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new SS(t)}),this.register(function(t){return new MS(t)}),this.register(function(t){return new NS(t)}),this.register(function(t){return new US(t)}),this.register(function(t){return new BS(t)}),this.register(function(t){return new TS(t)}),this.register(function(t){return new CS(t)}),this.register(function(t){return new IS(t)}),this.register(function(t){return new RS(t)}),this.register(function(t){return new wS(t)}),this.register(function(t){return new PS(t)}),this.register(function(t){return new ES(t)}),this.register(function(t){return new LS(t)}),this.register(function(t){return new DS(t)}),this.register(function(t){return new AS(t)}),this.register(function(t){return new OS(t)}),this.register(function(t){return new FS(t)})}load(e,t,n,i){const s=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=Li.extractUrlBase(e);o=Li.resolveURL(l,this.path)}else o=Li.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){i?i(l):console.error(l),s.manager.itemError(e),s.manager.itemEnd(e)},c=new An(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{s.parse(l,o,function(h){t(h),s.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const o={},a={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===qm){try{o[at.KHR_BINARY_GLTF]=new zS(e)}catch(u){i&&i(u);return}s=JSON.parse(o[at.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new JS(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const u=s.extensionsUsed[h],f=s.extensionsRequired||[];switch(u){case at.KHR_MATERIALS_UNLIT:o[u]=new bS;break;case at.KHR_DRACO_MESH_COMPRESSION:o[u]=new kS(s,this.dracoLoader);break;case at.KHR_TEXTURE_TRANSFORM:o[u]=new VS;break;case at.KHR_MESH_QUANTIZATION:o[u]=new HS;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function xS(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const at={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class AS{constructor(e){this.parser=e,this.name=at.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let l;const h=new xe(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],Xt);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new jc(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new pu(h),l.distance=u;break;case"spot":l=new du(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),ti(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),i=Promise.resolve(l),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}}class bS{constructor(){this.name=at.KHR_MATERIALS_UNLIT}getMaterialType(){return un}extendParams(e,t,n){const i=[];e.color=new xe(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],Xt),e.opacity=o[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,Tt))}return Promise.all(i)}}class wS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class SS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new he(a,a)}return Promise.all(s)}}class MS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class ES{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}}class TS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new xe(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],Xt)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,Tt)),o.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class CS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}}class IS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new xe().setRGB(a[0],a[1],a[2],Xt),Promise.all(s)}}class RS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class PS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new xe().setRGB(a[0],a[1],a[2],Xt),o.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,Tt)),Promise.all(s)}}class DS{constructor(e){this.parser=e,this.name=at.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}}class LS{constructor(e){this.parser=e,this.name=at.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Rn}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}}class NS{constructor(e){this.parser=e,this.name=at.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class US{constructor(e){this.parser=e,this.name=at.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,o.source,c)}}class BS{constructor(e){this.parser=e,this.name=at.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(e,o.source,c)}}class OS{constructor(e){this.name=at.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const c=i.byteOffset||0,l=i.byteLength||0,h=i.count,u=i.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,i.mode,i.filter).then(function(d){return d.buffer}):o.ready.then(function(){const d=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,i.mode,i.filter),d})})}else return null}}class FS{constructor(e){this.name=at.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const l of i.primitives)if(l.mode!==Dn.TRIANGLES&&l.mode!==Dn.TRIANGLE_STRIP&&l.mode!==Dn.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],c={};for(const l in o)a.push(this.parser.getDependency("accessor",o[l]).then(h=>(c[l]=h,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,d=[];for(const g of u){const _=new We,m=new U,p=new wt,v=new U(1,1,1),y=new _c(g.geometry,g.material,f);for(let x=0;x<f;x++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,x),c.SCALE&&v.fromBufferAttribute(c.SCALE,x),y.setMatrixAt(x,_.compose(m,p,v));for(const x in c)if(x==="_COLOR_0"){const A=c[x];y.instanceColor=new Ji(A.array,A.itemSize,A.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&g.geometry.setAttribute(x,c[x]);ct.prototype.copy.call(y,g),this.parser.assignFinalMaterial(y),d.push(y)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}}const qm="glTF",Io=12,Xm={JSON:1313821514,BIN:5130562};class zS{constructor(e){this.name=at.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Io),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==qm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Io,s=new DataView(e,Io);let o=0;for(;o<i;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,c===Xm.JSON){const l=new Uint8Array(e,Io+o,a);this.content=n.decode(l)}else if(c===Xm.BIN){const l=Io+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class kS{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=at.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(const h in o){const u=Hu[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=Hu[h]||h.toLowerCase();if(o[h]!==void 0){const f=n.accessors[e.attributes[h]],d=Is[f.componentType];l[u]=d.name,c[u]=f.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(u,f){i.decodeDracoFile(h,function(d){for(const g in d.attributes){const _=d.attributes[g],m=c[g];m!==void 0&&(_.normalized=m)}u(d)},a,l,Xt,f)})})}}class VS{constructor(){this.name=at.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class HS{constructor(){this.name=at.KHR_MESH_QUANTIZATION}}class Zm extends _s{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[s+o];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=i-t,u=(n-t)/h,f=u*u,d=f*u,g=e*l,_=g-l,m=-2*d+3*f,p=d-f,v=1-m,y=p-f+u;for(let x=0;x!==a;x++){const A=o[_+x+a],E=o[_+x+c]*h,I=o[g+x+a],D=o[g+x]*h;s[x]=v*A+y*E+m*I+p*D}return s}}const GS=new wt;class WS extends Zm{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return GS.fromArray(s).normalize().toArray(s),s}}const Dn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Is={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ym={9728:Mt,9729:pt,9984:Ko,9985:Ur,9986:Hi,9987:Mn},Qm={33071:tn,33648:Nr,10497:yi},Vu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Hu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Bi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},qS={CUBICSPLINE:void 0,LINEAR:zr,STEP:Fr},Gu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function XS(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new gs({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Wn})),r.DefaultMaterial}function Sr(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ti(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ZS(r,e,t){let n=!1,i=!1,s=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(r);const o=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(n){const f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):r.attributes.position;o.push(f)}if(i){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;a.push(f)}if(s){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):r.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],f=l[2];return n&&(r.morphAttributes.position=h),i&&(r.morphAttributes.normal=u),s&&(r.morphAttributes.color=f),r.morphTargetsRelative=!0,r})}function YS(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function QS(r){let e;const t=r.extensions&&r.extensions[at.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Wu(t.attributes):e=r.indices+":"+Wu(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+Wu(r.targets[n]);return e}function Wu(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function qu(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function KS(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const jS=new We;class JS{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new xS,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,s=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);i=n&&c?parseInt(c[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&o<98?this.textureLoader=new lu(this.options.manager):this.textureLoader=new Up(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new An(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return Sr(s,a,i),ti(a,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const o=t[i].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(o,a)=>{const c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(const[l,h]of o.children.entries())s(h,a.children[l])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[at.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,o){n.load(Li.resolveURL(t.uri,i.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=Vu[i.type],a=Is[i.componentType],c=i.normalized===!0,l=new a(i.count*o);return Promise.resolve(new ot(l,o,c))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(o){const a=o[0],c=Vu[i.type],l=Is[i.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,f=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let _,m;if(d&&d!==u){const p=Math.floor(f/d),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let y=t.cache.get(v);y||(_=new l(a,p*d,i.count*d/h),y=new os(_,d/h),t.cache.add(v,y)),m=new fi(y,c,f%d/h,g)}else a===null?_=new l(i.count*c):_=new l(a,f,i.count*c),m=new ot(_,c,g);if(i.sparse!==void 0){const p=Vu.SCALAR,v=Is[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,A=new v(o[1],y,i.sparse.count*p),E=new l(o[2],x,i.sparse.count*c);a!==null&&(m=new ot(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let I=0,D=A.length;I<D;I++){const b=A[I];if(m.setX(b,E[I*c]),c>=2&&m.setY(b,E[I*c+1]),c>=3&&m.setZ(b,E[I*c+2]),c>=4&&m.setW(b,E[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(s.samplers||{})[o.sampler]||{};return h.magFilter=Ym[f.magFilter]||pt,h.minFilter=Ym[f.minFilter]||Mn,h.wrapS=Qm[f.wrapS]||yi,h.wrapT=Qm[f.wrapT]||yi,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Mt&&h.minFilter!==pt,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(u){l=!0;const f=new Blob([u],{type:o.mimeType});return c=a.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(f,d){let g=f;t.isImageBitmapLoader===!0&&(g=function(_){const m=new xt(_);m.needsUpdate=!0,f(m)}),t.load(Li.resolveURL(u,s.path),g,void 0,d)})}).then(function(u){return l===!0&&a.revokeObjectURL(c),ti(u,o),u.userData.mimeType=o.mimeType||KS(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[at.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[at.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=s.associations.get(o);o=s.extensions[at.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,c)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new Ec,zt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new qt,zt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),s&&(c.vertexColors=!0),o&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return gs}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},c=s.extensions||{},l=[];if(c[at.KHR_MATERIALS_UNLIT]){const u=i[at.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),l.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new xe(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],Xt),a.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,Tt)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Sn);const h=s.alphaMode||Gu.OPAQUE;if(h===Gu.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Gu.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==un&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new he(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&o!==un&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==un){const u=s.emissiveFactor;a.emissive=new xe().setRGB(u[0],u[1],u[2],Xt)}return s.emissiveTexture!==void 0&&o!==un&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Tt)),Promise.all(l).then(function(){const u=new o(a);return s.name&&(u.name=s.name),ti(u,s),t.associations.set(u,{materials:e}),s.extensions&&Sr(i,u,s),u})}createUniqueName(e){const t=lt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[at.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Km(c,a,t)})}const o=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],h=QS(l),u=i[h];if(u)o.push(u.promise);else{let f;l.extensions&&l.extensions[at.KHR_DRACO_MESH_COMPRESSION]?f=s(l):f=Km(new Ke,l,t),i[h]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let c=0,l=o.length;c<l;c++){const h=o[c].material===void 0?XS(this.cache):this.getDependency("material",o[c].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let d=0,g=h.length;d<g;d++){const _=h[d],m=o[d];let p;const v=l[d];if(m.mode===Dn.TRIANGLES||m.mode===Dn.TRIANGLE_STRIP||m.mode===Dn.TRIANGLE_FAN||m.mode===void 0)p=s.isSkinnedMesh===!0?new Lh(_,v):new St(_,v),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),m.mode===Dn.TRIANGLE_STRIP?p.geometry=Wm(p.geometry,eh):m.mode===Dn.TRIANGLE_FAN&&(p.geometry=Wm(p.geometry,Oa));else if(m.mode===Dn.LINES)p=new In(_,v);else if(m.mode===Dn.LINE_STRIP)p=new di(_,v);else if(m.mode===Dn.LINE_LOOP)p=new Fh(_,v);else if(m.mode===Dn.POINTS)p=new kh(_,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&YS(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),ti(p,s),m.extensions&&Sr(i,p,m),t.assignFinalMaterial(p),u.push(p)}for(let d=0,g=u.length;d<g;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return s.extensions&&Sr(i,u[0],s),u[0];const f=new Kn;s.extensions&&Sr(i,f,s),t.associations.set(f,{meshes:e});for(let d=0,g=u.length;d<g;d++)f.add(u[d]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new kt(ka.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new ur(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ti(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),o=i,a=[],c=[];for(let l=0,h=o.length;l<h;l++){const u=o[l];if(u){a.push(u);const f=new We;s!==null&&f.fromArray(s.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new no(a,c)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,o=[],a=[],c=[],l=[],h=[];for(let u=0,f=i.channels.length;u<f;u++){const d=i.channels[u],g=i.samplers[d.sampler],_=d.target,m=_.node,p=i.parameters!==void 0?i.parameters[g.input]:g.input,v=i.parameters!==void 0?i.parameters[g.output]:g.output;_.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",v)),l.push(g),h.push(_))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const f=u[0],d=u[1],g=u[2],_=u[3],m=u[4],p=[];for(let y=0,x=f.length;y<x;y++){const A=f[y],E=d[y],I=g[y],D=_[y],b=m[y];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();const C=n._createAnimationTracks(A,E,I,D,b);if(C)for(let B=0;B<C.length;B++)p.push(C[B])}const v=new vs(s,void 0,p);return ti(v,i),v})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const o=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&o.traverse(function(a){if(!!a.isMesh)for(let c=0,l=i.weights.length;c<l;c++)a.morphTargetInfluences[c]=i.weights[c]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),o=[],a=i.children||[];for(let l=0,h=a.length;l<h;l++)o.push(n.getDependency("node",a[l]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(o),c]).then(function(l){const h=l[0],u=l[1],f=l[2];f!==null&&h.traverse(function(d){!d.isSkinnedMesh||d.bind(f,jS)});for(let d=0,g=u.length;d<g;d++)h.add(u[d]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],o=s.name?i.createUniqueName(s.name):"",a=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(l){return i._getNodeRef(i.cameraCache,s.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(s.isBone===!0?h=new mc:l.length>1?h=new Kn:l.length===1?h=l[0]:h=new ct,h!==l[0])for(let u=0,f=l.length;u<f;u++)h.add(l[u]);if(s.name&&(h.userData.name=s.name,h.name=o),ti(h,s),s.extensions&&Sr(n,h,s),s.matrix!==void 0){const u=new We;u.fromArray(s.matrix),h.applyMatrix4(u)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const u=i.associations.get(h);i.associations.set(h,{...u})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new Kn;n.name&&(s.name=i.createUniqueName(n.name)),ti(s,n),n.extensions&&Sr(t,s,n);const o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(i.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let h=0,u=c.length;h<u;h++)s.add(c[h]);const l=h=>{const u=new Map;for(const[f,d]of i.associations)(f instanceof zt||f instanceof xt)&&u.set(f,d);return h.traverse(f=>{const d=i.associations.get(f);d!=null&&u.set(f,d)}),u};return i.associations=l(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,c=[];Bi[s.path]===Bi.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(Bi[s.path]){case Bi.weights:l=ar;break;case Bi.rotation:l=cr;break;case Bi.translation:case Bi.scale:l=hr;break;default:switch(n.itemSize){case 1:l=ar;break;case 2:case 3:default:l=hr;break}break}const h=i.interpolation!==void 0?qS[i.interpolation]:zr,u=this._getArrayFromAccessor(n);for(let f=0,d=c.length;f<d;f++){const g=new l(c[f]+"."+Bi[s.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=qu(t.constructor),i=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof cr?WS:Zm;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function $S(r,e,t){const n=e.attributes,i=new Gt;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(i.set(new U(c[0],c[1],c[2]),new U(l[0],l[1],l[2])),a.normalized){const h=qu(Is[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new U,c=new U;for(let l=0,h=s.length;l<h;l++){const u=s[l];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],d=f.min,g=f.max;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),f.normalized){const _=qu(Is[f.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}r.boundingBox=i;const o=new Pt;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=o}function Km(r,e,t){const n=e.attributes,i=[];function s(o,a){return t.getDependency("accessor",o).then(function(c){r.setAttribute(a,c)})}for(const o in n){const a=Hu[o]||o.toLowerCase();a in r.attributes||i.push(s(n[o],a))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(a){r.setIndex(a)});i.push(o)}return rt.workingColorSpace!==Xt&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${rt.workingColorSpace}" not supported.`),ti(r,e),$S(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?ZS(r,e.targets,t):r})}const Xu=new WeakMap;class eM extends Jt{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new An(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Tt,n).catch(n)}decodeDracoFile(e,t,n,i,s=Xt,o=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Xu.has(e)){const c=Xu.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(c=>(i=c,new Promise((l,h)=>{i._callbacks[s]={resolve:l,reject:h},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Xu.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new Ke;e.index&&t.setIndex(new ot(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:o,stride:a,vertexColorSpace:c}=e.attributes[n];let l;if(o===a)l=new ot(s,o);else{const h=new os(s,a);l=new fi(h,o,0)}i==="color"&&(this._assignVertexColorSpace(l,c),l.normalized=!(s instanceof Float32Array)),t.setAttribute(i,l)}return t}_assignVertexColorSpace(e,t){if(t!==Tt)return;const n=new xe;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),rt.colorSpaceToWorking(n,Tt),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new An(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=tM.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
4036
4036
  `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function tM(){let r,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(h){r.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(r)});break;case"decode":const c=a.buffer,l=a.taskConfig;e.then(h=>{const u=h.draco,f=new u.Decoder;try{const d=t(u,f,new Int8Array(c),l),g=d.attributes.map(_=>_.array.buffer);d.index&&g.push(d.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:d},g)}catch(d){console.error(d),self.postMessage({type:"error",id:a.id,error:d.message})}finally{u.destroy(f)}});break}};function t(o,a,c,l){const h=l.attributeIDs,u=l.attributeTypes;let f,d;const g=a.GetEncodedGeometryType(c);if(g===o.TRIANGULAR_MESH)f=new o.Mesh,d=a.DecodeArrayToMesh(c,c.byteLength,f);else if(g===o.POINT_CLOUD)f=new o.PointCloud,d=a.DecodeArrayToPointCloud(c,c.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const _={index:null,attributes:[]};for(const m in h){const p=self[u[m]];let v,y;if(l.useUniqueIDs)y=h[m],v=a.GetAttributeByUniqueId(f,y);else{if(y=a.GetAttributeId(f,o[h[m]]),y===-1)continue;v=a.GetAttribute(f,y)}const x=i(o,a,f,m,p,v);m==="color"&&(x.vertexColorSpace=l.vertexColorSpace),_.attributes.push(x)}return g===o.TRIANGULAR_MESH&&(_.index=n(o,a,f)),o.destroy(f),_}function n(o,a,c){const h=c.num_faces()*3,u=h*4,f=o._malloc(u);a.GetTrianglesUInt32Array(c,u,f);const d=new Uint32Array(o.HEAPF32.buffer,f,h).slice();return o._free(f),{array:d,itemSize:1}}function i(o,a,c,l,h,u){const f=c.num_points(),d=u.num_components(),g=s(o,h),_=d*h.BYTES_PER_ELEMENT,m=Math.ceil(_/4)*4,p=m/h.BYTES_PER_ELEMENT,v=f*_,y=f*m,x=o._malloc(v);a.GetAttributeDataArrayForAllPoints(c,u,g,v,x);const A=new h(o.HEAPF32.buffer,x,v/h.BYTES_PER_ELEMENT);let E;if(_===m)E=A.slice();else{E=new h(y/h.BYTES_PER_ELEMENT);let I=0;for(let D=0,b=A.length;D<b;D++){for(let C=0;C<d;C++)E[I+C]=A[D*d+C];I+=p}}return o._free(x),{name:l,count:f,itemSize:d,array:E,stride:p}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}class nM{constructor(){$(this,"loader");this.loader=new yS;const e=new eM;e.setDecoderPath("/draco/"),this.loader.setDRACOLoader(e)}async load(e){return this.loadFromUrlOrZip(e)}async loadFromUrlOrZip(e){return e.toLowerCase().endsWith(".zip")?this.loadFromZipUrl(e):new Promise((t,n)=>{this.loader.load(e,i=>{const s=i.scene||i.scenes[0];if(!s)return n(new Error("Model contains no scene and cannot be viewed."));t(s)},void 0,n)})}async loadFromZipUrl(e){throw new Error("Not implemented")}}function yl(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var jm={exports:{}};/*!
4037
4037
 
4038
4038
  JSZip v3.10.1 - A JavaScript class for generating and reading zip files