@tresjs/cientos 4.1.0 → 4.1.1

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
1
  /**
2
2
  * name: @tresjs/cientos
3
- * version: v4.1.0
3
+ * version: v4.1.1
4
4
  * (c) 2025
5
5
  * description: Collection of useful helpers and fully functional, ready-made abstractions for Tres
6
6
  * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
@@ -489,7 +489,7 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
489
489
  #include <${Xt>=154?"colorspace_fragment":"encodings_fragment"}>
490
490
 
491
491
  }
492
- `},gr=new l.ShaderMaterial({name:"SkyShader",fragmentShader:mn.fragmentShader,vertexShader:mn.vertexShader,uniforms:l.UniformsUtils.clone(mn.uniforms),side:l.BackSide,depthWrite:!1});class Hn extends l.Mesh{constructor(){super(new l.BoxGeometry(1,1,1),gr)}}mr(Hn,"SkyShader",mn),mr(Hn,"material",gr);const Ue=new l.Triangle,gn=new l.Vector3;class Ya{constructor(e){let t=e.geometry;t.index&&(console.warn("THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry."),t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.colorAttribute=this.geometry.getAttribute("color"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){const e=this.positionAttribute,t=this.weightAttribute,n=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;t&&(s=t.getX(r)+t.getX(r+1)+t.getX(r+2)),Ue.a.fromBufferAttribute(e,r),Ue.b.fromBufferAttribute(e,r+1),Ue.c.fromBufferAttribute(e,r+2),s*=Ue.getArea(),n[r/3]=s}this.distribution=new Float32Array(e.count/3);let o=0;for(let r=0;r<n.length;r++)o+=n[r],this.distribution[r]=o;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,n){const o=this.sampleFaceIndex();return this.sampleFace(o,e,t,n)}sampleFaceIndex(){const e=this.distribution[this.distribution.length-1];return this.binarySearch(this.randomFunction()*e)}binarySearch(e){const t=this.distribution;let n=0,o=t.length-1,r=-1;for(;n<=o;){const s=Math.ceil((n+o)/2);if(s===0||t[s-1]<=e&&t[s]>e){r=s;break}else e<t[s]?o=s-1:n=s+1}return r}sampleFace(e,t,n,o){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Ue.a.fromBufferAttribute(this.positionAttribute,e*3),Ue.b.fromBufferAttribute(this.positionAttribute,e*3+1),Ue.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Ue.a,r).addScaledVector(Ue.b,s).addScaledVector(Ue.c,1-(r+s)),n!==void 0&&Ue.getNormal(n),o!==void 0&&this.colorAttribute!==void 0&&(Ue.a.fromBufferAttribute(this.colorAttribute,e*3),Ue.b.fromBufferAttribute(this.colorAttribute,e*3+1),Ue.c.fromBufferAttribute(this.colorAttribute,e*3+2),gn.set(0,0,0).addScaledVector(Ue.a,r).addScaledVector(Ue.b,s).addScaledVector(Ue.c,1-(r+s)),o.r=gn.x,o.g=gn.y,o.b=gn.z),this}}var Xa=Object.defineProperty,Ea=(a,e,t)=>e in a?Xa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,J=(a,e,t)=>(Ea(a,typeof e!="symbol"?e+"":e,t),t);class Za extends l.Object3D{constructor(e,t){super(),J(this,"isTransformControls",!0),J(this,"visible",!1),J(this,"domElement"),J(this,"raycaster",new l.Raycaster),J(this,"gizmo"),J(this,"plane"),J(this,"tempVector",new l.Vector3),J(this,"tempVector2",new l.Vector3),J(this,"tempQuaternion",new l.Quaternion),J(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),J(this,"pointStart",new l.Vector3),J(this,"pointEnd",new l.Vector3),J(this,"offset",new l.Vector3),J(this,"rotationAxis",new l.Vector3),J(this,"startNorm",new l.Vector3),J(this,"endNorm",new l.Vector3),J(this,"rotationAngle",0),J(this,"cameraPosition",new l.Vector3),J(this,"cameraQuaternion",new l.Quaternion),J(this,"cameraScale",new l.Vector3),J(this,"parentPosition",new l.Vector3),J(this,"parentQuaternion",new l.Quaternion),J(this,"parentQuaternionInv",new l.Quaternion),J(this,"parentScale",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldScaleStart",new l.Vector3),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"worldQuaternionInv",new l.Quaternion),J(this,"worldScale",new l.Vector3),J(this,"eye",new l.Vector3),J(this,"positionStart",new l.Vector3),J(this,"quaternionStart",new l.Quaternion),J(this,"scaleStart",new l.Vector3),J(this,"camera"),J(this,"object"),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"translationSnap",null),J(this,"rotationSnap",null),J(this,"scaleSnap",null),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"changeEvent",{type:"change"}),J(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),J(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),J(this,"objectChangeEvent",{type:"objectChange"}),J(this,"intersectObjectWithRay",(o,r,s)=>{const i=r.intersectObject(o,!0);for(let c=0;c<i.length;c++)if(i[c].object.visible||s)return i[c];return!1}),J(this,"attach",o=>(this.object=o,this.visible=!0,this)),J(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),J(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),J(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),J(this,"pointerHover",o=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(o,this.camera);const r=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);r?this.axis=r.object.name:this.axis=null}),J(this,"pointerDown",o=>{if(!(this.object===void 0||this.dragging===!0||o.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(o,this.camera);const r=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(r){let s=this.space;if(this.mode==="scale"?s="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(s="world"),s==="local"&&this.mode==="rotate"){const i=this.rotationSnap;this.axis==="X"&&i&&(this.object.rotation.x=Math.round(this.object.rotation.x/i)*i),this.axis==="Y"&&i&&(this.object.rotation.y=Math.round(this.object.rotation.y/i)*i),this.axis==="Z"&&i&&(this.object.rotation.z=Math.round(this.object.rotation.z/i)*i)}this.object.updateMatrixWorld(),this.object.parent&&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(r.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),J(this,"pointerMove",o=>{const r=this.axis,s=this.mode,i=this.object;let c=this.space;if(s==="scale"?c="local":(r==="E"||r==="XYZE"||r==="XYZ")&&(c="world"),i===void 0||r===null||this.dragging===!1||o.button!==-1)return;this.raycaster.setFromCamera(o,this.camera);const h=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(h){if(this.pointEnd.copy(h.point).sub(this.worldPositionStart),s==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),c==="local"&&r!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),r.indexOf("X")===-1&&(this.offset.x=0),r.indexOf("Y")===-1&&(this.offset.y=0),r.indexOf("Z")===-1&&(this.offset.z=0),c==="local"&&r!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),i.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(c==="local"&&(i.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),r.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this.quaternionStart)),c==="world"&&(i.parent&&i.position.add(this.tempVector.setFromMatrixPosition(i.parent.matrixWorld)),r.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(this.tempVector.setFromMatrixPosition(i.parent.matrixWorld))));else if(s==="scale"){if(r.search("XYZ")!==-1){let p=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(p*=-1),this.tempVector2.set(p,p,p)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),r.search("X")===-1&&(this.tempVector2.x=1),r.search("Y")===-1&&(this.tempVector2.y=1),r.search("Z")===-1&&(this.tempVector2.z=1);i.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(r.search("X")!==-1&&(this.object.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const p=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));r==="E"?(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):r==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*p):(r==="X"||r==="Y"||r==="Z")&&(this.rotationAxis.copy(this.unit[r]),this.tempVector.copy(this.unit[r]),c==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*p),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),c==="local"&&r!=="E"&&r!=="XYZE"?(i.quaternion.copy(this.quaternionStart),i.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),i.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),J(this,"pointerUp",o=>{o.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),J(this,"getPointer",o=>{var r;if(this.domElement&&((r=this.domElement.ownerDocument)!=null&&r.pointerLockElement))return{x:0,y:0,button:o.button};{const s=o.changedTouches?o.changedTouches[0]:o,i=this.domElement.getBoundingClientRect();return{x:(s.clientX-i.left)/i.width*2-1,y:-(s.clientY-i.top)/i.height*2+1,button:o.button}}}),J(this,"onPointerHover",o=>{if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(o));break}}),J(this,"onPointerDown",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(o)),this.pointerDown(this.getPointer(o)))}),J(this,"onPointerMove",o=>{this.enabled&&this.pointerMove(this.getPointer(o))}),J(this,"onPointerUp",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(o)))}),J(this,"getMode",()=>this.mode),J(this,"setMode",o=>{this.mode=o}),J(this,"setTranslationSnap",o=>{this.translationSnap=o}),J(this,"setRotationSnap",o=>{this.rotationSnap=o}),J(this,"setScaleSnap",o=>{this.scaleSnap=o}),J(this,"setSize",o=>{this.size=o}),J(this,"setSpace",o=>{this.space=o}),J(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),J(this,"connect",o=>{o===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=o,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),J(this,"dispose",()=>{var o,r,s,i,c,h;(o=this.domElement)==null||o.removeEventListener("pointerdown",this.onPointerDown),(r=this.domElement)==null||r.removeEventListener("pointermove",this.onPointerHover),(i=(s=this.domElement)==null?void 0:s.ownerDocument)==null||i.removeEventListener("pointermove",this.onPointerMove),(h=(c=this.domElement)==null?void 0:c.ownerDocument)==null||h.removeEventListener("pointerup",this.onPointerUp),this.traverse(p=>{const f=p;f.geometry&&f.geometry.dispose(),f.material&&f.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new Ka,this.add(this.gizmo),this.plane=new qa,this.add(this.plane);const n=(o,r)=>{let s=r;Object.defineProperty(this,o,{get:function(){return s!==void 0?s:r},set:function(i){s!==i&&(s=i,this.plane[o]=i,this.gizmo[o]=i,this.dispatchEvent({type:o+"-changed",value:i}),this.dispatchEvent(this.changeEvent))}}),this[o]=r,this.plane[o]=r,this.gizmo[o]=r};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class Ka extends l.Object3D{constructor(){super(),J(this,"isTransformControlsGizmo",!0),J(this,"type","TransformControlsGizmo"),J(this,"tempVector",new l.Vector3(0,0,0)),J(this,"tempEuler",new l.Euler),J(this,"alignVector",new l.Vector3(0,1,0)),J(this,"zeroVector",new l.Vector3(0,0,0)),J(this,"lookAtMatrix",new l.Matrix4),J(this,"tempQuaternion",new l.Quaternion),J(this,"tempQuaternion2",new l.Quaternion),J(this,"identityQuaternion",new l.Quaternion),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"gizmo"),J(this,"picker"),J(this,"helper"),J(this,"rotationAxis",new l.Vector3),J(this,"cameraPosition",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"camera",null),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"updateMatrixWorld",()=>{let ne=this.space;this.mode==="scale"&&(ne="local");const ce=ne==="local"?this.worldQuaternion:this.identityQuaternion;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 le=[];le=le.concat(this.picker[this.mode].children),le=le.concat(this.gizmo[this.mode].children),le=le.concat(this.helper[this.mode].children);for(let de=0;de<le.length;de++){const k=le[de];k.visible=!0,k.rotation.set(0,0,0),k.position.copy(this.worldPosition);let V;if(this.camera.isOrthographicCamera?V=(this.camera.top-this.camera.bottom)/this.camera.zoom:V=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),k.scale.set(1,1,1).multiplyScalar(V*this.size/7),k.tag==="helper"){k.visible=!1,k.name==="AXIS"?(k.position.copy(this.worldPositionStart),k.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),k.quaternion.multiply(this.tempQuaternion),k.visible=this.dragging),this.axis==="E"&&(k.visible=!1)):k.name==="START"?(k.position.copy(this.worldPositionStart),k.visible=this.dragging):k.name==="END"?(k.position.copy(this.worldPosition),k.visible=this.dragging):k.name==="DELTA"?(k.position.copy(this.worldPositionStart),k.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),k.scale.copy(this.tempVector),k.visible=this.dragging):(k.quaternion.copy(ce),this.dragging?k.position.copy(this.worldPositionStart):k.position.copy(this.worldPosition),this.axis&&(k.visible=this.axis.search(k.name)!==-1));continue}k.quaternion.copy(ce),this.mode==="translate"||this.mode==="scale"?((k.name==="X"||k.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Y"||k.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Z"||k.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.x*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.y*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.z*=-1:k.tag==="bwd"&&(k.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ce),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ce).invert()),k.name.search("E")!==-1&&k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),k.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion))),k.visible=k.visible&&(k.name.indexOf("X")===-1||this.showX),k.visible=k.visible&&(k.name.indexOf("Y")===-1||this.showY),k.visible=k.visible&&(k.name.indexOf("Z")===-1||this.showZ),k.visible=k.visible&&(k.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),k.material.tempOpacity=k.material.tempOpacity||k.material.opacity,k.material.tempColor=k.material.tempColor||k.material.color.clone(),k.material.color.copy(k.material.tempColor),k.material.opacity=k.material.tempOpacity,this.enabled?this.axis&&(k.name===this.axis?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(U){return k.name===U})?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):(k.material.opacity*=.25,k.material.color.lerp(new l.Color(1,1,1),.5))):(k.material.opacity*=.5,k.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const o=e.clone();o.opacity=.33;const r=e.clone();r.color.set(16711680);const s=e.clone();s.color.set(65280);const i=e.clone();i.color.set(255);const c=e.clone();c.opacity=.25;const h=c.clone();h.color.set(16776960);const p=c.clone();p.color.set(65535);const f=c.clone();f.color.set(16711935),e.clone().color.set(16776960);const d=t.clone();d.color.set(16711680);const g=t.clone();g.color.set(65280);const y=t.clone();y.color.set(255);const v=t.clone();v.color.set(65535);const _=t.clone();_.color.set(16711935);const A=t.clone();A.color.set(16776960);const b=t.clone();b.color.set(7895160);const C=A.clone();C.opacity=.25;const L=new l.CylinderGeometry(0,.05,.2,12,1,!1),M=new l.BoxGeometry(.125,.125,.125),P=new l.BufferGeometry;P.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const w=(ne,ce)=>{const le=new l.BufferGeometry,de=[];for(let k=0;k<=64*ce;++k)de.push(0,Math.cos(k/32*Math.PI)*ne,Math.sin(k/32*Math.PI)*ne);return le.setAttribute("position",new l.Float32BufferAttribute(de,3)),le},S=()=>{const ne=new l.BufferGeometry;return ne.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),ne},x={X:[[new l.Mesh(L,r),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(L,r),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(P,d)]],Y:[[new l.Mesh(L,s),[0,1,0],null,null,"fwd"],[new l.Mesh(L,s),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(P,g),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(L,i),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(L,i),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(P,y),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),c.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),h.clone()),[.15,.15,0]],[new l.Line(P,A),[.18,.3,0],null,[.125,1,1]],[new l.Line(P,A),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),p.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(P,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(P,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),f.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(P,_),[.18,0,.3],null,[.125,1,1]],[new l.Line(P,_),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},D={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new l.Line(S(),o),null,null,null,"helper"]],X:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(P,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(P,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={X:[[new l.Line(w(1,.5),d)],[new l.Mesh(new l.OctahedronGeometry(.04,0),r),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(w(1,.5),g),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),s),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(w(1,.5),y),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(w(1.25,1),C),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(w(1,1),b),null,[0,Math.PI/2,0]]]},G={AXIS:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},X={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},E={X:[[new l.Mesh(M,r),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(P,d),null,null,[.8,1,1]]],Y:[[new l.Mesh(M,s),[0,.8,0]],[new l.Line(P,g),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(M,i),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(P,y),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(M,h),[.85,.85,0],null,[2,2,.2]],[new l.Line(P,A),[.855,.98,0],null,[.125,1,1]],[new l.Line(P,A),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(M,p),[0,.85,.85],null,[.2,2,2]],[new l.Line(P,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(P,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(M,f),[.85,0,.85],null,[2,.2,2]],[new l.Line(P,_),[.855,0,.98],null,[.125,1,1]],[new l.Line(P,_),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,0,1.1]]]},te={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(M,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(M,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(M,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},q={X:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(P,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(P,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},oe=ne=>{const ce=new l.Object3D;for(let le in ne)for(let de=ne[le].length;de--;){const k=ne[le][de][0].clone(),V=ne[le][de][1],U=ne[le][de][2],B=ne[le][de][3],R=ne[le][de][4];k.name=le,k.tag=R,V&&k.position.set(V[0],V[1],V[2]),U&&k.rotation.set(U[0],U[1],U[2]),B&&k.scale.set(B[0],B[1],B[2]),k.updateMatrix();const T=k.geometry.clone();T.applyMatrix4(k.matrix),k.geometry=T,k.renderOrder=1/0,k.position.set(0,0,0),k.rotation.set(0,0,0),k.scale.set(1,1,1),ce.add(k)}return ce};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=oe(x)),this.add(this.gizmo.rotate=oe(z)),this.add(this.gizmo.scale=oe(E)),this.add(this.picker.translate=oe(I)),this.add(this.picker.rotate=oe(X)),this.add(this.picker.scale=oe(te)),this.add(this.helper.translate=oe(D)),this.add(this.helper.rotate=oe(G)),this.add(this.helper.scale=oe(q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class qa extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),J(this,"isTransformControlsPlane",!0),J(this,"type","TransformControlsPlane"),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"tempVector",new l.Vector3),J(this,"dirVector",new l.Vector3),J(this,"alignVector",new l.Vector3),J(this,"tempMatrix",new l.Matrix4),J(this,"identityQuaternion",new l.Quaternion),J(this,"cameraQuaternion",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var Qa=Object.defineProperty,Ja=(a,e,t)=>e in a?Qa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ke=(a,e,t)=>(Ja(a,typeof e!="symbol"?e+"":e,t),t);const Dt=new l.Euler(0,0,0,"YXZ"),kt=new l.Vector3,Ha={type:"change"},$a={type:"lock"},el={type:"unlock"},yr=Math.PI/2;class _r extends l.EventDispatcher{constructor(e,t){super(),ke(this,"camera"),ke(this,"domElement"),ke(this,"isLocked"),ke(this,"minPolarAngle"),ke(this,"maxPolarAngle"),ke(this,"pointerSpeed"),ke(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const o=n.movementX||n.mozMovementX||n.webkitMovementX||0,r=n.movementY||n.mozMovementY||n.webkitMovementY||0;Dt.setFromQuaternion(this.camera.quaternion),Dt.y-=o*.002*this.pointerSpeed,Dt.x-=r*.002*this.pointerSpeed,Dt.x=Math.max(yr-this.maxPolarAngle,Math.min(yr-this.minPolarAngle,Dt.x)),this.camera.quaternion.setFromEuler(Dt),this.dispatchEvent(Ha)}),ke(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent($a),this.isLocked=!0):(this.dispatchEvent(el),this.isLocked=!1))}),ke(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),ke(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),ke(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),ke(this,"dispose",()=>{this.disconnect()}),ke(this,"getObject",()=>this.camera),ke(this,"direction",new l.Vector3(0,0,-1)),ke(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),ke(this,"moveForward",n=>{kt.setFromMatrixColumn(this.camera.matrix,0),kt.crossVectors(this.camera.up,kt),this.camera.position.addScaledVector(kt,n)}),ke(this,"moveRight",n=>{kt.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(kt,n)}),ke(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),ke(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var tl=Object.defineProperty,nl=(a,e,t)=>e in a?tl(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,fe=(a,e,t)=>(nl(a,typeof e!="symbol"?e+"":e,t),t);const yn=new l.Ray,vr=new l.Plane,ol=Math.cos(70*(Math.PI/180)),xr=(a,e)=>(a%e+e)%e;class wr extends l.EventDispatcher{constructor(e,t){super(),fe(this,"object"),fe(this,"domElement"),fe(this,"enabled",!0),fe(this,"target",new l.Vector3),fe(this,"minDistance",0),fe(this,"maxDistance",1/0),fe(this,"minZoom",0),fe(this,"maxZoom",1/0),fe(this,"minPolarAngle",0),fe(this,"maxPolarAngle",Math.PI),fe(this,"minAzimuthAngle",-1/0),fe(this,"maxAzimuthAngle",1/0),fe(this,"enableDamping",!1),fe(this,"dampingFactor",.05),fe(this,"enableZoom",!0),fe(this,"zoomSpeed",1),fe(this,"enableRotate",!0),fe(this,"rotateSpeed",1),fe(this,"enablePan",!0),fe(this,"panSpeed",1),fe(this,"screenSpacePanning",!0),fe(this,"keyPanSpeed",7),fe(this,"zoomToCursor",!1),fe(this,"autoRotate",!1),fe(this,"autoRotateSpeed",2),fe(this,"reverseOrbit",!1),fe(this,"reverseHorizontalOrbit",!1),fe(this,"reverseVerticalOrbit",!1),fe(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),fe(this,"mouseButtons",{LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),fe(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN}),fe(this,"target0"),fe(this,"position0"),fe(this,"zoom0"),fe(this,"_domElementKeyEvents",null),fe(this,"getPolarAngle"),fe(this,"getAzimuthalAngle"),fe(this,"setPolarAngle"),fe(this,"setAzimuthalAngle"),fe(this,"getDistance"),fe(this,"getZoomScale"),fe(this,"listenToKeyEvents"),fe(this,"stopListenToKeyEvents"),fe(this,"saveState"),fe(this,"reset"),fe(this,"update"),fe(this,"connect"),fe(this,"dispose"),fe(this,"dollyIn"),fe(this,"dollyOut"),fe(this,"getScale"),fe(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=Z=>{let ae=xr(Z,2*Math.PI),ge=p.phi;ge<0&&(ge+=2*Math.PI),ae<0&&(ae+=2*Math.PI);let Me=Math.abs(ae-ge);2*Math.PI-Me<Me&&(ae<ge?ae+=2*Math.PI:ge+=2*Math.PI),f.phi=ae-ge,n.update()},this.setAzimuthalAngle=Z=>{let ae=xr(Z,2*Math.PI),ge=p.theta;ge<0&&(ge+=2*Math.PI),ae<0&&(ae+=2*Math.PI);let Me=Math.abs(ae-ge);2*Math.PI-Me<Me&&(ae<ge?ae+=2*Math.PI:ge+=2*Math.PI),f.theta=ae-ge,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=Z=>{Z.addEventListener("keydown",it),this._domElementKeyEvents=Z},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",it),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(o),n.update(),c=i.NONE},this.update=(()=>{const Z=new l.Vector3,ae=new l.Vector3(0,1,0),ge=new l.Quaternion().setFromUnitVectors(e.up,ae),Me=ge.clone().invert(),Be=new l.Vector3,ht=new l.Quaternion,bt=2*Math.PI;return function(){const Qs=n.object.position;ge.setFromUnitVectors(e.up,ae),Me.copy(ge).invert(),Z.copy(Qs).sub(n.target),Z.applyQuaternion(ge),p.setFromVector3(Z),n.autoRotate&&c===i.NONE&&G(D()),n.enableDamping?(p.theta+=f.theta*n.dampingFactor,p.phi+=f.phi*n.dampingFactor):(p.theta+=f.theta,p.phi+=f.phi);let ft=n.minAzimuthAngle,dt=n.maxAzimuthAngle;isFinite(ft)&&isFinite(dt)&&(ft<-Math.PI?ft+=bt:ft>Math.PI&&(ft-=bt),dt<-Math.PI?dt+=bt:dt>Math.PI&&(dt-=bt),ft<=dt?p.theta=Math.max(ft,Math.min(dt,p.theta)):p.theta=p.theta>(ft+dt)/2?Math.max(ft,p.theta):Math.min(dt,p.theta)),p.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,p.phi)),p.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(d,n.dampingFactor):n.target.add(d),n.zoomToCursor&&S||n.object.isOrthographicCamera?p.radius=de(p.radius):p.radius=de(p.radius*m),Z.setFromSpherical(p),Z.applyQuaternion(Me),Qs.copy(n.target).add(Z),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,d.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),d.set(0,0,0));let an=!1;if(n.zoomToCursor&&S){let ln=null;if(n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const cn=Z.length();ln=de(cn*m);const Un=cn-ln;n.object.position.addScaledVector(P,Un),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const cn=new l.Vector3(w.x,w.y,0);cn.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix(),an=!0;const Un=new l.Vector3(w.x,w.y,0);Un.unproject(n.object),n.object.position.sub(Un).add(cn),n.object.updateMatrixWorld(),ln=Z.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;ln!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(ln).add(n.object.position):(yn.origin.copy(n.object.position),yn.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(yn.direction))<ol?e.lookAt(n.target):(vr.setFromNormalAndCoplanarPoint(n.object.up,n.target),yn.intersectPlane(vr,n.target))))}else n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera&&(an=m!==1,an&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix()));return m=1,S=!1,an||Be.distanceToSquared(n.object.position)>h||8*(1-ht.dot(n.object.quaternion))>h?(n.dispatchEvent(o),Be.copy(n.object.position),ht.copy(n.object.quaternion),an=!1,!0):!1}})(),this.connect=Z=>{n.domElement=Z,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",sn),n.domElement.addEventListener("pointerdown",_e),n.domElement.addEventListener("pointercancel",Pe),n.domElement.addEventListener("wheel",It)},this.dispose=()=>{var Z,ae,ge,Me,Be,ht;n.domElement&&(n.domElement.style.touchAction="auto"),(Z=n.domElement)==null||Z.removeEventListener("contextmenu",sn),(ae=n.domElement)==null||ae.removeEventListener("pointerdown",_e),(ge=n.domElement)==null||ge.removeEventListener("pointercancel",Pe),(Me=n.domElement)==null||Me.removeEventListener("wheel",It),(Be=n.domElement)==null||Be.ownerDocument.removeEventListener("pointermove",Le),(ht=n.domElement)==null||ht.ownerDocument.removeEventListener("pointerup",Pe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",it)};const n=this,o={type:"change"},r={type:"start"},s={type:"end"},i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let c=i.NONE;const h=1e-6,p=new l.Spherical,f=new l.Spherical;let m=1;const d=new l.Vector3,g=new l.Vector2,y=new l.Vector2,v=new l.Vector2,_=new l.Vector2,A=new l.Vector2,b=new l.Vector2,C=new l.Vector2,L=new l.Vector2,M=new l.Vector2,P=new l.Vector3,w=new l.Vector2;let S=!1;const x=[],I={};function D(){return 2*Math.PI/60/60*n.autoRotateSpeed}function z(){return Math.pow(.95,n.zoomSpeed)}function G(Z){n.reverseOrbit||n.reverseHorizontalOrbit?f.theta+=Z:f.theta-=Z}function X(Z){n.reverseOrbit||n.reverseVerticalOrbit?f.phi+=Z:f.phi-=Z}const E=(()=>{const Z=new l.Vector3;return function(ge,Me){Z.setFromMatrixColumn(Me,0),Z.multiplyScalar(-ge),d.add(Z)}})(),te=(()=>{const Z=new l.Vector3;return function(ge,Me){n.screenSpacePanning===!0?Z.setFromMatrixColumn(Me,1):(Z.setFromMatrixColumn(Me,0),Z.crossVectors(n.object.up,Z)),Z.multiplyScalar(ge),d.add(Z)}})(),q=(()=>{const Z=new l.Vector3;return function(ge,Me){const Be=n.domElement;if(Be&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const ht=n.object.position;Z.copy(ht).sub(n.target);let bt=Z.length();bt*=Math.tan(n.object.fov/2*Math.PI/180),E(2*ge*bt/Be.clientHeight,n.object.matrix),te(2*Me*bt/Be.clientHeight,n.object.matrix)}else Be&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(E(ge*(n.object.right-n.object.left)/n.object.zoom/Be.clientWidth,n.object.matrix),te(Me*(n.object.top-n.object.bottom)/n.object.zoom/Be.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function oe(Z){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?m=Z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ne(Z){oe(m/Z)}function ce(Z){oe(m*Z)}function le(Z){if(!n.zoomToCursor||!n.domElement)return;S=!0;const ae=n.domElement.getBoundingClientRect(),ge=Z.clientX-ae.left,Me=Z.clientY-ae.top,Be=ae.width,ht=ae.height;w.x=ge/Be*2-1,w.y=-(Me/ht)*2+1,P.set(w.x,w.y,1).unproject(n.object).sub(n.object.position).normalize()}function de(Z){return Math.max(n.minDistance,Math.min(n.maxDistance,Z))}function k(Z){g.set(Z.clientX,Z.clientY)}function V(Z){le(Z),C.set(Z.clientX,Z.clientY)}function U(Z){_.set(Z.clientX,Z.clientY)}function B(Z){y.set(Z.clientX,Z.clientY),v.subVectors(y,g).multiplyScalar(n.rotateSpeed);const ae=n.domElement;ae&&(G(2*Math.PI*v.x/ae.clientHeight),X(2*Math.PI*v.y/ae.clientHeight)),g.copy(y),n.update()}function R(Z){L.set(Z.clientX,Z.clientY),M.subVectors(L,C),M.y>0?ne(z()):M.y<0&&ce(z()),C.copy(L),n.update()}function T(Z){A.set(Z.clientX,Z.clientY),b.subVectors(A,_).multiplyScalar(n.panSpeed),q(b.x,b.y),_.copy(A),n.update()}function O(Z){le(Z),Z.deltaY<0?ce(z()):Z.deltaY>0&&ne(z()),n.update()}function N(Z){let ae=!1;switch(Z.code){case n.keys.UP:q(0,n.keyPanSpeed),ae=!0;break;case n.keys.BOTTOM:q(0,-n.keyPanSpeed),ae=!0;break;case n.keys.LEFT:q(n.keyPanSpeed,0),ae=!0;break;case n.keys.RIGHT:q(-n.keyPanSpeed,0),ae=!0;break}ae&&(Z.preventDefault(),n.update())}function K(){if(x.length==1)g.set(x[0].pageX,x[0].pageY);else{const Z=.5*(x[0].pageX+x[1].pageX),ae=.5*(x[0].pageY+x[1].pageY);g.set(Z,ae)}}function W(){if(x.length==1)_.set(x[0].pageX,x[0].pageY);else{const Z=.5*(x[0].pageX+x[1].pageX),ae=.5*(x[0].pageY+x[1].pageY);_.set(Z,ae)}}function Y(){const Z=x[0].pageX-x[1].pageX,ae=x[0].pageY-x[1].pageY,ge=Math.sqrt(Z*Z+ae*ae);C.set(0,ge)}function Q(){n.enableZoom&&Y(),n.enablePan&&W()}function re(){n.enableZoom&&Y(),n.enableRotate&&K()}function se(Z){if(x.length==1)y.set(Z.pageX,Z.pageY);else{const ge=jo(Z),Me=.5*(Z.pageX+ge.x),Be=.5*(Z.pageY+ge.y);y.set(Me,Be)}v.subVectors(y,g).multiplyScalar(n.rotateSpeed);const ae=n.domElement;ae&&(G(2*Math.PI*v.x/ae.clientHeight),X(2*Math.PI*v.y/ae.clientHeight)),g.copy(y)}function j(Z){if(x.length==1)A.set(Z.pageX,Z.pageY);else{const ae=jo(Z),ge=.5*(Z.pageX+ae.x),Me=.5*(Z.pageY+ae.y);A.set(ge,Me)}b.subVectors(A,_).multiplyScalar(n.panSpeed),q(b.x,b.y),_.copy(A)}function F(Z){const ae=jo(Z),ge=Z.pageX-ae.x,Me=Z.pageY-ae.y,Be=Math.sqrt(ge*ge+Me*Me);L.set(0,Be),M.set(0,Math.pow(L.y/C.y,n.zoomSpeed)),ne(M.y),C.copy(L)}function ie(Z){n.enableZoom&&F(Z),n.enablePan&&j(Z)}function he(Z){n.enableZoom&&F(Z),n.enableRotate&&se(Z)}function _e(Z){var ae,ge;n.enabled!==!1&&(x.length===0&&((ae=n.domElement)==null||ae.ownerDocument.addEventListener("pointermove",Le),(ge=n.domElement)==null||ge.ownerDocument.addEventListener("pointerup",Pe)),kn(Z),Z.pointerType==="touch"?Ee(Z):Je(Z))}function Le(Z){n.enabled!==!1&&(Z.pointerType==="touch"?et(Z):wt(Z))}function Pe(Z){var ae,ge,Me;Ro(Z),x.length===0&&((ae=n.domElement)==null||ae.releasePointerCapture(Z.pointerId),(ge=n.domElement)==null||ge.ownerDocument.removeEventListener("pointermove",Le),(Me=n.domElement)==null||Me.ownerDocument.removeEventListener("pointerup",Pe)),n.dispatchEvent(s),c=i.NONE}function Je(Z){let ae;switch(Z.button){case 0:ae=n.mouseButtons.LEFT;break;case 1:ae=n.mouseButtons.MIDDLE;break;case 2:ae=n.mouseButtons.RIGHT;break;default:ae=-1}switch(ae){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;V(Z),c=i.DOLLY;break;case l.MOUSE.ROTATE:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(n.enablePan===!1)return;U(Z),c=i.PAN}else{if(n.enableRotate===!1)return;k(Z),c=i.ROTATE}break;case l.MOUSE.PAN:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(n.enableRotate===!1)return;k(Z),c=i.ROTATE}else{if(n.enablePan===!1)return;U(Z),c=i.PAN}break;default:c=i.NONE}c!==i.NONE&&n.dispatchEvent(r)}function wt(Z){if(n.enabled!==!1)switch(c){case i.ROTATE:if(n.enableRotate===!1)return;B(Z);break;case i.DOLLY:if(n.enableZoom===!1)return;R(Z);break;case i.PAN:if(n.enablePan===!1)return;T(Z);break}}function It(Z){n.enabled===!1||n.enableZoom===!1||c!==i.NONE&&c!==i.ROTATE||(Z.preventDefault(),n.dispatchEvent(r),O(Z),n.dispatchEvent(s))}function it(Z){n.enabled===!1||n.enablePan===!1||N(Z)}function Ee(Z){switch(Bn(Z),x.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;K(),c=i.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;W(),c=i.TOUCH_PAN;break;default:c=i.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Q(),c=i.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;re(),c=i.TOUCH_DOLLY_ROTATE;break;default:c=i.NONE}break;default:c=i.NONE}c!==i.NONE&&n.dispatchEvent(r)}function et(Z){switch(Bn(Z),c){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;se(Z),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;j(Z),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ie(Z),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;he(Z),n.update();break;default:c=i.NONE}}function sn(Z){n.enabled!==!1&&Z.preventDefault()}function kn(Z){x.push(Z)}function Ro(Z){delete I[Z.pointerId];for(let ae=0;ae<x.length;ae++)if(x[ae].pointerId==Z.pointerId){x.splice(ae,1);return}}function Bn(Z){let ae=I[Z.pointerId];ae===void 0&&(ae=new l.Vector2,I[Z.pointerId]=ae),ae.set(Z.pageX,Z.pageY)}function jo(Z){const ae=Z.pointerId===x[0].pointerId?x[1]:x[0];return I[ae.pointerId]}this.dollyIn=(Z=z())=>{ce(Z),n.update()},this.dollyOut=(Z=z())=>{ne(Z),n.update()},this.getScale=()=>m,this.setScale=Z=>{oe(Z),n.update()},this.getZoomScale=()=>z(),t!==void 0&&this.connect(t),this.update()}}class rl extends wr{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}function Bt(a){if(typeof TextDecoder<"u")return new TextDecoder().decode(a);let e="";for(let t=0,n=a.length;t<n;t++)e+=String.fromCharCode(a[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const St="srgb",lt="srgb-linear",br=3001,sl=3e3;class il extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new hl(t)}),this.register(function(t){return new fl(t)}),this.register(function(t){return new wl(t)}),this.register(function(t){return new bl(t)}),this.register(function(t){return new Ml(t)}),this.register(function(t){return new pl(t)}),this.register(function(t){return new ml(t)}),this.register(function(t){return new gl(t)}),this.register(function(t){return new yl(t)}),this.register(function(t){return new ul(t)}),this.register(function(t){return new _l(t)}),this.register(function(t){return new dl(t)}),this.register(function(t){return new xl(t)}),this.register(function(t){return new vl(t)}),this.register(function(t){return new ll(t)}),this.register(function(t){return new Sl(t)}),this.register(function(t){return new Al(t)})}load(e,t,n,o){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const h=l.LoaderUtils.extractUrlBase(e);s=l.LoaderUtils.resolveURL(h,this.path)}else s=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const i=function(h){o?o(h):console.error(h),r.manager.itemError(e),r.manager.itemEnd(e)},c=new l.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{r.parse(h,s,function(p){t(p),r.manager.itemEnd(e)},i)}catch(p){i(p)}},n,i)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,o){let r;const s={},i={};if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(Bt(new Uint8Array(e.slice(0,4)))===Mr){try{s[ve.KHR_BINARY_GLTF]=new Pl(e)}catch(p){o&&o(p);return}r=JSON.parse(s[ve.KHR_BINARY_GLTF].content)}else r=JSON.parse(Bt(new Uint8Array(e)));else r=e;if(r.asset===void 0||r.asset.version[0]<2){o&&o(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Vl(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const p=this.pluginCallbacks[h](c);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),i[p.name]=p,s[p.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const p=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(p){case ve.KHR_MATERIALS_UNLIT:s[p]=new cl;break;case ve.KHR_DRACO_MESH_COMPRESSION:s[p]=new Cl(r,this.dracoLoader);break;case ve.KHR_TEXTURE_TRANSFORM:s[p]=new Tl;break;case ve.KHR_MESH_QUANTIZATION:s[p]=new Il;break;default:f.indexOf(p)>=0&&i[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}c.setExtensions(s),c.setPlugins(i),c.parse(n,o)}parseAsync(e,t){const n=this;return new Promise(function(o,r){n.parse(e,t,o,r)})}}function al(){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={}}}}const ve={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ll{constructor(e){this.parser=e,this.name=ve.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,o=t.length;n<o;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let o=t.cache.get(n);if(o)return o;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const p=new l.Color(16777215);c.color!==void 0&&p.setRGB(c.color[0],c.color[1],c.color[2],lt);const f=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new l.DirectionalLight(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new l.PointLight(p),h.distance=f;break;case"spot":h=new l.SpotLight(p),h.distance=f,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,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),h.decay=2,ct(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),o=Promise.resolve(h),t.cache.add(n,o),o}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(c){return n._getNodeRef(t.cache,i,c)})}}class cl{constructor(){this.name=ve.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const o=[];e.color=new l.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],lt),e.opacity=s[3]}r.baseColorTexture!==void 0&&o.push(n.assignTexture(e,"map",r.baseColorTexture,St))}return Promise.all(o)}}class ul{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class hl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(i,i)}return Promise.all(r)}}class fl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class dl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.push(n.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&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class pl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=o.extensions[this.name];if(s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],lt)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,St)),s.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class ml{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class gl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color().setRGB(i[0],i[1],i[2],lt),Promise.all(r)}}class yl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class _l{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return t.specularColor=new l.Color().setRGB(i[0],i[1],i[2],lt),s.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,St)),Promise.all(r)}}class vl{constructor(e){this.parser=e,this.name=ve.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class xl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class wl{constructor(e){this.parser=e,this.name=ve.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,o=n.textures[e];if(!o.extensions||!o.extensions[this.name])return null;const r=o.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class bl{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],i=o.images[s.source];let c=n.textureLoader;if(i.uri){const h=n.options.manager.getHandler(i.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,s.source,c);if(o.extensionsRequired&&o.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ml{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],i=o.images[s.source];let c=n.textureLoader;if(i.uri){const h=n.options.manager.getHandler(i.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,s.source,c);if(o.extensionsRequired&&o.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Sl{constructor(e){this.name=ve.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const o=n.extensions[this.name],r=this.parser.getDependency("buffer",o.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 r.then(function(i){const c=o.byteOffset||0,h=o.byteLength||0,p=o.count,f=o.byteStride,m=new Uint8Array(i,c,h);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(p,f,m,o.mode,o.filter).then(function(d){return d.buffer}):s.ready.then(function(){const d=new ArrayBuffer(p*f);return s.decodeGltfBuffer(new Uint8Array(d),p,f,m,o.mode,o.filter),d})})}else return null}}class Al{constructor(e){this.name=ve.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const o=t.meshes[n.mesh];for(const h of o.primitives)if(h.mode!==Ke.TRIANGLES&&h.mode!==Ke.TRIANGLE_STRIP&&h.mode!==Ke.TRIANGLE_FAN&&h.mode!==void 0)return null;const s=n.extensions[this.name].attributes,i=[],c={};for(const h in s)i.push(this.parser.getDependency("accessor",s[h]).then(p=>(c[h]=p,c[h])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(h=>{const p=h.pop(),f=p.isGroup?p.children:[p],m=h[0].count,d=[];for(const g of f){const y=new l.Matrix4,v=new l.Vector3,_=new l.Quaternion,A=new l.Vector3(1,1,1),b=new l.InstancedMesh(g.geometry,g.material,m);for(let C=0;C<m;C++)c.TRANSLATION&&v.fromBufferAttribute(c.TRANSLATION,C),c.ROTATION&&_.fromBufferAttribute(c.ROTATION,C),c.SCALE&&A.fromBufferAttribute(c.SCALE,C),b.setMatrixAt(C,y.compose(v,_,A));for(const C in c)if(C==="_COLOR_0"){const L=c[C];b.instanceColor=new l.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else C!=="TRANSLATION"&&C!=="ROTATION"&&C!=="SCALE"&&g.geometry.setAttribute(C,c[C]);l.Object3D.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),d.push(b)}return p.isGroup?(p.clear(),p.add(...d),p):d[0]}))}}const Mr="glTF",qt=12,Sr={JSON:1313821514,BIN:5130562};class Pl{constructor(e){this.name=ve.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,qt);if(this.header={magic:Bt(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Mr)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-qt,o=new DataView(e,qt);let r=0;for(;r<n;){const s=o.getUint32(r,!0);r+=4;const i=o.getUint32(r,!0);if(r+=4,i===Sr.JSON){const c=new Uint8Array(e,qt+r,s);this.content=Bt(c)}else if(i===Sr.BIN){const c=qt+r;this.body=e.slice(c,c+s)}r+=s}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Cl{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ve.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,o=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,i={},c={},h={};for(const p in s){const f=eo[p]||p.toLowerCase();i[f]=s[p]}for(const p in e.attributes){const f=eo[p]||p.toLowerCase();if(s[p]!==void 0){const m=n.accessors[e.attributes[p]],d=Ut[m.componentType];h[f]=d.name,c[f]=m.normalized===!0}}return t.getDependency("bufferView",r).then(function(p){return new Promise(function(f,m){o.decodeDracoFile(p,function(d){for(const g in d.attributes){const y=d.attributes[g],v=c[g];v!==void 0&&(y.normalized=v)}f(d)},i,h,lt,m)})})}}class Tl{constructor(){this.name=ve.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 Il{constructor(){this.name=ve.KHR_MESH_QUANTIZATION}}class Ar extends l.Interpolant{constructor(e,t,n,o){super(e,t,n,o)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,o=this.valueSize,r=e*o*3+o;for(let s=0;s!==o;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,o){const r=this.resultBuffer,s=this.sampleValues,i=this.valueSize,c=i*2,h=i*3,p=o-t,f=(n-t)/p,m=f*f,d=m*f,g=e*h,y=g-h,v=-2*d+3*m,_=d-m,A=1-v,b=_-m+f;for(let C=0;C!==i;C++){const L=s[y+C+i],M=s[y+C+c]*p,P=s[g+C+i],w=s[g+C]*p;r[C]=A*L+b*M+v*P+_*w}return r}}const Ol=new l.Quaternion;class Ll extends Ar{interpolate_(e,t,n,o){const r=super.interpolate_(e,t,n,o);return Ol.fromArray(r).normalize().toArray(r),r}}const Ke={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ut={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Pr={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},Cr={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},$n={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eo={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Xt>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},_t={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Dl={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},to={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kl(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),a.DefaultMaterial}function At(a,e,t){for(const n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ct(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 Bl(a,e,t){let n=!1,o=!1,r=!1;for(let h=0,p=e.length;h<p;h++){const f=e[h];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(o=!0),f.COLOR_0!==void 0&&(r=!0),n&&o&&r)break}if(!n&&!o&&!r)return Promise.resolve(a);const s=[],i=[],c=[];for(let h=0,p=e.length;h<p;h++){const f=e[h];if(n){const m=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):a.attributes.position;s.push(m)}if(o){const m=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):a.attributes.normal;i.push(m)}if(r){const m=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):a.attributes.color;c.push(m)}}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(c)]).then(function(h){const p=h[0],f=h[1],m=h[2];return n&&(a.morphAttributes.position=p),o&&(a.morphAttributes.normal=f),r&&(a.morphAttributes.color=m),a.morphTargetsRelative=!0,a})}function Ul(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;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 n=0,o=t.length;n<o;n++)a.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Nl(a){let e;const t=a.extensions&&a.extensions[ve.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+no(t.attributes):e=a.indices+":"+no(a.attributes)+":"+a.mode,a.targets!==void 0)for(let n=0,o=a.targets.length;n<o;n++)e+=":"+no(a.targets[n]);return e}function no(a){let e="";const t=Object.keys(a).sort();for(let n=0,o=t.length;n<o;n++)e+=t[n]+":"+a[t[n]]+";";return e}function oo(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 Fl(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":"image/png"}const zl=new l.Matrix4;class Vl{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new al,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,o=!1,r=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,o=navigator.userAgent.indexOf("Firefox")>-1,r=o?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||o&&r<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.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 n=this,o=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){const i={scene:s[0][o.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:o.asset,parser:n,userData:{}};return At(r,i,o),ct(i,o),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(i)})).then(function(){for(const c of i.scenes)c.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let o=0,r=t.length;o<r;o++){const s=t[o].joints;for(let i=0,c=s.length;i<c;i++)e[s[i]].isBone=!0}for(let o=0,r=e.length;o<r;o++){const s=e[o];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(n[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const o=n.clone(),r=(s,i)=>{const c=this.associations.get(s);c!=null&&this.associations.set(i,c);for(const[h,p]of s.children.entries())r(p,i.children[h])};return r(n,o),o.name+="_instance_"+e.uses[t]++,o}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const o=e(t[n]);if(o)return o}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let o=this.cache.get(n);if(!o){switch(e){case"scene":o=this.loadScene(t);break;case"node":o=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":o=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":o=this.loadAccessor(t);break;case"bufferView":o=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":o=this.loadBuffer(t);break;case"material":o=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":o=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":o=this.loadSkin(t);break;case"animation":o=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":o=this.loadCamera(t);break;default:if(o=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!o)throw new Error("Unknown type: "+e);break}this.cache.add(n,o)}return o}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,o=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(o.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ve.KHR_BINARY_GLTF].body);const o=this.options;return new Promise(function(r,s){n.load(l.LoaderUtils.resolveURL(t.uri,o.path),r,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const o=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+o)})}loadAccessor(e){const t=this,n=this.json,o=this.json.accessors[e];if(o.bufferView===void 0&&o.sparse===void 0){const s=$n[o.type],i=Ut[o.componentType],c=o.normalized===!0,h=new i(o.count*s);return Promise.resolve(new l.BufferAttribute(h,s,c))}const r=[];return o.bufferView!==void 0?r.push(this.getDependency("bufferView",o.bufferView)):r.push(null),o.sparse!==void 0&&(r.push(this.getDependency("bufferView",o.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",o.sparse.values.bufferView))),Promise.all(r).then(function(s){const i=s[0],c=$n[o.type],h=Ut[o.componentType],p=h.BYTES_PER_ELEMENT,f=p*c,m=o.byteOffset||0,d=o.bufferView!==void 0?n.bufferViews[o.bufferView].byteStride:void 0,g=o.normalized===!0;let y,v;if(d&&d!==f){const _=Math.floor(m/d),A="InterleavedBuffer:"+o.bufferView+":"+o.componentType+":"+_+":"+o.count;let b=t.cache.get(A);b||(y=new h(i,_*d,o.count*d/p),b=new l.InterleavedBuffer(y,d/p),t.cache.add(A,b)),v=new l.InterleavedBufferAttribute(b,c,m%d/p,g)}else i===null?y=new h(o.count*c):y=new h(i,m,o.count*c),v=new l.BufferAttribute(y,c,g);if(o.sparse!==void 0){const _=$n.SCALAR,A=Ut[o.sparse.indices.componentType],b=o.sparse.indices.byteOffset||0,C=o.sparse.values.byteOffset||0,L=new A(s[1],b,o.sparse.count*_),M=new h(s[2],C,o.sparse.count*c);i!==null&&(v=new l.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let P=0,w=L.length;P<w;P++){const S=L[P];if(v.setX(S,M[P*c]),c>=2&&v.setY(S,M[P*c+1]),c>=3&&v.setZ(S,M[P*c+2]),c>=4&&v.setW(S,M[P*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r];let i=this.textureLoader;if(s.uri){const c=n.manager.getHandler(s.uri);c!==null&&(i=c)}return this.loadTextureImage(e,r,i)}loadTextureImage(e,t,n){const o=this,r=this.json,s=r.textures[e],i=r.images[t],c=(i.uri||i.bufferView)+":"+s.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(t,n).then(function(p){p.flipY=!1,p.name=s.name||i.name||"",p.name===""&&typeof i.uri=="string"&&i.uri.startsWith("data:image/")===!1&&(p.name=i.uri);const m=(r.samplers||{})[s.sampler]||{};return p.magFilter=Pr[m.magFilter]||l.LinearFilter,p.minFilter=Pr[m.minFilter]||l.LinearMipmapLinearFilter,p.wrapS=Cr[m.wrapS]||l.RepeatWrapping,p.wrapT=Cr[m.wrapT]||l.RepeatWrapping,o.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,t){const n=this,o=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const s=o.images[e],i=self.URL||self.webkitURL;let c=s.uri||"",h=!1;if(s.bufferView!==void 0)c=n.getDependency("bufferView",s.bufferView).then(function(f){h=!0;const m=new Blob([f],{type:s.mimeType});return c=i.createObjectURL(m),c});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(c).then(function(f){return new Promise(function(m,d){let g=m;t.isImageBitmapLoader===!0&&(g=function(y){const v=new l.Texture(y);v.needsUpdate=!0,m(v)}),t.load(l.LoaderUtils.resolveURL(f,r.path),g,void 0,d)})}).then(function(f){return h===!0&&i.revokeObjectURL(c),ct(f,s),f.userData.mimeType=s.mimeType||Fl(s.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),f});return this.sourceCache[e]=p,p}assignTexture(e,t,n,o){const r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(s=s.clone(),s.channel=n.texCoord),r.extensions[ve.KHR_TEXTURE_TRANSFORM]){const i=n.extensions!==void 0?n.extensions[ve.KHR_TEXTURE_TRANSFORM]:void 0;if(i){const c=r.associations.get(s);s=r.extensions[ve.KHR_TEXTURE_TRANSFORM].extendTexture(s,i),r.associations.set(s,c)}}return o!==void 0&&(typeof o=="number"&&(o=o===br?St:lt),"colorSpace"in s?s.colorSpace=o:s.encoding=o===St?br:sl),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const o=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const i="PointsMaterial:"+n.uuid;let c=this.cache.get(i);c||(c=new l.PointsMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(i,c)),n=c}else if(e.isLine){const i="LineBasicMaterial:"+n.uuid;let c=this.cache.get(i);c||(c=new l.LineBasicMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(i,c)),n=c}if(o||r||s){let i="ClonedMaterial:"+n.uuid+":";o&&(i+="derivative-tangents:"),r&&(i+="vertex-colors:"),s&&(i+="flat-shading:");let c=this.cache.get(i);c||(c=n.clone(),r&&(c.vertexColors=!0),s&&(c.flatShading=!0),o&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(i,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,o=this.extensions,r=n.materials[e];let s;const i={},c=r.extensions||{},h=[];if(c[ve.KHR_MATERIALS_UNLIT]){const f=o[ve.KHR_MATERIALS_UNLIT];s=f.getMaterialType(),h.push(f.extendParams(i,r,t))}else{const f=r.pbrMetallicRoughness||{};if(i.color=new l.Color(1,1,1),i.opacity=1,Array.isArray(f.baseColorFactor)){const m=f.baseColorFactor;i.color.setRGB(m[0],m[1],m[2],lt),i.opacity=m[3]}f.baseColorTexture!==void 0&&h.push(t.assignTexture(i,"map",f.baseColorTexture,St)),i.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,i.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(i,"metalnessMap",f.metallicRoughnessTexture)),h.push(t.assignTexture(i,"roughnessMap",f.metallicRoughnessTexture))),s=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,i)})))}r.doubleSided===!0&&(i.side=l.DoubleSide);const p=r.alphaMode||to.OPAQUE;if(p===to.BLEND?(i.transparent=!0,i.depthWrite=!1):(i.transparent=!1,p===to.MASK&&(i.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==l.MeshBasicMaterial&&(h.push(t.assignTexture(i,"normalMap",r.normalTexture)),i.normalScale=new l.Vector2(1,1),r.normalTexture.scale!==void 0)){const f=r.normalTexture.scale;i.normalScale.set(f,f)}if(r.occlusionTexture!==void 0&&s!==l.MeshBasicMaterial&&(h.push(t.assignTexture(i,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(i.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==l.MeshBasicMaterial){const f=r.emissiveFactor;i.emissive=new l.Color().setRGB(f[0],f[1],f[2],lt)}return r.emissiveTexture!==void 0&&s!==l.MeshBasicMaterial&&h.push(t.assignTexture(i,"emissiveMap",r.emissiveTexture,St)),Promise.all(h).then(function(){const f=new s(i);return r.name&&(f.name=r.name),ct(f,r),t.associations.set(f,{materials:e}),r.extensions&&At(o,f,r),f})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,o=this.primitiveCache;function r(i){return n[ve.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(i,t).then(function(c){return Tr(c,i,t)})}const s=[];for(let i=0,c=e.length;i<c;i++){const h=e[i],p=Nl(h),f=o[p];if(f)s.push(f.promise);else{let m;h.extensions&&h.extensions[ve.KHR_DRACO_MESH_COMPRESSION]?m=r(h):m=Tr(new l.BufferGeometry,h,t),o[p]={primitive:h,promise:m},s.push(m)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,o=this.extensions,r=n.meshes[e],s=r.primitives,i=[];for(let c=0,h=s.length;c<h;c++){const p=s[c].material===void 0?kl(this.cache):this.getDependency("material",s[c].material);i.push(p)}return i.push(t.loadGeometries(s)),Promise.all(i).then(function(c){const h=c.slice(0,c.length-1),p=c[c.length-1],f=[];for(let d=0,g=p.length;d<g;d++){const y=p[d],v=s[d];let _;const A=h[d];if(v.mode===Ke.TRIANGLES||v.mode===Ke.TRIANGLE_STRIP||v.mode===Ke.TRIANGLE_FAN||v.mode===void 0)_=r.isSkinnedMesh===!0?new l.SkinnedMesh(y,A):new l.Mesh(y,A),_.isSkinnedMesh===!0&&_.normalizeSkinWeights(),v.mode===Ke.TRIANGLE_STRIP?_.geometry=qo(_.geometry,l.TriangleStripDrawMode):v.mode===Ke.TRIANGLE_FAN&&(_.geometry=qo(_.geometry,l.TriangleFanDrawMode));else if(v.mode===Ke.LINES)_=new l.LineSegments(y,A);else if(v.mode===Ke.LINE_STRIP)_=new l.Line(y,A);else if(v.mode===Ke.LINE_LOOP)_=new l.LineLoop(y,A);else if(v.mode===Ke.POINTS)_=new l.Points(y,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(_.geometry.morphAttributes).length>0&&Ul(_,r),_.name=t.createUniqueName(r.name||"mesh_"+e),ct(_,r),v.extensions&&At(o,_,v),t.assignFinalMaterial(_),f.push(_)}for(let d=0,g=f.length;d<g;d++)t.associations.set(f[d],{meshes:e,primitives:d});if(f.length===1)return r.extensions&&At(o,f[0],r),f[0];const m=new l.Group;r.extensions&&At(o,m,r),t.associations.set(m,{meshes:e});for(let d=0,g=f.length;d<g;d++)m.add(f[d]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],o=n[n.type];if(!o){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(o.yfov),o.aspectRatio||1,o.znear||1,o.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-o.xmag,o.xmag,o.ymag,-o.ymag,o.znear,o.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ct(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let o=0,r=t.joints.length;o<r;o++)n.push(this._loadNodeShallow(t.joints[o]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(o){const r=o.pop(),s=o,i=[],c=[];for(let h=0,p=s.length;h<p;h++){const f=s[h];if(f){i.push(f);const m=new l.Matrix4;r!==null&&m.fromArray(r.array,h*16),c.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new l.Skeleton(i,c)})}loadAnimation(e){const t=this.json,n=this,o=t.animations[e],r=o.name?o.name:"animation_"+e,s=[],i=[],c=[],h=[],p=[];for(let f=0,m=o.channels.length;f<m;f++){const d=o.channels[f],g=o.samplers[d.sampler],y=d.target,v=y.node,_=o.parameters!==void 0?o.parameters[g.input]:g.input,A=o.parameters!==void 0?o.parameters[g.output]:g.output;y.node!==void 0&&(s.push(this.getDependency("node",v)),i.push(this.getDependency("accessor",_)),c.push(this.getDependency("accessor",A)),h.push(g),p.push(y))}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(c),Promise.all(h),Promise.all(p)]).then(function(f){const m=f[0],d=f[1],g=f[2],y=f[3],v=f[4],_=[];for(let A=0,b=m.length;A<b;A++){const C=m[A],L=d[A],M=g[A],P=y[A],w=v[A];if(C===void 0)continue;C.updateMatrix&&C.updateMatrix();const S=n._createAnimationTracks(C,L,M,P,w);if(S)for(let x=0;x<S.length;x++)_.push(S[x])}return new l.AnimationClip(r,void 0,_)})}createNodeMesh(e){const t=this.json,n=this,o=t.nodes[e];return o.mesh===void 0?null:n.getDependency("mesh",o.mesh).then(function(r){const s=n._getNodeRef(n.meshCache,o.mesh,r);return o.weights!==void 0&&s.traverse(function(i){if(i.isMesh)for(let c=0,h=o.weights.length;c<h;c++)i.morphTargetInfluences[c]=o.weights[c]}),s})}loadNode(e){const t=this.json,n=this,o=t.nodes[e],r=n._loadNodeShallow(e),s=[],i=o.children||[];for(let h=0,p=i.length;h<p;h++)s.push(n.getDependency("node",i[h]));const c=o.skin===void 0?Promise.resolve(null):n.getDependency("skin",o.skin);return Promise.all([r,Promise.all(s),c]).then(function(h){const p=h[0],f=h[1],m=h[2];m!==null&&p.traverse(function(d){d.isSkinnedMesh&&d.bind(m,zl)});for(let d=0,g=f.length;d<g;d++)p.add(f[d]);return p})}_loadNodeShallow(e){const t=this.json,n=this.extensions,o=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],s=r.name?o.createUniqueName(r.name):"",i=[],c=o._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&i.push(c),r.camera!==void 0&&i.push(o.getDependency("camera",r.camera).then(function(h){return o._getNodeRef(o.cameraCache,r.camera,h)})),o._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){i.push(h)}),this.nodeCache[e]=Promise.all(i).then(function(h){let p;if(r.isBone===!0?p=new l.Bone:h.length>1?p=new l.Group:h.length===1?p=h[0]:p=new l.Object3D,p!==h[0])for(let f=0,m=h.length;f<m;f++)p.add(h[f]);if(r.name&&(p.userData.name=r.name,p.name=s),ct(p,r),r.extensions&&At(n,p,r),r.matrix!==void 0){const f=new l.Matrix4;f.fromArray(r.matrix),p.applyMatrix4(f)}else r.translation!==void 0&&p.position.fromArray(r.translation),r.rotation!==void 0&&p.quaternion.fromArray(r.rotation),r.scale!==void 0&&p.scale.fromArray(r.scale);return o.associations.has(p)||o.associations.set(p,{}),o.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],o=this,r=new l.Group;n.name&&(r.name=o.createUniqueName(n.name)),ct(r,n),n.extensions&&At(t,r,n);const s=n.nodes||[],i=[];for(let c=0,h=s.length;c<h;c++)i.push(o.getDependency("node",s[c]));return Promise.all(i).then(function(c){for(let p=0,f=c.length;p<f;p++)r.add(c[p]);const h=p=>{const f=new Map;for(const[m,d]of o.associations)(m instanceof l.Material||m instanceof l.Texture)&&f.set(m,d);return p.traverse(m=>{const d=o.associations.get(m);d!=null&&f.set(m,d)}),f};return o.associations=h(r),r})}_createAnimationTracks(e,t,n,o,r){const s=[],i=e.name?e.name:e.uuid,c=[];_t[r.path]===_t.weights?e.traverse(function(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}):c.push(i);let h;switch(_t[r.path]){case _t.weights:h=l.NumberKeyframeTrack;break;case _t.rotation:h=l.QuaternionKeyframeTrack;break;case _t.position:case _t.scale:h=l.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=l.NumberKeyframeTrack;break;case 2:case 3:default:h=l.VectorKeyframeTrack;break}break}const p=o.interpolation!==void 0?Dl[o.interpolation]:l.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let m=0,d=c.length;m<d;m++){const g=new h(c[m]+"."+_t[r.path],t.array,f,p);o.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=oo(t.constructor),o=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)o[r]=t[r]*n;t=o}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const o=this instanceof l.QuaternionKeyframeTrack?Ll:Ar;return new o(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Gl(a,e,t){const n=e.attributes,o=new l.Box3;if(n.POSITION!==void 0){const i=t.json.accessors[n.POSITION],c=i.min,h=i.max;if(c!==void 0&&h!==void 0){if(o.set(new l.Vector3(c[0],c[1],c[2]),new l.Vector3(h[0],h[1],h[2])),i.normalized){const p=oo(Ut[i.componentType]);o.min.multiplyScalar(p),o.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const i=new l.Vector3,c=new l.Vector3;for(let h=0,p=r.length;h<p;h++){const f=r[h];if(f.POSITION!==void 0){const m=t.json.accessors[f.POSITION],d=m.min,g=m.max;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),m.normalized){const y=oo(Ut[m.componentType]);c.multiplyScalar(y)}i.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(i)}a.boundingBox=o;const s=new l.Sphere;o.getCenter(s.center),s.radius=o.min.distanceTo(o.max)/2,a.boundingSphere=s}function Tr(a,e,t){const n=e.attributes,o=[];function r(s,i){return t.getDependency("accessor",s).then(function(c){a.setAttribute(i,c)})}for(const s in n){const i=eo[s]||s.toLowerCase();i in a.attributes||o.push(r(n[s],i))}if(e.indices!==void 0&&!a.index){const s=t.getDependency("accessor",e.indices).then(function(i){a.setIndex(i)});o.push(s)}return ct(a,e),Gl(a,e,t),Promise.all(o).then(function(){return e.targets!==void 0?Bl(a,e.targets,t):a})}const Qt=new l.Vector3;function qe(a,e,t,n,o,r){const s=2*Math.PI*o/4,i=Math.max(r-2*o,0),c=Math.PI/4;Qt.copy(e),Qt[n]=0,Qt.normalize();const h=.5*s/(s+i),p=1-Qt.angleTo(a)/c;return Math.sign(Qt[t])===1?p*h:i/(s+i)+h+h*(1-p)}class Rl extends l.BoxGeometry{constructor(e=1,t=1,n=1,o=2,r=.1){if(o=o*2+1,r=Math.min(e/2,t/2,n/2,r),super(1,1,1,o,o,o),o===1)return;const s=this.toNonIndexed();this.index=null,this.attributes.position=s.attributes.position,this.attributes.normal=s.attributes.normal,this.attributes.uv=s.attributes.uv;const i=new l.Vector3,c=new l.Vector3,h=new l.Vector3(e,t,n).divideScalar(2).subScalar(r),p=this.attributes.position.array,f=this.attributes.normal.array,m=this.attributes.uv.array,d=p.length/6,g=new l.Vector3,y=.5/o;for(let v=0,_=0;v<p.length;v+=3,_+=2)switch(i.fromArray(p,v),c.copy(i),c.x-=Math.sign(c.x)*y,c.y-=Math.sign(c.y)*y,c.z-=Math.sign(c.z)*y,c.normalize(),p[v+0]=h.x*Math.sign(i.x)+c.x*r,p[v+1]=h.y*Math.sign(i.y)+c.y*r,p[v+2]=h.z*Math.sign(i.z)+c.z*r,f[v+0]=c.x,f[v+1]=c.y,f[v+2]=c.z,Math.floor(v/d)){case 0:g.set(1,0,0),m[_+0]=qe(g,c,"z","y",r,n),m[_+1]=1-qe(g,c,"y","z",r,t);break;case 1:g.set(-1,0,0),m[_+0]=1-qe(g,c,"z","y",r,n),m[_+1]=1-qe(g,c,"y","z",r,t);break;case 2:g.set(0,1,0),m[_+0]=1-qe(g,c,"x","z",r,e),m[_+1]=qe(g,c,"z","x",r,n);break;case 3:g.set(0,-1,0),m[_+0]=1-qe(g,c,"x","z",r,e),m[_+1]=1-qe(g,c,"z","x",r,n);break;case 4:g.set(0,0,1),m[_+0]=1-qe(g,c,"x","y",r,e),m[_+1]=1-qe(g,c,"y","x",r,t);break;case 5:g.set(0,0,-1),m[_+0]=qe(g,c,"x","y",r,e),m[_+1]=1-qe(g,c,"y","x",r,t);break}}}class Ir extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:o=8,bevelThickness:r=10,font:s,height:i=50,size:c=100,lineHeight:h=1,letterSpacing:p=0,...f}=t;if(s===void 0)super();else{const m=s.generateShapes(e,c,{lineHeight:h,letterSpacing:p});super(m,{...f,bevelEnabled:n,bevelSize:o,bevelThickness:r,depth:i})}this.type="TextGeometry"}}const jl={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
492
+ `},gr=new l.ShaderMaterial({name:"SkyShader",fragmentShader:mn.fragmentShader,vertexShader:mn.vertexShader,uniforms:l.UniformsUtils.clone(mn.uniforms),side:l.BackSide,depthWrite:!1});class Hn extends l.Mesh{constructor(){super(new l.BoxGeometry(1,1,1),gr)}}mr(Hn,"SkyShader",mn),mr(Hn,"material",gr);const Ue=new l.Triangle,gn=new l.Vector3;class Ya{constructor(e){let t=e.geometry;t.index&&(console.warn("THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry."),t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.colorAttribute=this.geometry.getAttribute("color"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){const e=this.positionAttribute,t=this.weightAttribute,n=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;t&&(s=t.getX(r)+t.getX(r+1)+t.getX(r+2)),Ue.a.fromBufferAttribute(e,r),Ue.b.fromBufferAttribute(e,r+1),Ue.c.fromBufferAttribute(e,r+2),s*=Ue.getArea(),n[r/3]=s}this.distribution=new Float32Array(e.count/3);let o=0;for(let r=0;r<n.length;r++)o+=n[r],this.distribution[r]=o;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,n){const o=this.sampleFaceIndex();return this.sampleFace(o,e,t,n)}sampleFaceIndex(){const e=this.distribution[this.distribution.length-1];return this.binarySearch(this.randomFunction()*e)}binarySearch(e){const t=this.distribution;let n=0,o=t.length-1,r=-1;for(;n<=o;){const s=Math.ceil((n+o)/2);if(s===0||t[s-1]<=e&&t[s]>e){r=s;break}else e<t[s]?o=s-1:n=s+1}return r}sampleFace(e,t,n,o){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Ue.a.fromBufferAttribute(this.positionAttribute,e*3),Ue.b.fromBufferAttribute(this.positionAttribute,e*3+1),Ue.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Ue.a,r).addScaledVector(Ue.b,s).addScaledVector(Ue.c,1-(r+s)),n!==void 0&&Ue.getNormal(n),o!==void 0&&this.colorAttribute!==void 0&&(Ue.a.fromBufferAttribute(this.colorAttribute,e*3),Ue.b.fromBufferAttribute(this.colorAttribute,e*3+1),Ue.c.fromBufferAttribute(this.colorAttribute,e*3+2),gn.set(0,0,0).addScaledVector(Ue.a,r).addScaledVector(Ue.b,s).addScaledVector(Ue.c,1-(r+s)),o.r=gn.x,o.g=gn.y,o.b=gn.z),this}}var Xa=Object.defineProperty,Ea=(a,e,t)=>e in a?Xa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,J=(a,e,t)=>(Ea(a,typeof e!="symbol"?e+"":e,t),t);class Za extends l.Object3D{constructor(e,t){super(),J(this,"isTransformControls",!0),J(this,"visible",!1),J(this,"domElement"),J(this,"raycaster",new l.Raycaster),J(this,"gizmo"),J(this,"plane"),J(this,"tempVector",new l.Vector3),J(this,"tempVector2",new l.Vector3),J(this,"tempQuaternion",new l.Quaternion),J(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),J(this,"pointStart",new l.Vector3),J(this,"pointEnd",new l.Vector3),J(this,"offset",new l.Vector3),J(this,"rotationAxis",new l.Vector3),J(this,"startNorm",new l.Vector3),J(this,"endNorm",new l.Vector3),J(this,"rotationAngle",0),J(this,"cameraPosition",new l.Vector3),J(this,"cameraQuaternion",new l.Quaternion),J(this,"cameraScale",new l.Vector3),J(this,"parentPosition",new l.Vector3),J(this,"parentQuaternion",new l.Quaternion),J(this,"parentQuaternionInv",new l.Quaternion),J(this,"parentScale",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldScaleStart",new l.Vector3),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"worldQuaternionInv",new l.Quaternion),J(this,"worldScale",new l.Vector3),J(this,"eye",new l.Vector3),J(this,"positionStart",new l.Vector3),J(this,"quaternionStart",new l.Quaternion),J(this,"scaleStart",new l.Vector3),J(this,"camera"),J(this,"object"),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"translationSnap",null),J(this,"rotationSnap",null),J(this,"scaleSnap",null),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"changeEvent",{type:"change"}),J(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),J(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),J(this,"objectChangeEvent",{type:"objectChange"}),J(this,"intersectObjectWithRay",(o,r,s)=>{const i=r.intersectObject(o,!0);for(let c=0;c<i.length;c++)if(i[c].object.visible||s)return i[c];return!1}),J(this,"attach",o=>(this.object=o,this.visible=!0,this)),J(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),J(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),J(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),J(this,"pointerHover",o=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(o,this.camera);const r=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);r?this.axis=r.object.name:this.axis=null}),J(this,"pointerDown",o=>{if(!(this.object===void 0||this.dragging===!0||o.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(o,this.camera);const r=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(r){let s=this.space;if(this.mode==="scale"?s="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(s="world"),s==="local"&&this.mode==="rotate"){const i=this.rotationSnap;this.axis==="X"&&i&&(this.object.rotation.x=Math.round(this.object.rotation.x/i)*i),this.axis==="Y"&&i&&(this.object.rotation.y=Math.round(this.object.rotation.y/i)*i),this.axis==="Z"&&i&&(this.object.rotation.z=Math.round(this.object.rotation.z/i)*i)}this.object.updateMatrixWorld(),this.object.parent&&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(r.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),J(this,"pointerMove",o=>{const r=this.axis,s=this.mode,i=this.object;let c=this.space;if(s==="scale"?c="local":(r==="E"||r==="XYZE"||r==="XYZ")&&(c="world"),i===void 0||r===null||this.dragging===!1||o.button!==-1)return;this.raycaster.setFromCamera(o,this.camera);const h=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(h){if(this.pointEnd.copy(h.point).sub(this.worldPositionStart),s==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),c==="local"&&r!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),r.indexOf("X")===-1&&(this.offset.x=0),r.indexOf("Y")===-1&&(this.offset.y=0),r.indexOf("Z")===-1&&(this.offset.z=0),c==="local"&&r!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),i.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(c==="local"&&(i.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),r.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this.quaternionStart)),c==="world"&&(i.parent&&i.position.add(this.tempVector.setFromMatrixPosition(i.parent.matrixWorld)),r.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(this.tempVector.setFromMatrixPosition(i.parent.matrixWorld))));else if(s==="scale"){if(r.search("XYZ")!==-1){let p=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(p*=-1),this.tempVector2.set(p,p,p)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),r.search("X")===-1&&(this.tempVector2.x=1),r.search("Y")===-1&&(this.tempVector2.y=1),r.search("Z")===-1&&(this.tempVector2.z=1);i.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(r.search("X")!==-1&&(this.object.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const p=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));r==="E"?(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):r==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*p):(r==="X"||r==="Y"||r==="Z")&&(this.rotationAxis.copy(this.unit[r]),this.tempVector.copy(this.unit[r]),c==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*p),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),c==="local"&&r!=="E"&&r!=="XYZE"?(i.quaternion.copy(this.quaternionStart),i.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),i.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),J(this,"pointerUp",o=>{o.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),J(this,"getPointer",o=>{var r;if(this.domElement&&((r=this.domElement.ownerDocument)!=null&&r.pointerLockElement))return{x:0,y:0,button:o.button};{const s=o.changedTouches?o.changedTouches[0]:o,i=this.domElement.getBoundingClientRect();return{x:(s.clientX-i.left)/i.width*2-1,y:-(s.clientY-i.top)/i.height*2+1,button:o.button}}}),J(this,"onPointerHover",o=>{if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(o));break}}),J(this,"onPointerDown",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(o)),this.pointerDown(this.getPointer(o)))}),J(this,"onPointerMove",o=>{this.enabled&&this.pointerMove(this.getPointer(o))}),J(this,"onPointerUp",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(o)))}),J(this,"getMode",()=>this.mode),J(this,"setMode",o=>{this.mode=o}),J(this,"setTranslationSnap",o=>{this.translationSnap=o}),J(this,"setRotationSnap",o=>{this.rotationSnap=o}),J(this,"setScaleSnap",o=>{this.scaleSnap=o}),J(this,"setSize",o=>{this.size=o}),J(this,"setSpace",o=>{this.space=o}),J(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),J(this,"connect",o=>{o===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=o,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),J(this,"dispose",()=>{var o,r,s,i,c,h;(o=this.domElement)==null||o.removeEventListener("pointerdown",this.onPointerDown),(r=this.domElement)==null||r.removeEventListener("pointermove",this.onPointerHover),(i=(s=this.domElement)==null?void 0:s.ownerDocument)==null||i.removeEventListener("pointermove",this.onPointerMove),(h=(c=this.domElement)==null?void 0:c.ownerDocument)==null||h.removeEventListener("pointerup",this.onPointerUp),this.traverse(p=>{const f=p;f.geometry&&f.geometry.dispose(),f.material&&f.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new Ka,this.add(this.gizmo),this.plane=new qa,this.add(this.plane);const n=(o,r)=>{let s=r;Object.defineProperty(this,o,{get:function(){return s!==void 0?s:r},set:function(i){s!==i&&(s=i,this.plane[o]=i,this.gizmo[o]=i,this.dispatchEvent({type:o+"-changed",value:i}),this.dispatchEvent(this.changeEvent))}}),this[o]=r,this.plane[o]=r,this.gizmo[o]=r};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class Ka extends l.Object3D{constructor(){super(),J(this,"isTransformControlsGizmo",!0),J(this,"type","TransformControlsGizmo"),J(this,"tempVector",new l.Vector3(0,0,0)),J(this,"tempEuler",new l.Euler),J(this,"alignVector",new l.Vector3(0,1,0)),J(this,"zeroVector",new l.Vector3(0,0,0)),J(this,"lookAtMatrix",new l.Matrix4),J(this,"tempQuaternion",new l.Quaternion),J(this,"tempQuaternion2",new l.Quaternion),J(this,"identityQuaternion",new l.Quaternion),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"gizmo"),J(this,"picker"),J(this,"helper"),J(this,"rotationAxis",new l.Vector3),J(this,"cameraPosition",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"camera",null),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"updateMatrixWorld",()=>{let ne=this.space;this.mode==="scale"&&(ne="local");const ce=ne==="local"?this.worldQuaternion:this.identityQuaternion;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 le=[];le=le.concat(this.picker[this.mode].children),le=le.concat(this.gizmo[this.mode].children),le=le.concat(this.helper[this.mode].children);for(let de=0;de<le.length;de++){const k=le[de];k.visible=!0,k.rotation.set(0,0,0),k.position.copy(this.worldPosition);let V;if(this.camera.isOrthographicCamera?V=(this.camera.top-this.camera.bottom)/this.camera.zoom:V=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),k.scale.set(1,1,1).multiplyScalar(V*this.size/7),k.tag==="helper"){k.visible=!1,k.name==="AXIS"?(k.position.copy(this.worldPositionStart),k.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),k.quaternion.multiply(this.tempQuaternion),k.visible=this.dragging),this.axis==="E"&&(k.visible=!1)):k.name==="START"?(k.position.copy(this.worldPositionStart),k.visible=this.dragging):k.name==="END"?(k.position.copy(this.worldPosition),k.visible=this.dragging):k.name==="DELTA"?(k.position.copy(this.worldPositionStart),k.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),k.scale.copy(this.tempVector),k.visible=this.dragging):(k.quaternion.copy(ce),this.dragging?k.position.copy(this.worldPositionStart):k.position.copy(this.worldPosition),this.axis&&(k.visible=this.axis.search(k.name)!==-1));continue}k.quaternion.copy(ce),this.mode==="translate"||this.mode==="scale"?((k.name==="X"||k.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Y"||k.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Z"||k.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.x*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.y*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.z*=-1:k.tag==="bwd"&&(k.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ce),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ce).invert()),k.name.search("E")!==-1&&k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),k.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion))),k.visible=k.visible&&(k.name.indexOf("X")===-1||this.showX),k.visible=k.visible&&(k.name.indexOf("Y")===-1||this.showY),k.visible=k.visible&&(k.name.indexOf("Z")===-1||this.showZ),k.visible=k.visible&&(k.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),k.material.tempOpacity=k.material.tempOpacity||k.material.opacity,k.material.tempColor=k.material.tempColor||k.material.color.clone(),k.material.color.copy(k.material.tempColor),k.material.opacity=k.material.tempOpacity,this.enabled?this.axis&&(k.name===this.axis?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(U){return k.name===U})?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):(k.material.opacity*=.25,k.material.color.lerp(new l.Color(1,1,1),.5))):(k.material.opacity*=.5,k.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const o=e.clone();o.opacity=.33;const r=e.clone();r.color.set(16711680);const s=e.clone();s.color.set(65280);const i=e.clone();i.color.set(255);const c=e.clone();c.opacity=.25;const h=c.clone();h.color.set(16776960);const p=c.clone();p.color.set(65535);const f=c.clone();f.color.set(16711935),e.clone().color.set(16776960);const d=t.clone();d.color.set(16711680);const g=t.clone();g.color.set(65280);const y=t.clone();y.color.set(255);const v=t.clone();v.color.set(65535);const _=t.clone();_.color.set(16711935);const A=t.clone();A.color.set(16776960);const b=t.clone();b.color.set(7895160);const C=A.clone();C.opacity=.25;const L=new l.CylinderGeometry(0,.05,.2,12,1,!1),M=new l.BoxGeometry(.125,.125,.125),P=new l.BufferGeometry;P.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const w=(ne,ce)=>{const le=new l.BufferGeometry,de=[];for(let k=0;k<=64*ce;++k)de.push(0,Math.cos(k/32*Math.PI)*ne,Math.sin(k/32*Math.PI)*ne);return le.setAttribute("position",new l.Float32BufferAttribute(de,3)),le},S=()=>{const ne=new l.BufferGeometry;return ne.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),ne},x={X:[[new l.Mesh(L,r),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(L,r),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(P,d)]],Y:[[new l.Mesh(L,s),[0,1,0],null,null,"fwd"],[new l.Mesh(L,s),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(P,g),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(L,i),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(L,i),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(P,y),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),c.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),h.clone()),[.15,.15,0]],[new l.Line(P,A),[.18,.3,0],null,[.125,1,1]],[new l.Line(P,A),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),p.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(P,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(P,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),f.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(P,_),[.18,0,.3],null,[.125,1,1]],[new l.Line(P,_),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},D={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new l.Line(S(),o),null,null,null,"helper"]],X:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(P,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(P,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={X:[[new l.Line(w(1,.5),d)],[new l.Mesh(new l.OctahedronGeometry(.04,0),r),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(w(1,.5),g),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),s),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(w(1,.5),y),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(w(1.25,1),C),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(w(1,1),b),null,[0,Math.PI/2,0]]]},G={AXIS:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},X={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},E={X:[[new l.Mesh(M,r),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(P,d),null,null,[.8,1,1]]],Y:[[new l.Mesh(M,s),[0,.8,0]],[new l.Line(P,g),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(M,i),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(P,y),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(M,h),[.85,.85,0],null,[2,2,.2]],[new l.Line(P,A),[.855,.98,0],null,[.125,1,1]],[new l.Line(P,A),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(M,p),[0,.85,.85],null,[.2,2,2]],[new l.Line(P,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(P,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(M,f),[.85,0,.85],null,[2,.2,2]],[new l.Line(P,_),[.855,0,.98],null,[.125,1,1]],[new l.Line(P,_),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,0,1.1]]]},te={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(M,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(M,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(M,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},q={X:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(P,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(P,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},oe=ne=>{const ce=new l.Object3D;for(let le in ne)for(let de=ne[le].length;de--;){const k=ne[le][de][0].clone(),V=ne[le][de][1],U=ne[le][de][2],B=ne[le][de][3],R=ne[le][de][4];k.name=le,k.tag=R,V&&k.position.set(V[0],V[1],V[2]),U&&k.rotation.set(U[0],U[1],U[2]),B&&k.scale.set(B[0],B[1],B[2]),k.updateMatrix();const T=k.geometry.clone();T.applyMatrix4(k.matrix),k.geometry=T,k.renderOrder=1/0,k.position.set(0,0,0),k.rotation.set(0,0,0),k.scale.set(1,1,1),ce.add(k)}return ce};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=oe(x)),this.add(this.gizmo.rotate=oe(z)),this.add(this.gizmo.scale=oe(E)),this.add(this.picker.translate=oe(I)),this.add(this.picker.rotate=oe(X)),this.add(this.picker.scale=oe(te)),this.add(this.helper.translate=oe(D)),this.add(this.helper.rotate=oe(G)),this.add(this.helper.scale=oe(q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class qa extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),J(this,"isTransformControlsPlane",!0),J(this,"type","TransformControlsPlane"),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"tempVector",new l.Vector3),J(this,"dirVector",new l.Vector3),J(this,"alignVector",new l.Vector3),J(this,"tempMatrix",new l.Matrix4),J(this,"identityQuaternion",new l.Quaternion),J(this,"cameraQuaternion",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var Qa=Object.defineProperty,Ja=(a,e,t)=>e in a?Qa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ke=(a,e,t)=>(Ja(a,typeof e!="symbol"?e+"":e,t),t);const Dt=new l.Euler(0,0,0,"YXZ"),kt=new l.Vector3,Ha={type:"change"},$a={type:"lock"},el={type:"unlock"},yr=Math.PI/2;class _r extends l.EventDispatcher{constructor(e,t){super(),ke(this,"camera"),ke(this,"domElement"),ke(this,"isLocked"),ke(this,"minPolarAngle"),ke(this,"maxPolarAngle"),ke(this,"pointerSpeed"),ke(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const o=n.movementX||n.mozMovementX||n.webkitMovementX||0,r=n.movementY||n.mozMovementY||n.webkitMovementY||0;Dt.setFromQuaternion(this.camera.quaternion),Dt.y-=o*.002*this.pointerSpeed,Dt.x-=r*.002*this.pointerSpeed,Dt.x=Math.max(yr-this.maxPolarAngle,Math.min(yr-this.minPolarAngle,Dt.x)),this.camera.quaternion.setFromEuler(Dt),this.dispatchEvent(Ha)}),ke(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent($a),this.isLocked=!0):(this.dispatchEvent(el),this.isLocked=!1))}),ke(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),ke(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),ke(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),ke(this,"dispose",()=>{this.disconnect()}),ke(this,"getObject",()=>this.camera),ke(this,"direction",new l.Vector3(0,0,-1)),ke(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),ke(this,"moveForward",n=>{kt.setFromMatrixColumn(this.camera.matrix,0),kt.crossVectors(this.camera.up,kt),this.camera.position.addScaledVector(kt,n)}),ke(this,"moveRight",n=>{kt.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(kt,n)}),ke(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),ke(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var tl=Object.defineProperty,nl=(a,e,t)=>e in a?tl(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,fe=(a,e,t)=>(nl(a,typeof e!="symbol"?e+"":e,t),t);const yn=new l.Ray,vr=new l.Plane,ol=Math.cos(70*(Math.PI/180)),xr=(a,e)=>(a%e+e)%e;class wr extends l.EventDispatcher{constructor(e,t){super(),fe(this,"object"),fe(this,"domElement"),fe(this,"enabled",!0),fe(this,"target",new l.Vector3),fe(this,"minDistance",0),fe(this,"maxDistance",1/0),fe(this,"minZoom",0),fe(this,"maxZoom",1/0),fe(this,"minPolarAngle",0),fe(this,"maxPolarAngle",Math.PI),fe(this,"minAzimuthAngle",-1/0),fe(this,"maxAzimuthAngle",1/0),fe(this,"enableDamping",!1),fe(this,"dampingFactor",.05),fe(this,"enableZoom",!0),fe(this,"zoomSpeed",1),fe(this,"enableRotate",!0),fe(this,"rotateSpeed",1),fe(this,"enablePan",!0),fe(this,"panSpeed",1),fe(this,"screenSpacePanning",!0),fe(this,"keyPanSpeed",7),fe(this,"zoomToCursor",!1),fe(this,"autoRotate",!1),fe(this,"autoRotateSpeed",2),fe(this,"reverseOrbit",!1),fe(this,"reverseHorizontalOrbit",!1),fe(this,"reverseVerticalOrbit",!1),fe(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),fe(this,"mouseButtons",{LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),fe(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN}),fe(this,"target0"),fe(this,"position0"),fe(this,"zoom0"),fe(this,"_domElementKeyEvents",null),fe(this,"getPolarAngle"),fe(this,"getAzimuthalAngle"),fe(this,"setPolarAngle"),fe(this,"setAzimuthalAngle"),fe(this,"getDistance"),fe(this,"getZoomScale"),fe(this,"listenToKeyEvents"),fe(this,"stopListenToKeyEvents"),fe(this,"saveState"),fe(this,"reset"),fe(this,"update"),fe(this,"connect"),fe(this,"dispose"),fe(this,"dollyIn"),fe(this,"dollyOut"),fe(this,"getScale"),fe(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=Z=>{let ae=xr(Z,2*Math.PI),ge=p.phi;ge<0&&(ge+=2*Math.PI),ae<0&&(ae+=2*Math.PI);let Me=Math.abs(ae-ge);2*Math.PI-Me<Me&&(ae<ge?ae+=2*Math.PI:ge+=2*Math.PI),f.phi=ae-ge,n.update()},this.setAzimuthalAngle=Z=>{let ae=xr(Z,2*Math.PI),ge=p.theta;ge<0&&(ge+=2*Math.PI),ae<0&&(ae+=2*Math.PI);let Me=Math.abs(ae-ge);2*Math.PI-Me<Me&&(ae<ge?ae+=2*Math.PI:ge+=2*Math.PI),f.theta=ae-ge,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=Z=>{Z.addEventListener("keydown",st),this._domElementKeyEvents=Z},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",st),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(o),n.update(),c=i.NONE},this.update=(()=>{const Z=new l.Vector3,ae=new l.Vector3(0,1,0),ge=new l.Quaternion().setFromUnitVectors(e.up,ae),Me=ge.clone().invert(),Be=new l.Vector3,ht=new l.Quaternion,bt=2*Math.PI;return function(){const Qs=n.object.position;ge.setFromUnitVectors(e.up,ae),Me.copy(ge).invert(),Z.copy(Qs).sub(n.target),Z.applyQuaternion(ge),p.setFromVector3(Z),n.autoRotate&&c===i.NONE&&G(D()),n.enableDamping?(p.theta+=f.theta*n.dampingFactor,p.phi+=f.phi*n.dampingFactor):(p.theta+=f.theta,p.phi+=f.phi);let ft=n.minAzimuthAngle,dt=n.maxAzimuthAngle;isFinite(ft)&&isFinite(dt)&&(ft<-Math.PI?ft+=bt:ft>Math.PI&&(ft-=bt),dt<-Math.PI?dt+=bt:dt>Math.PI&&(dt-=bt),ft<=dt?p.theta=Math.max(ft,Math.min(dt,p.theta)):p.theta=p.theta>(ft+dt)/2?Math.max(ft,p.theta):Math.min(dt,p.theta)),p.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,p.phi)),p.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(d,n.dampingFactor):n.target.add(d),n.zoomToCursor&&S||n.object.isOrthographicCamera?p.radius=de(p.radius):p.radius=de(p.radius*m),Z.setFromSpherical(p),Z.applyQuaternion(Me),Qs.copy(n.target).add(Z),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,d.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),d.set(0,0,0));let an=!1;if(n.zoomToCursor&&S){let ln=null;if(n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const cn=Z.length();ln=de(cn*m);const Un=cn-ln;n.object.position.addScaledVector(P,Un),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const cn=new l.Vector3(w.x,w.y,0);cn.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix(),an=!0;const Un=new l.Vector3(w.x,w.y,0);Un.unproject(n.object),n.object.position.sub(Un).add(cn),n.object.updateMatrixWorld(),ln=Z.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;ln!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(ln).add(n.object.position):(yn.origin.copy(n.object.position),yn.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(yn.direction))<ol?e.lookAt(n.target):(vr.setFromNormalAndCoplanarPoint(n.object.up,n.target),yn.intersectPlane(vr,n.target))))}else n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera&&(an=m!==1,an&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix()));return m=1,S=!1,an||Be.distanceToSquared(n.object.position)>h||8*(1-ht.dot(n.object.quaternion))>h?(n.dispatchEvent(o),Be.copy(n.object.position),ht.copy(n.object.quaternion),an=!1,!0):!1}})(),this.connect=Z=>{n.domElement=Z,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",sn),n.domElement.addEventListener("pointerdown",_e),n.domElement.addEventListener("pointercancel",Pe),n.domElement.addEventListener("wheel",It)},this.dispose=()=>{var Z,ae,ge,Me,Be,ht;n.domElement&&(n.domElement.style.touchAction="auto"),(Z=n.domElement)==null||Z.removeEventListener("contextmenu",sn),(ae=n.domElement)==null||ae.removeEventListener("pointerdown",_e),(ge=n.domElement)==null||ge.removeEventListener("pointercancel",Pe),(Me=n.domElement)==null||Me.removeEventListener("wheel",It),(Be=n.domElement)==null||Be.ownerDocument.removeEventListener("pointermove",Le),(ht=n.domElement)==null||ht.ownerDocument.removeEventListener("pointerup",Pe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",st)};const n=this,o={type:"change"},r={type:"start"},s={type:"end"},i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let c=i.NONE;const h=1e-6,p=new l.Spherical,f=new l.Spherical;let m=1;const d=new l.Vector3,g=new l.Vector2,y=new l.Vector2,v=new l.Vector2,_=new l.Vector2,A=new l.Vector2,b=new l.Vector2,C=new l.Vector2,L=new l.Vector2,M=new l.Vector2,P=new l.Vector3,w=new l.Vector2;let S=!1;const x=[],I={};function D(){return 2*Math.PI/60/60*n.autoRotateSpeed}function z(){return Math.pow(.95,n.zoomSpeed)}function G(Z){n.reverseOrbit||n.reverseHorizontalOrbit?f.theta+=Z:f.theta-=Z}function X(Z){n.reverseOrbit||n.reverseVerticalOrbit?f.phi+=Z:f.phi-=Z}const E=(()=>{const Z=new l.Vector3;return function(ge,Me){Z.setFromMatrixColumn(Me,0),Z.multiplyScalar(-ge),d.add(Z)}})(),te=(()=>{const Z=new l.Vector3;return function(ge,Me){n.screenSpacePanning===!0?Z.setFromMatrixColumn(Me,1):(Z.setFromMatrixColumn(Me,0),Z.crossVectors(n.object.up,Z)),Z.multiplyScalar(ge),d.add(Z)}})(),q=(()=>{const Z=new l.Vector3;return function(ge,Me){const Be=n.domElement;if(Be&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const ht=n.object.position;Z.copy(ht).sub(n.target);let bt=Z.length();bt*=Math.tan(n.object.fov/2*Math.PI/180),E(2*ge*bt/Be.clientHeight,n.object.matrix),te(2*Me*bt/Be.clientHeight,n.object.matrix)}else Be&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(E(ge*(n.object.right-n.object.left)/n.object.zoom/Be.clientWidth,n.object.matrix),te(Me*(n.object.top-n.object.bottom)/n.object.zoom/Be.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function oe(Z){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?m=Z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ne(Z){oe(m/Z)}function ce(Z){oe(m*Z)}function le(Z){if(!n.zoomToCursor||!n.domElement)return;S=!0;const ae=n.domElement.getBoundingClientRect(),ge=Z.clientX-ae.left,Me=Z.clientY-ae.top,Be=ae.width,ht=ae.height;w.x=ge/Be*2-1,w.y=-(Me/ht)*2+1,P.set(w.x,w.y,1).unproject(n.object).sub(n.object.position).normalize()}function de(Z){return Math.max(n.minDistance,Math.min(n.maxDistance,Z))}function k(Z){g.set(Z.clientX,Z.clientY)}function V(Z){le(Z),C.set(Z.clientX,Z.clientY)}function U(Z){_.set(Z.clientX,Z.clientY)}function B(Z){y.set(Z.clientX,Z.clientY),v.subVectors(y,g).multiplyScalar(n.rotateSpeed);const ae=n.domElement;ae&&(G(2*Math.PI*v.x/ae.clientHeight),X(2*Math.PI*v.y/ae.clientHeight)),g.copy(y),n.update()}function R(Z){L.set(Z.clientX,Z.clientY),M.subVectors(L,C),M.y>0?ne(z()):M.y<0&&ce(z()),C.copy(L),n.update()}function T(Z){A.set(Z.clientX,Z.clientY),b.subVectors(A,_).multiplyScalar(n.panSpeed),q(b.x,b.y),_.copy(A),n.update()}function O(Z){le(Z),Z.deltaY<0?ce(z()):Z.deltaY>0&&ne(z()),n.update()}function N(Z){let ae=!1;switch(Z.code){case n.keys.UP:q(0,n.keyPanSpeed),ae=!0;break;case n.keys.BOTTOM:q(0,-n.keyPanSpeed),ae=!0;break;case n.keys.LEFT:q(n.keyPanSpeed,0),ae=!0;break;case n.keys.RIGHT:q(-n.keyPanSpeed,0),ae=!0;break}ae&&(Z.preventDefault(),n.update())}function K(){if(x.length==1)g.set(x[0].pageX,x[0].pageY);else{const Z=.5*(x[0].pageX+x[1].pageX),ae=.5*(x[0].pageY+x[1].pageY);g.set(Z,ae)}}function W(){if(x.length==1)_.set(x[0].pageX,x[0].pageY);else{const Z=.5*(x[0].pageX+x[1].pageX),ae=.5*(x[0].pageY+x[1].pageY);_.set(Z,ae)}}function Y(){const Z=x[0].pageX-x[1].pageX,ae=x[0].pageY-x[1].pageY,ge=Math.sqrt(Z*Z+ae*ae);C.set(0,ge)}function Q(){n.enableZoom&&Y(),n.enablePan&&W()}function re(){n.enableZoom&&Y(),n.enableRotate&&K()}function se(Z){if(x.length==1)y.set(Z.pageX,Z.pageY);else{const ge=jo(Z),Me=.5*(Z.pageX+ge.x),Be=.5*(Z.pageY+ge.y);y.set(Me,Be)}v.subVectors(y,g).multiplyScalar(n.rotateSpeed);const ae=n.domElement;ae&&(G(2*Math.PI*v.x/ae.clientHeight),X(2*Math.PI*v.y/ae.clientHeight)),g.copy(y)}function j(Z){if(x.length==1)A.set(Z.pageX,Z.pageY);else{const ae=jo(Z),ge=.5*(Z.pageX+ae.x),Me=.5*(Z.pageY+ae.y);A.set(ge,Me)}b.subVectors(A,_).multiplyScalar(n.panSpeed),q(b.x,b.y),_.copy(A)}function F(Z){const ae=jo(Z),ge=Z.pageX-ae.x,Me=Z.pageY-ae.y,Be=Math.sqrt(ge*ge+Me*Me);L.set(0,Be),M.set(0,Math.pow(L.y/C.y,n.zoomSpeed)),ne(M.y),C.copy(L)}function ie(Z){n.enableZoom&&F(Z),n.enablePan&&j(Z)}function he(Z){n.enableZoom&&F(Z),n.enableRotate&&se(Z)}function _e(Z){var ae,ge;n.enabled!==!1&&(x.length===0&&((ae=n.domElement)==null||ae.ownerDocument.addEventListener("pointermove",Le),(ge=n.domElement)==null||ge.ownerDocument.addEventListener("pointerup",Pe)),kn(Z),Z.pointerType==="touch"?Ee(Z):Je(Z))}function Le(Z){n.enabled!==!1&&(Z.pointerType==="touch"?it(Z):wt(Z))}function Pe(Z){var ae,ge,Me;Ro(Z),x.length===0&&((ae=n.domElement)==null||ae.releasePointerCapture(Z.pointerId),(ge=n.domElement)==null||ge.ownerDocument.removeEventListener("pointermove",Le),(Me=n.domElement)==null||Me.ownerDocument.removeEventListener("pointerup",Pe)),n.dispatchEvent(s),c=i.NONE}function Je(Z){let ae;switch(Z.button){case 0:ae=n.mouseButtons.LEFT;break;case 1:ae=n.mouseButtons.MIDDLE;break;case 2:ae=n.mouseButtons.RIGHT;break;default:ae=-1}switch(ae){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;V(Z),c=i.DOLLY;break;case l.MOUSE.ROTATE:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(n.enablePan===!1)return;U(Z),c=i.PAN}else{if(n.enableRotate===!1)return;k(Z),c=i.ROTATE}break;case l.MOUSE.PAN:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(n.enableRotate===!1)return;k(Z),c=i.ROTATE}else{if(n.enablePan===!1)return;U(Z),c=i.PAN}break;default:c=i.NONE}c!==i.NONE&&n.dispatchEvent(r)}function wt(Z){if(n.enabled!==!1)switch(c){case i.ROTATE:if(n.enableRotate===!1)return;B(Z);break;case i.DOLLY:if(n.enableZoom===!1)return;R(Z);break;case i.PAN:if(n.enablePan===!1)return;T(Z);break}}function It(Z){n.enabled===!1||n.enableZoom===!1||c!==i.NONE&&c!==i.ROTATE||(Z.preventDefault(),n.dispatchEvent(r),O(Z),n.dispatchEvent(s))}function st(Z){n.enabled===!1||n.enablePan===!1||N(Z)}function Ee(Z){switch(Bn(Z),x.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;K(),c=i.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;W(),c=i.TOUCH_PAN;break;default:c=i.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Q(),c=i.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;re(),c=i.TOUCH_DOLLY_ROTATE;break;default:c=i.NONE}break;default:c=i.NONE}c!==i.NONE&&n.dispatchEvent(r)}function it(Z){switch(Bn(Z),c){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;se(Z),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;j(Z),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ie(Z),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;he(Z),n.update();break;default:c=i.NONE}}function sn(Z){n.enabled!==!1&&Z.preventDefault()}function kn(Z){x.push(Z)}function Ro(Z){delete I[Z.pointerId];for(let ae=0;ae<x.length;ae++)if(x[ae].pointerId==Z.pointerId){x.splice(ae,1);return}}function Bn(Z){let ae=I[Z.pointerId];ae===void 0&&(ae=new l.Vector2,I[Z.pointerId]=ae),ae.set(Z.pageX,Z.pageY)}function jo(Z){const ae=Z.pointerId===x[0].pointerId?x[1]:x[0];return I[ae.pointerId]}this.dollyIn=(Z=z())=>{ce(Z),n.update()},this.dollyOut=(Z=z())=>{ne(Z),n.update()},this.getScale=()=>m,this.setScale=Z=>{oe(Z),n.update()},this.getZoomScale=()=>z(),t!==void 0&&this.connect(t),this.update()}}class rl extends wr{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}function Bt(a){if(typeof TextDecoder<"u")return new TextDecoder().decode(a);let e="";for(let t=0,n=a.length;t<n;t++)e+=String.fromCharCode(a[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const St="srgb",lt="srgb-linear",br=3001,sl=3e3;class il extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new hl(t)}),this.register(function(t){return new fl(t)}),this.register(function(t){return new wl(t)}),this.register(function(t){return new bl(t)}),this.register(function(t){return new Ml(t)}),this.register(function(t){return new pl(t)}),this.register(function(t){return new ml(t)}),this.register(function(t){return new gl(t)}),this.register(function(t){return new yl(t)}),this.register(function(t){return new ul(t)}),this.register(function(t){return new _l(t)}),this.register(function(t){return new dl(t)}),this.register(function(t){return new xl(t)}),this.register(function(t){return new vl(t)}),this.register(function(t){return new ll(t)}),this.register(function(t){return new Sl(t)}),this.register(function(t){return new Al(t)})}load(e,t,n,o){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const h=l.LoaderUtils.extractUrlBase(e);s=l.LoaderUtils.resolveURL(h,this.path)}else s=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const i=function(h){o?o(h):console.error(h),r.manager.itemError(e),r.manager.itemEnd(e)},c=new l.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{r.parse(h,s,function(p){t(p),r.manager.itemEnd(e)},i)}catch(p){i(p)}},n,i)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,o){let r;const s={},i={};if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(Bt(new Uint8Array(e.slice(0,4)))===Mr){try{s[ve.KHR_BINARY_GLTF]=new Pl(e)}catch(p){o&&o(p);return}r=JSON.parse(s[ve.KHR_BINARY_GLTF].content)}else r=JSON.parse(Bt(new Uint8Array(e)));else r=e;if(r.asset===void 0||r.asset.version[0]<2){o&&o(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Vl(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const p=this.pluginCallbacks[h](c);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),i[p.name]=p,s[p.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const p=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(p){case ve.KHR_MATERIALS_UNLIT:s[p]=new cl;break;case ve.KHR_DRACO_MESH_COMPRESSION:s[p]=new Cl(r,this.dracoLoader);break;case ve.KHR_TEXTURE_TRANSFORM:s[p]=new Tl;break;case ve.KHR_MESH_QUANTIZATION:s[p]=new Il;break;default:f.indexOf(p)>=0&&i[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}c.setExtensions(s),c.setPlugins(i),c.parse(n,o)}parseAsync(e,t){const n=this;return new Promise(function(o,r){n.parse(e,t,o,r)})}}function al(){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={}}}}const ve={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ll{constructor(e){this.parser=e,this.name=ve.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,o=t.length;n<o;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let o=t.cache.get(n);if(o)return o;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const p=new l.Color(16777215);c.color!==void 0&&p.setRGB(c.color[0],c.color[1],c.color[2],lt);const f=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new l.DirectionalLight(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new l.PointLight(p),h.distance=f;break;case"spot":h=new l.SpotLight(p),h.distance=f,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,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),h.decay=2,ct(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),o=Promise.resolve(h),t.cache.add(n,o),o}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(c){return n._getNodeRef(t.cache,i,c)})}}class cl{constructor(){this.name=ve.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const o=[];e.color=new l.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],lt),e.opacity=s[3]}r.baseColorTexture!==void 0&&o.push(n.assignTexture(e,"map",r.baseColorTexture,St))}return Promise.all(o)}}class ul{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class hl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(i,i)}return Promise.all(r)}}class fl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class dl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.push(n.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&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class pl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=o.extensions[this.name];if(s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],lt)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,St)),s.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class ml{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class gl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color().setRGB(i[0],i[1],i[2],lt),Promise.all(r)}}class yl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class _l{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return t.specularColor=new l.Color().setRGB(i[0],i[1],i[2],lt),s.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,St)),Promise.all(r)}}class vl{constructor(e){this.parser=e,this.name=ve.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class xl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class wl{constructor(e){this.parser=e,this.name=ve.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,o=n.textures[e];if(!o.extensions||!o.extensions[this.name])return null;const r=o.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class bl{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],i=o.images[s.source];let c=n.textureLoader;if(i.uri){const h=n.options.manager.getHandler(i.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,s.source,c);if(o.extensionsRequired&&o.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ml{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],i=o.images[s.source];let c=n.textureLoader;if(i.uri){const h=n.options.manager.getHandler(i.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,s.source,c);if(o.extensionsRequired&&o.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Sl{constructor(e){this.name=ve.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const o=n.extensions[this.name],r=this.parser.getDependency("buffer",o.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 r.then(function(i){const c=o.byteOffset||0,h=o.byteLength||0,p=o.count,f=o.byteStride,m=new Uint8Array(i,c,h);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(p,f,m,o.mode,o.filter).then(function(d){return d.buffer}):s.ready.then(function(){const d=new ArrayBuffer(p*f);return s.decodeGltfBuffer(new Uint8Array(d),p,f,m,o.mode,o.filter),d})})}else return null}}class Al{constructor(e){this.name=ve.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const o=t.meshes[n.mesh];for(const h of o.primitives)if(h.mode!==Ke.TRIANGLES&&h.mode!==Ke.TRIANGLE_STRIP&&h.mode!==Ke.TRIANGLE_FAN&&h.mode!==void 0)return null;const s=n.extensions[this.name].attributes,i=[],c={};for(const h in s)i.push(this.parser.getDependency("accessor",s[h]).then(p=>(c[h]=p,c[h])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(h=>{const p=h.pop(),f=p.isGroup?p.children:[p],m=h[0].count,d=[];for(const g of f){const y=new l.Matrix4,v=new l.Vector3,_=new l.Quaternion,A=new l.Vector3(1,1,1),b=new l.InstancedMesh(g.geometry,g.material,m);for(let C=0;C<m;C++)c.TRANSLATION&&v.fromBufferAttribute(c.TRANSLATION,C),c.ROTATION&&_.fromBufferAttribute(c.ROTATION,C),c.SCALE&&A.fromBufferAttribute(c.SCALE,C),b.setMatrixAt(C,y.compose(v,_,A));for(const C in c)if(C==="_COLOR_0"){const L=c[C];b.instanceColor=new l.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else C!=="TRANSLATION"&&C!=="ROTATION"&&C!=="SCALE"&&g.geometry.setAttribute(C,c[C]);l.Object3D.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),d.push(b)}return p.isGroup?(p.clear(),p.add(...d),p):d[0]}))}}const Mr="glTF",qt=12,Sr={JSON:1313821514,BIN:5130562};class Pl{constructor(e){this.name=ve.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,qt);if(this.header={magic:Bt(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Mr)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-qt,o=new DataView(e,qt);let r=0;for(;r<n;){const s=o.getUint32(r,!0);r+=4;const i=o.getUint32(r,!0);if(r+=4,i===Sr.JSON){const c=new Uint8Array(e,qt+r,s);this.content=Bt(c)}else if(i===Sr.BIN){const c=qt+r;this.body=e.slice(c,c+s)}r+=s}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Cl{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ve.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,o=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,i={},c={},h={};for(const p in s){const f=eo[p]||p.toLowerCase();i[f]=s[p]}for(const p in e.attributes){const f=eo[p]||p.toLowerCase();if(s[p]!==void 0){const m=n.accessors[e.attributes[p]],d=Ut[m.componentType];h[f]=d.name,c[f]=m.normalized===!0}}return t.getDependency("bufferView",r).then(function(p){return new Promise(function(f,m){o.decodeDracoFile(p,function(d){for(const g in d.attributes){const y=d.attributes[g],v=c[g];v!==void 0&&(y.normalized=v)}f(d)},i,h,lt,m)})})}}class Tl{constructor(){this.name=ve.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 Il{constructor(){this.name=ve.KHR_MESH_QUANTIZATION}}class Ar extends l.Interpolant{constructor(e,t,n,o){super(e,t,n,o)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,o=this.valueSize,r=e*o*3+o;for(let s=0;s!==o;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,o){const r=this.resultBuffer,s=this.sampleValues,i=this.valueSize,c=i*2,h=i*3,p=o-t,f=(n-t)/p,m=f*f,d=m*f,g=e*h,y=g-h,v=-2*d+3*m,_=d-m,A=1-v,b=_-m+f;for(let C=0;C!==i;C++){const L=s[y+C+i],M=s[y+C+c]*p,P=s[g+C+i],w=s[g+C]*p;r[C]=A*L+b*M+v*P+_*w}return r}}const Ol=new l.Quaternion;class Ll extends Ar{interpolate_(e,t,n,o){const r=super.interpolate_(e,t,n,o);return Ol.fromArray(r).normalize().toArray(r),r}}const Ke={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ut={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Pr={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},Cr={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},$n={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eo={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Xt>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},_t={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Dl={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},to={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kl(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),a.DefaultMaterial}function At(a,e,t){for(const n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ct(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 Bl(a,e,t){let n=!1,o=!1,r=!1;for(let h=0,p=e.length;h<p;h++){const f=e[h];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(o=!0),f.COLOR_0!==void 0&&(r=!0),n&&o&&r)break}if(!n&&!o&&!r)return Promise.resolve(a);const s=[],i=[],c=[];for(let h=0,p=e.length;h<p;h++){const f=e[h];if(n){const m=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):a.attributes.position;s.push(m)}if(o){const m=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):a.attributes.normal;i.push(m)}if(r){const m=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):a.attributes.color;c.push(m)}}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(c)]).then(function(h){const p=h[0],f=h[1],m=h[2];return n&&(a.morphAttributes.position=p),o&&(a.morphAttributes.normal=f),r&&(a.morphAttributes.color=m),a.morphTargetsRelative=!0,a})}function Ul(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;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 n=0,o=t.length;n<o;n++)a.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Nl(a){let e;const t=a.extensions&&a.extensions[ve.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+no(t.attributes):e=a.indices+":"+no(a.attributes)+":"+a.mode,a.targets!==void 0)for(let n=0,o=a.targets.length;n<o;n++)e+=":"+no(a.targets[n]);return e}function no(a){let e="";const t=Object.keys(a).sort();for(let n=0,o=t.length;n<o;n++)e+=t[n]+":"+a[t[n]]+";";return e}function oo(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 Fl(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":"image/png"}const zl=new l.Matrix4;class Vl{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new al,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,o=!1,r=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,o=navigator.userAgent.indexOf("Firefox")>-1,r=o?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||o&&r<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.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 n=this,o=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){const i={scene:s[0][o.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:o.asset,parser:n,userData:{}};return At(r,i,o),ct(i,o),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(i)})).then(function(){for(const c of i.scenes)c.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let o=0,r=t.length;o<r;o++){const s=t[o].joints;for(let i=0,c=s.length;i<c;i++)e[s[i]].isBone=!0}for(let o=0,r=e.length;o<r;o++){const s=e[o];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(n[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const o=n.clone(),r=(s,i)=>{const c=this.associations.get(s);c!=null&&this.associations.set(i,c);for(const[h,p]of s.children.entries())r(p,i.children[h])};return r(n,o),o.name+="_instance_"+e.uses[t]++,o}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const o=e(t[n]);if(o)return o}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let o=this.cache.get(n);if(!o){switch(e){case"scene":o=this.loadScene(t);break;case"node":o=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":o=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":o=this.loadAccessor(t);break;case"bufferView":o=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":o=this.loadBuffer(t);break;case"material":o=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":o=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":o=this.loadSkin(t);break;case"animation":o=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":o=this.loadCamera(t);break;default:if(o=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!o)throw new Error("Unknown type: "+e);break}this.cache.add(n,o)}return o}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,o=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(o.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ve.KHR_BINARY_GLTF].body);const o=this.options;return new Promise(function(r,s){n.load(l.LoaderUtils.resolveURL(t.uri,o.path),r,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const o=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+o)})}loadAccessor(e){const t=this,n=this.json,o=this.json.accessors[e];if(o.bufferView===void 0&&o.sparse===void 0){const s=$n[o.type],i=Ut[o.componentType],c=o.normalized===!0,h=new i(o.count*s);return Promise.resolve(new l.BufferAttribute(h,s,c))}const r=[];return o.bufferView!==void 0?r.push(this.getDependency("bufferView",o.bufferView)):r.push(null),o.sparse!==void 0&&(r.push(this.getDependency("bufferView",o.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",o.sparse.values.bufferView))),Promise.all(r).then(function(s){const i=s[0],c=$n[o.type],h=Ut[o.componentType],p=h.BYTES_PER_ELEMENT,f=p*c,m=o.byteOffset||0,d=o.bufferView!==void 0?n.bufferViews[o.bufferView].byteStride:void 0,g=o.normalized===!0;let y,v;if(d&&d!==f){const _=Math.floor(m/d),A="InterleavedBuffer:"+o.bufferView+":"+o.componentType+":"+_+":"+o.count;let b=t.cache.get(A);b||(y=new h(i,_*d,o.count*d/p),b=new l.InterleavedBuffer(y,d/p),t.cache.add(A,b)),v=new l.InterleavedBufferAttribute(b,c,m%d/p,g)}else i===null?y=new h(o.count*c):y=new h(i,m,o.count*c),v=new l.BufferAttribute(y,c,g);if(o.sparse!==void 0){const _=$n.SCALAR,A=Ut[o.sparse.indices.componentType],b=o.sparse.indices.byteOffset||0,C=o.sparse.values.byteOffset||0,L=new A(s[1],b,o.sparse.count*_),M=new h(s[2],C,o.sparse.count*c);i!==null&&(v=new l.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let P=0,w=L.length;P<w;P++){const S=L[P];if(v.setX(S,M[P*c]),c>=2&&v.setY(S,M[P*c+1]),c>=3&&v.setZ(S,M[P*c+2]),c>=4&&v.setW(S,M[P*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r];let i=this.textureLoader;if(s.uri){const c=n.manager.getHandler(s.uri);c!==null&&(i=c)}return this.loadTextureImage(e,r,i)}loadTextureImage(e,t,n){const o=this,r=this.json,s=r.textures[e],i=r.images[t],c=(i.uri||i.bufferView)+":"+s.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(t,n).then(function(p){p.flipY=!1,p.name=s.name||i.name||"",p.name===""&&typeof i.uri=="string"&&i.uri.startsWith("data:image/")===!1&&(p.name=i.uri);const m=(r.samplers||{})[s.sampler]||{};return p.magFilter=Pr[m.magFilter]||l.LinearFilter,p.minFilter=Pr[m.minFilter]||l.LinearMipmapLinearFilter,p.wrapS=Cr[m.wrapS]||l.RepeatWrapping,p.wrapT=Cr[m.wrapT]||l.RepeatWrapping,o.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,t){const n=this,o=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const s=o.images[e],i=self.URL||self.webkitURL;let c=s.uri||"",h=!1;if(s.bufferView!==void 0)c=n.getDependency("bufferView",s.bufferView).then(function(f){h=!0;const m=new Blob([f],{type:s.mimeType});return c=i.createObjectURL(m),c});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(c).then(function(f){return new Promise(function(m,d){let g=m;t.isImageBitmapLoader===!0&&(g=function(y){const v=new l.Texture(y);v.needsUpdate=!0,m(v)}),t.load(l.LoaderUtils.resolveURL(f,r.path),g,void 0,d)})}).then(function(f){return h===!0&&i.revokeObjectURL(c),ct(f,s),f.userData.mimeType=s.mimeType||Fl(s.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),f});return this.sourceCache[e]=p,p}assignTexture(e,t,n,o){const r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(s=s.clone(),s.channel=n.texCoord),r.extensions[ve.KHR_TEXTURE_TRANSFORM]){const i=n.extensions!==void 0?n.extensions[ve.KHR_TEXTURE_TRANSFORM]:void 0;if(i){const c=r.associations.get(s);s=r.extensions[ve.KHR_TEXTURE_TRANSFORM].extendTexture(s,i),r.associations.set(s,c)}}return o!==void 0&&(typeof o=="number"&&(o=o===br?St:lt),"colorSpace"in s?s.colorSpace=o:s.encoding=o===St?br:sl),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const o=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const i="PointsMaterial:"+n.uuid;let c=this.cache.get(i);c||(c=new l.PointsMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(i,c)),n=c}else if(e.isLine){const i="LineBasicMaterial:"+n.uuid;let c=this.cache.get(i);c||(c=new l.LineBasicMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(i,c)),n=c}if(o||r||s){let i="ClonedMaterial:"+n.uuid+":";o&&(i+="derivative-tangents:"),r&&(i+="vertex-colors:"),s&&(i+="flat-shading:");let c=this.cache.get(i);c||(c=n.clone(),r&&(c.vertexColors=!0),s&&(c.flatShading=!0),o&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(i,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,o=this.extensions,r=n.materials[e];let s;const i={},c=r.extensions||{},h=[];if(c[ve.KHR_MATERIALS_UNLIT]){const f=o[ve.KHR_MATERIALS_UNLIT];s=f.getMaterialType(),h.push(f.extendParams(i,r,t))}else{const f=r.pbrMetallicRoughness||{};if(i.color=new l.Color(1,1,1),i.opacity=1,Array.isArray(f.baseColorFactor)){const m=f.baseColorFactor;i.color.setRGB(m[0],m[1],m[2],lt),i.opacity=m[3]}f.baseColorTexture!==void 0&&h.push(t.assignTexture(i,"map",f.baseColorTexture,St)),i.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,i.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(i,"metalnessMap",f.metallicRoughnessTexture)),h.push(t.assignTexture(i,"roughnessMap",f.metallicRoughnessTexture))),s=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,i)})))}r.doubleSided===!0&&(i.side=l.DoubleSide);const p=r.alphaMode||to.OPAQUE;if(p===to.BLEND?(i.transparent=!0,i.depthWrite=!1):(i.transparent=!1,p===to.MASK&&(i.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==l.MeshBasicMaterial&&(h.push(t.assignTexture(i,"normalMap",r.normalTexture)),i.normalScale=new l.Vector2(1,1),r.normalTexture.scale!==void 0)){const f=r.normalTexture.scale;i.normalScale.set(f,f)}if(r.occlusionTexture!==void 0&&s!==l.MeshBasicMaterial&&(h.push(t.assignTexture(i,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(i.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==l.MeshBasicMaterial){const f=r.emissiveFactor;i.emissive=new l.Color().setRGB(f[0],f[1],f[2],lt)}return r.emissiveTexture!==void 0&&s!==l.MeshBasicMaterial&&h.push(t.assignTexture(i,"emissiveMap",r.emissiveTexture,St)),Promise.all(h).then(function(){const f=new s(i);return r.name&&(f.name=r.name),ct(f,r),t.associations.set(f,{materials:e}),r.extensions&&At(o,f,r),f})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,o=this.primitiveCache;function r(i){return n[ve.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(i,t).then(function(c){return Tr(c,i,t)})}const s=[];for(let i=0,c=e.length;i<c;i++){const h=e[i],p=Nl(h),f=o[p];if(f)s.push(f.promise);else{let m;h.extensions&&h.extensions[ve.KHR_DRACO_MESH_COMPRESSION]?m=r(h):m=Tr(new l.BufferGeometry,h,t),o[p]={primitive:h,promise:m},s.push(m)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,o=this.extensions,r=n.meshes[e],s=r.primitives,i=[];for(let c=0,h=s.length;c<h;c++){const p=s[c].material===void 0?kl(this.cache):this.getDependency("material",s[c].material);i.push(p)}return i.push(t.loadGeometries(s)),Promise.all(i).then(function(c){const h=c.slice(0,c.length-1),p=c[c.length-1],f=[];for(let d=0,g=p.length;d<g;d++){const y=p[d],v=s[d];let _;const A=h[d];if(v.mode===Ke.TRIANGLES||v.mode===Ke.TRIANGLE_STRIP||v.mode===Ke.TRIANGLE_FAN||v.mode===void 0)_=r.isSkinnedMesh===!0?new l.SkinnedMesh(y,A):new l.Mesh(y,A),_.isSkinnedMesh===!0&&_.normalizeSkinWeights(),v.mode===Ke.TRIANGLE_STRIP?_.geometry=qo(_.geometry,l.TriangleStripDrawMode):v.mode===Ke.TRIANGLE_FAN&&(_.geometry=qo(_.geometry,l.TriangleFanDrawMode));else if(v.mode===Ke.LINES)_=new l.LineSegments(y,A);else if(v.mode===Ke.LINE_STRIP)_=new l.Line(y,A);else if(v.mode===Ke.LINE_LOOP)_=new l.LineLoop(y,A);else if(v.mode===Ke.POINTS)_=new l.Points(y,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(_.geometry.morphAttributes).length>0&&Ul(_,r),_.name=t.createUniqueName(r.name||"mesh_"+e),ct(_,r),v.extensions&&At(o,_,v),t.assignFinalMaterial(_),f.push(_)}for(let d=0,g=f.length;d<g;d++)t.associations.set(f[d],{meshes:e,primitives:d});if(f.length===1)return r.extensions&&At(o,f[0],r),f[0];const m=new l.Group;r.extensions&&At(o,m,r),t.associations.set(m,{meshes:e});for(let d=0,g=f.length;d<g;d++)m.add(f[d]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],o=n[n.type];if(!o){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(o.yfov),o.aspectRatio||1,o.znear||1,o.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-o.xmag,o.xmag,o.ymag,-o.ymag,o.znear,o.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ct(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let o=0,r=t.joints.length;o<r;o++)n.push(this._loadNodeShallow(t.joints[o]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(o){const r=o.pop(),s=o,i=[],c=[];for(let h=0,p=s.length;h<p;h++){const f=s[h];if(f){i.push(f);const m=new l.Matrix4;r!==null&&m.fromArray(r.array,h*16),c.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new l.Skeleton(i,c)})}loadAnimation(e){const t=this.json,n=this,o=t.animations[e],r=o.name?o.name:"animation_"+e,s=[],i=[],c=[],h=[],p=[];for(let f=0,m=o.channels.length;f<m;f++){const d=o.channels[f],g=o.samplers[d.sampler],y=d.target,v=y.node,_=o.parameters!==void 0?o.parameters[g.input]:g.input,A=o.parameters!==void 0?o.parameters[g.output]:g.output;y.node!==void 0&&(s.push(this.getDependency("node",v)),i.push(this.getDependency("accessor",_)),c.push(this.getDependency("accessor",A)),h.push(g),p.push(y))}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(c),Promise.all(h),Promise.all(p)]).then(function(f){const m=f[0],d=f[1],g=f[2],y=f[3],v=f[4],_=[];for(let A=0,b=m.length;A<b;A++){const C=m[A],L=d[A],M=g[A],P=y[A],w=v[A];if(C===void 0)continue;C.updateMatrix&&C.updateMatrix();const S=n._createAnimationTracks(C,L,M,P,w);if(S)for(let x=0;x<S.length;x++)_.push(S[x])}return new l.AnimationClip(r,void 0,_)})}createNodeMesh(e){const t=this.json,n=this,o=t.nodes[e];return o.mesh===void 0?null:n.getDependency("mesh",o.mesh).then(function(r){const s=n._getNodeRef(n.meshCache,o.mesh,r);return o.weights!==void 0&&s.traverse(function(i){if(i.isMesh)for(let c=0,h=o.weights.length;c<h;c++)i.morphTargetInfluences[c]=o.weights[c]}),s})}loadNode(e){const t=this.json,n=this,o=t.nodes[e],r=n._loadNodeShallow(e),s=[],i=o.children||[];for(let h=0,p=i.length;h<p;h++)s.push(n.getDependency("node",i[h]));const c=o.skin===void 0?Promise.resolve(null):n.getDependency("skin",o.skin);return Promise.all([r,Promise.all(s),c]).then(function(h){const p=h[0],f=h[1],m=h[2];m!==null&&p.traverse(function(d){d.isSkinnedMesh&&d.bind(m,zl)});for(let d=0,g=f.length;d<g;d++)p.add(f[d]);return p})}_loadNodeShallow(e){const t=this.json,n=this.extensions,o=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],s=r.name?o.createUniqueName(r.name):"",i=[],c=o._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&i.push(c),r.camera!==void 0&&i.push(o.getDependency("camera",r.camera).then(function(h){return o._getNodeRef(o.cameraCache,r.camera,h)})),o._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){i.push(h)}),this.nodeCache[e]=Promise.all(i).then(function(h){let p;if(r.isBone===!0?p=new l.Bone:h.length>1?p=new l.Group:h.length===1?p=h[0]:p=new l.Object3D,p!==h[0])for(let f=0,m=h.length;f<m;f++)p.add(h[f]);if(r.name&&(p.userData.name=r.name,p.name=s),ct(p,r),r.extensions&&At(n,p,r),r.matrix!==void 0){const f=new l.Matrix4;f.fromArray(r.matrix),p.applyMatrix4(f)}else r.translation!==void 0&&p.position.fromArray(r.translation),r.rotation!==void 0&&p.quaternion.fromArray(r.rotation),r.scale!==void 0&&p.scale.fromArray(r.scale);return o.associations.has(p)||o.associations.set(p,{}),o.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],o=this,r=new l.Group;n.name&&(r.name=o.createUniqueName(n.name)),ct(r,n),n.extensions&&At(t,r,n);const s=n.nodes||[],i=[];for(let c=0,h=s.length;c<h;c++)i.push(o.getDependency("node",s[c]));return Promise.all(i).then(function(c){for(let p=0,f=c.length;p<f;p++)r.add(c[p]);const h=p=>{const f=new Map;for(const[m,d]of o.associations)(m instanceof l.Material||m instanceof l.Texture)&&f.set(m,d);return p.traverse(m=>{const d=o.associations.get(m);d!=null&&f.set(m,d)}),f};return o.associations=h(r),r})}_createAnimationTracks(e,t,n,o,r){const s=[],i=e.name?e.name:e.uuid,c=[];_t[r.path]===_t.weights?e.traverse(function(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}):c.push(i);let h;switch(_t[r.path]){case _t.weights:h=l.NumberKeyframeTrack;break;case _t.rotation:h=l.QuaternionKeyframeTrack;break;case _t.position:case _t.scale:h=l.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=l.NumberKeyframeTrack;break;case 2:case 3:default:h=l.VectorKeyframeTrack;break}break}const p=o.interpolation!==void 0?Dl[o.interpolation]:l.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let m=0,d=c.length;m<d;m++){const g=new h(c[m]+"."+_t[r.path],t.array,f,p);o.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=oo(t.constructor),o=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)o[r]=t[r]*n;t=o}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const o=this instanceof l.QuaternionKeyframeTrack?Ll:Ar;return new o(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Gl(a,e,t){const n=e.attributes,o=new l.Box3;if(n.POSITION!==void 0){const i=t.json.accessors[n.POSITION],c=i.min,h=i.max;if(c!==void 0&&h!==void 0){if(o.set(new l.Vector3(c[0],c[1],c[2]),new l.Vector3(h[0],h[1],h[2])),i.normalized){const p=oo(Ut[i.componentType]);o.min.multiplyScalar(p),o.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const i=new l.Vector3,c=new l.Vector3;for(let h=0,p=r.length;h<p;h++){const f=r[h];if(f.POSITION!==void 0){const m=t.json.accessors[f.POSITION],d=m.min,g=m.max;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),m.normalized){const y=oo(Ut[m.componentType]);c.multiplyScalar(y)}i.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(i)}a.boundingBox=o;const s=new l.Sphere;o.getCenter(s.center),s.radius=o.min.distanceTo(o.max)/2,a.boundingSphere=s}function Tr(a,e,t){const n=e.attributes,o=[];function r(s,i){return t.getDependency("accessor",s).then(function(c){a.setAttribute(i,c)})}for(const s in n){const i=eo[s]||s.toLowerCase();i in a.attributes||o.push(r(n[s],i))}if(e.indices!==void 0&&!a.index){const s=t.getDependency("accessor",e.indices).then(function(i){a.setIndex(i)});o.push(s)}return ct(a,e),Gl(a,e,t),Promise.all(o).then(function(){return e.targets!==void 0?Bl(a,e.targets,t):a})}const Qt=new l.Vector3;function qe(a,e,t,n,o,r){const s=2*Math.PI*o/4,i=Math.max(r-2*o,0),c=Math.PI/4;Qt.copy(e),Qt[n]=0,Qt.normalize();const h=.5*s/(s+i),p=1-Qt.angleTo(a)/c;return Math.sign(Qt[t])===1?p*h:i/(s+i)+h+h*(1-p)}class Rl extends l.BoxGeometry{constructor(e=1,t=1,n=1,o=2,r=.1){if(o=o*2+1,r=Math.min(e/2,t/2,n/2,r),super(1,1,1,o,o,o),o===1)return;const s=this.toNonIndexed();this.index=null,this.attributes.position=s.attributes.position,this.attributes.normal=s.attributes.normal,this.attributes.uv=s.attributes.uv;const i=new l.Vector3,c=new l.Vector3,h=new l.Vector3(e,t,n).divideScalar(2).subScalar(r),p=this.attributes.position.array,f=this.attributes.normal.array,m=this.attributes.uv.array,d=p.length/6,g=new l.Vector3,y=.5/o;for(let v=0,_=0;v<p.length;v+=3,_+=2)switch(i.fromArray(p,v),c.copy(i),c.x-=Math.sign(c.x)*y,c.y-=Math.sign(c.y)*y,c.z-=Math.sign(c.z)*y,c.normalize(),p[v+0]=h.x*Math.sign(i.x)+c.x*r,p[v+1]=h.y*Math.sign(i.y)+c.y*r,p[v+2]=h.z*Math.sign(i.z)+c.z*r,f[v+0]=c.x,f[v+1]=c.y,f[v+2]=c.z,Math.floor(v/d)){case 0:g.set(1,0,0),m[_+0]=qe(g,c,"z","y",r,n),m[_+1]=1-qe(g,c,"y","z",r,t);break;case 1:g.set(-1,0,0),m[_+0]=1-qe(g,c,"z","y",r,n),m[_+1]=1-qe(g,c,"y","z",r,t);break;case 2:g.set(0,1,0),m[_+0]=1-qe(g,c,"x","z",r,e),m[_+1]=qe(g,c,"z","x",r,n);break;case 3:g.set(0,-1,0),m[_+0]=1-qe(g,c,"x","z",r,e),m[_+1]=1-qe(g,c,"z","x",r,n);break;case 4:g.set(0,0,1),m[_+0]=1-qe(g,c,"x","y",r,e),m[_+1]=1-qe(g,c,"y","x",r,t);break;case 5:g.set(0,0,-1),m[_+0]=qe(g,c,"x","y",r,e),m[_+1]=1-qe(g,c,"y","x",r,t);break}}}class Ir extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:o=8,bevelThickness:r=10,font:s,height:i=50,size:c=100,lineHeight:h=1,letterSpacing:p=0,...f}=t;if(s===void 0)super();else{const m=s.generateShapes(e,c,{lineHeight:h,letterSpacing:p});super(m,{...f,bevelEnabled:n,bevelSize:o,bevelThickness:r,depth:i})}this.type="TextGeometry"}}const jl={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
493
493
  varying vec2 vUv;
494
494
 
495
495
  void main() {
@@ -559,7 +559,7 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
559
559
  `,f=function(w,S,x){S=S||1024;let D=w.pos,z=-1,G=0,X="",E=String.fromCharCode.apply(null,new Uint16Array(w.subarray(D,D+128)));for(;0>(z=E.indexOf(p))&&G<S&&D<w.byteLength;)X+=E,G+=E.length,D+=128,E+=String.fromCharCode.apply(null,new Uint16Array(w.subarray(D,D+128)));return-1<z?(w.pos+=G+z+1,X+E.slice(0,z)):!1},m=function(w){const S=/^#\?(\S+)/,x=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,I=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,D=/^\s*FORMAT=(\S+)\s*$/,z=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,G={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let X,E;for((w.pos>=w.byteLength||!(X=f(w)))&&s(1,"no header found"),(E=X.match(S))||s(3,"bad initial token"),G.valid|=1,G.programtype=E[1],G.string+=X+`
560
560
  `;X=f(w),X!==!1;){if(G.string+=X+`
561
561
  `,X.charAt(0)==="#"){G.comments+=X+`
562
- `;continue}if((E=X.match(x))&&(G.gamma=parseFloat(E[1])),(E=X.match(I))&&(G.exposure=parseFloat(E[1])),(E=X.match(D))&&(G.valid|=2,G.format=E[1]),(E=X.match(z))&&(G.valid|=4,G.height=parseInt(E[1],10),G.width=parseInt(E[2],10)),G.valid&2&&G.valid&4)break}return G.valid&2||s(3,"missing format specifier"),G.valid&4||s(3,"missing image size specifier"),G},d=function(w,S,x){const I=S;if(I<8||I>32767||w[0]!==2||w[1]!==2||w[2]&128)return new Uint8Array(w);I!==(w[2]<<8|w[3])&&s(3,"wrong scanline width");const D=new Uint8Array(4*S*x);D.length||s(4,"unable to allocate buffer space");let z=0,G=0;const X=4*I,E=new Uint8Array(4),te=new Uint8Array(X);let q=x;for(;q>0&&G<w.byteLength;){G+4>w.byteLength&&s(1),E[0]=w[G++],E[1]=w[G++],E[2]=w[G++],E[3]=w[G++],(E[0]!=2||E[1]!=2||(E[2]<<8|E[3])!=I)&&s(3,"bad rgbe scanline format");let oe=0,ne;for(;oe<X&&G<w.byteLength;){ne=w[G++];const le=ne>128;if(le&&(ne-=128),(ne===0||oe+ne>X)&&s(3,"bad scanline data"),le){const de=w[G++];for(let k=0;k<ne;k++)te[oe++]=de}else te.set(w.subarray(G,G+ne),oe),oe+=ne,G+=ne}const ce=I;for(let le=0;le<ce;le++){let de=0;D[z]=te[le+de],de+=I,D[z+1]=te[le+de],de+=I,D[z+2]=te[le+de],de+=I,D[z+3]=te[le+de],z+=4}q--}return D},g=function(w,S,x,I){const D=w[S+3],z=Math.pow(2,D-128)/255;x[I+0]=w[S+0]*z,x[I+1]=w[S+1]*z,x[I+2]=w[S+2]*z,x[I+3]=1},y=function(w,S,x,I){const D=w[S+3],z=Math.pow(2,D-128)/255;x[I+0]=l.DataUtils.toHalfFloat(Math.min(w[S+0]*z,65504)),x[I+1]=l.DataUtils.toHalfFloat(Math.min(w[S+1]*z,65504)),x[I+2]=l.DataUtils.toHalfFloat(Math.min(w[S+2]*z,65504)),x[I+3]=l.DataUtils.toHalfFloat(1)},v=new Uint8Array(e);v.pos=0;const _=m(v),A=_.width,b=_.height,C=d(v.subarray(v.pos),A,b);let L,M,P;switch(this.type){case l.FloatType:P=C.length/4;const w=new Float32Array(P*4);for(let x=0;x<P;x++)g(C,x*4,w,x*4);L=w,M=l.FloatType;break;case l.HalfFloatType:P=C.length/4;const S=new Uint16Array(P*4);for(let x=0;x<P;x++)y(C,x*4,S,x*4);L=S,M=l.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:A,height:b,data:L,header:_.string,gamma:_.gamma,exposure:_.exposure,type:M}}setDataType(e){return this.type=e,this}load(e,t,n,o){function r(s,i){switch(s.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in s?s.colorSpace="srgb-linear":s.encoding=3e3,s.minFilter=l.LinearFilter,s.magFilter=l.LinearFilter,s.generateMipmaps=!1,s.flipY=!0;break}t&&t(s,i)}return super.load(e,r,n,o)}}const pc="srgb";class Jt extends l.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,o){const r=this,s=new l.FileLoader(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(i){try{t(r.parse(i))}catch(c){o?o(c):console.error(c),r.manager.itemError(e)}},n,o)}parse(e){const t=this;function n(k,V){if(k.nodeType!==1)return;const U=C(k);let B=!1,R=null;switch(k.nodeName){case"svg":V=g(k,V);break;case"style":r(k);break;case"g":V=g(k,V);break;case"path":V=g(k,V),k.hasAttribute("d")&&(R=o(k));break;case"rect":V=g(k,V),R=c(k);break;case"polygon":V=g(k,V),R=h(k);break;case"polyline":V=g(k,V),R=p(k);break;case"circle":V=g(k,V),R=f(k);break;case"ellipse":V=g(k,V),R=m(k);break;case"line":V=g(k,V),R=d(k);break;case"defs":B=!0;break;case"use":V=g(k,V);const N=(k.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),K=k.viewportElement.getElementById(N);K?n(K,V):console.warn("SVGLoader: 'use node' references non-existent node id: "+N);break}R&&(V.fill!==void 0&&V.fill!=="none"&&R.color.setStyle(V.fill,pc),M(R,ce),D.push(R),R.userData={node:k,style:V});const T=k.childNodes;for(let O=0;O<T.length;O++){const N=T[O];B&&N.nodeName!=="style"&&N.nodeName!=="defs"||n(N,V)}U&&(G.pop(),G.length>0?ce.copy(G[G.length-1]):ce.identity())}function o(k){const V=new l.ShapePath,U=new l.Vector2,B=new l.Vector2,R=new l.Vector2;let T=!0,O=!1;const N=k.getAttribute("d");if(N===""||N==="none")return null;const K=N.match(/[a-df-z][^a-df-z]*/gi);for(let W=0,Y=K.length;W<Y;W++){const Q=K[W],re=Q.charAt(0),se=Q.slice(1).trim();T===!0&&(O=!0,T=!1);let j;switch(re){case"M":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x=j[F+0],U.y=j[F+1],B.x=U.x,B.y=U.y,F===0?V.moveTo(U.x,U.y):V.lineTo(U.x,U.y),F===0&&R.copy(U);break;case"H":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.x=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"V":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.y=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"L":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x=j[F+0],U.y=j[F+1],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"C":j=v(se);for(let F=0,ie=j.length;F<ie;F+=6)V.bezierCurveTo(j[F+0],j[F+1],j[F+2],j[F+3],j[F+4],j[F+5]),B.x=j[F+2],B.y=j[F+3],U.x=j[F+4],U.y=j[F+5],F===0&&O===!0&&R.copy(U);break;case"S":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.bezierCurveTo(y(U.x,B.x),y(U.y,B.y),j[F+0],j[F+1],j[F+2],j[F+3]),B.x=j[F+0],B.y=j[F+1],U.x=j[F+2],U.y=j[F+3],F===0&&O===!0&&R.copy(U);break;case"Q":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.quadraticCurveTo(j[F+0],j[F+1],j[F+2],j[F+3]),B.x=j[F+0],B.y=j[F+1],U.x=j[F+2],U.y=j[F+3],F===0&&O===!0&&R.copy(U);break;case"T":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2){const he=y(U.x,B.x),_e=y(U.y,B.y);V.quadraticCurveTo(he,_e,j[F+0],j[F+1]),B.x=he,B.y=_e,U.x=j[F+0],U.y=j[F+1],F===0&&O===!0&&R.copy(U)}break;case"A":j=v(se,[3,4],7);for(let F=0,ie=j.length;F<ie;F+=7){if(j[F+5]==U.x&&j[F+6]==U.y)continue;const he=U.clone();U.x=j[F+5],U.y=j[F+6],B.x=U.x,B.y=U.y,s(V,j[F],j[F+1],j[F+2],j[F+3],j[F+4],he,U),F===0&&O===!0&&R.copy(U)}break;case"m":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x+=j[F+0],U.y+=j[F+1],B.x=U.x,B.y=U.y,F===0?V.moveTo(U.x,U.y):V.lineTo(U.x,U.y),F===0&&R.copy(U);break;case"h":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.x+=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"v":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.y+=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"l":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x+=j[F+0],U.y+=j[F+1],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"c":j=v(se);for(let F=0,ie=j.length;F<ie;F+=6)V.bezierCurveTo(U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3],U.x+j[F+4],U.y+j[F+5]),B.x=U.x+j[F+2],B.y=U.y+j[F+3],U.x+=j[F+4],U.y+=j[F+5],F===0&&O===!0&&R.copy(U);break;case"s":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.bezierCurveTo(y(U.x,B.x),y(U.y,B.y),U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3]),B.x=U.x+j[F+0],B.y=U.y+j[F+1],U.x+=j[F+2],U.y+=j[F+3],F===0&&O===!0&&R.copy(U);break;case"q":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.quadraticCurveTo(U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3]),B.x=U.x+j[F+0],B.y=U.y+j[F+1],U.x+=j[F+2],U.y+=j[F+3],F===0&&O===!0&&R.copy(U);break;case"t":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2){const he=y(U.x,B.x),_e=y(U.y,B.y);V.quadraticCurveTo(he,_e,U.x+j[F+0],U.y+j[F+1]),B.x=he,B.y=_e,U.x=U.x+j[F+0],U.y=U.y+j[F+1],F===0&&O===!0&&R.copy(U)}break;case"a":j=v(se,[3,4],7);for(let F=0,ie=j.length;F<ie;F+=7){if(j[F+5]==0&&j[F+6]==0)continue;const he=U.clone();U.x+=j[F+5],U.y+=j[F+6],B.x=U.x,B.y=U.y,s(V,j[F],j[F+1],j[F+2],j[F+3],j[F+4],he,U),F===0&&O===!0&&R.copy(U)}break;case"Z":case"z":V.currentPath.autoClose=!0,V.currentPath.curves.length>0&&(U.copy(R),V.currentPath.currentPoint.copy(U),T=!0);break;default:console.warn(Q)}O=!1}return V}function r(k){if(!(!k.sheet||!k.sheet.cssRules||!k.sheet.cssRules.length))for(let V=0;V<k.sheet.cssRules.length;V++){const U=k.sheet.cssRules[V];if(U.type!==1)continue;const B=U.selectorText.split(/,/gm).filter(Boolean).map(R=>R.trim());for(let R=0;R<B.length;R++){const T=Object.fromEntries(Object.entries(U.style).filter(([,O])=>O!==""));z[B[R]]=Object.assign(z[B[R]]||{},T)}}}function s(k,V,U,B,R,T,O,N){if(V==0||U==0){k.lineTo(N.x,N.y);return}B=B*Math.PI/180,V=Math.abs(V),U=Math.abs(U);const K=(O.x-N.x)/2,W=(O.y-N.y)/2,Y=Math.cos(B)*K+Math.sin(B)*W,Q=-Math.sin(B)*K+Math.cos(B)*W;let re=V*V,se=U*U;const j=Y*Y,F=Q*Q,ie=j/re+F/se;if(ie>1){const et=Math.sqrt(ie);V=et*V,U=et*U,re=V*V,se=U*U}const he=re*F+se*j,_e=(re*se-he)/he;let Le=Math.sqrt(Math.max(0,_e));R===T&&(Le=-Le);const Pe=Le*V*Q/U,Je=-Le*U*Y/V,wt=Math.cos(B)*Pe-Math.sin(B)*Je+(O.x+N.x)/2,It=Math.sin(B)*Pe+Math.cos(B)*Je+(O.y+N.y)/2,it=i(1,0,(Y-Pe)/V,(Q-Je)/U),Ee=i((Y-Pe)/V,(Q-Je)/U,(-Y-Pe)/V,(-Q-Je)/U)%(Math.PI*2);k.currentPath.absellipse(wt,It,V,U,it,it+Ee,T===0,B)}function i(k,V,U,B){const R=k*U+V*B,T=Math.sqrt(k*k+V*V)*Math.sqrt(U*U+B*B);let O=Math.acos(Math.max(-1,Math.min(1,R/T)));return k*B-V*U<0&&(O=-O),O}function c(k){const V=b(k.getAttribute("x")||0),U=b(k.getAttribute("y")||0),B=b(k.getAttribute("rx")||k.getAttribute("ry")||0),R=b(k.getAttribute("ry")||k.getAttribute("rx")||0),T=b(k.getAttribute("width")),O=b(k.getAttribute("height")),N=1-.551915024494,K=new l.ShapePath;return K.moveTo(V+B,U),K.lineTo(V+T-B,U),(B!==0||R!==0)&&K.bezierCurveTo(V+T-B*N,U,V+T,U+R*N,V+T,U+R),K.lineTo(V+T,U+O-R),(B!==0||R!==0)&&K.bezierCurveTo(V+T,U+O-R*N,V+T-B*N,U+O,V+T-B,U+O),K.lineTo(V+B,U+O),(B!==0||R!==0)&&K.bezierCurveTo(V+B*N,U+O,V,U+O-R*N,V,U+O-R),K.lineTo(V,U+R),(B!==0||R!==0)&&K.bezierCurveTo(V,U+R*N,V+B*N,U,V+B,U),K}function h(k){function V(T,O,N){const K=b(O),W=b(N);R===0?B.moveTo(K,W):B.lineTo(K,W),R++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let R=0;return k.getAttribute("points").replace(U,V),B.currentPath.autoClose=!0,B}function p(k){function V(T,O,N){const K=b(O),W=b(N);R===0?B.moveTo(K,W):B.lineTo(K,W),R++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let R=0;return k.getAttribute("points").replace(U,V),B.currentPath.autoClose=!1,B}function f(k){const V=b(k.getAttribute("cx")||0),U=b(k.getAttribute("cy")||0),B=b(k.getAttribute("r")||0),R=new l.Path;R.absarc(V,U,B,0,Math.PI*2);const T=new l.ShapePath;return T.subPaths.push(R),T}function m(k){const V=b(k.getAttribute("cx")||0),U=b(k.getAttribute("cy")||0),B=b(k.getAttribute("rx")||0),R=b(k.getAttribute("ry")||0),T=new l.Path;T.absellipse(V,U,B,R,0,Math.PI*2);const O=new l.ShapePath;return O.subPaths.push(T),O}function d(k){const V=b(k.getAttribute("x1")||0),U=b(k.getAttribute("y1")||0),B=b(k.getAttribute("x2")||0),R=b(k.getAttribute("y2")||0),T=new l.ShapePath;return T.moveTo(V,U),T.lineTo(B,R),T.currentPath.autoClose=!1,T}function g(k,V){V=Object.assign({},V);let U={};if(k.hasAttribute("class")){const O=k.getAttribute("class").split(/\s/).filter(Boolean).map(N=>N.trim());for(let N=0;N<O.length;N++)U=Object.assign(U,z["."+O[N]])}k.hasAttribute("id")&&(U=Object.assign(U,z["#"+k.getAttribute("id")]));function B(O,N,K){K===void 0&&(K=function(Y){return Y.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),Y}),k.hasAttribute(O)&&(V[N]=K(k.getAttribute(O))),U[O]&&(V[N]=K(U[O])),k.style&&k.style[O]!==""&&(V[N]=K(k.style[O]))}function R(O){return Math.max(0,Math.min(1,b(O)))}function T(O){return Math.max(0,b(O))}return B("fill","fill"),B("fill-opacity","fillOpacity",R),B("fill-rule","fillRule"),B("opacity","opacity",R),B("stroke","stroke"),B("stroke-opacity","strokeOpacity",R),B("stroke-width","strokeWidth",T),B("stroke-linejoin","strokeLineJoin"),B("stroke-linecap","strokeLineCap"),B("stroke-miterlimit","strokeMiterLimit",T),B("visibility","visibility"),V}function y(k,V){return k-(V-k)}function v(k,V,U){if(typeof k!="string")throw new TypeError("Invalid input: "+typeof k);const B={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},R=0,T=1,O=2,N=3;let K=R,W=!0,Y="",Q="";const re=[];function se(he,_e,Le){const Pe=new SyntaxError('Unexpected character "'+he+'" at index '+_e+".");throw Pe.partial=Le,Pe}function j(){Y!==""&&(Q===""?re.push(Number(Y)):re.push(Number(Y)*Math.pow(10,Number(Q)))),Y="",Q=""}let F;const ie=k.length;for(let he=0;he<ie;he++){if(F=k[he],Array.isArray(V)&&V.includes(re.length%U)&&B.FLAGS.test(F)){K=T,Y=F,j();continue}if(K===R){if(B.WHITESPACE.test(F))continue;if(B.DIGIT.test(F)||B.SIGN.test(F)){K=T,Y=F;continue}if(B.POINT.test(F)){K=O,Y=F;continue}B.COMMA.test(F)&&(W&&se(F,he,re),W=!0)}if(K===T){if(B.DIGIT.test(F)){Y+=F;continue}if(B.POINT.test(F)){Y+=F,K=O;continue}if(B.EXP.test(F)){K=N;continue}B.SIGN.test(F)&&Y.length===1&&B.SIGN.test(Y[0])&&se(F,he,re)}if(K===O){if(B.DIGIT.test(F)){Y+=F;continue}if(B.EXP.test(F)){K=N;continue}B.POINT.test(F)&&Y[Y.length-1]==="."&&se(F,he,re)}if(K===N){if(B.DIGIT.test(F)){Q+=F;continue}if(B.SIGN.test(F)){if(Q===""){Q+=F;continue}Q.length===1&&B.SIGN.test(Q)&&se(F,he,re)}}B.WHITESPACE.test(F)?(j(),K=R,W=!1):B.COMMA.test(F)?(j(),K=R,W=!0):B.SIGN.test(F)?(j(),K=T,Y=F):B.POINT.test(F)?(j(),K=O,Y=F):se(F,he,re)}return j(),re}const _=["mm","cm","in","pt","pc","px"],A={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function b(k){let V="px";if(typeof k=="string"||k instanceof String)for(let B=0,R=_.length;B<R;B++){const T=_[B];if(k.endsWith(T)){V=T,k=k.substring(0,k.length-T.length);break}}let U;return V==="px"&&t.defaultUnit!=="px"?U=A.in[t.defaultUnit]/t.defaultDPI:(U=A[V][t.defaultUnit],U<0&&(U=A[V].in*t.defaultDPI)),U*parseFloat(k)}function C(k){if(!(k.hasAttribute("transform")||k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))))return null;const V=L(k);return G.length>0&&V.premultiply(G[G.length-1]),ce.copy(V),G.push(V),V}function L(k){const V=new l.Matrix3,U=X;if(k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))){const B=b(k.getAttribute("x")),R=b(k.getAttribute("y"));V.translate(B,R)}if(k.hasAttribute("transform")){const B=k.getAttribute("transform").split(")");for(let R=B.length-1;R>=0;R--){const T=B[R].trim();if(T==="")continue;const O=T.indexOf("("),N=T.length;if(O>0&&O<N){const K=T.slice(0,O),W=v(T.slice(O+1));switch(U.identity(),K){case"translate":if(W.length>=1){const Y=W[0];let Q=0;W.length>=2&&(Q=W[1]),U.translate(Y,Q)}break;case"rotate":if(W.length>=1){let Y=0,Q=0,re=0;Y=W[0]*Math.PI/180,W.length>=3&&(Q=W[1],re=W[2]),E.makeTranslation(-Q,-re),te.makeRotation(Y),q.multiplyMatrices(te,E),E.makeTranslation(Q,re),U.multiplyMatrices(E,q)}break;case"scale":if(W.length>=1){const Y=W[0];let Q=Y;W.length>=2&&(Q=W[1]),U.scale(Y,Q)}break;case"skewX":W.length===1&&U.set(1,Math.tan(W[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":W.length===1&&U.set(1,0,0,Math.tan(W[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":W.length===6&&U.set(W[0],W[2],W[4],W[1],W[3],W[5],0,0,1);break}}V.premultiply(U)}}return V}function M(k,V){function U(O){ne.set(O.x,O.y,1).applyMatrix3(V),O.set(ne.x,ne.y)}function B(O){const N=O.xRadius,K=O.yRadius,W=Math.cos(O.aRotation),Y=Math.sin(O.aRotation),Q=new l.Vector3(N*W,N*Y,0),re=new l.Vector3(-K*Y,K*W,0),se=Q.applyMatrix3(V),j=re.applyMatrix3(V),F=X.set(se.x,j.x,0,se.y,j.y,0,0,0,1),ie=E.copy(F).invert(),Le=te.copy(ie).transpose().multiply(ie).elements,Pe=I(Le[0],Le[1],Le[4]),Je=Math.sqrt(Pe.rt1),wt=Math.sqrt(Pe.rt2);if(O.xRadius=1/Je,O.yRadius=1/wt,O.aRotation=Math.atan2(Pe.sn,Pe.cs),!((O.aEndAngle-O.aStartAngle)%(2*Math.PI)<Number.EPSILON)){const it=E.set(Je,0,0,0,wt,0,0,0,1),Ee=te.set(Pe.cs,Pe.sn,0,-Pe.sn,Pe.cs,0,0,0,1),et=it.multiply(Ee).multiply(F),sn=kn=>{const{x:Ro,y:Bn}=new l.Vector3(Math.cos(kn),Math.sin(kn),0).applyMatrix3(et);return Math.atan2(Bn,Ro)};O.aStartAngle=sn(O.aStartAngle),O.aEndAngle=sn(O.aEndAngle),P(V)&&(O.aClockwise=!O.aClockwise)}}function R(O){const N=S(V),K=x(V);O.xRadius*=N,O.yRadius*=K;const W=N>Number.EPSILON?Math.atan2(V.elements[1],V.elements[0]):Math.atan2(-V.elements[3],V.elements[4]);O.aRotation+=W,P(V)&&(O.aStartAngle*=-1,O.aEndAngle*=-1,O.aClockwise=!O.aClockwise)}const T=k.subPaths;for(let O=0,N=T.length;O<N;O++){const W=T[O].curves;for(let Y=0;Y<W.length;Y++){const Q=W[Y];Q.isLineCurve?(U(Q.v1),U(Q.v2)):Q.isCubicBezierCurve?(U(Q.v0),U(Q.v1),U(Q.v2),U(Q.v3)):Q.isQuadraticBezierCurve?(U(Q.v0),U(Q.v1),U(Q.v2)):Q.isEllipseCurve&&(oe.set(Q.aX,Q.aY),U(oe),Q.aX=oe.x,Q.aY=oe.y,w(V)?B(Q):R(Q))}}}function P(k){const V=k.elements;return V[0]*V[4]-V[1]*V[3]<0}function w(k){const V=k.elements,U=V[0]*V[3]+V[1]*V[4];if(U===0)return!1;const B=S(k),R=x(k);return Math.abs(U/(B*R))>Number.EPSILON}function S(k){const V=k.elements;return Math.sqrt(V[0]*V[0]+V[1]*V[1])}function x(k){const V=k.elements;return Math.sqrt(V[3]*V[3]+V[4]*V[4])}function I(k,V,U){let B,R,T,O,N;const K=k+U,W=k-U,Y=Math.sqrt(W*W+4*V*V);return K>0?(B=.5*(K+Y),N=1/B,R=k*N*U-V*N*V):K<0?R=.5*(K-Y):(B=.5*Y,R=-.5*Y),W>0?T=W+Y:T=W-Y,Math.abs(T)>2*Math.abs(V)?(N=-2*V/T,O=1/Math.sqrt(1+N*N),T=N*O):Math.abs(V)===0?(T=1,O=0):(N=-.5*T/V,T=1/Math.sqrt(1+N*N),O=N*T),W>0&&(N=T,T=-O,O=N),{rt1:B,rt2:R,cs:T,sn:O}}const D=[],z={},G=[],X=new l.Matrix3,E=new l.Matrix3,te=new l.Matrix3,q=new l.Matrix3,oe=new l.Vector2,ne=new l.Vector3,ce=new l.Matrix3,le=new DOMParser().parseFromString(e,"image/svg+xml");return n(le.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:D,xml:le.documentElement}}static createShapes(e){const n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},o={loc:n.ORIGIN,t:0};function r(y,v,_,A){const b=y.x,C=v.x,L=_.x,M=A.x,P=y.y,w=v.y,S=_.y,x=A.y,I=(M-L)*(P-S)-(x-S)*(b-L),D=(C-b)*(P-S)-(w-P)*(b-L),z=(x-S)*(C-b)-(M-L)*(w-P),G=I/z,X=D/z;if(z===0&&I!==0||G<=0||G>=1||X<0||X>1)return null;if(I===0&&z===0){for(let E=0;E<2;E++)if(s(E===0?_:A,y,v),o.loc==n.ORIGIN){const te=E===0?_:A;return{x:te.x,y:te.y,t:o.t}}else if(o.loc==n.BETWEEN){const te=+(b+o.t*(C-b)).toPrecision(10),q=+(P+o.t*(w-P)).toPrecision(10);return{x:te,y:q,t:o.t}}return null}else{for(let q=0;q<2;q++)if(s(q===0?_:A,y,v),o.loc==n.ORIGIN){const oe=q===0?_:A;return{x:oe.x,y:oe.y,t:o.t}}const E=+(b+G*(C-b)).toPrecision(10),te=+(P+G*(w-P)).toPrecision(10);return{x:E,y:te,t:G}}}function s(y,v,_){const A=_.x-v.x,b=_.y-v.y,C=y.x-v.x,L=y.y-v.y,M=A*L-C*b;if(y.x===v.x&&y.y===v.y){o.loc=n.ORIGIN,o.t=0;return}if(y.x===_.x&&y.y===_.y){o.loc=n.DESTINATION,o.t=1;return}if(M<-Number.EPSILON){o.loc=n.LEFT;return}if(M>Number.EPSILON){o.loc=n.RIGHT;return}if(A*C<0||b*L<0){o.loc=n.BEHIND;return}if(Math.sqrt(A*A+b*b)<Math.sqrt(C*C+L*L)){o.loc=n.BEYOND;return}let P;A!==0?P=C/A:P=L/b,o.loc=n.BETWEEN,o.t=P}function i(y,v){const _=[],A=[];for(let b=1;b<y.length;b++){const C=y[b-1],L=y[b];for(let M=1;M<v.length;M++){const P=v[M-1],w=v[M],S=r(C,L,P,w);S!==null&&_.find(x=>x.t<=S.t+Number.EPSILON&&x.t>=S.t-Number.EPSILON)===void 0&&(_.push(S),A.push(new l.Vector2(S.x,S.y)))}}return A}function c(y,v,_){const A=new l.Vector2;v.getCenter(A);const b=[];return _.forEach(C=>{C.boundingBox.containsPoint(A)&&i(y,C.points).forEach(M=>{b.push({identifier:C.identifier,isCW:C.isCW,point:M})})}),b.sort((C,L)=>C.point.x-L.point.x),b}function h(y,v,_,A,b){(b==null||b==="")&&(b="nonzero");const C=new l.Vector2;y.boundingBox.getCenter(C);const L=[new l.Vector2(_,C.y),new l.Vector2(A,C.y)],M=c(L,y.boundingBox,v);M.sort((D,z)=>D.point.x-z.point.x);const P=[],w=[];M.forEach(D=>{D.identifier===y.identifier?P.push(D):w.push(D)});const S=P[0].point.x,x=[];let I=0;for(;I<w.length&&w[I].point.x<S;)x.length>0&&x[x.length-1]===w[I].identifier?x.pop():x.push(w[I].identifier),I++;if(x.push(y.identifier),b==="evenodd"){const D=x.length%2===0,z=x[x.length-2];return{identifier:y.identifier,isHole:D,for:z}}else if(b==="nonzero"){let D=!0,z=null,G=null;for(let X=0;X<x.length;X++){const E=x[X];D?(G=v[E].isCW,D=!1,z=E):G!==v[E].isCW&&(G=v[E].isCW,D=!0)}return{identifier:y.identifier,isHole:D,for:z}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let p=999999999,f=-999999999,m=e.subPaths.map(y=>{const v=y.getPoints();let _=-999999999,A=999999999,b=-999999999,C=999999999;for(let L=0;L<v.length;L++){const M=v[L];M.y>_&&(_=M.y),M.y<A&&(A=M.y),M.x>b&&(b=M.x),M.x<C&&(C=M.x)}return f<=b&&(f=b+1),p>=C&&(p=C-1),{curves:y.curves,points:v,isCW:l.ShapeUtils.isClockWise(v),identifier:-1,boundingBox:new l.Box2(new l.Vector2(C,A),new l.Vector2(b,_))}});m=m.filter(y=>y.points.length>1);for(let y=0;y<m.length;y++)m[y].identifier=y;const d=m.map(y=>h(y,m,p,f,e.userData?e.userData.style.fillRule:void 0)),g=[];return m.forEach(y=>{if(!d[y.identifier].isHole){const _=new l.Shape;_.curves=y.curves,d.filter(b=>b.isHole&&b.for===y.identifier).forEach(b=>{const C=m[b.identifier],L=new l.Path;L.curves=C.curves,_.holes.push(L)}),g.push(_)}}),g}static getStrokeStyle(e,t,n,o,r){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",o=o!==void 0?o:"butt",r=r!==void 0?r:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:o,strokeMiterLimit:r}}static pointsToStroke(e,t,n,o){const r=[],s=[],i=[];if(Jt.pointsToStrokeWithBuffers(e,t,n,o,r,s,i)===0)return null;const c=new l.BufferGeometry;return c.setAttribute("position",new l.Float32BufferAttribute(r,3)),c.setAttribute("normal",new l.Float32BufferAttribute(s,3)),c.setAttribute("uv",new l.Float32BufferAttribute(i,2)),c}static pointsToStrokeWithBuffers(e,t,n,o,r,s,i,c){const h=new l.Vector2,p=new l.Vector2,f=new l.Vector2,m=new l.Vector2,d=new l.Vector2,g=new l.Vector2,y=new l.Vector2,v=new l.Vector2,_=new l.Vector2,A=new l.Vector2,b=new l.Vector2,C=new l.Vector2,L=new l.Vector2,M=new l.Vector2,P=new l.Vector2,w=new l.Vector2,S=new l.Vector2;n=n!==void 0?n:12,o=o!==void 0?o:.001,c=c!==void 0?c:0,e=W(e);const x=e.length;if(x<2)return 0;const I=e[0].equals(e[x-1]);let D,z=e[0],G;const X=t.strokeWidth/2,E=1/(x-1);let te=0,q,oe,ne,ce,le=!1,de=0,k=c*3,V=c*2;U(e[0],e[1],h).multiplyScalar(X),v.copy(e[0]).sub(h),_.copy(e[0]).add(h),A.copy(v),b.copy(_);for(let Y=1;Y<x;Y++){D=e[Y],Y===x-1?I?G=e[1]:G=void 0:G=e[Y+1];const Q=h;if(U(z,D,Q),f.copy(Q).multiplyScalar(X),C.copy(D).sub(f),L.copy(D).add(f),q=te+E,oe=!1,G!==void 0){U(D,G,p),f.copy(p).multiplyScalar(X),M.copy(D).sub(f),P.copy(D).add(f),ne=!0,f.subVectors(G,z),Q.dot(f)<0&&(ne=!1),Y===1&&(le=ne),f.subVectors(G,D),f.normalize();const re=Math.abs(Q.dot(f));if(re>Number.EPSILON){const se=X/re;f.multiplyScalar(-se),m.subVectors(D,z),d.copy(m).setLength(se).add(f),w.copy(d).negate();const j=d.length(),F=m.length();m.divideScalar(F),g.subVectors(G,D);const ie=g.length();switch(g.divideScalar(ie),m.dot(w)<F&&g.dot(w)<ie&&(oe=!0),S.copy(d).add(D),w.add(D),ce=!1,oe?ne?(P.copy(w),L.copy(w)):(M.copy(w),C.copy(w)):T(),t.strokeLineJoin){case"bevel":O(ne,oe,q);break;case"round":N(ne,oe),ne?R(D,C,M,q,0):R(D,P,L,q,1);break;case"miter":case"miter-clip":default:const he=X*t.strokeMiterLimit/j;if(he<1)if(t.strokeLineJoin!=="miter-clip"){O(ne,oe,q);break}else N(ne,oe),ne?(g.subVectors(S,C).multiplyScalar(he).add(C),y.subVectors(S,M).multiplyScalar(he).add(M),B(C,q,0),B(g,q,0),B(D,q,.5),B(D,q,.5),B(g,q,0),B(y,q,0),B(D,q,.5),B(y,q,0),B(M,q,0)):(g.subVectors(S,L).multiplyScalar(he).add(L),y.subVectors(S,P).multiplyScalar(he).add(P),B(L,q,1),B(g,q,1),B(D,q,.5),B(D,q,.5),B(g,q,1),B(y,q,1),B(D,q,.5),B(y,q,1),B(P,q,1));else oe?(ne?(B(_,te,1),B(v,te,0),B(S,q,0),B(_,te,1),B(S,q,0),B(w,q,1)):(B(_,te,1),B(v,te,0),B(S,q,1),B(v,te,0),B(w,q,0),B(S,q,1)),ne?M.copy(S):P.copy(S)):ne?(B(C,q,0),B(S,q,0),B(D,q,.5),B(D,q,.5),B(S,q,0),B(M,q,0)):(B(L,q,1),B(S,q,1),B(D,q,.5),B(D,q,.5),B(S,q,1),B(P,q,1)),ce=!0;break}}else T()}else T();!I&&Y===x-1&&K(e[0],A,b,ne,!0,te),te=q,z=D,v.copy(M),_.copy(P)}if(!I)K(D,C,L,ne,!1,q);else if(oe&&r){let Y=S,Q=w;le!==ne&&(Y=w,Q=S),ne?(ce||le)&&(Q.toArray(r,0*3),Q.toArray(r,3*3),ce&&Y.toArray(r,1*3)):(ce||!le)&&(Q.toArray(r,1*3),Q.toArray(r,3*3),ce&&Y.toArray(r,0*3))}return de;function U(Y,Q,re){return re.subVectors(Q,Y),re.set(-re.y,re.x).normalize()}function B(Y,Q,re){r&&(r[k]=Y.x,r[k+1]=Y.y,r[k+2]=0,s&&(s[k]=0,s[k+1]=0,s[k+2]=1),k+=3,i&&(i[V]=Q,i[V+1]=re,V+=2)),de+=3}function R(Y,Q,re,se,j){h.copy(Q).sub(Y).normalize(),p.copy(re).sub(Y).normalize();let F=Math.PI;const ie=h.dot(p);Math.abs(ie)<1&&(F=Math.abs(Math.acos(ie))),F/=n,f.copy(Q);for(let he=0,_e=n-1;he<_e;he++)m.copy(f).rotateAround(Y,F),B(f,se,j),B(m,se,j),B(Y,se,.5),f.copy(m);B(m,se,j),B(re,se,j),B(Y,se,.5)}function T(){B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(L,q,1)}function O(Y,Q,re){Q?Y?(B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(w,q,1),B(C,re,0),B(M,re,0),B(w,re,.5)):(B(_,te,1),B(v,te,0),B(L,q,1),B(v,te,0),B(w,q,0),B(L,q,1),B(L,re,1),B(w,re,0),B(P,re,1)):Y?(B(C,re,0),B(M,re,0),B(D,re,.5)):(B(L,re,1),B(P,re,0),B(D,re,.5))}function N(Y,Q){Q&&(Y?(B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(w,q,1),B(C,te,0),B(D,q,.5),B(w,q,1),B(D,q,.5),B(M,te,0),B(w,q,1)):(B(_,te,1),B(v,te,0),B(L,q,1),B(v,te,0),B(w,q,0),B(L,q,1),B(L,te,1),B(w,q,0),B(D,q,.5),B(D,q,.5),B(w,q,0),B(P,te,1)))}function K(Y,Q,re,se,j,F){switch(t.strokeLineCap){case"round":j?R(Y,re,Q,F,.5):R(Y,Q,re,F,.5);break;case"square":if(j)h.subVectors(Q,Y),p.set(h.y,-h.x),f.addVectors(h,p).add(Y),m.subVectors(p,h).add(Y),se?(f.toArray(r,1*3),m.toArray(r,0*3),m.toArray(r,3*3)):(f.toArray(r,1*3),i[3*2+1]===1?m.toArray(r,3*3):f.toArray(r,3*3),m.toArray(r,0*3));else{h.subVectors(re,Y),p.set(h.y,-h.x),f.addVectors(h,p).add(Y),m.subVectors(p,h).add(Y);const ie=r.length;se?(f.toArray(r,ie-1*3),m.toArray(r,ie-2*3),m.toArray(r,ie-4*3)):(m.toArray(r,ie-2*3),f.toArray(r,ie-1*3),m.toArray(r,ie-4*3))}break}}function W(Y){let Q=!1;for(let se=1,j=Y.length-1;se<j;se++)if(Y[se].distanceTo(Y[se+1])<o){Q=!0;break}if(!Q)return Y;const re=[];re.push(Y[0]);for(let se=1,j=Y.length-1;se<j;se++)Y[se].distanceTo(Y[se+1])>=o&&re.push(Y[se]);return re.push(Y[Y.length-1]),re}}}const lo=new WeakMap;class mc extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,o){const r=new l.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,s=>{const i={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(s,i).then(t).catch(o)},n,o)}decodeDracoFile(e,t,n,o){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:o||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const h=t.attributeTypes[c];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=h.name)}const n=JSON.stringify(t);if(lo.has(e)){const c=lo.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let o;const r=this.workerNextTaskID++,s=e.byteLength,i=this._getWorker(r,s).then(c=>(o=c,new Promise((h,p)=>{o._callbacks[r]={resolve:h,reject:p},o.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return i.catch(()=>!0).then(()=>{o&&r&&this._releaseTask(o,r)}),lo.set(e,{key:n,promise:i}),i}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const o=e.attributes[n],r=o.name,s=o.array,i=o.itemSize;t.setAttribute(r,new l.BufferAttribute(s,i))}return t}_loadLibrary(e,t){const n=new l.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((o,r)=>{n.load(e,o,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const o=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=gc.toString(),s=["/* draco decoder */",o,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
562
+ `;continue}if((E=X.match(x))&&(G.gamma=parseFloat(E[1])),(E=X.match(I))&&(G.exposure=parseFloat(E[1])),(E=X.match(D))&&(G.valid|=2,G.format=E[1]),(E=X.match(z))&&(G.valid|=4,G.height=parseInt(E[1],10),G.width=parseInt(E[2],10)),G.valid&2&&G.valid&4)break}return G.valid&2||s(3,"missing format specifier"),G.valid&4||s(3,"missing image size specifier"),G},d=function(w,S,x){const I=S;if(I<8||I>32767||w[0]!==2||w[1]!==2||w[2]&128)return new Uint8Array(w);I!==(w[2]<<8|w[3])&&s(3,"wrong scanline width");const D=new Uint8Array(4*S*x);D.length||s(4,"unable to allocate buffer space");let z=0,G=0;const X=4*I,E=new Uint8Array(4),te=new Uint8Array(X);let q=x;for(;q>0&&G<w.byteLength;){G+4>w.byteLength&&s(1),E[0]=w[G++],E[1]=w[G++],E[2]=w[G++],E[3]=w[G++],(E[0]!=2||E[1]!=2||(E[2]<<8|E[3])!=I)&&s(3,"bad rgbe scanline format");let oe=0,ne;for(;oe<X&&G<w.byteLength;){ne=w[G++];const le=ne>128;if(le&&(ne-=128),(ne===0||oe+ne>X)&&s(3,"bad scanline data"),le){const de=w[G++];for(let k=0;k<ne;k++)te[oe++]=de}else te.set(w.subarray(G,G+ne),oe),oe+=ne,G+=ne}const ce=I;for(let le=0;le<ce;le++){let de=0;D[z]=te[le+de],de+=I,D[z+1]=te[le+de],de+=I,D[z+2]=te[le+de],de+=I,D[z+3]=te[le+de],z+=4}q--}return D},g=function(w,S,x,I){const D=w[S+3],z=Math.pow(2,D-128)/255;x[I+0]=w[S+0]*z,x[I+1]=w[S+1]*z,x[I+2]=w[S+2]*z,x[I+3]=1},y=function(w,S,x,I){const D=w[S+3],z=Math.pow(2,D-128)/255;x[I+0]=l.DataUtils.toHalfFloat(Math.min(w[S+0]*z,65504)),x[I+1]=l.DataUtils.toHalfFloat(Math.min(w[S+1]*z,65504)),x[I+2]=l.DataUtils.toHalfFloat(Math.min(w[S+2]*z,65504)),x[I+3]=l.DataUtils.toHalfFloat(1)},v=new Uint8Array(e);v.pos=0;const _=m(v),A=_.width,b=_.height,C=d(v.subarray(v.pos),A,b);let L,M,P;switch(this.type){case l.FloatType:P=C.length/4;const w=new Float32Array(P*4);for(let x=0;x<P;x++)g(C,x*4,w,x*4);L=w,M=l.FloatType;break;case l.HalfFloatType:P=C.length/4;const S=new Uint16Array(P*4);for(let x=0;x<P;x++)y(C,x*4,S,x*4);L=S,M=l.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:A,height:b,data:L,header:_.string,gamma:_.gamma,exposure:_.exposure,type:M}}setDataType(e){return this.type=e,this}load(e,t,n,o){function r(s,i){switch(s.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in s?s.colorSpace="srgb-linear":s.encoding=3e3,s.minFilter=l.LinearFilter,s.magFilter=l.LinearFilter,s.generateMipmaps=!1,s.flipY=!0;break}t&&t(s,i)}return super.load(e,r,n,o)}}const pc="srgb";class Jt extends l.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,o){const r=this,s=new l.FileLoader(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(i){try{t(r.parse(i))}catch(c){o?o(c):console.error(c),r.manager.itemError(e)}},n,o)}parse(e){const t=this;function n(k,V){if(k.nodeType!==1)return;const U=C(k);let B=!1,R=null;switch(k.nodeName){case"svg":V=g(k,V);break;case"style":r(k);break;case"g":V=g(k,V);break;case"path":V=g(k,V),k.hasAttribute("d")&&(R=o(k));break;case"rect":V=g(k,V),R=c(k);break;case"polygon":V=g(k,V),R=h(k);break;case"polyline":V=g(k,V),R=p(k);break;case"circle":V=g(k,V),R=f(k);break;case"ellipse":V=g(k,V),R=m(k);break;case"line":V=g(k,V),R=d(k);break;case"defs":B=!0;break;case"use":V=g(k,V);const N=(k.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),K=k.viewportElement.getElementById(N);K?n(K,V):console.warn("SVGLoader: 'use node' references non-existent node id: "+N);break}R&&(V.fill!==void 0&&V.fill!=="none"&&R.color.setStyle(V.fill,pc),M(R,ce),D.push(R),R.userData={node:k,style:V});const T=k.childNodes;for(let O=0;O<T.length;O++){const N=T[O];B&&N.nodeName!=="style"&&N.nodeName!=="defs"||n(N,V)}U&&(G.pop(),G.length>0?ce.copy(G[G.length-1]):ce.identity())}function o(k){const V=new l.ShapePath,U=new l.Vector2,B=new l.Vector2,R=new l.Vector2;let T=!0,O=!1;const N=k.getAttribute("d");if(N===""||N==="none")return null;const K=N.match(/[a-df-z][^a-df-z]*/gi);for(let W=0,Y=K.length;W<Y;W++){const Q=K[W],re=Q.charAt(0),se=Q.slice(1).trim();T===!0&&(O=!0,T=!1);let j;switch(re){case"M":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x=j[F+0],U.y=j[F+1],B.x=U.x,B.y=U.y,F===0?V.moveTo(U.x,U.y):V.lineTo(U.x,U.y),F===0&&R.copy(U);break;case"H":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.x=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"V":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.y=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"L":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x=j[F+0],U.y=j[F+1],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"C":j=v(se);for(let F=0,ie=j.length;F<ie;F+=6)V.bezierCurveTo(j[F+0],j[F+1],j[F+2],j[F+3],j[F+4],j[F+5]),B.x=j[F+2],B.y=j[F+3],U.x=j[F+4],U.y=j[F+5],F===0&&O===!0&&R.copy(U);break;case"S":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.bezierCurveTo(y(U.x,B.x),y(U.y,B.y),j[F+0],j[F+1],j[F+2],j[F+3]),B.x=j[F+0],B.y=j[F+1],U.x=j[F+2],U.y=j[F+3],F===0&&O===!0&&R.copy(U);break;case"Q":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.quadraticCurveTo(j[F+0],j[F+1],j[F+2],j[F+3]),B.x=j[F+0],B.y=j[F+1],U.x=j[F+2],U.y=j[F+3],F===0&&O===!0&&R.copy(U);break;case"T":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2){const he=y(U.x,B.x),_e=y(U.y,B.y);V.quadraticCurveTo(he,_e,j[F+0],j[F+1]),B.x=he,B.y=_e,U.x=j[F+0],U.y=j[F+1],F===0&&O===!0&&R.copy(U)}break;case"A":j=v(se,[3,4],7);for(let F=0,ie=j.length;F<ie;F+=7){if(j[F+5]==U.x&&j[F+6]==U.y)continue;const he=U.clone();U.x=j[F+5],U.y=j[F+6],B.x=U.x,B.y=U.y,s(V,j[F],j[F+1],j[F+2],j[F+3],j[F+4],he,U),F===0&&O===!0&&R.copy(U)}break;case"m":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x+=j[F+0],U.y+=j[F+1],B.x=U.x,B.y=U.y,F===0?V.moveTo(U.x,U.y):V.lineTo(U.x,U.y),F===0&&R.copy(U);break;case"h":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.x+=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"v":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.y+=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"l":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x+=j[F+0],U.y+=j[F+1],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"c":j=v(se);for(let F=0,ie=j.length;F<ie;F+=6)V.bezierCurveTo(U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3],U.x+j[F+4],U.y+j[F+5]),B.x=U.x+j[F+2],B.y=U.y+j[F+3],U.x+=j[F+4],U.y+=j[F+5],F===0&&O===!0&&R.copy(U);break;case"s":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.bezierCurveTo(y(U.x,B.x),y(U.y,B.y),U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3]),B.x=U.x+j[F+0],B.y=U.y+j[F+1],U.x+=j[F+2],U.y+=j[F+3],F===0&&O===!0&&R.copy(U);break;case"q":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.quadraticCurveTo(U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3]),B.x=U.x+j[F+0],B.y=U.y+j[F+1],U.x+=j[F+2],U.y+=j[F+3],F===0&&O===!0&&R.copy(U);break;case"t":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2){const he=y(U.x,B.x),_e=y(U.y,B.y);V.quadraticCurveTo(he,_e,U.x+j[F+0],U.y+j[F+1]),B.x=he,B.y=_e,U.x=U.x+j[F+0],U.y=U.y+j[F+1],F===0&&O===!0&&R.copy(U)}break;case"a":j=v(se,[3,4],7);for(let F=0,ie=j.length;F<ie;F+=7){if(j[F+5]==0&&j[F+6]==0)continue;const he=U.clone();U.x+=j[F+5],U.y+=j[F+6],B.x=U.x,B.y=U.y,s(V,j[F],j[F+1],j[F+2],j[F+3],j[F+4],he,U),F===0&&O===!0&&R.copy(U)}break;case"Z":case"z":V.currentPath.autoClose=!0,V.currentPath.curves.length>0&&(U.copy(R),V.currentPath.currentPoint.copy(U),T=!0);break;default:console.warn(Q)}O=!1}return V}function r(k){if(!(!k.sheet||!k.sheet.cssRules||!k.sheet.cssRules.length))for(let V=0;V<k.sheet.cssRules.length;V++){const U=k.sheet.cssRules[V];if(U.type!==1)continue;const B=U.selectorText.split(/,/gm).filter(Boolean).map(R=>R.trim());for(let R=0;R<B.length;R++){const T=Object.fromEntries(Object.entries(U.style).filter(([,O])=>O!==""));z[B[R]]=Object.assign(z[B[R]]||{},T)}}}function s(k,V,U,B,R,T,O,N){if(V==0||U==0){k.lineTo(N.x,N.y);return}B=B*Math.PI/180,V=Math.abs(V),U=Math.abs(U);const K=(O.x-N.x)/2,W=(O.y-N.y)/2,Y=Math.cos(B)*K+Math.sin(B)*W,Q=-Math.sin(B)*K+Math.cos(B)*W;let re=V*V,se=U*U;const j=Y*Y,F=Q*Q,ie=j/re+F/se;if(ie>1){const it=Math.sqrt(ie);V=it*V,U=it*U,re=V*V,se=U*U}const he=re*F+se*j,_e=(re*se-he)/he;let Le=Math.sqrt(Math.max(0,_e));R===T&&(Le=-Le);const Pe=Le*V*Q/U,Je=-Le*U*Y/V,wt=Math.cos(B)*Pe-Math.sin(B)*Je+(O.x+N.x)/2,It=Math.sin(B)*Pe+Math.cos(B)*Je+(O.y+N.y)/2,st=i(1,0,(Y-Pe)/V,(Q-Je)/U),Ee=i((Y-Pe)/V,(Q-Je)/U,(-Y-Pe)/V,(-Q-Je)/U)%(Math.PI*2);k.currentPath.absellipse(wt,It,V,U,st,st+Ee,T===0,B)}function i(k,V,U,B){const R=k*U+V*B,T=Math.sqrt(k*k+V*V)*Math.sqrt(U*U+B*B);let O=Math.acos(Math.max(-1,Math.min(1,R/T)));return k*B-V*U<0&&(O=-O),O}function c(k){const V=b(k.getAttribute("x")||0),U=b(k.getAttribute("y")||0),B=b(k.getAttribute("rx")||k.getAttribute("ry")||0),R=b(k.getAttribute("ry")||k.getAttribute("rx")||0),T=b(k.getAttribute("width")),O=b(k.getAttribute("height")),N=1-.551915024494,K=new l.ShapePath;return K.moveTo(V+B,U),K.lineTo(V+T-B,U),(B!==0||R!==0)&&K.bezierCurveTo(V+T-B*N,U,V+T,U+R*N,V+T,U+R),K.lineTo(V+T,U+O-R),(B!==0||R!==0)&&K.bezierCurveTo(V+T,U+O-R*N,V+T-B*N,U+O,V+T-B,U+O),K.lineTo(V+B,U+O),(B!==0||R!==0)&&K.bezierCurveTo(V+B*N,U+O,V,U+O-R*N,V,U+O-R),K.lineTo(V,U+R),(B!==0||R!==0)&&K.bezierCurveTo(V,U+R*N,V+B*N,U,V+B,U),K}function h(k){function V(T,O,N){const K=b(O),W=b(N);R===0?B.moveTo(K,W):B.lineTo(K,W),R++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let R=0;return k.getAttribute("points").replace(U,V),B.currentPath.autoClose=!0,B}function p(k){function V(T,O,N){const K=b(O),W=b(N);R===0?B.moveTo(K,W):B.lineTo(K,W),R++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let R=0;return k.getAttribute("points").replace(U,V),B.currentPath.autoClose=!1,B}function f(k){const V=b(k.getAttribute("cx")||0),U=b(k.getAttribute("cy")||0),B=b(k.getAttribute("r")||0),R=new l.Path;R.absarc(V,U,B,0,Math.PI*2);const T=new l.ShapePath;return T.subPaths.push(R),T}function m(k){const V=b(k.getAttribute("cx")||0),U=b(k.getAttribute("cy")||0),B=b(k.getAttribute("rx")||0),R=b(k.getAttribute("ry")||0),T=new l.Path;T.absellipse(V,U,B,R,0,Math.PI*2);const O=new l.ShapePath;return O.subPaths.push(T),O}function d(k){const V=b(k.getAttribute("x1")||0),U=b(k.getAttribute("y1")||0),B=b(k.getAttribute("x2")||0),R=b(k.getAttribute("y2")||0),T=new l.ShapePath;return T.moveTo(V,U),T.lineTo(B,R),T.currentPath.autoClose=!1,T}function g(k,V){V=Object.assign({},V);let U={};if(k.hasAttribute("class")){const O=k.getAttribute("class").split(/\s/).filter(Boolean).map(N=>N.trim());for(let N=0;N<O.length;N++)U=Object.assign(U,z["."+O[N]])}k.hasAttribute("id")&&(U=Object.assign(U,z["#"+k.getAttribute("id")]));function B(O,N,K){K===void 0&&(K=function(Y){return Y.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),Y}),k.hasAttribute(O)&&(V[N]=K(k.getAttribute(O))),U[O]&&(V[N]=K(U[O])),k.style&&k.style[O]!==""&&(V[N]=K(k.style[O]))}function R(O){return Math.max(0,Math.min(1,b(O)))}function T(O){return Math.max(0,b(O))}return B("fill","fill"),B("fill-opacity","fillOpacity",R),B("fill-rule","fillRule"),B("opacity","opacity",R),B("stroke","stroke"),B("stroke-opacity","strokeOpacity",R),B("stroke-width","strokeWidth",T),B("stroke-linejoin","strokeLineJoin"),B("stroke-linecap","strokeLineCap"),B("stroke-miterlimit","strokeMiterLimit",T),B("visibility","visibility"),V}function y(k,V){return k-(V-k)}function v(k,V,U){if(typeof k!="string")throw new TypeError("Invalid input: "+typeof k);const B={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},R=0,T=1,O=2,N=3;let K=R,W=!0,Y="",Q="";const re=[];function se(he,_e,Le){const Pe=new SyntaxError('Unexpected character "'+he+'" at index '+_e+".");throw Pe.partial=Le,Pe}function j(){Y!==""&&(Q===""?re.push(Number(Y)):re.push(Number(Y)*Math.pow(10,Number(Q)))),Y="",Q=""}let F;const ie=k.length;for(let he=0;he<ie;he++){if(F=k[he],Array.isArray(V)&&V.includes(re.length%U)&&B.FLAGS.test(F)){K=T,Y=F,j();continue}if(K===R){if(B.WHITESPACE.test(F))continue;if(B.DIGIT.test(F)||B.SIGN.test(F)){K=T,Y=F;continue}if(B.POINT.test(F)){K=O,Y=F;continue}B.COMMA.test(F)&&(W&&se(F,he,re),W=!0)}if(K===T){if(B.DIGIT.test(F)){Y+=F;continue}if(B.POINT.test(F)){Y+=F,K=O;continue}if(B.EXP.test(F)){K=N;continue}B.SIGN.test(F)&&Y.length===1&&B.SIGN.test(Y[0])&&se(F,he,re)}if(K===O){if(B.DIGIT.test(F)){Y+=F;continue}if(B.EXP.test(F)){K=N;continue}B.POINT.test(F)&&Y[Y.length-1]==="."&&se(F,he,re)}if(K===N){if(B.DIGIT.test(F)){Q+=F;continue}if(B.SIGN.test(F)){if(Q===""){Q+=F;continue}Q.length===1&&B.SIGN.test(Q)&&se(F,he,re)}}B.WHITESPACE.test(F)?(j(),K=R,W=!1):B.COMMA.test(F)?(j(),K=R,W=!0):B.SIGN.test(F)?(j(),K=T,Y=F):B.POINT.test(F)?(j(),K=O,Y=F):se(F,he,re)}return j(),re}const _=["mm","cm","in","pt","pc","px"],A={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function b(k){let V="px";if(typeof k=="string"||k instanceof String)for(let B=0,R=_.length;B<R;B++){const T=_[B];if(k.endsWith(T)){V=T,k=k.substring(0,k.length-T.length);break}}let U;return V==="px"&&t.defaultUnit!=="px"?U=A.in[t.defaultUnit]/t.defaultDPI:(U=A[V][t.defaultUnit],U<0&&(U=A[V].in*t.defaultDPI)),U*parseFloat(k)}function C(k){if(!(k.hasAttribute("transform")||k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))))return null;const V=L(k);return G.length>0&&V.premultiply(G[G.length-1]),ce.copy(V),G.push(V),V}function L(k){const V=new l.Matrix3,U=X;if(k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))){const B=b(k.getAttribute("x")),R=b(k.getAttribute("y"));V.translate(B,R)}if(k.hasAttribute("transform")){const B=k.getAttribute("transform").split(")");for(let R=B.length-1;R>=0;R--){const T=B[R].trim();if(T==="")continue;const O=T.indexOf("("),N=T.length;if(O>0&&O<N){const K=T.slice(0,O),W=v(T.slice(O+1));switch(U.identity(),K){case"translate":if(W.length>=1){const Y=W[0];let Q=0;W.length>=2&&(Q=W[1]),U.translate(Y,Q)}break;case"rotate":if(W.length>=1){let Y=0,Q=0,re=0;Y=W[0]*Math.PI/180,W.length>=3&&(Q=W[1],re=W[2]),E.makeTranslation(-Q,-re),te.makeRotation(Y),q.multiplyMatrices(te,E),E.makeTranslation(Q,re),U.multiplyMatrices(E,q)}break;case"scale":if(W.length>=1){const Y=W[0];let Q=Y;W.length>=2&&(Q=W[1]),U.scale(Y,Q)}break;case"skewX":W.length===1&&U.set(1,Math.tan(W[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":W.length===1&&U.set(1,0,0,Math.tan(W[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":W.length===6&&U.set(W[0],W[2],W[4],W[1],W[3],W[5],0,0,1);break}}V.premultiply(U)}}return V}function M(k,V){function U(O){ne.set(O.x,O.y,1).applyMatrix3(V),O.set(ne.x,ne.y)}function B(O){const N=O.xRadius,K=O.yRadius,W=Math.cos(O.aRotation),Y=Math.sin(O.aRotation),Q=new l.Vector3(N*W,N*Y,0),re=new l.Vector3(-K*Y,K*W,0),se=Q.applyMatrix3(V),j=re.applyMatrix3(V),F=X.set(se.x,j.x,0,se.y,j.y,0,0,0,1),ie=E.copy(F).invert(),Le=te.copy(ie).transpose().multiply(ie).elements,Pe=I(Le[0],Le[1],Le[4]),Je=Math.sqrt(Pe.rt1),wt=Math.sqrt(Pe.rt2);if(O.xRadius=1/Je,O.yRadius=1/wt,O.aRotation=Math.atan2(Pe.sn,Pe.cs),!((O.aEndAngle-O.aStartAngle)%(2*Math.PI)<Number.EPSILON)){const st=E.set(Je,0,0,0,wt,0,0,0,1),Ee=te.set(Pe.cs,Pe.sn,0,-Pe.sn,Pe.cs,0,0,0,1),it=st.multiply(Ee).multiply(F),sn=kn=>{const{x:Ro,y:Bn}=new l.Vector3(Math.cos(kn),Math.sin(kn),0).applyMatrix3(it);return Math.atan2(Bn,Ro)};O.aStartAngle=sn(O.aStartAngle),O.aEndAngle=sn(O.aEndAngle),P(V)&&(O.aClockwise=!O.aClockwise)}}function R(O){const N=S(V),K=x(V);O.xRadius*=N,O.yRadius*=K;const W=N>Number.EPSILON?Math.atan2(V.elements[1],V.elements[0]):Math.atan2(-V.elements[3],V.elements[4]);O.aRotation+=W,P(V)&&(O.aStartAngle*=-1,O.aEndAngle*=-1,O.aClockwise=!O.aClockwise)}const T=k.subPaths;for(let O=0,N=T.length;O<N;O++){const W=T[O].curves;for(let Y=0;Y<W.length;Y++){const Q=W[Y];Q.isLineCurve?(U(Q.v1),U(Q.v2)):Q.isCubicBezierCurve?(U(Q.v0),U(Q.v1),U(Q.v2),U(Q.v3)):Q.isQuadraticBezierCurve?(U(Q.v0),U(Q.v1),U(Q.v2)):Q.isEllipseCurve&&(oe.set(Q.aX,Q.aY),U(oe),Q.aX=oe.x,Q.aY=oe.y,w(V)?B(Q):R(Q))}}}function P(k){const V=k.elements;return V[0]*V[4]-V[1]*V[3]<0}function w(k){const V=k.elements,U=V[0]*V[3]+V[1]*V[4];if(U===0)return!1;const B=S(k),R=x(k);return Math.abs(U/(B*R))>Number.EPSILON}function S(k){const V=k.elements;return Math.sqrt(V[0]*V[0]+V[1]*V[1])}function x(k){const V=k.elements;return Math.sqrt(V[3]*V[3]+V[4]*V[4])}function I(k,V,U){let B,R,T,O,N;const K=k+U,W=k-U,Y=Math.sqrt(W*W+4*V*V);return K>0?(B=.5*(K+Y),N=1/B,R=k*N*U-V*N*V):K<0?R=.5*(K-Y):(B=.5*Y,R=-.5*Y),W>0?T=W+Y:T=W-Y,Math.abs(T)>2*Math.abs(V)?(N=-2*V/T,O=1/Math.sqrt(1+N*N),T=N*O):Math.abs(V)===0?(T=1,O=0):(N=-.5*T/V,T=1/Math.sqrt(1+N*N),O=N*T),W>0&&(N=T,T=-O,O=N),{rt1:B,rt2:R,cs:T,sn:O}}const D=[],z={},G=[],X=new l.Matrix3,E=new l.Matrix3,te=new l.Matrix3,q=new l.Matrix3,oe=new l.Vector2,ne=new l.Vector3,ce=new l.Matrix3,le=new DOMParser().parseFromString(e,"image/svg+xml");return n(le.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:D,xml:le.documentElement}}static createShapes(e){const n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},o={loc:n.ORIGIN,t:0};function r(y,v,_,A){const b=y.x,C=v.x,L=_.x,M=A.x,P=y.y,w=v.y,S=_.y,x=A.y,I=(M-L)*(P-S)-(x-S)*(b-L),D=(C-b)*(P-S)-(w-P)*(b-L),z=(x-S)*(C-b)-(M-L)*(w-P),G=I/z,X=D/z;if(z===0&&I!==0||G<=0||G>=1||X<0||X>1)return null;if(I===0&&z===0){for(let E=0;E<2;E++)if(s(E===0?_:A,y,v),o.loc==n.ORIGIN){const te=E===0?_:A;return{x:te.x,y:te.y,t:o.t}}else if(o.loc==n.BETWEEN){const te=+(b+o.t*(C-b)).toPrecision(10),q=+(P+o.t*(w-P)).toPrecision(10);return{x:te,y:q,t:o.t}}return null}else{for(let q=0;q<2;q++)if(s(q===0?_:A,y,v),o.loc==n.ORIGIN){const oe=q===0?_:A;return{x:oe.x,y:oe.y,t:o.t}}const E=+(b+G*(C-b)).toPrecision(10),te=+(P+G*(w-P)).toPrecision(10);return{x:E,y:te,t:G}}}function s(y,v,_){const A=_.x-v.x,b=_.y-v.y,C=y.x-v.x,L=y.y-v.y,M=A*L-C*b;if(y.x===v.x&&y.y===v.y){o.loc=n.ORIGIN,o.t=0;return}if(y.x===_.x&&y.y===_.y){o.loc=n.DESTINATION,o.t=1;return}if(M<-Number.EPSILON){o.loc=n.LEFT;return}if(M>Number.EPSILON){o.loc=n.RIGHT;return}if(A*C<0||b*L<0){o.loc=n.BEHIND;return}if(Math.sqrt(A*A+b*b)<Math.sqrt(C*C+L*L)){o.loc=n.BEYOND;return}let P;A!==0?P=C/A:P=L/b,o.loc=n.BETWEEN,o.t=P}function i(y,v){const _=[],A=[];for(let b=1;b<y.length;b++){const C=y[b-1],L=y[b];for(let M=1;M<v.length;M++){const P=v[M-1],w=v[M],S=r(C,L,P,w);S!==null&&_.find(x=>x.t<=S.t+Number.EPSILON&&x.t>=S.t-Number.EPSILON)===void 0&&(_.push(S),A.push(new l.Vector2(S.x,S.y)))}}return A}function c(y,v,_){const A=new l.Vector2;v.getCenter(A);const b=[];return _.forEach(C=>{C.boundingBox.containsPoint(A)&&i(y,C.points).forEach(M=>{b.push({identifier:C.identifier,isCW:C.isCW,point:M})})}),b.sort((C,L)=>C.point.x-L.point.x),b}function h(y,v,_,A,b){(b==null||b==="")&&(b="nonzero");const C=new l.Vector2;y.boundingBox.getCenter(C);const L=[new l.Vector2(_,C.y),new l.Vector2(A,C.y)],M=c(L,y.boundingBox,v);M.sort((D,z)=>D.point.x-z.point.x);const P=[],w=[];M.forEach(D=>{D.identifier===y.identifier?P.push(D):w.push(D)});const S=P[0].point.x,x=[];let I=0;for(;I<w.length&&w[I].point.x<S;)x.length>0&&x[x.length-1]===w[I].identifier?x.pop():x.push(w[I].identifier),I++;if(x.push(y.identifier),b==="evenodd"){const D=x.length%2===0,z=x[x.length-2];return{identifier:y.identifier,isHole:D,for:z}}else if(b==="nonzero"){let D=!0,z=null,G=null;for(let X=0;X<x.length;X++){const E=x[X];D?(G=v[E].isCW,D=!1,z=E):G!==v[E].isCW&&(G=v[E].isCW,D=!0)}return{identifier:y.identifier,isHole:D,for:z}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let p=999999999,f=-999999999,m=e.subPaths.map(y=>{const v=y.getPoints();let _=-999999999,A=999999999,b=-999999999,C=999999999;for(let L=0;L<v.length;L++){const M=v[L];M.y>_&&(_=M.y),M.y<A&&(A=M.y),M.x>b&&(b=M.x),M.x<C&&(C=M.x)}return f<=b&&(f=b+1),p>=C&&(p=C-1),{curves:y.curves,points:v,isCW:l.ShapeUtils.isClockWise(v),identifier:-1,boundingBox:new l.Box2(new l.Vector2(C,A),new l.Vector2(b,_))}});m=m.filter(y=>y.points.length>1);for(let y=0;y<m.length;y++)m[y].identifier=y;const d=m.map(y=>h(y,m,p,f,e.userData?e.userData.style.fillRule:void 0)),g=[];return m.forEach(y=>{if(!d[y.identifier].isHole){const _=new l.Shape;_.curves=y.curves,d.filter(b=>b.isHole&&b.for===y.identifier).forEach(b=>{const C=m[b.identifier],L=new l.Path;L.curves=C.curves,_.holes.push(L)}),g.push(_)}}),g}static getStrokeStyle(e,t,n,o,r){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",o=o!==void 0?o:"butt",r=r!==void 0?r:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:o,strokeMiterLimit:r}}static pointsToStroke(e,t,n,o){const r=[],s=[],i=[];if(Jt.pointsToStrokeWithBuffers(e,t,n,o,r,s,i)===0)return null;const c=new l.BufferGeometry;return c.setAttribute("position",new l.Float32BufferAttribute(r,3)),c.setAttribute("normal",new l.Float32BufferAttribute(s,3)),c.setAttribute("uv",new l.Float32BufferAttribute(i,2)),c}static pointsToStrokeWithBuffers(e,t,n,o,r,s,i,c){const h=new l.Vector2,p=new l.Vector2,f=new l.Vector2,m=new l.Vector2,d=new l.Vector2,g=new l.Vector2,y=new l.Vector2,v=new l.Vector2,_=new l.Vector2,A=new l.Vector2,b=new l.Vector2,C=new l.Vector2,L=new l.Vector2,M=new l.Vector2,P=new l.Vector2,w=new l.Vector2,S=new l.Vector2;n=n!==void 0?n:12,o=o!==void 0?o:.001,c=c!==void 0?c:0,e=W(e);const x=e.length;if(x<2)return 0;const I=e[0].equals(e[x-1]);let D,z=e[0],G;const X=t.strokeWidth/2,E=1/(x-1);let te=0,q,oe,ne,ce,le=!1,de=0,k=c*3,V=c*2;U(e[0],e[1],h).multiplyScalar(X),v.copy(e[0]).sub(h),_.copy(e[0]).add(h),A.copy(v),b.copy(_);for(let Y=1;Y<x;Y++){D=e[Y],Y===x-1?I?G=e[1]:G=void 0:G=e[Y+1];const Q=h;if(U(z,D,Q),f.copy(Q).multiplyScalar(X),C.copy(D).sub(f),L.copy(D).add(f),q=te+E,oe=!1,G!==void 0){U(D,G,p),f.copy(p).multiplyScalar(X),M.copy(D).sub(f),P.copy(D).add(f),ne=!0,f.subVectors(G,z),Q.dot(f)<0&&(ne=!1),Y===1&&(le=ne),f.subVectors(G,D),f.normalize();const re=Math.abs(Q.dot(f));if(re>Number.EPSILON){const se=X/re;f.multiplyScalar(-se),m.subVectors(D,z),d.copy(m).setLength(se).add(f),w.copy(d).negate();const j=d.length(),F=m.length();m.divideScalar(F),g.subVectors(G,D);const ie=g.length();switch(g.divideScalar(ie),m.dot(w)<F&&g.dot(w)<ie&&(oe=!0),S.copy(d).add(D),w.add(D),ce=!1,oe?ne?(P.copy(w),L.copy(w)):(M.copy(w),C.copy(w)):T(),t.strokeLineJoin){case"bevel":O(ne,oe,q);break;case"round":N(ne,oe),ne?R(D,C,M,q,0):R(D,P,L,q,1);break;case"miter":case"miter-clip":default:const he=X*t.strokeMiterLimit/j;if(he<1)if(t.strokeLineJoin!=="miter-clip"){O(ne,oe,q);break}else N(ne,oe),ne?(g.subVectors(S,C).multiplyScalar(he).add(C),y.subVectors(S,M).multiplyScalar(he).add(M),B(C,q,0),B(g,q,0),B(D,q,.5),B(D,q,.5),B(g,q,0),B(y,q,0),B(D,q,.5),B(y,q,0),B(M,q,0)):(g.subVectors(S,L).multiplyScalar(he).add(L),y.subVectors(S,P).multiplyScalar(he).add(P),B(L,q,1),B(g,q,1),B(D,q,.5),B(D,q,.5),B(g,q,1),B(y,q,1),B(D,q,.5),B(y,q,1),B(P,q,1));else oe?(ne?(B(_,te,1),B(v,te,0),B(S,q,0),B(_,te,1),B(S,q,0),B(w,q,1)):(B(_,te,1),B(v,te,0),B(S,q,1),B(v,te,0),B(w,q,0),B(S,q,1)),ne?M.copy(S):P.copy(S)):ne?(B(C,q,0),B(S,q,0),B(D,q,.5),B(D,q,.5),B(S,q,0),B(M,q,0)):(B(L,q,1),B(S,q,1),B(D,q,.5),B(D,q,.5),B(S,q,1),B(P,q,1)),ce=!0;break}}else T()}else T();!I&&Y===x-1&&K(e[0],A,b,ne,!0,te),te=q,z=D,v.copy(M),_.copy(P)}if(!I)K(D,C,L,ne,!1,q);else if(oe&&r){let Y=S,Q=w;le!==ne&&(Y=w,Q=S),ne?(ce||le)&&(Q.toArray(r,0*3),Q.toArray(r,3*3),ce&&Y.toArray(r,1*3)):(ce||!le)&&(Q.toArray(r,1*3),Q.toArray(r,3*3),ce&&Y.toArray(r,0*3))}return de;function U(Y,Q,re){return re.subVectors(Q,Y),re.set(-re.y,re.x).normalize()}function B(Y,Q,re){r&&(r[k]=Y.x,r[k+1]=Y.y,r[k+2]=0,s&&(s[k]=0,s[k+1]=0,s[k+2]=1),k+=3,i&&(i[V]=Q,i[V+1]=re,V+=2)),de+=3}function R(Y,Q,re,se,j){h.copy(Q).sub(Y).normalize(),p.copy(re).sub(Y).normalize();let F=Math.PI;const ie=h.dot(p);Math.abs(ie)<1&&(F=Math.abs(Math.acos(ie))),F/=n,f.copy(Q);for(let he=0,_e=n-1;he<_e;he++)m.copy(f).rotateAround(Y,F),B(f,se,j),B(m,se,j),B(Y,se,.5),f.copy(m);B(m,se,j),B(re,se,j),B(Y,se,.5)}function T(){B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(L,q,1)}function O(Y,Q,re){Q?Y?(B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(w,q,1),B(C,re,0),B(M,re,0),B(w,re,.5)):(B(_,te,1),B(v,te,0),B(L,q,1),B(v,te,0),B(w,q,0),B(L,q,1),B(L,re,1),B(w,re,0),B(P,re,1)):Y?(B(C,re,0),B(M,re,0),B(D,re,.5)):(B(L,re,1),B(P,re,0),B(D,re,.5))}function N(Y,Q){Q&&(Y?(B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(w,q,1),B(C,te,0),B(D,q,.5),B(w,q,1),B(D,q,.5),B(M,te,0),B(w,q,1)):(B(_,te,1),B(v,te,0),B(L,q,1),B(v,te,0),B(w,q,0),B(L,q,1),B(L,te,1),B(w,q,0),B(D,q,.5),B(D,q,.5),B(w,q,0),B(P,te,1)))}function K(Y,Q,re,se,j,F){switch(t.strokeLineCap){case"round":j?R(Y,re,Q,F,.5):R(Y,Q,re,F,.5);break;case"square":if(j)h.subVectors(Q,Y),p.set(h.y,-h.x),f.addVectors(h,p).add(Y),m.subVectors(p,h).add(Y),se?(f.toArray(r,1*3),m.toArray(r,0*3),m.toArray(r,3*3)):(f.toArray(r,1*3),i[3*2+1]===1?m.toArray(r,3*3):f.toArray(r,3*3),m.toArray(r,0*3));else{h.subVectors(re,Y),p.set(h.y,-h.x),f.addVectors(h,p).add(Y),m.subVectors(p,h).add(Y);const ie=r.length;se?(f.toArray(r,ie-1*3),m.toArray(r,ie-2*3),m.toArray(r,ie-4*3)):(m.toArray(r,ie-2*3),f.toArray(r,ie-1*3),m.toArray(r,ie-4*3))}break}}function W(Y){let Q=!1;for(let se=1,j=Y.length-1;se<j;se++)if(Y[se].distanceTo(Y[se+1])<o){Q=!0;break}if(!Q)return Y;const re=[];re.push(Y[0]);for(let se=1,j=Y.length-1;se<j;se++)Y[se].distanceTo(Y[se+1])>=o&&re.push(Y[se]);return re.push(Y[Y.length-1]),re}}}const lo=new WeakMap;class mc extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,o){const r=new l.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,s=>{const i={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(s,i).then(t).catch(o)},n,o)}decodeDracoFile(e,t,n,o){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:o||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const h=t.attributeTypes[c];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=h.name)}const n=JSON.stringify(t);if(lo.has(e)){const c=lo.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let o;const r=this.workerNextTaskID++,s=e.byteLength,i=this._getWorker(r,s).then(c=>(o=c,new Promise((h,p)=>{o._callbacks[r]={resolve:h,reject:p},o.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return i.catch(()=>!0).then(()=>{o&&r&&this._releaseTask(o,r)}),lo.set(e,{key:n,promise:i}),i}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const o=e.attributes[n],r=o.name,s=o.array,i=o.itemSize;t.setAttribute(r,new l.BufferAttribute(s,i))}return t}_loadLibrary(e,t){const n=new l.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((o,r)=>{n.load(e,o,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const o=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=gc.toString(),s=["/* draco decoder */",o,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
563
563
  `);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const o=new Worker(this.workerSourceURL);o._callbacks={},o._taskCosts={},o._taskLoad=0,o.postMessage({type:"init",decoderConfig:this.decoderConfig}),o.onmessage=function(r){const s=r.data;switch(s.type){case"decode":o._callbacks[s.id].resolve(s);break;case"error":o._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(o)}else this.workerPool.sort(function(o,r){return o._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function gc(){let a,e;onmessage=function(s){const i=s.data;switch(i.type){case"init":a=i.decoderConfig,e=new Promise(function(p){a.onModuleLoaded=function(f){p({draco:f})},DracoDecoderModule(a)});break;case"decode":const c=i.buffer,h=i.taskConfig;e.then(p=>{const f=p.draco,m=new f.Decoder,d=new f.DecoderBuffer;d.Init(new Int8Array(c),c.byteLength);try{const g=t(f,m,d,h),y=g.attributes.map(v=>v.array.buffer);g.index&&y.push(g.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:g},y)}catch(g){console.error(g),self.postMessage({type:"error",id:i.id,error:g.message})}finally{f.destroy(d),f.destroy(m)}});break}};function t(s,i,c,h){const p=h.attributeIDs,f=h.attributeTypes;let m,d;const g=i.GetEncodedGeometryType(c);if(g===s.TRIANGULAR_MESH)m=new s.Mesh,d=i.DecodeBufferToMesh(c,m);else if(g===s.POINT_CLOUD)m=new s.PointCloud,d=i.DecodeBufferToPointCloud(c,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const y={index:null,attributes:[]};for(const v in p){const _=self[f[v]];let A,b;if(h.useUniqueIDs)b=p[v],A=i.GetAttributeByUniqueId(m,b);else{if(b=i.GetAttributeId(m,s[p[v]]),b===-1)continue;A=i.GetAttribute(m,b)}y.attributes.push(o(s,i,m,v,_,A))}return g===s.TRIANGULAR_MESH&&(y.index=n(s,i,m)),s.destroy(m),y}function n(s,i,c){const p=c.num_faces()*3,f=p*4,m=s._malloc(f);i.GetTrianglesUInt32Array(c,f,m);const d=new Uint32Array(s.HEAPF32.buffer,m,p).slice();return s._free(m),{array:d,itemSize:1}}function o(s,i,c,h,p,f){const m=f.num_components(),g=c.num_points()*m,y=g*p.BYTES_PER_ELEMENT,v=r(s,p),_=s._malloc(y);i.GetAttributeDataArrayForAllPoints(c,f,v,y,_);const A=new p(s.HEAPF32.buffer,_,g).slice();return s._free(_),{name:h,array:A,itemSize:m}}function r(s,i){switch(i){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}const Gr=new l.Box3,vn=new l.Vector3;class Rr extends l.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new l.Float32BufferAttribute(e,3)),this.setAttribute("uv",new l.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new l.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new l.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new l.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e,t=3){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const o=new l.InstancedInterleavedBuffer(n,t*2,1);return this.setAttribute("instanceColorStart",new l.InterleavedBufferAttribute(o,t,0)),this.setAttribute("instanceColorEnd",new l.InterleavedBufferAttribute(o,t,t)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new l.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new l.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Gr.setFromBufferAttribute(t),this.boundingBox.union(Gr))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new l.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let o=0;for(let r=0,s=e.count;r<s;r++)vn.fromBufferAttribute(e,r),o=Math.max(o,n.distanceToSquared(vn)),vn.fromBufferAttribute(t,r),o=Math.max(o,n.distanceToSquared(vn));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}class jr extends Rr{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let o=0;o<t;o+=3)n[2*o]=e[o],n[2*o+1]=e[o+1],n[2*o+2]=e[o+2],n[2*o+3]=e[o+3],n[2*o+4]=e[o+4],n[2*o+5]=e[o+5];return super.setPositions(n),this}setColors(e,t=3){const n=e.length-t,o=new Float32Array(2*n);if(t===3)for(let r=0;r<n;r+=t)o[2*r]=e[r],o[2*r+1]=e[r+1],o[2*r+2]=e[r+2],o[2*r+3]=e[r+3],o[2*r+4]=e[r+4],o[2*r+5]=e[r+5];else for(let r=0;r<n;r+=t)o[2*r]=e[r],o[2*r+1]=e[r+1],o[2*r+2]=e[r+2],o[2*r+3]=e[r+3],o[2*r+4]=e[r+4],o[2*r+5]=e[r+5],o[2*r+6]=e[r+6],o[2*r+7]=e[r+7];return super.setColors(o,t),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class co extends l.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:l.UniformsUtils.clone(l.UniformsUtils.merge([l.UniformsLib.common,l.UniformsLib.fog,{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new l.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}}])),vertexShader:`
564
564
  #include <common>
565
565
  #include <fog_pars_vertex>
@@ -968,7 +968,7 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
968
968
  #include <premultiplied_alpha_fragment>
969
969
 
970
970
  }
971
- `,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){t===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(t){!!t!="USE_DASH"in this.defines&&(this.needsUpdate=!0),t===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(t){!!t!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),t===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}}const uo=new l.Vector4,Wr=new l.Vector3,Yr=new l.Vector3,Ne=new l.Vector4,Fe=new l.Vector4,tt=new l.Vector4,ho=new l.Vector3,fo=new l.Matrix4,ze=new l.Line3,Xr=new l.Vector3,xn=new l.Box3,wn=new l.Sphere,nt=new l.Vector4;let ot,Pt;function Er(a,e,t){return nt.set(0,0,-e,1).applyMatrix4(a.projectionMatrix),nt.multiplyScalar(1/nt.w),nt.x=Pt/t.width,nt.y=Pt/t.height,nt.applyMatrix4(a.projectionMatrixInverse),nt.multiplyScalar(1/nt.w),Math.abs(Math.max(nt.x,nt.y))}function yc(a,e){const t=a.matrixWorld,n=a.geometry,o=n.attributes.instanceStart,r=n.attributes.instanceEnd,s=Math.min(n.instanceCount,o.count);for(let i=0,c=s;i<c;i++){ze.start.fromBufferAttribute(o,i),ze.end.fromBufferAttribute(r,i),ze.applyMatrix4(t);const h=new l.Vector3,p=new l.Vector3;ot.distanceSqToSegment(ze.start,ze.end,p,h),p.distanceTo(h)<Pt*.5&&e.push({point:p,pointOnLine:h,distance:ot.origin.distanceTo(p),object:a,face:null,faceIndex:i,uv:null,[Gn]:null})}}function _c(a,e,t){const n=e.projectionMatrix,r=a.material.resolution,s=a.matrixWorld,i=a.geometry,c=i.attributes.instanceStart,h=i.attributes.instanceEnd,p=Math.min(i.instanceCount,c.count),f=-e.near;ot.at(1,tt),tt.w=1,tt.applyMatrix4(e.matrixWorldInverse),tt.applyMatrix4(n),tt.multiplyScalar(1/tt.w),tt.x*=r.x/2,tt.y*=r.y/2,tt.z=0,ho.copy(tt),fo.multiplyMatrices(e.matrixWorldInverse,s);for(let m=0,d=p;m<d;m++){if(Ne.fromBufferAttribute(c,m),Fe.fromBufferAttribute(h,m),Ne.w=1,Fe.w=1,Ne.applyMatrix4(fo),Fe.applyMatrix4(fo),Ne.z>f&&Fe.z>f)continue;if(Ne.z>f){const b=Ne.z-Fe.z,C=(Ne.z-f)/b;Ne.lerp(Fe,C)}else if(Fe.z>f){const b=Fe.z-Ne.z,C=(Fe.z-f)/b;Fe.lerp(Ne,C)}Ne.applyMatrix4(n),Fe.applyMatrix4(n),Ne.multiplyScalar(1/Ne.w),Fe.multiplyScalar(1/Fe.w),Ne.x*=r.x/2,Ne.y*=r.y/2,Fe.x*=r.x/2,Fe.y*=r.y/2,ze.start.copy(Ne),ze.start.z=0,ze.end.copy(Fe),ze.end.z=0;const y=ze.closestPointToPointParameter(ho,!0);ze.at(y,Xr);const v=l.MathUtils.lerp(Ne.z,Fe.z,y),_=v>=-1&&v<=1,A=ho.distanceTo(Xr)<Pt*.5;if(_&&A){ze.start.fromBufferAttribute(c,m),ze.end.fromBufferAttribute(h,m),ze.start.applyMatrix4(s),ze.end.applyMatrix4(s);const b=new l.Vector3,C=new l.Vector3;ot.distanceSqToSegment(ze.start,ze.end,C,b),t.push({point:C,pointOnLine:b,distance:ot.origin.distanceTo(C),object:a,face:null,faceIndex:m,uv:null,[Gn]:null})}}}class vc extends l.Mesh{constructor(e=new Rr,t=new co({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,o=new Float32Array(2*t.count);for(let s=0,i=0,c=t.count;s<c;s++,i+=2)Wr.fromBufferAttribute(t,s),Yr.fromBufferAttribute(n,s),o[i]=i===0?0:o[i-1],o[i+1]=o[i]+Wr.distanceTo(Yr);const r=new l.InstancedInterleavedBuffer(o,2,1);return e.setAttribute("instanceDistanceStart",new l.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new l.InterleavedBufferAttribute(r,1,1)),this}raycast(e,t){const n=this.material.worldUnits,o=e.camera;o===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;ot=e.ray;const s=this.matrixWorld,i=this.geometry,c=this.material;Pt=c.linewidth+r,i.boundingSphere===null&&i.computeBoundingSphere(),wn.copy(i.boundingSphere).applyMatrix4(s);let h;if(n)h=Pt*.5;else{const f=Math.max(o.near,wn.distanceToPoint(ot.origin));h=Er(o,f,c.resolution)}if(wn.radius+=h,ot.intersectsSphere(wn)===!1)return;i.boundingBox===null&&i.computeBoundingBox(),xn.copy(i.boundingBox).applyMatrix4(s);let p;if(n)p=Pt*.5;else{const f=Math.max(o.near,xn.distanceToPoint(ot.origin));p=Er(o,f,c.resolution)}xn.expandByScalar(p),ot.intersectsBox(xn)!==!1&&(n?yc(this,t):_c(this,o,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(uo),this.material.uniforms.resolution.value.set(uo.z,uo.w))}}class xc extends vc{constructor(e=new jr,t=new co({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}class wc extends l.Line{constructor(e,t=1,n=16,o=2){const r=new l.BufferGeometry,s=n+o*2,i=new Float32Array((s*3+3)*3);r.setAttribute("position",new l.BufferAttribute(i,3));const c=new l.LineBasicMaterial({color:65280}),h=new l.LineBasicMaterial({color:16776960});super(r,[h,c]),this.type="PositionalAudioHelper",this.audio=e,this.range=t,this.divisionsInnerAngle=n,this.divisionsOuterAngle=o,this.update()}update(){const e=this.audio,t=this.range,n=this.divisionsInnerAngle,o=this.divisionsOuterAngle,r=l.MathUtils.degToRad(e.panner.coneInnerAngle),s=l.MathUtils.degToRad(e.panner.coneOuterAngle),i=r/2,c=s/2;let h=0,p=0,f,m;const d=this.geometry,g=d.attributes.position;d.clearGroups();function y(v,_,A,b){const C=(_-v)/A;for(g.setXYZ(h,0,0,0),p++,f=v;f<_;f+=C)m=h+p,g.setXYZ(m,Math.sin(f)*t,0,Math.cos(f)*t),g.setXYZ(m+1,Math.sin(Math.min(f+C,_))*t,0,Math.cos(Math.min(f+C,_))*t),g.setXYZ(m+2,0,0,0),p+=3;d.addGroup(h,p,b),h+=p,p=0}y(-c,-i,o,0),y(-i,i,n,1),y(i,c,o,0),g.needsUpdate=!0,r===s&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}function bc(a){return a}function Mc(a){return a*a*a}function Sc(a){return a<.5?4*a*a*a:1-(-2*a+2)**3/2}function Ac(a){return a*a*a*a}function Pc(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375}const ut="https://raw.githubusercontent.com/Tresjs/assets/93976c7d63ac83d4a254a41a10b2362bc17e90c9/textures/lensflare/",po=`${ut}circle.png`,bn=`${ut}circleBlur.png`,Cc=`${ut}circleRainbow.png`,Tc=`${ut}line.png`,Zr=`${ut}poly6.png`,Kr=`${ut}polyStroke6.png`,Ic=`${ut}rays.png`,Mn=`${ut}ring.png`,Oc=`${ut}starThin6.png`,Lc={texture:[Tc,Mn],color:["white"],distance:[0,0],size:[750,1024],length:[0,2]},Dc={texture:[bn],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},kc={texture:[Ic],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},Bc={texture:[po,Cc,Mn,Oc],color:["white"],distance:[0,0],size:[180,512],length:[2,3]},[qr,Qr]=[3679071,132442],mo=[Lc,Dc,kc,Bc,{texture:[bn,po,Mn,Zr,Kr],color:["dimgray","gray","darkgray",qr,Qr],distance:[.5,2.5],size:[20,180],length:[5,21]},{texture:[bn,po,Mn,Zr,Kr],color:["dimgray","gray","darkgray",qr,Qr],distance:[-.6,-.1],size:[180,360],length:[0,5]}],Sn={color:"white",distance:0,size:512,texture:bn},Jr=l.MathUtils.clamp;class Hr{constructor(e=0,t){ue(this,"_getNext");ue(this,"_getGenerator");this._getGenerator=t??this.getMulberry32,this._getNext=this._getGenerator(e)}seed(e){this._getNext=this._getGenerator(e)}rand(){return this._getNext()}float(e,t){return e+this._getNext()*(t-e)}floatSpread(e){return this.float(-.5*e,.5*e)}int(e,t){return e+Math.floor(this._getNext()*(t-e+1))}choice(e){return e.length?e[Math.floor(this._getNext()*e.length)]:null}defaultChoice(e,t){return e.length?e[Math.floor(this._getNext()*e.length)]:t}sample(e,t,n){const o=e.length;t=Jr(t,0,o-1),n=Jr(n??o-1,0,o-1);const r=this.int(t,n),s=this.shuffle(e.map((c,h)=>h)),i=Math.min(e.length,r);return s.slice(0,i).sort().map(c=>e[c])}shuffle(e){return e.map(t=>({value:t,sort:this._getNext()})).sort((t,n)=>t.sort-n.sort).map(({value:t})=>t)}getMulberry32(e=0){return e>0&&e<1&&(e=Math.floor(e*2**16)),()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}}const Uc=[bc,Mc,Sc,Ac,Pc],$r=l.MathUtils.lerp,es=(a=0,e=mo)=>{const n=new Hr(a).choice(Uc);return e.map((o,r)=>{const s=new Hr(a*(r*7907+1)+(typeof o.seed=="number"?o.seed:0)),i=s.int(o.length[0],o.length[1]);return Array.from({length:i}).fill(0).map(()=>{const c=n(s.rand());return{texture:s.defaultChoice(o.texture,Sn.texture),size:$r(o.size[0],o.size[1],n(1-c)),distance:$r(o.distance[0],o.distance[1],c),color:s.defaultChoice(o.color,Sn.color)}})}).flat()},ts=(a,e,t=void 0,n=void 0,o=Sn)=>{if(a!==void 0&&a.length>0&&(typeof t=="number"||typeof n<"u")){const i=es(t??0,n??mo),c=i.length,h=a.length;return c>=h?i.map((p,f)=>Object.assign(p,e,f<h?a[f]:{})):a.map((p,f)=>Object.assign({},o,f<c?i[f]:{},e,p))}if(a!==void 0&&a.length>0){const i=Object.assign({},o,e);return a.map(c=>Object.assign({},i,c))}const r=n===void 0||n.length===0?mo:n;return es(t??0,r).map(i=>Object.assign({},i,e))};function Nc(a){return Fc(a,(e,t)=>t in Sn&&e!==void 0)}function Fc(a,e){const t={};return Object.keys(a).forEach(n=>{e(a[n],n)&&(t[n]=a[n])}),t}const zc=u.defineComponent({__name:"component",props:{scale:{default:1},elements:{default:void 0},seed:{default:void 0},seedProps:{default:void 0},color:{default:void 0},distance:{default:void 0},size:{default:void 0},texture:{default:void 0}},setup(a,{expose:e}){const t=a,n=u.shallowRef(),o=u.shallowRef([]),r=u.shallowRef(Nc(t));e({instance:n});const s=new l.TextureLoader,i=new dr,c=[],h=()=>{var d,g,y;for(;c.length;)c.pop();(d=n.value)==null||d.children.forEach(v=>{"dispose"in v&&v.dispose()}),(g=n.value)==null||g.remove(...n.value.children),(y=n.value)==null||y.dispose()},p=d=>{if(typeof d.texture=="string"){const g=d.texture;d.texture=s.load(g),d.texture.name=g}return d.color=H.normalizeColor(d.color),d},f=()=>{for(let d=o.value.length-1;d<c.length;d++)c[d].size=0;o.value.forEach((d,g)=>{c[g].size=d.size*t.scale})},m=()=>{for(;o.value.length>c.length;){const g={...p(o.value[c.length])};c.push(g),i.addElement(g)}o.value.forEach((d,g)=>{const y=c[g],{texture:v,size:_,distance:A,color:b}=d;if(typeof v=="string"){if(y.texture.name!==v){y.texture.dispose();const C=v;y.texture=s.load(C),y.texture.name=C}}else y.texture!==v&&(y.texture.dispose(),y.texture=v);y.size=_,y.distance=A,y.color=H.normalizeColor(b)}),f()};return u.onUnmounted(()=>{h()}),u.onMounted(()=>{var d;(d=n.value)==null||d.add(i),o.value=ts(t.elements,r.value,t.seed,t.seedProps)}),u.watch(()=>[t.color,t.distance,t.size,t.texture],()=>{r.value={color:t.color,distance:t.distance,size:t.size,texture:t.texture}}),u.watch(()=>[r.value,t.elements,t.seed,t.seedProps],()=>{o.value=ts(t.elements,r.value,t.seed,t.seedProps)}),u.watch(()=>t.scale,()=>{f()}),u.watch(()=>o.value,()=>{m()}),(d,g)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"lensflareRef",ref:n},null,512))}}),Vc=u.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(a,{expose:e}){const t=a,n=u.shallowRef();e({instance:n});{const c=Math.random()*1e4,{onBeforeRender:h}=H.useLoop();let p=c;h(({delta:f,invalidate:m})=>{if(!n.value)return;p+=f*t.speed;const d=p*.25,g=n.value;g.rotation.x=Math.cos(d)*.125*t.rotationFactor,g.rotation.y=Math.sin(d)*.125*t.rotationFactor,g.rotation.z=Math.sin(d)*.05*t.rotationFactor,g.position.y=l.MathUtils.mapLinear(Math.sin(d),-1,1,t.range[0],t.range[1])*t.floatFactor,m()})}return(o,r)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps(o.$attrs,{ref_key:"groupRef",ref:n}),[u.renderSlot(o.$slots,"default")],16))}}),Gc=["render-order"],Rc=u.defineComponent({__name:"component",props:{id:{default:1},colorWrite:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,n=u.shallowRef();function o(){var s,i;const r=Array.isArray((s=n.value)==null?void 0:s.material)?n.value.material[0]:(i=n.value)==null?void 0:i.material;r&&(r.colorWrite=t.colorWrite,r.depthWrite=t.depthWrite,r.stencilWrite=!0,r.stencilRef=t.id,r.stencilFunc=l.AlwaysStencilFunc,r.stencilFail=l.ReplaceStencilOp,r.stencilZFail=l.ReplaceStencilOp,r.stencilZPass=l.ReplaceStencilOp)}return u.watchEffect(o),e({instance:n}),(r,s)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"meshRef",ref:n,"render-order":-t.id},[u.renderSlot(r.$slots,"default")],8,Gc))}}),jc=u.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1},local:{type:Boolean,default:!1}},setup(a){const e=a,{camera:t,renderer:n}=H.useTresContext(),{disabled:o,factor:r,ease:s,local:i}=u.toRefs(e),c={};i.value&&(c.target=n.value.domElement,c.type="client");const{x:h,y:p}=Fi(c),{width:f,height:m}=i.value?Di(n.value.domElement):Ko(),d=u.shallowRef(),g=u.ref(),y=u.ref();u.watch([r,s],()=>{g.value=Array.isArray(r.value)?r.value:[r.value,r.value],y.value=Array.isArray(s.value)?s.value:[s.value,s.value]},{immediate:!0});const v=u.computed(()=>(h.value/f.value-.5)*g.value[0]),_=u.computed(()=>-(p.value/m.value-.5)*g.value[1]),{onBeforeRender:A}=H.useLoop();return A(({delta:b,invalidate:C})=>{o.value||!d.value||Number.isNaN(v.value)||Number.isNaN(_.value)||(d.value.position.x+=(v.value-d.value.position.x)*y.value[0]*b,d.value.position.y+=(_.value-d.value.position.y)*y.value[1]*b,C())}),u.watch(()=>d.value,b=>b==null?void 0:b.add(t.value)),(b,C)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:d},null,512))}}),Wc=Vn({screenspace:!1,color:new l.Color("black"),opacity:1,thickness:.05,size:new l.Vector2(1,1)},`#include <common>
971
+ `,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){t===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(t){!!t!="USE_DASH"in this.defines&&(this.needsUpdate=!0),t===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(t){!!t!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),t===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}}const uo=new l.Vector4,Wr=new l.Vector3,Yr=new l.Vector3,Ne=new l.Vector4,Fe=new l.Vector4,et=new l.Vector4,ho=new l.Vector3,fo=new l.Matrix4,ze=new l.Line3,Xr=new l.Vector3,xn=new l.Box3,wn=new l.Sphere,tt=new l.Vector4;let nt,Pt;function Er(a,e,t){return tt.set(0,0,-e,1).applyMatrix4(a.projectionMatrix),tt.multiplyScalar(1/tt.w),tt.x=Pt/t.width,tt.y=Pt/t.height,tt.applyMatrix4(a.projectionMatrixInverse),tt.multiplyScalar(1/tt.w),Math.abs(Math.max(tt.x,tt.y))}function yc(a,e){const t=a.matrixWorld,n=a.geometry,o=n.attributes.instanceStart,r=n.attributes.instanceEnd,s=Math.min(n.instanceCount,o.count);for(let i=0,c=s;i<c;i++){ze.start.fromBufferAttribute(o,i),ze.end.fromBufferAttribute(r,i),ze.applyMatrix4(t);const h=new l.Vector3,p=new l.Vector3;nt.distanceSqToSegment(ze.start,ze.end,p,h),p.distanceTo(h)<Pt*.5&&e.push({point:p,pointOnLine:h,distance:nt.origin.distanceTo(p),object:a,face:null,faceIndex:i,uv:null,[Gn]:null})}}function _c(a,e,t){const n=e.projectionMatrix,r=a.material.resolution,s=a.matrixWorld,i=a.geometry,c=i.attributes.instanceStart,h=i.attributes.instanceEnd,p=Math.min(i.instanceCount,c.count),f=-e.near;nt.at(1,et),et.w=1,et.applyMatrix4(e.matrixWorldInverse),et.applyMatrix4(n),et.multiplyScalar(1/et.w),et.x*=r.x/2,et.y*=r.y/2,et.z=0,ho.copy(et),fo.multiplyMatrices(e.matrixWorldInverse,s);for(let m=0,d=p;m<d;m++){if(Ne.fromBufferAttribute(c,m),Fe.fromBufferAttribute(h,m),Ne.w=1,Fe.w=1,Ne.applyMatrix4(fo),Fe.applyMatrix4(fo),Ne.z>f&&Fe.z>f)continue;if(Ne.z>f){const b=Ne.z-Fe.z,C=(Ne.z-f)/b;Ne.lerp(Fe,C)}else if(Fe.z>f){const b=Fe.z-Ne.z,C=(Fe.z-f)/b;Fe.lerp(Ne,C)}Ne.applyMatrix4(n),Fe.applyMatrix4(n),Ne.multiplyScalar(1/Ne.w),Fe.multiplyScalar(1/Fe.w),Ne.x*=r.x/2,Ne.y*=r.y/2,Fe.x*=r.x/2,Fe.y*=r.y/2,ze.start.copy(Ne),ze.start.z=0,ze.end.copy(Fe),ze.end.z=0;const y=ze.closestPointToPointParameter(ho,!0);ze.at(y,Xr);const v=l.MathUtils.lerp(Ne.z,Fe.z,y),_=v>=-1&&v<=1,A=ho.distanceTo(Xr)<Pt*.5;if(_&&A){ze.start.fromBufferAttribute(c,m),ze.end.fromBufferAttribute(h,m),ze.start.applyMatrix4(s),ze.end.applyMatrix4(s);const b=new l.Vector3,C=new l.Vector3;nt.distanceSqToSegment(ze.start,ze.end,C,b),t.push({point:C,pointOnLine:b,distance:nt.origin.distanceTo(C),object:a,face:null,faceIndex:m,uv:null,[Gn]:null})}}}class vc extends l.Mesh{constructor(e=new Rr,t=new co({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,o=new Float32Array(2*t.count);for(let s=0,i=0,c=t.count;s<c;s++,i+=2)Wr.fromBufferAttribute(t,s),Yr.fromBufferAttribute(n,s),o[i]=i===0?0:o[i-1],o[i+1]=o[i]+Wr.distanceTo(Yr);const r=new l.InstancedInterleavedBuffer(o,2,1);return e.setAttribute("instanceDistanceStart",new l.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new l.InterleavedBufferAttribute(r,1,1)),this}raycast(e,t){const n=this.material.worldUnits,o=e.camera;o===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;nt=e.ray;const s=this.matrixWorld,i=this.geometry,c=this.material;Pt=c.linewidth+r,i.boundingSphere===null&&i.computeBoundingSphere(),wn.copy(i.boundingSphere).applyMatrix4(s);let h;if(n)h=Pt*.5;else{const f=Math.max(o.near,wn.distanceToPoint(nt.origin));h=Er(o,f,c.resolution)}if(wn.radius+=h,nt.intersectsSphere(wn)===!1)return;i.boundingBox===null&&i.computeBoundingBox(),xn.copy(i.boundingBox).applyMatrix4(s);let p;if(n)p=Pt*.5;else{const f=Math.max(o.near,xn.distanceToPoint(nt.origin));p=Er(o,f,c.resolution)}xn.expandByScalar(p),nt.intersectsBox(xn)!==!1&&(n?yc(this,t):_c(this,o,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(uo),this.material.uniforms.resolution.value.set(uo.z,uo.w))}}class xc extends vc{constructor(e=new jr,t=new co({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}class wc extends l.Line{constructor(e,t=1,n=16,o=2){const r=new l.BufferGeometry,s=n+o*2,i=new Float32Array((s*3+3)*3);r.setAttribute("position",new l.BufferAttribute(i,3));const c=new l.LineBasicMaterial({color:65280}),h=new l.LineBasicMaterial({color:16776960});super(r,[h,c]),this.type="PositionalAudioHelper",this.audio=e,this.range=t,this.divisionsInnerAngle=n,this.divisionsOuterAngle=o,this.update()}update(){const e=this.audio,t=this.range,n=this.divisionsInnerAngle,o=this.divisionsOuterAngle,r=l.MathUtils.degToRad(e.panner.coneInnerAngle),s=l.MathUtils.degToRad(e.panner.coneOuterAngle),i=r/2,c=s/2;let h=0,p=0,f,m;const d=this.geometry,g=d.attributes.position;d.clearGroups();function y(v,_,A,b){const C=(_-v)/A;for(g.setXYZ(h,0,0,0),p++,f=v;f<_;f+=C)m=h+p,g.setXYZ(m,Math.sin(f)*t,0,Math.cos(f)*t),g.setXYZ(m+1,Math.sin(Math.min(f+C,_))*t,0,Math.cos(Math.min(f+C,_))*t),g.setXYZ(m+2,0,0,0),p+=3;d.addGroup(h,p,b),h+=p,p=0}y(-c,-i,o,0),y(-i,i,n,1),y(i,c,o,0),g.needsUpdate=!0,r===s&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}function bc(a){return a}function Mc(a){return a*a*a}function Sc(a){return a<.5?4*a*a*a:1-(-2*a+2)**3/2}function Ac(a){return a*a*a*a}function Pc(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375}const ut="https://raw.githubusercontent.com/Tresjs/assets/93976c7d63ac83d4a254a41a10b2362bc17e90c9/textures/lensflare/",po=`${ut}circle.png`,bn=`${ut}circleBlur.png`,Cc=`${ut}circleRainbow.png`,Tc=`${ut}line.png`,Zr=`${ut}poly6.png`,Kr=`${ut}polyStroke6.png`,Ic=`${ut}rays.png`,Mn=`${ut}ring.png`,Oc=`${ut}starThin6.png`,Lc={texture:[Tc,Mn],color:["white"],distance:[0,0],size:[750,1024],length:[0,2]},Dc={texture:[bn],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},kc={texture:[Ic],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},Bc={texture:[po,Cc,Mn,Oc],color:["white"],distance:[0,0],size:[180,512],length:[2,3]},[qr,Qr]=[3679071,132442],mo=[Lc,Dc,kc,Bc,{texture:[bn,po,Mn,Zr,Kr],color:["dimgray","gray","darkgray",qr,Qr],distance:[.5,2.5],size:[20,180],length:[5,21]},{texture:[bn,po,Mn,Zr,Kr],color:["dimgray","gray","darkgray",qr,Qr],distance:[-.6,-.1],size:[180,360],length:[0,5]}],Sn={color:"white",distance:0,size:512,texture:bn},Jr=l.MathUtils.clamp;class Hr{constructor(e=0,t){ue(this,"_getNext");ue(this,"_getGenerator");this._getGenerator=t??this.getMulberry32,this._getNext=this._getGenerator(e)}seed(e){this._getNext=this._getGenerator(e)}rand(){return this._getNext()}float(e,t){return e+this._getNext()*(t-e)}floatSpread(e){return this.float(-.5*e,.5*e)}int(e,t){return e+Math.floor(this._getNext()*(t-e+1))}choice(e){return e.length?e[Math.floor(this._getNext()*e.length)]:null}defaultChoice(e,t){return e.length?e[Math.floor(this._getNext()*e.length)]:t}sample(e,t,n){const o=e.length;t=Jr(t,0,o-1),n=Jr(n??o-1,0,o-1);const r=this.int(t,n),s=this.shuffle(e.map((c,h)=>h)),i=Math.min(e.length,r);return s.slice(0,i).sort().map(c=>e[c])}shuffle(e){return e.map(t=>({value:t,sort:this._getNext()})).sort((t,n)=>t.sort-n.sort).map(({value:t})=>t)}getMulberry32(e=0){return e>0&&e<1&&(e=Math.floor(e*2**16)),()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}}const Uc=[bc,Mc,Sc,Ac,Pc],$r=l.MathUtils.lerp,es=(a=0,e=mo)=>{const n=new Hr(a).choice(Uc);return e.map((o,r)=>{const s=new Hr(a*(r*7907+1)+(typeof o.seed=="number"?o.seed:0)),i=s.int(o.length[0],o.length[1]);return Array.from({length:i}).fill(0).map(()=>{const c=n(s.rand());return{texture:s.defaultChoice(o.texture,Sn.texture),size:$r(o.size[0],o.size[1],n(1-c)),distance:$r(o.distance[0],o.distance[1],c),color:s.defaultChoice(o.color,Sn.color)}})}).flat()},ts=(a,e,t=void 0,n=void 0,o=Sn)=>{if(a!==void 0&&a.length>0&&(typeof t=="number"||typeof n<"u")){const i=es(t??0,n??mo),c=i.length,h=a.length;return c>=h?i.map((p,f)=>Object.assign(p,e,f<h?a[f]:{})):a.map((p,f)=>Object.assign({},o,f<c?i[f]:{},e,p))}if(a!==void 0&&a.length>0){const i=Object.assign({},o,e);return a.map(c=>Object.assign({},i,c))}const r=n===void 0||n.length===0?mo:n;return es(t??0,r).map(i=>Object.assign({},i,e))};function Nc(a){return Fc(a,(e,t)=>t in Sn&&e!==void 0)}function Fc(a,e){const t={};return Object.keys(a).forEach(n=>{e(a[n],n)&&(t[n]=a[n])}),t}const zc=u.defineComponent({__name:"component",props:{scale:{default:1},elements:{default:void 0},seed:{default:void 0},seedProps:{default:void 0},color:{default:void 0},distance:{default:void 0},size:{default:void 0},texture:{default:void 0}},setup(a,{expose:e}){const t=a,n=u.shallowRef(),o=u.shallowRef([]),r=u.shallowRef(Nc(t));e({instance:n});const s=new l.TextureLoader,i=new dr,c=[],h=()=>{var d,g,y;for(;c.length;)c.pop();(d=n.value)==null||d.children.forEach(v=>{"dispose"in v&&v.dispose()}),(g=n.value)==null||g.remove(...n.value.children),(y=n.value)==null||y.dispose()},p=d=>{if(typeof d.texture=="string"){const g=d.texture;d.texture=s.load(g),d.texture.name=g}return d.color=H.normalizeColor(d.color),d},f=()=>{for(let d=o.value.length-1;d<c.length;d++)c[d].size=0;o.value.forEach((d,g)=>{c[g].size=d.size*t.scale})},m=()=>{for(;o.value.length>c.length;){const g={...p(o.value[c.length])};c.push(g),i.addElement(g)}o.value.forEach((d,g)=>{const y=c[g],{texture:v,size:_,distance:A,color:b}=d;if(typeof v=="string"){if(y.texture.name!==v){y.texture.dispose();const C=v;y.texture=s.load(C),y.texture.name=C}}else y.texture!==v&&(y.texture.dispose(),y.texture=v);y.size=_,y.distance=A,y.color=H.normalizeColor(b)}),f()};return u.onUnmounted(()=>{h()}),u.onMounted(()=>{var d;(d=n.value)==null||d.add(i),o.value=ts(t.elements,r.value,t.seed,t.seedProps)}),u.watch(()=>[t.color,t.distance,t.size,t.texture],()=>{r.value={color:t.color,distance:t.distance,size:t.size,texture:t.texture}}),u.watch(()=>[r.value,t.elements,t.seed,t.seedProps],()=>{o.value=ts(t.elements,r.value,t.seed,t.seedProps)}),u.watch(()=>t.scale,()=>{f()}),u.watch(()=>o.value,()=>{m()}),(d,g)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"lensflareRef",ref:n},null,512))}}),Vc=u.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(a,{expose:e}){const t=a,n=u.shallowRef();e({instance:n});{const c=Math.random()*1e4,{onBeforeRender:h}=H.useLoop();let p=c;h(({delta:f,invalidate:m})=>{if(!n.value)return;p+=f*t.speed;const d=p*.25,g=n.value;g.rotation.x=Math.cos(d)*.125*t.rotationFactor,g.rotation.y=Math.sin(d)*.125*t.rotationFactor,g.rotation.z=Math.sin(d)*.05*t.rotationFactor,g.position.y=l.MathUtils.mapLinear(Math.sin(d),-1,1,t.range[0],t.range[1])*t.floatFactor,m()})}return(o,r)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps(o.$attrs,{ref_key:"groupRef",ref:n}),[u.renderSlot(o.$slots,"default")],16))}}),Gc=["render-order"],Rc=u.defineComponent({__name:"component",props:{id:{default:1},colorWrite:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,n=u.shallowRef();function o(){var s,i;const r=Array.isArray((s=n.value)==null?void 0:s.material)?n.value.material[0]:(i=n.value)==null?void 0:i.material;r&&(r.colorWrite=t.colorWrite,r.depthWrite=t.depthWrite,r.stencilWrite=!0,r.stencilRef=t.id,r.stencilFunc=l.AlwaysStencilFunc,r.stencilFail=l.ReplaceStencilOp,r.stencilZFail=l.ReplaceStencilOp,r.stencilZPass=l.ReplaceStencilOp)}return u.watchEffect(o),e({instance:n}),(r,s)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"meshRef",ref:n,"render-order":-t.id},[u.renderSlot(r.$slots,"default")],8,Gc))}}),jc=u.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1},local:{type:Boolean,default:!1}},setup(a){const e=a,{camera:t,renderer:n}=H.useTresContext(),{disabled:o,factor:r,ease:s,local:i}=u.toRefs(e),c={};i.value&&(c.target=n.value.domElement,c.type="client");const{x:h,y:p}=Fi(c),{width:f,height:m}=i.value?Di(n.value.domElement):Ko(),d=u.shallowRef(),g=u.ref(),y=u.ref();u.watch([r,s],()=>{g.value=Array.isArray(r.value)?r.value:[r.value,r.value],y.value=Array.isArray(s.value)?s.value:[s.value,s.value]},{immediate:!0});const v=u.computed(()=>(h.value/f.value-.5)*g.value[0]),_=u.computed(()=>-(p.value/m.value-.5)*g.value[1]),{onBeforeRender:A}=H.useLoop();return A(({delta:b,invalidate:C})=>{o.value||!d.value||Number.isNaN(v.value)||Number.isNaN(_.value)||(d.value.position.x+=(v.value-d.value.position.x)*y.value[0]*b,d.value.position.y+=(_.value-d.value.position.y)*y.value[1]*b,C())}),u.watch(()=>d.value,b=>b==null?void 0:b.add(t.value)),(b,C)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:d},null,512))}}),Wc=Vn({screenspace:!1,color:new l.Color("black"),opacity:1,thickness:.05,size:new l.Vector2(1,1)},`#include <common>
972
972
  #include <morphtarget_pars_vertex>
973
973
  #include <skinning_pars_vertex>
974
974
  uniform float thickness;
@@ -1013,7 +1013,7 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
1013
1013
  * https://github.com/yomotsu/camera-controls
1014
1014
  * (c) 2017 @yomotsu
1015
1015
  * Released under the MIT License.
1016
- */const Oe={LEFT:1,RIGHT:2,MIDDLE:4},$=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ft={NONE:0,IN:1,OUT:-1};function Ct(a){return a.isPerspectiveCamera}function vt(a){return a.isOrthographicCamera}const zt=Math.PI*2,ss=Math.PI/2,is=1e-5,Ht=Math.PI/180;function $e(a,e,t){return Math.max(e,Math.min(t,a))}function Te(a,e=is){return Math.abs(a)<e}function Se(a,e,t=is){return Te(a-e,t)}function as(a,e){return Math.round(a/e)*e}function $t(a){return isFinite(a)?a:a<0?-Number.MAX_VALUE:Number.MAX_VALUE}function en(a){return Math.abs(a)<Number.MAX_VALUE?a:a*(1/0)}function Pn(a,e,t,n,o=1/0,r){n=Math.max(1e-4,n);const s=2/n,i=s*r,c=1/(1+i+.48*i*i+.235*i*i*i);let h=a-e;const p=e,f=o*n;h=$e(h,-f,f),e=a-h;const m=(t.value+s*h)*r;t.value=(t.value-s*m)*c;let d=e+(h+m)*c;return p-a>0==d>p&&(d=p,t.value=(d-p)/r),d}function ls(a,e,t,n,o=1/0,r,s){n=Math.max(1e-4,n);const i=2/n,c=i*r,h=1/(1+c+.48*c*c+.235*c*c*c);let p=e.x,f=e.y,m=e.z,d=a.x-p,g=a.y-f,y=a.z-m;const v=p,_=f,A=m,b=o*n,C=b*b,L=d*d+g*g+y*y;if(L>C){const X=Math.sqrt(L);d=d/X*b,g=g/X*b,y=y/X*b}p=a.x-d,f=a.y-g,m=a.z-y;const M=(t.x+i*d)*r,P=(t.y+i*g)*r,w=(t.z+i*y)*r;t.x=(t.x-i*M)*h,t.y=(t.y-i*P)*h,t.z=(t.z-i*w)*h,s.x=p+(d+M)*h,s.y=f+(g+P)*h,s.z=m+(y+w)*h;const S=v-a.x,x=_-a.y,I=A-a.z,D=s.x-v,z=s.y-_,G=s.z-A;return S*D+x*z+I*G>0&&(s.x=v,s.y=_,s.z=A,t.x=(s.x-v)/r,t.y=(s.y-_)/r,t.z=(s.z-A)/r),s}function go(a,e){e.set(0,0),a.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=a.length,e.y/=a.length}function yo(a,e){return vt(a)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class du{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const o=this._listeners[e];if(o!==void 0){const r=o.indexOf(t);r!==-1&&o.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const o=n.slice(0);for(let r=0,s=o.length;r<s;r++)o[r].call(this,e)}}}var _o;const pu="2.9.0",Cn=1/8,mu=/Mac/.test((_o=globalThis==null?void 0:globalThis.navigator)===null||_o===void 0?void 0:_o.platform);let pe,cs,Tn,vo,je,ye,be,Vt,tn,rt,st,Tt,us,hs,Qe,nn,Gt,fs,xo,ds,wo,bo,In;class Ve extends du{static install(e){pe=e.THREE,cs=Object.freeze(new pe.Vector3(0,0,0)),Tn=Object.freeze(new pe.Vector3(0,1,0)),vo=Object.freeze(new pe.Vector3(0,0,1)),je=new pe.Vector2,ye=new pe.Vector3,be=new pe.Vector3,Vt=new pe.Vector3,tn=new pe.Vector3,rt=new pe.Vector3,st=new pe.Vector3,Tt=new pe.Vector3,us=new pe.Vector3,hs=new pe.Vector3,Qe=new pe.Spherical,nn=new pe.Spherical,Gt=new pe.Box3,fs=new pe.Box3,xo=new pe.Sphere,ds=new pe.Quaternion,wo=new pe.Quaternion,bo=new pe.Matrix4,In=new pe.Raycaster}static get ACTION(){return $}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=$.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ft.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new pe.Vector3,this._focalOffsetVelocity=new pe.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,A,b)=>{let C,L;if(Ct(this._camera)){const M=ye.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*Ht,w=M.length()*Math.tan(P*.5);C=this.truckSpeed*_*w/this._elementRect.height,L=this.truckSpeed*A*w/this._elementRect.height}else if(vt(this._camera)){const M=this._camera;C=_*(M.right-M.left)/M.zoom/this._elementRect.width,L=A*(M.top-M.bottom)/M.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(C,0,!0),this.forward(-L,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+L,this._focalOffsetEnd.z,!0):this.truck(C,L,!0)},this._rotateInternal=(_,A)=>{const b=zt*this.azimuthRotateSpeed*_/this._elementRect.height,C=zt*this.polarRotateSpeed*A/this._elementRect.height;this.rotate(b,C,!0)},this._dollyInternal=(_,A,b)=>{const C=Math.pow(.95,-_*this.dollySpeed),L=this._sphericalEnd.radius,M=this._sphericalEnd.radius*C,P=$e(M,this.minDistance,this.maxDistance),w=P-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(w,!0),this._dollyToNoClamp(P,!0)):this._dollyToNoClamp(P,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:P)-L,this._dollyControlCoord.set(A,b)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,A,b)=>{const C=Math.pow(.95,_*this.dollySpeed),L=this._zoom,M=this._zoom*C;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-L,this._dollyControlCoord.set(A,b))},typeof pe>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new pe.Quaternion().setFromUnitVectors(this._camera.up,Tn),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=$.NONE,this._target=new pe.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new pe.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new pe.Spherical().setFromVector3(ye.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new pe.Vector3,new pe.Vector3,new pe.Vector3,new pe.Vector3],this._updateNearPlaneCorners(),this._boundary=new pe.Box3(new pe.Vector3(-1/0,-1/0,-1/0),new pe.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new pe.Vector2,this.mouseButtons={left:$.ROTATE,middle:$.DOLLY,right:$.TRUCK,wheel:Ct(this._camera)?$.DOLLY:vt(this._camera)?$.ZOOM:$.NONE},this.touches={one:$.TOUCH_ROTATE,two:Ct(this._camera)?$.TOUCH_DOLLY_TRUCK:vt(this._camera)?$.TOUCH_ZOOM_TRUCK:$.NONE,three:$.TOUCH_TRUCK};const n=new pe.Vector2,o=new pe.Vector2,r=new pe.Vector2,s=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),L=_.clientX/C.width,M=_.clientY/C.height;if(L<this._interactiveArea.left||L>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const A=_.pointerType!=="mouse"?null:(_.buttons&Oe.LEFT)===Oe.LEFT?Oe.LEFT:(_.buttons&Oe.MIDDLE)===Oe.MIDDLE?Oe.MIDDLE:(_.buttons&Oe.RIGHT)===Oe.RIGHT?Oe.RIGHT:null;if(A!==null){const C=this._findPointerByMouseButton(A);C&&this._disposePointer(C)}if((_.buttons&Oe.LEFT)===Oe.LEFT&&this._lockedPointer)return;const b={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:A};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,m(_)},i=_=>{_.cancelable&&_.preventDefault();const A=_.pointerId,b=this._lockedPointer||this._findPointerById(A);if(b){if(b.clientX=_.clientX,b.clientY=_.clientY,b.deltaX=_.movementX,b.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&Oe.LEFT)===Oe.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&Oe.MIDDLE)===Oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&Oe.RIGHT)===Oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);d()}},c=_=>{const A=this._findPointerById(_.pointerId);if(!(A&&A===this._lockedPointer)){if(A&&this._disposePointer(A),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=$.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=$.NONE;g()}};let h=-1;const p=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===$.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),P=_.clientX/M.width,w=_.clientY/M.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||w<this._interactiveArea.top||w>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===$.ROTATE||this.mouseButtons.wheel===$.TRUCK){const M=performance.now();h-M<1e3&&this._getClientRect(this._elementRect),h=M}const A=mu?-1:-3,b=_.deltaMode===1?_.deltaY/A:_.deltaY/(A*10),C=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,L=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case $.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case $.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case $.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case $.DOLLY:{this._dollyInternal(-b,C,L),this._isUserControllingDolly=!0;break}case $.ZOOM:{this._zoomInternal(-b,C,L),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Ve.ACTION.NONE){const A=_ instanceof PointerEvent?_.pointerId:0,b=this._findPointerById(A);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}_.preventDefault()}},m=_=>{if(!this._enabled)return;if(go(this._activePointers,je),this._getClientRect(this._elementRect),n.copy(je),o.copy(je),this._activePointers.length>=2){const b=je.x-this._activePointers[1].clientX,C=je.y-this._activePointers[1].clientY,L=Math.sqrt(b*b+C*C);r.set(0,L);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,P=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;o.set(M,P)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&Oe.LEFT)===Oe.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&Oe.MIDDLE)===Oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&Oe.RIGHT)===Oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&$.DOLLY)===$.DOLLY||(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&$.ZOOM)===$.ZOOM||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,go(this._activePointers,je);const A=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=A?-A.deltaX:o.x-je.x,C=A?-A.deltaY:o.y-je.y;if(o.copy(je),((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,C),this._isUserControllingRotate=!0),(this._state&$.DOLLY)===$.DOLLY||(this._state&$.ZOOM)===$.ZOOM){const L=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,P=this.dollyDragInverted?-1:1;(this._state&$.DOLLY)===$.DOLLY?(this._dollyInternal(P*C*Cn,L,M),this._isUserControllingDolly=!0):(this._zoomInternal(P*C*Cn,L,M),this._isUserControllingZoom=!0)}if((this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE){const L=je.x-this._activePointers[1].clientX,M=je.y-this._activePointers[1].clientY,P=Math.sqrt(L*L+M*M),w=r.y-P;r.set(0,P);const S=this.dollyToCursor?(o.x-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(o.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET?(this._dollyInternal(w*Cn,S,x),this._isUserControllingDolly=!0):(this._zoomInternal(w*Cn,S,x),this._isUserControllingZoom=!0)}((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,C,!1),this._isUserControllingTruck=!0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{go(this._activePointers,je),o.copy(je),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",y),this._domElement.ownerDocument.addEventListener("pointerlockerror",v),this._domElement.ownerDocument.addEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),m())},this.unlockPointer=()=>{var _,A,b;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(A=this._domElement)===null||A===void 0||A.ownerDocument.removeEventListener("pointerlockchange",y),(b=this._domElement)===null||b===void 0||b.ownerDocument.removeEventListener("pointerlockerror",v),this.cancel()};const y=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},v=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",s),this._domElement.addEventListener("pointercancel",c),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",s),this._domElement.removeEventListener("pointercancel",c),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.removeEventListener("pointerlockchange",y),this._domElement.ownerDocument.removeEventListener("pointerlockerror",v))},this.cancel=()=>{this._state!==$.NONE&&(this._state=$.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=$e(e.width,0,1),this._interactiveArea.height=$e(e.height,0,1),this._interactiveArea.x=$e(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=$e(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const o=$e(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=$e(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=o,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const s=!n||Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(s)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0,this._dollyToNoClamp($e(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const s=this._collisionTest(),i=Se(s,this._spherical.radius);if(!(n>e)&&i)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,s)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(tn).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=$e(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Se(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),rt.setFromMatrixColumn(this._camera.matrix,0),st.setFromMatrixColumn(this._camera.matrix,1),rt.multiplyScalar(e),st.multiplyScalar(-t);const o=ye.copy(rt).add(st),r=be.copy(this._targetEnd).add(o);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){ye.setFromMatrixColumn(this._camera.matrix,0),ye.crossVectors(this._camera.up,ye),ye.multiplyScalar(e);const n=be.copy(this._targetEnd).add(ye);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return ye.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ye.x,this._targetEnd.y+ye.y,this._targetEnd.z+ye.z,t)}moveTo(e,t,n,o=!1){this._isUserControllingTruck=!1;const r=ye.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,o||this._target.copy(this._targetEnd);const s=!o||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}lookInDirectionOf(e,t,n,o=!1){const i=ye.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(i.x,i.y,i.z,o)}fitToBox(e,t,{cover:n=!1,paddingLeft:o=0,paddingRight:r=0,paddingBottom:s=0,paddingTop:i=0}={}){const c=[],h=e.isBox3?Gt.copy(e):Gt.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=as(this._sphericalEnd.theta,ss),f=as(this._sphericalEnd.phi,ss);c.push(this.rotateTo(p,f,t));const m=ye.setFromSpherical(this._sphericalEnd).normalize(),d=ds.setFromUnitVectors(m,vo),g=Se(Math.abs(m.y),1);g&&d.multiply(wo.setFromAxisAngle(Tn,p)),d.multiply(this._yAxisUpSpaceInverse);const y=fs.makeEmpty();be.copy(h.min).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setX(h.max.x).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setY(h.max.y).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setZ(h.min.z).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setZ(h.max.z).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setY(h.min.y).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setX(h.min.x).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).applyQuaternion(d),y.expandByPoint(be),y.min.x-=o,y.min.y-=s,y.max.x+=r,y.max.y+=i,d.setFromUnitVectors(vo,m),g&&d.premultiply(wo.invert()),d.premultiply(this._yAxisUpSpace);const v=y.getSize(ye),_=y.getCenter(be).applyQuaternion(d);if(Ct(this._camera)){const A=this.getDistanceToFitBox(v.x,v.y,v.z,n);c.push(this.moveTo(_.x,_.y,_.z,t)),c.push(this.dollyTo(A,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(vt(this._camera)){const A=this._camera,b=A.right-A.left,C=A.top-A.bottom,L=n?Math.max(b/v.x,C/v.y):Math.min(b/v.x,C/v.y);c.push(this.moveTo(_.x,_.y,_.z,t)),c.push(this.zoomTo(L,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const n=[],r="isObject3D"in e?Ve.createBoundingSphere(e,xo):xo.copy(e);if(n.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),Ct(this._camera)){const s=this.getDistanceToFitSphere(r.radius);n.push(this.dollyTo(s,t))}else if(vt(this._camera)){const s=this._camera.right-this._camera.left,i=this._camera.top-this._camera.bottom,c=2*r.radius,h=Math.min(s/c,i/c);n.push(this.zoomTo(h,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,o,r,s,i=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const c=be.set(o,r,s),h=ye.set(e,t,n);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(h.sub(c).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,i||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!i||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,n,o,r,s,i,c,h,p,f,m,d,g=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const y=ye.set(o,r,s),v=be.set(e,t,n);Qe.setFromVector3(v.sub(y).applyQuaternion(this._yAxisUpSpace));const _=Vt.set(p,f,m),A=be.set(i,c,h);nn.setFromVector3(A.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(_,d));const b=nn.theta-Qe.theta,C=nn.phi-Qe.phi,L=nn.radius-Qe.radius;this._sphericalEnd.set(Qe.radius+L*d,Qe.phi+C*d,Qe.theta+b*d),this.normalizeRotations(),this._needsUpdate=!0,g||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const M=!g||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(M)}setPosition(e,t,n,o=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,o)}setTarget(e,t,n,o=!1){const r=this.getPosition(ye),s=this.setLookAt(r.x,r.y,r.z,e,t,n,o);return this._sphericalEnd.phi=$e(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),s}setFocalOffset(e,t,n,o=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,o||this._focalOffset.copy(this._focalOffsetEnd);const r=!o||Se(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Se(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Se(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),rt.setFromMatrixColumn(this._camera.matrixWorldInverse,0),st.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Tt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const o=ye.set(e,t,n),r=o.distanceTo(this._camera.position),s=o.sub(this._camera.position);rt.multiplyScalar(s.x),st.multiplyScalar(s.y),Tt.multiplyScalar(s.z),ye.copy(rt).add(st).add(Tt),ye.z=ye.z+r,this.dollyTo(r,!1),this.setFocalOffset(-ye.x,ye.y,-ye.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,o){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new pe.Vector4,typeof e=="number"?this._viewport.set(e,t,n,o):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,o=!1){if(yo(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,s=this._camera.getEffectiveFOV()*Ht,i=this._camera.aspect;return((o?r>i:r<i)?t:e/i)*.5/Math.tan(s*.5)+n*.5}getDistanceToFitSphere(e){if(yo(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Ht,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,o=1<this._camera.aspect?t:n;return e/Math.sin(o*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new pe.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%zt,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=zt),this._spherical.theta+=zt*Math.round((this._sphericalEnd.theta-this._spherical.theta)/zt)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Se(this._camera.up.x,this._cameraUp0.x)||!Se(this._camera.up.y,this._cameraUp0.y)||!Se(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Tn),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ye.subVectors(this._target,this._camera.position).normalize(),t=be.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,o=this._sphericalEnd.radius-this._spherical.radius,r=us.subVectors(this._targetEnd,this._target),s=hs.subVectors(this._focalOffsetEnd,this._focalOffset),i=this._zoomEnd-this._zoom;if(Te(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Pn(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,f,1/0,e),this._needsUpdate=!0}if(Te(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Pn(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,f,1/0,e),this._needsUpdate=!0}if(Te(o))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const f=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Pn(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,f,this.maxSpeed,e),this._needsUpdate=!0}if(Te(r.x)&&Te(r.y)&&Te(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const f=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;ls(this._target,this._targetEnd,this._targetVelocity,f,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Te(s.x)&&Te(s.y)&&Te(s.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const f=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;ls(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,f,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Te(i))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const f=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Pn(this._zoom,this._zoomEnd,this._zoomVelocity,f,1/0,e)}if(this.dollyToCursor){if(Ct(this._camera)&&this._changedDolly!==0){const f=this._spherical.radius-this._lastDistance,m=this._camera,d=this._getCameraDirection(tn),g=ye.copy(d).cross(m.up).normalize();g.lengthSq()===0&&(g.x=1);const y=be.crossVectors(g,d),v=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*Ht*.5),A=(this._sphericalEnd.radius-f-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=Vt.copy(this._targetEnd).add(g.multiplyScalar(this._dollyControlCoord.x*v*m.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*v)),C=ye.copy(this._targetEnd).lerp(b,A),L=this._lastDollyDirection===Ft.IN&&this._spherical.radius<=this.minDistance,M=this._lastDollyDirection===Ft.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(L||M)){this._sphericalEnd.radius-=f,this._spherical.radius-=f;const w=be.copy(d).multiplyScalar(-f);C.add(w)}this._boundary.clampPoint(C,C);const P=be.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(P),this._changedDolly-=f,Te(this._changedDolly)&&(this._changedDolly=0)}else if(vt(this._camera)&&this._changedZoom!==0){const f=this._zoom-this._lastZoom,m=this._camera,d=ye.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),g=be.set(0,0,-1).applyQuaternion(m.quaternion),y=Vt.copy(d).add(g.multiplyScalar(-d.dot(m.up))),_=-(this._zoom-f-this._zoom)/this._zoom,A=this._getCameraDirection(tn),b=this._targetEnd.dot(A),C=ye.copy(this._targetEnd).lerp(y,_),L=C.dot(A),M=A.multiplyScalar(L-b);C.sub(M),this._boundary.clampPoint(C,C);const P=be.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(P),this._changedZoom-=f,Te(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Te(this._focalOffset.x)||!Te(this._focalOffset.y)||!Te(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),rt.setFromMatrixColumn(this._camera.matrix,0),st.setFromMatrixColumn(this._camera.matrix,1),Tt.setFromMatrixColumn(this._camera.matrix,2),rt.multiplyScalar(this._focalOffset.x),st.multiplyScalar(-this._focalOffset.y),Tt.multiplyScalar(this._focalOffset.z),ye.copy(rt).add(st).add(Tt),this._camera.position.add(ye)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ye.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),Te(t,this.restThreshold)&&Te(n,this.restThreshold)&&Te(o,this.restThreshold)&&Te(r.x,this.restThreshold)&&Te(r.y,this.restThreshold)&&Te(r.z,this.restThreshold)&&Te(s.x,this.restThreshold)&&Te(s.y,this.restThreshold)&&Te(s.z,this.restThreshold)&&Te(i,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:$t(this.maxDistance),minZoom:this.minZoom,maxZoom:$t(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:$t(this.maxPolarAngle),minAzimuthAngle:$t(this.minAzimuthAngle),maxAzimuthAngle:$t(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:ye.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=en(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=en(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=en(n.maxPolarAngle),this.minAzimuthAngle=en(n.minAzimuthAngle),this.maxAzimuthAngle=en(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Qe.setFromVector3(ye.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Qe.theta,Qe.phi,t),this.dollyTo(Qe.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",pu),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const o=t.lengthSq();if(o===0)return e;const r=be.copy(t).add(e),i=this._boundary.clampPoint(r,Vt).sub(r),c=i.lengthSq();if(c===0)return e.add(t);if(c===o)return e;if(n===0)return e.add(t).add(i);{const h=1+n*c/t.dot(i);return e.add(be.copy(t).multiplyScalar(h)).add(i.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Ct(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Ht,o=Math.tan(n*.5)*t,r=o*e.aspect;this._nearPlaneCorners[0].set(-r,-o,0),this._nearPlaneCorners[1].set(r,-o,0),this._nearPlaneCorners[2].set(r,o,0),this._nearPlaneCorners[3].set(-r,o,0)}else if(vt(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,o=e.right*t,r=e.top*t,s=e.bottom*t;this._nearPlaneCorners[0].set(n,r,0),this._nearPlaneCorners[1].set(o,r,0),this._nearPlaneCorners[2].set(o,s,0),this._nearPlaneCorners[3].set(n,s,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||yo(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(tn);bo.lookAt(cs,n,this._camera.up);for(let o=0;o<4;o++){const r=be.copy(this._nearPlaneCorners[o]);r.applyMatrix4(bo);const s=Vt.addVectors(this._target,r);In.set(s,n),In.far=this._spherical.radius+1;const i=In.intersectObjects(this.colliderMeshes);i.length!==0&&i[0].distance<e&&(e=i[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new pe.Sphere){const n=t,o=n.center;Gt.makeEmpty(),e.traverseVisible(s=>{s.isMesh&&Gt.expandByObject(s)}),Gt.getCenter(o);let r=0;return e.traverseVisible(s=>{if(!s.isMesh)return;const i=s,c=i.geometry.clone();c.applyMatrix4(i.matrixWorld);const p=c.attributes.position;for(let f=0,m=p.count;f<m;f++)ye.fromBufferAttribute(p,f),r=Math.max(r,o.distanceToSquared(ye))}),n.radius=Math.sqrt(r),n}}const ps=a=>!!(a&&a.isPerspectiveCamera),ms=a=>!!(a&&a.isOrthographicCamera),gu=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","distance","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args","mouse-buttons","touches"],gs=(a,e)=>({left:Ve.ACTION.ROTATE,middle:Ve.ACTION.DOLLY,right:Ve.ACTION.TRUCK,wheel:ps(a)?Ve.ACTION.DOLLY:ms(a)?Ve.ACTION.ZOOM:Ve.ACTION.NONE,...e}),ys=(a,e)=>({one:Ve.ACTION.TOUCH_ROTATE,two:ps(a)?Ve.ACTION.TOUCH_DOLLY_TRUCK:ms(a)?Ve.ACTION.TOUCH_ZOOM_TRUCK:Ve.ACTION.NONE,three:Ve.ACTION.TOUCH_TRUCK,...e}),yu=u.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},distance:{default:()=>H.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:Number.POSITIVE_INFINITY},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:Number.POSITIVE_INFINITY},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:Number.POSITIVE_INFINITY},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{default:()=>gs(H.useTresContext().camera.value)},touches:{default:()=>ys(H.useTresContext().camera.value)}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,o=t,{makeDefault:r,minPolarAngle:s,maxPolarAngle:i,minAzimuthAngle:c,maxAzimuthAngle:h,distance:p,minDistance:f,maxDistance:m,infinityDolly:d,minZoom:g,maxZoom:y,smoothTime:v,draggingSmoothTime:_,maxSpeed:A,azimuthRotateSpeed:b,polarRotateSpeed:C,dollySpeed:L,dollyDragInverted:M,truckSpeed:P,dollyToCursor:w,dragToOffset:S,verticalDragToForward:x,boundaryFriction:I,restThreshold:D,colliderMeshes:z}=u.toRefs(n),G={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};Ve.install({THREE:G});const{camera:X,renderer:E,extend:te,controls:q,invalidate:oe}=H.useTresContext();u.watch(n,()=>{oe()});const ne=u.computed(()=>gs(n.camera||X.value,n.mouseButtons)),ce=u.computed(()=>ys(n.camera||X.value,n.touches)),le=u.shallowRef(null);te({CameraControls:Ve}),u.watchEffect(()=>{de(),le.value&&r.value?q.value=le.value:q.value=null});function de(){Ce(le.value,"update",()=>{o("change",le.value),oe()}),Ce(le.value,"controlend",()=>o("end",le.value)),Ce(le.value,"controlstart",()=>o("start",le.value))}const{onBeforeRender:k}=H.useLoop();return k(({delta:V,invalidate:U})=>{var B,R;(B=le.value)!=null&&B.enabled&&((R=le.value)==null||R.update(V),U())}),u.onUnmounted(()=>{le.value&&le.value.disconnect()}),e({instance:le}),(V,U)=>(V.camera||u.unref(X))&&(V.domElement||u.unref(E))?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:le,"min-polar-angle":u.unref(s),"max-polar-angle":u.unref(i),"min-azimuth-angle":u.unref(c),"max-azimuth-angle":u.unref(h),distance:u.unref(p),"min-distance":u.unref(f),"max-distance":u.unref(m),"infinity-dolly":u.unref(d),"min-zoom":u.unref(g),"max-zoom":u.unref(y),"smooth-time":u.unref(v),"dragging-smooth-time":u.unref(_),"max-speed":u.unref(A),"azimuth-rotate-speed":u.unref(b),"polar-rotate-speed":u.unref(C),"dolly-speed":u.unref(L),"dolly-drag-inverted":u.unref(M),"truck-speed":u.unref(P),"dolly-to-cursor":u.unref(w),"drag-to-offset":u.unref(S),"vertical-drag-to-forward":u.unref(x),"boundary-friction":u.unref(I),"rest-threshold":u.unref(D),"collider-meshes":u.unref(z),args:[V.camera||u.unref(X),V.domElement||u.unref(E).domElement],"mouse-buttons":ne.value,touches:ce.value},null,8,gu)):u.createCommentVNode("",!0)}}),_u=u.defineComponent({__name:"KeyboardControls",props:{makeDefault:{type:Boolean,default:!0},camera:{},domElement:{},moveSpeed:{default:.2},selector:{}},emits:["isLock","change"],setup(a,{expose:e,emit:t}){const n=a,o=t,{moveSpeed:r}=u.toRefs(n),{camera:s,controls:i,renderer:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.ref(0),f=u.ref(0),{KeyW:m,KeyA:d,KeyS:g,KeyD:y,Up:v,Down:_,Left:A,Right:b}=Ui();u.watchEffect(()=>{d.value||A.value?p.value=-r.value:y.value||b.value?p.value=r.value:p.value=0,m.value||v.value?f.value=r.value:g.value||_.value?f.value=-r.value:f.value=0}),e({instance:i});const C=I=>o("isLock",I),L=I=>o("change",I),M=new l.Vector3,P=new l.Vector3,w=new l.Quaternion,S=(I,D)=>{var X;if(!((X=s.value)!=null&&X.position)&&!M)return;const z=s.value,G=I*.001;z==null||z.translateZ(-D),w.set(P.x*G,P.y*G,P.z*G,1).normalize(),z==null||z.quaternion.multiply(w),(p.value||f.value)&&o("change",i.value)},{onBeforeRender:x}=H.useLoop();return x(({delta:I,invalidate:D})=>{var z;i.value instanceof _r&&((z=i.value)!=null&&z.isLocked)&&(S(I,f.value),i.value.moveRight(p.value),D())}),(I,D)=>(u.openBlock(),u.createBlock(u.unref(_s),{selector:I.selector,"make-default":I.makeDefault,camera:I.camera||u.unref(s),"dom-element":I.domElement||u.unref(c).domElement,onIsLock:C,onChange:L},null,8,["selector","make-default","camera","dom-element"]))}}),vu=["args","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","enable-zoom","zoom-speed","enable-rotate","rotate-speed"],xu=u.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,{autoRotate:o,autoRotateSpeed:r,enableDamping:s,dampingFactor:i,enablePan:c,keyPanSpeed:h,maxAzimuthAngle:p,minAzimuthAngle:f,maxPolarAngle:m,minPolarAngle:d,minDistance:g,maxDistance:y,minZoom:v,maxZoom:_,enableZoom:A,zoomSpeed:b,enableRotate:C,rotateSpeed:L}=u.toRefs(n),{camera:M,renderer:P,extend:w,controls:S,invalidate:x}=H.useTresContext();u.watch(n,()=>{x()});const I=u.shallowRef(null);w({MapControls:rl}),u.watch(S,z=>{z&&n.makeDefault?S.value=z:S.value=null});const{onBeforeRender:D}=H.useLoop();return D(({invalidate:z})=>{I.value&&(s.value||o.value)&&(I.value.update(),z())}),u.onUnmounted(()=>{I.value&&I.value.dispose()}),e({instance:I}),(z,G)=>(z.camera||u.unref(M))&&(z.domElement||u.unref(P))?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:I,args:[z.camera||u.unref(M),z.domElement||u.unref(P).domElement],"auto-rotate":u.unref(o),"auto-rotate-speed":u.unref(r),"enable-damping":u.unref(s),"damping-factor":u.unref(i),"enable-pan":u.unref(c),"key-pan-speed":u.unref(h),keys:z.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(f),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(d),"min-distance":u.unref(g),"max-distance":u.unref(y),"min-zoom":u.unref(v),"max-zoom":u.unref(_),"enable-zoom":u.unref(A),"zoom-speed":u.unref(b),"enable-rotate":u.unref(C),"rotate-speed":u.unref(L)},null,8,vu)):u.createCommentVNode("",!0)}}),wu=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","args"],bu=u.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,o=t,{makeDefault:r,autoRotate:s,autoRotateSpeed:i,enableDamping:c,dampingFactor:h,enablePan:p,keyPanSpeed:f,maxAzimuthAngle:m,minAzimuthAngle:d,maxPolarAngle:g,minPolarAngle:y,minDistance:v,maxDistance:_,minZoom:A,maxZoom:b,enableZoom:C,zoomSpeed:L,enableRotate:M,touches:P,rotateSpeed:w,target:S}=u.toRefs(n),{camera:x,renderer:I,extend:D,controls:z,invalidate:G}=H.useTresContext(),X=u.shallowRef(null);D({OrbitControls:wr}),u.watch(X,q=>{E(),q&&r.value?z.value=q:z.value=null});function E(){Ce(X.value,"change",()=>{o("change",X.value),G()}),Ce(X.value,"start",()=>o("start",X.value)),Ce(X.value,"end",()=>o("end",X.value))}const{onBeforeRender:te}=H.useLoop();return te(({invalidate:q})=>{X.value&&(c.value||s.value)&&(X.value.update(),s.value&&q())}),u.onUnmounted(()=>{X.value&&X.value.dispose()}),e({instance:X}),(q,oe)=>(q.camera||u.unref(x))&&(q.domElement||u.unref(I))?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:X,target:u.unref(S),"auto-rotate":u.unref(s),"auto-rotate-speed":u.unref(i),"enable-damping":u.unref(c),"damping-factor":u.unref(h),"enable-pan":u.unref(p),"key-pan-speed":u.unref(f),keys:q.keys,"max-azimuth-angle":u.unref(m),"min-azimuth-angle":u.unref(d),"max-polar-angle":u.unref(g),"min-polar-angle":u.unref(y),"min-distance":u.unref(v),"max-distance":u.unref(_),"min-zoom":u.unref(A),"max-zoom":u.unref(b),touches:u.unref(P),"enable-zoom":u.unref(C),"zoom-speed":u.unref(L),"enable-rotate":u.unref(M),"rotate-speed":u.unref(w),args:[q.camera||u.unref(x),q.domElement||u.unref(I).domElement]},null,8,wu)):u.createCommentVNode("",!0)}}),Mu=["args"],_s=u.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock","change"],setup(a,{expose:e,emit:t}){const n=a,o=t,{camera:r,renderer:s,extend:i,controls:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.shallowRef(null);let f;i({PointerLockControls:_r});const m=d=>{o("isLock",d)};return u.watch(p,d=>{d&&n.makeDefault?c.value=d:c.value=null,f=document.getElementById(n.selector||"")||s.value.domElement,Ce(f,"click",()=>{p.value&&(p.value.lock(),p.value.addEventListener("lock",()=>m(!0)),p.value.addEventListener("unlock",()=>m(!1)),h())})}),u.onUnmounted(()=>{const d=p.value;d&&(d.removeEventListener("lock",()=>m(!0)),d.removeEventListener("unlock",()=>m(!1)),d.dispose())}),e({instance:c}),(d,g)=>(d.camera||u.unref(r))&&(d.domElement||u.unref(s))?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:p,args:[d.camera||u.unref(r),d.domElement||u.unref(s).domElement]},null,8,Mu)):u.createCommentVNode("",!0)}}),Su=u.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(a,{expose:e,emit:t}){const n=a,o=t,{logWarning:r}=H.useLogger();n.smoothScroll<0&&r("SmoothControl must be greater than zero"),n.pages<0&&r("Pages must be greater than zero");const{camera:s,controls:i,renderer:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.shallowRef(),f=document.createElement("div"),{y:m}=zi(),{x:d,y:g,isScrolling:y}=ki(f),{height:v,width:_}=Ko();let A=0;const b=u.ref(!1),C=u.ref(0),L=u.ref(0),M=u.ref(0),P=n.horizontal?"x":"y",w=u.watch(s,x=>{if(b.value){w();return}A=n.horizontal?(x==null?void 0:x.position.x)||0:(x==null?void 0:x.position.y)||0,b.value=!0},{immediate:!0});u.watch(y,x=>{i.value&&(i.value.enabled=!x)},{immediate:!0}),u.watch(m,x=>{!y.value&&!n.htmlScroll||(L.value=x/v.value/(M.value/v.value-1),C.value=-1*L.value,o("update:modelValue",L.value))}),u.watch(g,x=>{L.value=x/v.value/(M.value/v.value),C.value=-1*L.value,o("update:modelValue",L.value)}),u.watch(d,x=>{L.value=x/_.value/(M.value/_.value-1),C.value=+L.value,o("update:modelValue",L.value)}),u.watch(c,x=>{var D,z;const I=x==null?void 0:x.domElement;if(n.htmlScroll&&(x!=null&&x.domElement))I!=null&&I.style.width&&(I!=null&&I.style.position)&&(I!=null&&I.style.top)&&(I!=null&&I.style.left)&&(I.style.width="100%",I.style.position="fixed",I.style.zIndex=" -99999",I.style.top="0",I.style.left="0"),M.value=document.body.scrollHeight;else{const G=document.createElement("div"),X=document.createElement("div");f.style[n.horizontal?"overflowX":"overflowY"]="auto",f.style[n.horizontal?"overflowY":"overflowX"]="hidden",f.style.position="absolute",f.style.width="100%",f.style.height=" 100%",f.style.top="0",f.style.left="0",f.classList.add("scrollContainer"),G.style.position="sticky",G.style.top="0px",G.style.left="0px",G.style.width="100%",G.style.height="100%",G.style.overflow="hidden",f.appendChild(G),X.style.height=n.horizontal?"100%":`${v.value*n.pages}px`,X.style.width=n.horizontal?`${_.value*n.pages}px`:"100vw",X.style.pointerEvents="none",I.style.position="fixed",I.style.zIndex="0",I!=null&&I.style.width&&(I.style.width="100%"),f.appendChild(X),x!=null&&x.domElement.parentNode&&(x.domElement.parentNode.style.position="relative"),(z=(D=x==null?void 0:x.domElement)==null?void 0:D.parentNode)==null||z.appendChild(f),M.value=n.horizontal?_.value*n.pages:v.value*n.pages}},{immediate:!0});const{onBeforeRender:S}=H.useLoop();return S(({invalidate:x})=>{var I;if((I=s.value)!=null&&I.position){const D=(C.value*n.distance-s.value.position[P]+A)*n.smoothScroll;s.value.position[P]+=D,p.value.children.length>0&&(p.value.position[P]+=D),x()}}),e({instance:p}),(x,I)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:p},[u.renderSlot(x.$slots,"default")],512))}}),Au=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Pu=u.defineComponent({__name:"TransformControls",props:{object:{},camera:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(a,{expose:e,emit:t}){const n=a,o=t,{object:r,mode:s,enabled:i,axis:c,translationSnap:h,rotationSnap:p,scaleSnap:f,space:m,size:d,showX:g,showY:y,showZ:v}=u.toRefs(n),_=u.shallowRef(null),{controls:A,camera:b,renderer:C,extend:L,invalidate:M}=H.useTresContext();u.watch([r,s,i,c,h,p,f,m,d,g,y,v],()=>{M()}),L({TransformControls:Za});const P=()=>{M(),o("change")},w=z=>{A.value&&(A.value.enabled=!z.value),M(),o("dragging",z.value)},S=()=>{M(),o("mouseDown")},x=()=>{M(),o("mouseDown")},I=()=>{M(),o("objectChange")};function D(){Ce(_.value,"change",P),Ce(_.value,"dragging-changed",w),Ce(_.value,"mouseDown",S),Ce(_.value,"mouseUp",x),Ce(_.value,"objectChange",I)}return u.watch(_,z=>{z&&D()}),u.onUnmounted(()=>{_.value&&_.value.dispose()}),e({instance:_}),(z,G)=>{var X;return(z.camera||u.unref(b))&&u.unref(C)?(u.openBlock(),u.createElementBlock("TresTransformControls",{ref_key:"controlsRef",ref:_,key:(X=z.camera||u.unref(b))==null?void 0:X.uuid,object:u.unref(r),args:[z.camera||u.unref(b),u.unref(C).domElement],mode:u.unref(s),enabled:u.unref(i),axis:u.unref(c),"translation-snap":u.unref(h),"rotation-snap":u.unref(p),"scale-snap":u.unref(f),space:u.unref(m),size:u.unref(d),"show-x":u.unref(g),"show-y":u.unref(y),"show-z":u.unref(v),visible:!0},null,8,Au)):u.createCommentVNode("",!0)}}}),Cu=["geometry","render-order"],Tu=u.defineComponent({__name:"component",props:{src:{},skipStrokes:{type:Boolean,default:!1},skipFills:{type:Boolean,default:!1},fillMaterial:{},strokeMaterial:{},fillMeshProps:{},strokeMeshProps:{},depth:{default:"renderOrder"}},setup(a,{expose:e}){const t=a;class n extends Jt{load(b,C,L,M){const P=Array.isArray(b)?b[0]:b;super.load(P,C,L,M)}}const{src:o,skipStrokes:r,skipFills:s,fillMaterial:i,strokeMaterial:c,fillMeshProps:h,strokeMeshProps:p,depth:f}=u.toRefs(t),m=u.shallowRef(),d=u.shallowRef([]),g=u.shallowRef([]);e({instance:m}),u.watchEffect(async()=>y(o.value).then(A=>g.value=A.paths)),u.watch([s,r,i,c,g],_);async function y(A){const b=A.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${A}`):A;return H.useLoader(n,b)}u.onUnmounted(v);function v(){d.value.forEach(A=>A.geometry.dispose())}function _(){var M,P,w;v();const A=[],[b,C]=(()=>{const S={flat:!1,renderOrder:!1,offsetZ:!0},x={flat:0,renderOrder:0,offsetZ:.025},I=f.value;return typeof I=="number"?[!0,I]:[S[I],x[I]]})();let L=0;for(const S of g.value){const x=((M=S.userData)==null?void 0:M.style)??{},I=Object.assign({color:x.fill,opacity:x.fillOpacity,transparent:!0,side:l.DoubleSide,depthWrite:b},t.fillMaterial);if(!s.value&&x.fill!==void 0&&x.fill!=="none")for(const D of Jt.createShapes(S)){const z=new l.ShapeGeometry(D);z.scale(1,-1,1),C&&z.translate(0,0,L++*C),A.push({geometry:z,material:I,isStroke:!1})}if(!r.value&&x.stroke!==void 0&&x.stroke!=="none"){const D=Object.assign({color:(P=S.userData)==null?void 0:P.style.stroke,opacity:(w=S.userData)==null?void 0:w.style.strokeOpacity,transparent:!0,side:l.DoubleSide,depthWrite:b},t.strokeMaterial);for(const z of S.subPaths){const G=z.getPoints().map(E=>new l.Vector2(E.x,-E.y)),X=Jt.pointsToStroke(G,x||"none");C&&X.translate(0,0,L++*C),A.push({geometry:X,material:D,isStroke:!0})}}}d.value=A}return(A,b)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"svgRef",ref:m},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(d.value,({geometry:C,material:L,isStroke:M},P)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({key:`${P}`,ref_for:!0},M?u.unref(p):u.unref(h),{geometry:C,"render-order":u.unref(f)==="renderOrder"?P:0}),[u.createElementVNode("TresMeshBasicMaterial",u.mergeProps({ref_for:!0},L),null,16)],16,Cu))),128))],512))}});class Iu extends l.Loader{constructor(t){super(t);ue(this,"fbxLoader");this.fbxLoader=new Jl(t)}load(t,n,o,r){const s=Array.isArray(t)?t[0]:t;this.fbxLoader.load(s,n,o,r)}async loadAsync(t){const n=Array.isArray(t)?t[0]:t;return this.fbxLoader.loadAsync(n)}}const Ou=Iu;async function vs(a){return await H.useLoader(Ou,a)}const Lu=["object"],Du=u.defineComponent({__name:"component",props:{path:{},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref();e({instance:r});const s=([t,n]=u.withAsyncContext(()=>vs(o.path)),t=await t,n(),t);return(o.castShadow||o.receiveShadow)&&s.traverse(i=>{i.isMesh&&(i.castShadow=o.castShadow,i.receiveShadow=o.receiveShadow)}),(i,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:r,object:u.unref(s)},i.$attrs),null,16,Lu))}});class ku extends l.Loader{constructor(t){super(t);ue(this,"gltfLoader");this.gltfLoader=new il(t)}load(t,n,o,r){const s=Array.isArray(t)?t[0]:t;this.gltfLoader.load(s,n,o,r)}async loadAsync(t){const n=Array.isArray(t)?t[0]:t;return this.gltfLoader.loadAsync(n)}setDRACOLoader(t){return this.gltfLoader.setDRACOLoader(t)}}const Bu=ku;let xt=null;function Uu(a,e){return t=>{e&&e(t),a.draco&&(xt||(xt=new mc),xt.setDecoderPath(a.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader&&t.setDRACOLoader(xt))}}async function xs(a,e={draco:!1},t){const n=await H.useLoader(Bu,a,Uu(e,t));return xt==null||xt.dispose(),xt=null,n}const Nu=["object"],Fu=u.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref();e({instance:r});const{scene:s}=([t,n]=u.withAsyncContext(()=>xs(o.path,{draco:o.draco,decoderPath:o.decoderPath})),t=await t,n(),t);return(o.castShadow||o.receiveShadow)&&s.traverse(i=>{i.isMesh&&(i.castShadow=o.castShadow,i.receiveShadow=o.receiveShadow)}),(i,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:r,object:u.unref(s)},i.$attrs),null,16,Nu))}}),ws="[TresJS - Cientos ▲ ■ ♥] ";function zu(a,e){console.error(`${ws} ${a}`,e||"")}function Vu(a){console.warn(`${ws} ${a}`)}function Gu(a,e){}function bs(){return{logError:zu,logWarning:Vu,logMessage:Gu}}let Mo=0;function Ru(){const a=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:n}=bs();return new Promise(o=>{l.DefaultLoadingManager.onStart=()=>{a.value=!1},l.DefaultLoadingManager.onLoad=()=>{a.value=!0},l.DefaultLoadingManager.onProgress=(r,s,i)=>{s===i&&(Mo=i,a.value=!0,t.value.push(r)),e.value=Math.round((s-Mo)/(i-Mo)*100||100)},l.DefaultLoadingManager.onError=r=>{n("Error loading assets",new Error(r)),a.value=!0},o({items:t,hasFinishLoading:a,progress:e})})}async function ju(a,e){const{logError:t}=bs();if(!a)return t("Error no path provided");const{unsuspend:n,start:o,crossOrigin:r,muted:s,loop:i,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function h(){return new Promise((p,f)=>{const m=Object.assign(document.createElement("video"),{src:typeof a=="string"&&a||void 0,crossOrigin:r,loop:i,muted:s,autoplay:!0,...c}),d=new l.VideoTexture(m);return m.addEventListener(n,()=>p(d)),m.addEventListener("error",()=>f(new Error("Error loading video"))),d})}try{const p=await h();return o&&p.image&&p.image.play(),p}catch{t("Error loading resource")}}function on(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function On(a){throw new Error('Could not dynamically require "'+a+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var So={exports:{}},Ms;function Wu(){return Ms||(Ms=1,function(a,e){(function(t){a.exports=t()})(function(){return function t(n,o,r){function s(h,p){if(!o[h]){if(!n[h]){var f=typeof On=="function"&&On;if(!p&&f)return f(h,!0);if(i)return i(h,!0);throw new Error("Cannot find module '"+h+"'")}p=o[h]={exports:{}},n[h][0].call(p.exports,function(m){var d=n[h][1][m];return s(d||m)},p,p.exports,t,n,o,r)}return o[h].exports}for(var i=typeof On=="function"&&On,c=0;c<r.length;c++)s(r[c]);return s}({1:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g=t("crypto");function y(M,P){P=A(M,P);var w;return(w=P.algorithm!=="passthrough"?g.createHash(P.algorithm):new L).write===void 0&&(w.write=w.update,w.end=w.update),C(P,w).dispatch(M),w.update||w.end(""),w.digest?w.digest(P.encoding==="buffer"?void 0:P.encoding):(M=w.read(),P.encoding!=="buffer"?M.toString(P.encoding):M)}(o=n.exports=y).sha1=function(M){return y(M)},o.keys=function(M){return y(M,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},o.MD5=function(M){return y(M,{algorithm:"md5",encoding:"hex"})},o.keysMD5=function(M){return y(M,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var v=g.getHashes?g.getHashes().slice():["sha1","md5"],_=(v.push("passthrough"),["buffer","hex","binary","base64"]);function A(M,P){var w={};if(w.algorithm=(P=P||{}).algorithm||"sha1",w.encoding=P.encoding||"hex",w.excludeValues=!!P.excludeValues,w.algorithm=w.algorithm.toLowerCase(),w.encoding=w.encoding.toLowerCase(),w.ignoreUnknown=P.ignoreUnknown===!0,w.respectType=P.respectType!==!1,w.respectFunctionNames=P.respectFunctionNames!==!1,w.respectFunctionProperties=P.respectFunctionProperties!==!1,w.unorderedArrays=P.unorderedArrays===!0,w.unorderedSets=P.unorderedSets!==!1,w.unorderedObjects=P.unorderedObjects!==!1,w.replacer=P.replacer||void 0,w.excludeKeys=P.excludeKeys||void 0,M===void 0)throw new Error("Object argument required.");for(var S=0;S<v.length;++S)v[S].toLowerCase()===w.algorithm.toLowerCase()&&(w.algorithm=v[S]);if(v.indexOf(w.algorithm)===-1)throw new Error('Algorithm "'+w.algorithm+'" not supported. supported values: '+v.join(", "));if(_.indexOf(w.encoding)===-1&&w.algorithm!=="passthrough")throw new Error('Encoding "'+w.encoding+'" not supported. supported values: '+_.join(", "));return w}function b(M){if(typeof M=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(M))!=null}function C(M,P,w){w=w||[];function S(x){return P.update?P.update(x,"utf8"):P.write(x,"utf8")}return{dispatch:function(x){return this["_"+((x=M.replacer?M.replacer(x):x)===null?"null":typeof x)](x)},_object:function(x){var I,D=Object.prototype.toString.call(x),z=/\[object (.*)\]/i.exec(D);if(z=(z=z?z[1]:"unknown:["+D+"]").toLowerCase(),0<=(D=w.indexOf(x)))return this.dispatch("[CIRCULAR:"+D+"]");if(w.push(x),i!==void 0&&i.isBuffer&&i.isBuffer(x))return S("buffer:"),S(x);if(z==="object"||z==="function"||z==="asyncfunction")return D=Object.keys(x),M.unorderedObjects&&(D=D.sort()),M.respectType===!1||b(x)||D.splice(0,0,"prototype","__proto__","constructor"),M.excludeKeys&&(D=D.filter(function(G){return!M.excludeKeys(G)})),S("object:"+D.length+":"),I=this,D.forEach(function(G){I.dispatch(G),S(":"),M.excludeValues||I.dispatch(x[G]),S(",")});if(!this["_"+z]){if(M.ignoreUnknown)return S("["+z+"]");throw new Error('Unknown object type "'+z+'"')}this["_"+z](x)},_array:function(x,G){G=G!==void 0?G:M.unorderedArrays!==!1;var D=this;if(S("array:"+x.length+":"),!G||x.length<=1)return x.forEach(function(X){return D.dispatch(X)});var z=[],G=x.map(function(X){var E=new L,te=w.slice();return C(M,E,te).dispatch(X),z=z.concat(te.slice(w.length)),E.read().toString()});return w=w.concat(z),G.sort(),this._array(G,!1)},_date:function(x){return S("date:"+x.toJSON())},_symbol:function(x){return S("symbol:"+x.toString())},_error:function(x){return S("error:"+x.toString())},_boolean:function(x){return S("bool:"+x.toString())},_string:function(x){S("string:"+x.length+":"),S(x.toString())},_function:function(x){S("fn:"),b(x)?this.dispatch("[native]"):this.dispatch(x.toString()),M.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(x.name)),M.respectFunctionProperties&&this._object(x)},_number:function(x){return S("number:"+x.toString())},_xml:function(x){return S("xml:"+x.toString())},_null:function(){return S("Null")},_undefined:function(){return S("Undefined")},_regexp:function(x){return S("regex:"+x.toString())},_uint8array:function(x){return S("uint8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint8clampedarray:function(x){return S("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(x))},_int8array:function(x){return S("int8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint16array:function(x){return S("uint16array:"),this.dispatch(Array.prototype.slice.call(x))},_int16array:function(x){return S("int16array:"),this.dispatch(Array.prototype.slice.call(x))},_uint32array:function(x){return S("uint32array:"),this.dispatch(Array.prototype.slice.call(x))},_int32array:function(x){return S("int32array:"),this.dispatch(Array.prototype.slice.call(x))},_float32array:function(x){return S("float32array:"),this.dispatch(Array.prototype.slice.call(x))},_float64array:function(x){return S("float64array:"),this.dispatch(Array.prototype.slice.call(x))},_arraybuffer:function(x){return S("arraybuffer:"),this.dispatch(new Uint8Array(x))},_url:function(x){return S("url:"+x.toString())},_map:function(x){return S("map:"),x=Array.from(x),this._array(x,M.unorderedSets!==!1)},_set:function(x){return S("set:"),x=Array.from(x),this._array(x,M.unorderedSets!==!1)},_file:function(x){return S("file:"),this.dispatch([x.name,x.size,x.type,x.lastModfied])},_blob:function(){if(M.ignoreUnknown)return S("[blob]");throw Error(`Hashing Blob objects is currently not supported
1016
+ */const Oe={LEFT:1,RIGHT:2,MIDDLE:4},$=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ft={NONE:0,IN:1,OUT:-1};function Ct(a){return a.isPerspectiveCamera}function vt(a){return a.isOrthographicCamera}const zt=Math.PI*2,ss=Math.PI/2,is=1e-5,Ht=Math.PI/180;function $e(a,e,t){return Math.max(e,Math.min(t,a))}function Te(a,e=is){return Math.abs(a)<e}function Se(a,e,t=is){return Te(a-e,t)}function as(a,e){return Math.round(a/e)*e}function $t(a){return isFinite(a)?a:a<0?-Number.MAX_VALUE:Number.MAX_VALUE}function en(a){return Math.abs(a)<Number.MAX_VALUE?a:a*(1/0)}function Pn(a,e,t,n,o=1/0,r){n=Math.max(1e-4,n);const s=2/n,i=s*r,c=1/(1+i+.48*i*i+.235*i*i*i);let h=a-e;const p=e,f=o*n;h=$e(h,-f,f),e=a-h;const m=(t.value+s*h)*r;t.value=(t.value-s*m)*c;let d=e+(h+m)*c;return p-a>0==d>p&&(d=p,t.value=(d-p)/r),d}function ls(a,e,t,n,o=1/0,r,s){n=Math.max(1e-4,n);const i=2/n,c=i*r,h=1/(1+c+.48*c*c+.235*c*c*c);let p=e.x,f=e.y,m=e.z,d=a.x-p,g=a.y-f,y=a.z-m;const v=p,_=f,A=m,b=o*n,C=b*b,L=d*d+g*g+y*y;if(L>C){const X=Math.sqrt(L);d=d/X*b,g=g/X*b,y=y/X*b}p=a.x-d,f=a.y-g,m=a.z-y;const M=(t.x+i*d)*r,P=(t.y+i*g)*r,w=(t.z+i*y)*r;t.x=(t.x-i*M)*h,t.y=(t.y-i*P)*h,t.z=(t.z-i*w)*h,s.x=p+(d+M)*h,s.y=f+(g+P)*h,s.z=m+(y+w)*h;const S=v-a.x,x=_-a.y,I=A-a.z,D=s.x-v,z=s.y-_,G=s.z-A;return S*D+x*z+I*G>0&&(s.x=v,s.y=_,s.z=A,t.x=(s.x-v)/r,t.y=(s.y-_)/r,t.z=(s.z-A)/r),s}function go(a,e){e.set(0,0),a.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=a.length,e.y/=a.length}function yo(a,e){return vt(a)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class du{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const o=this._listeners[e];if(o!==void 0){const r=o.indexOf(t);r!==-1&&o.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const o=n.slice(0);for(let r=0,s=o.length;r<s;r++)o[r].call(this,e)}}}var _o;const pu="2.9.0",Cn=1/8,mu=/Mac/.test((_o=globalThis==null?void 0:globalThis.navigator)===null||_o===void 0?void 0:_o.platform);let pe,cs,Tn,vo,je,ye,be,Vt,tn,ot,rt,Tt,us,hs,Qe,nn,Gt,fs,xo,ds,wo,bo,In;class Ve extends du{static install(e){pe=e.THREE,cs=Object.freeze(new pe.Vector3(0,0,0)),Tn=Object.freeze(new pe.Vector3(0,1,0)),vo=Object.freeze(new pe.Vector3(0,0,1)),je=new pe.Vector2,ye=new pe.Vector3,be=new pe.Vector3,Vt=new pe.Vector3,tn=new pe.Vector3,ot=new pe.Vector3,rt=new pe.Vector3,Tt=new pe.Vector3,us=new pe.Vector3,hs=new pe.Vector3,Qe=new pe.Spherical,nn=new pe.Spherical,Gt=new pe.Box3,fs=new pe.Box3,xo=new pe.Sphere,ds=new pe.Quaternion,wo=new pe.Quaternion,bo=new pe.Matrix4,In=new pe.Raycaster}static get ACTION(){return $}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=$.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ft.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new pe.Vector3,this._focalOffsetVelocity=new pe.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,A,b)=>{let C,L;if(Ct(this._camera)){const M=ye.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*Ht,w=M.length()*Math.tan(P*.5);C=this.truckSpeed*_*w/this._elementRect.height,L=this.truckSpeed*A*w/this._elementRect.height}else if(vt(this._camera)){const M=this._camera;C=_*(M.right-M.left)/M.zoom/this._elementRect.width,L=A*(M.top-M.bottom)/M.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(C,0,!0),this.forward(-L,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+L,this._focalOffsetEnd.z,!0):this.truck(C,L,!0)},this._rotateInternal=(_,A)=>{const b=zt*this.azimuthRotateSpeed*_/this._elementRect.height,C=zt*this.polarRotateSpeed*A/this._elementRect.height;this.rotate(b,C,!0)},this._dollyInternal=(_,A,b)=>{const C=Math.pow(.95,-_*this.dollySpeed),L=this._sphericalEnd.radius,M=this._sphericalEnd.radius*C,P=$e(M,this.minDistance,this.maxDistance),w=P-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(w,!0),this._dollyToNoClamp(P,!0)):this._dollyToNoClamp(P,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:P)-L,this._dollyControlCoord.set(A,b)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,A,b)=>{const C=Math.pow(.95,_*this.dollySpeed),L=this._zoom,M=this._zoom*C;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-L,this._dollyControlCoord.set(A,b))},typeof pe>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new pe.Quaternion().setFromUnitVectors(this._camera.up,Tn),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=$.NONE,this._target=new pe.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new pe.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new pe.Spherical().setFromVector3(ye.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new pe.Vector3,new pe.Vector3,new pe.Vector3,new pe.Vector3],this._updateNearPlaneCorners(),this._boundary=new pe.Box3(new pe.Vector3(-1/0,-1/0,-1/0),new pe.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new pe.Vector2,this.mouseButtons={left:$.ROTATE,middle:$.DOLLY,right:$.TRUCK,wheel:Ct(this._camera)?$.DOLLY:vt(this._camera)?$.ZOOM:$.NONE},this.touches={one:$.TOUCH_ROTATE,two:Ct(this._camera)?$.TOUCH_DOLLY_TRUCK:vt(this._camera)?$.TOUCH_ZOOM_TRUCK:$.NONE,three:$.TOUCH_TRUCK};const n=new pe.Vector2,o=new pe.Vector2,r=new pe.Vector2,s=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),L=_.clientX/C.width,M=_.clientY/C.height;if(L<this._interactiveArea.left||L>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const A=_.pointerType!=="mouse"?null:(_.buttons&Oe.LEFT)===Oe.LEFT?Oe.LEFT:(_.buttons&Oe.MIDDLE)===Oe.MIDDLE?Oe.MIDDLE:(_.buttons&Oe.RIGHT)===Oe.RIGHT?Oe.RIGHT:null;if(A!==null){const C=this._findPointerByMouseButton(A);C&&this._disposePointer(C)}if((_.buttons&Oe.LEFT)===Oe.LEFT&&this._lockedPointer)return;const b={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:A};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,m(_)},i=_=>{_.cancelable&&_.preventDefault();const A=_.pointerId,b=this._lockedPointer||this._findPointerById(A);if(b){if(b.clientX=_.clientX,b.clientY=_.clientY,b.deltaX=_.movementX,b.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&Oe.LEFT)===Oe.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&Oe.MIDDLE)===Oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&Oe.RIGHT)===Oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);d()}},c=_=>{const A=this._findPointerById(_.pointerId);if(!(A&&A===this._lockedPointer)){if(A&&this._disposePointer(A),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=$.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=$.NONE;g()}};let h=-1;const p=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===$.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),P=_.clientX/M.width,w=_.clientY/M.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||w<this._interactiveArea.top||w>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===$.ROTATE||this.mouseButtons.wheel===$.TRUCK){const M=performance.now();h-M<1e3&&this._getClientRect(this._elementRect),h=M}const A=mu?-1:-3,b=_.deltaMode===1?_.deltaY/A:_.deltaY/(A*10),C=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,L=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case $.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case $.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case $.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case $.DOLLY:{this._dollyInternal(-b,C,L),this._isUserControllingDolly=!0;break}case $.ZOOM:{this._zoomInternal(-b,C,L),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Ve.ACTION.NONE){const A=_ instanceof PointerEvent?_.pointerId:0,b=this._findPointerById(A);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}_.preventDefault()}},m=_=>{if(!this._enabled)return;if(go(this._activePointers,je),this._getClientRect(this._elementRect),n.copy(je),o.copy(je),this._activePointers.length>=2){const b=je.x-this._activePointers[1].clientX,C=je.y-this._activePointers[1].clientY,L=Math.sqrt(b*b+C*C);r.set(0,L);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,P=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;o.set(M,P)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&Oe.LEFT)===Oe.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&Oe.MIDDLE)===Oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&Oe.RIGHT)===Oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&$.DOLLY)===$.DOLLY||(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&$.ZOOM)===$.ZOOM||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,go(this._activePointers,je);const A=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=A?-A.deltaX:o.x-je.x,C=A?-A.deltaY:o.y-je.y;if(o.copy(je),((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,C),this._isUserControllingRotate=!0),(this._state&$.DOLLY)===$.DOLLY||(this._state&$.ZOOM)===$.ZOOM){const L=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,P=this.dollyDragInverted?-1:1;(this._state&$.DOLLY)===$.DOLLY?(this._dollyInternal(P*C*Cn,L,M),this._isUserControllingDolly=!0):(this._zoomInternal(P*C*Cn,L,M),this._isUserControllingZoom=!0)}if((this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE){const L=je.x-this._activePointers[1].clientX,M=je.y-this._activePointers[1].clientY,P=Math.sqrt(L*L+M*M),w=r.y-P;r.set(0,P);const S=this.dollyToCursor?(o.x-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(o.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET?(this._dollyInternal(w*Cn,S,x),this._isUserControllingDolly=!0):(this._zoomInternal(w*Cn,S,x),this._isUserControllingZoom=!0)}((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,C,!1),this._isUserControllingTruck=!0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{go(this._activePointers,je),o.copy(je),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",y),this._domElement.ownerDocument.addEventListener("pointerlockerror",v),this._domElement.ownerDocument.addEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),m())},this.unlockPointer=()=>{var _,A,b;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(A=this._domElement)===null||A===void 0||A.ownerDocument.removeEventListener("pointerlockchange",y),(b=this._domElement)===null||b===void 0||b.ownerDocument.removeEventListener("pointerlockerror",v),this.cancel()};const y=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},v=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",s),this._domElement.addEventListener("pointercancel",c),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",s),this._domElement.removeEventListener("pointercancel",c),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.removeEventListener("pointerlockchange",y),this._domElement.ownerDocument.removeEventListener("pointerlockerror",v))},this.cancel=()=>{this._state!==$.NONE&&(this._state=$.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=$e(e.width,0,1),this._interactiveArea.height=$e(e.height,0,1),this._interactiveArea.x=$e(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=$e(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const o=$e(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=$e(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=o,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const s=!n||Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(s)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0,this._dollyToNoClamp($e(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const s=this._collisionTest(),i=Se(s,this._spherical.radius);if(!(n>e)&&i)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,s)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(tn).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=$e(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Se(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),ot.setFromMatrixColumn(this._camera.matrix,0),rt.setFromMatrixColumn(this._camera.matrix,1),ot.multiplyScalar(e),rt.multiplyScalar(-t);const o=ye.copy(ot).add(rt),r=be.copy(this._targetEnd).add(o);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){ye.setFromMatrixColumn(this._camera.matrix,0),ye.crossVectors(this._camera.up,ye),ye.multiplyScalar(e);const n=be.copy(this._targetEnd).add(ye);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return ye.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ye.x,this._targetEnd.y+ye.y,this._targetEnd.z+ye.z,t)}moveTo(e,t,n,o=!1){this._isUserControllingTruck=!1;const r=ye.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,o||this._target.copy(this._targetEnd);const s=!o||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}lookInDirectionOf(e,t,n,o=!1){const i=ye.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(i.x,i.y,i.z,o)}fitToBox(e,t,{cover:n=!1,paddingLeft:o=0,paddingRight:r=0,paddingBottom:s=0,paddingTop:i=0}={}){const c=[],h=e.isBox3?Gt.copy(e):Gt.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=as(this._sphericalEnd.theta,ss),f=as(this._sphericalEnd.phi,ss);c.push(this.rotateTo(p,f,t));const m=ye.setFromSpherical(this._sphericalEnd).normalize(),d=ds.setFromUnitVectors(m,vo),g=Se(Math.abs(m.y),1);g&&d.multiply(wo.setFromAxisAngle(Tn,p)),d.multiply(this._yAxisUpSpaceInverse);const y=fs.makeEmpty();be.copy(h.min).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setX(h.max.x).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setY(h.max.y).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setZ(h.min.z).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setZ(h.max.z).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setY(h.min.y).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setX(h.min.x).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).applyQuaternion(d),y.expandByPoint(be),y.min.x-=o,y.min.y-=s,y.max.x+=r,y.max.y+=i,d.setFromUnitVectors(vo,m),g&&d.premultiply(wo.invert()),d.premultiply(this._yAxisUpSpace);const v=y.getSize(ye),_=y.getCenter(be).applyQuaternion(d);if(Ct(this._camera)){const A=this.getDistanceToFitBox(v.x,v.y,v.z,n);c.push(this.moveTo(_.x,_.y,_.z,t)),c.push(this.dollyTo(A,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(vt(this._camera)){const A=this._camera,b=A.right-A.left,C=A.top-A.bottom,L=n?Math.max(b/v.x,C/v.y):Math.min(b/v.x,C/v.y);c.push(this.moveTo(_.x,_.y,_.z,t)),c.push(this.zoomTo(L,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const n=[],r="isObject3D"in e?Ve.createBoundingSphere(e,xo):xo.copy(e);if(n.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),Ct(this._camera)){const s=this.getDistanceToFitSphere(r.radius);n.push(this.dollyTo(s,t))}else if(vt(this._camera)){const s=this._camera.right-this._camera.left,i=this._camera.top-this._camera.bottom,c=2*r.radius,h=Math.min(s/c,i/c);n.push(this.zoomTo(h,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,o,r,s,i=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const c=be.set(o,r,s),h=ye.set(e,t,n);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(h.sub(c).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,i||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!i||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,n,o,r,s,i,c,h,p,f,m,d,g=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const y=ye.set(o,r,s),v=be.set(e,t,n);Qe.setFromVector3(v.sub(y).applyQuaternion(this._yAxisUpSpace));const _=Vt.set(p,f,m),A=be.set(i,c,h);nn.setFromVector3(A.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(_,d));const b=nn.theta-Qe.theta,C=nn.phi-Qe.phi,L=nn.radius-Qe.radius;this._sphericalEnd.set(Qe.radius+L*d,Qe.phi+C*d,Qe.theta+b*d),this.normalizeRotations(),this._needsUpdate=!0,g||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const M=!g||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(M)}setPosition(e,t,n,o=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,o)}setTarget(e,t,n,o=!1){const r=this.getPosition(ye),s=this.setLookAt(r.x,r.y,r.z,e,t,n,o);return this._sphericalEnd.phi=$e(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),s}setFocalOffset(e,t,n,o=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,o||this._focalOffset.copy(this._focalOffsetEnd);const r=!o||Se(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Se(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Se(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),ot.setFromMatrixColumn(this._camera.matrixWorldInverse,0),rt.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Tt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const o=ye.set(e,t,n),r=o.distanceTo(this._camera.position),s=o.sub(this._camera.position);ot.multiplyScalar(s.x),rt.multiplyScalar(s.y),Tt.multiplyScalar(s.z),ye.copy(ot).add(rt).add(Tt),ye.z=ye.z+r,this.dollyTo(r,!1),this.setFocalOffset(-ye.x,ye.y,-ye.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,o){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new pe.Vector4,typeof e=="number"?this._viewport.set(e,t,n,o):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,o=!1){if(yo(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,s=this._camera.getEffectiveFOV()*Ht,i=this._camera.aspect;return((o?r>i:r<i)?t:e/i)*.5/Math.tan(s*.5)+n*.5}getDistanceToFitSphere(e){if(yo(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Ht,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,o=1<this._camera.aspect?t:n;return e/Math.sin(o*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new pe.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%zt,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=zt),this._spherical.theta+=zt*Math.round((this._sphericalEnd.theta-this._spherical.theta)/zt)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Se(this._camera.up.x,this._cameraUp0.x)||!Se(this._camera.up.y,this._cameraUp0.y)||!Se(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Tn),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ye.subVectors(this._target,this._camera.position).normalize(),t=be.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,o=this._sphericalEnd.radius-this._spherical.radius,r=us.subVectors(this._targetEnd,this._target),s=hs.subVectors(this._focalOffsetEnd,this._focalOffset),i=this._zoomEnd-this._zoom;if(Te(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Pn(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,f,1/0,e),this._needsUpdate=!0}if(Te(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Pn(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,f,1/0,e),this._needsUpdate=!0}if(Te(o))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const f=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Pn(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,f,this.maxSpeed,e),this._needsUpdate=!0}if(Te(r.x)&&Te(r.y)&&Te(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const f=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;ls(this._target,this._targetEnd,this._targetVelocity,f,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Te(s.x)&&Te(s.y)&&Te(s.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const f=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;ls(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,f,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Te(i))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const f=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Pn(this._zoom,this._zoomEnd,this._zoomVelocity,f,1/0,e)}if(this.dollyToCursor){if(Ct(this._camera)&&this._changedDolly!==0){const f=this._spherical.radius-this._lastDistance,m=this._camera,d=this._getCameraDirection(tn),g=ye.copy(d).cross(m.up).normalize();g.lengthSq()===0&&(g.x=1);const y=be.crossVectors(g,d),v=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*Ht*.5),A=(this._sphericalEnd.radius-f-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=Vt.copy(this._targetEnd).add(g.multiplyScalar(this._dollyControlCoord.x*v*m.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*v)),C=ye.copy(this._targetEnd).lerp(b,A),L=this._lastDollyDirection===Ft.IN&&this._spherical.radius<=this.minDistance,M=this._lastDollyDirection===Ft.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(L||M)){this._sphericalEnd.radius-=f,this._spherical.radius-=f;const w=be.copy(d).multiplyScalar(-f);C.add(w)}this._boundary.clampPoint(C,C);const P=be.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(P),this._changedDolly-=f,Te(this._changedDolly)&&(this._changedDolly=0)}else if(vt(this._camera)&&this._changedZoom!==0){const f=this._zoom-this._lastZoom,m=this._camera,d=ye.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),g=be.set(0,0,-1).applyQuaternion(m.quaternion),y=Vt.copy(d).add(g.multiplyScalar(-d.dot(m.up))),_=-(this._zoom-f-this._zoom)/this._zoom,A=this._getCameraDirection(tn),b=this._targetEnd.dot(A),C=ye.copy(this._targetEnd).lerp(y,_),L=C.dot(A),M=A.multiplyScalar(L-b);C.sub(M),this._boundary.clampPoint(C,C);const P=be.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(P),this._changedZoom-=f,Te(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Te(this._focalOffset.x)||!Te(this._focalOffset.y)||!Te(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),ot.setFromMatrixColumn(this._camera.matrix,0),rt.setFromMatrixColumn(this._camera.matrix,1),Tt.setFromMatrixColumn(this._camera.matrix,2),ot.multiplyScalar(this._focalOffset.x),rt.multiplyScalar(-this._focalOffset.y),Tt.multiplyScalar(this._focalOffset.z),ye.copy(ot).add(rt).add(Tt),this._camera.position.add(ye)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ye.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),Te(t,this.restThreshold)&&Te(n,this.restThreshold)&&Te(o,this.restThreshold)&&Te(r.x,this.restThreshold)&&Te(r.y,this.restThreshold)&&Te(r.z,this.restThreshold)&&Te(s.x,this.restThreshold)&&Te(s.y,this.restThreshold)&&Te(s.z,this.restThreshold)&&Te(i,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:$t(this.maxDistance),minZoom:this.minZoom,maxZoom:$t(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:$t(this.maxPolarAngle),minAzimuthAngle:$t(this.minAzimuthAngle),maxAzimuthAngle:$t(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:ye.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=en(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=en(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=en(n.maxPolarAngle),this.minAzimuthAngle=en(n.minAzimuthAngle),this.maxAzimuthAngle=en(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Qe.setFromVector3(ye.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Qe.theta,Qe.phi,t),this.dollyTo(Qe.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",pu),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const o=t.lengthSq();if(o===0)return e;const r=be.copy(t).add(e),i=this._boundary.clampPoint(r,Vt).sub(r),c=i.lengthSq();if(c===0)return e.add(t);if(c===o)return e;if(n===0)return e.add(t).add(i);{const h=1+n*c/t.dot(i);return e.add(be.copy(t).multiplyScalar(h)).add(i.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Ct(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Ht,o=Math.tan(n*.5)*t,r=o*e.aspect;this._nearPlaneCorners[0].set(-r,-o,0),this._nearPlaneCorners[1].set(r,-o,0),this._nearPlaneCorners[2].set(r,o,0),this._nearPlaneCorners[3].set(-r,o,0)}else if(vt(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,o=e.right*t,r=e.top*t,s=e.bottom*t;this._nearPlaneCorners[0].set(n,r,0),this._nearPlaneCorners[1].set(o,r,0),this._nearPlaneCorners[2].set(o,s,0),this._nearPlaneCorners[3].set(n,s,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||yo(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(tn);bo.lookAt(cs,n,this._camera.up);for(let o=0;o<4;o++){const r=be.copy(this._nearPlaneCorners[o]);r.applyMatrix4(bo);const s=Vt.addVectors(this._target,r);In.set(s,n),In.far=this._spherical.radius+1;const i=In.intersectObjects(this.colliderMeshes);i.length!==0&&i[0].distance<e&&(e=i[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new pe.Sphere){const n=t,o=n.center;Gt.makeEmpty(),e.traverseVisible(s=>{s.isMesh&&Gt.expandByObject(s)}),Gt.getCenter(o);let r=0;return e.traverseVisible(s=>{if(!s.isMesh)return;const i=s,c=i.geometry.clone();c.applyMatrix4(i.matrixWorld);const p=c.attributes.position;for(let f=0,m=p.count;f<m;f++)ye.fromBufferAttribute(p,f),r=Math.max(r,o.distanceToSquared(ye))}),n.radius=Math.sqrt(r),n}}const ps=a=>!!(a&&a.isPerspectiveCamera),ms=a=>!!(a&&a.isOrthographicCamera),gu=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","distance","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args","mouse-buttons","touches"],gs=(a,e)=>({left:Ve.ACTION.ROTATE,middle:Ve.ACTION.DOLLY,right:Ve.ACTION.TRUCK,wheel:ps(a)?Ve.ACTION.DOLLY:ms(a)?Ve.ACTION.ZOOM:Ve.ACTION.NONE,...e}),ys=(a,e)=>({one:Ve.ACTION.TOUCH_ROTATE,two:ps(a)?Ve.ACTION.TOUCH_DOLLY_TRUCK:ms(a)?Ve.ACTION.TOUCH_ZOOM_TRUCK:Ve.ACTION.NONE,three:Ve.ACTION.TOUCH_TRUCK,...e}),yu=u.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},distance:{default:()=>H.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:Number.POSITIVE_INFINITY},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:Number.POSITIVE_INFINITY},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:Number.POSITIVE_INFINITY},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{default:()=>gs(H.useTresContext().camera.value)},touches:{default:()=>ys(H.useTresContext().camera.value)}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,o=t,{makeDefault:r,minPolarAngle:s,maxPolarAngle:i,minAzimuthAngle:c,maxAzimuthAngle:h,distance:p,minDistance:f,maxDistance:m,infinityDolly:d,minZoom:g,maxZoom:y,smoothTime:v,draggingSmoothTime:_,maxSpeed:A,azimuthRotateSpeed:b,polarRotateSpeed:C,dollySpeed:L,dollyDragInverted:M,truckSpeed:P,dollyToCursor:w,dragToOffset:S,verticalDragToForward:x,boundaryFriction:I,restThreshold:D,colliderMeshes:z}=u.toRefs(n),G={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};Ve.install({THREE:G});const{camera:X,renderer:E,extend:te,controls:q,invalidate:oe}=H.useTresContext();u.watch(n,()=>{oe()});const ne=u.computed(()=>gs(n.camera||X.value,n.mouseButtons)),ce=u.computed(()=>ys(n.camera||X.value,n.touches)),le=u.shallowRef(null);te({CameraControls:Ve}),u.watchEffect(()=>{de(),le.value&&r.value?q.value=le.value:q.value=null});function de(){Ce(le.value,"update",()=>{o("change",le.value),oe()}),Ce(le.value,"controlend",()=>o("end",le.value)),Ce(le.value,"controlstart",()=>o("start",le.value))}const{onBeforeRender:k}=H.useLoop();return k(({delta:V,invalidate:U})=>{var B,R;(B=le.value)!=null&&B.enabled&&((R=le.value)==null||R.update(V),U())}),u.onUnmounted(()=>{le.value&&le.value.disconnect()}),e({instance:le}),(V,U)=>(V.camera||u.unref(X))&&(V.domElement||u.unref(E))?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:le,"min-polar-angle":u.unref(s),"max-polar-angle":u.unref(i),"min-azimuth-angle":u.unref(c),"max-azimuth-angle":u.unref(h),distance:u.unref(p),"min-distance":u.unref(f),"max-distance":u.unref(m),"infinity-dolly":u.unref(d),"min-zoom":u.unref(g),"max-zoom":u.unref(y),"smooth-time":u.unref(v),"dragging-smooth-time":u.unref(_),"max-speed":u.unref(A),"azimuth-rotate-speed":u.unref(b),"polar-rotate-speed":u.unref(C),"dolly-speed":u.unref(L),"dolly-drag-inverted":u.unref(M),"truck-speed":u.unref(P),"dolly-to-cursor":u.unref(w),"drag-to-offset":u.unref(S),"vertical-drag-to-forward":u.unref(x),"boundary-friction":u.unref(I),"rest-threshold":u.unref(D),"collider-meshes":u.unref(z),args:[V.camera||u.unref(X),V.domElement||u.unref(E).domElement],"mouse-buttons":ne.value,touches:ce.value},null,8,gu)):u.createCommentVNode("",!0)}}),_u=u.defineComponent({__name:"KeyboardControls",props:{makeDefault:{type:Boolean,default:!0},camera:{},domElement:{},moveSpeed:{default:.2},selector:{}},emits:["isLock","change"],setup(a,{expose:e,emit:t}){const n=a,o=t,{moveSpeed:r}=u.toRefs(n),{camera:s,controls:i,renderer:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.ref(0),f=u.ref(0),{KeyW:m,KeyA:d,KeyS:g,KeyD:y,Up:v,Down:_,Left:A,Right:b}=Ui();u.watchEffect(()=>{d.value||A.value?p.value=-r.value:y.value||b.value?p.value=r.value:p.value=0,m.value||v.value?f.value=r.value:g.value||_.value?f.value=-r.value:f.value=0}),e({instance:i});const C=I=>o("isLock",I),L=I=>o("change",I),M=new l.Vector3,P=new l.Vector3,w=new l.Quaternion,S=(I,D)=>{var X;if(!((X=s.value)!=null&&X.position)&&!M)return;const z=s.value,G=I*.001;z==null||z.translateZ(-D),w.set(P.x*G,P.y*G,P.z*G,1).normalize(),z==null||z.quaternion.multiply(w),(p.value||f.value)&&o("change",i.value)},{onBeforeRender:x}=H.useLoop();return x(({delta:I,invalidate:D})=>{var z;i.value instanceof _r&&((z=i.value)!=null&&z.isLocked)&&(S(I,f.value),i.value.moveRight(p.value),D())}),(I,D)=>(u.openBlock(),u.createBlock(u.unref(_s),{selector:I.selector,"make-default":I.makeDefault,camera:I.camera||u.unref(s),"dom-element":I.domElement||u.unref(c).domElement,onIsLock:C,onChange:L},null,8,["selector","make-default","camera","dom-element"]))}}),vu=["args","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","enable-zoom","zoom-speed","enable-rotate","rotate-speed"],xu=u.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,{autoRotate:o,autoRotateSpeed:r,enableDamping:s,dampingFactor:i,enablePan:c,keyPanSpeed:h,maxAzimuthAngle:p,minAzimuthAngle:f,maxPolarAngle:m,minPolarAngle:d,minDistance:g,maxDistance:y,minZoom:v,maxZoom:_,enableZoom:A,zoomSpeed:b,enableRotate:C,rotateSpeed:L}=u.toRefs(n),{camera:M,renderer:P,extend:w,controls:S,invalidate:x}=H.useTresContext();u.watch(n,()=>{x()});const I=u.shallowRef(null);w({MapControls:rl}),u.watch(S,z=>{z&&n.makeDefault?S.value=z:S.value=null});const{onBeforeRender:D}=H.useLoop();return D(({invalidate:z})=>{I.value&&(s.value||o.value)&&(I.value.update(),z())}),u.onUnmounted(()=>{I.value&&I.value.dispose()}),e({instance:I}),(z,G)=>(z.camera||u.unref(M))&&(z.domElement||u.unref(P))?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:I,args:[z.camera||u.unref(M),z.domElement||u.unref(P).domElement],"auto-rotate":u.unref(o),"auto-rotate-speed":u.unref(r),"enable-damping":u.unref(s),"damping-factor":u.unref(i),"enable-pan":u.unref(c),"key-pan-speed":u.unref(h),keys:z.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(f),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(d),"min-distance":u.unref(g),"max-distance":u.unref(y),"min-zoom":u.unref(v),"max-zoom":u.unref(_),"enable-zoom":u.unref(A),"zoom-speed":u.unref(b),"enable-rotate":u.unref(C),"rotate-speed":u.unref(L)},null,8,vu)):u.createCommentVNode("",!0)}}),wu=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","args"],bu=u.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,o=t,{makeDefault:r,autoRotate:s,autoRotateSpeed:i,enableDamping:c,dampingFactor:h,enablePan:p,keyPanSpeed:f,maxAzimuthAngle:m,minAzimuthAngle:d,maxPolarAngle:g,minPolarAngle:y,minDistance:v,maxDistance:_,minZoom:A,maxZoom:b,enableZoom:C,zoomSpeed:L,enableRotate:M,touches:P,rotateSpeed:w,target:S}=u.toRefs(n),{camera:x,renderer:I,extend:D,controls:z,invalidate:G}=H.useTresContext(),X=u.shallowRef(null);D({OrbitControls:wr}),u.watch(X,q=>{E(),q&&r.value?z.value=q:z.value=null});function E(){Ce(X.value,"change",()=>{o("change",X.value),G()}),Ce(X.value,"start",()=>o("start",X.value)),Ce(X.value,"end",()=>o("end",X.value))}const{onBeforeRender:te}=H.useLoop();return te(({invalidate:q})=>{X.value&&(c.value||s.value)&&(X.value.update(),s.value&&q())}),u.onUnmounted(()=>{X.value&&X.value.dispose()}),e({instance:X}),(q,oe)=>(q.camera||u.unref(x))&&(q.domElement||u.unref(I))?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:X,target:u.unref(S),"auto-rotate":u.unref(s),"auto-rotate-speed":u.unref(i),"enable-damping":u.unref(c),"damping-factor":u.unref(h),"enable-pan":u.unref(p),"key-pan-speed":u.unref(f),keys:q.keys,"max-azimuth-angle":u.unref(m),"min-azimuth-angle":u.unref(d),"max-polar-angle":u.unref(g),"min-polar-angle":u.unref(y),"min-distance":u.unref(v),"max-distance":u.unref(_),"min-zoom":u.unref(A),"max-zoom":u.unref(b),touches:u.unref(P),"enable-zoom":u.unref(C),"zoom-speed":u.unref(L),"enable-rotate":u.unref(M),"rotate-speed":u.unref(w),args:[q.camera||u.unref(x),q.domElement||u.unref(I).domElement]},null,8,wu)):u.createCommentVNode("",!0)}}),Mu=["args"],_s=u.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock","change"],setup(a,{expose:e,emit:t}){const n=a,o=t,{camera:r,renderer:s,extend:i,controls:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.shallowRef(null);let f;i({PointerLockControls:_r});const m=d=>{o("isLock",d)};return u.watch(p,d=>{d&&n.makeDefault?c.value=d:c.value=null,f=document.getElementById(n.selector||"")||s.value.domElement,Ce(f,"click",()=>{p.value&&(p.value.lock(),p.value.addEventListener("lock",()=>m(!0)),p.value.addEventListener("unlock",()=>m(!1)),h())})}),u.onUnmounted(()=>{const d=p.value;d&&(d.removeEventListener("lock",()=>m(!0)),d.removeEventListener("unlock",()=>m(!1)),d.dispose())}),e({instance:c}),(d,g)=>(d.camera||u.unref(r))&&(d.domElement||u.unref(s))?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:p,args:[d.camera||u.unref(r),d.domElement||u.unref(s).domElement]},null,8,Mu)):u.createCommentVNode("",!0)}}),Su=u.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(a,{expose:e,emit:t}){const n=a,o=t,{logWarning:r}=H.useLogger();n.smoothScroll<0&&r("SmoothControl must be greater than zero"),n.pages<0&&r("Pages must be greater than zero");const{camera:s,controls:i,renderer:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.shallowRef(),f=document.createElement("div"),{y:m}=zi(),{x:d,y:g,isScrolling:y}=ki(f),{height:v,width:_}=Ko();let A=0;const b=u.ref(!1),C=u.ref(0),L=u.ref(0),M=u.ref(0),P=n.horizontal?"x":"y",w=u.watch(s,x=>{if(b.value){w();return}A=n.horizontal?(x==null?void 0:x.position.x)||0:(x==null?void 0:x.position.y)||0,b.value=!0},{immediate:!0});u.watch(y,x=>{i.value&&(i.value.enabled=!x)},{immediate:!0}),u.watch(m,x=>{!y.value&&!n.htmlScroll||(L.value=x/v.value/(M.value/v.value-1),C.value=-1*L.value,o("update:modelValue",L.value))}),u.watch(g,x=>{L.value=x/v.value/(M.value/v.value),C.value=-1*L.value,o("update:modelValue",L.value)}),u.watch(d,x=>{L.value=x/_.value/(M.value/_.value-1),C.value=+L.value,o("update:modelValue",L.value)}),u.watch(c,x=>{var D,z;const I=x==null?void 0:x.domElement;if(n.htmlScroll&&(x!=null&&x.domElement))I!=null&&I.style.width&&(I!=null&&I.style.position)&&(I!=null&&I.style.top)&&(I!=null&&I.style.left)&&(I.style.width="100%",I.style.position="fixed",I.style.zIndex=" -99999",I.style.top="0",I.style.left="0"),M.value=document.body.scrollHeight;else{const G=document.createElement("div"),X=document.createElement("div");f.style[n.horizontal?"overflowX":"overflowY"]="auto",f.style[n.horizontal?"overflowY":"overflowX"]="hidden",f.style.position="absolute",f.style.width="100%",f.style.height=" 100%",f.style.top="0",f.style.left="0",f.classList.add("scrollContainer"),G.style.position="sticky",G.style.top="0px",G.style.left="0px",G.style.width="100%",G.style.height="100%",G.style.overflow="hidden",f.appendChild(G),X.style.height=n.horizontal?"100%":`${v.value*n.pages}px`,X.style.width=n.horizontal?`${_.value*n.pages}px`:"100vw",X.style.pointerEvents="none",I.style.position="fixed",I.style.zIndex="0",I!=null&&I.style.width&&(I.style.width="100%"),f.appendChild(X),x!=null&&x.domElement.parentNode&&(x.domElement.parentNode.style.position="relative"),(z=(D=x==null?void 0:x.domElement)==null?void 0:D.parentNode)==null||z.appendChild(f),M.value=n.horizontal?_.value*n.pages:v.value*n.pages}},{immediate:!0});const{onBeforeRender:S}=H.useLoop();return S(({invalidate:x})=>{var I;if((I=s.value)!=null&&I.position){const D=(C.value*n.distance-s.value.position[P]+A)*n.smoothScroll;s.value.position[P]+=D,p.value.children.length>0&&(p.value.position[P]+=D),x()}}),e({instance:p}),(x,I)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:p},[u.renderSlot(x.$slots,"default")],512))}}),Au=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Pu=u.defineComponent({__name:"TransformControls",props:{object:{},camera:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(a,{expose:e,emit:t}){const n=a,o=t,{object:r,mode:s,enabled:i,axis:c,translationSnap:h,rotationSnap:p,scaleSnap:f,space:m,size:d,showX:g,showY:y,showZ:v}=u.toRefs(n),_=u.shallowRef(null),{controls:A,camera:b,renderer:C,extend:L,invalidate:M}=H.useTresContext();u.watch([r,s,i,c,h,p,f,m,d,g,y,v],()=>{M()}),L({TransformControls:Za});const P=()=>{M(),o("change")},w=z=>{A.value&&(A.value.enabled=!z.value),M(),o("dragging",z.value)},S=()=>{M(),o("mouseDown")},x=()=>{M(),o("mouseDown")},I=()=>{M(),o("objectChange")};function D(){Ce(_.value,"change",P),Ce(_.value,"dragging-changed",w),Ce(_.value,"mouseDown",S),Ce(_.value,"mouseUp",x),Ce(_.value,"objectChange",I)}return u.watch(_,z=>{z&&D()}),u.onUnmounted(()=>{_.value&&_.value.dispose()}),e({instance:_}),(z,G)=>{var X;return(z.camera||u.unref(b))&&u.unref(C)?(u.openBlock(),u.createElementBlock("TresTransformControls",{ref_key:"controlsRef",ref:_,key:(X=z.camera||u.unref(b))==null?void 0:X.uuid,object:u.unref(r),args:[z.camera||u.unref(b),u.unref(C).domElement],mode:u.unref(s),enabled:u.unref(i),axis:u.unref(c),"translation-snap":u.unref(h),"rotation-snap":u.unref(p),"scale-snap":u.unref(f),space:u.unref(m),size:u.unref(d),"show-x":u.unref(g),"show-y":u.unref(y),"show-z":u.unref(v),visible:!0},null,8,Au)):u.createCommentVNode("",!0)}}}),Cu=["geometry","render-order"],Tu=u.defineComponent({__name:"component",props:{src:{},skipStrokes:{type:Boolean,default:!1},skipFills:{type:Boolean,default:!1},fillMaterial:{},strokeMaterial:{},fillMeshProps:{},strokeMeshProps:{},depth:{default:"renderOrder"}},setup(a,{expose:e}){const t=a;class n extends Jt{load(b,C,L,M){const P=Array.isArray(b)?b[0]:b;super.load(P,C,L,M)}}const{src:o,skipStrokes:r,skipFills:s,fillMaterial:i,strokeMaterial:c,fillMeshProps:h,strokeMeshProps:p,depth:f}=u.toRefs(t),m=u.shallowRef(),d=u.shallowRef([]),g=u.shallowRef([]);e({instance:m}),u.watchEffect(async()=>y(o.value).then(A=>g.value=A.paths)),u.watch([s,r,i,c,g],_);async function y(A){const b=A.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${A}`):A;return H.useLoader(n,b)}u.onUnmounted(v);function v(){d.value.forEach(A=>A.geometry.dispose())}function _(){var M,P,w;v();const A=[],[b,C]=(()=>{const S={flat:!1,renderOrder:!1,offsetZ:!0},x={flat:0,renderOrder:0,offsetZ:.025},I=f.value;return typeof I=="number"?[!0,I]:[S[I],x[I]]})();let L=0;for(const S of g.value){const x=((M=S.userData)==null?void 0:M.style)??{},I=Object.assign({color:x.fill,opacity:x.fillOpacity,transparent:!0,side:l.DoubleSide,depthWrite:b},t.fillMaterial);if(!s.value&&x.fill!==void 0&&x.fill!=="none")for(const D of Jt.createShapes(S)){const z=new l.ShapeGeometry(D);z.scale(1,-1,1),C&&z.translate(0,0,L++*C),A.push({geometry:z,material:I,isStroke:!1})}if(!r.value&&x.stroke!==void 0&&x.stroke!=="none"){const D=Object.assign({color:(P=S.userData)==null?void 0:P.style.stroke,opacity:(w=S.userData)==null?void 0:w.style.strokeOpacity,transparent:!0,side:l.DoubleSide,depthWrite:b},t.strokeMaterial);for(const z of S.subPaths){const G=z.getPoints().map(E=>new l.Vector2(E.x,-E.y)),X=Jt.pointsToStroke(G,x||"none");C&&X.translate(0,0,L++*C),A.push({geometry:X,material:D,isStroke:!0})}}}d.value=A}return(A,b)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"svgRef",ref:m},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(d.value,({geometry:C,material:L,isStroke:M},P)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({key:`${P}`,ref_for:!0},M?u.unref(p):u.unref(h),{geometry:C,"render-order":u.unref(f)==="renderOrder"?P:0}),[u.createElementVNode("TresMeshBasicMaterial",u.mergeProps({ref_for:!0},L),null,16)],16,Cu))),128))],512))}});class Iu extends l.Loader{constructor(t){super(t);ue(this,"fbxLoader");this.fbxLoader=new Jl(t)}load(t,n,o,r){const s=Array.isArray(t)?t[0]:t;this.fbxLoader.load(s,n,o,r)}async loadAsync(t){const n=Array.isArray(t)?t[0]:t;return this.fbxLoader.loadAsync(n)}}const Ou=Iu;async function vs(a){return await H.useLoader(Ou,a)}const Lu=["object"],Du=u.defineComponent({__name:"component",props:{path:{},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref();e({instance:r});const s=([t,n]=u.withAsyncContext(()=>vs(o.path)),t=await t,n(),t);return(o.castShadow||o.receiveShadow)&&s.traverse(i=>{i.isMesh&&(i.castShadow=o.castShadow,i.receiveShadow=o.receiveShadow)}),(i,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:r,object:u.unref(s)},i.$attrs),null,16,Lu))}});class ku extends l.Loader{constructor(t){super(t);ue(this,"gltfLoader");this.gltfLoader=new il(t)}load(t,n,o,r){const s=Array.isArray(t)?t[0]:t;this.gltfLoader.load(s,n,o,r)}async loadAsync(t){const n=Array.isArray(t)?t[0]:t;return this.gltfLoader.loadAsync(n)}setDRACOLoader(t){return this.gltfLoader.setDRACOLoader(t)}}const Bu=ku;let xt=null;function Uu(a,e){return t=>{e&&e(t),a.draco&&(xt||(xt=new mc),xt.setDecoderPath(a.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader&&t.setDRACOLoader(xt))}}async function xs(a,e={draco:!1},t){const n=await H.useLoader(Bu,a,Uu(e,t));return xt==null||xt.dispose(),xt=null,n}const Nu=["object"],Fu=u.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref();e({instance:r});const{scene:s}=([t,n]=u.withAsyncContext(()=>xs(o.path,{draco:o.draco,decoderPath:o.decoderPath})),t=await t,n(),t);return(o.castShadow||o.receiveShadow)&&s.traverse(i=>{i.isMesh&&(i.castShadow=o.castShadow,i.receiveShadow=o.receiveShadow)}),(i,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:r,object:u.unref(s)},i.$attrs),null,16,Nu))}}),ws="[TresJS - Cientos ▲ ■ ♥] ";function zu(a,e){console.error(`${ws} ${a}`,e||"")}function Vu(a){console.warn(`${ws} ${a}`)}function Gu(a,e){}function bs(){return{logError:zu,logWarning:Vu,logMessage:Gu}}let Mo=0;function Ru(){const a=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:n}=bs();return new Promise(o=>{l.DefaultLoadingManager.onStart=()=>{a.value=!1},l.DefaultLoadingManager.onLoad=()=>{a.value=!0},l.DefaultLoadingManager.onProgress=(r,s,i)=>{s===i&&(Mo=i,a.value=!0,t.value.push(r)),e.value=Math.round((s-Mo)/(i-Mo)*100||100)},l.DefaultLoadingManager.onError=r=>{n("Error loading assets",new Error(r)),a.value=!0},o({items:t,hasFinishLoading:a,progress:e})})}async function ju(a,e){const{logError:t}=bs();if(!a)return t("Error no path provided");const{unsuspend:n,start:o,crossOrigin:r,muted:s,loop:i,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function h(){return new Promise((p,f)=>{const m=Object.assign(document.createElement("video"),{src:typeof a=="string"&&a||void 0,crossOrigin:r,loop:i,muted:s,autoplay:!0,...c}),d=new l.VideoTexture(m);return m.addEventListener(n,()=>p(d)),m.addEventListener("error",()=>f(new Error("Error loading video"))),d})}try{const p=await h();return o&&p.image&&p.image.play(),p}catch{t("Error loading resource")}}function on(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function On(a){throw new Error('Could not dynamically require "'+a+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var So={exports:{}},Ms;function Wu(){return Ms||(Ms=1,function(a,e){(function(t){a.exports=t()})(function(){return function t(n,o,r){function s(h,p){if(!o[h]){if(!n[h]){var f=typeof On=="function"&&On;if(!p&&f)return f(h,!0);if(i)return i(h,!0);throw new Error("Cannot find module '"+h+"'")}p=o[h]={exports:{}},n[h][0].call(p.exports,function(m){var d=n[h][1][m];return s(d||m)},p,p.exports,t,n,o,r)}return o[h].exports}for(var i=typeof On=="function"&&On,c=0;c<r.length;c++)s(r[c]);return s}({1:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g=t("crypto");function y(M,P){P=A(M,P);var w;return(w=P.algorithm!=="passthrough"?g.createHash(P.algorithm):new L).write===void 0&&(w.write=w.update,w.end=w.update),C(P,w).dispatch(M),w.update||w.end(""),w.digest?w.digest(P.encoding==="buffer"?void 0:P.encoding):(M=w.read(),P.encoding!=="buffer"?M.toString(P.encoding):M)}(o=n.exports=y).sha1=function(M){return y(M)},o.keys=function(M){return y(M,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},o.MD5=function(M){return y(M,{algorithm:"md5",encoding:"hex"})},o.keysMD5=function(M){return y(M,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var v=g.getHashes?g.getHashes().slice():["sha1","md5"],_=(v.push("passthrough"),["buffer","hex","binary","base64"]);function A(M,P){var w={};if(w.algorithm=(P=P||{}).algorithm||"sha1",w.encoding=P.encoding||"hex",w.excludeValues=!!P.excludeValues,w.algorithm=w.algorithm.toLowerCase(),w.encoding=w.encoding.toLowerCase(),w.ignoreUnknown=P.ignoreUnknown===!0,w.respectType=P.respectType!==!1,w.respectFunctionNames=P.respectFunctionNames!==!1,w.respectFunctionProperties=P.respectFunctionProperties!==!1,w.unorderedArrays=P.unorderedArrays===!0,w.unorderedSets=P.unorderedSets!==!1,w.unorderedObjects=P.unorderedObjects!==!1,w.replacer=P.replacer||void 0,w.excludeKeys=P.excludeKeys||void 0,M===void 0)throw new Error("Object argument required.");for(var S=0;S<v.length;++S)v[S].toLowerCase()===w.algorithm.toLowerCase()&&(w.algorithm=v[S]);if(v.indexOf(w.algorithm)===-1)throw new Error('Algorithm "'+w.algorithm+'" not supported. supported values: '+v.join(", "));if(_.indexOf(w.encoding)===-1&&w.algorithm!=="passthrough")throw new Error('Encoding "'+w.encoding+'" not supported. supported values: '+_.join(", "));return w}function b(M){if(typeof M=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(M))!=null}function C(M,P,w){w=w||[];function S(x){return P.update?P.update(x,"utf8"):P.write(x,"utf8")}return{dispatch:function(x){return this["_"+((x=M.replacer?M.replacer(x):x)===null?"null":typeof x)](x)},_object:function(x){var I,D=Object.prototype.toString.call(x),z=/\[object (.*)\]/i.exec(D);if(z=(z=z?z[1]:"unknown:["+D+"]").toLowerCase(),0<=(D=w.indexOf(x)))return this.dispatch("[CIRCULAR:"+D+"]");if(w.push(x),i!==void 0&&i.isBuffer&&i.isBuffer(x))return S("buffer:"),S(x);if(z==="object"||z==="function"||z==="asyncfunction")return D=Object.keys(x),M.unorderedObjects&&(D=D.sort()),M.respectType===!1||b(x)||D.splice(0,0,"prototype","__proto__","constructor"),M.excludeKeys&&(D=D.filter(function(G){return!M.excludeKeys(G)})),S("object:"+D.length+":"),I=this,D.forEach(function(G){I.dispatch(G),S(":"),M.excludeValues||I.dispatch(x[G]),S(",")});if(!this["_"+z]){if(M.ignoreUnknown)return S("["+z+"]");throw new Error('Unknown object type "'+z+'"')}this["_"+z](x)},_array:function(x,G){G=G!==void 0?G:M.unorderedArrays!==!1;var D=this;if(S("array:"+x.length+":"),!G||x.length<=1)return x.forEach(function(X){return D.dispatch(X)});var z=[],G=x.map(function(X){var E=new L,te=w.slice();return C(M,E,te).dispatch(X),z=z.concat(te.slice(w.length)),E.read().toString()});return w=w.concat(z),G.sort(),this._array(G,!1)},_date:function(x){return S("date:"+x.toJSON())},_symbol:function(x){return S("symbol:"+x.toString())},_error:function(x){return S("error:"+x.toString())},_boolean:function(x){return S("bool:"+x.toString())},_string:function(x){S("string:"+x.length+":"),S(x.toString())},_function:function(x){S("fn:"),b(x)?this.dispatch("[native]"):this.dispatch(x.toString()),M.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(x.name)),M.respectFunctionProperties&&this._object(x)},_number:function(x){return S("number:"+x.toString())},_xml:function(x){return S("xml:"+x.toString())},_null:function(){return S("Null")},_undefined:function(){return S("Undefined")},_regexp:function(x){return S("regex:"+x.toString())},_uint8array:function(x){return S("uint8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint8clampedarray:function(x){return S("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(x))},_int8array:function(x){return S("int8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint16array:function(x){return S("uint16array:"),this.dispatch(Array.prototype.slice.call(x))},_int16array:function(x){return S("int16array:"),this.dispatch(Array.prototype.slice.call(x))},_uint32array:function(x){return S("uint32array:"),this.dispatch(Array.prototype.slice.call(x))},_int32array:function(x){return S("int32array:"),this.dispatch(Array.prototype.slice.call(x))},_float32array:function(x){return S("float32array:"),this.dispatch(Array.prototype.slice.call(x))},_float64array:function(x){return S("float64array:"),this.dispatch(Array.prototype.slice.call(x))},_arraybuffer:function(x){return S("arraybuffer:"),this.dispatch(new Uint8Array(x))},_url:function(x){return S("url:"+x.toString())},_map:function(x){return S("map:"),x=Array.from(x),this._array(x,M.unorderedSets!==!1)},_set:function(x){return S("set:"),x=Array.from(x),this._array(x,M.unorderedSets!==!1)},_file:function(x){return S("file:"),this.dispatch([x.name,x.size,x.type,x.lastModfied])},_blob:function(){if(M.ignoreUnknown)return S("[blob]");throw Error(`Hashing Blob objects is currently not supported
1017
1017
  (see https://github.com/puleos/object-hash/issues/26)
1018
1018
  Use "options.replacer" or "options.ignoreUnknown"
1019
1019
  `)},_domwindow:function(){return S("domwindow")},_bigint:function(x){return S("bigint:"+x.toString())},_process:function(){return S("process")},_timer:function(){return S("timer")},_pipe:function(){return S("pipe")},_tcp:function(){return S("tcp")},_udp:function(){return S("udp")},_tty:function(){return S("tty")},_statwatcher:function(){return S("statwatcher")},_securecontext:function(){return S("securecontext")},_connection:function(){return S("connection")},_zlib:function(){return S("zlib")},_context:function(){return S("context")},_nodescript:function(){return S("nodescript")},_httpparser:function(){return S("httpparser")},_dataview:function(){return S("dataview")},_signal:function(){return S("signal")},_fsevent:function(){return S("fsevent")},_tlswrap:function(){return S("tlswrap")}}}function L(){return{buf:"",write:function(M){this.buf+=M},end:function(M){this.buf+=M},read:function(){return this.buf}}}o.writeToStream=function(M,P,w){return w===void 0&&(w=P,P={}),C(P=A(M,P),w).dispatch(M)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){(function(g){var y=typeof Uint8Array<"u"?Uint8Array:Array,v=43,_=47,A=48,b=97,C=65,L=45,M=95;function P(w){return w=w.charCodeAt(0),w===v||w===L?62:w===_||w===M?63:w<A?-1:w<A+10?w-A+26+26:w<C+26?w-C:w<b+26?w-b+26:void 0}g.toByteArray=function(w){var S,x;if(0<w.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var I=w.length,I=w.charAt(I-2)==="="?2:w.charAt(I-1)==="="?1:0,D=new y(3*w.length/4-I),z=0<I?w.length-4:w.length,G=0;function X(E){D[G++]=E}for(S=0;S<z;S+=4,0)X((16711680&(x=P(w.charAt(S))<<18|P(w.charAt(S+1))<<12|P(w.charAt(S+2))<<6|P(w.charAt(S+3))))>>16),X((65280&x)>>8),X(255&x);return I==2?X(255&(x=P(w.charAt(S))<<2|P(w.charAt(S+1))>>4)):I==1&&(X((x=P(w.charAt(S))<<10|P(w.charAt(S+1))<<4|P(w.charAt(S+2))>>2)>>8&255),X(255&x)),D},g.fromByteArray=function(w){var S,x,I,D,z=w.length%3,G="";function X(E){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(E)}for(S=0,I=w.length-z;S<I;S+=3)x=(w[S]<<16)+(w[S+1]<<8)+w[S+2],G+=X((D=x)>>18&63)+X(D>>12&63)+X(D>>6&63)+X(63&D);switch(z){case 1:G=(G+=X((x=w[w.length-1])>>2))+X(x<<4&63)+"==";break;case 2:G=(G=(G+=X((x=(w[w.length-2]<<8)+w[w.length-1])>>10))+X(x>>4&63))+X(x<<2&63)+"="}return G}})(o===void 0?this.base64js={}:o)}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(t,n,o){(function(r,s,v,c,h,p,f,m,d){var g=t("base64-js"),y=t("ieee754");function v(T,O,N){if(!(this instanceof v))return new v(T,O,N);var K,W,Y,Q,re=typeof T;if(O==="base64"&&re=="string")for(T=(Q=T).trim?Q.trim():Q.replace(/^\s+|\s+$/g,"");T.length%4!=0;)T+="=";if(re=="number")K=q(T);else if(re=="string")K=v.byteLength(T,O);else{if(re!="object")throw new Error("First argument needs to be a number, array or string.");K=q(T.length)}if(v._useTypedArrays?W=v._augment(new Uint8Array(K)):((W=this).length=K,W._isBuffer=!0),v._useTypedArrays&&typeof T.byteLength=="number")W._set(T);else if(oe(Q=T)||v.isBuffer(Q)||Q&&typeof Q=="object"&&typeof Q.length=="number")for(Y=0;Y<K;Y++)v.isBuffer(T)?W[Y]=T.readUInt8(Y):W[Y]=T[Y];else if(re=="string")W.write(T,0,O);else if(re=="number"&&!v._useTypedArrays&&!N)for(Y=0;Y<K;Y++)W[Y]=0;return W}function _(T,O,N,K){return v._charsWritten=de(function(W){for(var Y=[],Q=0;Q<W.length;Q++)Y.push(255&W.charCodeAt(Q));return Y}(O),T,N,K)}function A(T,O,N,K){return v._charsWritten=de(function(W){for(var Y,Q,re=[],se=0;se<W.length;se++)Q=W.charCodeAt(se),Y=Q>>8,Q=Q%256,re.push(Q),re.push(Y);return re}(O),T,N,K)}function b(T,O,N){var K="";N=Math.min(T.length,N);for(var W=O;W<N;W++)K+=String.fromCharCode(T[W]);return K}function C(T,O,N,Y){Y||(R(typeof N=="boolean","missing or invalid endian"),R(O!=null,"missing offset"),R(O+1<T.length,"Trying to read beyond buffer length"));var W,Y=T.length;if(!(Y<=O))return N?(W=T[O],O+1<Y&&(W|=T[O+1]<<8)):(W=T[O]<<8,O+1<Y&&(W|=T[O+1])),W}function L(T,O,N,Y){Y||(R(typeof N=="boolean","missing or invalid endian"),R(O!=null,"missing offset"),R(O+3<T.length,"Trying to read beyond buffer length"));var W,Y=T.length;if(!(Y<=O))return N?(O+2<Y&&(W=T[O+2]<<16),O+1<Y&&(W|=T[O+1]<<8),W|=T[O],O+3<Y&&(W+=T[O+3]<<24>>>0)):(O+1<Y&&(W=T[O+1]<<16),O+2<Y&&(W|=T[O+2]<<8),O+3<Y&&(W|=T[O+3]),W+=T[O]<<24>>>0),W}function M(T,O,N,K){if(K||(R(typeof N=="boolean","missing or invalid endian"),R(O!=null,"missing offset"),R(O+1<T.length,"Trying to read beyond buffer length")),!(T.length<=O))return K=C(T,O,N,!0),32768&K?-1*(65535-K+1):K}function P(T,O,N,K){if(K||(R(typeof N=="boolean","missing or invalid endian"),R(O!=null,"missing offset"),R(O+3<T.length,"Trying to read beyond buffer length")),!(T.length<=O))return K=L(T,O,N,!0),2147483648&K?-1*(4294967295-K+1):K}function w(T,O,N,K){return K||(R(typeof N=="boolean","missing or invalid endian"),R(O+3<T.length,"Trying to read beyond buffer length")),y.read(T,O,N,23,4)}function S(T,O,N,K){return K||(R(typeof N=="boolean","missing or invalid endian"),R(O+7<T.length,"Trying to read beyond buffer length")),y.read(T,O,N,52,8)}function x(T,O,N,K,W){if(W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+1<T.length,"trying to write beyond buffer length"),V(O,65535)),W=T.length,!(W<=N))for(var Y=0,Q=Math.min(W-N,2);Y<Q;Y++)T[N+Y]=(O&255<<8*(K?Y:1-Y))>>>8*(K?Y:1-Y)}function I(T,O,N,K,W){if(W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+3<T.length,"trying to write beyond buffer length"),V(O,4294967295)),W=T.length,!(W<=N))for(var Y=0,Q=Math.min(W-N,4);Y<Q;Y++)T[N+Y]=O>>>8*(K?Y:3-Y)&255}function D(T,O,N,K,W){W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+1<T.length,"Trying to write beyond buffer length"),U(O,32767,-32768)),T.length<=N||x(T,0<=O?O:65535+O+1,N,K,W)}function z(T,O,N,K,W){W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+3<T.length,"Trying to write beyond buffer length"),U(O,2147483647,-2147483648)),T.length<=N||I(T,0<=O?O:4294967295+O+1,N,K,W)}function G(T,O,N,K,W){W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+3<T.length,"Trying to write beyond buffer length"),B(O,34028234663852886e22,-34028234663852886e22)),T.length<=N||y.write(T,O,N,K,23,4)}function X(T,O,N,K,W){W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+7<T.length,"Trying to write beyond buffer length"),B(O,17976931348623157e292,-17976931348623157e292)),T.length<=N||y.write(T,O,N,K,52,8)}o.Buffer=v,o.SlowBuffer=v,o.INSPECT_MAX_BYTES=50,v.poolSize=8192,v._useTypedArrays=function(){try{var T=new ArrayBuffer(0),O=new Uint8Array(T);return O.foo=function(){return 42},O.foo()===42&&typeof O.subarray=="function"}catch{return!1}}(),v.isEncoding=function(T){switch(String(T).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},v.isBuffer=function(T){return!(T==null||!T._isBuffer)},v.byteLength=function(T,O){var N;switch(T+="",O||"utf8"){case"hex":N=T.length/2;break;case"utf8":case"utf-8":N=ce(T).length;break;case"ascii":case"binary":case"raw":N=T.length;break;case"base64":N=le(T).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":N=2*T.length;break;default:throw new Error("Unknown encoding")}return N},v.concat=function(T,O){if(R(oe(T),`Usage: Buffer.concat(list, [totalLength])
@@ -1476,7 +1476,7 @@ void main() {
1476
1476
  mvPosition.xy += rotatedPosition;
1477
1477
 
1478
1478
  gl_Position = projectionMatrix * mvPosition;
1479
- }`;const rn=new l.Vector3(0,0,0),Uo=new l.Vector3(0,0,0),Jh=new l.Vector3(0,0,0);function Rs(a,e,t){const n=rn.setFromMatrixPosition(a.matrixWorld);n.project(e);const o=t.width/2,r=t.height/2;return[(Number.isNaN(n.x)?0:n.x)*o+o,-(n.y*r)+r]}function Hh(a,e){const t=rn.setFromMatrixPosition(a.matrixWorld),n=Uo.setFromMatrixPosition(e.matrixWorld),o=t.sub(n),r=e.getWorldDirection(Jh);return o.angleTo(r)>Math.PI/2}function $h(a,e,t,n){const o=rn.setFromMatrixPosition(a.matrixWorld),r=o.clone();r.project(e),t.setFromCamera(new l.Vector2(r.x,r.y),e);const s=t.intersectObjects(n,!0);if(s.length>0){const i=s[0].distance;return o.distanceTo(t.ray.origin)<i}return!0}function ef(a,e){if(e instanceof l.OrthographicCamera)return e.zoom;if(e instanceof l.PerspectiveCamera){const t=rn.setFromMatrixPosition(a.matrixWorld),n=Uo.setFromMatrixPosition(e.matrixWorld),o=e.fov*Math.PI/180,r=t.distanceTo(n);return 1/(2*Math.tan(o/2)*r)}else return 1}function tf(a,e,t){if(e instanceof l.PerspectiveCamera||e instanceof l.OrthographicCamera){const n=rn.setFromMatrixPosition(a.matrixWorld),o=Uo.setFromMatrixPosition(e.matrixWorld),r=n.distanceTo(o),s=(t[1]-t[0])/(e.far-e.near),i=t[1]-s*e.far;return Math.round(s*r+i)}}const No=a=>Math.abs(a)<1e-10?0:a;function js(a,e,t=""){let n="matrix3d(";for(let o=0;o!==16;o++)n+=No(e[o]*a.elements[o])+(o!==15?",":")");return t+n}const nf=(a=>e=>js(e,a))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),of=(a=>(e,t)=>js(e,a(t),"translate(-50%,-50%)"))(a=>[1/a,1/a,1/a,1,-1/a,-1/a,-1/a,-1,1/a,1/a,1/a,1,1,1,1,1]),rf=["geometry","material"],sf=u.defineComponent({__name:"HTML",props:{geometry:{default:new l.PlaneGeometry},material:{},as:{default:"div"},transform:{type:Boolean,default:!1},portal:{},wrapperClass:{},eps:{default:1e-4},distanceFactor:{},fullscreen:{type:Boolean},center:{type:Boolean},pointerEvents:{default:"auto"},sprite:{type:Boolean,default:!1},zIndexRange:{default:()=>[16777271,0]},occlude:{type:[Object,null,Array,Boolean,String]}},emits:["onOcclude"],setup(a,{expose:e,emit:t}){const n=a,o=t,r=u.useSlots(),s=u.useAttrs(),i=u.ref(),c=u.ref(),{geometry:h,material:p,as:f,transform:m,portal:d,wrapperClass:g,eps:y,distanceFactor:v,fullscreen:_,center:A,pointerEvents:b,sprite:C,occlude:L,zIndexRange:M}=u.toRefs(n),{renderer:P,scene:w,camera:S,raycaster:x,sizes:I}=H.useTresContext(),D=u.computed(()=>document.createElement(f.value)),z=u.ref([0,0]),G=u.ref(0),X=u.ref(),E=u.computed(()=>m.value?{position:"absolute",top:0,left:0,width:`${I.width.value}px`,height:`${I.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2,willChange:"transform"}:{position:"absolute",transform:A.value?"translate3d(-50%,-50%,0)":"none",..._.value&&{top:-I.height.value/2,left:-I.width.value/2,width:`${I.width.value}px`,height:`${I.height.value}px`},zIndex:2,...Object.assign({},s.style),willChange:"transform"}),te=u.computed(()=>({position:"absolute",pointerEvents:b.value})),q=u.ref(null),oe=u.ref(!1),ne=u.computed(()=>(L==null?void 0:L.value)&&(L==null?void 0:L.value)!=="blending"||Array.isArray(L==null?void 0:L.value)&&(L==null?void 0:L.value.length)&&u.isRef(L.value[0]));u.watch(()=>L,({value:V})=>{V==="blending"?(D.value.style.zIndex=`${Math.floor(M.value[0]/2)}`,D.value.style.position="absolute",D.value.style.pointerEvents="none"):(D.value.style.zIndex=null,D.value.style.position=null,D.value.style.pointerEvents=null)}),u.watch(()=>{var V;return[i.value,P.value,I.width.value,I.height.value,(V=r.default)==null?void 0:V.call(r)]},([V,U])=>{var B,R,T,O,N,K;if(V&&U){const W=(d==null?void 0:d.value)||U.domElement;if((B=w.value)==null||B.updateMatrixWorld(),m.value)D.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const Y=Rs(V,S.value,{width:I.width.value,height:I.height.value});D.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${Y[0]}px,${Y[1]}px,0);transform-origin:0 0;`}W&&!D.value.parentNode&&((R=W.parentNode)==null||R.appendChild(D.value)),m.value?X.value=u.createVNode("div",{id:"outer",style:E.value},[u.createVNode("div",{id:"inner",style:te.value},[u.createVNode("div",{key:(T=c.value)==null?void 0:T.uuid,id:w==null?void 0:w.value.uuid,class:s.class,style:s.style},(O=r.default)==null?void 0:O.call(r))])]):X.value=u.createVNode("div",{key:(N=c.value)==null?void 0:N.uuid,id:w==null?void 0:w.value.uuid,style:E.value},(K=r.default)==null?void 0:K.call(r)),u.render(X.value,D.value)}}),u.watchEffect(()=>{g!=null&&g.value&&(D.value.className=g.value)});const ce=u.ref(!0),{onBeforeRender:le}=H.useLoop();le(({invalidate:V})=>{var U,B,R,T,O,N,K;if(V(),i.value&&S.value&&P.value){(U=S.value)==null||U.updateMatrixWorld(),i.value.updateWorldMatrix(!0,!1);const W=m.value?z.value:Rs(i.value,S.value,{width:I.width.value||0,height:I.height.value||0});if(m.value||Math.abs(G.value-S.value.zoom)>y.value||Math.abs(z.value[0]-W[0])>y.value||Math.abs(z.value[1]-W[1])>y.value){const Y=Hh(i.value,S.value);let Q=!1;ne.value&&(Array.isArray(L==null?void 0:L.value)?Q=L==null?void 0:L.value:(L==null?void 0:L.value)!=="blending"&&(Q=[w.value]));const re=ce.value;if(Q){const F=$h(i.value,S.value,x.value,Q);ce.value=F&&!Y}else ce.value=!Y;re!==ce.value&&(o("onOcclude",!ce.value),D.value.style.display=ce.value?"block":"none");const se=Math.floor(M.value[0]/2),j=L!=null&&L.value?ne.value?[M.value[0],se]:[se-1,0]:M.value;if(D.value.style.zIndex=`${tf(i.value,S.value,j)}`,D.value.style.willChange="transform",m.value){const[F,ie]=[I.width.value/2,I.height.value/2],he=S.value.projectionMatrix.elements[5]*ie,{isOrthographicCamera:_e,top:Le,left:Pe,bottom:Je,right:wt}=S.value,It=nf(S.value.matrixWorldInverse),it=_e?`scale(${he})translate(${No(-(wt+Pe)/2)}px,${No((Le+Je)/2)}px)`:`translateZ(${he}px)`;let Ee=i.value.matrixWorld;if(C.value&&(Ee=S.value.matrixWorldInverse.clone().transpose().copyPosition(Ee).scale(i.value.scale),Ee.elements[3]=Ee.elements[7]=Ee.elements[11]=0,Ee.elements[15]=1),D.value.style.width=`${I.width.value}px`,D.value.style.height=`${I.height.value}px`,D.value.style.perspective=_e?"":`${he}px`,(B=X.value)!=null&&B.el&&((R=X.value)!=null&&R.children)&&Array.isArray(X.value.children)){X.value.el.style.willChange="transform",X.value.el.style.transform=`${it}${It}translate(${F}px,${ie}px)`;const et=X.value.children[0];et&&et.el&&(et.el.style.willChange="transform",et.el.style.transform=of(Ee,1/(((v==null?void 0:v.value)||10)/400)))}}else{const F=(v==null?void 0:v.value)===void 0?1:ef(i.value,S.value)*(v==null?void 0:v.value);D.value.style.transform=`translate3d(${W[0]}px,${W[1]}px,0) scale(${F})`}}z.value=W,G.value=S.value.zoom}if(!ne.value&&c.value&&!oe.value)if(m.value){if((T=X.value)!=null&&T.el&&((O=X.value)!=null&&O.children)){const W=((N=X.value)==null?void 0:N.children)[0];if(W!=null&&W.clientWidth&&(W!=null&&W.clientHeight)){const{isOrthographicCamera:Y}=S.value;if(Y||h)s.scale&&(Array.isArray(s.scale)?s.scale instanceof l.Vector3?c.value.scale.copy(s.scale.clone().divideScalar(1)):c.value.scale.set(1/s.scale[0],1/s.scale[1],1/s.scale[2]):c.value.scale.setScalar(1/s.scale));else{const Q=((v==null?void 0:v.value)||10)/400,re=W.clientWidth*Q,se=W.clientHeight*Q;c.value.scale.set(re,se,1)}oe.value=!0}}}else{const W=D.value.children[0];if(W!=null&&W.clientWidth&&(W!=null&&W.clientHeight)){const Q=W.clientWidth*1,re=W.clientHeight*1;c.value.scale.set(Q,re,1),oe.value=!0}q.value.lookAt((K=S.value)==null?void 0:K.position)}});const de=u.computed(()=>({vertexShader:m.value?void 0:Qh,fragmentShader:qh})),k=u.computed(()=>{const V=de.value;return p.value||new l.ShaderMaterial({vertexShader:V.vertexShader,fragmentShader:V.fragmentShader,side:l.DoubleSide})});return u.onUnmounted(()=>{k.value&&k.value.dispose(),D.value.remove()}),e({instance:i}),(V,U)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:i},[u.unref(L)&&!ne.value?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:c,geometry:u.unref(h),material:k.value},null,8,rf)):u.createCommentVNode("",!0)],512))}});var Dn={exports:{}},af=Dn.exports,Ws;function lf(){return Ws||(Ws=1,function(a,e){(function(t,n){a.exports=n()})(af,function(){var t=function(){function n(d){return s.appendChild(d.dom),d}function o(d){for(var g=0;g<s.children.length;g++)s.children[g].style.display=g===d?"block":"none";r=d}var r=0,s=document.createElement("div");s.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",s.addEventListener("click",function(d){d.preventDefault(),o(++r%s.children.length)},!1);var i=(performance||Date).now(),c=i,h=0,p=n(new t.Panel("FPS","#0ff","#002")),f=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return o(0),{REVISION:16,dom:s,addPanel:n,showPanel:o,begin:function(){i=(performance||Date).now()},end:function(){h++;var d=(performance||Date).now();if(f.update(d-i,200),d>c+1e3&&(p.update(1e3*h/(d-c),100),c=d,h=0,m)){var g=performance.memory;m.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:s,setMode:o}};return t.Panel=function(n,o,r){var s=1/0,i=0,c=Math.round,h=c(window.devicePixelRatio||1),p=80*h,f=48*h,m=3*h,d=2*h,g=3*h,y=15*h,v=74*h,_=30*h,A=document.createElement("canvas");A.width=p,A.height=f,A.style.cssText="width:80px;height:48px";var b=A.getContext("2d");return b.font="bold "+9*h+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=r,b.fillRect(0,0,p,f),b.fillStyle=o,b.fillText(n,m,d),b.fillRect(g,y,v,_),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g,y,v,_),{dom:A,update:function(C,L){s=Math.min(s,C),i=Math.max(i,C),b.fillStyle=r,b.globalAlpha=1,b.fillRect(0,0,p,y),b.fillStyle=o,b.fillText(c(C)+" "+n+" ("+c(s)+"-"+c(i)+")",m,d),b.drawImage(A,g+h,y,v-h,_,g,y,v-h,_),b.fillRect(g+v-h,y,h,_),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g+v-h,y,h,c((1-C/L)*_))}}},t})}(Dn)),Dn.exports}var cf=lf();const uf=on(cf),hf=u.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(a,{expose:e}){const t=new uf;e({instance:t});const n=document.body;t.showPanel(a.showPanel||0),n==null||n.appendChild(t.dom);const{onBeforeRender:o,onAfterRender:r}=H.useLoop();o(()=>t.begin(),Number.NEGATIVE_INFINITY),r(()=>t.end(),Number.POSITIVE_INFINITY),u.onUnmounted(()=>{n==null||n.removeChild(t.dom)})}});class ff{constructor(e,t,n){this.name=e,this.fg=t,this.bg=n,this.gradient=null,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement("canvas"),this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.width="90px",this.canvas.style.height="48px",this.canvas.style.position="absolute",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.initializeCanvas()}createGradient(){if(!this.context)throw new Error("No context");const e=this.context.createLinearGradient(0,this.GRAPH_Y,0,this.GRAPH_Y+this.GRAPH_HEIGHT);let t;const n=this.fg;switch(this.fg.toLowerCase()){case"#0ff":t="#006666";break;case"#0f0":t="#006600";break;case"#ff0":t="#666600";break;case"#e1e1e1":t="#666666";break;default:t=this.bg;break}return e.addColorStop(0,t),e.addColorStop(1,n),e}initializeCanvas(){this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.gradient=this.createGradient(),this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillStyle=this.fg,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(e,t,n,o,r=0){if(!this.context||!this.gradient)return;const s=Math.min(1/0,e),i=Math.max(n,e);o=Math.max(o,t),this.context.globalAlpha=1,this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(`${e.toFixed(r)} ${this.name} (${s.toFixed(r)}-${parseFloat(i.toFixed(r))})`,this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT);const c=this.GRAPH_HEIGHT-(1-t/o)*this.GRAPH_HEIGHT;c>0&&(this.context.globalAlpha=1,this.context.fillStyle=this.gradient,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y+this.GRAPH_HEIGHT-c,this.PR,c))}}const Ys=class Wt{constructor({trackGPU:e=!1,logsPerSecond:t=30,samplesLog:n=60,samplesGraph:o=10,precision:r=2,minimal:s=!1,horizontal:i=!0,mode:c=0}={}){this.gl=null,this.ext=null,this.activeQuery=null,this.gpuQueries=[],this.threeRendererPatched=!1,this.frames=0,this.renderCount=0,this.isRunningCPUProfiling=!1,this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalGpuDurationCompute=0,this.totalFps=0,this.gpuPanel=null,this.gpuPanelCompute=null,this.averageFps={logs:[],graph:[]},this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.averageGpuCompute={logs:[],graph:[]},this.handleClick=h=>{h.preventDefault(),this.showPanel(++this.mode%this.dom.children.length)},this.handleResize=()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2),this.gpuPanelCompute&&this.resizePanel(this.gpuPanelCompute,3)},this.mode=c,this.horizontal=i,this.minimal=s,this.trackGPU=e,this.samplesLog=n,this.samplesGraph=o,this.precision=r,this.logsPerSecond=t,this.dom=document.createElement("div"),this.initializeDOM(),this.beginTime=performance.now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.fpsPanel=this.addPanel(new Wt.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new Wt.Panel("CPU","#0f0","#020"),1),this.setupEventListeners()}initializeDOM(){this.dom.style.cssText=`
1479
+ }`;const rn=new l.Vector3(0,0,0),Uo=new l.Vector3(0,0,0),Jh=new l.Vector3(0,0,0);function Rs(a,e,t){const n=rn.setFromMatrixPosition(a.matrixWorld);n.project(e);const o=t.width/2,r=t.height/2;return[(Number.isNaN(n.x)?0:n.x)*o+o,-(n.y*r)+r,n.z]}function Hh(a,e){const t=rn.setFromMatrixPosition(a.matrixWorld),n=Uo.setFromMatrixPosition(e.matrixWorld),o=t.sub(n),r=e.getWorldDirection(Jh);return o.angleTo(r)>Math.PI/2}function $h(a,e,t,n){const o=rn.setFromMatrixPosition(a.matrixWorld),r=o.clone();r.project(e),t.setFromCamera(new l.Vector2(r.x,r.y),e);const s=t.intersectObjects(n,!0);if(s.length>0){const i=s[0].distance;return o.distanceTo(t.ray.origin)<i}return!0}function ef(a,e){if(e instanceof l.OrthographicCamera)return e.zoom;if(e instanceof l.PerspectiveCamera){const t=rn.setFromMatrixPosition(a.matrixWorld),n=Uo.setFromMatrixPosition(e.matrixWorld),o=e.fov*Math.PI/180,r=t.distanceTo(n);return 1/(2*Math.tan(o/2)*r)}else return 1}function tf(a,e,t){if(e instanceof l.PerspectiveCamera||e instanceof l.OrthographicCamera){const n=rn.setFromMatrixPosition(a.matrixWorld),o=Uo.setFromMatrixPosition(e.matrixWorld),r=n.distanceTo(o),s=(t[1]-t[0])/(e.far-e.near),i=t[1]-s*e.far;return Math.round(s*r+i)}}const No=a=>Math.abs(a)<1e-10?0:a;function js(a,e,t=""){let n="matrix3d(";for(let o=0;o!==16;o++)n+=No(e[o]*a.elements[o])+(o!==15?",":")");return t+n}const nf=(a=>e=>js(e,a))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),of=(a=>(e,t)=>js(e,a(t),"translate(-50%,-50%)"))(a=>[1/a,1/a,1/a,1,-1/a,-1/a,-1/a,-1,1/a,1/a,1/a,1,1,1,1,1]),rf=["geometry","material"],sf=u.defineComponent({__name:"HTML",props:{geometry:{default:new l.PlaneGeometry},material:{},as:{default:"div"},transform:{type:Boolean,default:!1},portal:{},wrapperClass:{},eps:{default:1e-4},distanceFactor:{},fullscreen:{type:Boolean},center:{type:Boolean},pointerEvents:{default:"auto"},sprite:{type:Boolean,default:!1},zIndexRange:{default:()=>[16777271,0]},occlude:{type:[Object,null,Array,Boolean,String]}},emits:["onOcclude"],setup(a,{expose:e,emit:t}){const n=a,o=t,r=u.useSlots(),s=u.useAttrs(),i=u.ref(),c=u.ref(),{geometry:h,material:p,as:f,transform:m,portal:d,wrapperClass:g,eps:y,distanceFactor:v,fullscreen:_,center:A,pointerEvents:b,sprite:C,occlude:L,zIndexRange:M}=u.toRefs(n),{renderer:P,scene:w,camera:S,raycaster:x,sizes:I}=H.useTresContext(),D=u.computed(()=>document.createElement(f.value)),z=u.ref([0,0,0]),G=u.ref(0),X=u.ref(),E=u.computed(()=>m.value?{position:"absolute",top:0,left:0,width:`${I.width.value}px`,height:`${I.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2}:{position:"absolute",transform:A.value?"translate3d(-50%,-50%,0)":"none",..._.value&&{top:-I.height.value/2,left:-I.width.value/2,width:`${I.width.value}px`,height:`${I.height.value}px`},zIndex:2,...Object.assign({},s.style)}),te=u.computed(()=>({position:"absolute",pointerEvents:b.value})),q=u.ref(null),oe=u.ref(!1),ne=u.computed(()=>(L==null?void 0:L.value)&&(L==null?void 0:L.value)!=="blending"||Array.isArray(L==null?void 0:L.value)&&(L==null?void 0:L.value.length)&&u.isRef(L.value[0]));u.watch(()=>L,({value:V})=>{V==="blending"?(D.value.style.zIndex=`${Math.floor(M.value[0]/2)}`,D.value.style.position="absolute",D.value.style.pointerEvents="none"):(D.value.style.zIndex=null,D.value.style.position=null,D.value.style.pointerEvents=null)}),u.watch(()=>{var V;return[i.value,P.value,I.width.value,I.height.value,(V=r.default)==null?void 0:V.call(r)]},([V,U])=>{var B,R,T,O,N,K;if(V&&U){const W=(d==null?void 0:d.value)||U.domElement;if((B=w.value)==null||B.updateMatrixWorld(),m.value)D.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const Y=Rs(V,S.value,{width:I.width.value,height:I.height.value});D.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${Y[0]}px,${Y[1]}px,0);transform-origin:0 0;`}W&&!D.value.parentNode&&((R=W.parentNode)==null||R.appendChild(D.value)),m.value?X.value=u.createVNode("div",{id:"outer",style:E.value},[u.createVNode("div",{id:"inner",style:te.value},[u.createVNode("div",{key:(T=c.value)==null?void 0:T.uuid,id:w==null?void 0:w.value.uuid,class:s.class,style:s.style},(O=r.default)==null?void 0:O.call(r))])]):X.value=u.createVNode("div",{key:(N=c.value)==null?void 0:N.uuid,id:w==null?void 0:w.value.uuid,style:E.value},(K=r.default)==null?void 0:K.call(r)),u.render(X.value,D.value)}}),u.watchEffect(()=>{g!=null&&g.value&&(D.value.className=g.value)});const ce=u.ref(!0),{onBeforeRender:le}=H.useLoop();le(({invalidate:V})=>{var U,B,R,T,O,N,K;if(V(),i.value&&S.value&&P.value){(U=S.value)==null||U.updateMatrixWorld(),i.value.updateWorldMatrix(!0,!1);const W=m.value?z.value:Rs(i.value,S.value,{width:I.width.value||0,height:I.height.value||0});if(m.value||Math.abs(G.value-S.value.zoom)>y.value||Math.abs(z.value[0]-W[0])>y.value||Math.abs(z.value[1]-W[1])>y.value||Math.abs(z.value[2]-W[2])>y.value){const Y=Hh(i.value,S.value);let Q=!1;ne.value&&(Array.isArray(L==null?void 0:L.value)?Q=L==null?void 0:L.value:(L==null?void 0:L.value)!=="blending"&&(Q=[w.value]));const re=ce.value;if(Q){const F=$h(i.value,S.value,x.value,Q);ce.value=F&&!Y}else ce.value=!Y;re!==ce.value&&(o("onOcclude",!ce.value),D.value.style.display=ce.value?"block":"none");const se=Math.floor(M.value[0]/2),j=L!=null&&L.value?ne.value?[M.value[0],se]:[se-1,0]:M.value;if(D.value.style.zIndex=`${tf(i.value,S.value,j)}`,m.value){const[F,ie]=[I.width.value/2,I.height.value/2],he=S.value.projectionMatrix.elements[5]*ie,{isOrthographicCamera:_e,top:Le,left:Pe,bottom:Je,right:wt}=S.value,It=nf(S.value.matrixWorldInverse),st=_e?`scale(${he})translate(${No(-(wt+Pe)/2)}px,${No((Le+Je)/2)}px)`:`translateZ(${he}px)`;let Ee=i.value.matrixWorld;if(C.value&&(Ee=S.value.matrixWorldInverse.clone().transpose().copyPosition(Ee).scale(i.value.scale),Ee.elements[3]=Ee.elements[7]=Ee.elements[11]=0,Ee.elements[15]=1),D.value.style.width=`${I.width.value}px`,D.value.style.height=`${I.height.value}px`,D.value.style.perspective=_e?"":`${he}px`,(B=X.value)!=null&&B.el&&((R=X.value)!=null&&R.children)&&Array.isArray(X.value.children)){X.value.el.style.transform=`${st}${It}translate(${F}px,${ie}px)`;const it=X.value.children[0];it&&it.el&&(it.el.style.transform=of(Ee,1/(((v==null?void 0:v.value)||10)/400)))}}else{const F=(v==null?void 0:v.value)===void 0?1:ef(i.value,S.value)*(v==null?void 0:v.value);D.value.style.transform=`translate3d(${W[0]}px,${W[1]}px,0) scale(${F})`}}z.value=W,G.value=S.value.zoom}if(!ne.value&&c.value&&!oe.value)if(m.value){if((T=X.value)!=null&&T.el&&((O=X.value)!=null&&O.children)){const W=((N=X.value)==null?void 0:N.children)[0];if(W!=null&&W.clientWidth&&(W!=null&&W.clientHeight)){const{isOrthographicCamera:Y}=S.value;if(Y||h)s.scale&&(Array.isArray(s.scale)?s.scale instanceof l.Vector3?c.value.scale.copy(s.scale.clone().divideScalar(1)):c.value.scale.set(1/s.scale[0],1/s.scale[1],1/s.scale[2]):c.value.scale.setScalar(1/s.scale));else{const Q=((v==null?void 0:v.value)||10)/400,re=W.clientWidth*Q,se=W.clientHeight*Q;c.value.scale.set(re,se,1)}oe.value=!0}}}else{const W=D.value.children[0];if(W!=null&&W.clientWidth&&(W!=null&&W.clientHeight)){const Q=W.clientWidth*1,re=W.clientHeight*1;c.value.scale.set(Q,re,1),oe.value=!0}q.value.lookAt((K=S.value)==null?void 0:K.position)}});const de=u.computed(()=>({vertexShader:m.value?void 0:Qh,fragmentShader:qh})),k=u.computed(()=>{const V=de.value;return p.value||new l.ShaderMaterial({vertexShader:V.vertexShader,fragmentShader:V.fragmentShader,side:l.DoubleSide})});return u.onUnmounted(()=>{k.value&&k.value.dispose(),D.value.remove()}),e({instance:i}),(V,U)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:i},[u.unref(L)&&!ne.value?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:c,geometry:u.unref(h),material:k.value},null,8,rf)):u.createCommentVNode("",!0)],512))}});var Dn={exports:{}},af=Dn.exports,Ws;function lf(){return Ws||(Ws=1,function(a,e){(function(t,n){a.exports=n()})(af,function(){var t=function(){function n(d){return s.appendChild(d.dom),d}function o(d){for(var g=0;g<s.children.length;g++)s.children[g].style.display=g===d?"block":"none";r=d}var r=0,s=document.createElement("div");s.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",s.addEventListener("click",function(d){d.preventDefault(),o(++r%s.children.length)},!1);var i=(performance||Date).now(),c=i,h=0,p=n(new t.Panel("FPS","#0ff","#002")),f=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return o(0),{REVISION:16,dom:s,addPanel:n,showPanel:o,begin:function(){i=(performance||Date).now()},end:function(){h++;var d=(performance||Date).now();if(f.update(d-i,200),d>c+1e3&&(p.update(1e3*h/(d-c),100),c=d,h=0,m)){var g=performance.memory;m.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:s,setMode:o}};return t.Panel=function(n,o,r){var s=1/0,i=0,c=Math.round,h=c(window.devicePixelRatio||1),p=80*h,f=48*h,m=3*h,d=2*h,g=3*h,y=15*h,v=74*h,_=30*h,A=document.createElement("canvas");A.width=p,A.height=f,A.style.cssText="width:80px;height:48px";var b=A.getContext("2d");return b.font="bold "+9*h+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=r,b.fillRect(0,0,p,f),b.fillStyle=o,b.fillText(n,m,d),b.fillRect(g,y,v,_),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g,y,v,_),{dom:A,update:function(C,L){s=Math.min(s,C),i=Math.max(i,C),b.fillStyle=r,b.globalAlpha=1,b.fillRect(0,0,p,y),b.fillStyle=o,b.fillText(c(C)+" "+n+" ("+c(s)+"-"+c(i)+")",m,d),b.drawImage(A,g+h,y,v-h,_,g,y,v-h,_),b.fillRect(g+v-h,y,h,_),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g+v-h,y,h,c((1-C/L)*_))}}},t})}(Dn)),Dn.exports}var cf=lf();const uf=on(cf),hf=u.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(a,{expose:e}){const t=new uf;e({instance:t});const n=document.body;t.showPanel(a.showPanel||0),n==null||n.appendChild(t.dom);const{onBeforeRender:o,onAfterRender:r}=H.useLoop();o(()=>t.begin(),Number.NEGATIVE_INFINITY),r(()=>t.end(),Number.POSITIVE_INFINITY),u.onUnmounted(()=>{n==null||n.removeChild(t.dom)})}});class ff{constructor(e,t,n){this.name=e,this.fg=t,this.bg=n,this.gradient=null,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement("canvas"),this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.width="90px",this.canvas.style.height="48px",this.canvas.style.position="absolute",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.initializeCanvas()}createGradient(){if(!this.context)throw new Error("No context");const e=this.context.createLinearGradient(0,this.GRAPH_Y,0,this.GRAPH_Y+this.GRAPH_HEIGHT);let t;const n=this.fg;switch(this.fg.toLowerCase()){case"#0ff":t="#006666";break;case"#0f0":t="#006600";break;case"#ff0":t="#666600";break;case"#e1e1e1":t="#666666";break;default:t=this.bg;break}return e.addColorStop(0,t),e.addColorStop(1,n),e}initializeCanvas(){this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.gradient=this.createGradient(),this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillStyle=this.fg,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(e,t,n,o,r=0){if(!this.context||!this.gradient)return;const s=Math.min(1/0,e),i=Math.max(n,e);o=Math.max(o,t),this.context.globalAlpha=1,this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(`${e.toFixed(r)} ${this.name} (${s.toFixed(r)}-${parseFloat(i.toFixed(r))})`,this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT);const c=this.GRAPH_HEIGHT-(1-t/o)*this.GRAPH_HEIGHT;c>0&&(this.context.globalAlpha=1,this.context.fillStyle=this.gradient,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y+this.GRAPH_HEIGHT-c,this.PR,c))}}const Ys=class Wt{constructor({trackGPU:e=!1,logsPerSecond:t=30,samplesLog:n=60,samplesGraph:o=10,precision:r=2,minimal:s=!1,horizontal:i=!0,mode:c=0}={}){this.gl=null,this.ext=null,this.activeQuery=null,this.gpuQueries=[],this.threeRendererPatched=!1,this.frames=0,this.renderCount=0,this.isRunningCPUProfiling=!1,this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalGpuDurationCompute=0,this.totalFps=0,this.gpuPanel=null,this.gpuPanelCompute=null,this.averageFps={logs:[],graph:[]},this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.averageGpuCompute={logs:[],graph:[]},this.handleClick=h=>{h.preventDefault(),this.showPanel(++this.mode%this.dom.children.length)},this.handleResize=()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2),this.gpuPanelCompute&&this.resizePanel(this.gpuPanelCompute,3)},this.mode=c,this.horizontal=i,this.minimal=s,this.trackGPU=e,this.samplesLog=n,this.samplesGraph=o,this.precision=r,this.logsPerSecond=t,this.dom=document.createElement("div"),this.initializeDOM(),this.beginTime=performance.now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.fpsPanel=this.addPanel(new Wt.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new Wt.Panel("CPU","#0f0","#020"),1),this.setupEventListeners()}initializeDOM(){this.dom.style.cssText=`
1480
1480
  position: fixed;
1481
1481
  top: 0;
1482
1482
  left: 0;