endset_three_editor 0.1.3 → 0.1.4

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.
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),r=require("three"),mt=require("@tweenjs/tween.js");function gt(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const O=gt(r),Fe={type:"change"},De={type:"start"},it={type:"end"},ge=new r.Ray,He=new r.Plane,yt=Math.cos(70*r.MathUtils.DEG2RAD),C=new r.Vector3,j=2*Math.PI,R={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},xe=1e-6;class _t extends r.Controls{constructor(e,t=null){super(e,t),this.state=R.NONE,this.target=new r.Vector3,this.cursor=new r.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:r.MOUSE.ROTATE,MIDDLE:r.MOUSE.DOLLY,RIGHT:r.MOUSE.PAN},this.touches={ONE:r.TOUCH.ROTATE,TWO:r.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new r.Vector3,this._lastQuaternion=new r.Quaternion,this._lastTargetPosition=new r.Vector3,this._quat=new r.Quaternion().setFromUnitVectors(e.up,new r.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new r.Spherical,this._sphericalDelta=new r.Spherical,this._scale=1,this._panOffset=new r.Vector3,this._rotateStart=new r.Vector2,this._rotateEnd=new r.Vector2,this._rotateDelta=new r.Vector2,this._panStart=new r.Vector2,this._panEnd=new r.Vector2,this._panDelta=new r.Vector2,this._dollyStart=new r.Vector2,this._dollyEnd=new r.Vector2,this._dollyDelta=new r.Vector2,this._dollyDirection=new r.Vector3,this._mouse=new r.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=wt.bind(this),this._onPointerDown=bt.bind(this),this._onPointerUp=Tt.bind(this),this._onContextMenu=At.bind(this),this._onMouseWheel=xt.bind(this),this._onKeyDown=St.bind(this),this._onTouchStart=vt.bind(this),this._onTouchMove=Rt.bind(this),this._onMouseDown=Mt.bind(this),this._onMouseMove=Et.bind(this),this._interceptControlDown=Pt.bind(this),this._interceptControlUp=Lt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Fe),this.update(),this.state=R.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;C.copy(t).sub(this.target),C.applyQuaternion(this._quat),this._spherical.setFromVector3(C),this.autoRotate&&this.state===R.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=j:s>Math.PI&&(s-=j),n<-Math.PI?n+=j:n>Math.PI&&(n-=j),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(C.setFromSpherical(this._spherical),C.applyQuaternion(this._quatInverse),t.copy(this.target).add(C),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const l=C.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),i=!!c}else if(this.object.isOrthographicCamera){const l=new r.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=c!==this.object.zoom;const u=new r.Vector3(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=C.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(ge.origin.copy(this.object.position),ge.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ge.direction))<yt?this.object.lookAt(this.target):(He.setFromNormalAndCoplanarPoint(this.object.up,this.target),ge.intersectPlane(He,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>xe||8*(1-this._lastQuaternion.dot(this.object.quaternion))>xe||this._lastTargetPosition.distanceToSquared(this.target)>xe?(this.dispatchEvent(Fe),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?j/60*this.autoRotateSpeed*e:j/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){C.setFromMatrixColumn(t,0),C.multiplyScalar(-e),this._panOffset.add(C)}_panUp(e,t){this.screenSpacePanning===!0?C.setFromMatrixColumn(t,1):(C.setFromMatrixColumn(t,0),C.crossVectors(this.object.up,C)),C.multiplyScalar(e),this._panOffset.add(C)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;C.copy(n).sub(this.target);let i=C.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/s.clientHeight,this.object.matrix),this._panUp(2*t*i/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),n=e-s.left,i=t-s.top,o=s.width,l=s.height;this._mouse.x=n/o*2-1,this._mouse.y=-(i/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(j*this._rotateDelta.x/t.clientHeight),this._rotateUp(j*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(j*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-j*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(j*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-j*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),i=.5*(e.pageY+s.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(j*this._rotateDelta.x/t.clientHeight),this._rotateUp(j*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(o,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new r.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function bt(a){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(a.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(a)&&(this._addPointer(a),a.pointerType==="touch"?this._onTouchStart(a):this._onMouseDown(a),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function wt(a){this.enabled!==!1&&(a.pointerType==="touch"?this._onTouchMove(a):this._onMouseMove(a))}function Tt(a){switch(this._removePointer(a),this._pointers.length){case 0:this.domElement.releasePointerCapture(a.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(it),this.state=R.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Mt(a){let e;switch(a.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case r.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(a),this.state=R.DOLLY;break;case r.MOUSE.ROTATE:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=R.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=R.ROTATE}break;case r.MOUSE.PAN:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=R.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=R.PAN}break;default:this.state=R.NONE}this.state!==R.NONE&&this.dispatchEvent(De)}function Et(a){switch(this.state){case R.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(a);break;case R.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(a);break;case R.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(a);break}}function xt(a){this.enabled===!1||this.enableZoom===!1||this.state!==R.NONE||(a.preventDefault(),this.dispatchEvent(De),this._handleMouseWheel(this._customWheelEvent(a)),this.dispatchEvent(it))}function St(a){this.enabled!==!1&&this._handleKeyDown(a)}function vt(a){switch(this._trackPointer(a),this._pointers.length){case 1:switch(this.touches.ONE){case r.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(a),this.state=R.TOUCH_ROTATE;break;case r.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(a),this.state=R.TOUCH_PAN;break;default:this.state=R.NONE}break;case 2:switch(this.touches.TWO){case r.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(a),this.state=R.TOUCH_DOLLY_PAN;break;case r.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(a),this.state=R.TOUCH_DOLLY_ROTATE;break;default:this.state=R.NONE}break;default:this.state=R.NONE}this.state!==R.NONE&&this.dispatchEvent(De)}function Rt(a){switch(this._trackPointer(a),this.state){case R.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(a),this.update();break;case R.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(a),this.update();break;case R.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(a),this.update();break;case R.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(a),this.update();break;default:this.state=R.NONE}}function At(a){this.enabled!==!1&&a.preventDefault()}function Pt(a){a.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Lt(a){a.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const $=new r.Raycaster,k=new r.Vector3,Q=new r.Vector3,N=new r.Quaternion,Ge={X:new r.Vector3(1,0,0),Y:new r.Vector3(0,1,0),Z:new r.Vector3(0,0,1)},Se={type:"change"},Be={type:"mouseDown",mode:null},Ue={type:"mouseUp",mode:null},ze={type:"objectChange"};class Nt extends r.Controls{constructor(e,t=null){super(void 0,t);const s=new Vt(this);this._root=s;const n=new jt;this._gizmo=n,s.add(n);const i=new Ft;this._plane=i,s.add(i);const o=this;function l(E,x){let P=x;Object.defineProperty(o,E,{get:function(){return P!==void 0?P:x},set:function(S){P!==S&&(P=S,i[E]=S,n[E]=S,o.dispatchEvent({type:E+"-changed",value:S}),o.dispatchEvent(Se))}}),o[E]=x,i[E]=x,n[E]=x}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0),l("showXY",!0),l("showYZ",!0),l("showXZ",!0),l("minX",-1/0),l("maxX",1/0),l("minY",-1/0),l("maxY",1/0),l("minZ",-1/0),l("maxZ",1/0);const c=new r.Vector3,u=new r.Vector3,p=new r.Quaternion,h=new r.Quaternion,f=new r.Vector3,m=new r.Quaternion,g=new r.Vector3,y=new r.Vector3,_=new r.Vector3,b=0,M=new r.Vector3;l("worldPosition",c),l("worldPositionStart",u),l("worldQuaternion",p),l("worldQuaternionStart",h),l("cameraPosition",f),l("cameraQuaternion",m),l("pointStart",g),l("pointEnd",y),l("rotationAxis",_),l("rotationAngle",b),l("eye",M),this._offset=new r.Vector3,this._startNorm=new r.Vector3,this._endNorm=new r.Vector3,this._cameraScale=new r.Vector3,this._parentPosition=new r.Vector3,this._parentQuaternion=new r.Quaternion,this._parentQuaternionInv=new r.Quaternion,this._parentScale=new r.Vector3,this._worldScaleStart=new r.Vector3,this._worldQuaternionInv=new r.Quaternion,this._worldScale=new r.Vector3,this._positionStart=new r.Vector3,this._quaternionStart=new r.Quaternion,this._scaleStart=new r.Vector3,this._getPointer=It.bind(this),this._onPointerDown=Ot.bind(this),this._onPointerHover=Ct.bind(this),this._onPointerMove=Dt.bind(this),this._onPointerUp=kt.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction=""}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&$.setFromCamera(e,this.camera);const t=ve(this._gizmo.picker[this.mode],$);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&$.setFromCamera(e,this.camera);const t=ve(this._plane,$,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Be.mode=this.mode,this.dispatchEvent(Be)}}pointerMove(e){const t=this.axis,s=this.mode,n=this.object;let i=this.space;if(s==="scale"?i="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(i="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&$.setFromCamera(e,this.camera);const o=ve(this._plane,$,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),i==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),i==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(i==="local"&&(n.position.applyQuaternion(N.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),i==="world"&&(n.parent&&n.position.add(k.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(k.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if(s==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Q.set(l,l,l)}else k.copy(this.pointStart),Q.copy(this.pointEnd),k.applyQuaternion(this._worldQuaternionInv),Q.applyQuaternion(this._worldQuaternionInv),Q.divide(k),t.search("X")===-1&&(Q.x=1),t.search("Y")===-1&&(Q.y=1),t.search("Z")===-1&&(Q.z=1);n.scale.copy(this._scaleStart).multiply(Q),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(k.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(k.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Ge[t]),k.copy(Ge[t]),i==="local"&&k.applyQuaternion(this.worldQuaternion),k.cross(this.eye),k.length()===0?c=!0:this.rotationAngle=this._offset.dot(k.normalize())*l),(t==="E"||c)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(N.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(N.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Se),this.dispatchEvent(ze)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Ue.mode=this.mode,this.dispatchEvent(Ue)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Se),this.dispatchEvent(ze),this.pointStart.copy(this.pointEnd))}getRaycaster(){return $}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,s,n){const i=this._gizmo.materialLib;i.xAxis.color.set(e),i.yAxis.color.set(t),i.zAxis.color.set(s),i.active.color.set(n),i.xAxisTransparent.color.set(e),i.yAxisTransparent.color.set(t),i.zAxisTransparent.color.set(s),i.activeTransparent.color.set(n),i.xAxis._color&&i.xAxis._color.set(e),i.yAxis._color&&i.yAxis._color.set(t),i.zAxis._color&&i.zAxis._color.set(s),i.active._color&&i.active._color.set(n),i.xAxisTransparent._color&&i.xAxisTransparent._color.set(e),i.yAxisTransparent._color&&i.yAxisTransparent._color.set(t),i.zAxisTransparent._color&&i.zAxisTransparent._color.set(s),i.activeTransparent._color&&i.activeTransparent._color.set(n)}}function It(a){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};{const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-(a.clientY-e.top)/e.height*2+1,button:a.button}}}function Ct(a){if(this.enabled)switch(a.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(a));break}}function Ot(a){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(a.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(a)),this.pointerDown(this._getPointer(a)))}function Dt(a){this.enabled&&this.pointerMove(this._getPointer(a))}function kt(a){this.enabled&&(this.domElement.releasePointerCapture(a.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(a)))}function ve(a,e,t){const s=e.intersectObject(a,!0);for(let n=0;n<s.length;n++)if(s[n].object.visible||t)return s[n];return!1}const ye=new r.Euler,A=new r.Vector3(0,1,0),Xe=new r.Vector3(0,0,0),Ye=new r.Matrix4,_e=new r.Quaternion,Te=new r.Quaternion,X=new r.Vector3,Ke=new r.Matrix4,ce=new r.Vector3(1,0,0),ee=new r.Vector3(0,1,0),he=new r.Vector3(0,0,1),be=new r.Vector3,re=new r.Vector3,ae=new r.Vector3;class Vt extends r.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class jt extends r.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new r.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new r.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const n=t.clone();n.opacity=.5;const i=e.clone();i.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const l=e.clone();l.color.setHex(255);const c=e.clone();c.color.setHex(16711680),c.opacity=.5;const u=e.clone();u.color.setHex(65280),u.opacity=.5;const p=e.clone();p.color.setHex(255),p.opacity=.5;const h=e.clone();h.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25;const m=e.clone();m.color.setHex(16776960);const g=e.clone();g.color.setHex(7895160),this.materialLib={xAxis:i,yAxis:o,zAxis:l,active:m,xAxisTransparent:c,yAxisTransparent:u,zAxisTransparent:p,activeTransparent:f};const y=new r.CylinderGeometry(0,.04,.1,12);y.translate(0,.05,0);const _=new r.BoxGeometry(.08,.08,.08);_.translate(0,.04,0);const b=new r.BufferGeometry;b.setAttribute("position",new r.Float32BufferAttribute([0,0,0,1,0,0],3));const M=new r.CylinderGeometry(.0075,.0075,.5,3);M.translate(0,.25,0);function E(F,de){const U=new r.TorusGeometry(F,.0075,3,64,de*Math.PI*2);return U.rotateY(Math.PI/2),U.rotateX(Math.PI/2),U}function x(){const F=new r.BufferGeometry;return F.setAttribute("position",new r.Float32BufferAttribute([0,0,0,1,1,1],3)),F}const P={X:[[new r.Mesh(y,i),[.5,0,0],[0,0,-Math.PI/2]],[new r.Mesh(y,i),[-.5,0,0],[0,0,Math.PI/2]],[new r.Mesh(M,i),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new r.Mesh(y,o),[0,.5,0]],[new r.Mesh(y,o),[0,-.5,0],[Math.PI,0,0]],[new r.Mesh(M,o)]],Z:[[new r.Mesh(y,l),[0,0,.5],[Math.PI/2,0,0]],[new r.Mesh(y,l),[0,0,-.5],[-Math.PI/2,0,0]],[new r.Mesh(M,l),null,[Math.PI/2,0,0]]],XYZ:[[new r.Mesh(new r.OctahedronGeometry(.1,0),h),[0,0,0]]],XY:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),u),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new r.Mesh(new r.OctahedronGeometry(.2,0),s)]],XY:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},L={START:[[new r.Mesh(new r.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new r.Mesh(new r.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new r.Line(x(),n),null,null,null,"helper"]],X:[[new r.Line(b,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new r.Line(b,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new r.Line(b,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},K={XYZE:[[new r.Mesh(E(.5,1),g),null,[0,Math.PI/2,0]]],X:[[new r.Mesh(E(.5,.5),i)]],Y:[[new r.Mesh(E(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new r.Mesh(E(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new r.Mesh(E(.75,1),f),null,[0,Math.PI/2,0]]]},z={AXIS:[[new r.Line(b,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},W={XYZE:[[new r.Mesh(new r.SphereGeometry(.25,10,8),s)]],X:[[new r.Mesh(new r.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new r.Mesh(new r.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new r.Mesh(new r.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new r.Mesh(new r.TorusGeometry(.75,.1,2,24),s)]]},B={X:[[new r.Mesh(_,i),[.5,0,0],[0,0,-Math.PI/2]],[new r.Mesh(M,i),[0,0,0],[0,0,-Math.PI/2]],[new r.Mesh(_,i),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new r.Mesh(_,o),[0,.5,0]],[new r.Mesh(M,o)],[new r.Mesh(_,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new r.Mesh(_,l),[0,0,.5],[Math.PI/2,0,0]],[new r.Mesh(M,l),[0,0,0],[Math.PI/2,0,0]],[new r.Mesh(_,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),u),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new r.Mesh(new r.BoxGeometry(.1,.1,.1),h)]]},T={X:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},D={X:[[new r.Line(b,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new r.Line(b,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new r.Line(b,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Z(F){const de=new r.Object3D;for(const U in F)for(let se=F[U].length;se--;){const V=F[U][se][0].clone(),pe=F[U][se][1],fe=F[U][se][2],me=F[U][se][3],ft=F[U][se][4];V.name=U,V.tag=ft,pe&&V.position.set(pe[0],pe[1],pe[2]),fe&&V.rotation.set(fe[0],fe[1],fe[2]),me&&V.scale.set(me[0],me[1],me[2]),V.updateMatrix();const je=V.geometry.clone();je.applyMatrix4(V.matrix),V.geometry=je,V.renderOrder=1/0,V.position.set(0,0,0),V.rotation.set(0,0,0),V.scale.set(1,1,1),de.add(V)}return de}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Z(P)),this.add(this.gizmo.rotate=Z(K)),this.add(this.gizmo.scale=Z(B)),this.add(this.picker.translate=Z(S)),this.add(this.picker.rotate=Z(W)),this.add(this.picker.scale=Z(T)),this.add(this.helper.translate=Z(L)),this.add(this.helper.rotate=Z(z)),this.add(this.helper.scale=Z(D)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Te;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let i=0;i<n.length;i++){const o=n[i];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(l*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(N.setFromEuler(ye.set(0,0,0)),o.quaternion.copy(s).multiply(N),Math.abs(A.copy(ce).applyQuaternion(s).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(N.setFromEuler(ye.set(0,0,Math.PI/2)),o.quaternion.copy(s).multiply(N),Math.abs(A.copy(ee).applyQuaternion(s).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(N.setFromEuler(ye.set(0,Math.PI/2,0)),o.quaternion.copy(s).multiply(N),Math.abs(A.copy(he).applyQuaternion(s).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(N.setFromEuler(ye.set(0,Math.PI/2,0)),A.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(Ye.lookAt(Xe,A,ee)),o.quaternion.multiply(N),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),k.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),k.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(k),o.visible=this.dragging):(o.quaternion.copy(s),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(A.copy(ce).applyQuaternion(s).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(A.copy(ee).applyQuaternion(s).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(A.copy(he).applyQuaternion(s).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(A.copy(he).applyQuaternion(s).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(A.copy(ce).applyQuaternion(s).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(A.copy(ee).applyQuaternion(s).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(_e.copy(s),A.copy(this.eye).applyQuaternion(N.copy(s).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(Ye.lookAt(this.eye,Xe,ee)),o.name==="X"&&(N.setFromAxisAngle(ce,Math.atan2(-A.y,A.z)),N.multiplyQuaternions(_e,N),o.quaternion.copy(N)),o.name==="Y"&&(N.setFromAxisAngle(ee,Math.atan2(A.x,A.z)),N.multiplyQuaternions(_e,N),o.quaternion.copy(N)),o.name==="Z"&&(N.setFromAxisAngle(he,Math.atan2(A.y,A.x)),N.multiplyQuaternions(_e,N),o.quaternion.copy(N))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.visible=o.visible&&(o.name.indexOf("XY")===-1||this.showXY),o.visible=o.visible&&(o.name.indexOf("YZ")===-1||this.showYZ),o.visible=o.visible&&(o.name.indexOf("XZ")===-1||this.showXZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(c){return o.name===c})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class Ft extends r.Mesh{constructor(){super(new r.PlaneGeometry(1e5,1e5,2,2),new r.MeshBasicMaterial({visible:!1,wireframe:!0,side:r.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),be.copy(ce).applyQuaternion(t==="local"?this.worldQuaternion:Te),re.copy(ee).applyQuaternion(t==="local"?this.worldQuaternion:Te),ae.copy(he).applyQuaternion(t==="local"?this.worldQuaternion:Te),A.copy(re),this.mode){case"translate":case"scale":switch(this.axis){case"X":A.copy(this.eye).cross(be),X.copy(be).cross(A);break;case"Y":A.copy(this.eye).cross(re),X.copy(re).cross(A);break;case"Z":A.copy(this.eye).cross(ae),X.copy(ae).cross(A);break;case"XY":X.copy(ae);break;case"YZ":X.copy(be);break;case"XZ":A.copy(ae),X.copy(re);break;case"XYZ":case"E":X.set(0,0,0);break}break;case"rotate":default:X.set(0,0,0)}X.length()===0?this.quaternion.copy(this.cameraQuaternion):(Ke.lookAt(k.set(0,0,0),X,A),this.quaternion.setFromRotationMatrix(Ke)),super.updateMatrixWorld(e)}}const w={scene:null,camera:null,renderer:null,orbitControls:null,transformControls:null,container:null,gridHelper:null,selectedObject:null};let Re=!1,oe=!1,te=null,Ie=null,Me=null,ne=[];function Ht(a){w.container=a,Gt(),Bt(),Ut(),zt(),Yt(),Xt(),en(),Kt(),ot(),a.addEventListener("click",Qt),window.addEventListener("resize",Zt)}function Gt(){const a=new O.WebGLRenderer({antialias:!0,alpha:!0});a.setSize(w.container.clientWidth,w.container.clientHeight),a.setPixelRatio(Math.min(window.devicePixelRatio,2)),w.container.appendChild(a.domElement),w.renderer=a}function Bt(){w.scene=new O.Scene,w.scene.name="sl_scene"}function Ut(){const a=new O.GridHelper(30,30,8956671,3364232);a.name="地板",w.scene.add(a),w.gridHelper=a}function zt(){const a=w.container,e=a.clientWidth/a.clientHeight,t=new O.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),w.camera=t}function Xt(){const a=new _t(w.camera,w.renderer.domElement);a.minDistance=0,a.maxDistance=1/0,a.addEventListener("start",()=>{Re=!1}),a.addEventListener("change",()=>{Re=!0}),a.addEventListener("end",()=>{Re&&(oe=!0,setTimeout(()=>{oe=!1},200))}),w.orbitControls=a}function Yt(){const a=new Nt(w.camera,w.renderer.domElement);a.addEventListener("dragging-changed",e=>{w.orbitControls.enabled=!e.value,e.value||(oe=!0,setTimeout(()=>{oe=!1},200))}),a.addEventListener("objectChange",()=>{Ie&&w.selectedObject&&Ie(w.selectedObject)}),w.scene.add(a.getHelper()),w.transformControls=a}function Kt(){const a=new O.AmbientLight(16777215,2);w.scene.add(a);const e=new O.DirectionalLight(16777215,3);e.position.set(48,104,138),w.scene.add(e);const t=new O.BoxGeometry(1,1,1),s=new O.MeshStandardMaterial({color:16777215}),n=new O.Mesh(t,s);n.position.y=1,n.userData.isMovable=!0,n.name="默认立方体",Ee(n,!0)}function ot(){var a,e;requestAnimationFrame(ot),mt.update(),(a=w.orbitControls)==null||a.update(),(e=w.renderer)==null||e.render(w.scene,w.camera)}function Zt(){if(!w.container||!w.camera||!w.renderer)return;const a=w.container.clientWidth,e=w.container.clientHeight;a===0||e===0||(w.camera.aspect=a/e,w.camera.updateProjectionMatrix(),w.renderer.setSize(a,e))}function ke(a){w.selectedObject!==a&&(w.selectedObject&&w.transformControls.detach(),w.selectedObject=a,w.transformControls.attach(a),w.transformControls.setMode("translate"),w.transformControls.showX=!0,w.transformControls.showY=!0,w.transformControls.showZ=!0,te==null||te(a))}function rt(){w.selectedObject&&(w.transformControls.detach(),w.selectedObject=null,te==null||te(null))}function Qt(a){if(oe){oe=!1;return}const e=w.renderer.domElement.getBoundingClientRect(),t=new O.Vector2((a.clientX-e.left)/e.width*2-1,-((a.clientY-e.top)/e.height)*2+1),s=new O.Raycaster;s.setFromCamera(t,w.camera);const n=[];w.scene.traverse(o=>{o.type==="Mesh"&&o.userData.isMovable&&n.push(o)});const i=s.intersectObjects(n);i.length>0?ke(i[0].object):rt()}function Ee(a,e=!1){w.scene.add(a),a.userData.isMovable&&($t(a),Ve()),e&&ke(a)}function qt(a){w.selectedObject===a&&rt(),a.parent?a.parent.remove(a):w.scene.remove(a),Jt(a),Ve()}function Wt(a){const e=w.scene.getObjectByProperty("uuid",a);e&&qt(e)}function $t(a){a.userData.isMovable&&a.parent===w.scene&&(ne.includes(a)||ne.push(a))}function Jt(a){const e=ne.indexOf(a);e!==-1&&ne.splice(e,1)}function en(){const a=[];w.scene.children.forEach(e=>{e.userData.isMovable&&a.push(e)}),ne=a,Ve()}function Ve(){Me==null||Me([...ne])}function tn(a){te=a}function nn(a){Ie=a}function sn(a){Me=a}function on(){return ne}const rn=/^[og]\s*(.+)?/,an=/^mtllib /,ln=/^usemtl /,cn=/^usemap /,Ze=/\s+/,Qe=new r.Vector3,Ae=new r.Vector3,qe=new r.Vector3,We=new r.Vector3,H=new r.Vector3,we=new r.Color;function hn(){const a={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const s=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(n,i){const o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);const l={index:this.materials.length,name:n||"",mtllib:Array.isArray(i)&&i.length>0?i[i.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const u={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return u.clone=this.clone.bind(u),u}};return this.materials.push(l),l},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(n){const i=this.currentMaterial();if(i&&i.groupEnd===-1&&(i.groupEnd=this.geometry.vertices.length/3,i.groupCount=i.groupEnd-i.groupStart,i.inherited=!1),n&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),i}},s&&s.name&&typeof s.clone=="function"){const n=s.clone(0);n.inherited=!0,this.object.materials.push(n)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseNormalIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseUVIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/2)*2},addVertex:function(e,t,s){const n=this.vertices,i=this.object.geometry.vertices;i.push(n[e+0],n[e+1],n[e+2]),i.push(n[t+0],n[t+1],n[t+2]),i.push(n[s+0],n[s+1],n[s+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,s){const n=this.normals,i=this.object.geometry.normals;i.push(n[e+0],n[e+1],n[e+2]),i.push(n[t+0],n[t+1],n[t+2]),i.push(n[s+0],n[s+1],n[s+2])},addFaceNormal:function(e,t,s){const n=this.vertices,i=this.object.geometry.normals;Qe.fromArray(n,e),Ae.fromArray(n,t),qe.fromArray(n,s),H.subVectors(qe,Ae),We.subVectors(Qe,Ae),H.cross(We),H.normalize(),i.push(H.x,H.y,H.z),i.push(H.x,H.y,H.z),i.push(H.x,H.y,H.z)},addColor:function(e,t,s){const n=this.colors,i=this.object.geometry.colors;n[e]!==void 0&&i.push(n[e+0],n[e+1],n[e+2]),n[t]!==void 0&&i.push(n[t+0],n[t+1],n[t+2]),n[s]!==void 0&&i.push(n[s+0],n[s+1],n[s+2])},addUV:function(e,t,s){const n=this.uvs,i=this.object.geometry.uvs;i.push(n[e+0],n[e+1]),i.push(n[t+0],n[t+1]),i.push(n[s+0],n[s+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,s,n,i,o,l,c,u){const p=this.vertices.length;let h=this.parseVertexIndex(e,p),f=this.parseVertexIndex(t,p),m=this.parseVertexIndex(s,p);if(this.addVertex(h,f,m),this.addColor(h,f,m),l!==void 0&&l!==""){const g=this.normals.length;h=this.parseNormalIndex(l,g),f=this.parseNormalIndex(c,g),m=this.parseNormalIndex(u,g),this.addNormal(h,f,m)}else this.addFaceNormal(h,f,m);if(n!==void 0&&n!==""){const g=this.uvs.length;h=this.parseUVIndex(n,g),f=this.parseUVIndex(i,g),m=this.parseUVIndex(o,g),this.addUV(h,f,m),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let s=0,n=e.length;s<n;s++){const i=this.parseVertexIndex(e[s],t);this.addVertexPoint(i),this.addColor(i)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const s=this.vertices.length,n=this.uvs.length;for(let i=0,o=e.length;i<o;i++)this.addVertexLine(this.parseVertexIndex(e[i],s));for(let i=0,o=t.length;i<o;i++)this.addUVLine(this.parseUVIndex(t[i],n))}};return a.startObject("",!1),a}class un extends r.Loader{constructor(e){super(e),this.materials=null}load(e,t,s,n){const i=this,o=new r.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{t(i.parse(l))}catch(c){n?n(c):console.error(c),i.manager.itemError(e)}},s,n)}setMaterials(e){return this.materials=e,this}parse(e){const t=new hn;e.indexOf(`\r
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),r=require("three"),Rt=require("@tweenjs/tween.js");function At(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const O=At(r),Fe={type:"change"},ke={type:"start"},ot={type:"end"},ye=new r.Ray,He=new r.Plane,Pt=Math.cos(70*r.MathUtils.DEG2RAD),N=new r.Vector3,j=2*Math.PI,R={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Se=1e-6;class Lt extends r.Controls{constructor(e,t=null){super(e,t),this.state=R.NONE,this.target=new r.Vector3,this.cursor=new r.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:r.MOUSE.ROTATE,MIDDLE:r.MOUSE.DOLLY,RIGHT:r.MOUSE.PAN},this.touches={ONE:r.TOUCH.ROTATE,TWO:r.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new r.Vector3,this._lastQuaternion=new r.Quaternion,this._lastTargetPosition=new r.Vector3,this._quat=new r.Quaternion().setFromUnitVectors(e.up,new r.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new r.Spherical,this._sphericalDelta=new r.Spherical,this._scale=1,this._panOffset=new r.Vector3,this._rotateStart=new r.Vector2,this._rotateEnd=new r.Vector2,this._rotateDelta=new r.Vector2,this._panStart=new r.Vector2,this._panEnd=new r.Vector2,this._panDelta=new r.Vector2,this._dollyStart=new r.Vector2,this._dollyEnd=new r.Vector2,this._dollyDelta=new r.Vector2,this._dollyDirection=new r.Vector3,this._mouse=new r.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=It.bind(this),this._onPointerDown=Ct.bind(this),this._onPointerUp=Nt.bind(this),this._onContextMenu=Ht.bind(this),this._onMouseWheel=kt.bind(this),this._onKeyDown=Vt.bind(this),this._onTouchStart=jt.bind(this),this._onTouchMove=Ft.bind(this),this._onMouseDown=Ot.bind(this),this._onMouseMove=Dt.bind(this),this._interceptControlDown=Bt.bind(this),this._interceptControlUp=Gt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Fe),this.update(),this.state=R.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;N.copy(t).sub(this.target),N.applyQuaternion(this._quat),this._spherical.setFromVector3(N),this.autoRotate&&this.state===R.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=j:s>Math.PI&&(s-=j),n<-Math.PI?n+=j:n>Math.PI&&(n-=j),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const i=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=i!=this._spherical.radius}if(N.setFromSpherical(this._spherical),N.applyQuaternion(this._quatInverse),t.copy(this.target).add(N),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let i=null;if(this.object.isPerspectiveCamera){const l=N.length();i=this._clampDistance(l*this._scale);const c=l-i;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),o=!!c}else if(this.object.isOrthographicCamera){const l=new r.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=c!==this.object.zoom;const u=new r.Vector3(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),i=N.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;i!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(i).add(this.object.position):(ye.origin.copy(this.object.position),ye.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ye.direction))<Pt?this.object.lookAt(this.target):(He.setFromNormalAndCoplanarPoint(this.object.up,this.target),ye.intersectPlane(He,this.target))))}else if(this.object.isOrthographicCamera){const i=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),i!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>Se||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Se||this._lastTargetPosition.distanceToSquared(this.target)>Se?(this.dispatchEvent(Fe),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?j/60*this.autoRotateSpeed*e:j/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){N.setFromMatrixColumn(t,0),N.multiplyScalar(-e),this._panOffset.add(N)}_panUp(e,t){this.screenSpacePanning===!0?N.setFromMatrixColumn(t,1):(N.setFromMatrixColumn(t,0),N.crossVectors(this.object.up,N)),N.multiplyScalar(e),this._panOffset.add(N)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;N.copy(n).sub(this.target);let o=N.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/s.clientHeight,this.object.matrix),this._panUp(2*t*o/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),n=e-s.left,o=t-s.top,i=s.width,l=s.height;this._mouse.x=n/i*2-1,this._mouse.y=-(o/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(j*this._rotateDelta.x/t.clientHeight),this._rotateUp(j*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(j*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-j*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(j*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-j*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,o=Math.sqrt(s*s+n*n);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),o=.5*(e.pageY+s.y);this._rotateEnd.set(n,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(j*this._rotateDelta.x/t.clientHeight),this._rotateUp(j*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,o=Math.sqrt(s*s+n*n);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const i=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(i,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new r.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function Ct(a){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(a.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(a)&&(this._addPointer(a),a.pointerType==="touch"?this._onTouchStart(a):this._onMouseDown(a),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function It(a){this.enabled!==!1&&(a.pointerType==="touch"?this._onTouchMove(a):this._onMouseMove(a))}function Nt(a){switch(this._removePointer(a),this._pointers.length){case 0:this.domElement.releasePointerCapture(a.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ot),this.state=R.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Ot(a){let e;switch(a.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case r.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(a),this.state=R.DOLLY;break;case r.MOUSE.ROTATE:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=R.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=R.ROTATE}break;case r.MOUSE.PAN:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=R.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=R.PAN}break;default:this.state=R.NONE}this.state!==R.NONE&&this.dispatchEvent(ke)}function Dt(a){switch(this.state){case R.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(a);break;case R.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(a);break;case R.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(a);break}}function kt(a){this.enabled===!1||this.enableZoom===!1||this.state!==R.NONE||(a.preventDefault(),this.dispatchEvent(ke),this._handleMouseWheel(this._customWheelEvent(a)),this.dispatchEvent(ot))}function Vt(a){this.enabled!==!1&&this._handleKeyDown(a)}function jt(a){switch(this._trackPointer(a),this._pointers.length){case 1:switch(this.touches.ONE){case r.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(a),this.state=R.TOUCH_ROTATE;break;case r.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(a),this.state=R.TOUCH_PAN;break;default:this.state=R.NONE}break;case 2:switch(this.touches.TWO){case r.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(a),this.state=R.TOUCH_DOLLY_PAN;break;case r.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(a),this.state=R.TOUCH_DOLLY_ROTATE;break;default:this.state=R.NONE}break;default:this.state=R.NONE}this.state!==R.NONE&&this.dispatchEvent(ke)}function Ft(a){switch(this._trackPointer(a),this.state){case R.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(a),this.update();break;case R.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(a),this.update();break;case R.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(a),this.update();break;case R.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(a),this.update();break;default:this.state=R.NONE}}function Ht(a){this.enabled!==!1&&a.preventDefault()}function Bt(a){a.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Gt(a){a.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const $=new r.Raycaster,k=new r.Vector3,Q=new r.Vector3,C=new r.Quaternion,Be={X:new r.Vector3(1,0,0),Y:new r.Vector3(0,1,0),Z:new r.Vector3(0,0,1)},ve={type:"change"},Ge={type:"mouseDown",mode:null},Ue={type:"mouseUp",mode:null},ze={type:"objectChange"};class Ut extends r.Controls{constructor(e,t=null){super(void 0,t);const s=new Qt(this);this._root=s;const n=new qt;this._gizmo=n,s.add(n);const o=new Wt;this._plane=o,s.add(o);const i=this;function l(E,x){let P=x;Object.defineProperty(i,E,{get:function(){return P!==void 0?P:x},set:function(S){P!==S&&(P=S,o[E]=S,n[E]=S,i.dispatchEvent({type:E+"-changed",value:S}),i.dispatchEvent(ve))}}),i[E]=x,o[E]=x,n[E]=x}l("camera",e),l("object",void 0),l("enabled",!0),l("axis",null),l("mode","translate"),l("translationSnap",null),l("rotationSnap",null),l("scaleSnap",null),l("space","world"),l("size",1),l("dragging",!1),l("showX",!0),l("showY",!0),l("showZ",!0),l("showXY",!0),l("showYZ",!0),l("showXZ",!0),l("minX",-1/0),l("maxX",1/0),l("minY",-1/0),l("maxY",1/0),l("minZ",-1/0),l("maxZ",1/0);const c=new r.Vector3,u=new r.Vector3,p=new r.Quaternion,h=new r.Quaternion,f=new r.Vector3,m=new r.Quaternion,g=new r.Vector3,y=new r.Vector3,_=new r.Vector3,b=0,M=new r.Vector3;l("worldPosition",c),l("worldPositionStart",u),l("worldQuaternion",p),l("worldQuaternionStart",h),l("cameraPosition",f),l("cameraQuaternion",m),l("pointStart",g),l("pointEnd",y),l("rotationAxis",_),l("rotationAngle",b),l("eye",M),this._offset=new r.Vector3,this._startNorm=new r.Vector3,this._endNorm=new r.Vector3,this._cameraScale=new r.Vector3,this._parentPosition=new r.Vector3,this._parentQuaternion=new r.Quaternion,this._parentQuaternionInv=new r.Quaternion,this._parentScale=new r.Vector3,this._worldScaleStart=new r.Vector3,this._worldQuaternionInv=new r.Quaternion,this._worldScale=new r.Vector3,this._positionStart=new r.Vector3,this._quaternionStart=new r.Quaternion,this._scaleStart=new r.Vector3,this._getPointer=zt.bind(this),this._onPointerDown=Yt.bind(this),this._onPointerHover=Xt.bind(this),this._onPointerMove=Kt.bind(this),this._onPointerUp=Zt.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction=""}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&$.setFromCamera(e,this.camera);const t=Re(this._gizmo.picker[this.mode],$);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&$.setFromCamera(e,this.camera);const t=Re(this._plane,$,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Ge.mode=this.mode,this.dispatchEvent(Ge)}}pointerMove(e){const t=this.axis,s=this.mode,n=this.object;let o=this.space;if(s==="scale"?o="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(o="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&$.setFromCamera(e,this.camera);const i=Re(this._plane,$,!0);if(i){if(this.pointEnd.copy(i.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),o==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),o==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(o==="local"&&(n.position.applyQuaternion(C.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),o==="world"&&(n.parent&&n.position.add(k.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(k.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if(s==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Q.set(l,l,l)}else k.copy(this.pointStart),Q.copy(this.pointEnd),k.applyQuaternion(this._worldQuaternionInv),Q.applyQuaternion(this._worldQuaternionInv),Q.divide(k),t.search("X")===-1&&(Q.x=1),t.search("Y")===-1&&(Q.y=1),t.search("Z")===-1&&(Q.z=1);n.scale.copy(this._scaleStart).multiply(Q),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(k.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(k.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Be[t]),k.copy(Be[t]),o==="local"&&k.applyQuaternion(this.worldQuaternion),k.cross(this.eye),k.length()===0?c=!0:this.rotationAngle=this._offset.dot(k.normalize())*l),(t==="E"||c)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),o==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(C.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(C.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ve),this.dispatchEvent(ze)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(Ue.mode=this.mode,this.dispatchEvent(Ue)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ve),this.dispatchEvent(ze),this.pointStart.copy(this.pointEnd))}getRaycaster(){return $}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,s,n){const o=this._gizmo.materialLib;o.xAxis.color.set(e),o.yAxis.color.set(t),o.zAxis.color.set(s),o.active.color.set(n),o.xAxisTransparent.color.set(e),o.yAxisTransparent.color.set(t),o.zAxisTransparent.color.set(s),o.activeTransparent.color.set(n),o.xAxis._color&&o.xAxis._color.set(e),o.yAxis._color&&o.yAxis._color.set(t),o.zAxis._color&&o.zAxis._color.set(s),o.active._color&&o.active._color.set(n),o.xAxisTransparent._color&&o.xAxisTransparent._color.set(e),o.yAxisTransparent._color&&o.yAxisTransparent._color.set(t),o.zAxisTransparent._color&&o.zAxisTransparent._color.set(s),o.activeTransparent._color&&o.activeTransparent._color.set(n)}}function zt(a){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};{const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-(a.clientY-e.top)/e.height*2+1,button:a.button}}}function Xt(a){if(this.enabled)switch(a.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(a));break}}function Yt(a){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(a.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(a)),this.pointerDown(this._getPointer(a)))}function Kt(a){this.enabled&&this.pointerMove(this._getPointer(a))}function Zt(a){this.enabled&&(this.domElement.releasePointerCapture(a.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(a)))}function Re(a,e,t){const s=e.intersectObject(a,!0);for(let n=0;n<s.length;n++)if(s[n].object.visible||t)return s[n];return!1}const _e=new r.Euler,A=new r.Vector3(0,1,0),Xe=new r.Vector3(0,0,0),Ye=new r.Matrix4,be=new r.Quaternion,Me=new r.Quaternion,X=new r.Vector3,Ke=new r.Matrix4,ce=new r.Vector3(1,0,0),ee=new r.Vector3(0,1,0),he=new r.Vector3(0,0,1),we=new r.Vector3,re=new r.Vector3,ae=new r.Vector3;class Qt extends r.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class qt extends r.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new r.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new r.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const n=t.clone();n.opacity=.5;const o=e.clone();o.color.setHex(16711680);const i=e.clone();i.color.setHex(65280);const l=e.clone();l.color.setHex(255);const c=e.clone();c.color.setHex(16711680),c.opacity=.5;const u=e.clone();u.color.setHex(65280),u.opacity=.5;const p=e.clone();p.color.setHex(255),p.opacity=.5;const h=e.clone();h.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25;const m=e.clone();m.color.setHex(16776960);const g=e.clone();g.color.setHex(7895160),this.materialLib={xAxis:o,yAxis:i,zAxis:l,active:m,xAxisTransparent:c,yAxisTransparent:u,zAxisTransparent:p,activeTransparent:f};const y=new r.CylinderGeometry(0,.04,.1,12);y.translate(0,.05,0);const _=new r.BoxGeometry(.08,.08,.08);_.translate(0,.04,0);const b=new r.BufferGeometry;b.setAttribute("position",new r.Float32BufferAttribute([0,0,0,1,0,0],3));const M=new r.CylinderGeometry(.0075,.0075,.5,3);M.translate(0,.25,0);function E(F,pe){const U=new r.TorusGeometry(F,.0075,3,64,pe*Math.PI*2);return U.rotateY(Math.PI/2),U.rotateX(Math.PI/2),U}function x(){const F=new r.BufferGeometry;return F.setAttribute("position",new r.Float32BufferAttribute([0,0,0,1,1,1],3)),F}const P={X:[[new r.Mesh(y,o),[.5,0,0],[0,0,-Math.PI/2]],[new r.Mesh(y,o),[-.5,0,0],[0,0,Math.PI/2]],[new r.Mesh(M,o),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new r.Mesh(y,i),[0,.5,0]],[new r.Mesh(y,i),[0,-.5,0],[Math.PI,0,0]],[new r.Mesh(M,i)]],Z:[[new r.Mesh(y,l),[0,0,.5],[Math.PI/2,0,0]],[new r.Mesh(y,l),[0,0,-.5],[-Math.PI/2,0,0]],[new r.Mesh(M,l),null,[Math.PI/2,0,0]]],XYZ:[[new r.Mesh(new r.OctahedronGeometry(.1,0),h),[0,0,0]]],XY:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),u),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new r.Mesh(new r.OctahedronGeometry(.2,0),s)]],XY:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},L={START:[[new r.Mesh(new r.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new r.Mesh(new r.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new r.Line(x(),n),null,null,null,"helper"]],X:[[new r.Line(b,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new r.Line(b,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new r.Line(b,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},K={XYZE:[[new r.Mesh(E(.5,1),g),null,[0,Math.PI/2,0]]],X:[[new r.Mesh(E(.5,.5),o)]],Y:[[new r.Mesh(E(.5,.5),i),null,[0,0,-Math.PI/2]]],Z:[[new r.Mesh(E(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new r.Mesh(E(.75,1),f),null,[0,Math.PI/2,0]]]},z={AXIS:[[new r.Line(b,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},W={XYZE:[[new r.Mesh(new r.SphereGeometry(.25,10,8),s)]],X:[[new r.Mesh(new r.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new r.Mesh(new r.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new r.Mesh(new r.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new r.Mesh(new r.TorusGeometry(.75,.1,2,24),s)]]},G={X:[[new r.Mesh(_,o),[.5,0,0],[0,0,-Math.PI/2]],[new r.Mesh(M,o),[0,0,0],[0,0,-Math.PI/2]],[new r.Mesh(_,o),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new r.Mesh(_,i),[0,.5,0]],[new r.Mesh(M,i)],[new r.Mesh(_,i),[0,-.5,0],[0,0,Math.PI]]],Z:[[new r.Mesh(_,l),[0,0,.5],[Math.PI/2,0,0]],[new r.Mesh(M,l),[0,0,0],[Math.PI/2,0,0]],[new r.Mesh(_,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new r.Mesh(new r.BoxGeometry(.15,.15,.01),u),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new r.Mesh(new r.BoxGeometry(.1,.1,.1),h)]]},T={X:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new r.Mesh(new r.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new r.Mesh(new r.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},D={X:[[new r.Line(b,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new r.Line(b,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new r.Line(b,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function Z(F){const pe=new r.Object3D;for(const U in F)for(let se=F[U].length;se--;){const V=F[U][se][0].clone(),fe=F[U][se][1],me=F[U][se][2],ge=F[U][se][3],vt=F[U][se][4];V.name=U,V.tag=vt,fe&&V.position.set(fe[0],fe[1],fe[2]),me&&V.rotation.set(me[0],me[1],me[2]),ge&&V.scale.set(ge[0],ge[1],ge[2]),V.updateMatrix();const je=V.geometry.clone();je.applyMatrix4(V.matrix),V.geometry=je,V.renderOrder=1/0,V.position.set(0,0,0),V.rotation.set(0,0,0),V.scale.set(1,1,1),pe.add(V)}return pe}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=Z(P)),this.add(this.gizmo.rotate=Z(K)),this.add(this.gizmo.scale=Z(G)),this.add(this.picker.translate=Z(S)),this.add(this.picker.rotate=Z(W)),this.add(this.picker.scale=Z(T)),this.add(this.helper.translate=Z(L)),this.add(this.helper.rotate=Z(z)),this.add(this.helper.scale=Z(D)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Me;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let o=0;o<n.length;o++){const i=n[o];i.visible=!0,i.rotation.set(0,0,0),i.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),i.scale.set(1,1,1).multiplyScalar(l*this.size/4),i.tag==="helper"){i.visible=!1,i.name==="AXIS"?(i.visible=!!this.axis,this.axis==="X"&&(C.setFromEuler(_e.set(0,0,0)),i.quaternion.copy(s).multiply(C),Math.abs(A.copy(ce).applyQuaternion(s).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="Y"&&(C.setFromEuler(_e.set(0,0,Math.PI/2)),i.quaternion.copy(s).multiply(C),Math.abs(A.copy(ee).applyQuaternion(s).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="Z"&&(C.setFromEuler(_e.set(0,Math.PI/2,0)),i.quaternion.copy(s).multiply(C),Math.abs(A.copy(he).applyQuaternion(s).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="XYZE"&&(C.setFromEuler(_e.set(0,Math.PI/2,0)),A.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(Ye.lookAt(Xe,A,ee)),i.quaternion.multiply(C),i.visible=this.dragging),this.axis==="E"&&(i.visible=!1)):i.name==="START"?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):i.name==="END"?(i.position.copy(this.worldPosition),i.visible=this.dragging):i.name==="DELTA"?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),k.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),k.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(k),i.visible=this.dragging):(i.quaternion.copy(s),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=this.axis.search(i.name)!==-1));continue}i.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(i.name==="X"&&Math.abs(A.copy(ce).applyQuaternion(s).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="Y"&&Math.abs(A.copy(ee).applyQuaternion(s).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="Z"&&Math.abs(A.copy(he).applyQuaternion(s).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="XY"&&Math.abs(A.copy(he).applyQuaternion(s).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="YZ"&&Math.abs(A.copy(ce).applyQuaternion(s).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="XZ"&&Math.abs(A.copy(ee).applyQuaternion(s).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)):this.mode==="rotate"&&(be.copy(s),A.copy(this.eye).applyQuaternion(C.copy(s).invert()),i.name.search("E")!==-1&&i.quaternion.setFromRotationMatrix(Ye.lookAt(this.eye,Xe,ee)),i.name==="X"&&(C.setFromAxisAngle(ce,Math.atan2(-A.y,A.z)),C.multiplyQuaternions(be,C),i.quaternion.copy(C)),i.name==="Y"&&(C.setFromAxisAngle(ee,Math.atan2(A.x,A.z)),C.multiplyQuaternions(be,C),i.quaternion.copy(C)),i.name==="Z"&&(C.setFromAxisAngle(he,Math.atan2(A.y,A.x)),C.multiplyQuaternions(be,C),i.quaternion.copy(C))),i.visible=i.visible&&(i.name.indexOf("X")===-1||this.showX),i.visible=i.visible&&(i.name.indexOf("Y")===-1||this.showY),i.visible=i.visible&&(i.name.indexOf("Z")===-1||this.showZ),i.visible=i.visible&&(i.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),i.visible=i.visible&&(i.name.indexOf("XY")===-1||this.showXY),i.visible=i.visible&&(i.name.indexOf("YZ")===-1||this.showYZ),i.visible=i.visible&&(i.name.indexOf("XZ")===-1||this.showXZ),i.material._color=i.material._color||i.material.color.clone(),i.material._opacity=i.material._opacity||i.material.opacity,i.material.color.copy(i.material._color),i.material.opacity=i.material._opacity,this.enabled&&this.axis&&(i.name===this.axis?(i.material.color.copy(this.materialLib.active.color),i.material.opacity=1):this.axis.split("").some(function(c){return i.name===c})&&(i.material.color.copy(this.materialLib.active.color),i.material.opacity=1))}super.updateMatrixWorld(e)}}class Wt extends r.Mesh{constructor(){super(new r.PlaneGeometry(1e5,1e5,2,2),new r.MeshBasicMaterial({visible:!1,wireframe:!0,side:r.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),we.copy(ce).applyQuaternion(t==="local"?this.worldQuaternion:Me),re.copy(ee).applyQuaternion(t==="local"?this.worldQuaternion:Me),ae.copy(he).applyQuaternion(t==="local"?this.worldQuaternion:Me),A.copy(re),this.mode){case"translate":case"scale":switch(this.axis){case"X":A.copy(this.eye).cross(we),X.copy(we).cross(A);break;case"Y":A.copy(this.eye).cross(re),X.copy(re).cross(A);break;case"Z":A.copy(this.eye).cross(ae),X.copy(ae).cross(A);break;case"XY":X.copy(ae);break;case"YZ":X.copy(we);break;case"XZ":A.copy(ae),X.copy(re);break;case"XYZ":case"E":X.set(0,0,0);break}break;case"rotate":default:X.set(0,0,0)}X.length()===0?this.quaternion.copy(this.cameraQuaternion):(Ke.lookAt(k.set(0,0,0),X,A),this.quaternion.setFromRotationMatrix(Ke)),super.updateMatrixWorld(e)}}const w={scene:null,camera:null,renderer:null,orbitControls:null,transformControls:null,container:null,gridHelper:null,selectedObject:null};let Ae=!1,ie=!1,te=null,Ne=null,Ee=null,ne=[];function it(a){w.container=a,$t(),Jt(),en(),tn(),sn(),nn(),hn(),on(),rt(),a.addEventListener("click",an),window.addEventListener("resize",rn)}function $t(){const a=new O.WebGLRenderer({antialias:!0,alpha:!0});a.setSize(w.container.clientWidth,w.container.clientHeight),a.setPixelRatio(Math.min(window.devicePixelRatio,2)),w.container.appendChild(a.domElement),w.renderer=a}function Jt(){w.scene=new O.Scene,w.scene.name="sl_scene"}function en(){const a=new O.GridHelper(30,30,8956671,3364232);a.name="地板",w.scene.add(a),w.gridHelper=a}function tn(){const a=w.container,e=a.clientWidth/a.clientHeight,t=new O.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),w.camera=t}function nn(){const a=new Lt(w.camera,w.renderer.domElement);a.minDistance=0,a.maxDistance=1/0,a.addEventListener("start",()=>{Ae=!1}),a.addEventListener("change",()=>{Ae=!0}),a.addEventListener("end",()=>{Ae&&(ie=!0,setTimeout(()=>{ie=!1},200))}),w.orbitControls=a}function sn(){const a=new Ut(w.camera,w.renderer.domElement);a.addEventListener("dragging-changed",e=>{w.orbitControls.enabled=!e.value,e.value||(ie=!0,setTimeout(()=>{ie=!1},200))}),a.addEventListener("objectChange",()=>{Ne&&w.selectedObject&&Ne(w.selectedObject)}),w.scene.add(a.getHelper()),w.transformControls=a}function on(){const a=new O.AmbientLight(16777215,2);w.scene.add(a);const e=new O.DirectionalLight(16777215,3);e.position.set(48,104,138),w.scene.add(e);const t=new O.BoxGeometry(1,1,1),s=new O.MeshStandardMaterial({color:16777215}),n=new O.Mesh(t,s);n.position.y=1,n.userData.isMovable=!0,n.name="默认立方体",ue(n,!0)}function rt(){var a,e;requestAnimationFrame(rt),Rt.update(),(a=w.orbitControls)==null||a.update(),(e=w.renderer)==null||e.render(w.scene,w.camera)}function rn(){if(!w.container||!w.camera||!w.renderer)return;const a=w.container.clientWidth,e=w.container.clientHeight;a===0||e===0||(w.camera.aspect=a/e,w.camera.updateProjectionMatrix(),w.renderer.setSize(a,e))}function xe(a){w.selectedObject!==a&&(w.selectedObject&&w.transformControls.detach(),w.selectedObject=a,w.transformControls.attach(a),w.transformControls.setMode("translate"),w.transformControls.showX=!0,w.transformControls.showY=!0,w.transformControls.showZ=!0,te==null||te(a))}function at(){w.selectedObject&&(w.transformControls.detach(),w.selectedObject=null,te==null||te(null))}function an(a){if(ie){ie=!1;return}const e=w.renderer.domElement.getBoundingClientRect(),t=new O.Vector2((a.clientX-e.left)/e.width*2-1,-((a.clientY-e.top)/e.height)*2+1),s=new O.Raycaster;s.setFromCamera(t,w.camera);const n=[];w.scene.traverse(i=>{i.type==="Mesh"&&i.userData.isMovable&&n.push(i)});const o=s.intersectObjects(n);o.length>0?xe(o[0].object):at()}function ue(a,e=!1){w.scene.add(a),a.userData.isMovable&&(ln(a),Ve()),e&&xe(a)}function lt(a){w.selectedObject===a&&at(),a.parent?a.parent.remove(a):w.scene.remove(a),cn(a),Ve()}function ct(a){const e=w.scene.getObjectByProperty("uuid",a);e&&lt(e)}function ln(a){a.userData.isMovable&&a.parent===w.scene&&(ne.includes(a)||ne.push(a))}function cn(a){const e=ne.indexOf(a);e!==-1&&ne.splice(e,1)}function hn(){const a=[];w.scene.children.forEach(e=>{e.userData.isMovable&&a.push(e)}),ne=a,Ve()}function Ve(){Ee==null||Ee([...ne])}function ht(a){te=a}function ut(a){Ne=a}function dt(a){Ee=a}function pt(){return ne}function un(){return w.scene}function dn(){return w.camera}function pn(){return w.renderer}const fn=/^[og]\s*(.+)?/,mn=/^mtllib /,gn=/^usemtl /,yn=/^usemap /,Ze=/\s+/,Qe=new r.Vector3,Pe=new r.Vector3,qe=new r.Vector3,We=new r.Vector3,H=new r.Vector3,Te=new r.Color;function _n(){const a={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const s=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(n,o){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const l={index:this.materials.length,name:n||"",mtllib:Array.isArray(o)&&o.length>0?o[o.length-1]:"",smooth:i!==void 0?i.smooth:this.smooth,groupStart:i!==void 0?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const u={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return u.clone=this.clone.bind(u),u}};return this.materials.push(l),l},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(n){const o=this.currentMaterial();if(o&&o.groupEnd===-1&&(o.groupEnd=this.geometry.vertices.length/3,o.groupCount=o.groupEnd-o.groupStart,o.inherited=!1),n&&this.materials.length>1)for(let i=this.materials.length-1;i>=0;i--)this.materials[i].groupCount<=0&&this.materials.splice(i,1);return n&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),o}},s&&s.name&&typeof s.clone=="function"){const n=s.clone(0);n.inherited=!0,this.object.materials.push(n)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseNormalIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseUVIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/2)*2},addVertex:function(e,t,s){const n=this.vertices,o=this.object.geometry.vertices;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,s){const n=this.normals,o=this.object.geometry.normals;o.push(n[e+0],n[e+1],n[e+2]),o.push(n[t+0],n[t+1],n[t+2]),o.push(n[s+0],n[s+1],n[s+2])},addFaceNormal:function(e,t,s){const n=this.vertices,o=this.object.geometry.normals;Qe.fromArray(n,e),Pe.fromArray(n,t),qe.fromArray(n,s),H.subVectors(qe,Pe),We.subVectors(Qe,Pe),H.cross(We),H.normalize(),o.push(H.x,H.y,H.z),o.push(H.x,H.y,H.z),o.push(H.x,H.y,H.z)},addColor:function(e,t,s){const n=this.colors,o=this.object.geometry.colors;n[e]!==void 0&&o.push(n[e+0],n[e+1],n[e+2]),n[t]!==void 0&&o.push(n[t+0],n[t+1],n[t+2]),n[s]!==void 0&&o.push(n[s+0],n[s+1],n[s+2])},addUV:function(e,t,s){const n=this.uvs,o=this.object.geometry.uvs;o.push(n[e+0],n[e+1]),o.push(n[t+0],n[t+1]),o.push(n[s+0],n[s+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,s,n,o,i,l,c,u){const p=this.vertices.length;let h=this.parseVertexIndex(e,p),f=this.parseVertexIndex(t,p),m=this.parseVertexIndex(s,p);if(this.addVertex(h,f,m),this.addColor(h,f,m),l!==void 0&&l!==""){const g=this.normals.length;h=this.parseNormalIndex(l,g),f=this.parseNormalIndex(c,g),m=this.parseNormalIndex(u,g),this.addNormal(h,f,m)}else this.addFaceNormal(h,f,m);if(n!==void 0&&n!==""){const g=this.uvs.length;h=this.parseUVIndex(n,g),f=this.parseUVIndex(o,g),m=this.parseUVIndex(i,g),this.addUV(h,f,m),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let s=0,n=e.length;s<n;s++){const o=this.parseVertexIndex(e[s],t);this.addVertexPoint(o),this.addColor(o)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const s=this.vertices.length,n=this.uvs.length;for(let o=0,i=e.length;o<i;o++)this.addVertexLine(this.parseVertexIndex(e[o],s));for(let o=0,i=t.length;o<i;o++)this.addUVLine(this.parseUVIndex(t[o],n))}};return a.startObject("",!1),a}class bn extends r.Loader{constructor(e){super(e),this.materials=null}load(e,t,s,n){const o=this,i=new r.FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(l){try{t(o.parse(l))}catch(c){n?n(c):console.error(c),o.manager.itemError(e)}},s,n)}setMaterials(e){return this.materials=e,this}parse(e){const t=new _n;e.indexOf(`\r
2
2
  `)!==-1&&(e=e.replace(/\r\n/g,`
3
3
  `)),e.indexOf(`\\
4
4
  `)!==-1&&(e=e.replace(/\\\n/g,""));const s=e.split(`
5
- `);let n=[];for(let l=0,c=s.length;l<c;l++){const u=s[l].trimStart();if(u.length===0)continue;const p=u.charAt(0);if(p!=="#")if(p==="v"){const h=u.split(Ze);switch(h[0]){case"v":t.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),h.length>=7?(we.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6]),r.SRGBColorSpace),t.colors.push(we.r,we.g,we.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(p==="f"){const f=u.slice(1).trim().split(Ze),m=[];for(let y=0,_=f.length;y<_;y++){const b=f[y];if(b.length>0){const M=b.split("/");m.push(M)}}const g=m[0];for(let y=1,_=m.length-1;y<_;y++){const b=m[y],M=m[y+1];t.addFace(g[0],b[0],M[0],g[1],b[1],M[1],g[2],b[2],M[2])}}else if(p==="l"){const h=u.substring(1).trim().split(" ");let f=[];const m=[];if(u.indexOf("/")===-1)f=h;else for(let g=0,y=h.length;g<y;g++){const _=h[g].split("/");_[0]!==""&&f.push(_[0]),_[1]!==""&&m.push(_[1])}t.addLineGeometry(f,m)}else if(p==="p"){const f=u.slice(1).trim().split(" ");t.addPointGeometry(f)}else if((n=rn.exec(u))!==null){const h=(" "+n[0].slice(1).trim()).slice(1);t.startObject(h)}else if(ln.test(u))t.object.startMaterial(u.substring(7).trim(),t.materialLibraries);else if(an.test(u))t.materialLibraries.push(u.substring(7).trim());else if(cn.test(u))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(p==="s"){if(n=u.split(" "),n.length>1){const f=n[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(u==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+u+'"')}}t.finalize();const i=new r.Group;if(i.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let l=0,c=t.objects.length;l<c;l++){const u=t.objects[l],p=u.geometry,h=u.materials,f=p.type==="Line",m=p.type==="Points";let g=!1;if(p.vertices.length===0)continue;const y=new r.BufferGeometry;y.setAttribute("position",new r.Float32BufferAttribute(p.vertices,3)),p.normals.length>0&&y.setAttribute("normal",new r.Float32BufferAttribute(p.normals,3)),p.colors.length>0&&(g=!0,y.setAttribute("color",new r.Float32BufferAttribute(p.colors,3))),p.hasUVIndices===!0&&y.setAttribute("uv",new r.Float32BufferAttribute(p.uvs,2));const _=[];for(let M=0,E=h.length;M<E;M++){const x=h[M],P=x.name+"_"+x.smooth+"_"+g;let S=t.materials[P];if(this.materials!==null){if(S=this.materials.create(x.name),f&&S&&!(S instanceof r.LineBasicMaterial)){const L=new r.LineBasicMaterial;r.Material.prototype.copy.call(L,S),L.color.copy(S.color),S=L}else if(m&&S&&!(S instanceof r.PointsMaterial)){const L=new r.PointsMaterial({size:10,sizeAttenuation:!1});r.Material.prototype.copy.call(L,S),L.color.copy(S.color),L.map=S.map,S=L}}S===void 0&&(f?S=new r.LineBasicMaterial:m?S=new r.PointsMaterial({size:1,sizeAttenuation:!1}):S=new r.MeshPhongMaterial,S.name=x.name,S.flatShading=!x.smooth,S.vertexColors=g,t.materials[P]=S),_.push(S)}let b;if(_.length>1){for(let M=0,E=h.length;M<E;M++){const x=h[M];y.addGroup(x.groupStart,x.groupCount,M)}f?b=new r.LineSegments(y,_):m?b=new r.Points(y,_):b=new r.Mesh(y,_)}else f?b=new r.LineSegments(y,_[0]):m?b=new r.Points(y,_[0]):b=new r.Mesh(y,_[0]);b.name=u.name,i.add(b)}else if(t.vertices.length>0){const l=new r.PointsMaterial({size:1,sizeAttenuation:!1}),c=new r.BufferGeometry;c.setAttribute("position",new r.Float32BufferAttribute(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new r.Float32BufferAttribute(t.colors,3)),l.vertexColors=!0);const u=new r.Points(c,l);i.add(u)}return i}}function $e(a,e){if(e===r.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),a;if(e===r.TriangleFanDrawMode||e===r.TriangleStripDrawMode){let t=a.getIndex();if(t===null){const o=[],l=a.getAttribute("position");if(l!==void 0){for(let c=0;c<l.count;c++)o.push(c);a.setIndex(o),t=a.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),a}const s=t.count-2,n=[];if(e===r.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=a.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),a}function dn(a){const e=new Map,t=new Map,s=a.clone();return at(a,s,function(n,i){e.set(i,n),t.set(n,i)}),s.traverse(function(n){if(!n.isSkinnedMesh)return;const i=n,o=e.get(n),l=o.skeleton.bones;i.skeleton=o.skeleton.clone(),i.bindMatrix.copy(o.bindMatrix),i.skeleton.bones=l.map(function(c){return t.get(c)}),i.bind(i.skeleton,i.bindMatrix)}),s}function at(a,e,t){t(a,e);for(let s=0;s<a.children.length;s++)at(a.children[s],e.children[s],t)}class pn extends r.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new _n(t)}),this.register(function(t){return new bn(t)}),this.register(function(t){return new An(t)}),this.register(function(t){return new Pn(t)}),this.register(function(t){return new Ln(t)}),this.register(function(t){return new Tn(t)}),this.register(function(t){return new Mn(t)}),this.register(function(t){return new En(t)}),this.register(function(t){return new xn(t)}),this.register(function(t){return new yn(t)}),this.register(function(t){return new Sn(t)}),this.register(function(t){return new wn(t)}),this.register(function(t){return new Rn(t)}),this.register(function(t){return new vn(t)}),this.register(function(t){return new mn(t)}),this.register(function(t){return new Je(t,v.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Je(t,v.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Nn(t)})}load(e,t,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const u=r.LoaderUtils.extractUrlBase(e);o=r.LoaderUtils.resolveURL(u,this.path)}else o=r.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const l=function(u){n?n(u):console.error(u),i.manager.itemError(e),i.manager.itemEnd(e)},c=new r.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(u){try{i.parse(u,o,function(p){t(p),i.manager.itemEnd(e)},l)}catch(p){l(p)}},s,l)}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,s,n){let i;const o={},l={},c=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===lt){try{o[v.KHR_BINARY_GLTF]=new In(e)}catch(h){n&&n(h);return}i=JSON.parse(o[v.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new Xn(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const h=this.pluginCallbacks[p](u);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[h.name]=h,o[h.name]=!0}if(i.extensionsUsed)for(let p=0;p<i.extensionsUsed.length;++p){const h=i.extensionsUsed[p],f=i.extensionsRequired||[];switch(h){case v.KHR_MATERIALS_UNLIT:o[h]=new gn;break;case v.KHR_DRACO_MESH_COMPRESSION:o[h]=new Cn(i,this.dracoLoader);break;case v.KHR_TEXTURE_TRANSFORM:o[h]=new On;break;case v.KHR_MESH_QUANTIZATION:o[h]=new Dn;break;default:f.indexOf(h)>=0&&l[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}u.setExtensions(o),u.setPlugins(l),u.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function fn(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}function I(a,e,t){const s=a.json.materials[e];return s.extensions&&s.extensions[t]?s.extensions[t]:null}const v={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",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class mn{constructor(e){this.parser=e,this.name=v.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,c=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let u;const p=new r.Color(16777215);c.color!==void 0&&p.setRGB(c.color[0],c.color[1],c.color[2],r.LinearSRGBColorSpace);const h=c.range!==void 0?c.range:0;switch(c.type){case"directional":u=new r.DirectionalLight(p),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new r.PointLight(p),u.distance=h;break;case"spot":u=new r.SpotLight(p),u.distance=h,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,u.angle=c.spot.outerConeAngle,u.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return u.position.set(0,0,0),Y(u,c),c.intensity!==void 0&&(u.intensity=c.intensity),u.name=t.createUniqueName(c.name||"light_"+e),n=Promise.resolve(u),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],l=(i.extensions&&i.extensions[this.name]||{}).light;return l===void 0?null:this._loadLight(l).then(function(c){return s._getNodeRef(t.cache,l,c)})}}class gn{constructor(){this.name=v.KHR_MATERIALS_UNLIT}getMaterialType(){return r.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new r.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],r.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,r.SRGBColorSpace))}return Promise.all(n)}}class yn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);return s===null||s.emissiveStrength!==void 0&&(t.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class _n{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new r.Vector2(i,i)}return Promise.all(n)}}class bn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_DISPERSION}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);return s===null||(t.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class wn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(n)}}class Tn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_SHEEN}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];if(t.sheenColor=new r.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],r.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenColorMap",s.sheenColorTexture,r.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(n)}}class Mn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(n)}}class En{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_VOLUME}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return t.attenuationColor=new r.Color().setRGB(i[0],i[1],i[2],r.LinearSRGBColorSpace),Promise.all(n)}}class xn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_IOR}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);return s===null||(t.ior=s.ior!==void 0?s.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}}class Sn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_SPECULAR}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return t.specularColor=new r.Color().setRGB(i[0],i[1],i[2],r.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularColorMap",s.specularColorTexture,r.SRGBColorSpace)),Promise.all(n)}}class vn{constructor(e){this.parser=e,this.name=v.EXT_MATERIALS_BUMP}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&n.push(this.parser.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(n)}}class Rn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(n)}}class An{constructor(e){this.parser=e,this.name=v.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class Pn{constructor(e){this.parser=e,this.name=v.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],l=n.images[o.source];let c=s.textureLoader;if(l.uri){const u=s.options.manager.getHandler(l.uri);u!==null&&(c=u)}return s.loadTextureImage(e,o.source,c)}}class Ln{constructor(e){this.parser=e,this.name=v.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],l=n.images[o.source];let c=s.textureLoader;if(l.uri){const u=s.options.manager.getHandler(l.uri);u!==null&&(c=u)}return s.loadTextureImage(e,o.source,c)}}class Je{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(l){const c=n.byteOffset||0,u=n.byteLength||0,p=n.count,h=n.byteStride,f=new Uint8Array(l,c,u);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(p,h,f,n.mode,n.filter).then(function(m){return m.buffer}):o.ready.then(function(){const m=new ArrayBuffer(p*h);return o.decodeGltfBuffer(new Uint8Array(m),p,h,f,n.mode,n.filter),m})})}else return null}}class Nn{constructor(e){this.name=v.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const u of n.primitives)if(u.mode!==G.TRIANGLES&&u.mode!==G.TRIANGLE_STRIP&&u.mode!==G.TRIANGLE_FAN&&u.mode!==void 0)return null;const o=s.extensions[this.name].attributes,l=[],c={};for(const u in o)l.push(this.parser.getDependency("accessor",o[u]).then(p=>(c[u]=p,c[u])));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then(u=>{const p=u.pop(),h=p.isGroup?p.children:[p],f=u[0].count,m=[];for(const g of h){const y=new r.Matrix4,_=new r.Vector3,b=new r.Quaternion,M=new r.Vector3(1,1,1),E=new r.InstancedMesh(g.geometry,g.material,f);for(let x=0;x<f;x++)c.TRANSLATION&&_.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&b.fromBufferAttribute(c.ROTATION,x),c.SCALE&&M.fromBufferAttribute(c.SCALE,x),E.setMatrixAt(x,y.compose(_,b,M));for(const x in c)if(x==="_COLOR_0"){const P=c[x];E.instanceColor=new r.InstancedBufferAttribute(P.array,P.itemSize,P.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&g.geometry.setAttribute(x,c[x]);r.Object3D.prototype.copy.call(E,g),this.parser.assignFinalMaterial(E),m.push(E)}return p.isGroup?(p.clear(),p.add(...m),p):m[0]}))}}const lt="glTF",le=12,et={JSON:1313821514,BIN:5130562};class In{constructor(e){this.name=v.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,le),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==lt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-le,i=new DataView(e,le);let o=0;for(;o<n;){const l=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,c===et.JSON){const u=new Uint8Array(e,le+o,l);this.content=s.decode(u)}else if(c===et.BIN){const u=le+o;this.body=e.slice(u,u+l)}o+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Cn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=v.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,l={},c={},u={};for(const p in o){const h=Ce[p]||p.toLowerCase();l[h]=o[p]}for(const p in e.attributes){const h=Ce[p]||p.toLowerCase();if(o[p]!==void 0){const f=s.accessors[e.attributes[p]],m=ie[f.componentType];u[h]=m.name,c[h]=f.normalized===!0}}return t.getDependency("bufferView",i).then(function(p){return new Promise(function(h,f){n.decodeDracoFile(p,function(m){for(const g in m.attributes){const y=m.attributes[g],_=c[g];_!==void 0&&(y.normalized=_)}h(m)},l,u,r.LinearSRGBColorSpace,f)})})}}class On{constructor(){this.name=v.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 Dn{constructor(){this.name=v.KHR_MESH_QUANTIZATION}}class ct extends r.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,l=this.valueSize,c=l*2,u=l*3,p=n-t,h=(s-t)/p,f=h*h,m=f*h,g=e*u,y=g-u,_=-2*m+3*f,b=m-f,M=1-_,E=b-f+h;for(let x=0;x!==l;x++){const P=o[y+x+l],S=o[y+x+c]*p,L=o[g+x+l],K=o[g+x]*p;i[x]=M*P+E*S+_*L+b*K}return i}}const kn=new r.Quaternion;class Vn extends ct{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return kn.fromArray(i).normalize().toArray(i),i}}const G={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ie={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},tt={9728:r.NearestFilter,9729:r.LinearFilter,9984:r.NearestMipmapNearestFilter,9985:r.LinearMipmapNearestFilter,9986:r.NearestMipmapLinearFilter,9987:r.LinearMipmapLinearFilter},nt={33071:r.ClampToEdgeWrapping,33648:r.MirroredRepeatWrapping,10497:r.RepeatWrapping},Pe={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ce={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"},q={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jn={CUBICSPLINE:void 0,LINEAR:r.InterpolateLinear,STEP:r.InterpolateDiscrete},Le={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Fn(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new r.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:r.FrontSide})),a.DefaultMaterial}function J(a,e,t){for(const s in t.extensions)a[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function Y(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Hn(a,e,t){let s=!1,n=!1,i=!1;for(let u=0,p=e.length;u<p;u++){const h=e[u];if(h.POSITION!==void 0&&(s=!0),h.NORMAL!==void 0&&(n=!0),h.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(a);const o=[],l=[],c=[];for(let u=0,p=e.length;u<p;u++){const h=e[u];if(s){const f=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):a.attributes.position;o.push(f)}if(n){const f=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):a.attributes.normal;l.push(f)}if(i){const f=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):a.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(c)]).then(function(u){const p=u[0],h=u[1],f=u[2];return s&&(a.morphAttributes.position=p),n&&(a.morphAttributes.normal=h),i&&(a.morphAttributes.color=f),a.morphTargetsRelative=!0,a})}function Gn(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)a.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(a.morphTargetInfluences.length===t.length){a.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)a.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Bn(a){let e;const t=a.extensions&&a.extensions[v.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ne(t.attributes):e=a.indices+":"+Ne(a.attributes)+":"+a.mode,a.targets!==void 0)for(let s=0,n=a.targets.length;s<n;s++)e+=":"+Ne(a.targets[s]);return e}function Ne(a){let e="";const t=Object.keys(a).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+a[t[s]]+";";return e}function Oe(a){switch(a){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 Un(a){return a.search(/\.jpe?g($|\?)/i)>0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":a.search(/\.ktx2($|\?)/i)>0||a.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const zn=new r.Matrix4;class Xn{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fn,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 s=!1,n=-1,i=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const l=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(l)===!0;const c=l.match(/Version\/(\d+)/);n=s&&c?parseInt(c[1],10):-1,i=l.indexOf("Firefox")>-1,o=i?l.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&o<98?this.textureLoader=new r.TextureLoader(this.options.manager):this.textureLoader=new r.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new r.FileLoader(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 s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const l={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return J(i,l,n),Y(l,n),Promise.all(s._invokeAll(function(c){return c.afterRoot&&c.afterRoot(l)})).then(function(){for(const c of l.scenes)c.updateMatrixWorld();e(l)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let l=0,c=o.length;l<c;l++)e[o[l]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,l)=>{const c=this.associations.get(o);c!=null&&this.associations.set(l,c);for(const[u,p]of o.children.entries())i(p,l.children[u])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=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[v.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(r.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=Pe[n.type],l=ie[n.componentType],c=n.normalized===!0,u=new l(n.count*o);return Promise.resolve(new r.BufferAttribute(u,o,c))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const l=o[0],c=Pe[n.type],u=ie[n.componentType],p=u.BYTES_PER_ELEMENT,h=p*c,f=n.byteOffset||0,m=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let y,_;if(m&&m!==h){const b=Math.floor(f/m),M="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+b+":"+n.count;let E=t.cache.get(M);E||(y=new u(l,b*m,n.count*m/p),E=new r.InterleavedBuffer(y,m/p),t.cache.add(M,E)),_=new r.InterleavedBufferAttribute(E,c,f%m/p,g)}else l===null?y=new u(n.count*c):y=new u(l,f,n.count*c),_=new r.BufferAttribute(y,c,g);if(n.sparse!==void 0){const b=Pe.SCALAR,M=ie[n.sparse.indices.componentType],E=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,P=new M(o[1],E,n.sparse.count*b),S=new u(o[2],x,n.sparse.count*c);l!==null&&(_=new r.BufferAttribute(_.array.slice(),_.itemSize,_.normalized)),_.normalized=!1;for(let L=0,K=P.length;L<K;L++){const z=P[L];if(_.setX(z,S[L*c]),c>=2&&_.setY(z,S[L*c+1]),c>=3&&_.setZ(z,S[L*c+2]),c>=4&&_.setW(z,S[L*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=g}return _})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let l=this.textureLoader;if(o.uri){const c=s.manager.getHandler(o.uri);c!==null&&(l=c)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],l=i.images[t],c=(l.uri||l.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const u=this.loadImageSource(t,s).then(function(p){p.flipY=!1,p.name=o.name||l.name||"",p.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(p.name=l.uri);const f=(i.samplers||{})[o.sampler]||{};return p.magFilter=tt[f.magFilter]||r.LinearFilter,p.minFilter=tt[f.minFilter]||r.LinearMipmapLinearFilter,p.wrapS=nt[f.wrapS]||r.RepeatWrapping,p.wrapT=nt[f.wrapT]||r.RepeatWrapping,p.generateMipmaps=!p.isCompressedTexture&&p.minFilter!==r.NearestFilter&&p.minFilter!==r.LinearFilter,n.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[c]=u,u}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=n.images[e],l=self.URL||self.webkitURL;let c=o.uri||"",u=!1;if(o.bufferView!==void 0)c=s.getDependency("bufferView",o.bufferView).then(function(h){u=!0;const f=new Blob([h],{type:o.mimeType});return c=l.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(c).then(function(h){return new Promise(function(f,m){let g=f;t.isImageBitmapLoader===!0&&(g=function(y){const _=new r.Texture(y);_.needsUpdate=!0,f(_)}),t.load(r.LoaderUtils.resolveURL(h,i.path),g,void 0,m)})}).then(function(h){return u===!0&&l.revokeObjectURL(c),Y(h,o),h.userData.mimeType=o.mimeType||Un(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=p,p}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[v.KHR_TEXTURE_TRANSFORM]){const l=s.extensions!==void 0?s.extensions[v.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const c=i.associations.get(o);o=i.extensions[v.KHR_TEXTURE_TRANSFORM].extendTexture(o,l),i.associations.set(o,c)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+s.uuid;let c=this.cache.get(l);c||(c=new r.PointsMaterial,r.Material.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,c.sizeAttenuation=!1,this.cache.add(l,c)),s=c}else if(e.isLine){const l="LineBasicMaterial:"+s.uuid;let c=this.cache.get(l);c||(c=new r.LineBasicMaterial,r.Material.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,this.cache.add(l,c)),s=c}if(n||i||o){let l="ClonedMaterial:"+s.uuid+":";n&&(l+="derivative-tangents:"),i&&(l+="vertex-colors:"),o&&(l+="flat-shading:");let c=this.cache.get(l);c||(c=s.clone(),i&&(c.vertexColors=!0),o&&(c.flatShading=!0),n&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(l,c),this.associations.set(c,this.associations.get(s))),s=c}e.material=s}getMaterialType(){return r.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const l={},c=i.extensions||{},u=[];if(c[v.KHR_MATERIALS_UNLIT]){const h=n[v.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),u.push(h.extendParams(l,i,t))}else{const h=i.pbrMetallicRoughness||{};if(l.color=new r.Color(1,1,1),l.opacity=1,Array.isArray(h.baseColorFactor)){const f=h.baseColorFactor;l.color.setRGB(f[0],f[1],f[2],r.LinearSRGBColorSpace),l.opacity=f[3]}h.baseColorTexture!==void 0&&u.push(t.assignTexture(l,"map",h.baseColorTexture,r.SRGBColorSpace)),l.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,l.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(l,"metalnessMap",h.metallicRoughnessTexture)),u.push(t.assignTexture(l,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,l)})))}i.doubleSided===!0&&(l.side=r.DoubleSide);const p=i.alphaMode||Le.OPAQUE;if(p===Le.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,p===Le.MASK&&(l.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==r.MeshBasicMaterial&&(u.push(t.assignTexture(l,"normalMap",i.normalTexture)),l.normalScale=new r.Vector2(1,1),i.normalTexture.scale!==void 0)){const h=i.normalTexture.scale;l.normalScale.set(h,h)}if(i.occlusionTexture!==void 0&&o!==r.MeshBasicMaterial&&(u.push(t.assignTexture(l,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==r.MeshBasicMaterial){const h=i.emissiveFactor;l.emissive=new r.Color().setRGB(h[0],h[1],h[2],r.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==r.MeshBasicMaterial&&u.push(t.assignTexture(l,"emissiveMap",i.emissiveTexture,r.SRGBColorSpace)),Promise.all(u).then(function(){const h=new o(l);return i.name&&(h.name=i.name),Y(h,i),t.associations.set(h,{materials:e}),i.extensions&&J(n,h,i),h})}createUniqueName(e){const t=r.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(l){return s[v.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,t).then(function(c){return st(c,l,t)})}const o=[];for(let l=0,c=e.length;l<c;l++){const u=e[l],p=Bn(u),h=n[p];if(h)o.push(h.promise);else{let f;u.extensions&&u.extensions[v.KHR_DRACO_MESH_COMPRESSION]?f=i(u):f=st(new r.BufferGeometry,u,t),n[p]={primitive:u,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,l=[];for(let c=0,u=o.length;c<u;c++){const p=o[c].material===void 0?Fn(this.cache):this.getDependency("material",o[c].material);l.push(p)}return l.push(t.loadGeometries(o)),Promise.all(l).then(function(c){const u=c.slice(0,c.length-1),p=c[c.length-1],h=[];for(let m=0,g=p.length;m<g;m++){const y=p[m],_=o[m];let b;const M=u[m];if(_.mode===G.TRIANGLES||_.mode===G.TRIANGLE_STRIP||_.mode===G.TRIANGLE_FAN||_.mode===void 0)b=i.isSkinnedMesh===!0?new r.SkinnedMesh(y,M):new r.Mesh(y,M),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),_.mode===G.TRIANGLE_STRIP?b.geometry=$e(b.geometry,r.TriangleStripDrawMode):_.mode===G.TRIANGLE_FAN&&(b.geometry=$e(b.geometry,r.TriangleFanDrawMode));else if(_.mode===G.LINES)b=new r.LineSegments(y,M);else if(_.mode===G.LINE_STRIP)b=new r.Line(y,M);else if(_.mode===G.LINE_LOOP)b=new r.LineLoop(y,M);else if(_.mode===G.POINTS)b=new r.Points(y,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(b.geometry.morphAttributes).length>0&&Gn(b,i),b.name=t.createUniqueName(i.name||"mesh_"+e),Y(b,i),_.extensions&&J(n,b,_),t.assignFinalMaterial(b),h.push(b)}for(let m=0,g=h.length;m<g;m++)t.associations.set(h[m],{meshes:e,primitives:m});if(h.length===1)return i.extensions&&J(n,h[0],i),h[0];const f=new r.Group;i.extensions&&J(n,f,i),t.associations.set(f,{meshes:e});for(let m=0,g=h.length;m<g;m++)f.add(h[m]);return f})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new r.PerspectiveCamera(r.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new r.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),Y(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,l=[],c=[];for(let u=0,p=o.length;u<p;u++){const h=o[u];if(h){l.push(h);const f=new r.Matrix4;i!==null&&f.fromArray(i.array,u*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new r.Skeleton(l,c)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,o=[],l=[],c=[],u=[],p=[];for(let h=0,f=n.channels.length;h<f;h++){const m=n.channels[h],g=n.samplers[m.sampler],y=m.target,_=y.node,b=n.parameters!==void 0?n.parameters[g.input]:g.input,M=n.parameters!==void 0?n.parameters[g.output]:g.output;y.node!==void 0&&(o.push(this.getDependency("node",_)),l.push(this.getDependency("accessor",b)),c.push(this.getDependency("accessor",M)),u.push(g),p.push(y))}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(u),Promise.all(p)]).then(function(h){const f=h[0],m=h[1],g=h[2],y=h[3],_=h[4],b=[];for(let E=0,x=f.length;E<x;E++){const P=f[E],S=m[E],L=g[E],K=y[E],z=_[E];if(P===void 0)continue;P.updateMatrix&&P.updateMatrix();const W=s._createAnimationTracks(P,S,L,K,z);if(W)for(let B=0;B<W.length;B++)b.push(W[B])}const M=new r.AnimationClip(i,void 0,b);return Y(M,n),M})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(l){if(l.isMesh)for(let c=0,u=n.weights.length;c<u;c++)l.morphTargetInfluences[c]=n.weights[c]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],l=n.children||[];for(let u=0,p=l.length;u<p;u++)o.push(s.getDependency("node",l[u]));const c=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),c]).then(function(u){const p=u[0],h=u[1],f=u[2];f!==null&&p.traverse(function(m){m.isSkinnedMesh&&m.bind(f,zn)});for(let m=0,g=h.length;m<g;m++)p.add(h[m]);if(p.userData.pivot!==void 0&&h.length>0){const m=p.userData.pivot,g=h[0];p.pivot=new r.Vector3().fromArray(m),p.position.x-=m[0],p.position.y-=m[1],p.position.z-=m[2],g.position.set(0,0,0),delete p.userData.pivot}return p})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",l=[],c=n._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return c&&l.push(c),i.camera!==void 0&&l.push(n.getDependency("camera",i.camera).then(function(u){return n._getNodeRef(n.cameraCache,i.camera,u)})),n._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){l.push(u)}),this.nodeCache[e]=Promise.all(l).then(function(u){let p;if(i.isBone===!0?p=new r.Bone:u.length>1?p=new r.Group:u.length===1?p=u[0]:p=new r.Object3D,p!==u[0])for(let h=0,f=u.length;h<f;h++)p.add(u[h]);if(i.name&&(p.userData.name=i.name,p.name=o),Y(p,i),i.extensions&&J(s,p,i),i.matrix!==void 0){const h=new r.Matrix4;h.fromArray(i.matrix),p.applyMatrix4(h)}else i.translation!==void 0&&p.position.fromArray(i.translation),i.rotation!==void 0&&p.quaternion.fromArray(i.rotation),i.scale!==void 0&&p.scale.fromArray(i.scale);if(!n.associations.has(p))n.associations.set(p,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const h=n.associations.get(p);n.associations.set(p,{...h})}return n.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new r.Group;s.name&&(i.name=n.createUniqueName(s.name)),Y(i,s),s.extensions&&J(t,i,s);const o=s.nodes||[],l=[];for(let c=0,u=o.length;c<u;c++)l.push(n.getDependency("node",o[c]));return Promise.all(l).then(function(c){for(let p=0,h=c.length;p<h;p++){const f=c[p];f.parent!==null?i.add(dn(f)):i.add(f)}const u=p=>{const h=new Map;for(const[f,m]of n.associations)(f instanceof r.Material||f instanceof r.Texture)&&h.set(f,m);return p.traverse(f=>{const m=n.associations.get(f);m!=null&&h.set(f,m)}),h};return n.associations=u(i),i})}_createAnimationTracks(e,t,s,n,i){const o=[],l=e.name?e.name:e.uuid,c=[];function u(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}q[i.path]===q.weights?(u(e),e.isGroup&&e.children.forEach(u)):c.push(l);let p;switch(q[i.path]){case q.weights:p=r.NumberKeyframeTrack;break;case q.rotation:p=r.QuaternionKeyframeTrack;break;case q.translation:case q.scale:p=r.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:p=r.NumberKeyframeTrack;break;case 2:case 3:default:p=r.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?jn[n.interpolation]:r.InterpolateLinear,f=this._getArrayFromAccessor(s);for(let m=0,g=c.length;m<g;m++){const y=new p(c[m]+"."+q[i.path],t.array,f,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),o.push(y)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=Oe(t.constructor),n=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof r.QuaternionKeyframeTrack?Vn:ct;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Yn(a,e,t){const s=e.attributes,n=new r.Box3;if(s.POSITION!==void 0){const l=t.json.accessors[s.POSITION],c=l.min,u=l.max;if(c!==void 0&&u!==void 0){if(n.set(new r.Vector3(c[0],c[1],c[2]),new r.Vector3(u[0],u[1],u[2])),l.normalized){const p=Oe(ie[l.componentType]);n.min.multiplyScalar(p),n.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const l=new r.Vector3,c=new r.Vector3;for(let u=0,p=i.length;u<p;u++){const h=i[u];if(h.POSITION!==void 0){const f=t.json.accessors[h.POSITION],m=f.min,g=f.max;if(m!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(m[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(m[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(m[2]),Math.abs(g[2]))),f.normalized){const y=Oe(ie[f.componentType]);c.multiplyScalar(y)}l.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(l)}a.boundingBox=n;const o=new r.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,a.boundingSphere=o}function st(a,e,t){const s=e.attributes,n=[];function i(o,l){return t.getDependency("accessor",o).then(function(c){a.setAttribute(l,c)})}for(const o in s){const l=Ce[o]||o.toLowerCase();l in a.attributes||n.push(i(s[o],l))}if(e.indices!==void 0&&!a.index){const o=t.getDependency("accessor",e.indices).then(function(l){a.setIndex(l)});n.push(o)}return r.ColorManagement.workingColorSpace!==r.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${r.ColorManagement.workingColorSpace}" not supported.`),Y(a,e),Yn(a,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Hn(a,e.targets,t):a})}function Kn(){const a=new O.BoxGeometry(1,1,1),e=new O.MeshStandardMaterial({color:43775}),t=new O.Mesh(a,e);return t.position.y=.5,t.userData.isMovable=!0,t.name="正方体",Ee(t,!0),t}function Zn(){const a=new O.SphereGeometry(.6,32,32),e=new O.MeshStandardMaterial({color:16746496}),t=new O.Mesh(a,e);return t.position.y=.6,t.userData.isMovable=!0,t.name="球体",Ee(t,!0),t}function Qn(a){return new Promise((e,t)=>{var o;const s=(o=a.name.split(".").pop())==null?void 0:o.toLowerCase(),n=URL.createObjectURL(a);let i;if(s==="obj")i=new un;else if(s==="gltf"||s==="glb")i=new pn;else{t(new Error("不支持的文件格式,请使用 .obj, .gltf, .glb"));return}i.load(n,l=>{const c=s==="gltf"||s==="glb"?l.scene:l;c.traverse(h=>{var f;h.userData.isMovable=!0,h.name||(h.name=h.type),h.type==="Mesh"&&(h.frustumCulled=!0,(f=h.geometry)==null||f.computeVertexNormals())});const p=new O.Box3().setFromObject(c).getCenter(new O.Vector3);c.position.sub(p),Ee(c,!0),e(c)},void 0,l=>t(l))})}function qn(a){switch(a){case"box":Kn();break;case"sphere":Zn();break}}const Wn={key:1,class:"toggle-placeholder"},$n={class:"tree-icon"},Jn={class:"tree-name"},es={key:0,class:"tree-children"},ts=d.defineComponent({__name:"TreeItem",props:{node:{},selectedObject:{},version:{}},emits:["select","delete"],setup(a,{emit:e}){const t=a,s=e,n=d.ref(null),{expandedSet:i,toggleExpand:o}=d.inject("treeExpand"),l=d.computed(()=>i.value.has(t.node.uuid)),c=d.computed(()=>(t.version,t.node.children.some(y=>y.userData.isMovable===!0))),u=d.computed(()=>(t.version,t.node.children.filter(y=>y.userData.isMovable===!0))),p=d.computed(()=>{var y;return((y=t.selectedObject)==null?void 0:y.uuid)===t.node.uuid});d.watchEffect(()=>{p.value&&n.value&&n.value.scrollIntoView({block:"nearest",behavior:"smooth"})},{flush:"post"});const h=y=>{y.stopPropagation(),s("select",t.node)},f=y=>{y.stopPropagation(),s("delete",t.node)},m=y=>y.type==="Mesh"||y.type==="Sprite"?"🟦":y.type==="Light"?"💡":"📦",g=y=>y.name||`${y.type} (${y.id})`;return(y,_)=>{const b=d.resolveComponent("TreeItem",!0);return d.openBlock(),d.createElementBlock("div",{class:"tree-node",ref_key:"nodeRef",ref:n},[d.createElementVNode("div",{class:d.normalizeClass(["tree-item",{selected:p.value}]),onClick:h},[c.value?(d.openBlock(),d.createElementBlock("span",{key:0,class:"toggle-icon",onClick:_[0]||(_[0]=d.withModifiers(M=>d.unref(o)(a.node.uuid),["stop"]))},d.toDisplayString(l.value?"▼":"▶"),1)):(d.openBlock(),d.createElementBlock("span",Wn)),d.createElementVNode("span",$n,d.toDisplayString(m(a.node)),1),d.createElementVNode("span",Jn,d.toDisplayString(g(a.node)),1),d.createElementVNode("button",{class:"tree-delete",onClick:d.withModifiers(f,["stop"])},"×")],2),l.value&&c.value?(d.openBlock(),d.createElementBlock("div",es,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(u.value,M=>(d.openBlock(),d.createBlock(b,{key:M.uuid,node:M,"selected-object":a.selectedObject,version:a.version,onSelect:_[1]||(_[1]=E=>s("select",E)),onDelete:_[2]||(_[2]=E=>s("delete",E))},null,8,["node","selected-object","version"]))),128))])):d.createCommentVNode("",!0)],512)}}}),ue=(a,e)=>{const t=a.__vccOpts||a;for(const[s,n]of e)t[s]=n;return t},ht=ue(ts,[["__scopeId","data-v-5ad9c842"]]);function ns(a){const e=d.ref(new Set),t=n=>{const i=new Set(e.value);i.has(n)?i.delete(n):i.add(n),e.value=i},s=n=>{if(!n)return;const i=new Set(e.value);let o=n.parent;for(;o&&o.type!=="Scene";)i.add(o.uuid),o=o.parent;e.value=i};return d.watch(a,n=>{n&&s(n)},{immediate:!0}),{expandedSet:e,toggleExpand:t}}const ss={key:0,class:"property-panel"},is={class:"property-group tree-group"},os={class:"tree-container"},rs={key:0,class:"tree-empty"},as={class:"property-group"},ls={class:"row"},cs={class:"property-group"},hs={class:"row"},us={class:"property-group"},ds={class:"row"},ps={key:1,class:"property-panel empty"},fs=d.defineComponent({__name:"PropertyPanel",props:{transform:{},treeData:{},selectedObject:{}},emits:["propertyChange","treeSelect","treeDelete"],setup(a,{emit:e}){const t=a,s=e,n=()=>s("propertyChange"),i=d.ref(0),o=d.toRef(t,"selectedObject"),{expandedSet:l,toggleExpand:c}=ns(o);d.provide("treeExpand",{expandedSet:l,toggleExpand:c});const u=p=>{i.value++,s("treeDelete",p)};return(p,h)=>a.transform?(d.openBlock(),d.createElementBlock("div",ss,[h[23]||(h[23]=d.createElementVNode("h3",null,"属性面板",-1)),d.createElementVNode("div",is,[h[10]||(h[10]=d.createElementVNode("label",null,"场景物体",-1)),d.createElementVNode("div",os,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(a.treeData,f=>(d.openBlock(),d.createBlock(ht,{key:f.uuid,node:f,"selected-object":a.selectedObject,version:i.value,onSelect:h[0]||(h[0]=m=>s("treeSelect",m)),onDelete:u},null,8,["node","selected-object","version"]))),128)),a.treeData.length===0?(d.openBlock(),d.createElementBlock("div",rs,"暂无物体")):d.createCommentVNode("",!0)])]),d.createElementVNode("div",as,[h[14]||(h[14]=d.createElementVNode("label",null,"位置",-1)),d.createElementVNode("div",ls,[h[11]||(h[11]=d.createElementVNode("span",null,"X:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[1]||(h[1]=f=>a.transform.position.x=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.position.x,void 0,{number:!0}]]),h[12]||(h[12]=d.createElementVNode("span",null,"Y:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[2]||(h[2]=f=>a.transform.position.y=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.position.y,void 0,{number:!0}]]),h[13]||(h[13]=d.createElementVNode("span",null,"Z:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[3]||(h[3]=f=>a.transform.position.z=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.position.z,void 0,{number:!0}]])])]),d.createElementVNode("div",cs,[h[18]||(h[18]=d.createElementVNode("label",null,"旋转 (弧度)",-1)),d.createElementVNode("div",hs,[h[15]||(h[15]=d.createElementVNode("span",null,"X:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[4]||(h[4]=f=>a.transform.rotation.x=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.rotation.x,void 0,{number:!0}]]),h[16]||(h[16]=d.createElementVNode("span",null,"Y:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[5]||(h[5]=f=>a.transform.rotation.y=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.rotation.y,void 0,{number:!0}]]),h[17]||(h[17]=d.createElementVNode("span",null,"Z:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[6]||(h[6]=f=>a.transform.rotation.z=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.rotation.z,void 0,{number:!0}]])])]),d.createElementVNode("div",us,[h[22]||(h[22]=d.createElementVNode("label",null,"缩放",-1)),d.createElementVNode("div",ds,[h[19]||(h[19]=d.createElementVNode("span",null,"X:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[7]||(h[7]=f=>a.transform.scale.x=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.scale.x,void 0,{number:!0}]]),h[20]||(h[20]=d.createElementVNode("span",null,"Y:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[8]||(h[8]=f=>a.transform.scale.y=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.scale.y,void 0,{number:!0}]]),h[21]||(h[21]=d.createElementVNode("span",null,"Z:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[9]||(h[9]=f=>a.transform.scale.z=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.scale.z,void 0,{number:!0}]])])])])):(d.openBlock(),d.createElementBlock("div",ps,[...h[24]||(h[24]=[d.createElementVNode("p",null,"未选中任何模型",-1)])]))}}),ut=ue(fs,[["__scopeId","data-v-94ef5fd1"]]),ms={class:"top-bar"},gs={class:"left-section"},ys={class:"dropdown-menu"},_s={class:"dropdown-menu sub-menu"},bs={class:"dropdown-menu"},ws={class:"dropdown-menu sub-menu"},Ts={class:"dropdown-menu"},Ms={class:"dropdown-menu"},Es={class:"dropdown-menu"},xs=d.defineComponent({__name:"TopBar",emits:["addModel","importModel"],setup(a,{emit:e}){const t=d.ref(!1),s=d.ref(!1),n=d.ref(!1),i=d.ref(!1),o=d.ref(!1),l=d.ref(!1),c=d.ref(!1),u=e,p=d.ref(null),h=()=>{var B;return(B=p.value)==null?void 0:B.click()},f=B=>{const T=B.target;T.files&&T.files.length>0&&(u("importModel",T.files[0]),T.value="")},m=()=>console.log("新建项目"),g=()=>console.log("保存场景"),y=()=>console.log("导出模型"),_=()=>console.log("撤销"),b=()=>console.log("重做"),M=()=>console.log("复制物体"),E=()=>console.log("删除物体"),x=()=>console.log("重置相机"),P=()=>console.log("切换网格"),S=()=>console.log("打开帮助"),L=()=>console.log("关于编辑器"),K=()=>console.log("打开项目"),z=()=>console.log("打开模型"),W=()=>console.log("打开场景");return(B,T)=>(d.openBlock(),d.createElementBlock("div",ms,[d.createElementVNode("div",gs,[d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[2]||(T[2]=D=>t.value=!0),onMouseleave:T[3]||(T[3]=D=>t.value=!1)},[T[17]||(T[17]=d.createElementVNode("button",{class:"menu-btn"},"文件",-1)),d.withDirectives(d.createElementVNode("div",ys,[d.createElementVNode("div",{class:"menu-item",onClick:m},"新建"),d.createElementVNode("div",{class:"menu-item dropdown-wrapper sub-trigger",onMouseenter:T[0]||(T[0]=D=>l.value=!0),onMouseleave:T[1]||(T[1]=D=>l.value=!1)},[T[16]||(T[16]=d.createElementVNode("span",null,"打开",-1)),d.withDirectives(d.createElementVNode("div",_s,[d.createElementVNode("div",{class:"menu-item",onClick:K},"打开项目"),d.createElementVNode("div",{class:"menu-item",onClick:z},"打开模型"),d.createElementVNode("div",{class:"menu-item",onClick:W},"打开场景")],512),[[d.vShow,l.value]])],32),d.createElementVNode("div",{class:"menu-item",onClick:g},"保存"),d.createElementVNode("div",{class:"menu-item",onClick:y},"导出")],512),[[d.vShow,t.value]])],32),d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[8]||(T[8]=D=>o.value=!0),onMouseleave:T[9]||(T[9]=D=>o.value=!1)},[T[19]||(T[19]=d.createElementVNode("button",{class:"menu-btn"},"添加",-1)),d.withDirectives(d.createElementVNode("div",bs,[d.createElementVNode("div",{class:"menu-item",onClick:_},"组"),d.createElementVNode("div",{class:"menu-item dropdown-wrapper sub-trigger",onMouseenter:T[6]||(T[6]=D=>c.value=!0),onMouseleave:T[7]||(T[7]=D=>c.value=!1)},[T[18]||(T[18]=d.createElementVNode("span",null,"网格",-1)),d.withDirectives(d.createElementVNode("div",ws,[d.createElementVNode("div",{class:"menu-item",onClick:T[4]||(T[4]=D=>u("addModel","box"))}," 正方体 "),d.createElementVNode("div",{class:"menu-item",onClick:T[5]||(T[5]=D=>u("addModel","sphere"))}," 球体 "),d.createElementVNode("div",{class:"menu-item",onClick:h},"导入")],512),[[d.vShow,c.value]])],32),d.createElementVNode("div",{class:"menu-item",onClick:M},"光源"),d.createElementVNode("div",{class:"menu-item",onClick:E},"摄像机")],512),[[d.vShow,o.value]])],32),d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[10]||(T[10]=D=>s.value=!0),onMouseleave:T[11]||(T[11]=D=>s.value=!1)},[T[20]||(T[20]=d.createElementVNode("button",{class:"menu-btn"},"编辑",-1)),d.withDirectives(d.createElementVNode("div",Ts,[d.createElementVNode("div",{class:"menu-item",onClick:_},"撤销"),d.createElementVNode("div",{class:"menu-item",onClick:b},"重做"),d.createElementVNode("div",{class:"menu-item",onClick:M},"复制"),d.createElementVNode("div",{class:"menu-item",onClick:E},"删除")],512),[[d.vShow,s.value]])],32),d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[12]||(T[12]=D=>n.value=!0),onMouseleave:T[13]||(T[13]=D=>n.value=!1)},[T[21]||(T[21]=d.createElementVNode("button",{class:"menu-btn"},"视图",-1)),d.withDirectives(d.createElementVNode("div",Ms,[d.createElementVNode("div",{class:"menu-item",onClick:x},"重置相机"),d.createElementVNode("div",{class:"menu-item",onClick:P},"显示网格")],512),[[d.vShow,n.value]])],32),d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[14]||(T[14]=D=>i.value=!0),onMouseleave:T[15]||(T[15]=D=>i.value=!1)},[T[22]||(T[22]=d.createElementVNode("button",{class:"menu-btn"},"帮助",-1)),d.withDirectives(d.createElementVNode("div",Es,[d.createElementVNode("div",{class:"menu-item",onClick:S},"使用帮助"),d.createElementVNode("div",{class:"menu-item",onClick:L},"关于")],512),[[d.vShow,i.value]])],32)]),T[23]||(T[23]=d.createElementVNode("div",{class:"right-section"},[d.createElementVNode("span",{class:"app-title"},"3D 模型编辑器")],-1)),d.createElementVNode("input",{type:"file",ref_key:"fileInput",ref:p,accept:".obj,.gltf,.glb",style:{display:"none"},onChange:f},null,544)]))}}),dt=ue(xs,[["__scopeId","data-v-6bb4762f"]]),Ss={class:"bottom-bar"},vs=d.defineComponent({__name:"BottomBar",setup(a){return(e,t)=>(d.openBlock(),d.createElementBlock("div",Ss,[...t[0]||(t[0]=[d.createElementVNode("div",{class:"status-left"},[d.createElementVNode("span",null,"就绪")],-1),d.createElementVNode("div",{class:"status-right"},[d.createElementVNode("span",null,"顶点: 0 | 面: 0")],-1)])]))}}),pt=ue(vs,[["__scopeId","data-v-3427bb27"]]),Rs={class:"app-layout"},As={class:"editor-container"},Ps=d.defineComponent({__name:"DrawingBoard",setup(a){const e=d.ref(null),t=d.reactive({position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}),s=g=>{t.position.x=Number(g.position.x.toFixed(3)),t.position.y=Number(g.position.y.toFixed(3)),t.position.z=Number(g.position.z.toFixed(3)),t.rotation.x=Number(g.rotation.x.toFixed(3)),t.rotation.y=Number(g.rotation.y.toFixed(3)),t.rotation.z=Number(g.rotation.z.toFixed(3)),t.scale.x=Number(g.scale.x.toFixed(3)),t.scale.y=Number(g.scale.y.toFixed(3)),t.scale.z=Number(g.scale.z.toFixed(3))},n=g=>{g.position.set(t.position.x,t.position.y,t.position.z),g.rotation.set(t.rotation.x,t.rotation.y,t.rotation.z),g.scale.set(t.scale.x,t.scale.y,t.scale.z)};tn(g=>{e.value=g,g&&s(g)}),nn(g=>{s(g)});const i=()=>{e.value&&n(e.value)},o=g=>qn(g),l=async g=>{try{await Qn(g)}catch(y){console.error("导入失败:",y),alert("导入失败:"+y.message)}},c=d.shallowRef([]);sn(g=>{c.value=g});const u=()=>{const g=on();g&&(c.value=g)},p=g=>ke(g),h=g=>Wt(g.uuid),f=d.ref(null),m=()=>{f.value&&Ht(f.value),u()};return d.onMounted(m),(g,y)=>(d.openBlock(),d.createElementBlock("div",Rs,[d.createVNode(dt,{onAddModel:o,onImportModel:l}),d.createElementVNode("div",As,[d.createElementVNode("div",{class:"canvas",ref_key:"containerRef",ref:f},null,512),d.createVNode(ut,{transform:t,"tree-data":c.value,"selected-object":e.value,onPropertyChange:i,onTreeSelect:p,onTreeDelete:h},null,8,["transform","tree-data","selected-object"])]),d.createVNode(pt)]))}}),Ls=ue(Ps,[["__scopeId","data-v-a7595f5b"]]);exports.BottomBar=pt;exports.DrawingBoard=Ls;exports.PropertyPanel=ut;exports.TopBar=dt;exports.TreeItem=ht;
5
+ `);let n=[];for(let l=0,c=s.length;l<c;l++){const u=s[l].trimStart();if(u.length===0)continue;const p=u.charAt(0);if(p!=="#")if(p==="v"){const h=u.split(Ze);switch(h[0]){case"v":t.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),h.length>=7?(Te.setRGB(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6]),r.SRGBColorSpace),t.colors.push(Te.r,Te.g,Te.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(p==="f"){const f=u.slice(1).trim().split(Ze),m=[];for(let y=0,_=f.length;y<_;y++){const b=f[y];if(b.length>0){const M=b.split("/");m.push(M)}}const g=m[0];for(let y=1,_=m.length-1;y<_;y++){const b=m[y],M=m[y+1];t.addFace(g[0],b[0],M[0],g[1],b[1],M[1],g[2],b[2],M[2])}}else if(p==="l"){const h=u.substring(1).trim().split(" ");let f=[];const m=[];if(u.indexOf("/")===-1)f=h;else for(let g=0,y=h.length;g<y;g++){const _=h[g].split("/");_[0]!==""&&f.push(_[0]),_[1]!==""&&m.push(_[1])}t.addLineGeometry(f,m)}else if(p==="p"){const f=u.slice(1).trim().split(" ");t.addPointGeometry(f)}else if((n=fn.exec(u))!==null){const h=(" "+n[0].slice(1).trim()).slice(1);t.startObject(h)}else if(gn.test(u))t.object.startMaterial(u.substring(7).trim(),t.materialLibraries);else if(mn.test(u))t.materialLibraries.push(u.substring(7).trim());else if(yn.test(u))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(p==="s"){if(n=u.split(" "),n.length>1){const f=n[1].trim().toLowerCase();t.object.smooth=f!=="0"&&f!=="off"}else t.object.smooth=!0;const h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(u==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+u+'"')}}t.finalize();const o=new r.Group;if(o.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let l=0,c=t.objects.length;l<c;l++){const u=t.objects[l],p=u.geometry,h=u.materials,f=p.type==="Line",m=p.type==="Points";let g=!1;if(p.vertices.length===0)continue;const y=new r.BufferGeometry;y.setAttribute("position",new r.Float32BufferAttribute(p.vertices,3)),p.normals.length>0&&y.setAttribute("normal",new r.Float32BufferAttribute(p.normals,3)),p.colors.length>0&&(g=!0,y.setAttribute("color",new r.Float32BufferAttribute(p.colors,3))),p.hasUVIndices===!0&&y.setAttribute("uv",new r.Float32BufferAttribute(p.uvs,2));const _=[];for(let M=0,E=h.length;M<E;M++){const x=h[M],P=x.name+"_"+x.smooth+"_"+g;let S=t.materials[P];if(this.materials!==null){if(S=this.materials.create(x.name),f&&S&&!(S instanceof r.LineBasicMaterial)){const L=new r.LineBasicMaterial;r.Material.prototype.copy.call(L,S),L.color.copy(S.color),S=L}else if(m&&S&&!(S instanceof r.PointsMaterial)){const L=new r.PointsMaterial({size:10,sizeAttenuation:!1});r.Material.prototype.copy.call(L,S),L.color.copy(S.color),L.map=S.map,S=L}}S===void 0&&(f?S=new r.LineBasicMaterial:m?S=new r.PointsMaterial({size:1,sizeAttenuation:!1}):S=new r.MeshPhongMaterial,S.name=x.name,S.flatShading=!x.smooth,S.vertexColors=g,t.materials[P]=S),_.push(S)}let b;if(_.length>1){for(let M=0,E=h.length;M<E;M++){const x=h[M];y.addGroup(x.groupStart,x.groupCount,M)}f?b=new r.LineSegments(y,_):m?b=new r.Points(y,_):b=new r.Mesh(y,_)}else f?b=new r.LineSegments(y,_[0]):m?b=new r.Points(y,_[0]):b=new r.Mesh(y,_[0]);b.name=u.name,o.add(b)}else if(t.vertices.length>0){const l=new r.PointsMaterial({size:1,sizeAttenuation:!1}),c=new r.BufferGeometry;c.setAttribute("position",new r.Float32BufferAttribute(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new r.Float32BufferAttribute(t.colors,3)),l.vertexColors=!0);const u=new r.Points(c,l);o.add(u)}return o}}function $e(a,e){if(e===r.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),a;if(e===r.TriangleFanDrawMode||e===r.TriangleStripDrawMode){let t=a.getIndex();if(t===null){const i=[],l=a.getAttribute("position");if(l!==void 0){for(let c=0;c<l.count;c++)i.push(c);a.setIndex(i),t=a.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),a}const s=t.count-2,n=[];if(e===r.TriangleFanDrawMode)for(let i=1;i<=s;i++)n.push(t.getX(0)),n.push(t.getX(i)),n.push(t.getX(i+1));else for(let i=0;i<s;i++)i%2===0?(n.push(t.getX(i)),n.push(t.getX(i+1)),n.push(t.getX(i+2))):(n.push(t.getX(i+2)),n.push(t.getX(i+1)),n.push(t.getX(i)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=a.clone();return o.setIndex(n),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),a}function wn(a){const e=new Map,t=new Map,s=a.clone();return ft(a,s,function(n,o){e.set(o,n),t.set(n,o)}),s.traverse(function(n){if(!n.isSkinnedMesh)return;const o=n,i=e.get(n),l=i.skeleton.bones;o.skeleton=i.skeleton.clone(),o.bindMatrix.copy(i.bindMatrix),o.skeleton.bones=l.map(function(c){return t.get(c)}),o.bind(o.skeleton,o.bindMatrix)}),s}function ft(a,e,t){t(a,e);for(let s=0;s<a.children.length;s++)ft(a.children[s],e.children[s],t)}class Tn extends r.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new vn(t)}),this.register(function(t){return new Rn(t)}),this.register(function(t){return new kn(t)}),this.register(function(t){return new Vn(t)}),this.register(function(t){return new jn(t)}),this.register(function(t){return new Pn(t)}),this.register(function(t){return new Ln(t)}),this.register(function(t){return new Cn(t)}),this.register(function(t){return new In(t)}),this.register(function(t){return new Sn(t)}),this.register(function(t){return new Nn(t)}),this.register(function(t){return new An(t)}),this.register(function(t){return new Dn(t)}),this.register(function(t){return new On(t)}),this.register(function(t){return new En(t)}),this.register(function(t){return new Je(t,v.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Je(t,v.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Fn(t)})}load(e,t,s,n){const o=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const u=r.LoaderUtils.extractUrlBase(e);i=r.LoaderUtils.resolveURL(u,this.path)}else i=r.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const l=function(u){n?n(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},c=new r.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(u){try{o.parse(u,i,function(p){t(p),o.manager.itemEnd(e)},l)}catch(p){l(p)}},s,l)}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,s,n){let o;const i={},l={},c=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===mt){try{i[v.KHR_BINARY_GLTF]=new Hn(e)}catch(h){n&&n(h);return}o=JSON.parse(i[v.KHR_BINARY_GLTF].content)}else o=JSON.parse(c.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new Jn(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const h=this.pluginCallbacks[p](u);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[h.name]=h,i[h.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const h=o.extensionsUsed[p],f=o.extensionsRequired||[];switch(h){case v.KHR_MATERIALS_UNLIT:i[h]=new xn;break;case v.KHR_DRACO_MESH_COMPRESSION:i[h]=new Bn(o,this.dracoLoader);break;case v.KHR_TEXTURE_TRANSFORM:i[h]=new Gn;break;case v.KHR_MESH_QUANTIZATION:i[h]=new Un;break;default:f.indexOf(h)>=0&&l[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}u.setExtensions(i),u.setPlugins(l),u.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,o){s.parse(e,t,n,o)})}}function Mn(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}function I(a,e,t){const s=a.json.materials[e];return s.extensions&&s.extensions[t]?s.extensions[t]:null}const v={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",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class En{constructor(e){this.parser=e,this.name=v.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const o=t[s];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const o=t.json,c=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const p=new r.Color(16777215);c.color!==void 0&&p.setRGB(c.color[0],c.color[1],c.color[2],r.LinearSRGBColorSpace);const h=c.range!==void 0?c.range:0;switch(c.type){case"directional":u=new r.DirectionalLight(p),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new r.PointLight(p),u.distance=h;break;case"spot":u=new r.SpotLight(p),u.distance=h,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,u.angle=c.spot.outerConeAngle,u.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return u.position.set(0,0,0),Y(u,c),c.intensity!==void 0&&(u.intensity=c.intensity),u.name=t.createUniqueName(c.name||"light_"+e),n=Promise.resolve(u),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,o=s.json.nodes[e],l=(o.extensions&&o.extensions[this.name]||{}).light;return l===void 0?null:this._loadLight(l).then(function(c){return s._getNodeRef(t.cache,l,c)})}}class xn{constructor(){this.name=v.KHR_MATERIALS_UNLIT}getMaterialType(){return r.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new r.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const i=o.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],r.LinearSRGBColorSpace),e.opacity=i[3]}o.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",o.baseColorTexture,r.SRGBColorSpace))}return Promise.all(n)}}class Sn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);return s===null||s.emissiveStrength!==void 0&&(t.emissiveIntensity=s.emissiveStrength),Promise.resolve()}}class vn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const o=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new r.Vector2(o,o)}return Promise.all(n)}}class Rn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_DISPERSION}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);return s===null||(t.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}}class An{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(n)}}class Pn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_SHEEN}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];if(t.sheenColor=new r.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,s.sheenColorFactor!==void 0){const o=s.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],r.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenColorMap",s.sheenColorTexture,r.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(n)}}class Ln{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(n)}}class Cn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_VOLUME}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new r.Color().setRGB(o[0],o[1],o[2],r.LinearSRGBColorSpace),Promise.all(n)}}class In{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_IOR}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);return s===null||(t.ior=s.ior!==void 0?s.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}}class Nn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_SPECULAR}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new r.Color().setRGB(o[0],o[1],o[2],r.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularColorMap",s.specularColorTexture,r.SRGBColorSpace)),Promise.all(n)}}class On{constructor(e){this.parser=e,this.name=v.EXT_MATERIALS_BUMP}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&n.push(this.parser.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(n)}}class Dn{constructor(e){this.parser=e,this.name=v.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return I(this.parser,e,this.name)!==null?r.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=I(this.parser,e,this.name);if(s===null)return Promise.resolve();const n=[];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(n)}}class kn{constructor(e){this.parser=e,this.name=v.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const o=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,i)}}class Vn{constructor(e){this.parser=e,this.name=v.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],l=n.images[i.source];let c=s.textureLoader;if(l.uri){const u=s.options.manager.getHandler(l.uri);u!==null&&(c=u)}return s.loadTextureImage(e,i.source,c)}}class jn{constructor(e){this.parser=e,this.name=v.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],l=n.images[i.source];let c=s.textureLoader;if(l.uri){const u=s.options.manager.getHandler(l.uri);u!==null&&(c=u)}return s.loadTextureImage(e,i.source,c)}}class Je{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],o=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.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 o.then(function(l){const c=n.byteOffset||0,u=n.byteLength||0,p=n.count,h=n.byteStride,f=new Uint8Array(l,c,u);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(p,h,f,n.mode,n.filter).then(function(m){return m.buffer}):i.ready.then(function(){const m=new ArrayBuffer(p*h);return i.decodeGltfBuffer(new Uint8Array(m),p,h,f,n.mode,n.filter),m})})}else return null}}class Fn{constructor(e){this.name=v.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const u of n.primitives)if(u.mode!==B.TRIANGLES&&u.mode!==B.TRIANGLE_STRIP&&u.mode!==B.TRIANGLE_FAN&&u.mode!==void 0)return null;const i=s.extensions[this.name].attributes,l=[],c={};for(const u in i)l.push(this.parser.getDependency("accessor",i[u]).then(p=>(c[u]=p,c[u])));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then(u=>{const p=u.pop(),h=p.isGroup?p.children:[p],f=u[0].count,m=[];for(const g of h){const y=new r.Matrix4,_=new r.Vector3,b=new r.Quaternion,M=new r.Vector3(1,1,1),E=new r.InstancedMesh(g.geometry,g.material,f);for(let x=0;x<f;x++)c.TRANSLATION&&_.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&b.fromBufferAttribute(c.ROTATION,x),c.SCALE&&M.fromBufferAttribute(c.SCALE,x),E.setMatrixAt(x,y.compose(_,b,M));for(const x in c)if(x==="_COLOR_0"){const P=c[x];E.instanceColor=new r.InstancedBufferAttribute(P.array,P.itemSize,P.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&g.geometry.setAttribute(x,c[x]);r.Object3D.prototype.copy.call(E,g),this.parser.assignFinalMaterial(E),m.push(E)}return p.isGroup?(p.clear(),p.add(...m),p):m[0]}))}}const mt="glTF",le=12,et={JSON:1313821514,BIN:5130562};class Hn{constructor(e){this.name=v.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,le),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==mt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-le,o=new DataView(e,le);let i=0;for(;i<n;){const l=o.getUint32(i,!0);i+=4;const c=o.getUint32(i,!0);if(i+=4,c===et.JSON){const u=new Uint8Array(e,le+i,l);this.content=s.decode(u)}else if(c===et.BIN){const u=le+i;this.body=e.slice(u,u+l)}i+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Bn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=v.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,l={},c={},u={};for(const p in i){const h=Oe[p]||p.toLowerCase();l[h]=i[p]}for(const p in e.attributes){const h=Oe[p]||p.toLowerCase();if(i[p]!==void 0){const f=s.accessors[e.attributes[p]],m=oe[f.componentType];u[h]=m.name,c[h]=f.normalized===!0}}return t.getDependency("bufferView",o).then(function(p){return new Promise(function(h,f){n.decodeDracoFile(p,function(m){for(const g in m.attributes){const y=m.attributes[g],_=c[g];_!==void 0&&(y.normalized=_)}h(m)},l,u,r.LinearSRGBColorSpace,f)})})}}class Gn{constructor(){this.name=v.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 Un{constructor(){this.name=v.KHR_MESH_QUANTIZATION}}class gt extends r.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,o=e*n*3+n;for(let i=0;i!==n;i++)t[i]=s[o+i];return t}interpolate_(e,t,s,n){const o=this.resultBuffer,i=this.sampleValues,l=this.valueSize,c=l*2,u=l*3,p=n-t,h=(s-t)/p,f=h*h,m=f*h,g=e*u,y=g-u,_=-2*m+3*f,b=m-f,M=1-_,E=b-f+h;for(let x=0;x!==l;x++){const P=i[y+x+l],S=i[y+x+c]*p,L=i[g+x+l],K=i[g+x]*p;o[x]=M*P+E*S+_*L+b*K}return o}}const zn=new r.Quaternion;class Xn extends gt{interpolate_(e,t,s,n){const o=super.interpolate_(e,t,s,n);return zn.fromArray(o).normalize().toArray(o),o}}const B={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},oe={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},tt={9728:r.NearestFilter,9729:r.LinearFilter,9984:r.NearestMipmapNearestFilter,9985:r.LinearMipmapNearestFilter,9986:r.NearestMipmapLinearFilter,9987:r.LinearMipmapLinearFilter},nt={33071:r.ClampToEdgeWrapping,33648:r.MirroredRepeatWrapping,10497:r.RepeatWrapping},Le={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Oe={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"},q={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Yn={CUBICSPLINE:void 0,LINEAR:r.InterpolateLinear,STEP:r.InterpolateDiscrete},Ce={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Kn(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new r.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:r.FrontSide})),a.DefaultMaterial}function J(a,e,t){for(const s in t.extensions)a[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function Y(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Zn(a,e,t){let s=!1,n=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const h=e[u];if(h.POSITION!==void 0&&(s=!0),h.NORMAL!==void 0&&(n=!0),h.COLOR_0!==void 0&&(o=!0),s&&n&&o)break}if(!s&&!n&&!o)return Promise.resolve(a);const i=[],l=[],c=[];for(let u=0,p=e.length;u<p;u++){const h=e[u];if(s){const f=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):a.attributes.position;i.push(f)}if(n){const f=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):a.attributes.normal;l.push(f)}if(o){const f=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):a.attributes.color;c.push(f)}}return Promise.all([Promise.all(i),Promise.all(l),Promise.all(c)]).then(function(u){const p=u[0],h=u[1],f=u[2];return s&&(a.morphAttributes.position=p),n&&(a.morphAttributes.normal=h),o&&(a.morphAttributes.color=f),a.morphTargetsRelative=!0,a})}function Qn(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)a.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(a.morphTargetInfluences.length===t.length){a.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)a.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function qn(a){let e;const t=a.extensions&&a.extensions[v.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ie(t.attributes):e=a.indices+":"+Ie(a.attributes)+":"+a.mode,a.targets!==void 0)for(let s=0,n=a.targets.length;s<n;s++)e+=":"+Ie(a.targets[s]);return e}function Ie(a){let e="";const t=Object.keys(a).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+a[t[s]]+";";return e}function De(a){switch(a){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 Wn(a){return a.search(/\.jpe?g($|\?)/i)>0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":a.search(/\.ktx2($|\?)/i)>0||a.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const $n=new r.Matrix4;class Jn{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Mn,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 s=!1,n=-1,o=!1,i=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const l=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(l)===!0;const c=l.match(/Version\/(\d+)/);n=s&&c?parseInt(c[1],10):-1,o=l.indexOf("Firefox")>-1,i=o?l.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||o&&i<98?this.textureLoader=new r.TextureLoader(this.options.manager):this.textureLoader=new r.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new r.FileLoader(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 s=this,n=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(i){const l={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:s,userData:{}};return J(o,l,n),Y(l,n),Promise.all(s._invokeAll(function(c){return c.afterRoot&&c.afterRoot(l)})).then(function(){for(const c of l.scenes)c.updateMatrixWorld();e(l)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,o=t.length;n<o;n++){const i=t[n].joints;for(let l=0,c=i.length;l<c;l++)e[i[l]].isBone=!0}for(let n=0,o=e.length;n<o;n++){const i=e[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(s[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.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,s){if(e.refs[t]<=1)return s;const n=s.clone(),o=(i,l)=>{const c=this.associations.get(i);c!=null&&this.associations.set(l,c);for(const[u,p]of i.children.entries())o(p,l.children[u])};return o(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const o=e(t[n]);o&&s.push(o)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":n=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(o,i){return s.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=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[v.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(o,i){s.load(r.LoaderUtils.resolveURL(t.uri,n.path),o,void 0,function(){i(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(s){const n=t.byteLength||0,o=t.byteOffset||0;return s.slice(o,o+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const i=Le[n.type],l=oe[n.componentType],c=n.normalized===!0,u=new l(n.count*i);return Promise.resolve(new r.BufferAttribute(u,i,c))}const o=[];return n.bufferView!==void 0?o.push(this.getDependency("bufferView",n.bufferView)):o.push(null),n.sparse!==void 0&&(o.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(o).then(function(i){const l=i[0],c=Le[n.type],u=oe[n.componentType],p=u.BYTES_PER_ELEMENT,h=p*c,f=n.byteOffset||0,m=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let y,_;if(m&&m!==h){const b=Math.floor(f/m),M="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+b+":"+n.count;let E=t.cache.get(M);E||(y=new u(l,b*m,n.count*m/p),E=new r.InterleavedBuffer(y,m/p),t.cache.add(M,E)),_=new r.InterleavedBufferAttribute(E,c,f%m/p,g)}else l===null?y=new u(n.count*c):y=new u(l,f,n.count*c),_=new r.BufferAttribute(y,c,g);if(n.sparse!==void 0){const b=Le.SCALAR,M=oe[n.sparse.indices.componentType],E=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,P=new M(i[1],E,n.sparse.count*b),S=new u(i[2],x,n.sparse.count*c);l!==null&&(_=new r.BufferAttribute(_.array.slice(),_.itemSize,_.normalized)),_.normalized=!1;for(let L=0,K=P.length;L<K;L++){const z=P[L];if(_.setX(z,S[L*c]),c>=2&&_.setY(z,S[L*c+1]),c>=3&&_.setZ(z,S[L*c+2]),c>=4&&_.setW(z,S[L*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}_.normalized=g}return _})}loadTexture(e){const t=this.json,s=this.options,o=t.textures[e].source,i=t.images[o];let l=this.textureLoader;if(i.uri){const c=s.manager.getHandler(i.uri);c!==null&&(l=c)}return this.loadTextureImage(e,o,l)}loadTextureImage(e,t,s){const n=this,o=this.json,i=o.textures[e],l=o.images[t],c=(l.uri||l.bufferView)+":"+i.sampler;if(this.textureCache[c])return this.textureCache[c];const u=this.loadImageSource(t,s).then(function(p){p.flipY=!1,p.name=i.name||l.name||"",p.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(p.name=l.uri);const f=(o.samplers||{})[i.sampler]||{};return p.magFilter=tt[f.magFilter]||r.LinearFilter,p.minFilter=tt[f.minFilter]||r.LinearMipmapLinearFilter,p.wrapS=nt[f.wrapS]||r.RepeatWrapping,p.wrapT=nt[f.wrapT]||r.RepeatWrapping,p.generateMipmaps=!p.isCompressedTexture&&p.minFilter!==r.NearestFilter&&p.minFilter!==r.LinearFilter,n.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[c]=u,u}loadImageSource(e,t){const s=this,n=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const i=n.images[e],l=self.URL||self.webkitURL;let c=i.uri||"",u=!1;if(i.bufferView!==void 0)c=s.getDependency("bufferView",i.bufferView).then(function(h){u=!0;const f=new Blob([h],{type:i.mimeType});return c=l.createObjectURL(f),c});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(c).then(function(h){return new Promise(function(f,m){let g=f;t.isImageBitmapLoader===!0&&(g=function(y){const _=new r.Texture(y);_.needsUpdate=!0,f(_)}),t.load(r.LoaderUtils.resolveURL(h,o.path),g,void 0,m)})}).then(function(h){return u===!0&&l.revokeObjectURL(c),Y(h,i),h.userData.mimeType=i.mimeType||Wn(i.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=p,p}assignTexture(e,t,s,n){const o=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),o.extensions[v.KHR_TEXTURE_TRANSFORM]){const l=s.extensions!==void 0?s.extensions[v.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const c=o.associations.get(i);i=o.extensions[v.KHR_TEXTURE_TRANSFORM].extendTexture(i,l),o.associations.set(i,c)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+s.uuid;let c=this.cache.get(l);c||(c=new r.PointsMaterial,r.Material.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,c.sizeAttenuation=!1,this.cache.add(l,c)),s=c}else if(e.isLine){const l="LineBasicMaterial:"+s.uuid;let c=this.cache.get(l);c||(c=new r.LineBasicMaterial,r.Material.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,this.cache.add(l,c)),s=c}if(n||o||i){let l="ClonedMaterial:"+s.uuid+":";n&&(l+="derivative-tangents:"),o&&(l+="vertex-colors:"),i&&(l+="flat-shading:");let c=this.cache.get(l);c||(c=s.clone(),o&&(c.vertexColors=!0),i&&(c.flatShading=!0),n&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(l,c),this.associations.set(c,this.associations.get(s))),s=c}e.material=s}getMaterialType(){return r.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,o=s.materials[e];let i;const l={},c=o.extensions||{},u=[];if(c[v.KHR_MATERIALS_UNLIT]){const h=n[v.KHR_MATERIALS_UNLIT];i=h.getMaterialType(),u.push(h.extendParams(l,o,t))}else{const h=o.pbrMetallicRoughness||{};if(l.color=new r.Color(1,1,1),l.opacity=1,Array.isArray(h.baseColorFactor)){const f=h.baseColorFactor;l.color.setRGB(f[0],f[1],f[2],r.LinearSRGBColorSpace),l.opacity=f[3]}h.baseColorTexture!==void 0&&u.push(t.assignTexture(l,"map",h.baseColorTexture,r.SRGBColorSpace)),l.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,l.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(l,"metalnessMap",h.metallicRoughnessTexture)),u.push(t.assignTexture(l,"roughnessMap",h.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,l)})))}o.doubleSided===!0&&(l.side=r.DoubleSide);const p=o.alphaMode||Ce.OPAQUE;if(p===Ce.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,p===Ce.MASK&&(l.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&i!==r.MeshBasicMaterial&&(u.push(t.assignTexture(l,"normalMap",o.normalTexture)),l.normalScale=new r.Vector2(1,1),o.normalTexture.scale!==void 0)){const h=o.normalTexture.scale;l.normalScale.set(h,h)}if(o.occlusionTexture!==void 0&&i!==r.MeshBasicMaterial&&(u.push(t.assignTexture(l,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&i!==r.MeshBasicMaterial){const h=o.emissiveFactor;l.emissive=new r.Color().setRGB(h[0],h[1],h[2],r.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&i!==r.MeshBasicMaterial&&u.push(t.assignTexture(l,"emissiveMap",o.emissiveTexture,r.SRGBColorSpace)),Promise.all(u).then(function(){const h=new i(l);return o.name&&(h.name=o.name),Y(h,o),t.associations.set(h,{materials:e}),o.extensions&&J(n,h,o),h})}createUniqueName(e){const t=r.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function o(l){return s[v.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,t).then(function(c){return st(c,l,t)})}const i=[];for(let l=0,c=e.length;l<c;l++){const u=e[l],p=qn(u),h=n[p];if(h)i.push(h.promise);else{let f;u.extensions&&u.extensions[v.KHR_DRACO_MESH_COMPRESSION]?f=o(u):f=st(new r.BufferGeometry,u,t),n[p]={primitive:u,promise:f},i.push(f)}}return Promise.all(i)}loadMesh(e){const t=this,s=this.json,n=this.extensions,o=s.meshes[e],i=o.primitives,l=[];for(let c=0,u=i.length;c<u;c++){const p=i[c].material===void 0?Kn(this.cache):this.getDependency("material",i[c].material);l.push(p)}return l.push(t.loadGeometries(i)),Promise.all(l).then(function(c){const u=c.slice(0,c.length-1),p=c[c.length-1],h=[];for(let m=0,g=p.length;m<g;m++){const y=p[m],_=i[m];let b;const M=u[m];if(_.mode===B.TRIANGLES||_.mode===B.TRIANGLE_STRIP||_.mode===B.TRIANGLE_FAN||_.mode===void 0)b=o.isSkinnedMesh===!0?new r.SkinnedMesh(y,M):new r.Mesh(y,M),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),_.mode===B.TRIANGLE_STRIP?b.geometry=$e(b.geometry,r.TriangleStripDrawMode):_.mode===B.TRIANGLE_FAN&&(b.geometry=$e(b.geometry,r.TriangleFanDrawMode));else if(_.mode===B.LINES)b=new r.LineSegments(y,M);else if(_.mode===B.LINE_STRIP)b=new r.Line(y,M);else if(_.mode===B.LINE_LOOP)b=new r.LineLoop(y,M);else if(_.mode===B.POINTS)b=new r.Points(y,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(b.geometry.morphAttributes).length>0&&Qn(b,o),b.name=t.createUniqueName(o.name||"mesh_"+e),Y(b,o),_.extensions&&J(n,b,_),t.assignFinalMaterial(b),h.push(b)}for(let m=0,g=h.length;m<g;m++)t.associations.set(h[m],{meshes:e,primitives:m});if(h.length===1)return o.extensions&&J(n,h[0],o),h[0];const f=new r.Group;o.extensions&&J(n,f,o),t.associations.set(f,{meshes:e});for(let m=0,g=h.length;m<g;m++)f.add(h[m]);return f})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new r.PerspectiveCamera(r.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new r.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),Y(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,o=t.joints.length;n<o;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const o=n.pop(),i=n,l=[],c=[];for(let u=0,p=i.length;u<p;u++){const h=i[u];if(h){l.push(h);const f=new r.Matrix4;o!==null&&f.fromArray(o.array,u*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new r.Skeleton(l,c)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],o=n.name?n.name:"animation_"+e,i=[],l=[],c=[],u=[],p=[];for(let h=0,f=n.channels.length;h<f;h++){const m=n.channels[h],g=n.samplers[m.sampler],y=m.target,_=y.node,b=n.parameters!==void 0?n.parameters[g.input]:g.input,M=n.parameters!==void 0?n.parameters[g.output]:g.output;y.node!==void 0&&(i.push(this.getDependency("node",_)),l.push(this.getDependency("accessor",b)),c.push(this.getDependency("accessor",M)),u.push(g),p.push(y))}return Promise.all([Promise.all(i),Promise.all(l),Promise.all(c),Promise.all(u),Promise.all(p)]).then(function(h){const f=h[0],m=h[1],g=h[2],y=h[3],_=h[4],b=[];for(let E=0,x=f.length;E<x;E++){const P=f[E],S=m[E],L=g[E],K=y[E],z=_[E];if(P===void 0)continue;P.updateMatrix&&P.updateMatrix();const W=s._createAnimationTracks(P,S,L,K,z);if(W)for(let G=0;G<W.length;G++)b.push(W[G])}const M=new r.AnimationClip(o,void 0,b);return Y(M,n),M})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(o){const i=s._getNodeRef(s.meshCache,n.mesh,o);return n.weights!==void 0&&i.traverse(function(l){if(l.isMesh)for(let c=0,u=n.weights.length;c<u;c++)l.morphTargetInfluences[c]=n.weights[c]}),i})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],o=s._loadNodeShallow(e),i=[],l=n.children||[];for(let u=0,p=l.length;u<p;u++)i.push(s.getDependency("node",l[u]));const c=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([o,Promise.all(i),c]).then(function(u){const p=u[0],h=u[1],f=u[2];f!==null&&p.traverse(function(m){m.isSkinnedMesh&&m.bind(f,$n)});for(let m=0,g=h.length;m<g;m++)p.add(h[m]);if(p.userData.pivot!==void 0&&h.length>0){const m=p.userData.pivot,g=h[0];p.pivot=new r.Vector3().fromArray(m),p.position.x-=m[0],p.position.y-=m[1],p.position.z-=m[2],g.position.set(0,0,0),delete p.userData.pivot}return p})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],i=o.name?n.createUniqueName(o.name):"",l=[],c=n._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return c&&l.push(c),o.camera!==void 0&&l.push(n.getDependency("camera",o.camera).then(function(u){return n._getNodeRef(n.cameraCache,o.camera,u)})),n._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){l.push(u)}),this.nodeCache[e]=Promise.all(l).then(function(u){let p;if(o.isBone===!0?p=new r.Bone:u.length>1?p=new r.Group:u.length===1?p=u[0]:p=new r.Object3D,p!==u[0])for(let h=0,f=u.length;h<f;h++)p.add(u[h]);if(o.name&&(p.userData.name=o.name,p.name=i),Y(p,o),o.extensions&&J(s,p,o),o.matrix!==void 0){const h=new r.Matrix4;h.fromArray(o.matrix),p.applyMatrix4(h)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);if(!n.associations.has(p))n.associations.set(p,{});else if(o.mesh!==void 0&&n.meshCache.refs[o.mesh]>1){const h=n.associations.get(p);n.associations.set(p,{...h})}return n.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,o=new r.Group;s.name&&(o.name=n.createUniqueName(s.name)),Y(o,s),s.extensions&&J(t,o,s);const i=s.nodes||[],l=[];for(let c=0,u=i.length;c<u;c++)l.push(n.getDependency("node",i[c]));return Promise.all(l).then(function(c){for(let p=0,h=c.length;p<h;p++){const f=c[p];f.parent!==null?o.add(wn(f)):o.add(f)}const u=p=>{const h=new Map;for(const[f,m]of n.associations)(f instanceof r.Material||f instanceof r.Texture)&&h.set(f,m);return p.traverse(f=>{const m=n.associations.get(f);m!=null&&h.set(f,m)}),h};return n.associations=u(o),o})}_createAnimationTracks(e,t,s,n,o){const i=[],l=e.name?e.name:e.uuid,c=[];function u(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}q[o.path]===q.weights?(u(e),e.isGroup&&e.children.forEach(u)):c.push(l);let p;switch(q[o.path]){case q.weights:p=r.NumberKeyframeTrack;break;case q.rotation:p=r.QuaternionKeyframeTrack;break;case q.translation:case q.scale:p=r.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:p=r.NumberKeyframeTrack;break;case 2:case 3:default:p=r.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?Yn[n.interpolation]:r.InterpolateLinear,f=this._getArrayFromAccessor(s);for(let m=0,g=c.length;m<g;m++){const y=new p(c[m]+"."+q[o.path],t.array,f,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),i.push(y)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=De(t.constructor),n=new Float32Array(t.length);for(let o=0,i=t.length;o<i;o++)n[o]=t[o]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof r.QuaternionKeyframeTrack?Xn:gt;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function es(a,e,t){const s=e.attributes,n=new r.Box3;if(s.POSITION!==void 0){const l=t.json.accessors[s.POSITION],c=l.min,u=l.max;if(c!==void 0&&u!==void 0){if(n.set(new r.Vector3(c[0],c[1],c[2]),new r.Vector3(u[0],u[1],u[2])),l.normalized){const p=De(oe[l.componentType]);n.min.multiplyScalar(p),n.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const l=new r.Vector3,c=new r.Vector3;for(let u=0,p=o.length;u<p;u++){const h=o[u];if(h.POSITION!==void 0){const f=t.json.accessors[h.POSITION],m=f.min,g=f.max;if(m!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(m[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(m[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(m[2]),Math.abs(g[2]))),f.normalized){const y=De(oe[f.componentType]);c.multiplyScalar(y)}l.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(l)}a.boundingBox=n;const i=new r.Sphere;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,a.boundingSphere=i}function st(a,e,t){const s=e.attributes,n=[];function o(i,l){return t.getDependency("accessor",i).then(function(c){a.setAttribute(l,c)})}for(const i in s){const l=Oe[i]||i.toLowerCase();l in a.attributes||n.push(o(s[i],l))}if(e.indices!==void 0&&!a.index){const i=t.getDependency("accessor",e.indices).then(function(l){a.setIndex(l)});n.push(i)}return r.ColorManagement.workingColorSpace!==r.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${r.ColorManagement.workingColorSpace}" not supported.`),Y(a,e),es(a,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Zn(a,e.targets,t):a})}function yt(){const a=new O.BoxGeometry(1,1,1),e=new O.MeshStandardMaterial({color:43775}),t=new O.Mesh(a,e);return t.position.y=.5,t.userData.isMovable=!0,t.name="正方体",ue(t,!0),t}function _t(){const a=new O.SphereGeometry(.6,32,32),e=new O.MeshStandardMaterial({color:16746496}),t=new O.Mesh(a,e);return t.position.y=.6,t.userData.isMovable=!0,t.name="球体",ue(t,!0),t}function bt(a){return new Promise((e,t)=>{var i;const s=(i=a.name.split(".").pop())==null?void 0:i.toLowerCase(),n=URL.createObjectURL(a);let o;if(s==="obj")o=new bn;else if(s==="gltf"||s==="glb")o=new Tn;else{t(new Error("不支持的文件格式,请使用 .obj, .gltf, .glb"));return}o.load(n,l=>{const c=s==="gltf"||s==="glb"?l.scene:l;c.traverse(h=>{var f;h.userData.isMovable=!0,h.name||(h.name=h.type),h.type==="Mesh"&&(h.frustumCulled=!0,(f=h.geometry)==null||f.computeVertexNormals())});const p=new O.Box3().setFromObject(c).getCenter(new O.Vector3);c.position.sub(p),ue(c,!0),e(c)},void 0,l=>t(l))})}function wt(a){switch(a){case"box":yt();break;case"sphere":_t();break}}const ts={key:1,class:"toggle-placeholder"},ns={class:"tree-icon"},ss={class:"tree-name"},os={key:0,class:"tree-children"},is=d.defineComponent({__name:"TreeItem",props:{node:{},selectedObject:{},version:{}},emits:["select","delete"],setup(a,{emit:e}){const t=a,s=e,n=d.ref(null),{expandedSet:o,toggleExpand:i}=d.inject("treeExpand"),l=d.computed(()=>o.value.has(t.node.uuid)),c=d.computed(()=>(t.version,t.node.children.some(y=>y.userData.isMovable===!0))),u=d.computed(()=>(t.version,t.node.children.filter(y=>y.userData.isMovable===!0))),p=d.computed(()=>{var y;return((y=t.selectedObject)==null?void 0:y.uuid)===t.node.uuid});d.watchEffect(()=>{p.value&&n.value&&n.value.scrollIntoView({block:"nearest",behavior:"smooth"})},{flush:"post"});const h=y=>{y.stopPropagation(),s("select",t.node)},f=y=>{y.stopPropagation(),s("delete",t.node)},m=y=>y.type==="Mesh"||y.type==="Sprite"?"🟦":y.type==="Light"?"💡":"📦",g=y=>y.name||`${y.type} (${y.id})`;return(y,_)=>{const b=d.resolveComponent("TreeItem",!0);return d.openBlock(),d.createElementBlock("div",{class:"tree-node",ref_key:"nodeRef",ref:n},[d.createElementVNode("div",{class:d.normalizeClass(["tree-item",{selected:p.value}]),onClick:h},[c.value?(d.openBlock(),d.createElementBlock("span",{key:0,class:"toggle-icon",onClick:_[0]||(_[0]=d.withModifiers(M=>d.unref(i)(a.node.uuid),["stop"]))},d.toDisplayString(l.value?"▼":"▶"),1)):(d.openBlock(),d.createElementBlock("span",ts)),d.createElementVNode("span",ns,d.toDisplayString(m(a.node)),1),d.createElementVNode("span",ss,d.toDisplayString(g(a.node)),1),d.createElementVNode("button",{class:"tree-delete",onClick:d.withModifiers(f,["stop"])},"×")],2),l.value&&c.value?(d.openBlock(),d.createElementBlock("div",os,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(u.value,M=>(d.openBlock(),d.createBlock(b,{key:M.uuid,node:M,"selected-object":a.selectedObject,version:a.version,onSelect:_[1]||(_[1]=E=>s("select",E)),onDelete:_[2]||(_[2]=E=>s("delete",E))},null,8,["node","selected-object","version"]))),128))])):d.createCommentVNode("",!0)],512)}}}),de=(a,e)=>{const t=a.__vccOpts||a;for(const[s,n]of e)t[s]=n;return t},Tt=de(is,[["__scopeId","data-v-5ad9c842"]]);function Mt(a){const e=d.ref(new Set),t=n=>{const o=new Set(e.value);o.has(n)?o.delete(n):o.add(n),e.value=o},s=n=>{if(!n)return;const o=new Set(e.value);let i=n.parent;for(;i&&i.type!=="Scene";)o.add(i.uuid),i=i.parent;e.value=o};return d.watch(a,n=>{n&&s(n)},{immediate:!0}),{expandedSet:e,toggleExpand:t}}const rs={key:0,class:"property-panel"},as={class:"property-group tree-group"},ls={class:"tree-container"},cs={key:0,class:"tree-empty"},hs={class:"property-group"},us={class:"row"},ds={class:"property-group"},ps={class:"row"},fs={class:"property-group"},ms={class:"row"},gs={key:1,class:"property-panel empty"},ys=d.defineComponent({__name:"PropertyPanel",props:{transform:{},treeData:{},selectedObject:{}},emits:["propertyChange","treeSelect","treeDelete"],setup(a,{emit:e}){const t=a,s=e,n=()=>s("propertyChange"),o=d.ref(0),i=d.toRef(t,"selectedObject"),{expandedSet:l,toggleExpand:c}=Mt(i);d.provide("treeExpand",{expandedSet:l,toggleExpand:c});const u=p=>{o.value++,s("treeDelete",p)};return(p,h)=>a.transform?(d.openBlock(),d.createElementBlock("div",rs,[h[23]||(h[23]=d.createElementVNode("h3",null,"属性面板",-1)),d.createElementVNode("div",as,[h[10]||(h[10]=d.createElementVNode("label",null,"场景物体",-1)),d.createElementVNode("div",ls,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(a.treeData,f=>(d.openBlock(),d.createBlock(Tt,{key:f.uuid,node:f,"selected-object":a.selectedObject,version:o.value,onSelect:h[0]||(h[0]=m=>s("treeSelect",m)),onDelete:u},null,8,["node","selected-object","version"]))),128)),a.treeData.length===0?(d.openBlock(),d.createElementBlock("div",cs,"暂无物体")):d.createCommentVNode("",!0)])]),d.createElementVNode("div",hs,[h[14]||(h[14]=d.createElementVNode("label",null,"位置",-1)),d.createElementVNode("div",us,[h[11]||(h[11]=d.createElementVNode("span",null,"X:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[1]||(h[1]=f=>a.transform.position.x=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.position.x,void 0,{number:!0}]]),h[12]||(h[12]=d.createElementVNode("span",null,"Y:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[2]||(h[2]=f=>a.transform.position.y=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.position.y,void 0,{number:!0}]]),h[13]||(h[13]=d.createElementVNode("span",null,"Z:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[3]||(h[3]=f=>a.transform.position.z=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.position.z,void 0,{number:!0}]])])]),d.createElementVNode("div",ds,[h[18]||(h[18]=d.createElementVNode("label",null,"旋转 (弧度)",-1)),d.createElementVNode("div",ps,[h[15]||(h[15]=d.createElementVNode("span",null,"X:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[4]||(h[4]=f=>a.transform.rotation.x=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.rotation.x,void 0,{number:!0}]]),h[16]||(h[16]=d.createElementVNode("span",null,"Y:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[5]||(h[5]=f=>a.transform.rotation.y=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.rotation.y,void 0,{number:!0}]]),h[17]||(h[17]=d.createElementVNode("span",null,"Z:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[6]||(h[6]=f=>a.transform.rotation.z=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.rotation.z,void 0,{number:!0}]])])]),d.createElementVNode("div",fs,[h[22]||(h[22]=d.createElementVNode("label",null,"缩放",-1)),d.createElementVNode("div",ms,[h[19]||(h[19]=d.createElementVNode("span",null,"X:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[7]||(h[7]=f=>a.transform.scale.x=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.scale.x,void 0,{number:!0}]]),h[20]||(h[20]=d.createElementVNode("span",null,"Y:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[8]||(h[8]=f=>a.transform.scale.y=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.scale.y,void 0,{number:!0}]]),h[21]||(h[21]=d.createElementVNode("span",null,"Z:",-1)),d.withDirectives(d.createElementVNode("input",{type:"number","onUpdate:modelValue":h[9]||(h[9]=f=>a.transform.scale.z=f),step:"0.01",onInput:n},null,544),[[d.vModelText,a.transform.scale.z,void 0,{number:!0}]])])])])):(d.openBlock(),d.createElementBlock("div",gs,[...h[24]||(h[24]=[d.createElementVNode("p",null,"未选中任何模型",-1)])]))}}),Et=de(ys,[["__scopeId","data-v-94ef5fd1"]]),_s={class:"top-bar"},bs={class:"left-section"},ws={class:"dropdown-menu"},Ts={class:"dropdown-menu sub-menu"},Ms={class:"dropdown-menu"},Es={class:"dropdown-menu sub-menu"},xs={class:"dropdown-menu"},Ss={class:"dropdown-menu"},vs={class:"dropdown-menu"},Rs=d.defineComponent({__name:"TopBar",emits:["addModel","importModel"],setup(a,{emit:e}){const t=d.ref(!1),s=d.ref(!1),n=d.ref(!1),o=d.ref(!1),i=d.ref(!1),l=d.ref(!1),c=d.ref(!1),u=e,p=d.ref(null),h=()=>{var G;return(G=p.value)==null?void 0:G.click()},f=G=>{const T=G.target;T.files&&T.files.length>0&&(u("importModel",T.files[0]),T.value="")},m=()=>console.log("新建项目"),g=()=>console.log("保存场景"),y=()=>console.log("导出模型"),_=()=>console.log("撤销"),b=()=>console.log("重做"),M=()=>console.log("复制物体"),E=()=>console.log("删除物体"),x=()=>console.log("重置相机"),P=()=>console.log("切换网格"),S=()=>console.log("打开帮助"),L=()=>console.log("关于编辑器"),K=()=>console.log("打开项目"),z=()=>console.log("打开模型"),W=()=>console.log("打开场景");return(G,T)=>(d.openBlock(),d.createElementBlock("div",_s,[d.createElementVNode("div",bs,[d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[2]||(T[2]=D=>t.value=!0),onMouseleave:T[3]||(T[3]=D=>t.value=!1)},[T[17]||(T[17]=d.createElementVNode("button",{class:"menu-btn"},"文件",-1)),d.withDirectives(d.createElementVNode("div",ws,[d.createElementVNode("div",{class:"menu-item",onClick:m},"新建"),d.createElementVNode("div",{class:"menu-item dropdown-wrapper sub-trigger",onMouseenter:T[0]||(T[0]=D=>l.value=!0),onMouseleave:T[1]||(T[1]=D=>l.value=!1)},[T[16]||(T[16]=d.createElementVNode("span",null,"打开",-1)),d.withDirectives(d.createElementVNode("div",Ts,[d.createElementVNode("div",{class:"menu-item",onClick:K},"打开项目"),d.createElementVNode("div",{class:"menu-item",onClick:z},"打开模型"),d.createElementVNode("div",{class:"menu-item",onClick:W},"打开场景")],512),[[d.vShow,l.value]])],32),d.createElementVNode("div",{class:"menu-item",onClick:g},"保存"),d.createElementVNode("div",{class:"menu-item",onClick:y},"导出")],512),[[d.vShow,t.value]])],32),d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[8]||(T[8]=D=>i.value=!0),onMouseleave:T[9]||(T[9]=D=>i.value=!1)},[T[19]||(T[19]=d.createElementVNode("button",{class:"menu-btn"},"添加",-1)),d.withDirectives(d.createElementVNode("div",Ms,[d.createElementVNode("div",{class:"menu-item",onClick:_},"组"),d.createElementVNode("div",{class:"menu-item dropdown-wrapper sub-trigger",onMouseenter:T[6]||(T[6]=D=>c.value=!0),onMouseleave:T[7]||(T[7]=D=>c.value=!1)},[T[18]||(T[18]=d.createElementVNode("span",null,"网格",-1)),d.withDirectives(d.createElementVNode("div",Es,[d.createElementVNode("div",{class:"menu-item",onClick:T[4]||(T[4]=D=>u("addModel","box"))}," 正方体 "),d.createElementVNode("div",{class:"menu-item",onClick:T[5]||(T[5]=D=>u("addModel","sphere"))}," 球体 "),d.createElementVNode("div",{class:"menu-item",onClick:h},"导入")],512),[[d.vShow,c.value]])],32),d.createElementVNode("div",{class:"menu-item",onClick:M},"光源"),d.createElementVNode("div",{class:"menu-item",onClick:E},"摄像机")],512),[[d.vShow,i.value]])],32),d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[10]||(T[10]=D=>s.value=!0),onMouseleave:T[11]||(T[11]=D=>s.value=!1)},[T[20]||(T[20]=d.createElementVNode("button",{class:"menu-btn"},"编辑",-1)),d.withDirectives(d.createElementVNode("div",xs,[d.createElementVNode("div",{class:"menu-item",onClick:_},"撤销"),d.createElementVNode("div",{class:"menu-item",onClick:b},"重做"),d.createElementVNode("div",{class:"menu-item",onClick:M},"复制"),d.createElementVNode("div",{class:"menu-item",onClick:E},"删除")],512),[[d.vShow,s.value]])],32),d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[12]||(T[12]=D=>n.value=!0),onMouseleave:T[13]||(T[13]=D=>n.value=!1)},[T[21]||(T[21]=d.createElementVNode("button",{class:"menu-btn"},"视图",-1)),d.withDirectives(d.createElementVNode("div",Ss,[d.createElementVNode("div",{class:"menu-item",onClick:x},"重置相机"),d.createElementVNode("div",{class:"menu-item",onClick:P},"显示网格")],512),[[d.vShow,n.value]])],32),d.createElementVNode("div",{class:"dropdown-wrapper",onMouseenter:T[14]||(T[14]=D=>o.value=!0),onMouseleave:T[15]||(T[15]=D=>o.value=!1)},[T[22]||(T[22]=d.createElementVNode("button",{class:"menu-btn"},"帮助",-1)),d.withDirectives(d.createElementVNode("div",vs,[d.createElementVNode("div",{class:"menu-item",onClick:S},"使用帮助"),d.createElementVNode("div",{class:"menu-item",onClick:L},"关于")],512),[[d.vShow,o.value]])],32)]),T[23]||(T[23]=d.createElementVNode("div",{class:"right-section"},[d.createElementVNode("span",{class:"app-title"},"3D 模型编辑器")],-1)),d.createElementVNode("input",{type:"file",ref_key:"fileInput",ref:p,accept:".obj,.gltf,.glb",style:{display:"none"},onChange:f},null,544)]))}}),xt=de(Rs,[["__scopeId","data-v-6bb4762f"]]),As={class:"bottom-bar"},Ps=d.defineComponent({__name:"BottomBar",setup(a){return(e,t)=>(d.openBlock(),d.createElementBlock("div",As,[...t[0]||(t[0]=[d.createElementVNode("div",{class:"status-left"},[d.createElementVNode("span",null,"就绪")],-1),d.createElementVNode("div",{class:"status-right"},[d.createElementVNode("span",null,"顶点: 0 | 面: 0")],-1)])]))}}),St=de(Ps,[["__scopeId","data-v-3427bb27"]]),Ls={class:"app-layout"},Cs={class:"editor-container"},Is=d.defineComponent({__name:"DrawingBoard",setup(a){const e=d.ref(null),t=d.reactive({position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}),s=g=>{t.position.x=Number(g.position.x.toFixed(3)),t.position.y=Number(g.position.y.toFixed(3)),t.position.z=Number(g.position.z.toFixed(3)),t.rotation.x=Number(g.rotation.x.toFixed(3)),t.rotation.y=Number(g.rotation.y.toFixed(3)),t.rotation.z=Number(g.rotation.z.toFixed(3)),t.scale.x=Number(g.scale.x.toFixed(3)),t.scale.y=Number(g.scale.y.toFixed(3)),t.scale.z=Number(g.scale.z.toFixed(3))},n=g=>{g.position.set(t.position.x,t.position.y,t.position.z),g.rotation.set(t.rotation.x,t.rotation.y,t.rotation.z),g.scale.set(t.scale.x,t.scale.y,t.scale.z)};ht(g=>{e.value=g,g&&s(g)}),ut(g=>{s(g)});const o=()=>{e.value&&n(e.value)},i=g=>wt(g),l=async g=>{try{await bt(g)}catch(y){console.error("导入失败:",y),alert("导入失败:"+y.message)}},c=d.shallowRef([]);dt(g=>{c.value=g});const u=()=>{const g=pt();g&&(c.value=g)},p=g=>xe(g),h=g=>ct(g.uuid),f=d.ref(null),m=()=>{f.value&&it(f.value),u()};return d.onMounted(m),(g,y)=>(d.openBlock(),d.createElementBlock("div",Ls,[d.createVNode(xt,{onAddModel:i,onImportModel:l}),d.createElementVNode("div",Cs,[d.createElementVNode("div",{class:"canvas",ref_key:"containerRef",ref:f},null,512),d.createVNode(Et,{transform:t,"tree-data":c.value,"selected-object":e.value,onPropertyChange:o,onTreeSelect:p,onTreeDelete:h},null,8,["transform","tree-data","selected-object"])]),d.createVNode(St)]))}}),Ns=de(Is,[["__scopeId","data-v-a7595f5b"]]);exports.BottomBar=St;exports.DrawingBoard=Ns;exports.PropertyPanel=Et;exports.TopBar=xt;exports.TreeItem=Tt;exports.addBox=yt;exports.addModel=ue;exports.addModelByType=wt;exports.addSphere=_t;exports.getCamera=dn;exports.getRenderer=pn;exports.getScene=un;exports.getSceneObjects=pt;exports.importModelFromFile=bt;exports.initEditor=it;exports.onSceneObjectsChangeCallback=dt;exports.removeModel=lt;exports.removeModelById=ct;exports.selectObject=xe;exports.setSelectedObjectCallback=ht;exports.setTransformChangeCallback=ut;exports.useTreeExpand=Mt;
6
6
  //# sourceMappingURL=three-editor.cjs.js.map