@yschindel/ara3d-webgl 1.3.14 → 1.3.16

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=xa;Object.defineProperty(r,"SignalDispatcher",{enumerable:!0,get:function(){return e.SignalDispatcher}});const t=dl;Object.defineProperty(r,"SignalHandlingBase",{enumerable:!0,get:function(){return t.SignalHandlingBase}});const n=Ma;Object.defineProperty(r,"SignalList",{enumerable:!0,get:function(){return n.SignalList}})}(ws);class Hw{constructor(e){Q(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 Gw{constructor(e){Q(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 Pm{constructor(e){Q(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),a=Math.asin(e.y)-Math.asin(t.y),o=new he(a,s);o.multiplyScalar(180/Math.PI),this.orbit(o)}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 Ww extends Pm{constructor(t,n){super(t);Q(this,"_movement");Q(this,"_clock",new jc);Q(this,"onProgress");Q(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),a=new U;this.onProgress=o=>{a.copy(i),a.lerp(s,o),this._movement.move3(a)}}rotate(t){const n=new Qt(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(),a=new Mt().setFromEuler(n),o=new Mt;this.onProgress=c=>{o.copy(s),o.slerp(a,c),this._movement.applyRotation(o)}}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=a=>{s.set(0,0),s.lerp(t,a),this._movement.set(n,i),this._movement.orbit(s)}}target(t){const i=t.clone().sub(this._camera.position),s=this._camera.quaternion.clone(),a=new Mt().setFromUnitVectors(new U(0,0,-1),i.normalize());this.onProgress=o=>{const c=s.clone().slerp(a,o);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(),a=this._camera.target.clone();this.onProgress=o=>{this._movement.set(s.clone().lerp(t,o),a.clone().lerp(i,o))}}}class qw extends Pm{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 Qt(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 Mt().setFromEuler(t)}}class Xw{constructor(e,t){Q(this,"camPerspective");Q(this,"camOrthographic");Q(this,"_viewport");Q(this,"_lerp");Q(this,"_movement");Q(this,"_inputVelocity",new U);Q(this,"_velocity",new U);Q(this,"_speed",0);Q(this,"_orthographic",!1);Q(this,"_target",new U);Q(this,"_lastPosition",new U);Q(this,"_lastQuaternion",new Mt);Q(this,"_lastTarget",new U);Q(this,"_savedPosition",new U(0,0,-5));Q(this,"_savedTarget",new U(0,0,0));Q(this,"_onValueChanged",new ws.SignalDispatcher);Q(this,"_hasMoved");Q(this,"_onMoved",new ws.SignalDispatcher);Q(this,"_force",!1);Q(this,"_allowedMovement",new U(1,1,1));Q(this,"_allowedRotation",new he(1,1));Q(this,"_defaultForward",new U(0,0,1));Q(this,"_velocityBlendFactor",1e-4);Q(this,"_moveSpeed",1);this.camPerspective=new Hw(new kt),this.camOrthographic=new Gw(new hr),this._movement=new qw(this),this._lerp=new Ww(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=yw(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 Nu{constructor(e){Q(this,"_viewer");Q(this,"_unregisters",[]);Q(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},Zw=new Set(Object.values(At));class Yw extends Nu{constructor(){super(...arguments);Q(this,"SHIFT_MULTIPLIER",3);Q(this,"isUpPressed",!1);Q(this,"isDownPressed",!1);Q(this,"isLeftPressed",!1);Q(this,"isRightPressed",!1);Q(this,"isEPressed",!1);Q(this,"isQPressed",!1);Q(this,"isShiftPressed",!1);Q(this,"isCtrlPressed",!1);Q(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&&Zw.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 Qw extends Nu{constructor(t){super(t);Q(this,"TAP_DURATION_MS",500);Q(this,"DOUBLE_TAP_DELAY_MS",500);Q(this,"TAP_MAX_MOVE_PIXEL",5);Q(this,"ZOOM_SPEED",1);Q(this,"MOVE_SPEED",100);Q(this,"rotateSpeed",1);Q(this,"orbitSpeed",1);Q(this,"_touch");Q(this,"_touch1");Q(this,"_touch2");Q(this,"_touchStartTime");Q(this,"_lastTapMs");Q(this,"_touchStart");Q(this,"reset",()=>{this._touch=this._touch1=this._touch2=this._touchStartTime=void 0});Q(this,"onTap",t=>{const n=new Date().getTime();this._lastTapMs&&n-this._lastTapMs<this.DOUBLE_TAP_DELAY_MS,this._lastTapMs=new Date().getTime()});Q(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)});Q(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))});Q(this,"onDoubleDrag",t=>{const n=t.clone().multiplyScalar(this.MOVE_SPEED);this.camera.do().move2(n,"XY")});Q(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")});Q(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),a=this.viewport.getSize(),o=this._touch.clone().sub(s).multiply(new he(-1/a.x,-1/a.y)),c=n.distanceTo(i),l=this._touch1.distanceTo(this._touch2),h=Math.min(a.x,a.y),u=(c-l)/-h;this._touch=s,this._touch1=n,this._touch2=i,o.length()>Math.abs(u)?this.onDoubleDrag(o):this.onPinchOrSpread(u)}}});Q(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 Kw extends Nu{constructor(t){super(t);Q(this,"_idleDelayMs",150);Q(this,"zoomSpeed",1);Q(this,"panSpeed",100);Q(this,"rotateSpeed",1);Q(this,"orbitSpeed",1);Q(this,"_buttonDown");Q(this,"_hasMouseMoved",!1);Q(this,"_hasCameraMoved",!1);Q(this,"_idleTimeout");Q(this,"_idlePosition");Q(this,"_lastPosition");Q(this,"_downPosition");Q(this,"reset",()=>{this._buttonDown=void 0,this._hasMouseMoved=!1,this._lastPosition=this._downPosition=void 0,clearTimeout(this._idleTimeout)});Q(this,"onMouseOut",t=>{t.stopImmediatePropagation(),this._buttonDown=void 0,this._hasMouseMoved=!1,this._lastPosition=void 0,this.resetIdle()});Q(this,"onCameraMoved",()=>{this.resetIdle(),this._hasCameraMoved=!0});Q(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)});Q(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});Q(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(.25).zoom(i)}});Q(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(),a=new he(n/s.x,i/s.y),o=new he(t.offsetX,t.offsetY);switch(this._hasMouseMoved=this._hasMouseMoved||this._downPosition&&this._downPosition?.distanceTo(o)>4,this._buttonDown){case"main":this.onMouseMainDrag(a);break;case"middle":this.onMouseMiddleDrag(a);break;case"right":this.onMouseRightDrag(a);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 Dm={},Ms={};Object.defineProperty(Ms,"__esModule",{value:!0}),Ms.SimpleEventDispatcher=void 0;const Lm=xr;class jw extends Lm.DispatcherBase{constructor(){super()}dispatch(e){const t=this._dispatch(!1,this,arguments);if(t==null)throw new Lm.DispatchError("Got `null` back from dispatch.");return t}dispatchAsync(e){this._dispatch(!0,this,arguments)}asEvent(){return super.asEvent()}}Ms.SimpleEventDispatcher=jw;var pl={},Ea={};Object.defineProperty(Ea,"__esModule",{value:!0}),Ea.SimpleEventList=void 0;const Jw=xr,$w=Ms;class eS extends Jw.EventListBase{constructor(){super()}createDispatcher(){return new $w.SimpleEventDispatcher}}Ea.SimpleEventList=eS,Object.defineProperty(pl,"__esModule",{value:!0}),pl.SimpleEventHandlingBase=void 0;const tS=xr,nS=Ea;class iS extends tS.HandlingBase{constructor(){super(new nS.SimpleEventList)}}pl.SimpleEventHandlingBase=iS;var ml={};Object.defineProperty(ml,"__esModule",{value:!0}),ml.NonUniformSimpleEventList=void 0;const rS=Ms;class sS{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 rS.SimpleEventDispatcher}}ml.NonUniformSimpleEventList=sS,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.NonUniformSimpleEventList=r.SimpleEventList=r.SimpleEventHandlingBase=r.SimpleEventDispatcher=void 0;const e=Ms;Object.defineProperty(r,"SimpleEventDispatcher",{enumerable:!0,get:function(){return e.SimpleEventDispatcher}});const t=pl;Object.defineProperty(r,"SimpleEventHandlingBase",{enumerable:!0,get:function(){return t.SimpleEventHandlingBase}});const n=ml;Object.defineProperty(r,"NonUniformSimpleEventList",{enumerable:!0,get:function(){return n.NonUniformSimpleEventList}});const i=Ea;Object.defineProperty(r,"SimpleEventList",{enumerable:!0,get:function(){return i.SimpleEventList}})}(Dm);class Nm{constructor(e){Q(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 aS{constructor(e){Q(this,"_viewer");Q(this,"_scheme");Q(this,"touch");Q(this,"mouse");Q(this,"keyboard");Q(this,"_pointerActive","orbit");Q(this,"_pointerFallback","look");Q(this,"_pointerOverride");Q(this,"_onPointerModeChanged",new ws.SignalDispatcher);Q(this,"_onPointerOverrideChanged",new ws.SignalDispatcher);Q(this,"_onContextMenu",new Dm.SimpleEventDispatcher);Q(this,"unregisterAll",()=>{this.mouse.unregister(),this.keyboard.unregister(),this.touch.unregister()});this._viewer=e,this._scheme=new Nm(e),this.keyboard=new Yw(e),this.mouse=new Kw(e),this.touch=new Qw(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 oS{constructor(){Q(this,"mesh");Q(this,"_source");Q(this,"_size",1);Q(this,"_geometry");Q(this,"_material");Q(this,"_texture");this._geometry=new ir,this._material=new un({transparent:!0,depthTest:!0,depthWrite:!1}),this.mesh=new wt(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 Mt().setFromEuler(new Qt(1.5*Math.PI,0,0)));const s=(e?.getBoundingSphere(new Pt)?.radius??1)*this._size,a=new U(1,1,1).multiplyScalar(s);this.mesh.scale.copy(a)}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 au;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 cS{constructor(e){Q(this,"skyLight");Q(this,"sunLights");Q(this,"_groundPlane");this._groundPlane=new oS,this.skyLight=new ou,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.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;const t=e.sunLights.length;for(let n=0;n<t;n++){this.sunLights[n]||(this.sunLights[n]=new Yc);const i=e.sunLights[n].color,s=e.sunLights[n].position,a=e.sunLights[n].intensity;i&&this.sunLights[n].color.copy(i),s&&this.sunLights[n].position.copy(s),a&&(this.sunLights[n].intensity=a)}}adaptToContent(e){this._groundPlane.adaptToContent(e)}dispose(){this.sunLights.forEach(e=>e.dispose()),this.skyLight.dispose(),this._groundPlane.dispose()}}class lS{constructor(e,t,n,i){Q(this,"_renderer");Q(this,"_camera");Q(this,"_inputs");Q(this,"_size",1);Q(this,"_fov",50);Q(this,"_color",new be("blue"));Q(this,"_opacity",.2);Q(this,"_opacityAlways",.5);Q(this,"_fadeDurationMs",200);Q(this,"_showDurationMs",1e3);Q(this,"_box");Q(this,"_wireframe");Q(this,"_material");Q(this,"_materialAlways");Q(this,"_gizmos");Q(this,"_disconnectCamera");Q(this,"_timeout");Q(this,"_fadeEnd",0);Q(this,"_active",!0);Q(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=Oo.lerp(0,this._opacity,n),this._materialAlways.opacity=Oo.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 ds(1),this._wireframe=new jh(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 Es=new U,Um=new qe,Bm=new qe,Om=new U,Fm=new U;class hS{constructor(e={}){const t=this;let n,i,s,a;const o={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(m,_){m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),_.parent===null&&_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),Um.copy(_.matrixWorldInverse),Bm.multiplyMatrices(_.projectionMatrix,Um),h(m,m,_),this.sortObjects&&d(m)},this.setSize=function(m,_){n=m,i=_,s=n/2,a=i/2,c.style.width=m+"px",c.style.height=_+"px"};function l(m){m.isCSS2DObject&&(m.element.style.display="none");for(let _=0,g=m.children.length;_<g;_++)l(m.children[_])}function h(m,_,g){if(m.visible===!1){l(m);return}if(m.isCSS2DObject){Es.setFromMatrixPosition(m.matrixWorld),Es.applyMatrix4(Bm);const p=Es.z>=-1&&Es.z<=1&&m.layers.test(g.layers)===!0,v=m.element;v.style.display=p===!0?"":"none",p===!0&&(m.onBeforeRender(t,_,g),v.style.transform="translate("+-100*m.center.x+"%,"+-100*m.center.y+"%)translate("+(Es.x*s+s)+"px,"+(-Es.y*a+a)+"px)",v.parentNode!==c&&c.appendChild(v),m.onAfterRender(t,_,g));const y={distanceToCameraSquared:u(g,m)};o.objects.set(m,y)}for(let p=0,v=m.children.length;p<v;p++)h(m.children[p],_,g)}function u(m,_){return Om.setFromMatrixPosition(m.matrixWorld),Fm.setFromMatrixPosition(_.matrixWorld),Om.distanceToSquared(Fm)}function f(m){const _=[];return m.traverseVisible(function(g){g.isCSS2DObject&&_.push(g)}),_}function d(m){const _=f(m).sort(function(p,v){if(p.renderOrder!==v.renderOrder)return v.renderOrder-p.renderOrder;const y=o.objects.get(p).distanceToCameraSquared,x=o.objects.get(v).distanceToCameraSquared;return y-x}),g=_.length;for(let p=0,v=_.length;p<v;p++)_[p].element.style.zIndex=g-p}}}class Uu{constructor(e){Q(this,"canvas");Q(this,"text");Q(this,"_unregisterResize");Q(this,"_ownedCanvas");Q(this,"_onResize",new ws.SignalDispatcher);const[t,n]=Uu.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 hS;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 uS{constructor(e,t,n,i){Q(this,"renderer");Q(this,"antialias",!0);Q(this,"scene");Q(this,"viewport");Q(this,"camera");Q(this,"needsUpdate");Q(this,"_lastSize",new he);Q(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 wm({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}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,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 fS{constructor(e){Q(this,"settings");Q(this,"renderer");Q(this,"viewport");Q(this,"inputs");Q(this,"camera");Q(this,"environment");Q(this,"gizmoOrbit");Q(this,"running",!1);Q(this,"updateId",null);Q(this,"clock",new jc);Q(this,"scene",new Mh);Q(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=Tm(e),this.viewport=new Uu(this.settings),this.camera=new Xw(this.viewport,this.settings),this.renderer=new uS(this.scene,this.viewport,this.camera,this.settings),this.inputs=new aS(this),this.settings.camera.gizmo.enable&&(this.gizmoOrbit=new lS(this.renderer,this.camera,this.inputs,this.settings)),this.environment=new cS(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")}remove(e){console.log("Removing object"),this.renderer.needsUpdate=!0,this.renderer.remove(e)}clear(){this.renderer.clear()}dispose(){cancelAnimationFrame(this.updateId),this.environment.dispose(),this.gizmoOrbit.dispose(),this.viewport.dispose(),this.renderer.dispose(),this.inputs.unregisterAll()}}function zm(r,e){if(e===Vf)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===No||e===jl){let t=r.getIndex();if(t===null){const a=[],o=r.getAttribute("position");if(o!==void 0){for(let c=0;c<o.count;c++)a.push(c);r.setIndex(a),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===No)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));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 dS extends Jt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new vS(t)}),this.register(function(t){return new yS(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 AS(t)}),this.register(function(t){return new bS(t)}),this.register(function(t){return new wS(t)}),this.register(function(t){return new SS(t)}),this.register(function(t){return new _S(t)}),this.register(function(t){return new MS(t)}),this.register(function(t){return new xS(t)}),this.register(function(t){return new TS(t)}),this.register(function(t){return new ES(t)}),this.register(function(t){return new mS(t)}),this.register(function(t){return new PS(t)}),this.register(function(t){return new DS(t)})}load(e,t,n,i){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const l=Di.extractUrlBase(e);a=Di.resolveURL(l,this.path)}else a=Di.extractUrlBase(e);this.manager.itemStart(e);const o=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,a,function(h){t(h),s.manager.itemEnd(e)},o)}catch(h){o(h)}},n,o)}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 a={},o={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===km){try{a[ot.KHR_BINARY_GLTF]=new LS(e)}catch(u){i&&i(u);return}s=JSON.parse(a[ot.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 XS(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"),o[u.name]=u,a[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 ot.KHR_MATERIALS_UNLIT:a[u]=new gS;break;case ot.KHR_DRACO_MESH_COMPRESSION:a[u]=new NS(s,this.dracoLoader);break;case ot.KHR_TEXTURE_TRANSFORM:a[u]=new US;break;case ot.KHR_MESH_QUANTIZATION:a[u]=new BS;break;default:f.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function pS(){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 ot={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 mS{constructor(e){this.parser=e,this.name=ot.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 be(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 Yc(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new uu(h),l.distance=u;break;case"spot":l=new hu(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],o=(s.extensions&&s.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return n._getNodeRef(t.cache,o,c)})}}class gS{constructor(){this.name=ot.KHR_MATERIALS_UNLIT}getMaterialType(){return un}extendParams(e,t,n){const i=[];e.color=new be(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Xt),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,Tt))}return Promise.all(i)}}class _S{constructor(e){this.parser=e,this.name=ot.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 vS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new he(o,o)}return Promise.all(s)}}class yS{constructor(e){this.parser=e,this.name=ot.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 xS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(s)}}class AS{constructor(e){this.parser=e,this.name=ot.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 be(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],Xt)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,Tt)),a.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(s)}}class bS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(s)}}class wS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new be().setRGB(o[0],o[1],o[2],Xt),Promise.all(s)}}class SS{constructor(e){this.parser=e,this.name=ot.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 MS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new be().setRGB(o[0],o[1],o[2],Xt),a.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,Tt)),Promise.all(s)}}class ES{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(s)}}class TS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(s)}}class CS{constructor(e){this.parser=e,this.name=ot.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],a=t.options.ktx2Loader;if(!a){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,a)}}class IS{constructor(e){this.parser=e,this.name=ot.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 a=s.extensions[t],o=i.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}}class RS{constructor(e){this.parser=e,this.name=ot.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 a=s.extensions[t],o=i.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}}class PS{constructor(e){this.name=ot.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),a=this.parser.options.meshoptDecoder;if(!a||!a.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(o){const c=i.byteOffset||0,l=i.byteLength||0,h=i.count,u=i.byteStride,f=new Uint8Array(o,c,l);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,f,i.mode,i.filter).then(function(d){return d.buffer}):a.ready.then(function(){const d=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(d),h,u,f,i.mode,i.filter),d})})}else return null}}class DS{constructor(e){this.name=ot.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 a=n.extensions[this.name].attributes,o=[],c={};for(const l in a)o.push(this.parser.getDependency("accessor",a[l]).then(h=>(c[l]=h,c[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,d=[];for(const m of u){const _=new qe,g=new U,p=new Mt,v=new U(1,1,1),y=new pc(m.geometry,m.material,f);for(let x=0;x<f;x++)c.TRANSLATION&&g.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,x),c.SCALE&&v.fromBufferAttribute(c.SCALE,x),y.setMatrixAt(x,_.compose(g,p,v));for(const x in c)if(x==="_COLOR_0"){const w=c[x];y.instanceColor=new ji(w.array,w.itemSize,w.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&m.geometry.setAttribute(x,c[x]);ct.prototype.copy.call(y,m),this.parser.assignFinalMaterial(y),d.push(y)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}}const km="glTF",Ta=12,Vm={JSON:1313821514,BIN:5130562};class LS{constructor(e){this.name=ot.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ta),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!==km)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-Ta,s=new DataView(e,Ta);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const c=s.getUint32(a,!0);if(a+=4,c===Vm.JSON){const l=new Uint8Array(e,Ta+a,o);this.content=n.decode(l)}else if(c===Vm.BIN){const l=Ta+a;this.body=e.slice(l,l+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class NS{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ot.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,a=e.extensions[this.name].attributes,o={},c={},l={};for(const h in a){const u=Ou[h]||h.toLowerCase();o[u]=a[h]}for(const h in e.attributes){const u=Ou[h]||h.toLowerCase();if(a[h]!==void 0){const f=n.accessors[e.attributes[h]],d=Ts[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 m in d.attributes){const _=d.attributes[m],g=c[m];g!==void 0&&(_.normalized=g)}u(d)},o,l,Xt,f)})})}}class US{constructor(){this.name=ot.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 BS{constructor(){this.name=ot.KHR_MESH_QUANTIZATION}}class Hm extends ms{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 a=0;a!==i;a++)t[a]=n[s+a];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,h=i-t,u=(n-t)/h,f=u*u,d=f*u,m=e*l,_=m-l,g=-2*d+3*f,p=d-f,v=1-g,y=p-f+u;for(let x=0;x!==o;x++){const w=a[_+x+o],E=a[_+x+c]*h,I=a[m+x+o],D=a[m+x]*h;s[x]=v*w+y*E+g*I+p*D}return s}}const OS=new Mt;class FS extends Hm{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return OS.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},Ts={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Gm={9728:St,9729:pt,9984:Xa,9985:Lr,9986:Vi,9987:Mn},Wm={33071:tn,33648:Dr,10497:vi},Bu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ou={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"},Ui={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},zS={CUBICSPLINE:void 0,LINEAR:Or,STEP:Br},Fu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kS(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new ps({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Wn})),r.DefaultMaterial}function br(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 VS(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 a=[],o=[],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;a.push(f)}if(i){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;o.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(a),Promise.all(o),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 HS(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 GS(r){let e;const t=r.extensions&&r.extensions[ot.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+zu(t.attributes):e=r.indices+":"+zu(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+zu(r.targets[n]);return e}function zu(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 ku(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 WS(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 qS=new qe;class XS{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new pS,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,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const c=o.match(/Version\/(\d+)/);i=n&&c?parseInt(c[1],10):-1,s=o.indexOf("Firefox")>-1,a=s?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&a<98?this.textureLoader=new au(this.options.manager):this.textureLoader=new Rp(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(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return br(s,o,i),ti(o,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(const c of o.scenes)c.updateMatrixWorld();e(o)})}).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 a=t[i].joints;for(let o=0,c=a.length;o<c;o++)e[a[o]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.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=(a,o)=>{const c=this.associations.get(a);c!=null&&this.associations.set(o,c);for(const[l,h]of a.children.entries())s(h,o.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,a){return n.getDependency(e,a)})),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[ot.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,a){n.load(Di.resolveURL(t.uri,i.path),s,void 0,function(){a(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 a=Bu[i.type],o=Ts[i.componentType],c=i.normalized===!0,l=new o(i.count*a);return Promise.resolve(new at(l,a,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(a){const o=a[0],c=Bu[i.type],l=Ts[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,m=i.normalized===!0;let _,g;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(o,p*d,i.count*d/h),y=new rs(_,d/h),t.cache.add(v,y)),g=new fi(y,c,f%d/h,m)}else o===null?_=new l(i.count*c):_=new l(o,f,i.count*c),g=new at(_,c,m);if(i.sparse!==void 0){const p=Bu.SCALAR,v=Ts[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,w=new v(a[1],y,i.sparse.count*p),E=new l(a[2],x,i.sparse.count*c);o!==null&&(g=new at(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let I=0,D=w.length;I<D;I++){const b=w[I];if(g.setX(b,E[I*c]),c>=2&&g.setY(b,E[I*c+1]),c>=3&&g.setZ(b,E[I*c+2]),c>=4&&g.setW(b,E[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,a=t.images[s];let o=this.textureLoader;if(a.uri){const c=n.manager.getHandler(a.uri);c!==null&&(o=c)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,a=s.textures[e],o=s.images[t],c=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const f=(s.samplers||{})[a.sampler]||{};return h.magFilter=Gm[f.magFilter]||pt,h.minFilter=Gm[f.minFilter]||Mn,h.wrapS=Wm[f.wrapS]||vi,h.wrapT=Wm[f.wrapT]||vi,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==St&&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 a=i.images[e],o=self.URL||self.webkitURL;let c=a.uri||"",l=!1;if(a.bufferView!==void 0)c=n.getDependency("bufferView",a.bufferView).then(function(u){l=!0;const f=new Blob([u],{type:a.mimeType});return c=o.createObjectURL(f),c});else if(a.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 m=f;t.isImageBitmapLoader===!0&&(m=function(_){const g=new xt(_);g.needsUpdate=!0,f(g)}),t.load(Di.resolveURL(u,s.path),m,void 0,d)})}).then(function(u){return l===!0&&o.revokeObjectURL(c),ti(u,a),u.userData.mimeType=a.mimeType||WS(a.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(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),s.extensions[ot.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[ot.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=s.associations.get(a);a=s.extensions[ot.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,c)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new wc,zt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new qt,zt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(o,c)),n=c}if(i||s||a){let o="ClonedMaterial:"+n.uuid+":";i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),s&&(c.vertexColors=!0),a&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return ps}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let a;const o={},c=s.extensions||{},l=[];if(c[ot.KHR_MATERIALS_UNLIT]){const u=i[ot.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),l.push(u.extendParams(o,s,t))}else{const u=s.pbrMetallicRoughness||{};if(o.color=new be(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],Xt),o.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",u.baseColorTexture,Tt)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=Sn);const h=s.alphaMode||Fu.OPAQUE;if(h===Fu.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Fu.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==un&&(l.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new he(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;o.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&a!==un&&(l.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==un){const u=s.emissiveFactor;o.emissive=new be().setRGB(u[0],u[1],u[2],Xt)}return s.emissiveTexture!==void 0&&a!==un&&l.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,Tt)),Promise.all(l).then(function(){const u=new a(o);return s.name&&(u.name=s.name),ti(u,s),t.associations.set(u,{materials:e}),s.extensions&&br(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(o){return n[ot.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return qm(c,o,t)})}const a=[];for(let o=0,c=e.length;o<c;o++){const l=e[o],h=GS(l),u=i[h];if(u)a.push(u.promise);else{let f;l.extensions&&l.extensions[ot.KHR_DRACO_MESH_COMPRESSION]?f=s(l):f=qm(new Ke,l,t),i[h]={primitive:l,promise:f},a.push(f)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],a=s.primitives,o=[];for(let c=0,l=a.length;c<l;c++){const h=a[c].material===void 0?kS(this.cache):this.getDependency("material",a[c].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let d=0,m=h.length;d<m;d++){const _=h[d],g=a[d];let p;const v=l[d];if(g.mode===Dn.TRIANGLES||g.mode===Dn.TRIANGLE_STRIP||g.mode===Dn.TRIANGLE_FAN||g.mode===void 0)p=s.isSkinnedMesh===!0?new Rh(_,v):new wt(_,v),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===Dn.TRIANGLE_STRIP?p.geometry=zm(p.geometry,jl):g.mode===Dn.TRIANGLE_FAN&&(p.geometry=zm(p.geometry,No));else if(g.mode===Dn.LINES)p=new In(_,v);else if(g.mode===Dn.LINE_STRIP)p=new di(_,v);else if(g.mode===Dn.LINE_LOOP)p=new Uh(_,v);else if(g.mode===Dn.POINTS)p=new Oh(_,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&HS(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),ti(p,s),g.extensions&&br(i,p,g),t.assignFinalMaterial(p),u.push(p)}for(let d=0,m=u.length;d<m;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return s.extensions&&br(i,u[0],s),u[0];const f=new Kn;s.extensions&&br(i,f,s),t.associations.set(f,{meshes:e});for(let d=0,m=u.length;d<m;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(Oo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new hr(-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(),a=i,o=[],c=[];for(let l=0,h=a.length;l<h;l++){const u=a[l];if(u){o.push(u);const f=new qe;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 ta(o,c)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,a=[],o=[],c=[],l=[],h=[];for(let u=0,f=i.channels.length;u<f;u++){const d=i.channels[u],m=i.samplers[d.sampler],_=d.target,g=_.node,p=i.parameters!==void 0?i.parameters[m.input]:m.input,v=i.parameters!==void 0?i.parameters[m.output]:m.output;_.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",v)),l.push(m),h.push(_))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const f=u[0],d=u[1],m=u[2],_=u[3],g=u[4],p=[];for(let y=0,x=f.length;y<x;y++){const w=f[y],E=d[y],I=m[y],D=_[y],b=g[y];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const C=n._createAnimationTracks(w,E,I,D,b);if(C)for(let B=0;B<C.length;B++)p.push(C[B])}const v=new gs(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 a=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&a.traverse(function(o){if(!!o.isMesh)for(let c=0,l=i.weights.length;c<l;c++)o.morphTargetInfluences[c]=i.weights[c]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),a=[],o=i.children||[];for(let l=0,h=o.length;l<h;l++)a.push(n.getDependency("node",o[l]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(a),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,qS)});for(let d=0,m=u.length;d<m;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],a=s.name?i.createUniqueName(s.name):"",o=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&o.push(c),s.camera!==void 0&&o.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){o.push(l)}),this.nodeCache[e]=Promise.all(o).then(function(l){let h;if(s.isBone===!0?h=new fc: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=a),ti(h,s),s.extensions&&br(n,h,s),s.matrix!==void 0){const u=new qe;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&&br(t,s,n);const a=n.nodes||[],o=[];for(let c=0,l=a.length;c<l;c++)o.push(i.getDependency("node",a[c]));return Promise.all(o).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 a=[],o=e.name?e.name:e.uuid,c=[];Ui[s.path]===Ui.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(o);let l;switch(Ui[s.path]){case Ui.weights:l=ar;break;case Ui.rotation:l=or;break;case Ui.translation:case Ui.scale:l=lr;break;default:switch(n.itemSize){case 1:l=ar;break;case 2:case 3:default:l=lr;break}break}const h=i.interpolation!==void 0?zS[i.interpolation]:Or,u=this._getArrayFromAccessor(n);for(let f=0,d=c.length;f<d;f++){const m=new l(c[f]+"."+Ui[s.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),a.push(m)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=ku(t.constructor),i=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof or?FS:Hm;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ZS(r,e,t){const n=e.attributes,i=new Gt;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],c=o.min,l=o.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])),o.normalized){const h=ku(Ts[o.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 o=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,m=f.max;if(d!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(m[2]))),f.normalized){const _=ku(Ts[f.componentType]);c.multiplyScalar(_)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}r.boundingBox=i;const a=new Pt;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=a}function qm(r,e,t){const n=e.attributes,i=[];function s(a,o){return t.getDependency("accessor",a).then(function(c){r.setAttribute(o,c)})}for(const a in n){const o=Ou[a]||a.toLowerCase();o in r.attributes||i.push(s(n[a],o))}if(e.indices!==void 0&&!r.index){const a=t.getDependency("accessor",e.indices).then(function(o){r.setIndex(o)});i.push(a)}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),ZS(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?VS(r,e.targets,t):r})}const Vu=new WeakMap;class YS 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,a=>{this.parse(a,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,a=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Vu.has(e)){const c=Vu.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++,a=e.byteLength,o=this._getWorker(s,a).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 o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Vu.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Ke;e.index&&t.setIndex(new at(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:a,stride:o,vertexColorSpace:c}=e.attributes[n];let l;if(a===o)l=new at(s,a);else{const h=new rs(s,o);l=new fi(h,a,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 be;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=QS.toString(),a=["/* 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=xa;Object.defineProperty(r,"SignalDispatcher",{enumerable:!0,get:function(){return e.SignalDispatcher}});const t=dl;Object.defineProperty(r,"SignalHandlingBase",{enumerable:!0,get:function(){return t.SignalHandlingBase}});const n=Ma;Object.defineProperty(r,"SignalList",{enumerable:!0,get:function(){return n.SignalList}})}(ws);class Hw{constructor(e){Q(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 Gw{constructor(e){Q(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 Pm{constructor(e){Q(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),a=Math.asin(e.y)-Math.asin(t.y),o=new he(a,s);o.multiplyScalar(180/Math.PI),this.orbit(o)}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 Ww extends Pm{constructor(t,n){super(t);Q(this,"_movement");Q(this,"_clock",new jc);Q(this,"onProgress");Q(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),a=new U;this.onProgress=o=>{a.copy(i),a.lerp(s,o),this._movement.move3(a)}}rotate(t){const n=new Qt(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(),a=new Mt().setFromEuler(n),o=new Mt;this.onProgress=c=>{o.copy(s),o.slerp(a,c),this._movement.applyRotation(o)}}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=a=>{s.set(0,0),s.lerp(t,a),this._movement.set(n,i),this._movement.orbit(s)}}target(t){const i=t.clone().sub(this._camera.position),s=this._camera.quaternion.clone(),a=new Mt().setFromUnitVectors(new U(0,0,-1),i.normalize());this.onProgress=o=>{const c=s.clone().slerp(a,o);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(),a=this._camera.target.clone();this.onProgress=o=>{this._movement.set(s.clone().lerp(t,o),a.clone().lerp(i,o))}}}class qw extends Pm{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 Qt(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 Mt().setFromEuler(t)}}class Xw{constructor(e,t){Q(this,"camPerspective");Q(this,"camOrthographic");Q(this,"_viewport");Q(this,"_lerp");Q(this,"_movement");Q(this,"_inputVelocity",new U);Q(this,"_velocity",new U);Q(this,"_speed",0);Q(this,"_orthographic",!1);Q(this,"_target",new U);Q(this,"_lastPosition",new U);Q(this,"_lastQuaternion",new Mt);Q(this,"_lastTarget",new U);Q(this,"_savedPosition",new U(0,0,-5));Q(this,"_savedTarget",new U(0,0,0));Q(this,"_onValueChanged",new ws.SignalDispatcher);Q(this,"_hasMoved");Q(this,"_onMoved",new ws.SignalDispatcher);Q(this,"_force",!1);Q(this,"_allowedMovement",new U(1,1,1));Q(this,"_allowedRotation",new he(1,1));Q(this,"_defaultForward",new U(0,0,1));Q(this,"_velocityBlendFactor",1e-4);Q(this,"_moveSpeed",1);this.camPerspective=new Hw(new kt),this.camOrthographic=new Gw(new hr),this._movement=new qw(this),this._lerp=new Ww(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=yw(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 Nu{constructor(e){Q(this,"_viewer");Q(this,"_unregisters",[]);Q(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},Zw=new Set(Object.values(At));class Yw extends Nu{constructor(){super(...arguments);Q(this,"SHIFT_MULTIPLIER",3);Q(this,"isUpPressed",!1);Q(this,"isDownPressed",!1);Q(this,"isLeftPressed",!1);Q(this,"isRightPressed",!1);Q(this,"isEPressed",!1);Q(this,"isQPressed",!1);Q(this,"isShiftPressed",!1);Q(this,"isCtrlPressed",!1);Q(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&&Zw.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 Qw extends Nu{constructor(t){super(t);Q(this,"TAP_DURATION_MS",500);Q(this,"DOUBLE_TAP_DELAY_MS",500);Q(this,"TAP_MAX_MOVE_PIXEL",5);Q(this,"ZOOM_SPEED",1);Q(this,"MOVE_SPEED",100);Q(this,"rotateSpeed",1);Q(this,"orbitSpeed",1);Q(this,"_touch");Q(this,"_touch1");Q(this,"_touch2");Q(this,"_touchStartTime");Q(this,"_lastTapMs");Q(this,"_touchStart");Q(this,"reset",()=>{this._touch=this._touch1=this._touch2=this._touchStartTime=void 0});Q(this,"onTap",t=>{const n=new Date().getTime();this._lastTapMs&&n-this._lastTapMs<this.DOUBLE_TAP_DELAY_MS,this._lastTapMs=new Date().getTime()});Q(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)});Q(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))});Q(this,"onDoubleDrag",t=>{const n=t.clone().multiplyScalar(this.MOVE_SPEED);this.camera.do().move2(n,"XY")});Q(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")});Q(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),a=this.viewport.getSize(),o=this._touch.clone().sub(s).multiply(new he(-1/a.x,-1/a.y)),c=n.distanceTo(i),l=this._touch1.distanceTo(this._touch2),h=Math.min(a.x,a.y),u=(c-l)/-h;this._touch=s,this._touch1=n,this._touch2=i,o.length()>Math.abs(u)?this.onDoubleDrag(o):this.onPinchOrSpread(u)}}});Q(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 Kw extends Nu{constructor(t){super(t);Q(this,"_idleDelayMs",150);Q(this,"zoomSpeed",1);Q(this,"panSpeed",1);Q(this,"rotateSpeed",1);Q(this,"orbitSpeed",1);Q(this,"_buttonDown");Q(this,"_hasMouseMoved",!1);Q(this,"_hasCameraMoved",!1);Q(this,"_idleTimeout");Q(this,"_idlePosition");Q(this,"_lastPosition");Q(this,"_downPosition");Q(this,"reset",()=>{this._buttonDown=void 0,this._hasMouseMoved=!1,this._lastPosition=this._downPosition=void 0,clearTimeout(this._idleTimeout)});Q(this,"onMouseOut",t=>{t.stopImmediatePropagation(),this._buttonDown=void 0,this._hasMouseMoved=!1,this._lastPosition=void 0,this.resetIdle()});Q(this,"onCameraMoved",()=>{this.resetIdle(),this._hasCameraMoved=!0});Q(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)});Q(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});Q(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(.25).zoom(i)}});Q(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(),a=new he(n/s.x,i/s.y),o=new he(t.offsetX,t.offsetY);switch(this._hasMouseMoved=this._hasMouseMoved||this._downPosition&&this._downPosition?.distanceTo(o)>4,this._buttonDown){case"main":this.onMouseMainDrag(a);break;case"middle":this.onMouseMiddleDrag(a);break;case"right":this.onMouseRightDrag(a);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(this.toPanDelta(t).multiplyScalar(this.panSpeed),"XY");break;case"zoom":this.camera.do().zoom(1+t.y*this.zoomSpeed);break}}onMouseMiddleDrag(t){this.camera.do().move2(this.toPanDelta(t).multiplyScalar(this.panSpeed),"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"}toPanDelta(t){const n=this.viewport.getSize(),i=n.y===0?1:n.y,s=n.x/i,o=this.camera.frustrumSizeAt(this.camera.target).y*2,c=o*s;return new he(t.x*c,t.y*o)}}var Dm={},Ms={};Object.defineProperty(Ms,"__esModule",{value:!0}),Ms.SimpleEventDispatcher=void 0;const Lm=xr;class jw extends Lm.DispatcherBase{constructor(){super()}dispatch(e){const t=this._dispatch(!1,this,arguments);if(t==null)throw new Lm.DispatchError("Got `null` back from dispatch.");return t}dispatchAsync(e){this._dispatch(!0,this,arguments)}asEvent(){return super.asEvent()}}Ms.SimpleEventDispatcher=jw;var pl={},Ea={};Object.defineProperty(Ea,"__esModule",{value:!0}),Ea.SimpleEventList=void 0;const Jw=xr,$w=Ms;class eS extends Jw.EventListBase{constructor(){super()}createDispatcher(){return new $w.SimpleEventDispatcher}}Ea.SimpleEventList=eS,Object.defineProperty(pl,"__esModule",{value:!0}),pl.SimpleEventHandlingBase=void 0;const tS=xr,nS=Ea;class iS extends tS.HandlingBase{constructor(){super(new nS.SimpleEventList)}}pl.SimpleEventHandlingBase=iS;var ml={};Object.defineProperty(ml,"__esModule",{value:!0}),ml.NonUniformSimpleEventList=void 0;const rS=Ms;class sS{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 rS.SimpleEventDispatcher}}ml.NonUniformSimpleEventList=sS,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.NonUniformSimpleEventList=r.SimpleEventList=r.SimpleEventHandlingBase=r.SimpleEventDispatcher=void 0;const e=Ms;Object.defineProperty(r,"SimpleEventDispatcher",{enumerable:!0,get:function(){return e.SimpleEventDispatcher}});const t=pl;Object.defineProperty(r,"SimpleEventHandlingBase",{enumerable:!0,get:function(){return t.SimpleEventHandlingBase}});const n=ml;Object.defineProperty(r,"NonUniformSimpleEventList",{enumerable:!0,get:function(){return n.NonUniformSimpleEventList}});const i=Ea;Object.defineProperty(r,"SimpleEventList",{enumerable:!0,get:function(){return i.SimpleEventList}})}(Dm);class Nm{constructor(e){Q(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 aS{constructor(e){Q(this,"_viewer");Q(this,"_scheme");Q(this,"touch");Q(this,"mouse");Q(this,"keyboard");Q(this,"_pointerActive","orbit");Q(this,"_pointerFallback","look");Q(this,"_pointerOverride");Q(this,"_onPointerModeChanged",new ws.SignalDispatcher);Q(this,"_onPointerOverrideChanged",new ws.SignalDispatcher);Q(this,"_onContextMenu",new Dm.SimpleEventDispatcher);Q(this,"unregisterAll",()=>{this.mouse.unregister(),this.keyboard.unregister(),this.touch.unregister()});this._viewer=e,this._scheme=new Nm(e),this.keyboard=new Yw(e),this.mouse=new Kw(e),this.touch=new Qw(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 oS{constructor(){Q(this,"mesh");Q(this,"_source");Q(this,"_size",1);Q(this,"_geometry");Q(this,"_material");Q(this,"_texture");this._geometry=new ir,this._material=new un({transparent:!0,depthTest:!0,depthWrite:!1}),this.mesh=new wt(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 Mt().setFromEuler(new Qt(1.5*Math.PI,0,0)));const s=(e?.getBoundingSphere(new Pt)?.radius??1)*this._size,a=new U(1,1,1).multiplyScalar(s);this.mesh.scale.copy(a)}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 au;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 cS{constructor(e){Q(this,"skyLight");Q(this,"sunLights");Q(this,"_groundPlane");this._groundPlane=new oS,this.skyLight=new ou,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.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;const t=e.sunLights.length;for(let n=0;n<t;n++){this.sunLights[n]||(this.sunLights[n]=new Yc);const i=e.sunLights[n].color,s=e.sunLights[n].position,a=e.sunLights[n].intensity;i&&this.sunLights[n].color.copy(i),s&&this.sunLights[n].position.copy(s),a&&(this.sunLights[n].intensity=a)}}adaptToContent(e){this._groundPlane.adaptToContent(e)}dispose(){this.sunLights.forEach(e=>e.dispose()),this.skyLight.dispose(),this._groundPlane.dispose()}}class lS{constructor(e,t,n,i){Q(this,"_renderer");Q(this,"_camera");Q(this,"_inputs");Q(this,"_size",1);Q(this,"_fov",50);Q(this,"_color",new be("blue"));Q(this,"_opacity",.2);Q(this,"_opacityAlways",.5);Q(this,"_fadeDurationMs",200);Q(this,"_showDurationMs",1e3);Q(this,"_box");Q(this,"_wireframe");Q(this,"_material");Q(this,"_materialAlways");Q(this,"_gizmos");Q(this,"_disconnectCamera");Q(this,"_timeout");Q(this,"_fadeEnd",0);Q(this,"_active",!0);Q(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=Oo.lerp(0,this._opacity,n),this._materialAlways.opacity=Oo.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 ds(1),this._wireframe=new jh(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 Es=new U,Um=new qe,Bm=new qe,Om=new U,Fm=new U;class hS{constructor(e={}){const t=this;let n,i,s,a;const o={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(m,_){m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),_.parent===null&&_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),Um.copy(_.matrixWorldInverse),Bm.multiplyMatrices(_.projectionMatrix,Um),h(m,m,_),this.sortObjects&&d(m)},this.setSize=function(m,_){n=m,i=_,s=n/2,a=i/2,c.style.width=m+"px",c.style.height=_+"px"};function l(m){m.isCSS2DObject&&(m.element.style.display="none");for(let _=0,g=m.children.length;_<g;_++)l(m.children[_])}function h(m,_,g){if(m.visible===!1){l(m);return}if(m.isCSS2DObject){Es.setFromMatrixPosition(m.matrixWorld),Es.applyMatrix4(Bm);const p=Es.z>=-1&&Es.z<=1&&m.layers.test(g.layers)===!0,v=m.element;v.style.display=p===!0?"":"none",p===!0&&(m.onBeforeRender(t,_,g),v.style.transform="translate("+-100*m.center.x+"%,"+-100*m.center.y+"%)translate("+(Es.x*s+s)+"px,"+(-Es.y*a+a)+"px)",v.parentNode!==c&&c.appendChild(v),m.onAfterRender(t,_,g));const y={distanceToCameraSquared:u(g,m)};o.objects.set(m,y)}for(let p=0,v=m.children.length;p<v;p++)h(m.children[p],_,g)}function u(m,_){return Om.setFromMatrixPosition(m.matrixWorld),Fm.setFromMatrixPosition(_.matrixWorld),Om.distanceToSquared(Fm)}function f(m){const _=[];return m.traverseVisible(function(g){g.isCSS2DObject&&_.push(g)}),_}function d(m){const _=f(m).sort(function(p,v){if(p.renderOrder!==v.renderOrder)return v.renderOrder-p.renderOrder;const y=o.objects.get(p).distanceToCameraSquared,x=o.objects.get(v).distanceToCameraSquared;return y-x}),g=_.length;for(let p=0,v=_.length;p<v;p++)_[p].element.style.zIndex=g-p}}}class Uu{constructor(e){Q(this,"canvas");Q(this,"text");Q(this,"_unregisterResize");Q(this,"_ownedCanvas");Q(this,"_onResize",new ws.SignalDispatcher);const[t,n]=Uu.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 hS;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 uS{constructor(e,t,n,i){Q(this,"renderer");Q(this,"antialias",!0);Q(this,"scene");Q(this,"viewport");Q(this,"camera");Q(this,"needsUpdate");Q(this,"_lastSize",new he);Q(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 wm({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}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,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 fS{constructor(e){Q(this,"settings");Q(this,"renderer");Q(this,"viewport");Q(this,"inputs");Q(this,"camera");Q(this,"environment");Q(this,"gizmoOrbit");Q(this,"running",!1);Q(this,"updateId",null);Q(this,"clock",new jc);Q(this,"scene",new Mh);Q(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=Tm(e),this.viewport=new Uu(this.settings),this.camera=new Xw(this.viewport,this.settings),this.renderer=new uS(this.scene,this.viewport,this.camera,this.settings),this.inputs=new aS(this),this.settings.camera.gizmo.enable&&(this.gizmoOrbit=new lS(this.renderer,this.camera,this.inputs,this.settings)),this.environment=new cS(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")}remove(e){console.log("Removing object"),this.renderer.needsUpdate=!0,this.renderer.remove(e)}clear(){this.renderer.clear()}dispose(){cancelAnimationFrame(this.updateId),this.environment.dispose(),this.gizmoOrbit.dispose(),this.viewport.dispose(),this.renderer.dispose(),this.inputs.unregisterAll()}}function zm(r,e){if(e===Vf)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===No||e===jl){let t=r.getIndex();if(t===null){const a=[],o=r.getAttribute("position");if(o!==void 0){for(let c=0;c<o.count;c++)a.push(c);r.setIndex(a),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===No)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));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 dS extends Jt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new vS(t)}),this.register(function(t){return new yS(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 AS(t)}),this.register(function(t){return new bS(t)}),this.register(function(t){return new wS(t)}),this.register(function(t){return new SS(t)}),this.register(function(t){return new _S(t)}),this.register(function(t){return new MS(t)}),this.register(function(t){return new xS(t)}),this.register(function(t){return new TS(t)}),this.register(function(t){return new ES(t)}),this.register(function(t){return new mS(t)}),this.register(function(t){return new PS(t)}),this.register(function(t){return new DS(t)})}load(e,t,n,i){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const l=Di.extractUrlBase(e);a=Di.resolveURL(l,this.path)}else a=Di.extractUrlBase(e);this.manager.itemStart(e);const o=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,a,function(h){t(h),s.manager.itemEnd(e)},o)}catch(h){o(h)}},n,o)}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 a={},o={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===km){try{a[ot.KHR_BINARY_GLTF]=new LS(e)}catch(u){i&&i(u);return}s=JSON.parse(a[ot.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 XS(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"),o[u.name]=u,a[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 ot.KHR_MATERIALS_UNLIT:a[u]=new gS;break;case ot.KHR_DRACO_MESH_COMPRESSION:a[u]=new NS(s,this.dracoLoader);break;case ot.KHR_TEXTURE_TRANSFORM:a[u]=new US;break;case ot.KHR_MESH_QUANTIZATION:a[u]=new BS;break;default:f.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function pS(){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 ot={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 mS{constructor(e){this.parser=e,this.name=ot.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 be(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 Yc(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new uu(h),l.distance=u;break;case"spot":l=new hu(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],o=(s.extensions&&s.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return n._getNodeRef(t.cache,o,c)})}}class gS{constructor(){this.name=ot.KHR_MATERIALS_UNLIT}getMaterialType(){return un}extendParams(e,t,n){const i=[];e.color=new be(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Xt),e.opacity=a[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,Tt))}return Promise.all(i)}}class _S{constructor(e){this.parser=e,this.name=ot.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 vS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new he(o,o)}return Promise.all(s)}}class yS{constructor(e){this.parser=e,this.name=ot.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 xS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(s)}}class AS{constructor(e){this.parser=e,this.name=ot.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 be(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],Xt)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,Tt)),a.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(s)}}class bS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(s)}}class wS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new be().setRGB(o[0],o[1],o[2],Xt),Promise.all(s)}}class SS{constructor(e){this.parser=e,this.name=ot.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 MS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new be().setRGB(o[0],o[1],o[2],Xt),a.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,Tt)),Promise.all(s)}}class ES{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(s)}}class TS{constructor(e){this.parser=e,this.name=ot.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=[],a=i.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(s)}}class CS{constructor(e){this.parser=e,this.name=ot.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],a=t.options.ktx2Loader;if(!a){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,a)}}class IS{constructor(e){this.parser=e,this.name=ot.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 a=s.extensions[t],o=i.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}}class RS{constructor(e){this.parser=e,this.name=ot.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 a=s.extensions[t],o=i.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}}class PS{constructor(e){this.name=ot.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),a=this.parser.options.meshoptDecoder;if(!a||!a.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(o){const c=i.byteOffset||0,l=i.byteLength||0,h=i.count,u=i.byteStride,f=new Uint8Array(o,c,l);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,f,i.mode,i.filter).then(function(d){return d.buffer}):a.ready.then(function(){const d=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(d),h,u,f,i.mode,i.filter),d})})}else return null}}class DS{constructor(e){this.name=ot.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 a=n.extensions[this.name].attributes,o=[],c={};for(const l in a)o.push(this.parser.getDependency("accessor",a[l]).then(h=>(c[l]=h,c[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,d=[];for(const m of u){const _=new qe,g=new U,p=new Mt,v=new U(1,1,1),y=new pc(m.geometry,m.material,f);for(let x=0;x<f;x++)c.TRANSLATION&&g.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,x),c.SCALE&&v.fromBufferAttribute(c.SCALE,x),y.setMatrixAt(x,_.compose(g,p,v));for(const x in c)if(x==="_COLOR_0"){const w=c[x];y.instanceColor=new ji(w.array,w.itemSize,w.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&m.geometry.setAttribute(x,c[x]);ct.prototype.copy.call(y,m),this.parser.assignFinalMaterial(y),d.push(y)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}}const km="glTF",Ta=12,Vm={JSON:1313821514,BIN:5130562};class LS{constructor(e){this.name=ot.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ta),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!==km)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-Ta,s=new DataView(e,Ta);let a=0;for(;a<i;){const o=s.getUint32(a,!0);a+=4;const c=s.getUint32(a,!0);if(a+=4,c===Vm.JSON){const l=new Uint8Array(e,Ta+a,o);this.content=n.decode(l)}else if(c===Vm.BIN){const l=Ta+a;this.body=e.slice(l,l+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class NS{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ot.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,a=e.extensions[this.name].attributes,o={},c={},l={};for(const h in a){const u=Ou[h]||h.toLowerCase();o[u]=a[h]}for(const h in e.attributes){const u=Ou[h]||h.toLowerCase();if(a[h]!==void 0){const f=n.accessors[e.attributes[h]],d=Ts[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 m in d.attributes){const _=d.attributes[m],g=c[m];g!==void 0&&(_.normalized=g)}u(d)},o,l,Xt,f)})})}}class US{constructor(){this.name=ot.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 BS{constructor(){this.name=ot.KHR_MESH_QUANTIZATION}}class Hm extends ms{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 a=0;a!==i;a++)t[a]=n[s+a];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,h=i-t,u=(n-t)/h,f=u*u,d=f*u,m=e*l,_=m-l,g=-2*d+3*f,p=d-f,v=1-g,y=p-f+u;for(let x=0;x!==o;x++){const w=a[_+x+o],E=a[_+x+c]*h,I=a[m+x+o],D=a[m+x]*h;s[x]=v*w+y*E+g*I+p*D}return s}}const OS=new Mt;class FS extends Hm{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return OS.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},Ts={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Gm={9728:St,9729:pt,9984:Xa,9985:Lr,9986:Vi,9987:Mn},Wm={33071:tn,33648:Dr,10497:vi},Bu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ou={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"},Ui={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},zS={CUBICSPLINE:void 0,LINEAR:Or,STEP:Br},Fu={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kS(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new ps({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Wn})),r.DefaultMaterial}function br(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 VS(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 a=[],o=[],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;a.push(f)}if(i){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;o.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(a),Promise.all(o),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 HS(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 GS(r){let e;const t=r.extensions&&r.extensions[ot.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+zu(t.attributes):e=r.indices+":"+zu(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+zu(r.targets[n]);return e}function zu(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 ku(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 WS(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 qS=new qe;class XS{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new pS,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,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const c=o.match(/Version\/(\d+)/);i=n&&c?parseInt(c[1],10):-1,s=o.indexOf("Firefox")>-1,a=s?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&a<98?this.textureLoader=new au(this.options.manager):this.textureLoader=new Rp(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(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return br(s,o,i),ti(o,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(const c of o.scenes)c.updateMatrixWorld();e(o)})}).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 a=t[i].joints;for(let o=0,c=a.length;o<c;o++)e[a[o]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.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=(a,o)=>{const c=this.associations.get(a);c!=null&&this.associations.set(o,c);for(const[l,h]of a.children.entries())s(h,o.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,a){return n.getDependency(e,a)})),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[ot.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,a){n.load(Di.resolveURL(t.uri,i.path),s,void 0,function(){a(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 a=Bu[i.type],o=Ts[i.componentType],c=i.normalized===!0,l=new o(i.count*a);return Promise.resolve(new at(l,a,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(a){const o=a[0],c=Bu[i.type],l=Ts[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,m=i.normalized===!0;let _,g;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(o,p*d,i.count*d/h),y=new rs(_,d/h),t.cache.add(v,y)),g=new fi(y,c,f%d/h,m)}else o===null?_=new l(i.count*c):_=new l(o,f,i.count*c),g=new at(_,c,m);if(i.sparse!==void 0){const p=Bu.SCALAR,v=Ts[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,w=new v(a[1],y,i.sparse.count*p),E=new l(a[2],x,i.sparse.count*c);o!==null&&(g=new at(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let I=0,D=w.length;I<D;I++){const b=w[I];if(g.setX(b,E[I*c]),c>=2&&g.setY(b,E[I*c+1]),c>=3&&g.setZ(b,E[I*c+2]),c>=4&&g.setW(b,E[I*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,a=t.images[s];let o=this.textureLoader;if(a.uri){const c=n.manager.getHandler(a.uri);c!==null&&(o=c)}return this.loadTextureImage(e,s,o)}loadTextureImage(e,t,n){const i=this,s=this.json,a=s.textures[e],o=s.images[t],c=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const f=(s.samplers||{})[a.sampler]||{};return h.magFilter=Gm[f.magFilter]||pt,h.minFilter=Gm[f.minFilter]||Mn,h.wrapS=Wm[f.wrapS]||vi,h.wrapT=Wm[f.wrapT]||vi,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==St&&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 a=i.images[e],o=self.URL||self.webkitURL;let c=a.uri||"",l=!1;if(a.bufferView!==void 0)c=n.getDependency("bufferView",a.bufferView).then(function(u){l=!0;const f=new Blob([u],{type:a.mimeType});return c=o.createObjectURL(f),c});else if(a.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 m=f;t.isImageBitmapLoader===!0&&(m=function(_){const g=new xt(_);g.needsUpdate=!0,f(g)}),t.load(Di.resolveURL(u,s.path),m,void 0,d)})}).then(function(u){return l===!0&&o.revokeObjectURL(c),ti(u,a),u.userData.mimeType=a.mimeType||WS(a.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(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),s.extensions[ot.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[ot.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=s.associations.get(a);a=s.extensions[ot.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,c)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new wc,zt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new qt,zt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(o,c)),n=c}if(i||s||a){let o="ClonedMaterial:"+n.uuid+":";i&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),s&&(c.vertexColors=!0),a&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return ps}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let a;const o={},c=s.extensions||{},l=[];if(c[ot.KHR_MATERIALS_UNLIT]){const u=i[ot.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),l.push(u.extendParams(o,s,t))}else{const u=s.pbrMetallicRoughness||{};if(o.color=new be(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;o.color.setRGB(f[0],f[1],f[2],Xt),o.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",u.baseColorTexture,Tt)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=Sn);const h=s.alphaMode||Fu.OPAQUE;if(h===Fu.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Fu.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==un&&(l.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new he(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;o.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&a!==un&&(l.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==un){const u=s.emissiveFactor;o.emissive=new be().setRGB(u[0],u[1],u[2],Xt)}return s.emissiveTexture!==void 0&&a!==un&&l.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,Tt)),Promise.all(l).then(function(){const u=new a(o);return s.name&&(u.name=s.name),ti(u,s),t.associations.set(u,{materials:e}),s.extensions&&br(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(o){return n[ot.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return qm(c,o,t)})}const a=[];for(let o=0,c=e.length;o<c;o++){const l=e[o],h=GS(l),u=i[h];if(u)a.push(u.promise);else{let f;l.extensions&&l.extensions[ot.KHR_DRACO_MESH_COMPRESSION]?f=s(l):f=qm(new Ke,l,t),i[h]={primitive:l,promise:f},a.push(f)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],a=s.primitives,o=[];for(let c=0,l=a.length;c<l;c++){const h=a[c].material===void 0?kS(this.cache):this.getDependency("material",a[c].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let d=0,m=h.length;d<m;d++){const _=h[d],g=a[d];let p;const v=l[d];if(g.mode===Dn.TRIANGLES||g.mode===Dn.TRIANGLE_STRIP||g.mode===Dn.TRIANGLE_FAN||g.mode===void 0)p=s.isSkinnedMesh===!0?new Rh(_,v):new wt(_,v),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===Dn.TRIANGLE_STRIP?p.geometry=zm(p.geometry,jl):g.mode===Dn.TRIANGLE_FAN&&(p.geometry=zm(p.geometry,No));else if(g.mode===Dn.LINES)p=new In(_,v);else if(g.mode===Dn.LINE_STRIP)p=new di(_,v);else if(g.mode===Dn.LINE_LOOP)p=new Uh(_,v);else if(g.mode===Dn.POINTS)p=new Oh(_,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&HS(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),ti(p,s),g.extensions&&br(i,p,g),t.assignFinalMaterial(p),u.push(p)}for(let d=0,m=u.length;d<m;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return s.extensions&&br(i,u[0],s),u[0];const f=new Kn;s.extensions&&br(i,f,s),t.associations.set(f,{meshes:e});for(let d=0,m=u.length;d<m;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(Oo.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new hr(-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(),a=i,o=[],c=[];for(let l=0,h=a.length;l<h;l++){const u=a[l];if(u){o.push(u);const f=new qe;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 ta(o,c)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,a=[],o=[],c=[],l=[],h=[];for(let u=0,f=i.channels.length;u<f;u++){const d=i.channels[u],m=i.samplers[d.sampler],_=d.target,g=_.node,p=i.parameters!==void 0?i.parameters[m.input]:m.input,v=i.parameters!==void 0?i.parameters[m.output]:m.output;_.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",v)),l.push(m),h.push(_))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const f=u[0],d=u[1],m=u[2],_=u[3],g=u[4],p=[];for(let y=0,x=f.length;y<x;y++){const w=f[y],E=d[y],I=m[y],D=_[y],b=g[y];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const C=n._createAnimationTracks(w,E,I,D,b);if(C)for(let B=0;B<C.length;B++)p.push(C[B])}const v=new gs(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 a=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&a.traverse(function(o){if(!!o.isMesh)for(let c=0,l=i.weights.length;c<l;c++)o.morphTargetInfluences[c]=i.weights[c]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),a=[],o=i.children||[];for(let l=0,h=o.length;l<h;l++)a.push(n.getDependency("node",o[l]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(a),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,qS)});for(let d=0,m=u.length;d<m;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],a=s.name?i.createUniqueName(s.name):"",o=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&o.push(c),s.camera!==void 0&&o.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){o.push(l)}),this.nodeCache[e]=Promise.all(o).then(function(l){let h;if(s.isBone===!0?h=new fc: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=a),ti(h,s),s.extensions&&br(n,h,s),s.matrix!==void 0){const u=new qe;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&&br(t,s,n);const a=n.nodes||[],o=[];for(let c=0,l=a.length;c<l;c++)o.push(i.getDependency("node",a[c]));return Promise.all(o).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 a=[],o=e.name?e.name:e.uuid,c=[];Ui[s.path]===Ui.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(o);let l;switch(Ui[s.path]){case Ui.weights:l=ar;break;case Ui.rotation:l=or;break;case Ui.translation:case Ui.scale:l=lr;break;default:switch(n.itemSize){case 1:l=ar;break;case 2:case 3:default:l=lr;break}break}const h=i.interpolation!==void 0?zS[i.interpolation]:Or,u=this._getArrayFromAccessor(n);for(let f=0,d=c.length;f<d;f++){const m=new l(c[f]+"."+Ui[s.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),a.push(m)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=ku(t.constructor),i=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof or?FS:Hm;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ZS(r,e,t){const n=e.attributes,i=new Gt;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],c=o.min,l=o.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])),o.normalized){const h=ku(Ts[o.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 o=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,m=f.max;if(d!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(m[2]))),f.normalized){const _=ku(Ts[f.componentType]);c.multiplyScalar(_)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}r.boundingBox=i;const a=new Pt;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=a}function qm(r,e,t){const n=e.attributes,i=[];function s(a,o){return t.getDependency("accessor",a).then(function(c){r.setAttribute(o,c)})}for(const a in n){const o=Ou[a]||a.toLowerCase();o in r.attributes||i.push(s(n[a],o))}if(e.indices!==void 0&&!r.index){const a=t.getDependency("accessor",e.indices).then(function(o){r.setIndex(o)});i.push(a)}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),ZS(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?VS(r,e.targets,t):r})}const Vu=new WeakMap;class YS 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,a=>{this.parse(a,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,a=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Vu.has(e)){const c=Vu.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++,a=e.byteLength,o=this._getWorker(s,a).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 o.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Vu.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Ke;e.index&&t.setIndex(new at(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:a,stride:o,vertexColorSpace:c}=e.attributes[n];let l;if(a===o)l=new at(s,a);else{const h=new rs(s,o);l=new fi(h,a,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 be;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=QS.toString(),a=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
4036
4036
  `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),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 a=s.data;switch(a.type){case"decode":i._callbacks[a.id].resolve(a);break;case"error":i._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.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 QS(){let r,e;onmessage=function(a){const o=a.data;switch(o.type){case"init":r=o.decoderConfig,e=new Promise(function(h){r.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(r)});break;case"decode":const c=o.buffer,l=o.taskConfig;e.then(h=>{const u=h.draco,f=new u.Decoder;try{const d=t(u,f,new Int8Array(c),l),m=d.attributes.map(_=>_.array.buffer);d.index&&m.push(d.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:d},m)}catch(d){console.error(d),self.postMessage({type:"error",id:o.id,error:d.message})}finally{u.destroy(f)}});break}};function t(a,o,c,l){const h=l.attributeIDs,u=l.attributeTypes;let f,d;const m=o.GetEncodedGeometryType(c);if(m===a.TRIANGULAR_MESH)f=new a.Mesh,d=o.DecodeArrayToMesh(c,c.byteLength,f);else if(m===a.POINT_CLOUD)f=new a.PointCloud,d=o.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 g in h){const p=self[u[g]];let v,y;if(l.useUniqueIDs)y=h[g],v=o.GetAttributeByUniqueId(f,y);else{if(y=o.GetAttributeId(f,a[h[g]]),y===-1)continue;v=o.GetAttribute(f,y)}const x=i(a,o,f,g,p,v);g==="color"&&(x.vertexColorSpace=l.vertexColorSpace),_.attributes.push(x)}return m===a.TRIANGULAR_MESH&&(_.index=n(a,o,f)),a.destroy(f),_}function n(a,o,c){const h=c.num_faces()*3,u=h*4,f=a._malloc(u);o.GetTrianglesUInt32Array(c,u,f);const d=new Uint32Array(a.HEAPF32.buffer,f,h).slice();return a._free(f),{array:d,itemSize:1}}function i(a,o,c,l,h,u){const f=c.num_points(),d=u.num_components(),m=s(a,h),_=d*h.BYTES_PER_ELEMENT,g=Math.ceil(_/4)*4,p=g/h.BYTES_PER_ELEMENT,v=f*_,y=f*g,x=a._malloc(v);o.GetAttributeDataArrayForAllPoints(c,u,m,v,x);const w=new h(a.HEAPF32.buffer,x,v/h.BYTES_PER_ELEMENT);let E;if(_===g)E=w.slice();else{E=new h(y/h.BYTES_PER_ELEMENT);let I=0;for(let D=0,b=w.length;D<b;D++){for(let C=0;C<d;C++)E[I+C]=w[D*d+C];I+=p}}return a._free(x),{name:l,count:f,itemSize:d,array:E,stride:p}}function s(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}class KS{constructor(){Q(this,"loader");this.loader=new dS;const e=new YS;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 gl(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 Xm={exports:{}};/*!
4037
4037
 
4038
4038
  JSZip v3.10.1 - A JavaScript class for generating and reading zip files
@@ -5016,5 +5016,5 @@ MTkwg9sJOkT8/jQ3KmnzBOLJyS9wLo3ELR3NZZ75gRlhN8fndGHhOc1ZSa3T8F7PabYqsjMvqRWKVy/i
5016
5016
  YEruPHv9jvnYZxalzUMH9iWulTvIaLTXEa5ZX8xVa61fFraX9QCIAKg5bh8rVRiy7m8o4pJl5O0ogZ8d
5017
5017
  vmbCnCfH5TJKTBFva0O4Wl+l/Ix13xO6KCJPD5H51fete+aO/R8EyzZRoN8BAA==`;let Cl;function LE(){if(!Cl){Cl=new Uint8Array(122784);const r=atob(DE),e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);of(e,Cl)}return Cl}const ke=0,kg=1,NE=2,UE=3,BE=4,OE=5,FE=6,zE=7,kE=8,Vg=9,Nt=10,Ft=11,cf=12,VE=13,HE=14,GE=15,WE=16,qE=17,XE=18,ZE=20;function ue(r,e,t){this.prefix=new Uint8Array(r.length),this.transform=e,this.suffix=new Uint8Array(t.length);for(let n=0;n<r.length;n++)this.prefix[n]=r.charCodeAt(n);for(let n=0;n<t.length;n++)this.suffix[n]=t.charCodeAt(n)}const Il=[new ue("",ke,""),new ue("",ke," "),new ue(" ",ke," "),new ue("",cf,""),new ue("",Nt," "),new ue("",ke," the "),new ue(" ",ke,""),new ue("s ",ke," "),new ue("",ke," of "),new ue("",Nt,""),new ue("",ke," and "),new ue("",VE,""),new ue("",kg,""),new ue(", ",ke," "),new ue("",ke,", "),new ue(" ",Nt," "),new ue("",ke," in "),new ue("",ke," to "),new ue("e ",ke," "),new ue("",ke,'"'),new ue("",ke,"."),new ue("",ke,'">'),new ue("",ke,`
5018
5018
  `),new ue("",UE,""),new ue("",ke,"]"),new ue("",ke," for "),new ue("",HE,""),new ue("",NE,""),new ue("",ke," a "),new ue("",ke," that "),new ue(" ",Nt,""),new ue("",ke,". "),new ue(".",ke,""),new ue(" ",ke,", "),new ue("",GE,""),new ue("",ke," with "),new ue("",ke,"'"),new ue("",ke," from "),new ue("",ke," by "),new ue("",WE,""),new ue("",qE,""),new ue(" the ",ke,""),new ue("",BE,""),new ue("",ke,". The "),new ue("",Ft,""),new ue("",ke," on "),new ue("",ke," as "),new ue("",ke," is "),new ue("",zE,""),new ue("",kg,"ing "),new ue("",ke,`
5019
- `),new ue("",ke,":"),new ue(" ",ke,". "),new ue("",ke,"ed "),new ue("",ZE,""),new ue("",XE,""),new ue("",FE,""),new ue("",ke,"("),new ue("",Nt,", "),new ue("",kE,""),new ue("",ke," at "),new ue("",ke,"ly "),new ue(" the ",ke," of "),new ue("",OE,""),new ue("",Vg,""),new ue(" ",Nt,", "),new ue("",Nt,'"'),new ue(".",ke,"("),new ue("",Ft," "),new ue("",Nt,'">'),new ue("",ke,'="'),new ue(" ",ke,"."),new ue(".com/",ke,""),new ue(" the ",ke," of the "),new ue("",Nt,"'"),new ue("",ke,". This "),new ue("",ke,","),new ue(".",ke," "),new ue("",Nt,"("),new ue("",Nt,"."),new ue("",ke," not "),new ue(" ",ke,'="'),new ue("",ke,"er "),new ue(" ",Ft," "),new ue("",ke,"al "),new ue(" ",Ft,""),new ue("",ke,"='"),new ue("",Ft,'"'),new ue("",Nt,". "),new ue(" ",ke,"("),new ue("",ke,"ful "),new ue(" ",Nt,". "),new ue("",ke,"ive "),new ue("",ke,"less "),new ue("",Ft,"'"),new ue("",ke,"est "),new ue(" ",Nt,"."),new ue("",Ft,'">'),new ue(" ",ke,"='"),new ue("",Nt,","),new ue("",ke,"ize "),new ue("",Ft,"."),new ue("\xC2\xA0",ke,""),new ue(" ",ke,","),new ue("",Nt,'="'),new ue("",Ft,'="'),new ue("",ke,"ous "),new ue("",Ft,", "),new ue("",Nt,"='"),new ue(" ",Nt,","),new ue(" ",Ft,'="'),new ue(" ",Ft,", "),new ue("",Ft,","),new ue("",Ft,"("),new ue("",Ft,". "),new ue(" ",Ft,"."),new ue("",Ft,"='"),new ue(" ",Ft,". "),new ue(" ",Nt,'="'),new ue(" ",Ft,"='"),new ue(" ",Nt,"='")],YE=Il.length;function Hg(r,e){return r[e]<192?(r[e]>=97&&r[e]<=122&&(r[e]^=32),1):r[e]<224?(r[e+1]^=32,2):(r[e+2]^=5,3)}function QE(r,e,t,n,i){const s=LE(),{prefix:a}=Il[i],{suffix:o}=Il[i],c=Il[i].transform;let l=c<cf?0:c-(cf-1);const h=e;l>n&&(l=n);let u=0;for(;u<a.length;)r[e++]=a[u++];t+=l,n-=l,c<=Vg&&(n-=c);for(let m=0;m<n;m++)r[e++]=s[t+m];let f=e-n;if(c===Nt)Hg(r,f);else if(c===Ft)for(;n>0;){const m=Hg(r,f);f+=m,n-=m}let d=0;for(;d<o.length;)r[e++]=o[d++];return e-h}const KE=256,jE=704,JE=26,Gg=6,Wg=2,lf=16,$E=new Uint8Array([3,2,1,0,3,3,3,3,3,3,2,2,2,2,2,2]),eT=new Int8Array([0,0,0,0,-1,1,-2,2,-3,3,-1,1,-2,2,-3,3]),tT=new Uint32Array([0,0,0,0,0,4096,9216,21504,35840,44032,53248,63488,74752,87040,93696,100864,104704,106752,108928,113536,115968,118528,119872,121280,122016]),nT=new Uint8Array([0,0,0,0,10,10,11,11,10,10,10,10,10,9,9,8,7,7,8,7,7,6,6,5,5]),iT=4,qg=24;function rT(r,e){const t=new Uint8Array(e),n=new Fg(r),i=new zg(t);return sT(n,i),t}function sT(r,e){let t=0,n=0,i=0,s=0;const a=[16,15,11,4];let o=0,c=0,l=0;const h=[new Tr(0,0),new Tr(0,0),new Tr(0,0)],u=128+Hn.READ_SIZE,f=new Hn(r);i=ME(f);const d=(1<<i)-16,m=1<<i,_=m-1,g=new Uint8Array(m+u+qg),p=m,v=[],y=[];for(let x=0;x<3*Oi;x++)v[x]=new bt(0,0),y[x]=new bt(0,0);for(;!n;){let x=0;const w=[1<<28,1<<28,1<<28],E=[0],I=[1,1,1],D=[0,1,0,1,0,1],b=[0];let C=0;for(let ee=0;ee<3;ee++)h[ee].codes=[],h[ee].htrees=new Uint32Array;f.readMoreInput();const B=wE(f);if(x=B.meta_block_length,t+x>e.buffer.length){const ee=new Uint8Array(t+x);ee.set(e.buffer),e.buffer=ee}if(n=B.input_end,B.is_metadata){for(EE(f);x>0;--x)f.readMoreInput(),f.readBits(8);continue}if(x===0)continue;if(B.is_uncompressed){f.bit_pos_=f.bit_pos_+7&-8,SE(e,x,t,g,_,f),t+=x;continue}for(let ee=0;ee<3;ee++)I[ee]=Ug(f)+1,I[ee]>=2&&(Ml(I[ee]+2,v,ee*Oi,f),Ml(JE,y,ee*Oi,f),w[ee]=El(y,ee*Oi,f),b[ee]=1);f.readMoreInput();const R=f.readBits(2),O=lf+(f.readBits(4)<<R),M=(1<<R)-1,z=O+(48<<R),X=new Uint8Array(I[0]);for(let ee=0;ee<I[0];ee++)f.readMoreInput(),X[ee]=f.readBits(2)<<1;const[H,re]=Og(I[0]<<Gg,f),[$,le]=Og(I[2]<<Wg,f);h[0]=new Tr(KE,H),h[1]=new Tr(jE,I[1]),h[2]=new Tr(z,$);for(let ee=0;ee<3;++ee)h[ee].decode(f);let W=0,Z=0,ge=X[E[0]],_e=Tl[ge],de=Tl[ge+1],ae=h[1].htrees[0];for(;x>0;){let ee;f.readMoreInput(),w[1]===0&&(sf(I[1],v,1,E,D,b,f),w[1]=El(y,Oi,f),ae=h[1].htrees[E[1]]),w[1]--;const pe=Rs(h[1].codes,ae,f);let ye=pe>>6;ye>=2?(ye-=2,ee=-1):ee=0;const xe=_E[ye]+(pe>>3&7),ze=mE[xe],je=ze.offset+f.readBits(ze.nbits),He=vE[ye]+(pe&7),A=gE[He],q=A.offset+f.readBits(A.nbits);c=g[t-1&_],l=g[t-2&_];for(let S=0;S<je;S++){f.readMoreInput(),w[0]===0&&(sf(I[0],v,0,E,D,b,f),w[0]=El(y,0,f),C=E[0]<<Gg,W=C,ge=X[E[0]],_e=Tl[ge],de=Tl[ge+1]);const G=Bg[_e+c]|Bg[de+l],j=re[W+G];w[0]--,l=c,c=Rs(h[0].codes,h[0].htrees[j],f),g[t&_]=c,(t&_)===_&&e.write(g,m),t++}if(x-=je,x<=0)break;if(ee<0){f.readMoreInput(),w[2]===0&&(sf(I[2],v,2,E,D,b,f),w[2]=El(y,2*Oi,f),Z=E[2]<<Wg),w[2]--;const S=(q>4?3:q-2)&255,G=le[Z+S];if(ee=Rs(h[2].codes,h[2].htrees[G],f),ee>=O){ee-=O;const j=ee&M;ee>>=R;const ie=(ee>>1)+1,V=(2+(ee&1)<<ie)-4;ee=O+(V+f.readBits(ie)<<R)+j}}const k=aT(ee,a,o);if(k<0)throw new Error("[BrotliDecompress] invalid distance");t<d&&s!==d?s=t:s=d;let N=t&_;if(k>s)if(q>=iT&&q<=qg){let S=tT[q];const G=k-s-1,j=nT[q],ie=(1<<j)-1,V=G&ie,P=G>>j;if(S+=V*q,P<YE){const T=QE(g,N,S,q,P);if(N+=T,t+=T,x-=T,N>=p){e.write(g,m);for(let F=0;F<N-p;F++)g[F]=g[p+F]}}else throw new Error("Invalid backward reference")}else throw new Error("Invalid backward reference");else{if(ee>0&&(a[o&3]=k,o++),q>x)throw new Error("Invalid backward reference");for(let S=0;S<q;S++)g[t&_]=g[t-k&_],(t&_)===_&&e.write(g,m),t++,x--}c=g[t-1&_],l=g[t-2&_]}t&=1073741823}e.write(g,t&_)}function aT(r,e,t){return r<lf?(t+=$E[r],t&=3,e[t]+eT[r]):r-lf+1}function oT(r,e){const t=new Uint8Array(e);try{let n=0,i=0;for(;n<r.length-8;){const s=r[n++]<<24|r[n++]<<16|r[n++]<<8|r[n++],a=r[n++]<<24|r[n++]<<16|r[n++]<<8|r[n++];if(r.length-n<a)throw new Error("lz4 not hadoop");if(t.length<s)throw new Error("lz4 not hadoop");if(hf(r.subarray(n,n+a),t,i)!==s)throw new Error("lz4 not hadoop");if(n+=a,i+=s,n===r.length)return t}if(n<r.length)throw new Error("lz4 not hadoop")}catch(n){if(n instanceof Error&&n.message!=="lz4 not hadoop")throw n;hf(r,t,0)}return t}function cT(r,e){const t=new Uint8Array(e);return hf(r,t,0),t}function hf(r,e,t){let n=t;for(let i=0;i<r.length;){const s=r[i++];let a=s>>4;if(a){let f=a+240;for(;f===255;)a+=f=r[i++];if(e.set(r.subarray(i,i+a),n),n+=a,i+=a,i>=r.length)return n-t}const o=r[i++]|r[i++]<<8;if(!o||o>n)throw new Error(`lz4 offset out of range ${o}`);let c=(s&15)+4,l=c+240;for(;l===255;)c+=l=r[i++];let h=n-o;const u=n+c;for(;n<u;)e[n++]=e[h++]}return n-t}const lT={SNAPPY:iE(),GZIP:(r,e)=>of(r,new Uint8Array(e)),BROTLI:rT,ZSTD:r=>nE(r),LZ4:oT,LZ4_RAW:cT};function Xg(r,e){console.time("Building geometry");const t=new Kn,n=fT(r),i=dT(n),s=pT(n),a=hT(i);let o=0;for(const c of s)o+=c.geometry.index.count/3*c.count,t.add(c);for(const c of a)o+=c.geometry.index.count/3,t.add(c);return(e?.applyZUpToYUpRotation??!0)&&(t.rotation.x=-Math.PI/2),console.timeEnd("Building geometry"),t}function hT(r){const e=[];for(const t of r){const n=t.instances.length;if(n===0)continue;const i=t.material;if(n===1){const u=t.instances[0],f=new wt(u.geometry,u.material);f.matrixAutoUpdate=!1,f.matrix.copy(u.transform),f.userData.pick={kind:"single",instanceIndex:u.instance},e.push(f);continue}const s=[],a=[];for(const u of t.instances){const f=u.isIdentity?u.geometry:u.geometry.clone().applyMatrix4(u.transform);s.push(f),a.push(u.instance)}const{geometry:o,triToInstanceIndex:c}=uT(s),l=new wt(o,i);l.name=`MergedStatic_Material_${i.Id}`;const h=new Uint32Array(c.length);for(let u=0;u<c.length;u++)h[u]=a[c[u]];l.userData.pick={kind:"merged",triToInstanceIndex:h},e.push(l)}return e}function uT(r){let e=0,t=0;for(let l=0,h=r.length;l<h;l++){const u=r[l],f=u.getIndex(),d=u.getAttribute("position");e+=f.count,t+=d.count}const n=new Float32Array(t*3),i=new Uint32Array(e),s=new Uint32Array(e/3);let a=0,o=0;for(let l=0,h=r.length;l<h;l++){const u=r[l],f=u.getAttribute("position"),d=u.getIndex(),m=f.array,_=d.array,g=f.count,p=d.count,v=f.itemSize,y=p/3,x=g*v,w=o*v;n.set(m.subarray(0,x),w);for(let I=0;I<p;I++)i[a+I]=_[I]+o;const E=a/3;for(let I=0;I<y;I++)s[E+I]=l;o+=g,a+=p}const c=new Ke;return c.setAttribute("position",new at(n,3)),c.setIndex(new at(i,1)),{geometry:c,triToInstanceIndex:s}}function fT(r){const e=new Map;for(const t of r){if(!t)continue;let n=e.get(t.material);n||(n=new Map,e.set(t.material,n));let i=n.get(t.geometry);i||(i=[],n.set(t.geometry,i)),i.push(t)}return e}function dT(r){const e=new Array;for(const[t,n]of r){let i=[];for(const[,s]of n)s.length==1&&i.push(s[0]);i.length<1||e.push({material:t,instances:i})}return e}function pT(r){const e=new Array;for(const[t,n]of r)for(const[i,s]of n){const a=s.length;if(a<=1)continue;const o=new pc(i,t,a);o.instanceMatrix.setUsage(Fr);const c=new Uint32Array(a);for(let l=0;l<a;l++)o.setMatrixAt(l,s[l].transform),c[l]=s[l].instance;o.frustumCulled=!1,o.matrixAutoUpdate=!1,o.matrixWorldNeedsUpdate=!1,o.userData.pick={kind:"instanced",instanceIndices:c},e.push(o)}return e}function mT(r){console.time("Building instances");const e=vT(r),t=gT(r),n=_T(r),i=r.InstanceMeshIndex.length,s=new Array(i),a=new qe;for(let o=0;o<i;o++){const c=r.InstanceMeshIndex[o];if(c<0||r.InstanceFlags[o]&1)continue;const h=t[c];if(!h)continue;const u=n[r.InstanceMaterialIndex[o]],f=e[r.InstanceTransformIndex[o]],d=r.InstanceEntityIndex[o],m=f.equals(a);s[o]={instance:o,geometry:h,material:u,transform:f,entity:d,isIdentity:m}}return console.timeEnd("Building instances"),s}function gT(r){const e=r.MeshVertexOffset.length,t=r.IndexBuffer.length,n=r.VertexX.length,i=new Array(e),{VertexX:s,VertexY:a,VertexZ:o,IndexBuffer:c,MeshVertexOffset:l,MeshIndexOffset:h}=r;for(let u=0;u<e;u++){const f=h[u],d=u+1<e?h[u+1]:t,m=d-f,_=l[u],p=(u+1<e?l[u+1]:n)-_;if(m===0||p===0)continue;const v=c.subarray(f,d),y=1e4,x=new Float32Array(p*3);for(let E=0;E<p;E++)x[E*3+0]=s[E+_]/y,x[E*3+1]=a[E+_]/y,x[E*3+2]=o[E+_]/y;const w=new Ke;w.setAttribute("position",new at(x,3)),w.setIndex(new at(v,1)),i[u]=w}return i}function _T(r){const e=r.MaterialAlpha.length,t=new Array(e);for(let n=0;n<e;n++){const i=r.MaterialRed[n]/255,s=r.MaterialGreen[n]/255,a=r.MaterialBlue[n]/255,o=r.MaterialAlpha[n]/255,c=r.MaterialRoughness[n]/255,l=r.MaterialMetallic[n]/255,h=new ps({color:new be(i,s,a),opacity:o,flatShading:!0,transparent:o<.999,roughness:c,metalness:l,side:Sn});t[n]=h}return t}function vT(r){const{TransformTX:e,TransformTY:t,TransformTZ:n,TransformQX:i,TransformQY:s,TransformQZ:a,TransformQW:o,TransformSX:c,TransformSY:l,TransformSZ:h}=r,u=new U,f=new Mt,d=new U,m=e.length,_=new Array(m);for(let g=0;g<m;g++){const p=e[g],v=t[g],y=n[g],x=c[g],w=l[g],E=h[g],I=i[g],D=s[g],b=a[g],C=o[g],B=new qe;u.set(p,v,y),f.set(I,D,b,C),d.set(x,w,E),B.compose(u,f,d),_[g]=B}return _}class yT{constructor(){Q(this,"BimGeometry");Q(this,"Entities");Q(this,"Strings");Q(this,"ThreeGeometry");Q(this,"Resolver");Q(this,"Query");Q(this,"Instances");Q(this,"Descriptors");Q(this,"IntegerParameters");Q(this,"StringParameters");Q(this,"EntityParameters");Q(this,"SingleParameters");Q(this,"PointParameters");Q(this,"geometryOptions",{applyZUpToYUpRotation:!0})}rebuildGeometry(e){return Xg(e,this.geometryOptions)}}class xT{constructor(e,t){Q(this,"Descriptors");Q(this,"Strings");Q(this,"Entities");Q(this,"InstanceCount");Q(this,"EntityCount");Q(this,"BimGeometry");Q(this,"DescriptorCount");Q(this,"ParameterMap");this.Data=e,this.Entities=e.Entities??{},this.Strings=e.Strings??[],this.BimGeometry=e.BimGeometry,this.InstanceCount=this.BimGeometry?.InstanceEntityIndex?.length??0,this.EntityCount=this.Entities?.Category?.length??0,this.Descriptors=t?.skipDescriptorsAndParameters?{}:e.Descriptors??{},this.DescriptorCount=t?.skipDescriptorsAndParameters?0:this.Descriptors?.Name?.length??0,this.ParameterMap=new Map,t?.skipDescriptorsAndParameters||(console.time("Computing parameters"),e.IntegerParameters&&this.ProcessParameters(e.IntegerParameters),e.SingleParameters&&this.ProcessParameters(e.SingleParameters),e.StringParameters&&this.ProcessParameters(e.StringParameters),e.EntityParameters&&this.ProcessParameters(e.EntityParameters),console.timeEnd("Computing parameters"))}GetVal(e,t){return t==3?this.Strings[e]:t==2?e>=0?this.GetEntityName(e):"":e}ProcessParameters(e){if(!(!e||!e.Value||!e.Descriptor||!e.Entity))for(let t=0;t<e.Value.length;t++){let n=e.Descriptor[t],i=e.Entity[t],s=e.Value[t];if(n<0)continue;let a=this.Descriptors.Name[n],o=this.Descriptors.Type[n],c=this.GetVal(s,o),h={Name:this.Strings[a],Value:c},u=this.ParameterMap.get(i);u===void 0?this.ParameterMap.set(i,[h]):u.push(h)}}GetString(e){return this.Strings[e]}GetEntityName(e){return this.GetString(this.Entities.Name[e])}GetEntityCategory(e){return this.Entities.Category[e]}GetEntityCategoryName(e){return this.GetEntityName(this.GetEntityCategory(e))}GetEntityType(e){return this.Entities.Type[e]}GetEntityTypeName(e){return this.GetEntityName(this.GetEntityType(e))}GetEntityDocument(e){return this.Entities.Type[e]}GetEntityDocumentName(e){return this.GetEntityName(this.GetEntityDocument(e))}GetEntityParameters(e){return this.ParameterMap.get(e)}GetInstanceName(e){return this.GetEntityName(e.entity)}GetInstanceCategoryName(e){return this.GetEntityCategoryName(e.entity)}GetInstanceTypeName(e){return this.GetEntityTypeName(e.entity)}GetInstanceDocumentName(e){return this.GetEntityDocumentName(e.entity)}GetInstanceGlobalId(e){return this.GetString(this.Entities.GlobalId[e.entity])}GetInstanceParameters(e){return this.GetEntityParameters(e.entity)}GetDescriptorName(e){return this.GetString(this.Descriptors.Name[e])}GetDescriptorType(e){return this.Descriptors.Type[e]}GetDescriptorGroup(e){return this.GetString(this.Descriptors.Group[e])}GetDescriptorUnits(e){return this.GetString(this.Descriptors.Units[e])}*EntityIndices(){for(let e=0;e<this.EntityCount;e++)yield e}*InstanceIndices(){for(let e=0;e<this.InstanceCount;e++)yield e}*DescriptorIndices(){for(let e=0;e<this.DescriptorCount;e++)yield e}first(e,t,n){for(const i of e)if(t(i))return i;return n}FindDescriptor(e){return this.first(this.DescriptorIndices(),t=>this.GetDescriptorName(t)==e,-1)}}class AT{constructor(e){Q(this,"Resolver");this.Data=e,this.Resolver=new xT(e);let t=this.Resolver.FindDescriptor("Rvt:Element:Level");console.log("The level descriptor is ",t),e.EntityParameters.Descriptor}FuncToInstances(e){const t=new Map;for(const n of this.Resolver.Data.Instances){if(!n)continue;const i=e(n);let s=t.get(i);s?s.push(n):t.set(i,[n])}return t}CategoryToInstances(){return this.FuncToInstances(e=>this.Resolver.GetInstanceCategoryName(e))}GlobalIdToInstances(){return this.FuncToInstances(e=>this.Resolver.GetInstanceGlobalId(e))}GetLevelFromParameters(e){if(!e)return null;let t=e.find(n=>n.Name=="Rvt:Element:Level");return t?String(t.Value):""}LevelToInstances(){return this.FuncToInstances(e=>this.GetLevelFromParameters(this.Resolver.GetInstanceParameters(e)))}}class bT{async load(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch BOS from ${e}: ${n.status} ${n.statusText}`);const i=await n.arrayBuffer(),s=await jS.loadAsync(i),a=await Zg(s,t);return a.Instances=mT(a.BimGeometry),a.Query=new AT(a),a.Resolver=a.Query.Resolver,a.geometryOptions={applyZUpToYUpRotation:t?.applyZUpToYUpRotation??!0},a.ThreeGeometry=Xg(a.Instances,a.geometryOptions),a}}async function Zg(r,e){function t(a){const o=a.toLowerCase(),c=Object.keys(r.files).find(l=>l.toLowerCase().endsWith(o));if(!c)throw new Error(`Could not find "${a}" in zip archive.`);return c}async function n(a,o,c=void 0,l=!1){let h;try{h=t(a+".parquet")}catch(d){if(l)return;throw d}if(!h){if(l)return;throw new Error(`Could not find "${a}.parquet" in zip archive.`)}const u=await r.files[h].async("arraybuffer"),f=await lg(u);if(Number(f.num_rows)===0){for(const d of f.schema)d.name&&d.type!==void 0&&(o[d.name]=c?new c(0):[]);return}await zM({file:u,compressors:lT,metadata:f,onChunk(d){let m=d.columnData;m instanceof BigInt64Array?c===Int32Array?m=Int32Array.from(m,_=>Number(_)):c===Float32Array?m=Float32Array.from(m,_=>Number(_)):c===Uint32Array?m=Uint32Array.from(m,_=>Number(_)):m=Array.from(m,_=>Number(_)):c&&m.constructor.name!=c.name&&(m=new c(m)),o[d.columnName]=m}})}console.time("Reading parquet tables");const i=new yT,s={};return await n("Instances",s,Int32Array),await n("VertexBuffer",s,Int32Array),await n("IndexBuffer",s,Uint32Array),await n("Meshes",s,Int32Array),await n("Materials",s,Uint8Array),await n("Transforms",s,Float32Array),i.BimGeometry=s,await n("Entities",i.Entities={},Int32Array),i.Descriptors={},e?.skipDescriptorsAndParameters||await n("Descriptors",i.Descriptors,void 0,!0),i.IntegerParameters={},i.SingleParameters={},i.StringParameters={},i.EntityParameters={},i.PointParameters={},e?.skipDescriptorsAndParameters||(await n("IntegerParameters",i.IntegerParameters,Int32Array,!0),await n("SingleParameters",i.SingleParameters,Int32Array,!0),await n("StringParameters",i.StringParameters,Int32Array,!0),await n("EntityParameters",i.EntityParameters,Int32Array,!0),await n("PointParameters",i.PointParameters,Int32Array,!0)),await n("Strings",i),i}Ut.BimOpenSchemaLoader=bT,Ut.DefaultInputScheme=Nm,Ut.GizmoOptions=vw,Ut.GltfLoader=KS,Ut.KEYS=At,Ut.THREE=nw,Ut.Viewer=fS,Ut.getSettings=Tm,Ut.loadBimGeometryFromZip=Zg,Object.defineProperties(Ut,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
5019
+ `),new ue("",ke,":"),new ue(" ",ke,". "),new ue("",ke,"ed "),new ue("",ZE,""),new ue("",XE,""),new ue("",FE,""),new ue("",ke,"("),new ue("",Nt,", "),new ue("",kE,""),new ue("",ke," at "),new ue("",ke,"ly "),new ue(" the ",ke," of "),new ue("",OE,""),new ue("",Vg,""),new ue(" ",Nt,", "),new ue("",Nt,'"'),new ue(".",ke,"("),new ue("",Ft," "),new ue("",Nt,'">'),new ue("",ke,'="'),new ue(" ",ke,"."),new ue(".com/",ke,""),new ue(" the ",ke," of the "),new ue("",Nt,"'"),new ue("",ke,". This "),new ue("",ke,","),new ue(".",ke," "),new ue("",Nt,"("),new ue("",Nt,"."),new ue("",ke," not "),new ue(" ",ke,'="'),new ue("",ke,"er "),new ue(" ",Ft," "),new ue("",ke,"al "),new ue(" ",Ft,""),new ue("",ke,"='"),new ue("",Ft,'"'),new ue("",Nt,". "),new ue(" ",ke,"("),new ue("",ke,"ful "),new ue(" ",Nt,". "),new ue("",ke,"ive "),new ue("",ke,"less "),new ue("",Ft,"'"),new ue("",ke,"est "),new ue(" ",Nt,"."),new ue("",Ft,'">'),new ue(" ",ke,"='"),new ue("",Nt,","),new ue("",ke,"ize "),new ue("",Ft,"."),new ue("\xC2\xA0",ke,""),new ue(" ",ke,","),new ue("",Nt,'="'),new ue("",Ft,'="'),new ue("",ke,"ous "),new ue("",Ft,", "),new ue("",Nt,"='"),new ue(" ",Nt,","),new ue(" ",Ft,'="'),new ue(" ",Ft,", "),new ue("",Ft,","),new ue("",Ft,"("),new ue("",Ft,". "),new ue(" ",Ft,"."),new ue("",Ft,"='"),new ue(" ",Ft,". "),new ue(" ",Nt,'="'),new ue(" ",Ft,"='"),new ue(" ",Nt,"='")],YE=Il.length;function Hg(r,e){return r[e]<192?(r[e]>=97&&r[e]<=122&&(r[e]^=32),1):r[e]<224?(r[e+1]^=32,2):(r[e+2]^=5,3)}function QE(r,e,t,n,i){const s=LE(),{prefix:a}=Il[i],{suffix:o}=Il[i],c=Il[i].transform;let l=c<cf?0:c-(cf-1);const h=e;l>n&&(l=n);let u=0;for(;u<a.length;)r[e++]=a[u++];t+=l,n-=l,c<=Vg&&(n-=c);for(let m=0;m<n;m++)r[e++]=s[t+m];let f=e-n;if(c===Nt)Hg(r,f);else if(c===Ft)for(;n>0;){const m=Hg(r,f);f+=m,n-=m}let d=0;for(;d<o.length;)r[e++]=o[d++];return e-h}const KE=256,jE=704,JE=26,Gg=6,Wg=2,lf=16,$E=new Uint8Array([3,2,1,0,3,3,3,3,3,3,2,2,2,2,2,2]),eT=new Int8Array([0,0,0,0,-1,1,-2,2,-3,3,-1,1,-2,2,-3,3]),tT=new Uint32Array([0,0,0,0,0,4096,9216,21504,35840,44032,53248,63488,74752,87040,93696,100864,104704,106752,108928,113536,115968,118528,119872,121280,122016]),nT=new Uint8Array([0,0,0,0,10,10,11,11,10,10,10,10,10,9,9,8,7,7,8,7,7,6,6,5,5]),iT=4,qg=24;function rT(r,e){const t=new Uint8Array(e),n=new Fg(r),i=new zg(t);return sT(n,i),t}function sT(r,e){let t=0,n=0,i=0,s=0;const a=[16,15,11,4];let o=0,c=0,l=0;const h=[new Tr(0,0),new Tr(0,0),new Tr(0,0)],u=128+Hn.READ_SIZE,f=new Hn(r);i=ME(f);const d=(1<<i)-16,m=1<<i,_=m-1,g=new Uint8Array(m+u+qg),p=m,v=[],y=[];for(let x=0;x<3*Oi;x++)v[x]=new bt(0,0),y[x]=new bt(0,0);for(;!n;){let x=0;const w=[1<<28,1<<28,1<<28],E=[0],I=[1,1,1],D=[0,1,0,1,0,1],b=[0];let C=0;for(let ee=0;ee<3;ee++)h[ee].codes=[],h[ee].htrees=new Uint32Array;f.readMoreInput();const B=wE(f);if(x=B.meta_block_length,t+x>e.buffer.length){const ee=new Uint8Array(t+x);ee.set(e.buffer),e.buffer=ee}if(n=B.input_end,B.is_metadata){for(EE(f);x>0;--x)f.readMoreInput(),f.readBits(8);continue}if(x===0)continue;if(B.is_uncompressed){f.bit_pos_=f.bit_pos_+7&-8,SE(e,x,t,g,_,f),t+=x;continue}for(let ee=0;ee<3;ee++)I[ee]=Ug(f)+1,I[ee]>=2&&(Ml(I[ee]+2,v,ee*Oi,f),Ml(JE,y,ee*Oi,f),w[ee]=El(y,ee*Oi,f),b[ee]=1);f.readMoreInput();const R=f.readBits(2),O=lf+(f.readBits(4)<<R),M=(1<<R)-1,z=O+(48<<R),X=new Uint8Array(I[0]);for(let ee=0;ee<I[0];ee++)f.readMoreInput(),X[ee]=f.readBits(2)<<1;const[H,re]=Og(I[0]<<Gg,f),[$,le]=Og(I[2]<<Wg,f);h[0]=new Tr(KE,H),h[1]=new Tr(jE,I[1]),h[2]=new Tr(z,$);for(let ee=0;ee<3;++ee)h[ee].decode(f);let W=0,Z=0,ge=X[E[0]],_e=Tl[ge],de=Tl[ge+1],ae=h[1].htrees[0];for(;x>0;){let ee;f.readMoreInput(),w[1]===0&&(sf(I[1],v,1,E,D,b,f),w[1]=El(y,Oi,f),ae=h[1].htrees[E[1]]),w[1]--;const pe=Rs(h[1].codes,ae,f);let ye=pe>>6;ye>=2?(ye-=2,ee=-1):ee=0;const xe=_E[ye]+(pe>>3&7),ze=mE[xe],je=ze.offset+f.readBits(ze.nbits),He=vE[ye]+(pe&7),A=gE[He],q=A.offset+f.readBits(A.nbits);c=g[t-1&_],l=g[t-2&_];for(let S=0;S<je;S++){f.readMoreInput(),w[0]===0&&(sf(I[0],v,0,E,D,b,f),w[0]=El(y,0,f),C=E[0]<<Gg,W=C,ge=X[E[0]],_e=Tl[ge],de=Tl[ge+1]);const G=Bg[_e+c]|Bg[de+l],j=re[W+G];w[0]--,l=c,c=Rs(h[0].codes,h[0].htrees[j],f),g[t&_]=c,(t&_)===_&&e.write(g,m),t++}if(x-=je,x<=0)break;if(ee<0){f.readMoreInput(),w[2]===0&&(sf(I[2],v,2,E,D,b,f),w[2]=El(y,2*Oi,f),Z=E[2]<<Wg),w[2]--;const S=(q>4?3:q-2)&255,G=le[Z+S];if(ee=Rs(h[2].codes,h[2].htrees[G],f),ee>=O){ee-=O;const j=ee&M;ee>>=R;const ie=(ee>>1)+1,V=(2+(ee&1)<<ie)-4;ee=O+(V+f.readBits(ie)<<R)+j}}const k=aT(ee,a,o);if(k<0)throw new Error("[BrotliDecompress] invalid distance");t<d&&s!==d?s=t:s=d;let N=t&_;if(k>s)if(q>=iT&&q<=qg){let S=tT[q];const G=k-s-1,j=nT[q],ie=(1<<j)-1,V=G&ie,P=G>>j;if(S+=V*q,P<YE){const T=QE(g,N,S,q,P);if(N+=T,t+=T,x-=T,N>=p){e.write(g,m);for(let F=0;F<N-p;F++)g[F]=g[p+F]}}else throw new Error("Invalid backward reference")}else throw new Error("Invalid backward reference");else{if(ee>0&&(a[o&3]=k,o++),q>x)throw new Error("Invalid backward reference");for(let S=0;S<q;S++)g[t&_]=g[t-k&_],(t&_)===_&&e.write(g,m),t++,x--}c=g[t-1&_],l=g[t-2&_]}t&=1073741823}e.write(g,t&_)}function aT(r,e,t){return r<lf?(t+=$E[r],t&=3,e[t]+eT[r]):r-lf+1}function oT(r,e){const t=new Uint8Array(e);try{let n=0,i=0;for(;n<r.length-8;){const s=r[n++]<<24|r[n++]<<16|r[n++]<<8|r[n++],a=r[n++]<<24|r[n++]<<16|r[n++]<<8|r[n++];if(r.length-n<a)throw new Error("lz4 not hadoop");if(t.length<s)throw new Error("lz4 not hadoop");if(hf(r.subarray(n,n+a),t,i)!==s)throw new Error("lz4 not hadoop");if(n+=a,i+=s,n===r.length)return t}if(n<r.length)throw new Error("lz4 not hadoop")}catch(n){if(n instanceof Error&&n.message!=="lz4 not hadoop")throw n;hf(r,t,0)}return t}function cT(r,e){const t=new Uint8Array(e);return hf(r,t,0),t}function hf(r,e,t){let n=t;for(let i=0;i<r.length;){const s=r[i++];let a=s>>4;if(a){let f=a+240;for(;f===255;)a+=f=r[i++];if(e.set(r.subarray(i,i+a),n),n+=a,i+=a,i>=r.length)return n-t}const o=r[i++]|r[i++]<<8;if(!o||o>n)throw new Error(`lz4 offset out of range ${o}`);let c=(s&15)+4,l=c+240;for(;l===255;)c+=l=r[i++];let h=n-o;const u=n+c;for(;n<u;)e[n++]=e[h++]}return n-t}const lT={SNAPPY:iE(),GZIP:(r,e)=>of(r,new Uint8Array(e)),BROTLI:rT,ZSTD:r=>nE(r),LZ4:oT,LZ4_RAW:cT};function Xg(r){console.time("Building geometry");const e=new Kn,t=fT(r),n=dT(t),i=pT(t),s=hT(n);let a=0;for(const o of i)a+=o.geometry.index.count/3*o.count,e.add(o);for(const o of s)a+=o.geometry.index.count/3,e.add(o);return e.rotation.x=-Math.PI/2,console.timeEnd("Building geometry"),e}function hT(r){const e=[];for(const t of r){const n=t.instances.length;if(n===0)continue;const i=t.material;if(n===1){const u=t.instances[0],f=new wt(u.geometry,u.material);f.matrixAutoUpdate=!1,f.matrix.copy(u.transform),f.userData.pick={kind:"single",instanceIndex:u.instance},e.push(f);continue}const s=[],a=[];for(const u of t.instances){const f=u.isIdentity?u.geometry:u.geometry.clone().applyMatrix4(u.transform);s.push(f),a.push(u.instance)}const{geometry:o,triToInstanceIndex:c}=uT(s),l=new wt(o,i);l.name=`MergedStatic_Material_${i.Id}`;const h=new Uint32Array(c.length);for(let u=0;u<c.length;u++)h[u]=a[c[u]];l.userData.pick={kind:"merged",triToInstanceIndex:h},e.push(l)}return e}function uT(r){let e=0,t=0;for(let l=0,h=r.length;l<h;l++){const u=r[l],f=u.getIndex(),d=u.getAttribute("position");e+=f.count,t+=d.count}const n=new Float32Array(t*3),i=new Uint32Array(e),s=new Uint32Array(e/3);let a=0,o=0;for(let l=0,h=r.length;l<h;l++){const u=r[l],f=u.getAttribute("position"),d=u.getIndex(),m=f.array,_=d.array,g=f.count,p=d.count,v=f.itemSize,y=p/3,x=g*v,w=o*v;n.set(m.subarray(0,x),w);for(let I=0;I<p;I++)i[a+I]=_[I]+o;const E=a/3;for(let I=0;I<y;I++)s[E+I]=l;o+=g,a+=p}const c=new Ke;return c.setAttribute("position",new at(n,3)),c.setIndex(new at(i,1)),{geometry:c,triToInstanceIndex:s}}function fT(r){const e=new Map;for(const t of r){if(!t)continue;let n=e.get(t.material);n||(n=new Map,e.set(t.material,n));let i=n.get(t.geometry);i||(i=[],n.set(t.geometry,i)),i.push(t)}return e}function dT(r){const e=new Array;for(const[t,n]of r){let i=[];for(const[,s]of n)s.length==1&&i.push(s[0]);i.length<1||e.push({material:t,instances:i})}return e}function pT(r){const e=new Array;for(const[t,n]of r)for(const[i,s]of n){const a=s.length;if(a<=1)continue;const o=new pc(i,t,a);o.instanceMatrix.setUsage(Fr);const c=new Uint32Array(a);for(let l=0;l<a;l++)o.setMatrixAt(l,s[l].transform),c[l]=s[l].instance;o.frustumCulled=!1,o.matrixAutoUpdate=!1,o.matrixWorldNeedsUpdate=!1,o.userData.pick={kind:"instanced",instanceIndices:c},e.push(o)}return e}function mT(r){console.time("Building instances");const e=vT(r),t=gT(r),n=_T(r),i=r.InstanceMeshIndex.length,s=new Array(i),a=new qe;for(let o=0;o<i;o++){const c=r.InstanceMeshIndex[o];if(c<0||r.InstanceFlags[o]&1)continue;const h=t[c];if(!h)continue;const u=n[r.InstanceMaterialIndex[o]],f=e[r.InstanceTransformIndex[o]],d=r.InstanceEntityIndex[o],m=f.equals(a);s[o]={instance:o,geometry:h,material:u,transform:f,entity:d,isIdentity:m}}return console.timeEnd("Building instances"),s}function gT(r){const e=r.MeshVertexOffset.length,t=r.IndexBuffer.length,n=r.VertexX.length,i=new Array(e),{VertexX:s,VertexY:a,VertexZ:o,IndexBuffer:c,MeshVertexOffset:l,MeshIndexOffset:h}=r;for(let u=0;u<e;u++){const f=h[u],d=u+1<e?h[u+1]:t,m=d-f,_=l[u],p=(u+1<e?l[u+1]:n)-_;if(m===0||p===0)continue;const v=c.subarray(f,d),y=1e4,x=new Float32Array(p*3);for(let E=0;E<p;E++)x[E*3+0]=s[E+_]/y,x[E*3+1]=a[E+_]/y,x[E*3+2]=o[E+_]/y;const w=new Ke;w.setAttribute("position",new at(x,3)),w.setIndex(new at(v,1)),i[u]=w}return i}function _T(r){const e=r.MaterialAlpha.length,t=new Array(e);for(let n=0;n<e;n++){const i=r.MaterialRed[n]/255,s=r.MaterialGreen[n]/255,a=r.MaterialBlue[n]/255,o=r.MaterialAlpha[n]/255,c=r.MaterialRoughness[n]/255,l=r.MaterialMetallic[n]/255,h=new ps({color:new be(i,s,a),opacity:o,flatShading:!0,transparent:o<.999,roughness:c,metalness:l,side:Sn});t[n]=h}return t}function vT(r){const{TransformTX:e,TransformTY:t,TransformTZ:n,TransformQX:i,TransformQY:s,TransformQZ:a,TransformQW:o,TransformSX:c,TransformSY:l,TransformSZ:h}=r,u=new U,f=new Mt,d=new U,m=e.length,_=new Array(m);for(let g=0;g<m;g++){const p=e[g],v=t[g],y=n[g],x=c[g],w=l[g],E=h[g],I=i[g],D=s[g],b=a[g],C=o[g],B=new qe;u.set(p,v,y),f.set(I,D,b,C),d.set(x,w,E),B.compose(u,f,d),_[g]=B}return _}class yT{constructor(){Q(this,"BimGeometry");Q(this,"Entities");Q(this,"Strings");Q(this,"ThreeGeometry");Q(this,"Resolver");Q(this,"Query");Q(this,"Instances");Q(this,"Descriptors");Q(this,"IntegerParameters");Q(this,"StringParameters");Q(this,"EntityParameters");Q(this,"SingleParameters");Q(this,"PointParameters")}rebuildGeometry(e){return Xg(e)}}class xT{constructor(e){Q(this,"Descriptors");Q(this,"Strings");Q(this,"Entities");Q(this,"InstanceCount");Q(this,"EntityCount");Q(this,"BimGeometry");Q(this,"DescriptorCount");Q(this,"ParameterMap");this.Data=e,this.Entities=e.Entities??{},this.Strings=e.Strings??[],this.BimGeometry=e.BimGeometry,this.InstanceCount=this.BimGeometry.InstanceEntityIndex.length,this.EntityCount=this.Entities.Category.length,this.Descriptors=e.Descriptors,this.DescriptorCount=0,this.ParameterMap=new Map,this.Descriptors&&(console.time("Computing parameters"),this.DescriptorCount=this.Descriptors.Name.length,this.ProcessParameters(e.IntegerParameters),this.ProcessParameters(e.SingleParameters),this.ProcessParameters(e.StringParameters),this.ProcessParameters(e.EntityParameters),console.timeEnd("Computing parameters"))}GetVal(e,t){return t==3?this.Strings[e]:t==2?e>=0?this.GetEntityName(e):"":e}ProcessParameters(e){if(!(!e||!e.Value||!e.Descriptor||!e.Entity))for(let t=0;t<e.Value.length;t++){let n=e.Descriptor[t],i=e.Entity[t],s=e.Value[t];if(n<0)continue;let a=this.Descriptors.Name[n],o=this.Descriptors.Type[n],c=this.GetVal(s,o),h={Name:this.Strings[a],Value:c},u=this.ParameterMap.get(i);u===void 0?this.ParameterMap.set(i,[h]):u.push(h)}}GetString(e){return this.Strings[e]}GetEntityName(e){return this.GetString(this.Entities.Name[e])}GetEntityCategory(e){return this.Entities.Category[e]}GetEntityCategoryName(e){return this.GetEntityName(this.GetEntityCategory(e))}GetEntityType(e){return this.Entities.Type[e]}GetEntityTypeName(e){return this.GetEntityName(this.GetEntityType(e))}GetEntityDocument(e){return this.Entities.Type[e]}GetEntityDocumentName(e){return this.GetEntityName(this.GetEntityDocument(e))}GetEntityParameters(e){return this.ParameterMap.get(e)}GetInstanceName(e){return this.GetEntityName(e.entity)}GetInstanceCategoryName(e){return this.GetEntityCategoryName(e.entity)}GetInstanceTypeName(e){return this.GetEntityTypeName(e.entity)}GetInstanceDocumentName(e){return this.GetEntityDocumentName(e.entity)}GetInstanceGlobalId(e){return this.GetString(this.Entities.GlobalId[e.entity])}GetInstanceParameters(e){return this.GetEntityParameters(e.entity)}GetDescriptorName(e){return this.GetString(this.Descriptors.Name[e])}GetDescriptorType(e){return this.Descriptors.Type[e]}GetDescriptorGroup(e){return this.GetString(this.Descriptors.Group[e])}GetDescriptorUnits(e){return this.GetString(this.Descriptors.Units[e])}*EntityIndices(){for(let e=0;e<this.EntityCount;e++)yield e}*InstanceIndices(){for(let e=0;e<this.InstanceCount;e++)yield e}*DescriptorIndices(){for(let e=0;e<this.DescriptorCount;e++)yield e}first(e,t,n){for(const i of e)if(t(i))return i;return n}FindDescriptor(e){return this.first(this.DescriptorIndices(),t=>this.GetDescriptorName(t)==e,-1)}}class AT{constructor(e){Q(this,"Resolver");this.Data=e,this.Resolver=new xT(e)}FuncToInstances(e){const t=new Map;for(const n of this.Resolver.Data.Instances){if(!n)continue;const i=e(n);let s=t.get(i);s?s.push(n):t.set(i,[n])}return t}CategoryToInstances(){return this.FuncToInstances(e=>this.Resolver.GetInstanceCategoryName(e))}GlobalIdToInstances(){return this.FuncToInstances(e=>this.Resolver.GetInstanceGlobalId(e))}GetLevelFromParameters(e){if(!e)return null;let t=e.find(n=>n.Name=="Rvt:Element:Level");return t?String(t.Value):""}LevelToInstances(){return this.FuncToInstances(e=>this.GetLevelFromParameters(this.Resolver.GetInstanceParameters(e)))}}class bT{async load(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch BOS from ${e}: ${n.status} ${n.statusText}`);const i=await n.arrayBuffer(),s=await jS.loadAsync(i),a=await Zg(s,t);return a.Instances=mT(a.BimGeometry),a.Query=new AT(a),a.Resolver=a.Query.Resolver,a.ThreeGeometry=Xg(a.Instances),a}}async function Zg(r,e){function t(a){const o=a.toLowerCase(),c=Object.keys(r.files).find(l=>l.toLowerCase().endsWith(o));if(!c)throw new Error(`Could not find "${a}" in zip archive.`);return c}async function n(a,o,c=void 0,l=!1){let h;try{h=t(a+".parquet")}catch(d){if(l)return;throw d}if(!h){if(l)return;throw new Error(`Could not find "${a}.parquet" in zip archive.`)}const u=await r.files[h].async("arraybuffer"),f=await lg(u);if(Number(f.num_rows)===0){for(const d of f.schema)d.name&&d.type!==void 0&&(o[d.name]=c?new c(0):[]);return}await zM({file:u,compressors:lT,metadata:f,onChunk(d){let m=d.columnData;const g=typeof(m?.length?m[0]:void 0)=="bigint";c&&m.constructor.name!=c.name&&!g&&(m=new c(m)),o[d.columnName]=m}})}console.time("Reading parquet tables");const i=new yT,s={};return await n("Instances",s,Int32Array),await n("VertexBuffer",s,Int32Array),await n("IndexBuffer",s,Uint32Array),await n("Meshes",s,Int32Array),await n("Materials",s,Uint8Array),await n("Transforms",s,Float32Array),i.BimGeometry=s,await n("Entities",i.Entities={},Int32Array),e&&e.loadParameters&&(await n("Descriptors",i.Descriptors={}),await n("IntegerParameters",i.IntegerParameters={},Int32Array),await n("SingleParameters",i.SingleParameters={},Int32Array),await n("StringParameters",i.StringParameters={},Int32Array),await n("EntityParameters",i.EntityParameters={},Int32Array),await n("PointParameters",i.PointParameters={},Int32Array)),await n("Strings",i),i}Ut.BimOpenSchemaLoader=bT,Ut.DefaultInputScheme=Nm,Ut.GizmoOptions=vw,Ut.GltfLoader=KS,Ut.KEYS=At,Ut.THREE=nw,Ut.Viewer=fS,Ut.getSettings=Tm,Ut.loadBimGeometryFromZip=Zg,Object.defineProperties(Ut,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
5020
5020
  //# sourceMappingURL=ara3d-webgl.umd.js.map