@tresjs/cientos 3.4.1 → 3.5.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,11 +1,11 @@
1
1
  /**
2
2
  * name: @tresjs/cientos
3
- * version: v3.4.1
3
+ * version: v3.5.1
4
4
  * (c) 2023
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/)
7
7
  */
8
- (function(q,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue"),require("three"),require("@tresjs/core"),require("tweakpane")):typeof define=="function"&&define.amd?define(["exports","vue","three","@tresjs/core","tweakpane"],u):(q=typeof globalThis<"u"?globalThis:q||self,u(q.trescientos={},q.Vue,q.Three,q.TresjsCore,q.tweakpane))})(this,function(q,u,c,ue,Nn){"use strict";var ml=Object.defineProperty;var gl=(q,u,c)=>u in q?ml(q,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):q[u]=c;var Ae=(q,u,c)=>(gl(q,typeof u!="symbol"?u+"":u,c),c);function Ls(l,e){if(e===c.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===c.TriangleFanDrawMode||e===c.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],r=l.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)o.push(a);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=t.count-2,n=[];if(t)if(e===c.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}var De=Uint8Array,Qe=Uint16Array,Qt=Uint32Array,Os=new De([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Is=new De([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),zn=new De([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ds=function(l,e){for(var t=new Qe(31),s=0;s<31;++s)t[s]=e+=1<<l[s-1];for(var n=new Qt(t[30]),s=1;s<30;++s)for(var i=t[s];i<t[s+1];++i)n[i]=i-t[s]<<5|s;return[t,n]},ks=Ds(Os,2),Fs=ks[0],Rn=ks[1];Fs[28]=258,Rn[258]=28;for(var Gn=Ds(Is,0),En=Gn[0],Kt=new Qe(32768),ve=0;ve<32768;++ve){var Ke=(ve&43690)>>>1|(ve&21845)<<1;Ke=(Ke&52428)>>>2|(Ke&13107)<<2,Ke=(Ke&61680)>>>4|(Ke&3855)<<4,Kt[ve]=((Ke&65280)>>>8|(Ke&255)<<8)>>>1}for(var yt=function(l,e,t){for(var s=l.length,n=0,i=new Qe(e);n<s;++n)++i[l[n]-1];var o=new Qe(e);for(n=0;n<e;++n)o[n]=o[n-1]+i[n-1]<<1;var r;if(t){r=new Qe(1<<e);var a=15-e;for(n=0;n<s;++n)if(l[n])for(var h=n<<4|l[n],f=e-l[n],p=o[l[n]-1]++<<f,m=p|(1<<f)-1;p<=m;++p)r[Kt[p]>>>a]=h}else for(r=new Qe(s),n=0;n<s;++n)l[n]&&(r[n]=Kt[o[l[n]-1]++]>>>15-l[n]);return r},_t=new De(288),ve=0;ve<144;++ve)_t[ve]=8;for(var ve=144;ve<256;++ve)_t[ve]=9;for(var ve=256;ve<280;++ve)_t[ve]=7;for(var ve=280;ve<288;++ve)_t[ve]=8;for(var Bs=new De(32),ve=0;ve<32;++ve)Bs[ve]=5;var jn=yt(_t,9,1),Xn=yt(Bs,5,1),qt=function(l){for(var e=l[0],t=1;t<l.length;++t)l[t]>e&&(e=l[t]);return e},Ve=function(l,e,t){var s=e/8|0;return(l[s]|l[s+1]<<8)>>(e&7)&t},Jt=function(l,e){var t=e/8|0;return(l[t]|l[t+1]<<8|l[t+2]<<16)>>(e&7)},Yn=function(l){return(l/8|0)+(l&7&&1)},Zn=function(l,e,t){(e==null||e<0)&&(e=0),(t==null||t>l.length)&&(t=l.length);var s=new(l instanceof Qe?Qe:l instanceof Qt?Qt:De)(t-e);return s.set(l.subarray(e,t)),s},Wn=function(l,e,t){var s=l.length;if(!s||t&&!t.l&&s<5)return e||new De(0);var n=!e||t,i=!t||t.i;t||(t={}),e||(e=new De(s*3));var o=function(E){var L=e.length;if(E>L){var j=new De(Math.max(L*2,E));j.set(e),e=j}},r=t.f||0,a=t.p||0,h=t.b||0,f=t.l,p=t.d,m=t.m,g=t.n,w=s*8;do{if(!f){t.f=r=Ve(l,a,1);var x=Ve(l,a+1,3);if(a+=3,x)if(x==1)f=jn,p=Xn,m=9,g=5;else if(x==2){var v=Ve(l,a,31)+257,y=Ve(l,a+10,15)+4,M=v+Ve(l,a+5,31)+1;a+=14;for(var P=new De(M),A=new De(19),b=0;b<y;++b)A[zn[b]]=Ve(l,a+b*3,7);a+=y*3;for(var D=qt(A),z=(1<<D)-1,U=yt(A,D,1),b=0;b<M;){var R=U[Ve(l,a,z)];a+=R&15;var _=R>>>4;if(_<16)P[b++]=_;else{var K=0,Z=0;for(_==16?(Z=3+Ve(l,a,3),a+=2,K=P[b-1]):_==17?(Z=3+Ve(l,a,7),a+=3):_==18&&(Z=11+Ve(l,a,127),a+=7);Z--;)P[b++]=K}}var W=P.subarray(0,v),pe=P.subarray(v);m=qt(W),g=qt(pe),f=yt(W,m,1),p=yt(pe,g,1)}else throw"invalid block type";else{var _=Yn(a)+4,S=l[_-4]|l[_-3]<<8,C=_+S;if(C>s){if(i)throw"unexpected EOF";break}n&&o(h+S),e.set(l.subarray(_,C),h),t.b=h+=S,t.p=a=C*8;continue}if(a>w){if(i)throw"unexpected EOF";break}}n&&o(h+131072);for(var Q=(1<<m)-1,G=(1<<g)-1,ce=a;;ce=a){var K=f[Jt(l,a)&Q],se=K>>>4;if(a+=K&15,a>w){if(i)throw"unexpected EOF";break}if(!K)throw"invalid length/literal";if(se<256)e[h++]=se;else if(se==256){ce=a,f=null;break}else{var ae=se-254;if(se>264){var b=se-257,B=Os[b];ae=Ve(l,a,(1<<B)-1)+Fs[b],a+=B}var I=p[Jt(l,a)&G],d=I>>>4;if(!I)throw"invalid distance";a+=I&15;var pe=En[d];if(d>3){var B=Is[d];pe+=Jt(l,a)&(1<<B)-1,a+=B}if(a>w){if(i)throw"unexpected EOF";break}n&&o(h+131072);for(var k=h+ae;h<k;h+=4)e[h]=e[h-pe],e[h+1]=e[h+1-pe],e[h+2]=e[h+2-pe],e[h+3]=e[h+3-pe];h=k}}t.l=f,t.p=ce,t.b=h,f&&(r=1,t.m=m,t.d=p,t.n=g)}while(!r);return h==e.length?e:Zn(e,0,h)},Qn=new De(0),Kn=function(l){if((l[0]&15)!=8||l[0]>>>4>7||(l[0]<<8|l[1])%31)throw"invalid zlib data";if(l[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function qn(l,e){return Wn((Kn(l),l.subarray(2,-4)),e)}var Jn=typeof TextDecoder<"u"&&new TextDecoder,Hn=0;try{Jn.decode(Qn,{stream:!0}),Hn=1}catch{}var $n=Object.defineProperty,ei=(l,e,t)=>e in l?$n(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,V=(l,e,t)=>(ei(l,typeof e!="symbol"?e+"":e,t),t);class ti extends c.Object3D{constructor(e,t){super(),V(this,"isTransformControls",!0),V(this,"visible",!1),V(this,"domElement"),V(this,"raycaster",new c.Raycaster),V(this,"gizmo"),V(this,"plane"),V(this,"tempVector",new c.Vector3),V(this,"tempVector2",new c.Vector3),V(this,"tempQuaternion",new c.Quaternion),V(this,"unit",{X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)}),V(this,"pointStart",new c.Vector3),V(this,"pointEnd",new c.Vector3),V(this,"offset",new c.Vector3),V(this,"rotationAxis",new c.Vector3),V(this,"startNorm",new c.Vector3),V(this,"endNorm",new c.Vector3),V(this,"rotationAngle",0),V(this,"cameraPosition",new c.Vector3),V(this,"cameraQuaternion",new c.Quaternion),V(this,"cameraScale",new c.Vector3),V(this,"parentPosition",new c.Vector3),V(this,"parentQuaternion",new c.Quaternion),V(this,"parentQuaternionInv",new c.Quaternion),V(this,"parentScale",new c.Vector3),V(this,"worldPositionStart",new c.Vector3),V(this,"worldQuaternionStart",new c.Quaternion),V(this,"worldScaleStart",new c.Vector3),V(this,"worldPosition",new c.Vector3),V(this,"worldQuaternion",new c.Quaternion),V(this,"worldQuaternionInv",new c.Quaternion),V(this,"worldScale",new c.Vector3),V(this,"eye",new c.Vector3),V(this,"positionStart",new c.Vector3),V(this,"quaternionStart",new c.Quaternion),V(this,"scaleStart",new c.Vector3),V(this,"camera"),V(this,"object"),V(this,"enabled",!0),V(this,"axis",null),V(this,"mode","translate"),V(this,"translationSnap",null),V(this,"rotationSnap",null),V(this,"scaleSnap",null),V(this,"space","world"),V(this,"size",1),V(this,"dragging",!1),V(this,"showX",!0),V(this,"showY",!0),V(this,"showZ",!0),V(this,"changeEvent",{type:"change"}),V(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),V(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),V(this,"objectChangeEvent",{type:"objectChange"}),V(this,"intersectObjectWithRay",(n,i,o)=>{const r=i.intersectObject(n,!0);for(let a=0;a<r.length;a++)if(r[a].object.visible||o)return r[a];return!1}),V(this,"attach",n=>(this.object=n,this.visible=!0,this)),V(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),V(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),V(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()}),V(this,"pointerHover",n=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(n,this.camera);const i=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);i?this.axis=i.object.name:this.axis=null}),V(this,"pointerDown",n=>{if(!(this.object===void 0||this.dragging===!0||n.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(n,this.camera);const i=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(i){let o=this.space;if(this.mode==="scale"?o="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(o="world"),o==="local"&&this.mode==="rotate"){const r=this.rotationSnap;this.axis==="X"&&r&&(this.object.rotation.x=Math.round(this.object.rotation.x/r)*r),this.axis==="Y"&&r&&(this.object.rotation.y=Math.round(this.object.rotation.y/r)*r),this.axis==="Z"&&r&&(this.object.rotation.z=Math.round(this.object.rotation.z/r)*r)}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(i.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),V(this,"pointerMove",n=>{const i=this.axis,o=this.mode,r=this.object;let a=this.space;if(o==="scale"?a="local":(i==="E"||i==="XYZE"||i==="XYZ")&&(a="world"),r===void 0||i===null||this.dragging===!1||n.button!==-1)return;this.raycaster.setFromCamera(n,this.camera);const h=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(h){if(this.pointEnd.copy(h.point).sub(this.worldPositionStart),o==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&i!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),i.indexOf("X")===-1&&(this.offset.x=0),i.indexOf("Y")===-1&&(this.offset.y=0),i.indexOf("Z")===-1&&(this.offset.z=0),a==="local"&&i!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),r.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(a==="local"&&(r.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this.quaternionStart)),a==="world"&&(r.parent&&r.position.add(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld)),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld))));else if(o==="scale"){if(i.search("XYZ")!==-1){let f=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(f*=-1),this.tempVector2.set(f,f,f)}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),i.search("X")===-1&&(this.tempVector2.x=1),i.search("Y")===-1&&(this.tempVector2.y=1),i.search("Z")===-1&&(this.tempVector2.z=1);r.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(i.search("X")!==-1&&(this.object.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(o==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const f=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));i==="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):i==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*f):(i==="X"||i==="Y"||i==="Z")&&(this.rotationAxis.copy(this.unit[i]),this.tempVector.copy(this.unit[i]),a==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*f),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&i!=="E"&&i!=="XYZE"?(r.quaternion.copy(this.quaternionStart),r.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),r.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),V(this,"pointerUp",n=>{n.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),V(this,"getPointer",n=>{var i,o;if(this.domElement&&((i=this.domElement.ownerDocument)!=null&&i.pointerLockElement))return{x:0,y:0,button:n.button};{const r=n.changedTouches?n.changedTouches[0]:n,a=(o=this.domElement)==null?void 0:o.getBoundingClientRect();return{x:(r.clientX-a.left)/a.width*2-1,y:-(r.clientY-a.top)/a.height*2+1,button:n.button}}}),V(this,"onPointerHover",n=>{if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(n));break}}),V(this,"onPointerDown",n=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(n)),this.pointerDown(this.getPointer(n)))}),V(this,"onPointerMove",n=>{this.enabled&&this.pointerMove(this.getPointer(n))}),V(this,"onPointerUp",n=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(n)))}),V(this,"getMode",()=>this.mode),V(this,"setMode",n=>{this.mode=n}),V(this,"setTranslationSnap",n=>{this.translationSnap=n}),V(this,"setRotationSnap",n=>{this.rotationSnap=n}),V(this,"setScaleSnap",n=>{this.scaleSnap=n}),V(this,"setSize",n=>{this.size=n}),V(this,"setSpace",n=>{this.space=n}),V(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),V(this,"connect",n=>{n===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=n,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),V(this,"dispose",()=>{var n,i,o,r,a,h;(n=this.domElement)==null||n.removeEventListener("pointerdown",this.onPointerDown),(i=this.domElement)==null||i.removeEventListener("pointermove",this.onPointerHover),(r=(o=this.domElement)==null?void 0:o.ownerDocument)==null||r.removeEventListener("pointermove",this.onPointerMove),(h=(a=this.domElement)==null?void 0:a.ownerDocument)==null||h.removeEventListener("pointerup",this.onPointerUp),this.traverse(f=>{const p=f;p.geometry&&p.geometry.dispose(),p.material&&p.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new si,this.add(this.gizmo),this.plane=new ni,this.add(this.plane);const s=(n,i)=>{let o=i;Object.defineProperty(this,n,{get:function(){return o!==void 0?o:i},set:function(r){o!==r&&(o=r,this.plane[n]=r,this.gizmo[n]=r,this.dispatchEvent({type:n+"-changed",value:r}),this.dispatchEvent(this.changeEvent))}}),this[n]=i,this.plane[n]=i,this.gizmo[n]=i};s("camera",this.camera),s("object",this.object),s("enabled",this.enabled),s("axis",this.axis),s("mode",this.mode),s("translationSnap",this.translationSnap),s("rotationSnap",this.rotationSnap),s("scaleSnap",this.scaleSnap),s("space",this.space),s("size",this.size),s("dragging",this.dragging),s("showX",this.showX),s("showY",this.showY),s("showZ",this.showZ),s("worldPosition",this.worldPosition),s("worldPositionStart",this.worldPositionStart),s("worldQuaternion",this.worldQuaternion),s("worldQuaternionStart",this.worldQuaternionStart),s("cameraPosition",this.cameraPosition),s("cameraQuaternion",this.cameraQuaternion),s("pointStart",this.pointStart),s("pointEnd",this.pointEnd),s("rotationAxis",this.rotationAxis),s("rotationAngle",this.rotationAngle),s("eye",this.eye),t!==void 0&&this.connect(t)}}class si extends c.Object3D{constructor(){super(),V(this,"isTransformControlsGizmo",!0),V(this,"type","TransformControlsGizmo"),V(this,"tempVector",new c.Vector3(0,0,0)),V(this,"tempEuler",new c.Euler),V(this,"alignVector",new c.Vector3(0,1,0)),V(this,"zeroVector",new c.Vector3(0,0,0)),V(this,"lookAtMatrix",new c.Matrix4),V(this,"tempQuaternion",new c.Quaternion),V(this,"tempQuaternion2",new c.Quaternion),V(this,"identityQuaternion",new c.Quaternion),V(this,"unitX",new c.Vector3(1,0,0)),V(this,"unitY",new c.Vector3(0,1,0)),V(this,"unitZ",new c.Vector3(0,0,1)),V(this,"gizmo"),V(this,"picker"),V(this,"helper"),V(this,"rotationAxis",new c.Vector3),V(this,"cameraPosition",new c.Vector3),V(this,"worldPositionStart",new c.Vector3),V(this,"worldQuaternionStart",new c.Quaternion),V(this,"worldPosition",new c.Vector3),V(this,"worldQuaternion",new c.Quaternion),V(this,"eye",new c.Vector3),V(this,"camera",null),V(this,"enabled",!0),V(this,"axis",null),V(this,"mode","translate"),V(this,"space","world"),V(this,"size",1),V(this,"dragging",!1),V(this,"showX",!0),V(this,"showY",!0),V(this,"showZ",!0),V(this,"updateMatrixWorld",()=>{let se=this.space;this.mode==="scale"&&(se="local");const ae=se==="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 B=[];B=B.concat(this.picker[this.mode].children),B=B.concat(this.gizmo[this.mode].children),B=B.concat(this.helper[this.mode].children);for(let I=0;I<B.length;I++){const d=B[I];d.visible=!0,d.rotation.set(0,0,0),d.position.copy(this.worldPosition);let k;if(this.camera.isOrthographicCamera?k=(this.camera.top-this.camera.bottom)/this.camera.zoom:k=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),d.scale.set(1,1,1).multiplyScalar(k*this.size/7),d.tag==="helper"){d.visible=!1,d.name==="AXIS"?(d.position.copy(this.worldPositionStart),d.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),d.quaternion.copy(ae).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ae).dot(this.eye))>.9&&(d.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),d.quaternion.copy(ae).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ae).dot(this.eye))>.9&&(d.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),d.quaternion.copy(ae).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ae).dot(this.eye))>.9&&(d.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),d.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),d.quaternion.multiply(this.tempQuaternion),d.visible=this.dragging),this.axis==="E"&&(d.visible=!1)):d.name==="START"?(d.position.copy(this.worldPositionStart),d.visible=this.dragging):d.name==="END"?(d.position.copy(this.worldPosition),d.visible=this.dragging):d.name==="DELTA"?(d.position.copy(this.worldPositionStart),d.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()),d.scale.copy(this.tempVector),d.visible=this.dragging):(d.quaternion.copy(ae),this.dragging?d.position.copy(this.worldPositionStart):d.position.copy(this.worldPosition),this.axis&&(d.visible=this.axis.search(d.name)!==-1));continue}d.quaternion.copy(ae),this.mode==="translate"||this.mode==="scale"?((d.name==="X"||d.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ae).dot(this.eye))>.99&&(d.scale.set(1e-10,1e-10,1e-10),d.visible=!1),(d.name==="Y"||d.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ae).dot(this.eye))>.99&&(d.scale.set(1e-10,1e-10,1e-10),d.visible=!1),(d.name==="Z"||d.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ae).dot(this.eye))>.99&&(d.scale.set(1e-10,1e-10,1e-10),d.visible=!1),d.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ae).dot(this.eye))<.2&&(d.scale.set(1e-10,1e-10,1e-10),d.visible=!1),d.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ae).dot(this.eye))<.2&&(d.scale.set(1e-10,1e-10,1e-10),d.visible=!1),d.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ae).dot(this.eye))<.2&&(d.scale.set(1e-10,1e-10,1e-10),d.visible=!1),d.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ae).dot(this.eye)<0?d.tag==="fwd"?d.visible=!1:d.scale.x*=-1:d.tag==="bwd"&&(d.visible=!1)),d.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ae).dot(this.eye)<0?d.tag==="fwd"?d.visible=!1:d.scale.y*=-1:d.tag==="bwd"&&(d.visible=!1)),d.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ae).dot(this.eye)<0?d.tag==="fwd"?d.visible=!1:d.scale.z*=-1:d.tag==="bwd"&&(d.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ae),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ae).invert()),d.name.search("E")!==-1&&d.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),d.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),d.quaternion.copy(this.tempQuaternion)),d.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),d.quaternion.copy(this.tempQuaternion)),d.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),d.quaternion.copy(this.tempQuaternion))),d.visible=d.visible&&(d.name.indexOf("X")===-1||this.showX),d.visible=d.visible&&(d.name.indexOf("Y")===-1||this.showY),d.visible=d.visible&&(d.name.indexOf("Z")===-1||this.showZ),d.visible=d.visible&&(d.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),d.material.tempOpacity=d.material.tempOpacity||d.material.opacity,d.material.tempColor=d.material.tempColor||d.material.color.clone(),d.material.color.copy(d.material.tempColor),d.material.opacity=d.material.tempOpacity,this.enabled?this.axis&&(d.name===this.axis?(d.material.opacity=1,d.material.color.lerp(new c.Color(1,1,1),.5)):this.axis.split("").some(function(E){return d.name===E})?(d.material.opacity=1,d.material.color.lerp(new c.Color(1,1,1),.5)):(d.material.opacity*=.25,d.material.color.lerp(new c.Color(1,1,1),.5))):(d.material.opacity*=.5,d.material.color.lerp(new c.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new c.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:c.DoubleSide,fog:!1,toneMapped:!1}),t=new c.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),s=e.clone();s.opacity=.15;const n=e.clone();n.opacity=.33;const i=e.clone();i.color.set(16711680);const o=e.clone();o.color.set(65280);const r=e.clone();r.color.set(255);const a=e.clone();a.opacity=.25;const h=a.clone();h.color.set(16776960);const f=a.clone();f.color.set(65535);const p=a.clone();p.color.set(16711935),e.clone().color.set(16776960);const g=t.clone();g.color.set(16711680);const w=t.clone();w.color.set(65280);const x=t.clone();x.color.set(255);const _=t.clone();_.color.set(65535);const S=t.clone();S.color.set(16711935);const C=t.clone();C.color.set(16776960);const v=t.clone();v.color.set(7895160);const y=C.clone();y.opacity=.25;const M=new c.CylinderGeometry(0,.05,.2,12,1,!1),P=new c.BoxGeometry(.125,.125,.125),A=new c.BufferGeometry;A.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3));const b=(se,ae)=>{const B=new c.BufferGeometry,I=[];for(let d=0;d<=64*ae;++d)I.push(0,Math.cos(d/32*Math.PI)*se,Math.sin(d/32*Math.PI)*se);return B.setAttribute("position",new c.Float32BufferAttribute(I,3)),B},D=()=>{const se=new c.BufferGeometry;return se.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),se},z={X:[[new c.Mesh(M,i),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new c.Mesh(M,i),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new c.Line(A,g)]],Y:[[new c.Mesh(M,o),[0,1,0],null,null,"fwd"],[new c.Mesh(M,o),[0,1,0],[Math.PI,0,0],null,"bwd"],[new c.Line(A,w),null,[0,0,Math.PI/2]]],Z:[[new c.Mesh(M,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new c.Mesh(M,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new c.Line(A,x),null,[0,-Math.PI/2,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.1,0),a.clone()),[0,0,0],[0,0,0]]],XY:[[new c.Mesh(new c.PlaneGeometry(.295,.295),h.clone()),[.15,.15,0]],[new c.Line(A,C),[.18,.3,0],null,[.125,1,1]],[new c.Line(A,C),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),f.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new c.Line(A,_),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(A,_),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),p.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new c.Line(A,S),[.18,0,.3],null,[.125,1,1]],[new c.Line(A,S),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},U={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),s),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),s),[0,.6,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),s),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.2,0),s)]],XY:[[new c.Mesh(new c.PlaneGeometry(.4,.4),s),[.2,.2,0]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),s),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),s),[.2,0,.2],[-Math.PI/2,0,0]]]},R={START:[[new c.Mesh(new c.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new c.Mesh(new c.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new c.Line(D(),n),null,null,null,"helper"]],X:[[new c.Line(A,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(A,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(A,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},K={X:[[new c.Line(b(1,.5),g)],[new c.Mesh(new c.OctahedronGeometry(.04,0),i),[0,0,.99],null,[1,3,1]]],Y:[[new c.Line(b(1,.5),w),null,[0,0,-Math.PI/2]],[new c.Mesh(new c.OctahedronGeometry(.04,0),o),[0,0,.99],null,[3,1,1]]],Z:[[new c.Line(b(1,.5),x),null,[0,Math.PI/2,0]],[new c.Mesh(new c.OctahedronGeometry(.04,0),r),[.99,0,0],null,[1,3,1]]],E:[[new c.Line(b(1.25,1),y),null,[0,Math.PI/2,0]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),y),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),y),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),y),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),y),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new c.Line(b(1,1),v),null,[0,Math.PI/2,0]]]},Z={AXIS:[[new c.Line(A,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},W={X:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new c.Mesh(new c.TorusGeometry(1.25,.1,2,24),s)]],XYZE:[[new c.Mesh(new c.SphereGeometry(.7,10,8),s)]]},pe={X:[[new c.Mesh(P,i),[.8,0,0],[0,0,-Math.PI/2]],[new c.Line(A,g),null,null,[.8,1,1]]],Y:[[new c.Mesh(P,o),[0,.8,0]],[new c.Line(A,w),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new c.Mesh(P,r),[0,0,.8],[Math.PI/2,0,0]],[new c.Line(A,x),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new c.Mesh(P,h),[.85,.85,0],null,[2,2,.2]],[new c.Line(A,C),[.855,.98,0],null,[.125,1,1]],[new c.Line(A,C),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(P,f),[0,.85,.85],null,[.2,2,2]],[new c.Line(A,_),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(A,_),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(P,p),[.85,0,.85],null,[2,.2,2]],[new c.Line(A,S),[.855,0,.98],null,[.125,1,1]],[new c.Line(A,S),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),a.clone()),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),a.clone()),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),a.clone()),[0,0,1.1]]]},Q={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),s),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),s),[0,.5,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),s),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new c.Mesh(P,s),[.85,.85,0],null,[3,3,.2]]],YZ:[[new c.Mesh(P,s),[0,.85,.85],null,[.2,3,3]]],XZ:[[new c.Mesh(P,s),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),s),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),s),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),s),[0,0,1.1]]]},G={X:[[new c.Line(A,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(A,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(A,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ce=se=>{const ae=new c.Object3D;for(let B in se)for(let I=se[B].length;I--;){const d=se[B][I][0].clone(),k=se[B][I][1],E=se[B][I][2],L=se[B][I][3],j=se[B][I][4];d.name=B,d.tag=j,k&&d.position.set(k[0],k[1],k[2]),E&&d.rotation.set(E[0],E[1],E[2]),L&&d.scale.set(L[0],L[1],L[2]),d.updateMatrix();const ie=d.geometry.clone();ie.applyMatrix4(d.matrix),d.geometry=ie,d.renderOrder=1/0,d.position.set(0,0,0),d.rotation.set(0,0,0),d.scale.set(1,1,1),ae.add(d)}return ae};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=ce(z)),this.add(this.gizmo.rotate=ce(K)),this.add(this.gizmo.scale=ce(pe)),this.add(this.picker.translate=ce(U)),this.add(this.picker.rotate=ce(W)),this.add(this.picker.scale=ce(Q)),this.add(this.helper.translate=ce(R)),this.add(this.helper.rotate=ce(Z)),this.add(this.helper.scale=ce(G)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class ni extends c.Mesh{constructor(){super(new c.PlaneGeometry(1e5,1e5,2,2),new c.MeshBasicMaterial({visible:!1,wireframe:!0,side:c.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),V(this,"isTransformControlsPlane",!0),V(this,"type","TransformControlsPlane"),V(this,"unitX",new c.Vector3(1,0,0)),V(this,"unitY",new c.Vector3(0,1,0)),V(this,"unitZ",new c.Vector3(0,0,1)),V(this,"tempVector",new c.Vector3),V(this,"dirVector",new c.Vector3),V(this,"alignVector",new c.Vector3),V(this,"tempMatrix",new c.Matrix4),V(this,"identityQuaternion",new c.Quaternion),V(this,"cameraQuaternion",new c.Quaternion),V(this,"worldPosition",new c.Vector3),V(this,"worldQuaternion",new c.Quaternion),V(this,"eye",new c.Vector3),V(this,"axis",null),V(this,"mode","translate"),V(this,"space","world"),V(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 ii=Object.defineProperty,oi=(l,e,t)=>e in l?ii(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,Pe=(l,e,t)=>(oi(l,typeof e!="symbol"?e+"":e,t),t);const ct=new c.Euler(0,0,0,"YXZ"),ht=new c.Vector3,ri={type:"change"},ai={type:"lock"},li={type:"unlock"},Us=Math.PI/2;class Ht extends c.EventDispatcher{constructor(e,t){super(),Pe(this,"camera"),Pe(this,"domElement"),Pe(this,"isLocked"),Pe(this,"minPolarAngle"),Pe(this,"maxPolarAngle"),Pe(this,"pointerSpeed"),Pe(this,"onMouseMove",s=>{if(!this.domElement||this.isLocked===!1)return;const n=s.movementX||s.mozMovementX||s.webkitMovementX||0,i=s.movementY||s.mozMovementY||s.webkitMovementY||0;ct.setFromQuaternion(this.camera.quaternion),ct.y-=n*.002*this.pointerSpeed,ct.x-=i*.002*this.pointerSpeed,ct.x=Math.max(Us-this.maxPolarAngle,Math.min(Us-this.minPolarAngle,ct.x)),this.camera.quaternion.setFromEuler(ct),this.dispatchEvent(ri)}),Pe(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(ai),this.isLocked=!0):(this.dispatchEvent(li),this.isLocked=!1))}),Pe(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),Pe(this,"connect",s=>{this.domElement=s||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))}),Pe(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))}),Pe(this,"dispose",()=>{this.disconnect()}),Pe(this,"getObject",()=>this.camera),Pe(this,"direction",new c.Vector3(0,0,-1)),Pe(this,"getDirection",s=>s.copy(this.direction).applyQuaternion(this.camera.quaternion)),Pe(this,"moveForward",s=>{ht.setFromMatrixColumn(this.camera.matrix,0),ht.crossVectors(this.camera.up,ht),this.camera.position.addScaledVector(ht,s)}),Pe(this,"moveRight",s=>{ht.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(ht,s)}),Pe(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),Pe(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 ci=Object.defineProperty,hi=(l,e,t)=>e in l?ci(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,re=(l,e,t)=>(hi(l,typeof e!="symbol"?e+"":e,t),t);const Vs=(l,e)=>(l%e+e)%e;class Ns extends c.EventDispatcher{constructor(e,t){super(),re(this,"object"),re(this,"domElement"),re(this,"enabled",!0),re(this,"target",new c.Vector3),re(this,"minDistance",0),re(this,"maxDistance",1/0),re(this,"minZoom",0),re(this,"maxZoom",1/0),re(this,"minPolarAngle",0),re(this,"maxPolarAngle",Math.PI),re(this,"minAzimuthAngle",-1/0),re(this,"maxAzimuthAngle",1/0),re(this,"enableDamping",!1),re(this,"dampingFactor",.05),re(this,"enableZoom",!0),re(this,"zoomSpeed",1),re(this,"enableRotate",!0),re(this,"rotateSpeed",1),re(this,"enablePan",!0),re(this,"panSpeed",1),re(this,"screenSpacePanning",!0),re(this,"keyPanSpeed",7),re(this,"autoRotate",!1),re(this,"autoRotateSpeed",2),re(this,"reverseOrbit",!1),re(this,"reverseHorizontalOrbit",!1),re(this,"reverseVerticalOrbit",!1),re(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),re(this,"mouseButtons",{LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN}),re(this,"touches",{ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN}),re(this,"target0"),re(this,"position0"),re(this,"zoom0"),re(this,"_domElementKeyEvents",null),re(this,"getPolarAngle"),re(this,"getAzimuthalAngle"),re(this,"setPolarAngle"),re(this,"setAzimuthalAngle"),re(this,"getDistance"),re(this,"listenToKeyEvents"),re(this,"stopListenToKeyEvents"),re(this,"saveState"),re(this,"reset"),re(this,"update"),re(this,"connect"),re(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>f.phi,this.getAzimuthalAngle=()=>f.theta,this.setPolarAngle=F=>{let X=Vs(F,2*Math.PI),le=f.phi;le<0&&(le+=2*Math.PI),X<0&&(X+=2*Math.PI);let xe=Math.abs(X-le);2*Math.PI-xe<xe&&(X<le?X+=2*Math.PI:le+=2*Math.PI),p.phi=X-le,s.update()},this.setAzimuthalAngle=F=>{let X=Vs(F,2*Math.PI),le=f.theta;le<0&&(le+=2*Math.PI),X<0&&(X+=2*Math.PI);let xe=Math.abs(X-le);2*Math.PI-xe<xe&&(X<le?X+=2*Math.PI:le+=2*Math.PI),p.theta=X-le,s.update()},this.getDistance=()=>s.object.position.distanceTo(s.target),this.listenToKeyEvents=F=>{F.addEventListener("keydown",Ot),this._domElementKeyEvents=F},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Ot),this._domElementKeyEvents=null},this.saveState=()=>{s.target0.copy(s.target),s.position0.copy(s.object.position),s.zoom0=s.object.zoom},this.reset=()=>{s.target.copy(s.target0),s.object.position.copy(s.position0),s.object.zoom=s.zoom0,s.object.updateProjectionMatrix(),s.dispatchEvent(n),s.update(),a=r.NONE},this.update=(()=>{const F=new c.Vector3,X=new c.Vector3(0,1,0),le=new c.Quaternion().setFromUnitVectors(e.up,X),xe=le.clone().invert(),Le=new c.Vector3,lt=new c.Quaternion,et=2*Math.PI;return function(){const Vn=s.object.position;le.setFromUnitVectors(e.up,X),xe.copy(le).invert(),F.copy(Vn).sub(s.target),F.applyQuaternion(le),f.setFromVector3(F),s.autoRotate&&a===r.NONE&&R(z()),s.enableDamping?(f.theta+=p.theta*s.dampingFactor,f.phi+=p.phi*s.dampingFactor):(f.theta+=p.theta,f.phi+=p.phi);let Ze=s.minAzimuthAngle,We=s.maxAzimuthAngle;return isFinite(Ze)&&isFinite(We)&&(Ze<-Math.PI?Ze+=et:Ze>Math.PI&&(Ze-=et),We<-Math.PI?We+=et:We>Math.PI&&(We-=et),Ze<=We?f.theta=Math.max(Ze,Math.min(We,f.theta)):f.theta=f.theta>(Ze+We)/2?Math.max(Ze,f.theta):Math.min(We,f.theta)),f.phi=Math.max(s.minPolarAngle,Math.min(s.maxPolarAngle,f.phi)),f.makeSafe(),f.radius*=m,f.radius=Math.max(s.minDistance,Math.min(s.maxDistance,f.radius)),s.enableDamping===!0?s.target.addScaledVector(g,s.dampingFactor):s.target.add(g),F.setFromSpherical(f),F.applyQuaternion(xe),Vn.copy(s.target).add(F),s.object.lookAt(s.target),s.enableDamping===!0?(p.theta*=1-s.dampingFactor,p.phi*=1-s.dampingFactor,g.multiplyScalar(1-s.dampingFactor)):(p.set(0,0,0),g.set(0,0,0)),m=1,w||Le.distanceToSquared(s.object.position)>h||8*(1-lt.dot(s.object.quaternion))>h?(s.dispatchEvent(n),Le.copy(s.object.position),lt.copy(s.object.quaternion),w=!1,!0):!1}})(),this.connect=F=>{F===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),s.domElement=F,s.domElement.style.touchAction="none",s.domElement.addEventListener("contextmenu",Yt),s.domElement.addEventListener("pointerdown",T),s.domElement.addEventListener("pointercancel",be),s.domElement.addEventListener("wheel",$e)},this.dispose=()=>{var F,X,le,xe,Le,lt;(F=s.domElement)==null||F.removeEventListener("contextmenu",Yt),(X=s.domElement)==null||X.removeEventListener("pointerdown",T),(le=s.domElement)==null||le.removeEventListener("pointercancel",be),(xe=s.domElement)==null||xe.removeEventListener("wheel",$e),(Le=s.domElement)==null||Le.ownerDocument.removeEventListener("pointermove",$),(lt=s.domElement)==null||lt.ownerDocument.removeEventListener("pointerup",de),s._domElementKeyEvents!==null&&s._domElementKeyEvents.removeEventListener("keydown",Ot)};const s=this,n={type:"change"},i={type:"start"},o={type:"end"},r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=r.NONE;const h=1e-6,f=new c.Spherical,p=new c.Spherical;let m=1;const g=new c.Vector3;let w=!1;const x=new c.Vector2,_=new c.Vector2,S=new c.Vector2,C=new c.Vector2,v=new c.Vector2,y=new c.Vector2,M=new c.Vector2,P=new c.Vector2,A=new c.Vector2,b=[],D={};function z(){return 2*Math.PI/60/60*s.autoRotateSpeed}function U(){return Math.pow(.95,s.zoomSpeed)}function R(F){s.reverseOrbit||s.reverseHorizontalOrbit?p.theta+=F:p.theta-=F}function K(F){s.reverseOrbit||s.reverseVerticalOrbit?p.phi+=F:p.phi-=F}const Z=(()=>{const F=new c.Vector3;return function(le,xe){F.setFromMatrixColumn(xe,0),F.multiplyScalar(-le),g.add(F)}})(),W=(()=>{const F=new c.Vector3;return function(le,xe){s.screenSpacePanning===!0?F.setFromMatrixColumn(xe,1):(F.setFromMatrixColumn(xe,0),F.crossVectors(s.object.up,F)),F.multiplyScalar(le),g.add(F)}})(),pe=(()=>{const F=new c.Vector3;return function(le,xe){const Le=s.domElement;if(Le&&s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera){const lt=s.object.position;F.copy(lt).sub(s.target);let et=F.length();et*=Math.tan(s.object.fov/2*Math.PI/180),Z(2*le*et/Le.clientHeight,s.object.matrix),W(2*xe*et/Le.clientHeight,s.object.matrix)}else Le&&s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(Z(le*(s.object.right-s.object.left)/s.object.zoom/Le.clientWidth,s.object.matrix),W(xe*(s.object.top-s.object.bottom)/s.object.zoom/Le.clientHeight,s.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),s.enablePan=!1)}})();function Q(F){s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera?m/=F:s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(s.object.zoom=Math.max(s.minZoom,Math.min(s.maxZoom,s.object.zoom*F)),s.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),s.enableZoom=!1)}function G(F){s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera?m*=F:s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(s.object.zoom=Math.max(s.minZoom,Math.min(s.maxZoom,s.object.zoom/F)),s.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),s.enableZoom=!1)}function ce(F){x.set(F.clientX,F.clientY)}function se(F){M.set(F.clientX,F.clientY)}function ae(F){C.set(F.clientX,F.clientY)}function B(F){_.set(F.clientX,F.clientY),S.subVectors(_,x).multiplyScalar(s.rotateSpeed);const X=s.domElement;X&&(R(2*Math.PI*S.x/X.clientHeight),K(2*Math.PI*S.y/X.clientHeight)),x.copy(_),s.update()}function I(F){P.set(F.clientX,F.clientY),A.subVectors(P,M),A.y>0?Q(U()):A.y<0&&G(U()),M.copy(P),s.update()}function d(F){v.set(F.clientX,F.clientY),y.subVectors(v,C).multiplyScalar(s.panSpeed),pe(y.x,y.y),C.copy(v),s.update()}function k(F){F.deltaY<0?G(U()):F.deltaY>0&&Q(U()),s.update()}function E(F){let X=!1;switch(F.code){case s.keys.UP:pe(0,s.keyPanSpeed),X=!0;break;case s.keys.BOTTOM:pe(0,-s.keyPanSpeed),X=!0;break;case s.keys.LEFT:pe(s.keyPanSpeed,0),X=!0;break;case s.keys.RIGHT:pe(-s.keyPanSpeed,0),X=!0;break}X&&(F.preventDefault(),s.update())}function L(){if(b.length==1)x.set(b[0].pageX,b[0].pageY);else{const F=.5*(b[0].pageX+b[1].pageX),X=.5*(b[0].pageY+b[1].pageY);x.set(F,X)}}function j(){if(b.length==1)C.set(b[0].pageX,b[0].pageY);else{const F=.5*(b[0].pageX+b[1].pageX),X=.5*(b[0].pageY+b[1].pageY);C.set(F,X)}}function ie(){const F=b[0].pageX-b[1].pageX,X=b[0].pageY-b[1].pageY,le=Math.sqrt(F*F+X*X);M.set(0,le)}function ee(){s.enableZoom&&ie(),s.enablePan&&j()}function te(){s.enableZoom&&ie(),s.enableRotate&&L()}function J(F){if(b.length==1)_.set(F.pageX,F.pageY);else{const le=Cs(F),xe=.5*(F.pageX+le.x),Le=.5*(F.pageY+le.y);_.set(xe,Le)}S.subVectors(_,x).multiplyScalar(s.rotateSpeed);const X=s.domElement;X&&(R(2*Math.PI*S.x/X.clientHeight),K(2*Math.PI*S.y/X.clientHeight)),x.copy(_)}function ge(F){if(b.length==1)v.set(F.pageX,F.pageY);else{const X=Cs(F),le=.5*(F.pageX+X.x),xe=.5*(F.pageY+X.y);v.set(le,xe)}y.subVectors(v,C).multiplyScalar(s.panSpeed),pe(y.x,y.y),C.copy(v)}function Y(F){const X=Cs(F),le=F.pageX-X.x,xe=F.pageY-X.y,Le=Math.sqrt(le*le+xe*xe);P.set(0,Le),A.set(0,Math.pow(P.y/M.y,s.zoomSpeed)),Q(A.y),M.copy(P)}function H(F){s.enableZoom&&Y(F),s.enablePan&&ge(F)}function O(F){s.enableZoom&&Y(F),s.enableRotate&&J(F)}function T(F){var X,le;s.enabled!==!1&&(b.length===0&&((X=s.domElement)==null||X.ownerDocument.addEventListener("pointermove",$),(le=s.domElement)==null||le.ownerDocument.addEventListener("pointerup",de)),Zt(F),F.pointerType==="touch"?Ts(F):Te(F))}function $(F){s.enabled!==!1&&(F.pointerType==="touch"?Xt(F):Ue(F))}function de(F){var X,le,xe;Bn(F),b.length===0&&((X=s.domElement)==null||X.releasePointerCapture(F.pointerId),(le=s.domElement)==null||le.ownerDocument.removeEventListener("pointermove",$),(xe=s.domElement)==null||xe.ownerDocument.removeEventListener("pointerup",de)),s.dispatchEvent(o),a=r.NONE}function be(F){Bn(F)}function Te(F){let X;switch(F.button){case 0:X=s.mouseButtons.LEFT;break;case 1:X=s.mouseButtons.MIDDLE;break;case 2:X=s.mouseButtons.RIGHT;break;default:X=-1}switch(X){case c.MOUSE.DOLLY:if(s.enableZoom===!1)return;se(F),a=r.DOLLY;break;case c.MOUSE.ROTATE:if(F.ctrlKey||F.metaKey||F.shiftKey){if(s.enablePan===!1)return;ae(F),a=r.PAN}else{if(s.enableRotate===!1)return;ce(F),a=r.ROTATE}break;case c.MOUSE.PAN:if(F.ctrlKey||F.metaKey||F.shiftKey){if(s.enableRotate===!1)return;ce(F),a=r.ROTATE}else{if(s.enablePan===!1)return;ae(F),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&s.dispatchEvent(i)}function Ue(F){if(s.enabled!==!1)switch(a){case r.ROTATE:if(s.enableRotate===!1)return;B(F);break;case r.DOLLY:if(s.enableZoom===!1)return;I(F);break;case r.PAN:if(s.enablePan===!1)return;d(F);break}}function $e(F){s.enabled===!1||s.enableZoom===!1||a!==r.NONE&&a!==r.ROTATE||(F.preventDefault(),s.dispatchEvent(i),k(F),s.dispatchEvent(o))}function Ot(F){s.enabled===!1||s.enablePan===!1||E(F)}function Ts(F){switch(Un(F),b.length){case 1:switch(s.touches.ONE){case c.TOUCH.ROTATE:if(s.enableRotate===!1)return;L(),a=r.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(s.enablePan===!1)return;j(),a=r.TOUCH_PAN;break;default:a=r.NONE}break;case 2:switch(s.touches.TWO){case c.TOUCH.DOLLY_PAN:if(s.enableZoom===!1&&s.enablePan===!1)return;ee(),a=r.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(s.enableZoom===!1&&s.enableRotate===!1)return;te(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&s.dispatchEvent(i)}function Xt(F){switch(Un(F),a){case r.TOUCH_ROTATE:if(s.enableRotate===!1)return;J(F),s.update();break;case r.TOUCH_PAN:if(s.enablePan===!1)return;ge(F),s.update();break;case r.TOUCH_DOLLY_PAN:if(s.enableZoom===!1&&s.enablePan===!1)return;H(F),s.update();break;case r.TOUCH_DOLLY_ROTATE:if(s.enableZoom===!1&&s.enableRotate===!1)return;O(F),s.update();break;default:a=r.NONE}}function Yt(F){s.enabled!==!1&&F.preventDefault()}function Zt(F){b.push(F)}function Bn(F){delete D[F.pointerId];for(let X=0;X<b.length;X++)if(b[X].pointerId==F.pointerId){b.splice(X,1);return}}function Un(F){let X=D[F.pointerId];X===void 0&&(X=new c.Vector2,D[F.pointerId]=X),X.set(F.pageX,F.pageY)}function Cs(F){const X=F.pointerId===b[0].pointerId?b[1]:b[0];return D[X.pointerId]}t!==void 0&&this.connect(t),this.update()}}class ui extends Ns{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=c.MOUSE.PAN,this.mouseButtons.RIGHT=c.MOUSE.ROTATE,this.touches.ONE=c.TOUCH.PAN,this.touches.TWO=c.TOUCH.DOLLY_ROTATE}}class pi extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new yi(t)}),this.register(function(t){return new Si(t)}),this.register(function(t){return new Pi(t)}),this.register(function(t){return new Ti(t)}),this.register(function(t){return new xi(t)}),this.register(function(t){return new wi(t)}),this.register(function(t){return new vi(t)}),this.register(function(t){return new bi(t)}),this.register(function(t){return new gi(t)}),this.register(function(t){return new Ai(t)}),this.register(function(t){return new _i(t)}),this.register(function(t){return new Mi(t)}),this.register(function(t){return new di(t)}),this.register(function(t){return new Ci(t)}),this.register(function(t){return new Li(t)})}load(e,t,s,n){const i=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=c.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const r=function(h){n?n(h):console.error(h),i.manager.itemError(e),i.manager.itemEnd(e)},a=new c.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(h){try{i.parse(h,o,function(f){t(f),i.manager.itemEnd(e)},r)}catch(f){r(f)}},s,r)}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,s,n){let i;const o={},r={};if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===zs){try{o[me.KHR_BINARY_GLTF]=new Oi(e)}catch(f){n&&n(f);return}i=JSON.parse(o[me.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.LoaderUtils.decodeText(new Uint8Array(e)));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const a=new ji(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const f=this.pluginCallbacks[h](a);r[f.name]=f,o[f.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const f=i.extensionsUsed[h],p=i.extensionsRequired||[];switch(f){case me.KHR_MATERIALS_UNLIT:o[f]=new mi;break;case me.KHR_DRACO_MESH_COMPRESSION:o[f]=new Ii(i,this.dracoLoader);break;case me.KHR_TEXTURE_TRANSFORM:o[f]=new Di;break;case me.KHR_MESH_QUANTIZATION:o[f]=new ki;break;default:p.indexOf(f)>=0&&r[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}a.setExtensions(o),a.setPlugins(r),a.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function fi(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const me={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_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_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 di{constructor(e){this.parser=e,this.name=me.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let h;const f=new c.Color(16777215);a.color!==void 0&&f.fromArray(a.color);const p=a.range!==void 0?a.range:0;switch(a.type){case"directional":h=new c.DirectionalLight(f),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new c.PointLight(f),h.distance=p;break;case"spot":h=new c.SpotLight(f),h.distance=p,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,h.angle=a.spot.outerConeAngle,h.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return h.position.set(0,0,0),h.decay=2,Je(h,a),a.intensity!==void 0&&(h.intensity=a.intensity),h.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(h),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return s._getNodeRef(t.cache,r,a)})}}class mi{constructor(){this.name=me.KHR_MATERIALS_UNLIT}getMaterialType(){return c.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new c.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.fromArray(o),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,3001))}return Promise.all(n)}}class gi{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class yi{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const r=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new c.Vector2(r,r)}return Promise.all(i)}}class _i{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class xi{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];return o.sheenColorFactor!==void 0&&t.sheenColor.fromArray(o.sheenColorFactor),o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,3001)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class wi{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class vi{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const r=o.attenuationColor||[1,1,1];return t.attenuationColor=new c.Color(r[0],r[1],r[2]),Promise.all(i)}}class bi{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Ai{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const r=o.specularColorFactor||[1,1,1];return t.specularColor=new c.Color(r[0],r[1],r[2]),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,3001)),Promise.all(i)}}class Mi{constructor(e){this.parser=e,this.name=me.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Si{constructor(e){this.parser=e,this.name=me.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class Pi{constructor(e){this.parser=e,this.name=me.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=n.images[o.source];let a=s.textureLoader;if(r.uri){const h=s.options.manager.getHandler(r.uri);h!==null&&(a=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,o.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.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 Ti{constructor(e){this.parser=e,this.name=me.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=n.images[o.source];let a=s.textureLoader;if(r.uri){const h=s.options.manager.getHandler(r.uri);h!==null&&(a=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,o.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.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 Ci{constructor(e){this.name=me.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(r){const a=n.byteOffset||0,h=n.byteLength||0,f=n.count,p=n.byteStride,m=new Uint8Array(r,a,h);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(f,p,m,n.mode,n.filter).then(function(g){return g.buffer}):o.ready.then(function(){const g=new ArrayBuffer(f*p);return o.decodeGltfBuffer(new Uint8Array(g),f,p,m,n.mode,n.filter),g})})}else return null}}class Li{constructor(e){this.name=me.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const h of n.primitives)if(h.mode!==ke.TRIANGLES&&h.mode!==ke.TRIANGLE_STRIP&&h.mode!==ke.TRIANGLE_FAN&&h.mode!==void 0)return null;const o=s.extensions[this.name].attributes,r=[],a={};for(const h in o)r.push(this.parser.getDependency("accessor",o[h]).then(f=>(a[h]=f,a[h])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(h=>{const f=h.pop(),p=f.isGroup?f.children:[f],m=h[0].count,g=[];for(const w of p){const x=new c.Matrix4,_=new c.Vector3,S=new c.Quaternion,C=new c.Vector3(1,1,1),v=new c.InstancedMesh(w.geometry,w.material,m);for(let y=0;y<m;y++)a.TRANSLATION&&_.fromBufferAttribute(a.TRANSLATION,y),a.ROTATION&&S.fromBufferAttribute(a.ROTATION,y),a.SCALE&&C.fromBufferAttribute(a.SCALE,y),v.setMatrixAt(y,x.compose(_,S,C));for(const y in a)y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&w.geometry.setAttribute(y,a[y]);c.Object3D.prototype.copy.call(v,w),this.parser.assignFinalMaterial(v),g.push(v)}return f.isGroup?(f.clear(),f.add(...g),f):g[0]}))}}const zs="glTF",xt=12,Rs={JSON:1313821514,BIN:5130562};class Oi{constructor(e){this.name=me.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,xt);if(this.header={magic:c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==zs)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-xt,n=new DataView(e,xt);let i=0;for(;i<s;){const o=n.getUint32(i,!0);i+=4;const r=n.getUint32(i,!0);if(i+=4,r===Rs.JSON){const a=new Uint8Array(e,xt+i,o);this.content=c.LoaderUtils.decodeText(a)}else if(r===Rs.BIN){const a=xt+i;this.body=e.slice(a,a+o)}i+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ii{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=me.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,r={},a={},h={};for(const f in o){const p=es[f]||f.toLowerCase();r[p]=o[f]}for(const f in e.attributes){const p=es[f]||f.toLowerCase();if(o[f]!==void 0){const m=s.accessors[e.attributes[f]],g=ut[m.componentType];h[p]=g.name,a[p]=m.normalized===!0}}return t.getDependency("bufferView",i).then(function(f){return new Promise(function(p){n.decodeDracoFile(f,function(m){for(const g in m.attributes){const w=m.attributes[g],x=a[g];x!==void 0&&(w.normalized=x)}p(m)},r,h)})})}}class Di{constructor(){this.name=me.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 ki{constructor(){this.name=me.KHR_MESH_QUANTIZATION}}class Gs extends c.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,r=this.valueSize,a=r*2,h=r*3,f=n-t,p=(s-t)/f,m=p*p,g=m*p,w=e*h,x=w-h,_=-2*g+3*m,S=g-m,C=1-_,v=S-m+p;for(let y=0;y!==r;y++){const M=o[x+y+r],P=o[x+y+a]*f,A=o[w+y+r],b=o[w+y]*f;i[y]=C*M+v*P+_*A+S*b}return i}}const Fi=new c.Quaternion;class Bi extends Gs{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return Fi.fromArray(i).normalize().toArray(i),i}}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},Es={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},js={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},$t={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},es={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...c.REVISION.replace(/\D+/g,"")>=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"},qe={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ui={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},ts={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Vi(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),l.DefaultMaterial}function tt(l,e,t){for(const s in t.extensions)l[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function Je(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Ni(l,e,t){let s=!1,n=!1,i=!1;for(let h=0,f=e.length;h<f;h++){const p=e[h];if(p.POSITION!==void 0&&(s=!0),p.NORMAL!==void 0&&(n=!0),p.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const o=[],r=[],a=[];for(let h=0,f=e.length;h<f;h++){const p=e[h];if(s){const m=p.POSITION!==void 0?t.getDependency("accessor",p.POSITION):l.attributes.position;o.push(m)}if(n){const m=p.NORMAL!==void 0?t.getDependency("accessor",p.NORMAL):l.attributes.normal;r.push(m)}if(i){const m=p.COLOR_0!==void 0?t.getDependency("accessor",p.COLOR_0):l.attributes.color;a.push(m)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a)]).then(function(h){const f=h[0],p=h[1],m=h[2];return s&&(l.morphAttributes.position=f),n&&(l.morphAttributes.normal=p),i&&(l.morphAttributes.color=m),l.morphTargetsRelative=!0,l})}function zi(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)l.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ri(l){let e;const t=l.extensions&&l.extensions[me.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ss(t.attributes):e=l.indices+":"+ss(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+ss(l.targets[s]);return e}function ss(l){let e="";const t=Object.keys(l).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+l[t[s]]+";";return e}function ns(l){switch(l){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 Gi(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Ei=new c.Matrix4;class ji{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fi,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=!1,i=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,i=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||n&&i<98?this.textureLoader=new c.TextureLoader(this.options.manager):this.textureLoader=new c.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const r={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};tt(i,r,n),Je(r,n),Promise.all(s._invokeAll(function(a){return a.afterRoot&&a.afterRoot(r)})).then(function(){e(r)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let r=0,a=o.length;r<a;r++)e[o[r]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,r)=>{const a=this.associations.get(o);a!=null&&this.associations.set(r,a);for(const[h,f]of o.children.entries())i(f,r.children[h])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[me.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(c.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=$t[n.type],r=ut[n.componentType],a=n.normalized===!0,h=new r(n.count*o);return Promise.resolve(new c.BufferAttribute(h,o,a))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const r=o[0],a=$t[n.type],h=ut[n.componentType],f=h.BYTES_PER_ELEMENT,p=f*a,m=n.byteOffset||0,g=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,w=n.normalized===!0;let x,_;if(g&&g!==p){const S=Math.floor(m/g),C="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+S+":"+n.count;let v=t.cache.get(C);v||(x=new h(r,S*g,n.count*g/f),v=new c.InterleavedBuffer(x,g/f),t.cache.add(C,v)),_=new c.InterleavedBufferAttribute(v,a,m%g/f,w)}else r===null?x=new h(n.count*a):x=new h(r,m,n.count*a),_=new c.BufferAttribute(x,a,w);if(n.sparse!==void 0){const S=$t.SCALAR,C=ut[n.sparse.indices.componentType],v=n.sparse.indices.byteOffset||0,y=n.sparse.values.byteOffset||0,M=new C(o[1],v,n.sparse.count*S),P=new h(o[2],y,n.sparse.count*a);r!==null&&(_=new c.BufferAttribute(_.array.slice(),_.itemSize,_.normalized));for(let A=0,b=M.length;A<b;A++){const D=M[A];if(_.setX(D,P[A*a]),a>=2&&_.setY(D,P[A*a+1]),a>=3&&_.setZ(D,P[A*a+2]),a>=4&&_.setW(D,P[A*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let r=this.textureLoader;if(o.uri){const a=s.manager.getHandler(o.uri);a!==null&&(r=a)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],r=i.images[t],a=(r.uri||r.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const h=this.loadImageSource(t,s).then(function(f){f.flipY=!1,f.name=o.name||r.name||"",f.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(f.name=r.uri);const m=(i.samplers||{})[o.sampler]||{};return f.magFilter=Es[m.magFilter]||c.LinearFilter,f.minFilter=Es[m.minFilter]||c.LinearMipmapLinearFilter,f.wrapS=js[m.wrapS]||c.RepeatWrapping,f.wrapT=js[m.wrapT]||c.RepeatWrapping,n.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[a]=h,h}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(p=>p.clone());const o=n.images[e],r=self.URL||self.webkitURL;let a=o.uri||"",h=!1;if(o.bufferView!==void 0)a=s.getDependency("bufferView",o.bufferView).then(function(p){h=!0;const m=new Blob([p],{type:o.mimeType});return a=r.createObjectURL(m),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(a).then(function(p){return new Promise(function(m,g){let w=m;t.isImageBitmapLoader===!0&&(w=function(x){const _=new c.Texture(x);_.needsUpdate=!0,m(_)}),t.load(c.LoaderUtils.resolveURL(p,i.path),w,void 0,g)})}).then(function(p){return h===!0&&r.revokeObjectURL(a),p.userData.mimeType=o.mimeType||Gi(o.uri),p}).catch(function(p){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),p});return this.sourceCache[e]=f,f}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[me.KHR_TEXTURE_TRANSFORM]){const r=s.extensions!==void 0?s.extensions[me.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=i.associations.get(o);o=i.extensions[me.KHR_TEXTURE_TRANSFORM].extendTexture(o,r),i.associations.set(o,a)}}return n!==void 0&&("colorSpace"in o?o.colorSpace=n===3001?"srgb":"srgb-linear":o.encoding=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+s.uuid;let a=this.cache.get(r);a||(a=new c.PointsMaterial,c.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,a.sizeAttenuation=!1,this.cache.add(r,a)),s=a}else if(e.isLine){const r="LineBasicMaterial:"+s.uuid;let a=this.cache.get(r);a||(a=new c.LineBasicMaterial,c.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,this.cache.add(r,a)),s=a}if(n||i||o){let r="ClonedMaterial:"+s.uuid+":";n&&(r+="derivative-tangents:"),i&&(r+="vertex-colors:"),o&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=s.clone(),i&&(a.vertexColors=!0),o&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(s))),s=a}e.material=s}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const r={},a=i.extensions||{},h=[];if(a[me.KHR_MATERIALS_UNLIT]){const p=n[me.KHR_MATERIALS_UNLIT];o=p.getMaterialType(),h.push(p.extendParams(r,i,t))}else{const p=i.pbrMetallicRoughness||{};if(r.color=new c.Color(1,1,1),r.opacity=1,Array.isArray(p.baseColorFactor)){const m=p.baseColorFactor;r.color.fromArray(m),r.opacity=m[3]}p.baseColorTexture!==void 0&&h.push(t.assignTexture(r,"map",p.baseColorTexture,3001)),r.metalness=p.metallicFactor!==void 0?p.metallicFactor:1,r.roughness=p.roughnessFactor!==void 0?p.roughnessFactor:1,p.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(r,"metalnessMap",p.metallicRoughnessTexture)),h.push(t.assignTexture(r,"roughnessMap",p.metallicRoughnessTexture))),o=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,r)})))}i.doubleSided===!0&&(r.side=c.DoubleSide);const f=i.alphaMode||ts.OPAQUE;if(f===ts.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,f===ts.MASK&&(r.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==c.MeshBasicMaterial&&(h.push(t.assignTexture(r,"normalMap",i.normalTexture)),r.normalScale=new c.Vector2(1,1),i.normalTexture.scale!==void 0)){const p=i.normalTexture.scale;r.normalScale.set(p,p)}return i.occlusionTexture!==void 0&&o!==c.MeshBasicMaterial&&(h.push(t.assignTexture(r,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==c.MeshBasicMaterial&&(r.emissive=new c.Color().fromArray(i.emissiveFactor)),i.emissiveTexture!==void 0&&o!==c.MeshBasicMaterial&&h.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture,3001)),Promise.all(h).then(function(){const p=new o(r);return i.name&&(p.name=i.name),Je(p,i),t.associations.set(p,{materials:e}),i.extensions&&tt(n,p,i),p})}createUniqueName(e){const t=c.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(r){return s[me.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return Xs(a,r,t)})}const o=[];for(let r=0,a=e.length;r<a;r++){const h=e[r],f=Ri(h),p=n[f];if(p)o.push(p.promise);else{let m;h.extensions&&h.extensions[me.KHR_DRACO_MESH_COMPRESSION]?m=i(h):m=Xs(new c.BufferGeometry,h,t),n[f]={primitive:h,promise:m},o.push(m)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,r=[];for(let a=0,h=o.length;a<h;a++){const f=o[a].material===void 0?Vi(this.cache):this.getDependency("material",o[a].material);r.push(f)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(a){const h=a.slice(0,a.length-1),f=a[a.length-1],p=[];for(let g=0,w=f.length;g<w;g++){const x=f[g],_=o[g];let S;const C=h[g];if(_.mode===ke.TRIANGLES||_.mode===ke.TRIANGLE_STRIP||_.mode===ke.TRIANGLE_FAN||_.mode===void 0)S=i.isSkinnedMesh===!0?new c.SkinnedMesh(x,C):new c.Mesh(x,C),S.isSkinnedMesh===!0&&S.normalizeSkinWeights(),_.mode===ke.TRIANGLE_STRIP?S.geometry=Ls(S.geometry,c.TriangleStripDrawMode):_.mode===ke.TRIANGLE_FAN&&(S.geometry=Ls(S.geometry,c.TriangleFanDrawMode));else if(_.mode===ke.LINES)S=new c.LineSegments(x,C);else if(_.mode===ke.LINE_STRIP)S=new c.Line(x,C);else if(_.mode===ke.LINE_LOOP)S=new c.LineLoop(x,C);else if(_.mode===ke.POINTS)S=new c.Points(x,C);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(S.geometry.morphAttributes).length>0&&zi(S,i),S.name=t.createUniqueName(i.name||"mesh_"+e),Je(S,i),_.extensions&&tt(n,S,_),t.assignFinalMaterial(S),p.push(S)}for(let g=0,w=p.length;g<w;g++)t.associations.set(p[g],{meshes:e,primitives:g});if(p.length===1)return i.extensions&&tt(n,p[0],i),p[0];const m=new c.Group;i.extensions&&tt(n,m,i),t.associations.set(m,{meshes:e});for(let g=0,w=p.length;g<w;g++)m.add(p[g]);return m})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new c.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),Je(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,r=[],a=[];for(let h=0,f=o.length;h<f;h++){const p=o[h];if(p){r.push(p);const m=new c.Matrix4;i!==null&&m.fromArray(i.array,h*16),a.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new c.Skeleton(r,a)})}loadAnimation(e){const s=this.json.animations[e],n=s.name?s.name:"animation_"+e,i=[],o=[],r=[],a=[],h=[];for(let f=0,p=s.channels.length;f<p;f++){const m=s.channels[f],g=s.samplers[m.sampler],w=m.target,x=w.node,_=s.parameters!==void 0?s.parameters[g.input]:g.input,S=s.parameters!==void 0?s.parameters[g.output]:g.output;w.node!==void 0&&(i.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",_)),r.push(this.getDependency("accessor",S)),a.push(g),h.push(w))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(r),Promise.all(a),Promise.all(h)]).then(function(f){const p=f[0],m=f[1],g=f[2],w=f[3],x=f[4],_=[];for(let S=0,C=p.length;S<C;S++){const v=p[S],y=m[S],M=g[S],P=w[S],A=x[S];if(v===void 0)continue;v.updateMatrix();let b;switch(qe[A.path]){case qe.weights:b=c.NumberKeyframeTrack;break;case qe.rotation:b=c.QuaternionKeyframeTrack;break;case qe.position:case qe.scale:default:b=c.VectorKeyframeTrack;break}const D=v.name?v.name:v.uuid,z=P.interpolation!==void 0?Ui[P.interpolation]:c.InterpolateLinear,U=[];qe[A.path]===qe.weights?v.traverse(function(K){K.morphTargetInfluences&&U.push(K.name?K.name:K.uuid)}):U.push(D);let R=M.array;if(M.normalized){const K=ns(R.constructor),Z=new Float32Array(R.length);for(let W=0,pe=R.length;W<pe;W++)Z[W]=R[W]*K;R=Z}for(let K=0,Z=U.length;K<Z;K++){const W=new b(U[K]+"."+qe[A.path],y.array,R,z);P.interpolation==="CUBICSPLINE"&&(W.createInterpolant=function(Q){const G=this instanceof c.QuaternionKeyframeTrack?Bi:Gs;return new G(this.times,this.values,this.getValueSize()/3,Q)},W.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),_.push(W)}}return new c.AnimationClip(n,void 0,_)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(r){if(r.isMesh)for(let a=0,h=n.weights.length;a<h;a++)r.morphTargetInfluences[a]=n.weights[a]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],r=n.children||[];for(let h=0,f=r.length;h<f;h++)o.push(s.getDependency("node",r[h]));const a=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),a]).then(function(h){const f=h[0],p=h[1],m=h[2];m!==null&&f.traverse(function(g){g.isSkinnedMesh&&g.bind(m,Ei)});for(let g=0,w=p.length;g<w;g++)f.add(p[g]);return f})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",r=[],a=n._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return a&&r.push(a),i.camera!==void 0&&r.push(n.getDependency("camera",i.camera).then(function(h){return n._getNodeRef(n.cameraCache,i.camera,h)})),n._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){r.push(h)}),this.nodeCache[e]=Promise.all(r).then(function(h){let f;if(i.isBone===!0?f=new c.Bone:h.length>1?f=new c.Group:h.length===1?f=h[0]:f=new c.Object3D,f!==h[0])for(let p=0,m=h.length;p<m;p++)f.add(h[p]);if(i.name&&(f.userData.name=i.name,f.name=o),Je(f,i),i.extensions&&tt(s,f,i),i.matrix!==void 0){const p=new c.Matrix4;p.fromArray(i.matrix),f.applyMatrix4(p)}else i.translation!==void 0&&f.position.fromArray(i.translation),i.rotation!==void 0&&f.quaternion.fromArray(i.rotation),i.scale!==void 0&&f.scale.fromArray(i.scale);return n.associations.has(f)||n.associations.set(f,{}),n.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new c.Group;s.name&&(i.name=n.createUniqueName(s.name)),Je(i,s),s.extensions&&tt(t,i,s);const o=s.nodes||[],r=[];for(let a=0,h=o.length;a<h;a++)r.push(n.getDependency("node",o[a]));return Promise.all(r).then(function(a){for(let f=0,p=a.length;f<p;f++)i.add(a[f]);const h=f=>{const p=new Map;for(const[m,g]of n.associations)(m instanceof c.Material||m instanceof c.Texture)&&p.set(m,g);return f.traverse(m=>{const g=n.associations.get(m);g!=null&&p.set(m,g)}),p};return n.associations=h(i),i})}}function Xi(l,e,t){const s=e.attributes,n=new c.Box3;if(s.POSITION!==void 0){const r=t.json.accessors[s.POSITION],a=r.min,h=r.max;if(a!==void 0&&h!==void 0){if(n.set(new c.Vector3(a[0],a[1],a[2]),new c.Vector3(h[0],h[1],h[2])),r.normalized){const f=ns(ut[r.componentType]);n.min.multiplyScalar(f),n.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new c.Vector3,a=new c.Vector3;for(let h=0,f=i.length;h<f;h++){const p=i[h];if(p.POSITION!==void 0){const m=t.json.accessors[p.POSITION],g=m.min,w=m.max;if(g!==void 0&&w!==void 0){if(a.setX(Math.max(Math.abs(g[0]),Math.abs(w[0]))),a.setY(Math.max(Math.abs(g[1]),Math.abs(w[1]))),a.setZ(Math.max(Math.abs(g[2]),Math.abs(w[2]))),m.normalized){const x=ns(ut[m.componentType]);a.multiplyScalar(x)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(r)}l.boundingBox=n;const o=new c.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=o}function Xs(l,e,t){const s=e.attributes,n=[];function i(o,r){return t.getDependency("accessor",o).then(function(a){l.setAttribute(r,a)})}for(const o in s){const r=es[o]||o.toLowerCase();r in l.attributes||n.push(i(s[o],r))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(r){l.setIndex(r)});n.push(o)}return Je(l,e),Xi(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Ni(l,e.targets,t):l})}class Ys extends c.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:s=!1,bevelSize:n=8,bevelThickness:i=10,font:o,height:r=50,size:a=100,lineHeight:h=1,letterSpacing:f=0,...p}=t;if(o===void 0)super();else{const m=o.generateShapes(e,a,{lineHeight:h,letterSpacing:f});super(m,{...p,bevelEnabled:s,bevelSize:n,bevelThickness:i,depth:r})}this.type="TextGeometry"}}const Yi={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
8
+ (function(q,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("three"),require("vue"),require("@tresjs/core"),require("tweakpane")):typeof define=="function"&&define.amd?define(["exports","three","vue","@tresjs/core","tweakpane"],c):(q=typeof globalThis<"u"?globalThis:q||self,c(q.trescientos={},q.Three,q.Vue,q.TresjsCore,q.tweakpane))})(this,function(q,c,h,ne,Li){"use strict";var kc=Object.defineProperty;var Fc=(q,c,h)=>c in q?kc(q,c,{enumerable:!0,configurable:!0,writable:!0,value:h}):q[c]=h;var Me=(q,c,h)=>(Fc(q,typeof c!="symbol"?c+"":c,h),h);function ts(a,e){if(e===c.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),a;if(e===c.TriangleFanDrawMode||e===c.TriangleStripDrawMode){let t=a.getIndex();if(t===null){const o=[],r=a.getAttribute("position");if(r!==void 0){for(let l=0;l<r.count;l++)o.push(l);a.setIndex(o),t=a.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),a}const n=t.count-2,s=[];if(t)if(e===c.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=a.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),a}const Ti=parseInt(c.REVISION.replace(/\D+/g,""));var Ue=Uint8Array,nt=Uint16Array,mn=Uint32Array,ns=new Ue([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ss=new Ue([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Oi=new Ue([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),is=function(a,e){for(var t=new nt(31),n=0;n<31;++n)t[n]=e+=1<<a[n-1];for(var s=new mn(t[30]),n=1;n<30;++n)for(var i=t[n];i<t[n+1];++i)s[i]=i-t[n]<<5|n;return[t,s]},os=is(ns,2),rs=os[0],Di=os[1];rs[28]=258,Di[258]=28;for(var Ii=is(ss,0),ki=Ii[0],gn=new nt(32768),be=0;be<32768;++be){var st=(be&43690)>>>1|(be&21845)<<1;st=(st&52428)>>>2|(st&13107)<<2,st=(st&61680)>>>4|(st&3855)<<4,gn[be]=((st&65280)>>>8|(st&255)<<8)>>>1}for(var Lt=function(a,e,t){for(var n=a.length,s=0,i=new nt(e);s<n;++s)++i[a[s]-1];var o=new nt(e);for(s=0;s<e;++s)o[s]=o[s-1]+i[s-1]<<1;var r;if(t){r=new nt(1<<e);var l=15-e;for(s=0;s<n;++s)if(a[s])for(var f=s<<4|a[s],d=e-a[s],u=o[a[s]-1]++<<d,p=u|(1<<d)-1;u<=p;++u)r[gn[u]>>>l]=f}else for(r=new nt(n),s=0;s<n;++s)a[s]&&(r[s]=gn[o[a[s]-1]++]>>>15-a[s]);return r},Tt=new Ue(288),be=0;be<144;++be)Tt[be]=8;for(var be=144;be<256;++be)Tt[be]=9;for(var be=256;be<280;++be)Tt[be]=7;for(var be=280;be<288;++be)Tt[be]=8;for(var as=new Ue(32),be=0;be<32;++be)as[be]=5;var Fi=Lt(Tt,9,1),Bi=Lt(as,5,1),yn=function(a){for(var e=a[0],t=1;t<a.length;++t)a[t]>e&&(e=a[t]);return e},Re=function(a,e,t){var n=e/8|0;return(a[n]|a[n+1]<<8)>>(e&7)&t},_n=function(a,e){var t=e/8|0;return(a[t]|a[t+1]<<8|a[t+2]<<16)>>(e&7)},Ui=function(a){return(a/8|0)+(a&7&&1)},Vi=function(a,e,t){(e==null||e<0)&&(e=0),(t==null||t>a.length)&&(t=a.length);var n=new(a instanceof nt?nt:a instanceof mn?mn:Ue)(t-e);return n.set(a.subarray(e,t)),n},zi=function(a,e,t){var n=a.length;if(!n||t&&!t.l&&n<5)return e||new Ue(0);var s=!e||t,i=!t||t.i;t||(t={}),e||(e=new Ue(n*3));var o=function(j){var D=e.length;if(j>D){var E=new Ue(Math.max(D*2,j));E.set(e),e=E}},r=t.f||0,l=t.p||0,f=t.b||0,d=t.l,u=t.d,p=t.m,g=t.n,x=n*8;do{if(!d){t.f=r=Re(a,l,1);var w=Re(a,l+1,3);if(l+=3,w)if(w==1)d=Fi,u=Bi,p=9,g=5;else if(w==2){var v=Re(a,l,31)+257,y=Re(a,l+10,15)+4,A=v+Re(a,l+5,31)+1;l+=14;for(var S=new Ue(A),b=new Ue(19),P=0;P<y;++P)b[Oi[P]]=Re(a,l+P*3,7);l+=y*3;for(var O=yn(b),k=(1<<O)-1,V=Lt(b,O,1),P=0;P<A;){var R=V[Re(a,l,k)];l+=R&15;var _=R>>>4;if(_<16)S[P++]=_;else{var X=0,K=0;for(_==16?(K=3+Re(a,l,3),l+=2,X=S[P-1]):_==17?(K=3+Re(a,l,7),l+=3):_==18&&(K=11+Re(a,l,127),l+=7);K--;)S[P++]=X}}var H=S.subarray(0,v),he=S.subarray(v);p=yn(H),g=yn(he),d=Lt(H,p,1),u=Lt(he,g,1)}else throw"invalid block type";else{var _=Ui(l)+4,M=a[_-4]|a[_-3]<<8,L=_+M;if(L>n){if(i)throw"unexpected EOF";break}s&&o(f+M),e.set(a.subarray(_,L),f),t.b=f+=M,t.p=l=L*8;continue}if(l>x){if(i)throw"unexpected EOF";break}}s&&o(f+131072);for(var J=(1<<p)-1,G=(1<<g)-1,oe=l;;oe=l){var X=d[_n(a,l)&J],se=X>>>4;if(l+=X&15,l>x){if(i)throw"unexpected EOF";break}if(!X)throw"invalid length/literal";if(se<256)e[f++]=se;else if(se==256){oe=l,d=null;break}else{var ce=se-254;if(se>264){var P=se-257,U=ns[P];ce=Re(a,l,(1<<U)-1)+rs[P],l+=U}var T=u[_n(a,l)&G],m=T>>>4;if(!T)throw"invalid distance";l+=T&15;var he=ki[m];if(m>3){var U=ss[m];he+=_n(a,l)&(1<<U)-1,l+=U}if(l>x){if(i)throw"unexpected EOF";break}s&&o(f+131072);for(var F=f+ce;f<F;f+=4)e[f]=e[f-he],e[f+1]=e[f+1-he],e[f+2]=e[f+2-he],e[f+3]=e[f+3-he];f=F}}t.l=d,t.p=oe,t.b=f,d&&(r=1,t.m=p,t.d=u,t.n=g)}while(!r);return f==e.length?e:Vi(e,0,f)},Ni=new Ue(0),Gi=function(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Ri(a,e){return zi((Gi(a),a.subarray(2,-4)),e)}var ji=typeof TextDecoder<"u"&&new TextDecoder,Ei=0;try{ji.decode(Ni,{stream:!0}),Ei=1}catch{}var Xi=Object.defineProperty,Yi=(a,e,t)=>e in a?Xi(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,z=(a,e,t)=>(Yi(a,typeof e!="symbol"?e+"":e,t),t);class Wi extends c.Object3D{constructor(e,t){super(),z(this,"isTransformControls",!0),z(this,"visible",!1),z(this,"domElement"),z(this,"raycaster",new c.Raycaster),z(this,"gizmo"),z(this,"plane"),z(this,"tempVector",new c.Vector3),z(this,"tempVector2",new c.Vector3),z(this,"tempQuaternion",new c.Quaternion),z(this,"unit",{X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)}),z(this,"pointStart",new c.Vector3),z(this,"pointEnd",new c.Vector3),z(this,"offset",new c.Vector3),z(this,"rotationAxis",new c.Vector3),z(this,"startNorm",new c.Vector3),z(this,"endNorm",new c.Vector3),z(this,"rotationAngle",0),z(this,"cameraPosition",new c.Vector3),z(this,"cameraQuaternion",new c.Quaternion),z(this,"cameraScale",new c.Vector3),z(this,"parentPosition",new c.Vector3),z(this,"parentQuaternion",new c.Quaternion),z(this,"parentQuaternionInv",new c.Quaternion),z(this,"parentScale",new c.Vector3),z(this,"worldPositionStart",new c.Vector3),z(this,"worldQuaternionStart",new c.Quaternion),z(this,"worldScaleStart",new c.Vector3),z(this,"worldPosition",new c.Vector3),z(this,"worldQuaternion",new c.Quaternion),z(this,"worldQuaternionInv",new c.Quaternion),z(this,"worldScale",new c.Vector3),z(this,"eye",new c.Vector3),z(this,"positionStart",new c.Vector3),z(this,"quaternionStart",new c.Quaternion),z(this,"scaleStart",new c.Vector3),z(this,"camera"),z(this,"object"),z(this,"enabled",!0),z(this,"axis",null),z(this,"mode","translate"),z(this,"translationSnap",null),z(this,"rotationSnap",null),z(this,"scaleSnap",null),z(this,"space","world"),z(this,"size",1),z(this,"dragging",!1),z(this,"showX",!0),z(this,"showY",!0),z(this,"showZ",!0),z(this,"changeEvent",{type:"change"}),z(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),z(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),z(this,"objectChangeEvent",{type:"objectChange"}),z(this,"intersectObjectWithRay",(s,i,o)=>{const r=i.intersectObject(s,!0);for(let l=0;l<r.length;l++)if(r[l].object.visible||o)return r[l];return!1}),z(this,"attach",s=>(this.object=s,this.visible=!0,this)),z(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),z(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),z(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()}),z(this,"pointerHover",s=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(s,this.camera);const i=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);i?this.axis=i.object.name:this.axis=null}),z(this,"pointerDown",s=>{if(!(this.object===void 0||this.dragging===!0||s.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(s,this.camera);const i=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(i){let o=this.space;if(this.mode==="scale"?o="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(o="world"),o==="local"&&this.mode==="rotate"){const r=this.rotationSnap;this.axis==="X"&&r&&(this.object.rotation.x=Math.round(this.object.rotation.x/r)*r),this.axis==="Y"&&r&&(this.object.rotation.y=Math.round(this.object.rotation.y/r)*r),this.axis==="Z"&&r&&(this.object.rotation.z=Math.round(this.object.rotation.z/r)*r)}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(i.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),z(this,"pointerMove",s=>{const i=this.axis,o=this.mode,r=this.object;let l=this.space;if(o==="scale"?l="local":(i==="E"||i==="XYZE"||i==="XYZ")&&(l="world"),r===void 0||i===null||this.dragging===!1||s.button!==-1)return;this.raycaster.setFromCamera(s,this.camera);const f=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(f){if(this.pointEnd.copy(f.point).sub(this.worldPositionStart),o==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),l==="local"&&i!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),i.indexOf("X")===-1&&(this.offset.x=0),i.indexOf("Y")===-1&&(this.offset.y=0),i.indexOf("Z")===-1&&(this.offset.z=0),l==="local"&&i!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),r.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(l==="local"&&(r.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this.quaternionStart)),l==="world"&&(r.parent&&r.position.add(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld)),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld))));else if(o==="scale"){if(i.search("XYZ")!==-1){let d=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(d*=-1),this.tempVector2.set(d,d,d)}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),i.search("X")===-1&&(this.tempVector2.x=1),i.search("Y")===-1&&(this.tempVector2.y=1),i.search("Z")===-1&&(this.tempVector2.z=1);r.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(i.search("X")!==-1&&(this.object.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(o==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const d=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));i==="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):i==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*d):(i==="X"||i==="Y"||i==="Z")&&(this.rotationAxis.copy(this.unit[i]),this.tempVector.copy(this.unit[i]),l==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*d),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),l==="local"&&i!=="E"&&i!=="XYZE"?(r.quaternion.copy(this.quaternionStart),r.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),r.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),z(this,"pointerUp",s=>{s.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),z(this,"getPointer",s=>{var i,o;if(this.domElement&&((i=this.domElement.ownerDocument)!=null&&i.pointerLockElement))return{x:0,y:0,button:s.button};{const r=s.changedTouches?s.changedTouches[0]:s,l=(o=this.domElement)==null?void 0:o.getBoundingClientRect();return{x:(r.clientX-l.left)/l.width*2-1,y:-(r.clientY-l.top)/l.height*2+1,button:s.button}}}),z(this,"onPointerHover",s=>{if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(s));break}}),z(this,"onPointerDown",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(s)),this.pointerDown(this.getPointer(s)))}),z(this,"onPointerMove",s=>{this.enabled&&this.pointerMove(this.getPointer(s))}),z(this,"onPointerUp",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(s)))}),z(this,"getMode",()=>this.mode),z(this,"setMode",s=>{this.mode=s}),z(this,"setTranslationSnap",s=>{this.translationSnap=s}),z(this,"setRotationSnap",s=>{this.rotationSnap=s}),z(this,"setScaleSnap",s=>{this.scaleSnap=s}),z(this,"setSize",s=>{this.size=s}),z(this,"setSpace",s=>{this.space=s}),z(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),z(this,"connect",s=>{s===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=s,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),z(this,"dispose",()=>{var s,i,o,r,l,f;(s=this.domElement)==null||s.removeEventListener("pointerdown",this.onPointerDown),(i=this.domElement)==null||i.removeEventListener("pointermove",this.onPointerHover),(r=(o=this.domElement)==null?void 0:o.ownerDocument)==null||r.removeEventListener("pointermove",this.onPointerMove),(f=(l=this.domElement)==null?void 0:l.ownerDocument)==null||f.removeEventListener("pointerup",this.onPointerUp),this.traverse(d=>{const u=d;u.geometry&&u.geometry.dispose(),u.material&&u.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new Zi,this.add(this.gizmo),this.plane=new Qi,this.add(this.plane);const n=(s,i)=>{let o=i;Object.defineProperty(this,s,{get:function(){return o!==void 0?o:i},set:function(r){o!==r&&(o=r,this.plane[s]=r,this.gizmo[s]=r,this.dispatchEvent({type:s+"-changed",value:r}),this.dispatchEvent(this.changeEvent))}}),this[s]=i,this.plane[s]=i,this.gizmo[s]=i};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 Zi extends c.Object3D{constructor(){super(),z(this,"isTransformControlsGizmo",!0),z(this,"type","TransformControlsGizmo"),z(this,"tempVector",new c.Vector3(0,0,0)),z(this,"tempEuler",new c.Euler),z(this,"alignVector",new c.Vector3(0,1,0)),z(this,"zeroVector",new c.Vector3(0,0,0)),z(this,"lookAtMatrix",new c.Matrix4),z(this,"tempQuaternion",new c.Quaternion),z(this,"tempQuaternion2",new c.Quaternion),z(this,"identityQuaternion",new c.Quaternion),z(this,"unitX",new c.Vector3(1,0,0)),z(this,"unitY",new c.Vector3(0,1,0)),z(this,"unitZ",new c.Vector3(0,0,1)),z(this,"gizmo"),z(this,"picker"),z(this,"helper"),z(this,"rotationAxis",new c.Vector3),z(this,"cameraPosition",new c.Vector3),z(this,"worldPositionStart",new c.Vector3),z(this,"worldQuaternionStart",new c.Quaternion),z(this,"worldPosition",new c.Vector3),z(this,"worldQuaternion",new c.Quaternion),z(this,"eye",new c.Vector3),z(this,"camera",null),z(this,"enabled",!0),z(this,"axis",null),z(this,"mode","translate"),z(this,"space","world"),z(this,"size",1),z(this,"dragging",!1),z(this,"showX",!0),z(this,"showY",!0),z(this,"showZ",!0),z(this,"updateMatrixWorld",()=>{let se=this.space;this.mode==="scale"&&(se="local");const ce=se==="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 U=[];U=U.concat(this.picker[this.mode].children),U=U.concat(this.gizmo[this.mode].children),U=U.concat(this.helper[this.mode].children);for(let T=0;T<U.length;T++){const m=U[T];m.visible=!0,m.rotation.set(0,0,0),m.position.copy(this.worldPosition);let F;if(this.camera.isOrthographicCamera?F=(this.camera.top-this.camera.bottom)/this.camera.zoom:F=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),m.scale.set(1,1,1).multiplyScalar(F*this.size/7),m.tag==="helper"){m.visible=!1,m.name==="AXIS"?(m.position.copy(this.worldPositionStart),m.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),m.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.9&&(m.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),m.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.9&&(m.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),m.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.9&&(m.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),m.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),m.quaternion.multiply(this.tempQuaternion),m.visible=this.dragging),this.axis==="E"&&(m.visible=!1)):m.name==="START"?(m.position.copy(this.worldPositionStart),m.visible=this.dragging):m.name==="END"?(m.position.copy(this.worldPosition),m.visible=this.dragging):m.name==="DELTA"?(m.position.copy(this.worldPositionStart),m.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()),m.scale.copy(this.tempVector),m.visible=this.dragging):(m.quaternion.copy(ce),this.dragging?m.position.copy(this.worldPositionStart):m.position.copy(this.worldPosition),this.axis&&(m.visible=this.axis.search(m.name)!==-1));continue}m.quaternion.copy(ce),this.mode==="translate"||this.mode==="scale"?((m.name==="X"||m.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.99&&(m.scale.set(1e-10,1e-10,1e-10),m.visible=!1),(m.name==="Y"||m.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.99&&(m.scale.set(1e-10,1e-10,1e-10),m.visible=!1),(m.name==="Z"||m.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.99&&(m.scale.set(1e-10,1e-10,1e-10),m.visible=!1),m.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))<.2&&(m.scale.set(1e-10,1e-10,1e-10),m.visible=!1),m.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))<.2&&(m.scale.set(1e-10,1e-10,1e-10),m.visible=!1),m.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))<.2&&(m.scale.set(1e-10,1e-10,1e-10),m.visible=!1),m.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye)<0?m.tag==="fwd"?m.visible=!1:m.scale.x*=-1:m.tag==="bwd"&&(m.visible=!1)),m.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye)<0?m.tag==="fwd"?m.visible=!1:m.scale.y*=-1:m.tag==="bwd"&&(m.visible=!1)),m.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye)<0?m.tag==="fwd"?m.visible=!1:m.scale.z*=-1:m.tag==="bwd"&&(m.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ce),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ce).invert()),m.name.search("E")!==-1&&m.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),m.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),m.quaternion.copy(this.tempQuaternion)),m.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),m.quaternion.copy(this.tempQuaternion)),m.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),m.quaternion.copy(this.tempQuaternion))),m.visible=m.visible&&(m.name.indexOf("X")===-1||this.showX),m.visible=m.visible&&(m.name.indexOf("Y")===-1||this.showY),m.visible=m.visible&&(m.name.indexOf("Z")===-1||this.showZ),m.visible=m.visible&&(m.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),m.material.tempOpacity=m.material.tempOpacity||m.material.opacity,m.material.tempColor=m.material.tempColor||m.material.color.clone(),m.material.color.copy(m.material.tempColor),m.material.opacity=m.material.tempOpacity,this.enabled?this.axis&&(m.name===this.axis?(m.material.opacity=1,m.material.color.lerp(new c.Color(1,1,1),.5)):this.axis.split("").some(function(j){return m.name===j})?(m.material.opacity=1,m.material.color.lerp(new c.Color(1,1,1),.5)):(m.material.opacity*=.25,m.material.color.lerp(new c.Color(1,1,1),.5))):(m.material.opacity*=.5,m.material.color.lerp(new c.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new c.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:c.DoubleSide,fog:!1,toneMapped:!1}),t=new c.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const s=e.clone();s.opacity=.33;const i=e.clone();i.color.set(16711680);const o=e.clone();o.color.set(65280);const r=e.clone();r.color.set(255);const l=e.clone();l.opacity=.25;const f=l.clone();f.color.set(16776960);const d=l.clone();d.color.set(65535);const u=l.clone();u.color.set(16711935),e.clone().color.set(16776960);const g=t.clone();g.color.set(16711680);const x=t.clone();x.color.set(65280);const w=t.clone();w.color.set(255);const _=t.clone();_.color.set(65535);const M=t.clone();M.color.set(16711935);const L=t.clone();L.color.set(16776960);const v=t.clone();v.color.set(7895160);const y=L.clone();y.opacity=.25;const A=new c.CylinderGeometry(0,.05,.2,12,1,!1),S=new c.BoxGeometry(.125,.125,.125),b=new c.BufferGeometry;b.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3));const P=(se,ce)=>{const U=new c.BufferGeometry,T=[];for(let m=0;m<=64*ce;++m)T.push(0,Math.cos(m/32*Math.PI)*se,Math.sin(m/32*Math.PI)*se);return U.setAttribute("position",new c.Float32BufferAttribute(T,3)),U},O=()=>{const se=new c.BufferGeometry;return se.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),se},k={X:[[new c.Mesh(A,i),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new c.Mesh(A,i),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new c.Line(b,g)]],Y:[[new c.Mesh(A,o),[0,1,0],null,null,"fwd"],[new c.Mesh(A,o),[0,1,0],[Math.PI,0,0],null,"bwd"],[new c.Line(b,x),null,[0,0,Math.PI/2]]],Z:[[new c.Mesh(A,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new c.Mesh(A,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new c.Line(b,w),null,[0,-Math.PI/2,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.1,0),l.clone()),[0,0,0],[0,0,0]]],XY:[[new c.Mesh(new c.PlaneGeometry(.295,.295),f.clone()),[.15,.15,0]],[new c.Line(b,L),[.18,.3,0],null,[.125,1,1]],[new c.Line(b,L),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),d.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new c.Line(b,_),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(b,_),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),u.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new c.Line(b,M),[.18,0,.3],null,[.125,1,1]],[new c.Line(b,M),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},V={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.2,0),n)]],XY:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},R={START:[[new c.Mesh(new c.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new c.Mesh(new c.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new c.Line(O(),s),null,null,null,"helper"]],X:[[new c.Line(b,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(b,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(b,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},X={X:[[new c.Line(P(1,.5),g)],[new c.Mesh(new c.OctahedronGeometry(.04,0),i),[0,0,.99],null,[1,3,1]]],Y:[[new c.Line(P(1,.5),x),null,[0,0,-Math.PI/2]],[new c.Mesh(new c.OctahedronGeometry(.04,0),o),[0,0,.99],null,[3,1,1]]],Z:[[new c.Line(P(1,.5),w),null,[0,Math.PI/2,0]],[new c.Mesh(new c.OctahedronGeometry(.04,0),r),[.99,0,0],null,[1,3,1]]],E:[[new c.Line(P(1.25,1),y),null,[0,Math.PI/2,0]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),y),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),y),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),y),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),y),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new c.Line(P(1,1),v),null,[0,Math.PI/2,0]]]},K={AXIS:[[new c.Line(b,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},H={X:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new c.Mesh(new c.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new c.Mesh(new c.SphereGeometry(.7,10,8),n)]]},he={X:[[new c.Mesh(S,i),[.8,0,0],[0,0,-Math.PI/2]],[new c.Line(b,g),null,null,[.8,1,1]]],Y:[[new c.Mesh(S,o),[0,.8,0]],[new c.Line(b,x),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new c.Mesh(S,r),[0,0,.8],[Math.PI/2,0,0]],[new c.Line(b,w),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new c.Mesh(S,f),[.85,.85,0],null,[2,2,.2]],[new c.Line(b,L),[.855,.98,0],null,[.125,1,1]],[new c.Line(b,L),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(S,d),[0,.85,.85],null,[.2,2,2]],[new c.Line(b,_),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(b,_),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(S,u),[.85,0,.85],null,[2,.2,2]],[new c.Line(b,M),[.855,0,.98],null,[.125,1,1]],[new c.Line(b,M),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[0,0,1.1]]]},J={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new c.Mesh(S,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new c.Mesh(S,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new c.Mesh(S,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},G={X:[[new c.Line(b,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(b,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(b,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},oe=se=>{const ce=new c.Object3D;for(let U in se)for(let T=se[U].length;T--;){const m=se[U][T][0].clone(),F=se[U][T][1],j=se[U][T][2],D=se[U][T][3],E=se[U][T][4];m.name=U,m.tag=E,F&&m.position.set(F[0],F[1],F[2]),j&&m.rotation.set(j[0],j[1],j[2]),D&&m.scale.set(D[0],D[1],D[2]),m.updateMatrix();const ie=m.geometry.clone();ie.applyMatrix4(m.matrix),m.geometry=ie,m.renderOrder=1/0,m.position.set(0,0,0),m.rotation.set(0,0,0),m.scale.set(1,1,1),ce.add(m)}return ce};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=oe(k)),this.add(this.gizmo.rotate=oe(X)),this.add(this.gizmo.scale=oe(he)),this.add(this.picker.translate=oe(V)),this.add(this.picker.rotate=oe(H)),this.add(this.picker.scale=oe(J)),this.add(this.helper.translate=oe(R)),this.add(this.helper.rotate=oe(K)),this.add(this.helper.scale=oe(G)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class Qi extends c.Mesh{constructor(){super(new c.PlaneGeometry(1e5,1e5,2,2),new c.MeshBasicMaterial({visible:!1,wireframe:!0,side:c.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),z(this,"isTransformControlsPlane",!0),z(this,"type","TransformControlsPlane"),z(this,"unitX",new c.Vector3(1,0,0)),z(this,"unitY",new c.Vector3(0,1,0)),z(this,"unitZ",new c.Vector3(0,0,1)),z(this,"tempVector",new c.Vector3),z(this,"dirVector",new c.Vector3),z(this,"alignVector",new c.Vector3),z(this,"tempMatrix",new c.Matrix4),z(this,"identityQuaternion",new c.Quaternion),z(this,"cameraQuaternion",new c.Quaternion),z(this,"worldPosition",new c.Vector3),z(this,"worldQuaternion",new c.Quaternion),z(this,"eye",new c.Vector3),z(this,"axis",null),z(this,"mode","translate"),z(this,"space","world"),z(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 Ki=Object.defineProperty,qi=(a,e,t)=>e in a?Ki(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ce=(a,e,t)=>(qi(a,typeof e!="symbol"?e+"":e,t),t);const _t=new c.Euler(0,0,0,"YXZ"),vt=new c.Vector3,Ji={type:"change"},Hi={type:"lock"},$i={type:"unlock"},ls=Math.PI/2;class vn extends c.EventDispatcher{constructor(e,t){super(),Ce(this,"camera"),Ce(this,"domElement"),Ce(this,"isLocked"),Ce(this,"minPolarAngle"),Ce(this,"maxPolarAngle"),Ce(this,"pointerSpeed"),Ce(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const s=n.movementX||n.mozMovementX||n.webkitMovementX||0,i=n.movementY||n.mozMovementY||n.webkitMovementY||0;_t.setFromQuaternion(this.camera.quaternion),_t.y-=s*.002*this.pointerSpeed,_t.x-=i*.002*this.pointerSpeed,_t.x=Math.max(ls-this.maxPolarAngle,Math.min(ls-this.minPolarAngle,_t.x)),this.camera.quaternion.setFromEuler(_t),this.dispatchEvent(Ji)}),Ce(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(Hi),this.isLocked=!0):(this.dispatchEvent($i),this.isLocked=!1))}),Ce(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),Ce(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))}),Ce(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))}),Ce(this,"dispose",()=>{this.disconnect()}),Ce(this,"getObject",()=>this.camera),Ce(this,"direction",new c.Vector3(0,0,-1)),Ce(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),Ce(this,"moveForward",n=>{vt.setFromMatrixColumn(this.camera.matrix,0),vt.crossVectors(this.camera.up,vt),this.camera.position.addScaledVector(vt,n)}),Ce(this,"moveRight",n=>{vt.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(vt,n)}),Ce(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),Ce(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 eo=Object.defineProperty,to=(a,e,t)=>e in a?eo(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ae=(a,e,t)=>(to(a,typeof e!="symbol"?e+"":e,t),t);const Yt=new c.Ray,cs=new c.Plane,no=Math.cos(70*(Math.PI/180)),hs=(a,e)=>(a%e+e)%e;class us extends c.EventDispatcher{constructor(e,t){super(),ae(this,"object"),ae(this,"domElement"),ae(this,"enabled",!0),ae(this,"target",new c.Vector3),ae(this,"minDistance",0),ae(this,"maxDistance",1/0),ae(this,"minZoom",0),ae(this,"maxZoom",1/0),ae(this,"minPolarAngle",0),ae(this,"maxPolarAngle",Math.PI),ae(this,"minAzimuthAngle",-1/0),ae(this,"maxAzimuthAngle",1/0),ae(this,"enableDamping",!1),ae(this,"dampingFactor",.05),ae(this,"enableZoom",!0),ae(this,"zoomSpeed",1),ae(this,"enableRotate",!0),ae(this,"rotateSpeed",1),ae(this,"enablePan",!0),ae(this,"panSpeed",1),ae(this,"screenSpacePanning",!0),ae(this,"keyPanSpeed",7),ae(this,"zoomToCursor",!1),ae(this,"autoRotate",!1),ae(this,"autoRotateSpeed",2),ae(this,"reverseOrbit",!1),ae(this,"reverseHorizontalOrbit",!1),ae(this,"reverseVerticalOrbit",!1),ae(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),ae(this,"mouseButtons",{LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN}),ae(this,"touches",{ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN}),ae(this,"target0"),ae(this,"position0"),ae(this,"zoom0"),ae(this,"_domElementKeyEvents",null),ae(this,"getPolarAngle"),ae(this,"getAzimuthalAngle"),ae(this,"setPolarAngle"),ae(this,"setAzimuthalAngle"),ae(this,"getDistance"),ae(this,"listenToKeyEvents"),ae(this,"stopListenToKeyEvents"),ae(this,"saveState"),ae(this,"reset"),ae(this,"update"),ae(this,"connect"),ae(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>d.phi,this.getAzimuthalAngle=()=>d.theta,this.setPolarAngle=B=>{let W=hs(B,2*Math.PI),ue=d.phi;ue<0&&(ue+=2*Math.PI),W<0&&(W+=2*Math.PI);let _e=Math.abs(W-ue);2*Math.PI-_e<_e&&(W<ue?W+=2*Math.PI:ue+=2*Math.PI),u.phi=W-ue,n.update()},this.setAzimuthalAngle=B=>{let W=hs(B,2*Math.PI),ue=d.theta;ue<0&&(ue+=2*Math.PI),W<0&&(W+=2*Math.PI);let _e=Math.abs(W-ue);2*Math.PI-_e<_e&&(W<ue?W+=2*Math.PI:ue+=2*Math.PI),u.theta=W-ue,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=B=>{B.addEventListener("keydown",Ct),this._domElementKeyEvents=B},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Ct),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(s),n.update(),l=r.NONE},this.update=(()=>{const B=new c.Vector3,W=new c.Vector3(0,1,0),ue=new c.Quaternion().setFromUnitVectors(e.up,W),_e=ue.clone().invert(),Le=new c.Vector3,$e=new c.Quaternion,ct=2*Math.PI;return function(){const Ci=n.object.position;ue.setFromUnitVectors(e.up,W),_e.copy(ue).invert(),B.copy(Ci).sub(n.target),B.applyQuaternion(ue),d.setFromVector3(B),n.autoRotate&&l===r.NONE&&K(R()),n.enableDamping?(d.theta+=u.theta*n.dampingFactor,d.phi+=u.phi*n.dampingFactor):(d.theta+=u.theta,d.phi+=u.phi);let et=n.minAzimuthAngle,tt=n.maxAzimuthAngle;isFinite(et)&&isFinite(tt)&&(et<-Math.PI?et+=ct:et>Math.PI&&(et-=ct),tt<-Math.PI?tt+=ct:tt>Math.PI&&(tt-=ct),et<=tt?d.theta=Math.max(et,Math.min(tt,d.theta)):d.theta=d.theta>(et+tt)/2?Math.max(et,d.theta):Math.min(tt,d.theta)),d.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,d.phi)),d.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(g,n.dampingFactor):n.target.add(g),n.zoomToCursor&&O||n.object.isOrthographicCamera?d.radius=U(d.radius):d.radius=U(d.radius*p),B.setFromSpherical(d),B.applyQuaternion(_e),Ci.copy(n.target).add(B),n.object.lookAt(n.target),n.enableDamping===!0?(u.theta*=1-n.dampingFactor,u.phi*=1-n.dampingFactor,g.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),g.set(0,0,0));let dn=!1;if(n.zoomToCursor&&O){let Et=null;if(n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera){const Xt=B.length();Et=U(Xt*p);const fn=Xt-Et;n.object.position.addScaledVector(b,fn),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Xt=new c.Vector3(P.x,P.y,0);Xt.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix(),dn=!0;const fn=new c.Vector3(P.x,P.y,0);fn.unproject(n.object),n.object.position.sub(fn).add(Xt),n.object.updateMatrixWorld(),Et=B.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;Et!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(Et).add(n.object.position):(Yt.origin.copy(n.object.position),Yt.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(Yt.direction))<no?e.lookAt(n.target):(cs.setFromNormalAndCoplanarPoint(n.object.up,n.target),Yt.intersectPlane(cs,n.target))))}else n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix(),dn=!0);return p=1,O=!1,dn||Le.distanceToSquared(n.object.position)>f||8*(1-$e.dot(n.object.quaternion))>f?(n.dispatchEvent(s),Le.copy(n.object.position),$e.copy(n.object.quaternion),dn=!1,!0):!1}})(),this.connect=B=>{B===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=B,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Mi),n.domElement.addEventListener("pointerdown",Pe),n.domElement.addEventListener("pointercancel",Pt),n.domElement.addEventListener("wheel",un)},this.dispose=()=>{var B,W,ue,_e,Le,$e;(B=n.domElement)==null||B.removeEventListener("contextmenu",Mi),(W=n.domElement)==null||W.removeEventListener("pointerdown",Pe),(ue=n.domElement)==null||ue.removeEventListener("pointercancel",Pt),(_e=n.domElement)==null||_e.removeEventListener("wheel",un),(Le=n.domElement)==null||Le.ownerDocument.removeEventListener("pointermove",ke),($e=n.domElement)==null||$e.ownerDocument.removeEventListener("pointerup",Xe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Ct)};const n=this,s={type:"change"},i={type:"start"},o={type:"end"},r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=r.NONE;const f=1e-6,d=new c.Spherical,u=new c.Spherical;let p=1;const g=new c.Vector3,x=new c.Vector2,w=new c.Vector2,_=new c.Vector2,M=new c.Vector2,L=new c.Vector2,v=new c.Vector2,y=new c.Vector2,A=new c.Vector2,S=new c.Vector2,b=new c.Vector3,P=new c.Vector2;let O=!1;const k=[],V={};function R(){return 2*Math.PI/60/60*n.autoRotateSpeed}function X(){return Math.pow(.95,n.zoomSpeed)}function K(B){n.reverseOrbit||n.reverseHorizontalOrbit?u.theta+=B:u.theta-=B}function H(B){n.reverseOrbit||n.reverseVerticalOrbit?u.phi+=B:u.phi-=B}const he=(()=>{const B=new c.Vector3;return function(ue,_e){B.setFromMatrixColumn(_e,0),B.multiplyScalar(-ue),g.add(B)}})(),J=(()=>{const B=new c.Vector3;return function(ue,_e){n.screenSpacePanning===!0?B.setFromMatrixColumn(_e,1):(B.setFromMatrixColumn(_e,0),B.crossVectors(n.object.up,B)),B.multiplyScalar(ue),g.add(B)}})(),G=(()=>{const B=new c.Vector3;return function(ue,_e){const Le=n.domElement;if(Le&&n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera){const $e=n.object.position;B.copy($e).sub(n.target);let ct=B.length();ct*=Math.tan(n.object.fov/2*Math.PI/180),he(2*ue*ct/Le.clientHeight,n.object.matrix),J(2*_e*ct/Le.clientHeight,n.object.matrix)}else Le&&n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?(he(ue*(n.object.right-n.object.left)/n.object.zoom/Le.clientWidth,n.object.matrix),J(_e*(n.object.top-n.object.bottom)/n.object.zoom/Le.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function oe(B){n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?p/=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function se(B){n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?p*=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ce(B){if(!n.zoomToCursor||!n.domElement)return;O=!0;const W=n.domElement.getBoundingClientRect(),ue=B.clientX-W.left,_e=B.clientY-W.top,Le=W.width,$e=W.height;P.x=ue/Le*2-1,P.y=-(_e/$e)*2+1,b.set(P.x,P.y,1).unproject(n.object).sub(n.object.position).normalize()}function U(B){return Math.max(n.minDistance,Math.min(n.maxDistance,B))}function T(B){x.set(B.clientX,B.clientY)}function m(B){ce(B),y.set(B.clientX,B.clientY)}function F(B){M.set(B.clientX,B.clientY)}function j(B){w.set(B.clientX,B.clientY),_.subVectors(w,x).multiplyScalar(n.rotateSpeed);const W=n.domElement;W&&(K(2*Math.PI*_.x/W.clientHeight),H(2*Math.PI*_.y/W.clientHeight)),x.copy(w),n.update()}function D(B){A.set(B.clientX,B.clientY),S.subVectors(A,y),S.y>0?oe(X()):S.y<0&&se(X()),y.copy(A),n.update()}function E(B){L.set(B.clientX,B.clientY),v.subVectors(L,M).multiplyScalar(n.panSpeed),G(v.x,v.y),M.copy(L),n.update()}function ie(B){ce(B),B.deltaY<0?se(X()):B.deltaY>0&&oe(X()),n.update()}function Y(B){let W=!1;switch(B.code){case n.keys.UP:G(0,n.keyPanSpeed),W=!0;break;case n.keys.BOTTOM:G(0,-n.keyPanSpeed),W=!0;break;case n.keys.LEFT:G(n.keyPanSpeed,0),W=!0;break;case n.keys.RIGHT:G(-n.keyPanSpeed,0),W=!0;break}W&&(B.preventDefault(),n.update())}function $(){if(k.length==1)x.set(k[0].pageX,k[0].pageY);else{const B=.5*(k[0].pageX+k[1].pageX),W=.5*(k[0].pageY+k[1].pageY);x.set(B,W)}}function Z(){if(k.length==1)M.set(k[0].pageX,k[0].pageY);else{const B=.5*(k[0].pageX+k[1].pageX),W=.5*(k[0].pageY+k[1].pageY);M.set(B,W)}}function fe(){const B=k[0].pageX-k[1].pageX,W=k[0].pageY-k[1].pageY,ue=Math.sqrt(B*B+W*W);y.set(0,ue)}function Q(){n.enableZoom&&fe(),n.enablePan&&Z()}function ee(){n.enableZoom&&fe(),n.enableRotate&&$()}function I(B){if(k.length==1)w.set(B.pageX,B.pageY);else{const ue=es(B),_e=.5*(B.pageX+ue.x),Le=.5*(B.pageY+ue.y);w.set(_e,Le)}_.subVectors(w,x).multiplyScalar(n.rotateSpeed);const W=n.domElement;W&&(K(2*Math.PI*_.x/W.clientHeight),H(2*Math.PI*_.y/W.clientHeight)),x.copy(w)}function C(B){if(k.length==1)L.set(B.pageX,B.pageY);else{const W=es(B),ue=.5*(B.pageX+W.x),_e=.5*(B.pageY+W.y);L.set(ue,_e)}v.subVectors(L,M).multiplyScalar(n.panSpeed),G(v.x,v.y),M.copy(L)}function te(B){const W=es(B),ue=B.pageX-W.x,_e=B.pageY-W.y,Le=Math.sqrt(ue*ue+_e*_e);A.set(0,Le),S.set(0,Math.pow(A.y/y.y,n.zoomSpeed)),oe(S.y),y.copy(A)}function pe(B){n.enableZoom&&te(B),n.enablePan&&C(B)}function we(B){n.enableZoom&&te(B),n.enableRotate&&I(B)}function Pe(B){var W,ue;n.enabled!==!1&&(k.length===0&&((W=n.domElement)==null||W.ownerDocument.addEventListener("pointermove",ke),(ue=n.domElement)==null||ue.ownerDocument.addEventListener("pointerup",Xe)),Ic(B),B.pointerType==="touch"?Oc(B):jt(B))}function ke(B){n.enabled!==!1&&(B.pointerType==="touch"?Dc(B):Ge(B))}function Xe(B){var W,ue,_e;Si(B),k.length===0&&((W=n.domElement)==null||W.releasePointerCapture(B.pointerId),(ue=n.domElement)==null||ue.ownerDocument.removeEventListener("pointermove",ke),(_e=n.domElement)==null||_e.ownerDocument.removeEventListener("pointerup",Xe)),n.dispatchEvent(o),l=r.NONE}function Pt(B){Si(B)}function jt(B){let W;switch(B.button){case 0:W=n.mouseButtons.LEFT;break;case 1:W=n.mouseButtons.MIDDLE;break;case 2:W=n.mouseButtons.RIGHT;break;default:W=-1}switch(W){case c.MOUSE.DOLLY:if(n.enableZoom===!1)return;m(B),l=r.DOLLY;break;case c.MOUSE.ROTATE:if(B.ctrlKey||B.metaKey||B.shiftKey){if(n.enablePan===!1)return;F(B),l=r.PAN}else{if(n.enableRotate===!1)return;T(B),l=r.ROTATE}break;case c.MOUSE.PAN:if(B.ctrlKey||B.metaKey||B.shiftKey){if(n.enableRotate===!1)return;T(B),l=r.ROTATE}else{if(n.enablePan===!1)return;F(B),l=r.PAN}break;default:l=r.NONE}l!==r.NONE&&n.dispatchEvent(i)}function Ge(B){if(n.enabled!==!1)switch(l){case r.ROTATE:if(n.enableRotate===!1)return;j(B);break;case r.DOLLY:if(n.enableZoom===!1)return;D(B);break;case r.PAN:if(n.enablePan===!1)return;E(B);break}}function un(B){n.enabled===!1||n.enableZoom===!1||l!==r.NONE&&l!==r.ROTATE||(B.preventDefault(),n.dispatchEvent(i),ie(B),n.dispatchEvent(o))}function Ct(B){n.enabled===!1||n.enablePan===!1||Y(B)}function Oc(B){switch(Pi(B),k.length){case 1:switch(n.touches.ONE){case c.TOUCH.ROTATE:if(n.enableRotate===!1)return;$(),l=r.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(n.enablePan===!1)return;Z(),l=r.TOUCH_PAN;break;default:l=r.NONE}break;case 2:switch(n.touches.TWO){case c.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Q(),l=r.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ee(),l=r.TOUCH_DOLLY_ROTATE;break;default:l=r.NONE}break;default:l=r.NONE}l!==r.NONE&&n.dispatchEvent(i)}function Dc(B){switch(Pi(B),l){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;I(B),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;C(B),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;pe(B),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;we(B),n.update();break;default:l=r.NONE}}function Mi(B){n.enabled!==!1&&B.preventDefault()}function Ic(B){k.push(B)}function Si(B){delete V[B.pointerId];for(let W=0;W<k.length;W++)if(k[W].pointerId==B.pointerId){k.splice(W,1);return}}function Pi(B){let W=V[B.pointerId];W===void 0&&(W=new c.Vector2,V[B.pointerId]=W),W.set(B.pageX,B.pageY)}function es(B){const W=B.pointerId===k[0].pointerId?k[1]:k[0];return V[W.pointerId]}t!==void 0&&this.connect(t),this.update()}}class so extends us{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=c.MOUSE.PAN,this.mouseButtons.RIGHT=c.MOUSE.ROTATE,this.touches.ONE=c.TOUCH.PAN,this.touches.TWO=c.TOUCH.DOLLY_ROTATE}}class io extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new co(t)}),this.register(function(t){return new _o(t)}),this.register(function(t){return new vo(t)}),this.register(function(t){return new xo(t)}),this.register(function(t){return new uo(t)}),this.register(function(t){return new fo(t)}),this.register(function(t){return new po(t)}),this.register(function(t){return new mo(t)}),this.register(function(t){return new lo(t)}),this.register(function(t){return new go(t)}),this.register(function(t){return new ho(t)}),this.register(function(t){return new yo(t)}),this.register(function(t){return new ro(t)}),this.register(function(t){return new wo(t)}),this.register(function(t){return new bo(t)})}load(e,t,n,s){const i=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=c.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const r=function(f){s?s(f):console.error(f),i.manager.itemError(e),i.manager.itemEnd(e)},l=new c.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(f){try{i.parse(f,o,function(d){t(d),i.manager.itemEnd(e)},r)}catch(d){r(d)}},n,r)}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,s){let i;const o={},r={};if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===ds){try{o[ge.KHR_BINARY_GLTF]=new Ao(e)}catch(d){s&&s(d);return}i=JSON.parse(o[ge.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.LoaderUtils.decodeText(new Uint8Array(e)));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Uo(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const d=this.pluginCallbacks[f](l);r[d.name]=d,o[d.name]=!0}if(i.extensionsUsed)for(let f=0;f<i.extensionsUsed.length;++f){const d=i.extensionsUsed[f],u=i.extensionsRequired||[];switch(d){case ge.KHR_MATERIALS_UNLIT:o[d]=new ao;break;case ge.KHR_DRACO_MESH_COMPRESSION:o[d]=new Mo(i,this.dracoLoader);break;case ge.KHR_TEXTURE_TRANSFORM:o[d]=new So;break;case ge.KHR_MESH_QUANTIZATION:o[d]=new Po;break;default:u.indexOf(d)>=0&&r[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(o),l.setPlugins(r),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function oo(){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 ge={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_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_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 ro{constructor(e){this.parser=e,this.name=ge.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,l=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let f;const d=new c.Color(16777215);l.color!==void 0&&d.fromArray(l.color);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":f=new c.DirectionalLight(d),f.target.position.set(0,0,-1),f.add(f.target);break;case"point":f=new c.PointLight(d),f.distance=u;break;case"spot":f=new c.SpotLight(d),f.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,f.angle=l.spot.outerConeAngle,f.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,f.target.position.set(0,0,-1),f.add(f.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return f.position.set(0,0,0),f.decay=2,ot(f,l),l.intensity!==void 0&&(f.intensity=l.intensity),f.name=t.createUniqueName(l.name||"light_"+e),s=Promise.resolve(f),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(l){return n._getNodeRef(t.cache,r,l)})}}class ao{constructor(){this.name=ge.KHR_MATERIALS_UNLIT}getMaterialType(){return c.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new c.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.fromArray(o),e.opacity=o[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,3001))}return Promise.all(s)}}class lo{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class co{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const r=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new c.Vector2(r,r)}return Promise.all(i)}}class ho{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class uo{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=s.extensions[this.name];return o.sheenColorFactor!==void 0&&t.sheenColor.fromArray(o.sheenColorFactor),o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,3001)),o.sheenRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class fo{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class po{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const r=o.attenuationColor||[1,1,1];return t.attenuationColor=new c.Color(r[0],r[1],r[2]),Promise.all(i)}}class mo{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class go{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const r=o.specularColorFactor||[1,1,1];return t.specularColor=new c.Color(r[0],r[1],r[2]),o.specularColorTexture!==void 0&&i.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,3001)),Promise.all(i)}}class yo{constructor(e){this.parser=e,this.name=ge.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class _o{constructor(e){this.parser=e,this.name=ge.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class vo{constructor(e){this.parser=e,this.name=ge.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=s.images[o.source];let l=n.textureLoader;if(r.uri){const f=n.options.manager.getHandler(r.uri);f!==null&&(l=f)}return this.detectSupport().then(function(f){if(f)return n.loadTextureImage(e,o.source,l);if(s.extensionsRequired&&s.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 xo{constructor(e){this.parser=e,this.name=ge.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=s.images[o.source];let l=n.textureLoader;if(r.uri){const f=n.options.manager.getHandler(r.uri);f!==null&&(l=f)}return this.detectSupport().then(function(f){if(f)return n.loadTextureImage(e,o.source,l);if(s.extensionsRequired&&s.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 wo{constructor(e){this.name=ge.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 s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(r){const l=s.byteOffset||0,f=s.byteLength||0,d=s.count,u=s.byteStride,p=new Uint8Array(r,l,f);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,u,p,s.mode,s.filter).then(function(g){return g.buffer}):o.ready.then(function(){const g=new ArrayBuffer(d*u);return o.decodeGltfBuffer(new Uint8Array(g),d,u,p,s.mode,s.filter),g})})}else return null}}class bo{constructor(e){this.name=ge.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 s=t.meshes[n.mesh];for(const f of s.primitives)if(f.mode!==Ve.TRIANGLES&&f.mode!==Ve.TRIANGLE_STRIP&&f.mode!==Ve.TRIANGLE_FAN&&f.mode!==void 0)return null;const o=n.extensions[this.name].attributes,r=[],l={};for(const f in o)r.push(this.parser.getDependency("accessor",o[f]).then(d=>(l[f]=d,l[f])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(f=>{const d=f.pop(),u=d.isGroup?d.children:[d],p=f[0].count,g=[];for(const x of u){const w=new c.Matrix4,_=new c.Vector3,M=new c.Quaternion,L=new c.Vector3(1,1,1),v=new c.InstancedMesh(x.geometry,x.material,p);for(let y=0;y<p;y++)l.TRANSLATION&&_.fromBufferAttribute(l.TRANSLATION,y),l.ROTATION&&M.fromBufferAttribute(l.ROTATION,y),l.SCALE&&L.fromBufferAttribute(l.SCALE,y),v.setMatrixAt(y,w.compose(_,M,L));for(const y in l)y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&x.geometry.setAttribute(y,l[y]);c.Object3D.prototype.copy.call(v,x),this.parser.assignFinalMaterial(v),g.push(v)}return d.isGroup?(d.clear(),d.add(...g),d):g[0]}))}}const ds="glTF",Ot=12,fs={JSON:1313821514,BIN:5130562};class Ao{constructor(e){this.name=ge.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ot);if(this.header={magic:c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ds)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-Ot,s=new DataView(e,Ot);let i=0;for(;i<n;){const o=s.getUint32(i,!0);i+=4;const r=s.getUint32(i,!0);if(i+=4,r===fs.JSON){const l=new Uint8Array(e,Ot+i,o);this.content=c.LoaderUtils.decodeText(l)}else if(r===fs.BIN){const l=Ot+i;this.body=e.slice(l,l+o)}i+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Mo{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ge.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,r={},l={},f={};for(const d in o){const u=wn[d]||d.toLowerCase();r[u]=o[d]}for(const d in e.attributes){const u=wn[d]||d.toLowerCase();if(o[d]!==void 0){const p=n.accessors[e.attributes[d]],g=xt[p.componentType];f[u]=g.name,l[u]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(d){return new Promise(function(u){s.decodeDracoFile(d,function(p){for(const g in p.attributes){const x=p.attributes[g],w=l[g];w!==void 0&&(x.normalized=w)}u(p)},r,f)})})}}class So{constructor(){this.name=ge.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 Po{constructor(){this.name=ge.KHR_MESH_QUANTIZATION}}class ps extends c.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[i+o];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,o=this.sampleValues,r=this.valueSize,l=r*2,f=r*3,d=s-t,u=(n-t)/d,p=u*u,g=p*u,x=e*f,w=x-f,_=-2*g+3*p,M=g-p,L=1-_,v=M-p+u;for(let y=0;y!==r;y++){const A=o[w+y+r],S=o[w+y+l]*d,b=o[x+y+r],P=o[x+y]*d;i[y]=L*A+v*S+_*b+M*P}return i}}const Co=new c.Quaternion;class Lo extends ps{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return Co.fromArray(i).normalize().toArray(i),i}}const Ve={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},xt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ms={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},gs={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},xn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},wn={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Ti>=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"},it={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},To={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},bn={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Oo(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),a.DefaultMaterial}function ht(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 ot(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 Do(a,e,t){let n=!1,s=!1,i=!1;for(let f=0,d=e.length;f<d;f++){const u=e[f];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(a);const o=[],r=[],l=[];for(let f=0,d=e.length;f<d;f++){const u=e[f];if(n){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):a.attributes.position;o.push(p)}if(s){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):a.attributes.normal;r.push(p)}if(i){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):a.attributes.color;l.push(p)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(l)]).then(function(f){const d=f[0],u=f[1],p=f[2];return n&&(a.morphAttributes.position=d),s&&(a.morphAttributes.normal=u),i&&(a.morphAttributes.color=p),a.morphTargetsRelative=!0,a})}function Io(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,s=t.length;n<s;n++)a.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ko(a){let e;const t=a.extensions&&a.extensions[ge.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+An(t.attributes):e=a.indices+":"+An(a.attributes)+":"+a.mode,a.targets!==void 0)for(let n=0,s=a.targets.length;n<s;n++)e+=":"+An(a.targets[n]);return e}function An(a){let e="";const t=Object.keys(a).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+a[t[n]]+";";return e}function Mn(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 Fo(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 Bo=new c.Matrix4;class Uo{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new oo,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,s=!1,i=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,i=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||s&&i<98?this.textureLoader=new c.TextureLoader(this.options.manager):this.textureLoader=new c.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.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,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const r={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};ht(i,r,s),ot(r,s),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(r)})).then(function(){e(r)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const o=t[s].joints;for(let r=0,l=o.length;r<l;r++)e[o[r]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(o,r)=>{const l=this.associations.get(o);l!=null&&this.associations.set(r,l);for(const[f,d]of o.children.entries())i(d,r.children[f])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ge.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(i,o){n.load(c.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=xn[s.type],r=xt[s.componentType],l=s.normalized===!0,f=new r(s.count*o);return Promise.resolve(new c.BufferAttribute(f,o,l))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(o){const r=o[0],l=xn[s.type],f=xt[s.componentType],d=f.BYTES_PER_ELEMENT,u=d*l,p=s.byteOffset||0,g=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,x=s.normalized===!0;let w,_;if(g&&g!==u){const M=Math.floor(p/g),L="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+M+":"+s.count;let v=t.cache.get(L);v||(w=new f(r,M*g,s.count*g/d),v=new c.InterleavedBuffer(w,g/d),t.cache.add(L,v)),_=new c.InterleavedBufferAttribute(v,l,p%g/d,x)}else r===null?w=new f(s.count*l):w=new f(r,p,s.count*l),_=new c.BufferAttribute(w,l,x);if(s.sparse!==void 0){const M=xn.SCALAR,L=xt[s.sparse.indices.componentType],v=s.sparse.indices.byteOffset||0,y=s.sparse.values.byteOffset||0,A=new L(o[1],v,s.sparse.count*M),S=new f(o[2],y,s.sparse.count*l);r!==null&&(_=new c.BufferAttribute(_.array.slice(),_.itemSize,_.normalized));for(let b=0,P=A.length;b<P;b++){const O=A[b];if(_.setX(O,S[b*l]),l>=2&&_.setY(O,S[b*l+1]),l>=3&&_.setZ(O,S[b*l+2]),l>=4&&_.setW(O,S[b*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,o=t.images[i];let r=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(r=l)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,n){const s=this,i=this.json,o=i.textures[e],r=i.images[t],l=(r.uri||r.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const f=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=o.name||r.name||"",d.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(d.name=r.uri);const p=(i.samplers||{})[o.sampler]||{};return d.magFilter=ms[p.magFilter]||c.LinearFilter,d.minFilter=ms[p.minFilter]||c.LinearMipmapLinearFilter,d.wrapS=gs[p.wrapS]||c.RepeatWrapping,d.wrapT=gs[p.wrapT]||c.RepeatWrapping,s.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[l]=f,f}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=s.images[e],r=self.URL||self.webkitURL;let l=o.uri||"",f=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(u){f=!0;const p=new Blob([u],{type:o.mimeType});return l=r.createObjectURL(p),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(l).then(function(u){return new Promise(function(p,g){let x=p;t.isImageBitmapLoader===!0&&(x=function(w){const _=new c.Texture(w);_.needsUpdate=!0,p(_)}),t.load(c.LoaderUtils.resolveURL(u,i.path),x,void 0,g)})}).then(function(u){return f===!0&&r.revokeObjectURL(l),u.userData.mimeType=o.mimeType||Fo(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=d,d}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),i.extensions[ge.KHR_TEXTURE_TRANSFORM]){const r=n.extensions!==void 0?n.extensions[ge.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const l=i.associations.get(o);o=i.extensions[ge.KHR_TEXTURE_TRANSFORM].extendTexture(o,r),i.associations.set(o,l)}}return s!==void 0&&("colorSpace"in o?o.colorSpace=s===3001?"srgb":"srgb-linear":o.encoding=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+n.uuid;let l=this.cache.get(r);l||(l=new c.PointsMaterial,c.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(r,l)),n=l}else if(e.isLine){const r="LineBasicMaterial:"+n.uuid;let l=this.cache.get(r);l||(l=new c.LineBasicMaterial,c.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(r,l)),n=l}if(s||i||o){let r="ClonedMaterial:"+n.uuid+":";s&&(r+="derivative-tangents:"),i&&(r+="vertex-colors:"),o&&(r+="flat-shading:");let l=this.cache.get(r);l||(l=n.clone(),i&&(l.vertexColors=!0),o&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(r,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let o;const r={},l=i.extensions||{},f=[];if(l[ge.KHR_MATERIALS_UNLIT]){const u=s[ge.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),f.push(u.extendParams(r,i,t))}else{const u=i.pbrMetallicRoughness||{};if(r.color=new c.Color(1,1,1),r.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;r.color.fromArray(p),r.opacity=p[3]}u.baseColorTexture!==void 0&&f.push(t.assignTexture(r,"map",u.baseColorTexture,3001)),r.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,r.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(f.push(t.assignTexture(r,"metalnessMap",u.metallicRoughnessTexture)),f.push(t.assignTexture(r,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),f.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,r)})))}i.doubleSided===!0&&(r.side=c.DoubleSide);const d=i.alphaMode||bn.OPAQUE;if(d===bn.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===bn.MASK&&(r.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==c.MeshBasicMaterial&&(f.push(t.assignTexture(r,"normalMap",i.normalTexture)),r.normalScale=new c.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;r.normalScale.set(u,u)}return i.occlusionTexture!==void 0&&o!==c.MeshBasicMaterial&&(f.push(t.assignTexture(r,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==c.MeshBasicMaterial&&(r.emissive=new c.Color().fromArray(i.emissiveFactor)),i.emissiveTexture!==void 0&&o!==c.MeshBasicMaterial&&f.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture,3001)),Promise.all(f).then(function(){const u=new o(r);return i.name&&(u.name=i.name),ot(u,i),t.associations.set(u,{materials:e}),i.extensions&&ht(s,u,i),u})}createUniqueName(e){const t=c.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,s=this.primitiveCache;function i(r){return n[ge.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(l){return ys(l,r,t)})}const o=[];for(let r=0,l=e.length;r<l;r++){const f=e[r],d=ko(f),u=s[d];if(u)o.push(u.promise);else{let p;f.extensions&&f.extensions[ge.KHR_DRACO_MESH_COMPRESSION]?p=i(f):p=ys(new c.BufferGeometry,f,t),s[d]={primitive:f,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],o=i.primitives,r=[];for(let l=0,f=o.length;l<f;l++){const d=o[l].material===void 0?Oo(this.cache):this.getDependency("material",o[l].material);r.push(d)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(l){const f=l.slice(0,l.length-1),d=l[l.length-1],u=[];for(let g=0,x=d.length;g<x;g++){const w=d[g],_=o[g];let M;const L=f[g];if(_.mode===Ve.TRIANGLES||_.mode===Ve.TRIANGLE_STRIP||_.mode===Ve.TRIANGLE_FAN||_.mode===void 0)M=i.isSkinnedMesh===!0?new c.SkinnedMesh(w,L):new c.Mesh(w,L),M.isSkinnedMesh===!0&&M.normalizeSkinWeights(),_.mode===Ve.TRIANGLE_STRIP?M.geometry=ts(M.geometry,c.TriangleStripDrawMode):_.mode===Ve.TRIANGLE_FAN&&(M.geometry=ts(M.geometry,c.TriangleFanDrawMode));else if(_.mode===Ve.LINES)M=new c.LineSegments(w,L);else if(_.mode===Ve.LINE_STRIP)M=new c.Line(w,L);else if(_.mode===Ve.LINE_LOOP)M=new c.LineLoop(w,L);else if(_.mode===Ve.POINTS)M=new c.Points(w,L);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(M.geometry.morphAttributes).length>0&&Io(M,i),M.name=t.createUniqueName(i.name||"mesh_"+e),ot(M,i),_.extensions&&ht(s,M,_),t.assignFinalMaterial(M),u.push(M)}for(let g=0,x=u.length;g<x;g++)t.associations.set(u[g],{meshes:e,primitives:g});if(u.length===1)return i.extensions&&ht(s,u[0],i),u[0];const p=new c.Group;i.extensions&&ht(s,p,i),t.associations.set(p,{meshes:e});for(let g=0,x=u.length;g<x;g++)p.add(u[g]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new c.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ot(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),o=s,r=[],l=[];for(let f=0,d=o.length;f<d;f++){const u=o[f];if(u){r.push(u);const p=new c.Matrix4;i!==null&&p.fromArray(i.array,f*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[f])}return new c.Skeleton(r,l)})}loadAnimation(e){const n=this.json.animations[e],s=n.name?n.name:"animation_"+e,i=[],o=[],r=[],l=[],f=[];for(let d=0,u=n.channels.length;d<u;d++){const p=n.channels[d],g=n.samplers[p.sampler],x=p.target,w=x.node,_=n.parameters!==void 0?n.parameters[g.input]:g.input,M=n.parameters!==void 0?n.parameters[g.output]:g.output;x.node!==void 0&&(i.push(this.getDependency("node",w)),o.push(this.getDependency("accessor",_)),r.push(this.getDependency("accessor",M)),l.push(g),f.push(x))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(r),Promise.all(l),Promise.all(f)]).then(function(d){const u=d[0],p=d[1],g=d[2],x=d[3],w=d[4],_=[];for(let M=0,L=u.length;M<L;M++){const v=u[M],y=p[M],A=g[M],S=x[M],b=w[M];if(v===void 0)continue;v.updateMatrix();let P;switch(it[b.path]){case it.weights:P=c.NumberKeyframeTrack;break;case it.rotation:P=c.QuaternionKeyframeTrack;break;case it.position:case it.scale:default:P=c.VectorKeyframeTrack;break}const O=v.name?v.name:v.uuid,k=S.interpolation!==void 0?To[S.interpolation]:c.InterpolateLinear,V=[];it[b.path]===it.weights?v.traverse(function(X){X.morphTargetInfluences&&V.push(X.name?X.name:X.uuid)}):V.push(O);let R=A.array;if(A.normalized){const X=Mn(R.constructor),K=new Float32Array(R.length);for(let H=0,he=R.length;H<he;H++)K[H]=R[H]*X;R=K}for(let X=0,K=V.length;X<K;X++){const H=new P(V[X]+"."+it[b.path],y.array,R,k);S.interpolation==="CUBICSPLINE"&&(H.createInterpolant=function(J){const G=this instanceof c.QuaternionKeyframeTrack?Lo:ps;return new G(this.times,this.values,this.getValueSize()/3,J)},H.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),_.push(H)}}return new c.AnimationClip(s,void 0,_)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const o=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&o.traverse(function(r){if(r.isMesh)for(let l=0,f=s.weights.length;l<f;l++)r.morphTargetInfluences[l]=s.weights[l]}),o})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),o=[],r=s.children||[];for(let f=0,d=r.length;f<d;f++)o.push(n.getDependency("node",r[f]));const l=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(o),l]).then(function(f){const d=f[0],u=f[1],p=f[2];p!==null&&d.traverse(function(g){g.isSkinnedMesh&&g.bind(p,Bo)});for(let g=0,x=u.length;g<x;g++)d.add(u[g]);return d})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?s.createUniqueName(i.name):"",r=[],l=s._invokeOne(function(f){return f.createNodeMesh&&f.createNodeMesh(e)});return l&&r.push(l),i.camera!==void 0&&r.push(s.getDependency("camera",i.camera).then(function(f){return s._getNodeRef(s.cameraCache,i.camera,f)})),s._invokeAll(function(f){return f.createNodeAttachment&&f.createNodeAttachment(e)}).forEach(function(f){r.push(f)}),this.nodeCache[e]=Promise.all(r).then(function(f){let d;if(i.isBone===!0?d=new c.Bone:f.length>1?d=new c.Group:f.length===1?d=f[0]:d=new c.Object3D,d!==f[0])for(let u=0,p=f.length;u<p;u++)d.add(f[u]);if(i.name&&(d.userData.name=i.name,d.name=o),ot(d,i),i.extensions&&ht(n,d,i),i.matrix!==void 0){const u=new c.Matrix4;u.fromArray(i.matrix),d.applyMatrix4(u)}else i.translation!==void 0&&d.position.fromArray(i.translation),i.rotation!==void 0&&d.quaternion.fromArray(i.rotation),i.scale!==void 0&&d.scale.fromArray(i.scale);return s.associations.has(d)||s.associations.set(d,{}),s.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new c.Group;n.name&&(i.name=s.createUniqueName(n.name)),ot(i,n),n.extensions&&ht(t,i,n);const o=n.nodes||[],r=[];for(let l=0,f=o.length;l<f;l++)r.push(s.getDependency("node",o[l]));return Promise.all(r).then(function(l){for(let d=0,u=l.length;d<u;d++)i.add(l[d]);const f=d=>{const u=new Map;for(const[p,g]of s.associations)(p instanceof c.Material||p instanceof c.Texture)&&u.set(p,g);return d.traverse(p=>{const g=s.associations.get(p);g!=null&&u.set(p,g)}),u};return s.associations=f(i),i})}}function Vo(a,e,t){const n=e.attributes,s=new c.Box3;if(n.POSITION!==void 0){const r=t.json.accessors[n.POSITION],l=r.min,f=r.max;if(l!==void 0&&f!==void 0){if(s.set(new c.Vector3(l[0],l[1],l[2]),new c.Vector3(f[0],f[1],f[2])),r.normalized){const d=Mn(xt[r.componentType]);s.min.multiplyScalar(d),s.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new c.Vector3,l=new c.Vector3;for(let f=0,d=i.length;f<d;f++){const u=i[f];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],g=p.min,x=p.max;if(g!==void 0&&x!==void 0){if(l.setX(Math.max(Math.abs(g[0]),Math.abs(x[0]))),l.setY(Math.max(Math.abs(g[1]),Math.abs(x[1]))),l.setZ(Math.max(Math.abs(g[2]),Math.abs(x[2]))),p.normalized){const w=Mn(xt[p.componentType]);l.multiplyScalar(w)}r.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(r)}a.boundingBox=s;const o=new c.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,a.boundingSphere=o}function ys(a,e,t){const n=e.attributes,s=[];function i(o,r){return t.getDependency("accessor",o).then(function(l){a.setAttribute(r,l)})}for(const o in n){const r=wn[o]||o.toLowerCase();r in a.attributes||s.push(i(n[o],r))}if(e.indices!==void 0&&!a.index){const o=t.getDependency("accessor",e.indices).then(function(r){a.setIndex(r)});s.push(o)}return ot(a,e),Vo(a,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Do(a,e.targets,t):a})}class _s extends c.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:s=8,bevelThickness:i=10,font:o,height:r=50,size:l=100,lineHeight:f=1,letterSpacing:d=0,...u}=t;if(o===void 0)super();else{const p=o.generateShapes(e,l,{lineHeight:f,letterSpacing:d});super(p,{...u,bevelEnabled:n,bevelSize:s,bevelThickness:i,depth:r})}this.type="TextGeometry"}}const zo={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
9
9
  varying vec2 vUv;
10
10
 
11
11
  void main() {
@@ -37,7 +37,7 @@
37
37
  gl_FragColor = sum;
38
38
 
39
39
  }
40
- `},Zi={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`
40
+ `},No={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`
41
41
  varying vec2 vUv;
42
42
 
43
43
  void main() {
@@ -70,13 +70,13 @@
70
70
  gl_FragColor = sum;
71
71
 
72
72
  }
73
- `};function Zs(l,e,t){const s=t.length-l-1;if(e>=t[s])return s-1;if(e<=t[l])return l;let n=l,i=s,o=Math.floor((n+i)/2);for(;e<t[o]||e>=t[o+1];)e<t[o]?i=o:n=o,o=Math.floor((n+i)/2);return o}function Wi(l,e,t,s){const n=[],i=[],o=[];n[0]=1;for(let r=1;r<=t;++r){i[r]=e-s[l+1-r],o[r]=s[l+r]-e;let a=0;for(let h=0;h<r;++h){const f=o[h+1],p=i[r-h],m=n[h]/(f+p);n[h]=a+f*m,a=p*m}n[r]=a}return n}function Qi(l,e,t,s){const n=Zs(l,s,e),i=Wi(n,s,l,e),o=new c.Vector4(0,0,0,0);for(let r=0;r<=l;++r){const a=t[n-l+r],h=i[r],f=a.w*h;o.x+=a.x*f,o.y+=a.y*f,o.z+=a.z*f,o.w+=a.w*h}return o}function Ki(l,e,t,s,n){const i=[];for(let p=0;p<=t;++p)i[p]=0;const o=[];for(let p=0;p<=s;++p)o[p]=i.slice(0);const r=[];for(let p=0;p<=t;++p)r[p]=i.slice(0);r[0][0]=1;const a=i.slice(0),h=i.slice(0);for(let p=1;p<=t;++p){a[p]=e-n[l+1-p],h[p]=n[l+p]-e;let m=0;for(let g=0;g<p;++g){const w=h[g+1],x=a[p-g];r[p][g]=w+x;const _=r[g][p-1]/r[p][g];r[g][p]=m+w*_,m=x*_}r[p][p]=m}for(let p=0;p<=t;++p)o[0][p]=r[p][t];for(let p=0;p<=t;++p){let m=0,g=1;const w=[];for(let x=0;x<=t;++x)w[x]=i.slice(0);w[0][0]=1;for(let x=1;x<=s;++x){let _=0;const S=p-x,C=t-x;p>=x&&(w[g][0]=w[m][0]/r[C+1][S],_=w[g][0]*r[S][C]);const v=S>=-1?1:-S,y=p-1<=C?x-1:t-p;for(let P=v;P<=y;++P)w[g][P]=(w[m][P]-w[m][P-1])/r[C+1][S+P],_+=w[g][P]*r[S+P][C];p<=C&&(w[g][x]=-w[m][x-1]/r[C+1][p],_+=w[g][x]*r[p][C]),o[x][p]=_;const M=m;m=g,g=M}}let f=t;for(let p=1;p<=s;++p){for(let m=0;m<=t;++m)o[p][m]*=f;f*=t-p}return o}function qi(l,e,t,s,n){const i=n<l?n:l,o=[],r=Zs(l,s,e),a=Ki(r,s,l,i,e),h=[];for(let f=0;f<t.length;++f){const p=t[f].clone(),m=p.w;p.x*=m,p.y*=m,p.z*=m,h[f]=p}for(let f=0;f<=i;++f){const p=h[r-l].clone().multiplyScalar(a[f][0]);for(let m=1;m<=l;++m)p.add(h[r-l+m].clone().multiplyScalar(a[f][m]));o[f]=p}for(let f=i+1;f<=n+1;++f)o[f]=new c.Vector4(0,0,0);return o}function Ji(l,e){let t=1;for(let n=2;n<=l;++n)t*=n;let s=1;for(let n=2;n<=e;++n)s*=n;for(let n=2;n<=l-e;++n)s*=n;return t/s}function Hi(l){const e=l.length,t=[],s=[];for(let i=0;i<e;++i){const o=l[i];t[i]=new c.Vector3(o.x,o.y,o.z),s[i]=o.w}const n=[];for(let i=0;i<e;++i){const o=t[i].clone();for(let r=1;r<=i;++r)o.sub(n[i-r].clone().multiplyScalar(Ji(i,r)*s[r]));n[i]=o.divideScalar(s[0])}return n}function $i(l,e,t,s,n){const i=qi(l,e,t,s,n);return Hi(i)}class Ws extends c.Curve{constructor(e,t,s,n,i){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=n||0,this.endKnot=i||this.knots.length-1;for(let o=0;o<s.length;++o){const r=s[o];this.controlPoints[o]=new c.Vector4(r.x,r.y,r.z,r.w)}}getPoint(e,t){const s=t||new c.Vector3,n=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=Qi(this.degree,this.knots,this.controlPoints,n);return i.w!=1&&i.divideScalar(i.w),s.set(i.x,i.y,i.z)}getTangent(e,t){const s=t||new c.Vector3,n=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=$i(this.degree,this.knots,this.controlPoints,n,1);return s.copy(i[1]).normalize(),s}}let fe,Me,Oe;class eo extends c.Loader{constructor(e){super(e)}load(e,t,s,n){const i=this,o=i.path===""?c.LoaderUtils.extractUrlBase(e):i.path,r=new c.FileLoader(this.manager);r.setPath(i.path),r.setResponseType("arraybuffer"),r.setRequestHeader(i.requestHeader),r.setWithCredentials(i.withCredentials),r.load(e,function(a){try{t(i.parse(a,o))}catch(h){n?n(h):console.error(h),i.manager.itemError(e)}},s,n)}parse(e,t){if(ro(e))fe=new oo().parse(e);else{const n=$s(e);if(!ao(n))throw new Error("THREE.FBXLoader: Unknown format.");if(qs(n)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+qs(n));fe=new io().parse(n)}const s=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new to(s,this.manager).parse(fe)}}class to{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Me=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),s=this.parseMaterials(t),n=this.parseDeformers(),i=new so().parse(n);return this.parseScene(n,i,s),Oe}parseConnections(){const e=new Map;return"Connections"in fe&&fe.Connections.connections.forEach(function(s){const n=s[0],i=s[1],o=s[2];e.has(n)||e.set(n,{parents:[],children:[]});const r={ID:i,relationship:o};e.get(n).parents.push(r),e.has(i)||e.set(i,{parents:[],children:[]});const a={ID:n,relationship:o};e.get(i).children.push(a)}),e}parseImages(){const e={},t={};if("Video"in fe.Objects){const s=fe.Objects.Video;for(const n in s){const i=s[n],o=parseInt(n);if(e[o]=i.RelativeFilename||i.Filename,"Content"in i){const r=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,a=typeof i.Content=="string"&&i.Content!=="";if(r||a){const h=this.parseImage(s[n]);t[i.RelativeFilename||i.Filename]=h}}}}for(const s in e){const n=e[s];t[n]!==void 0?e[s]=t[n]:e[s]=e[s].split("\\").pop()}return e}parseImage(e){const t=e.Content,s=e.RelativeFilename||e.Filename,n=s.slice(s.lastIndexOf(".")+1).toLowerCase();let i;switch(n){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",s),i="image/tga";break;default:console.warn('FBXLoader: Image type "'+n+'" is not supported.');return}if(typeof t=="string")return"data:"+i+";base64,"+t;{const o=new Uint8Array(t);return window.URL.createObjectURL(new Blob([o],{type:i}))}}parseTextures(e){const t=new Map;if("Texture"in fe.Objects){const s=fe.Objects.Texture;for(const n in s){const i=this.parseTexture(s[n],e);t.set(parseInt(n),i)}}return t}parseTexture(e,t){const s=this.loadTexture(e,t);s.ID=e.id,s.name=e.attrName;const n=e.WrapModeU,i=e.WrapModeV,o=n!==void 0?n.value:0,r=i!==void 0?i.value:0;if(s.wrapS=o===0?c.RepeatWrapping:c.ClampToEdgeWrapping,s.wrapT=r===0?c.RepeatWrapping:c.ClampToEdgeWrapping,"Scaling"in e){const a=e.Scaling.value;s.repeat.x=a[0],s.repeat.y=a[1]}return s}loadTexture(e,t){let s;const n=this.textureLoader.path,i=Me.get(e.id).children;i!==void 0&&i.length>0&&t[i[0].ID]!==void 0&&(s=t[i[0].ID],(s.indexOf("blob:")===0||s.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let o;const r=e.FileName.slice(-3).toLowerCase();if(r==="tga"){const a=this.manager.getHandler(".tga");a===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),o=new c.Texture):(a.setPath(this.textureLoader.path),o=a.load(s))}else r==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),o=new c.Texture):o=this.textureLoader.load(s);return this.textureLoader.setPath(n),o}parseMaterials(e){const t=new Map;if("Material"in fe.Objects){const s=fe.Objects.Material;for(const n in s){const i=this.parseMaterial(s[n],e);i!==null&&t.set(parseInt(n),i)}}return t}parseMaterial(e,t){const s=e.id,n=e.attrName;let i=e.ShadingModel;if(typeof i=="object"&&(i=i.value),!Me.has(s))return null;const o=this.parseParameters(e,t,s);let r;switch(i.toLowerCase()){case"phong":r=new c.MeshPhongMaterial;break;case"lambert":r=new c.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),r=new c.MeshPhongMaterial;break}return r.setValues(o),r.name=n,r}parseParameters(e,t,s){const n={};e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=new c.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(n.color=new c.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=new c.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(n.emissive=new c.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(n.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(n.opacity=parseFloat(e.Opacity.value)),n.opacity<1&&(n.transparent=!0),e.ReflectionFactor&&(n.reflectivity=e.ReflectionFactor.value),e.Shininess&&(n.shininess=e.Shininess.value),e.Specular?n.specular=new c.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(n.specular=new c.Color().fromArray(e.SpecularColor.value));const i=this;return Me.get(s).children.forEach(function(o){const r=o.relationship;switch(r){case"Bump":n.bumpMap=i.getTexture(t,o.ID);break;case"Maya|TEX_ao_map":n.aoMap=i.getTexture(t,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=i.getTexture(t,o.ID),n.map!==void 0&&("colorSpace"in n.map?n.map.colorSpace="srgb":n.map.encoding=3001);break;case"DisplacementColor":n.displacementMap=i.getTexture(t,o.ID);break;case"EmissiveColor":n.emissiveMap=i.getTexture(t,o.ID),n.emissiveMap!==void 0&&("colorSpace"in n.emissiveMap?n.emissiveMap.colorSpace="srgb":n.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=i.getTexture(t,o.ID);break;case"ReflectionColor":n.envMap=i.getTexture(t,o.ID),n.envMap!==void 0&&(n.envMap.mapping=c.EquirectangularReflectionMapping,"colorSpace"in n.envMap?n.envMap.colorSpace="srgb":n.envMap.encoding=3001);break;case"SpecularColor":n.specularMap=i.getTexture(t,o.ID),n.specularMap!==void 0&&("colorSpace"in n.specularMap?n.specularMap.colorSpace="srgb":n.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=i.getTexture(t,o.ID),n.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r);break}}),n}getTexture(e,t){return"LayeredTexture"in fe.Objects&&t in fe.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Me.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in fe.Objects){const s=fe.Objects.Deformer;for(const n in s){const i=s[n],o=Me.get(parseInt(n));if(i.attrType==="Skin"){const r=this.parseSkeleton(o,s);r.ID=n,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),r.geometryID=o.parents[0].ID,e[n]=r}else if(i.attrType==="BlendShape"){const r={id:n};r.rawTargets=this.parseMorphTargets(o,s),r.id=n,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[n]=r}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const s=[];return e.children.forEach(function(n){const i=t[n.ID];if(i.attrType!=="Cluster")return;const o={ID:n.ID,indices:[],weights:[],transformLink:new c.Matrix4().fromArray(i.TransformLink.a)};"Indexes"in i&&(o.indices=i.Indexes.a,o.weights=i.Weights.a),s.push(o)}),{rawBones:s,bones:[]}}parseMorphTargets(e,t){const s=[];for(let n=0;n<e.children.length;n++){const i=e.children[n],o=t[i.ID],r={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if(o.attrType!=="BlendShapeChannel")return;r.geoID=Me.get(parseInt(i.ID)).children.filter(function(a){return a.relationship===void 0})[0].ID,s.push(r)}return s}parseScene(e,t,s){Oe=new c.Group;const n=this.parseModels(e.skeletons,t,s),i=fe.Objects.Model,o=this;n.forEach(function(a){const h=i[a.ID];o.setLookAtProperties(a,h),Me.get(a.ID).parents.forEach(function(p){const m=n.get(p.ID);m!==void 0&&m.add(a)}),a.parent===null&&Oe.add(a)}),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),Oe.traverse(function(a){if(a.userData.transformData){a.parent&&(a.userData.transformData.parentMatrix=a.parent.matrix,a.userData.transformData.parentMatrixWorld=a.parent.matrixWorld);const h=Js(a.userData.transformData);a.applyMatrix4(h),a.updateWorldMatrix()}});const r=new no().parse();Oe.children.length===1&&Oe.children[0].isGroup&&(Oe.children[0].animations=r,Oe=Oe.children[0]),Oe.animations=r}parseModels(e,t,s){const n=new Map,i=fe.Objects.Model;for(const o in i){const r=parseInt(o),a=i[o],h=Me.get(r);let f=this.buildSkeleton(h,e,r,a.attrName);if(!f){switch(a.attrType){case"Camera":f=this.createCamera(h);break;case"Light":f=this.createLight(h);break;case"Mesh":f=this.createMesh(h,t,s);break;case"NurbsCurve":f=this.createCurve(h,t);break;case"LimbNode":case"Root":f=new c.Bone;break;case"Null":default:f=new c.Group;break}f.name=a.attrName?c.PropertyBinding.sanitizeNodeName(a.attrName):"",f.ID=r}this.getTransformData(f,a),n.set(r,f)}return n}buildSkeleton(e,t,s,n){let i=null;return e.parents.forEach(function(o){for(const r in t){const a=t[r];a.rawBones.forEach(function(h,f){if(h.ID===o.ID){const p=i;i=new c.Bone,i.matrixWorld.copy(h.transformLink),i.name=n?c.PropertyBinding.sanitizeNodeName(n):"",i.ID=s,a.bones[f]=i,p!==null&&i.add(p)}})}}),i}createCamera(e){let t,s;if(e.children.forEach(function(n){const i=fe.Objects.NodeAttribute[n.ID];i!==void 0&&(s=i)}),s===void 0)t=new c.Object3D;else{let n=0;s.CameraProjectionType!==void 0&&s.CameraProjectionType.value===1&&(n=1);let i=1;s.NearPlane!==void 0&&(i=s.NearPlane.value/1e3);let o=1e3;s.FarPlane!==void 0&&(o=s.FarPlane.value/1e3);let r=window.innerWidth,a=window.innerHeight;s.AspectWidth!==void 0&&s.AspectHeight!==void 0&&(r=s.AspectWidth.value,a=s.AspectHeight.value);const h=r/a;let f=45;s.FieldOfView!==void 0&&(f=s.FieldOfView.value);const p=s.FocalLength?s.FocalLength.value:null;switch(n){case 0:t=new c.PerspectiveCamera(f,h,i,o),p!==null&&t.setFocalLength(p);break;case 1:t=new c.OrthographicCamera(-r/2,r/2,a/2,-a/2,i,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+n+"."),t=new c.Object3D;break}}return t}createLight(e){let t,s;if(e.children.forEach(function(n){const i=fe.Objects.NodeAttribute[n.ID];i!==void 0&&(s=i)}),s===void 0)t=new c.Object3D;else{let n;s.LightType===void 0?n=0:n=s.LightType.value;let i=16777215;s.Color!==void 0&&(i=new c.Color().fromArray(s.Color.value));let o=s.Intensity===void 0?1:s.Intensity.value/100;s.CastLightOnObject!==void 0&&s.CastLightOnObject.value===0&&(o=0);let r=0;s.FarAttenuationEnd!==void 0&&(s.EnableFarAttenuation!==void 0&&s.EnableFarAttenuation.value===0?r=0:r=s.FarAttenuationEnd.value);const a=1;switch(n){case 0:t=new c.PointLight(i,o,r,a);break;case 1:t=new c.DirectionalLight(i,o);break;case 2:let h=Math.PI/3;s.InnerAngle!==void 0&&(h=c.MathUtils.degToRad(s.InnerAngle.value));let f=0;s.OuterAngle!==void 0&&(f=c.MathUtils.degToRad(s.OuterAngle.value),f=Math.max(f,1)),t=new c.SpotLight(i,o,r,h,f,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+s.LightType.value+", defaulting to a PointLight."),t=new c.PointLight(i,o);break}s.CastShadows!==void 0&&s.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,s){let n,i=null,o=null;const r=[];return e.children.forEach(function(a){t.has(a.ID)&&(i=t.get(a.ID)),s.has(a.ID)&&r.push(s.get(a.ID))}),r.length>1?o=r:r.length>0?o=r[0]:(o=new c.MeshPhongMaterial({color:13421772}),r.push(o)),"color"in i.attributes&&r.forEach(function(a){a.vertexColors=!0}),i.FBX_Deformer?(n=new c.SkinnedMesh(i,o),n.normalizeSkinWeights()):n=new c.Mesh(i,o),n}createCurve(e,t){const s=e.children.reduce(function(i,o){return t.has(o.ID)&&(i=t.get(o.ID)),i},null),n=new c.LineBasicMaterial({color:3342591,linewidth:1});return new c.Line(s,n)}getTransformData(e,t){const s={};"InheritType"in t&&(s.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?s.eulerOrder=Hs(t.RotationOrder.value):s.eulerOrder="ZYX","Lcl_Translation"in t&&(s.translation=t.Lcl_Translation.value),"PreRotation"in t&&(s.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(s.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(s.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(s.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(s.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(s.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(s.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(s.rotationPivot=t.RotationPivot.value),e.userData.transformData=s}setLookAtProperties(e,t){"LookAtProperty"in t&&Me.get(e.ID).children.forEach(function(n){if(n.relationship==="LookAtProperty"){const i=fe.Objects.Model[n.ID];if("Lcl_Translation"in i){const o=i.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),Oe.add(e.target)):e.lookAt(new c.Vector3().fromArray(o))}}})}bindSkeleton(e,t,s){const n=this.parsePoseNodes();for(const i in e){const o=e[i];Me.get(parseInt(o.ID)).parents.forEach(function(a){if(t.has(a.ID)){const h=a.ID;Me.get(h).parents.forEach(function(p){s.has(p.ID)&&s.get(p.ID).bind(new c.Skeleton(o.bones),n[p.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in fe.Objects){const t=fe.Objects.Pose;for(const s in t)if(t[s].attrType==="BindPose"&&t[s].NbPoseNodes>0){const n=t[s].PoseNode;Array.isArray(n)?n.forEach(function(i){e[i.Node]=new c.Matrix4().fromArray(i.Matrix.a)}):e[n.Node]=new c.Matrix4().fromArray(n.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in fe&&"AmbientColor"in fe.GlobalSettings){const e=fe.GlobalSettings.AmbientColor.value,t=e[0],s=e[1],n=e[2];if(t!==0||s!==0||n!==0){const i=new c.Color(t,s,n);Oe.add(new c.AmbientLight(i,1))}}}}class so{parse(e){const t=new Map;if("Geometry"in fe.Objects){const s=fe.Objects.Geometry;for(const n in s){const i=Me.get(parseInt(n)),o=this.parseGeometry(i,s[n],e);t.set(parseInt(n),o)}}return t}parseGeometry(e,t,s){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,s);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,s){const n=s.skeletons,i=[],o=e.parents.map(function(p){return fe.Objects.Model[p.ID]});if(o.length===0)return;const r=e.children.reduce(function(p,m){return n[m.ID]!==void 0&&(p=n[m.ID]),p},null);e.children.forEach(function(p){s.morphTargets[p.ID]!==void 0&&i.push(s.morphTargets[p.ID])});const a=o[0],h={};"RotationOrder"in a&&(h.eulerOrder=Hs(a.RotationOrder.value)),"InheritType"in a&&(h.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(h.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(h.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(h.scale=a.GeometricScaling.value);const f=Js(h);return this.genGeometry(t,r,i,f)}genGeometry(e,t,s,n){const i=new c.BufferGeometry;e.attrName&&(i.name=e.attrName);const o=this.parseGeoNode(e,t),r=this.genBuffers(o),a=new c.Float32BufferAttribute(r.vertex,3);if(a.applyMatrix4(n),i.setAttribute("position",a),r.colors.length>0&&i.setAttribute("color",new c.Float32BufferAttribute(r.colors,3)),t&&(i.setAttribute("skinIndex",new c.Uint16BufferAttribute(r.weightsIndices,4)),i.setAttribute("skinWeight",new c.Float32BufferAttribute(r.vertexWeights,4)),i.FBX_Deformer=t),r.normal.length>0){const h=new c.Matrix3().getNormalMatrix(n),f=new c.Float32BufferAttribute(r.normal,3);f.applyNormalMatrix(h),i.setAttribute("normal",f)}if(r.uvs.forEach(function(h,f){let p="uv"+(f+1).toString();f===0&&(p="uv"),i.setAttribute(p,new c.Float32BufferAttribute(r.uvs[f],2))}),o.material&&o.material.mappingType!=="AllSame"){let h=r.materialIndex[0],f=0;if(r.materialIndex.forEach(function(p,m){p!==h&&(i.addGroup(f,m-f,h),h=p,f=m)}),i.groups.length>0){const p=i.groups[i.groups.length-1],m=p.start+p.count;m!==r.materialIndex.length&&i.addGroup(m,r.materialIndex.length-m,h)}i.groups.length===0&&i.addGroup(0,r.materialIndex.length,r.materialIndex[0])}return this.addMorphTargets(i,e,s,n),i}parseGeoNode(e,t){const s={};if(s.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],s.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(s.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(s.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(s.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){s.uv=[];let n=0;for(;e.LayerElementUV[n];)e.LayerElementUV[n].UV&&s.uv.push(this.parseUVs(e.LayerElementUV[n])),n++}return s.weightTable={},t!==null&&(s.skeleton=t,t.rawBones.forEach(function(n,i){n.indices.forEach(function(o,r){s.weightTable[o]===void 0&&(s.weightTable[o]=[]),s.weightTable[o].push({id:i,weight:n.weights[r]})})})),s}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let s=0,n=0,i=!1,o=[],r=[],a=[],h=[],f=[],p=[];const m=this;return e.vertexIndices.forEach(function(g,w){let x,_=!1;g<0&&(g=g^-1,_=!0);let S=[],C=[];if(o.push(g*3,g*3+1,g*3+2),e.color){const v=It(w,s,g,e.color);a.push(v[0],v[1],v[2])}if(e.skeleton){if(e.weightTable[g]!==void 0&&e.weightTable[g].forEach(function(v){C.push(v.weight),S.push(v.id)}),C.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const v=[0,0,0,0],y=[0,0,0,0];C.forEach(function(M,P){let A=M,b=S[P];y.forEach(function(D,z,U){if(A>D){U[z]=A,A=D;const R=v[z];v[z]=b,b=R}})}),S=v,C=y}for(;C.length<4;)C.push(0),S.push(0);for(let v=0;v<4;++v)f.push(C[v]),p.push(S[v])}if(e.normal){const v=It(w,s,g,e.normal);r.push(v[0],v[1],v[2])}e.material&&e.material.mappingType!=="AllSame"&&(x=It(w,s,g,e.material)[0]),e.uv&&e.uv.forEach(function(v,y){const M=It(w,s,g,v);h[y]===void 0&&(h[y]=[]),h[y].push(M[0]),h[y].push(M[1])}),n++,_&&(m.genFace(t,e,o,x,r,a,h,f,p,n),s++,n=0,o=[],r=[],a=[],h=[],f=[],p=[])}),t}genFace(e,t,s,n,i,o,r,a,h,f){for(let p=2;p<f;p++)e.vertex.push(t.vertexPositions[s[0]]),e.vertex.push(t.vertexPositions[s[1]]),e.vertex.push(t.vertexPositions[s[2]]),e.vertex.push(t.vertexPositions[s[(p-1)*3]]),e.vertex.push(t.vertexPositions[s[(p-1)*3+1]]),e.vertex.push(t.vertexPositions[s[(p-1)*3+2]]),e.vertex.push(t.vertexPositions[s[p*3]]),e.vertex.push(t.vertexPositions[s[p*3+1]]),e.vertex.push(t.vertexPositions[s[p*3+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[(p-1)*4]),e.vertexWeights.push(a[(p-1)*4+1]),e.vertexWeights.push(a[(p-1)*4+2]),e.vertexWeights.push(a[(p-1)*4+3]),e.vertexWeights.push(a[p*4]),e.vertexWeights.push(a[p*4+1]),e.vertexWeights.push(a[p*4+2]),e.vertexWeights.push(a[p*4+3]),e.weightsIndices.push(h[0]),e.weightsIndices.push(h[1]),e.weightsIndices.push(h[2]),e.weightsIndices.push(h[3]),e.weightsIndices.push(h[(p-1)*4]),e.weightsIndices.push(h[(p-1)*4+1]),e.weightsIndices.push(h[(p-1)*4+2]),e.weightsIndices.push(h[(p-1)*4+3]),e.weightsIndices.push(h[p*4]),e.weightsIndices.push(h[p*4+1]),e.weightsIndices.push(h[p*4+2]),e.weightsIndices.push(h[p*4+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[(p-1)*3]),e.colors.push(o[(p-1)*3+1]),e.colors.push(o[(p-1)*3+2]),e.colors.push(o[p*3]),e.colors.push(o[p*3+1]),e.colors.push(o[p*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(n),e.materialIndex.push(n),e.materialIndex.push(n)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[(p-1)*3]),e.normal.push(i[(p-1)*3+1]),e.normal.push(i[(p-1)*3+2]),e.normal.push(i[p*3]),e.normal.push(i[p*3+1]),e.normal.push(i[p*3+2])),t.uv&&t.uv.forEach(function(m,g){e.uvs[g]===void 0&&(e.uvs[g]=[]),e.uvs[g].push(r[g][0]),e.uvs[g].push(r[g][1]),e.uvs[g].push(r[g][(p-1)*2]),e.uvs[g].push(r[g][(p-1)*2+1]),e.uvs[g].push(r[g][p*2]),e.uvs[g].push(r[g][p*2+1])})}addMorphTargets(e,t,s,n){if(s.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const i=this;s.forEach(function(o){o.rawTargets.forEach(function(r){const a=fe.Objects.Geometry[r.geoID];a!==void 0&&i.genMorphGeometry(e,t,a,n,r.name)})})}genMorphGeometry(e,t,s,n,i){const o=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],r=s.Vertices!==void 0?s.Vertices.a:[],a=s.Indexes!==void 0?s.Indexes.a:[],h=e.attributes.position.count*3,f=new Float32Array(h);for(let w=0;w<a.length;w++){const x=a[w]*3;f[x]=r[w*3],f[x+1]=r[w*3+1],f[x+2]=r[w*3+2]}const p={vertexIndices:o,vertexPositions:f},m=this.genBuffers(p),g=new c.Float32BufferAttribute(m.vertex,3);g.name=i||s.attrName,g.applyMatrix4(n),e.morphAttributes.position.push(g)}parseNormals(e){const t=e.MappingInformationType,s=e.ReferenceInformationType,n=e.Normals.a;let i=[];return s==="IndexToDirect"&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:n,indices:i,mappingType:t,referenceType:s}}parseUVs(e){const t=e.MappingInformationType,s=e.ReferenceInformationType,n=e.UV.a;let i=[];return s==="IndexToDirect"&&(i=e.UVIndex.a),{dataSize:2,buffer:n,indices:i,mappingType:t,referenceType:s}}parseVertexColors(e){const t=e.MappingInformationType,s=e.ReferenceInformationType,n=e.Colors.a;let i=[];return s==="IndexToDirect"&&(i=e.ColorIndex.a),{dataSize:4,buffer:n,indices:i,mappingType:t,referenceType:s}}parseMaterialIndices(e){const t=e.MappingInformationType,s=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:s};const n=e.Materials.a,i=[];for(let o=0;o<n.length;++o)i.push(o);return{dataSize:1,buffer:n,indices:i,mappingType:t,referenceType:s}}parseNurbsGeometry(e){if(Ws===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new c.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new c.BufferGeometry;const s=t-1,n=e.KnotVector.a,i=[],o=e.Points.a;for(let p=0,m=o.length;p<m;p+=4)i.push(new c.Vector4().fromArray(o,p));let r,a;if(e.Form==="Closed")i.push(i[0]);else if(e.Form==="Periodic"){r=s,a=n.length-1-r;for(let p=0;p<s;++p)i.push(i[p])}const f=new Ws(s,n,i,r,a).getPoints(i.length*12);return new c.BufferGeometry().setFromPoints(f)}}class no{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const s in t){const n=t[s],i=this.addClip(n);e.push(i)}return e}parseClips(){if(fe.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=fe.Objects.AnimationCurveNode,t=new Map;for(const s in e){const n=e[s];if(n.attrName.match(/S|R|T|DeformPercent/)!==null){const i={id:n.id,attr:n.attrName,curves:{}};t.set(i.id,i)}}return t}parseAnimationCurves(e){const t=fe.Objects.AnimationCurve;for(const s in t){const n={id:t[s].id,times:t[s].KeyTime.a.map(lo),values:t[s].KeyValueFloat.a},i=Me.get(n.id);if(i!==void 0){const o=i.parents[0].ID,r=i.parents[0].relationship;r.match(/X/)?e.get(o).curves.x=n:r.match(/Y/)?e.get(o).curves.y=n:r.match(/Z/)?e.get(o).curves.z=n:r.match(/d|DeformPercent/)&&e.has(o)&&(e.get(o).curves.morph=n)}}}parseAnimationLayers(e){const t=fe.Objects.AnimationLayer,s=new Map;for(const n in t){const i=[],o=Me.get(parseInt(n));o!==void 0&&(o.children.forEach(function(a,h){if(e.has(a.ID)){const f=e.get(a.ID);if(f.curves.x!==void 0||f.curves.y!==void 0||f.curves.z!==void 0){if(i[h]===void 0){const p=Me.get(a.ID).parents.filter(function(m){return m.relationship!==void 0})[0].ID;if(p!==void 0){const m=fe.Objects.Model[p.toString()];if(m===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",a);return}const g={modelName:m.attrName?c.PropertyBinding.sanitizeNodeName(m.attrName):"",ID:m.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Oe.traverse(function(w){w.ID===m.id&&(g.transform=w.matrix,w.userData.transformData&&(g.eulerOrder=w.userData.transformData.eulerOrder))}),g.transform||(g.transform=new c.Matrix4),"PreRotation"in m&&(g.preRotation=m.PreRotation.value),"PostRotation"in m&&(g.postRotation=m.PostRotation.value),i[h]=g}}i[h]&&(i[h][f.attr]=f)}else if(f.curves.morph!==void 0){if(i[h]===void 0){const p=Me.get(a.ID).parents.filter(function(S){return S.relationship!==void 0})[0].ID,m=Me.get(p).parents[0].ID,g=Me.get(m).parents[0].ID,w=Me.get(g).parents[0].ID,x=fe.Objects.Model[w],_={modelName:x.attrName?c.PropertyBinding.sanitizeNodeName(x.attrName):"",morphName:fe.Objects.Deformer[p].attrName};i[h]=_}i[h][f.attr]=f}}}),s.set(parseInt(n),i))}return s}parseAnimStacks(e){const t=fe.Objects.AnimationStack,s={};for(const n in t){const i=Me.get(parseInt(n)).children;i.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const o=e.get(i[0].ID);s[n]={name:t[n].attrName,layer:o}}return s}addClip(e){let t=[];const s=this;return e.layer.forEach(function(n){t=t.concat(s.generateTracks(n))}),new c.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let s=new c.Vector3,n=new c.Quaternion,i=new c.Vector3;if(e.transform&&e.transform.decompose(s,n,i),s=s.toArray(),n=new c.Euler().setFromQuaternion(n,e.eulerOrder).toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.T.curves,s,"position");o!==void 0&&t.push(o)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const o=this.generateRotationTrack(e.modelName,e.R.curves,n,e.preRotation,e.postRotation,e.eulerOrder);o!==void 0&&t.push(o)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");o!==void 0&&t.push(o)}if(e.DeformPercent!==void 0){const o=this.generateMorphTrack(e);o!==void 0&&t.push(o)}return t}generateVectorTrack(e,t,s,n){const i=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(i,t,s);return new c.VectorKeyframeTrack(e+"."+n,i,o)}generateRotationTrack(e,t,s,n,i,o){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(c.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(c.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(c.MathUtils.degToRad));const r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,s);n!==void 0&&(n=n.map(c.MathUtils.degToRad),n.push(o),n=new c.Euler().fromArray(n),n=new c.Quaternion().setFromEuler(n)),i!==void 0&&(i=i.map(c.MathUtils.degToRad),i.push(o),i=new c.Euler().fromArray(i),i=new c.Quaternion().setFromEuler(i).invert());const h=new c.Quaternion,f=new c.Euler,p=[];for(let m=0;m<a.length;m+=3)f.set(a[m],a[m+1],a[m+2],o),h.setFromEuler(f),n!==void 0&&h.premultiply(n),i!==void 0&&h.multiply(i),h.toArray(p,m/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",r,p)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,s=t.values.map(function(i){return i/100}),n=Oe.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new c.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+n+"]",t.times,s)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(s,n){return s-n}),t.length>1){let s=1,n=t[0];for(let i=1;i<t.length;i++){const o=t[i];o!==n&&(t[s]=o,n=o,s++)}t=t.slice(0,s)}return t}getKeyframeTrackValues(e,t,s){const n=s,i=[];let o=-1,r=-1,a=-1;return e.forEach(function(h){if(t.x&&(o=t.x.times.indexOf(h)),t.y&&(r=t.y.times.indexOf(h)),t.z&&(a=t.z.times.indexOf(h)),o!==-1){const f=t.x.values[o];i.push(f),n[0]=f}else i.push(n[0]);if(r!==-1){const f=t.y.values[r];i.push(f),n[1]=f}else i.push(n[1]);if(a!==-1){const f=t.z.values[a];i.push(f),n[2]=f}else i.push(n[2])}),i}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const s=e.values[t-1],n=e.values[t]-s,i=Math.abs(n);if(i>=180){const o=i/180,r=n/o;let a=s+r;const h=e.times[t-1],p=(e.times[t]-h)/o;let m=h+p;const g=[],w=[];for(;m<e.times[t];)g.push(m),m+=p,w.push(a),a+=r;e.times=en(e.times,t,g),e.values=en(e.values,t,w)}}}}class io{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Ks,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,s=e.split(/[\r\n]+/);return s.forEach(function(n,i){const o=n.match(/^[\s\t]*;/),r=n.match(/^[\s\t]*$/);if(o||r)return;const a=n.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),h=n.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),f=n.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(n,a):h?t.parseNodeProperty(n,h,s[++i]):f?t.popStack():n.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(n)}),this.allNodes}parseNodeBegin(e,t){const s=t[1].trim().replace(/^"/,"").replace(/"$/,""),n=t[2].split(",").map(function(a){return a.trim().replace(/^"/,"").replace(/"$/,"")}),i={name:s},o=this.parseNodeAttr(n),r=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(s,i):s in r?(s==="PoseNode"?r.PoseNode.push(i):r[s].id!==void 0&&(r[s]={},r[s][r[s].id]=r[s]),o.id!==""&&(r[s][o.id]=i)):typeof o.id=="number"?(r[s]={},r[s][o.id]=i):s!=="Properties70"&&(s==="PoseNode"?r[s]=[i]:r[s]=i),typeof o.id=="number"&&(i.id=o.id),o.name!==""&&(i.attrName=o.name),o.type!==""&&(i.attrType=o.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let s="",n="";return e.length>1&&(s=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:s,type:n}}parseNodeProperty(e,t,s){let n=t[1].replace(/^"/,"").replace(/"$/,"").trim(),i=t[2].replace(/^"/,"").replace(/"$/,"").trim();n==="Content"&&i===","&&(i=s.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(e,n,i);return}if(n==="C"){const a=i.split(",").slice(1),h=parseInt(a[0]),f=parseInt(a[1]);let p=i.split(",").slice(3);p=p.map(function(m){return m.trim().replace(/^"/,"")}),n="connections",i=[h,f],ho(i,p),o[n]===void 0&&(o[n]=[])}n==="Node"&&(o.id=i),n in o&&Array.isArray(o[n])?o[n].push(i):n!=="a"?o[n]=i:o.a=i,this.setCurrentProp(o,n),n==="a"&&i.slice(-1)!==","&&(o.a=os(i))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=os(t.a))}parseNodeSpecialProperty(e,t,s){const n=s.split('",').map(function(f){return f.trim().replace(/^\"/,"").replace(/\s/,"_")}),i=n[0],o=n[1],r=n[2],a=n[3];let h=n[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":h=parseFloat(h);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":h=os(h);break}this.getPrevNode()[i]={type:o,type2:r,flag:a,value:h},this.setCurrentProp(this.getPrevNode(),i)}}class oo{parse(e){const t=new Qs(e);t.skip(23);const s=t.getUint32();if(s<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+s);const n=new Ks;for(;!this.endOfContent(t);){const i=this.parseNode(t,s);i!==null&&n.add(i.name,i)}return n}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const s={},n=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),r=e.getString(o);if(n===0)return null;const a=[];for(let m=0;m<i;m++)a.push(this.parseProperty(e));const h=a.length>0?a[0]:"",f=a.length>1?a[1]:"",p=a.length>2?a[2]:"";for(s.singleProperty=i===1&&e.getOffset()===n;n>e.getOffset();){const m=this.parseNode(e,t);m!==null&&this.parseSubNode(r,s,m)}return s.propertyList=a,typeof h=="number"&&(s.id=h),f!==""&&(s.attrName=f),p!==""&&(s.attrType=p),r!==""&&(s.name=r),s}parseSubNode(e,t,s){if(s.singleProperty===!0){const n=s.propertyList[0];Array.isArray(n)?(t[s.name]=s,s.a=n):t[s.name]=n}else if(e==="Connections"&&s.name==="C"){const n=[];s.propertyList.forEach(function(i,o){o!==0&&n.push(i)}),t.connections===void 0&&(t.connections=[]),t.connections.push(n)}else if(s.name==="Properties70")Object.keys(s).forEach(function(i){t[i]=s[i]});else if(e==="Properties70"&&s.name==="P"){let n=s.propertyList[0],i=s.propertyList[1];const o=s.propertyList[2],r=s.propertyList[3];let a;n.indexOf("Lcl ")===0&&(n=n.replace("Lcl ","Lcl_")),i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),i==="Color"||i==="ColorRGB"||i==="Vector"||i==="Vector3D"||i.indexOf("Lcl_")===0?a=[s.propertyList[4],s.propertyList[5],s.propertyList[6]]:a=s.propertyList[4],t[n]={type:i,type2:o,flag:r,value:a}}else t[s.name]===void 0?typeof s.id=="number"?(t[s.name]={},t[s.name][s.id]=s):t[s.name]=s:s.name==="PoseNode"?(Array.isArray(t[s.name])||(t[s.name]=[t[s.name]]),t[s.name].push(s)):t[s.name][s.id]===void 0&&(t[s.name][s.id]=s)}parseProperty(e){const t=e.getString(1);let s;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return s=e.getUint32(),e.getArrayBuffer(s);case"S":return s=e.getUint32(),e.getString(s);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const n=e.getUint32(),i=e.getUint32(),o=e.getUint32();if(i===0)switch(t){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}const r=qn(new Uint8Array(e.getArrayBuffer(o))),a=new Qs(r.buffer);switch(t){case"b":case"c":return a.getBooleanArray(n);case"d":return a.getFloat64Array(n);case"f":return a.getFloat32Array(n);case"i":return a.getInt32Array(n);case"l":return a.getInt64Array(n)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Qs{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let s=0;s<e;s++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let s=0;s<e;s++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let s=0;s<e;s++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let s=0;s<e;s++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let s=0;s<e;s++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let n=0;n<e;n++)t[n]=this.getUint8();const s=t.indexOf(0);return s>=0&&(t=t.slice(0,s)),c.LoaderUtils.decodeText(new Uint8Array(t))}}class Ks{add(e,t){this[e]=t}}function ro(l){const e="Kaydara FBX Binary \0";return l.byteLength>=e.length&&e===$s(l,0,e.length)}function ao(l){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function s(n){const i=l[n-1];return l=l.slice(t+n),t++,i}for(let n=0;n<e.length;++n)if(s(1)===e[n])return!1;return!0}function qs(l){const e=/FBXVersion: (\d+)/,t=l.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function lo(l){return l/46186158e3}const co=[];function It(l,e,t,s){let n;switch(s.mappingType){case"ByPolygonVertex":n=l;break;case"ByPolygon":n=e;break;case"ByVertice":n=t;break;case"AllSame":n=s.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+s.mappingType)}s.referenceType==="IndexToDirect"&&(n=s.indices[n]);const i=n*s.dataSize,o=i+s.dataSize;return uo(co,s.buffer,i,o)}const is=new c.Euler,pt=new c.Vector3;function Js(l){const e=new c.Matrix4,t=new c.Matrix4,s=new c.Matrix4,n=new c.Matrix4,i=new c.Matrix4,o=new c.Matrix4,r=new c.Matrix4,a=new c.Matrix4,h=new c.Matrix4,f=new c.Matrix4,p=new c.Matrix4,m=new c.Matrix4,g=l.inheritType?l.inheritType:0;if(l.translation&&e.setPosition(pt.fromArray(l.translation)),l.preRotation){const z=l.preRotation.map(c.MathUtils.degToRad);z.push(l.eulerOrder),t.makeRotationFromEuler(is.fromArray(z))}if(l.rotation){const z=l.rotation.map(c.MathUtils.degToRad);z.push(l.eulerOrder),s.makeRotationFromEuler(is.fromArray(z))}if(l.postRotation){const z=l.postRotation.map(c.MathUtils.degToRad);z.push(l.eulerOrder),n.makeRotationFromEuler(is.fromArray(z)),n.invert()}l.scale&&i.scale(pt.fromArray(l.scale)),l.scalingOffset&&r.setPosition(pt.fromArray(l.scalingOffset)),l.scalingPivot&&o.setPosition(pt.fromArray(l.scalingPivot)),l.rotationOffset&&a.setPosition(pt.fromArray(l.rotationOffset)),l.rotationPivot&&h.setPosition(pt.fromArray(l.rotationPivot)),l.parentMatrixWorld&&(p.copy(l.parentMatrix),f.copy(l.parentMatrixWorld));const w=t.clone().multiply(s).multiply(n),x=new c.Matrix4;x.extractRotation(f);const _=new c.Matrix4;_.copyPosition(f);const S=_.clone().invert().multiply(f),C=x.clone().invert().multiply(S),v=i,y=new c.Matrix4;if(g===0)y.copy(x).multiply(w).multiply(C).multiply(v);else if(g===1)y.copy(x).multiply(C).multiply(w).multiply(v);else{const U=new c.Matrix4().scale(new c.Vector3().setFromMatrixScale(p)).clone().invert(),R=C.clone().multiply(U);y.copy(x).multiply(w).multiply(R).multiply(v)}const M=h.clone().invert(),P=o.clone().invert();let A=e.clone().multiply(a).multiply(h).multiply(t).multiply(s).multiply(n).multiply(M).multiply(r).multiply(o).multiply(i).multiply(P);const b=new c.Matrix4().copyPosition(A),D=f.clone().multiply(b);return m.copyPosition(D),A=m.clone().multiply(y),A.premultiply(f.invert()),A}function Hs(l){l=l||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return l===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[l]}function os(l){return l.split(",").map(function(t){return parseFloat(t)})}function $s(l,e,t){return e===void 0&&(e=0),t===void 0&&(t=l.byteLength),c.LoaderUtils.decodeText(new Uint8Array(l,e,t))}function ho(l,e){for(let t=0,s=l.length,n=e.length;t<n;t++,s++)l[s]=e[t]}function uo(l,e,t,s){for(let n=t,i=0;n<s;n++,i++)l[i]=e[n];return l}function en(l,e,t){return l.slice(0,e).concat(t).concat(l.slice(e))}var po=Object.defineProperty,fo=(l,e,t)=>e in l?po(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,rs=(l,e,t)=>(fo(l,typeof e!="symbol"?e+"":e,t),t);class mo extends c.Loader{constructor(e){super(e)}load(e,t,s,n){const i=new c.FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,o=>{if(typeof o!="string")throw new Error("unsupported data type");const r=JSON.parse(o),a=this.parse(r);t&&t(a)},s,n)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new as(e)}}class as{constructor(e){rs(this,"data"),this.data=e}generateShapes(e,t=100,s){const n=[],i={letterSpacing:0,lineHeight:1,...s},o=go(e,t,this.data,i);for(let r=0,a=o.length;r<a;r++)Array.prototype.push.apply(n,o[r].toShapes(!1));return n}}rs(as,"isFont"),rs(as,"type");function go(l,e,t,s){const n=Array.from(l),i=e/t.resolution,o=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,r=[];let a=0,h=0;for(let f=0;f<n.length;f++){const p=n[f];if(p===`
74
- `)a=0,h-=o*s.lineHeight;else{const m=yo(p,i,a,h,t);m&&(a+=m.offsetX+s.letterSpacing,r.push(m.path))}}return r}function yo(l,e,t,s,n){const i=n.glyphs[l]||n.glyphs["?"];if(!i){console.error('THREE.Font: character "'+l+'" does not exists in font family '+n.familyName+".");return}const o=new c.ShapePath;let r,a,h,f,p,m,g,w;if(i.o){const x=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let _=0,S=x.length;_<S;)switch(x[_++]){case"m":r=parseInt(x[_++])*e+t,a=parseInt(x[_++])*e+s,o.moveTo(r,a);break;case"l":r=parseInt(x[_++])*e+t,a=parseInt(x[_++])*e+s,o.lineTo(r,a);break;case"q":h=parseInt(x[_++])*e+t,f=parseInt(x[_++])*e+s,p=parseInt(x[_++])*e+t,m=parseInt(x[_++])*e+s,o.quadraticCurveTo(p,m,h,f);break;case"b":h=parseInt(x[_++])*e+t,f=parseInt(x[_++])*e+s,p=parseInt(x[_++])*e+t,m=parseInt(x[_++])*e+s,g=parseInt(x[_++])*e+t,w=parseInt(x[_++])*e+s,o.bezierCurveTo(p,m,g,w,h,f);break}}return{offsetX:i.ha*e,path:o}}var _o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xo(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}class wo extends c.DataTextureLoader{constructor(e){super(e),this.type=c.HalfFloatType}parse(e){const r=function(v,y){switch(v){case 1:console.error("THREE.RGBELoader Read Error: "+(y||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(y||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(y||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(y||""))}return-1},p=`
75
- `,m=function(v,y,M){y=y||1024;let A=v.pos,b=-1,D=0,z="",U=String.fromCharCode.apply(null,new Uint16Array(v.subarray(A,A+128)));for(;0>(b=U.indexOf(p))&&D<y&&A<v.byteLength;)z+=U,D+=U.length,A+=128,U+=String.fromCharCode.apply(null,new Uint16Array(v.subarray(A,A+128)));return-1<b?(M!==!1&&(v.pos+=D+b+1),z+U.slice(0,b)):!1},g=function(v){const y=/^#\?(\S+)/,M=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,P=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,A=/^\s*FORMAT=(\S+)\s*$/,b=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,D={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let z,U;if(v.pos>=v.byteLength||!(z=m(v)))return r(1,"no header found");if(!(U=z.match(y)))return r(3,"bad initial token");for(D.valid|=1,D.programtype=U[1],D.string+=z+`
76
- `;z=m(v),z!==!1;){if(D.string+=z+`
77
- `,z.charAt(0)==="#"){D.comments+=z+`
78
- `;continue}if((U=z.match(M))&&(D.gamma=parseFloat(U[1])),(U=z.match(P))&&(D.exposure=parseFloat(U[1])),(U=z.match(A))&&(D.valid|=2,D.format=U[1]),(U=z.match(b))&&(D.valid|=4,D.height=parseInt(U[1],10),D.width=parseInt(U[2],10)),D.valid&2&&D.valid&4)break}return D.valid&2?D.valid&4?D:r(3,"missing image size specifier"):r(3,"missing format specifier")},w=function(v,y,M){const P=y;if(P<8||P>32767||v[0]!==2||v[1]!==2||v[2]&128)return new Uint8Array(v);if(P!==(v[2]<<8|v[3]))return r(3,"wrong scanline width");const A=new Uint8Array(4*y*M);if(!A.length)return r(4,"unable to allocate buffer space");let b=0,D=0;const z=4*P,U=new Uint8Array(4),R=new Uint8Array(z);let K=M;for(;K>0&&D<v.byteLength;){if(D+4>v.byteLength)return r(1);if(U[0]=v[D++],U[1]=v[D++],U[2]=v[D++],U[3]=v[D++],U[0]!=2||U[1]!=2||(U[2]<<8|U[3])!=P)return r(3,"bad rgbe scanline format");let Z=0,W;for(;Z<z&&D<v.byteLength;){W=v[D++];const Q=W>128;if(Q&&(W-=128),W===0||Z+W>z)return r(3,"bad scanline data");if(Q){const G=v[D++];for(let ce=0;ce<W;ce++)R[Z++]=G}else R.set(v.subarray(D,D+W),Z),Z+=W,D+=W}const pe=P;for(let Q=0;Q<pe;Q++){let G=0;A[b]=R[Q+G],G+=P,A[b+1]=R[Q+G],G+=P,A[b+2]=R[Q+G],G+=P,A[b+3]=R[Q+G],b+=4}K--}return A},x=function(v,y,M,P){const A=v[y+3],b=Math.pow(2,A-128)/255;M[P+0]=v[y+0]*b,M[P+1]=v[y+1]*b,M[P+2]=v[y+2]*b,M[P+3]=1},_=function(v,y,M,P){const A=v[y+3],b=Math.pow(2,A-128)/255;M[P+0]=c.DataUtils.toHalfFloat(Math.min(v[y+0]*b,65504)),M[P+1]=c.DataUtils.toHalfFloat(Math.min(v[y+1]*b,65504)),M[P+2]=c.DataUtils.toHalfFloat(Math.min(v[y+2]*b,65504)),M[P+3]=c.DataUtils.toHalfFloat(1)},S=new Uint8Array(e);S.pos=0;const C=g(S);if(C!==-1){const v=C.width,y=C.height,M=w(S.subarray(S.pos),v,y);if(M!==-1){let P,A,b;switch(this.type){case c.FloatType:b=M.length/4;const D=new Float32Array(b*4);for(let U=0;U<b;U++)x(M,U*4,D,U*4);P=D,A=c.FloatType;break;case c.HalfFloatType:b=M.length/4;const z=new Uint16Array(b*4);for(let U=0;U<b;U++)_(M,U*4,z,U*4);P=z,A=c.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:v,height:y,data:P,header:C.string,gamma:C.gamma,exposure:C.exposure,type:A}}}return null}setDataType(e){return this.type=e,this}load(e,t,s,n){function i(o,r){switch(o.type){case c.FloatType:case c.HalfFloatType:"colorSpace"in o?o.colorSpace="srgb-linear":o.encoding=3e3,o.minFilter=c.LinearFilter,o.magFilter=c.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,r)}return super.load(e,i,s,n)}}class wt extends c.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,s,n){const i=this,o=new c.FileLoader(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,function(r){try{t(i.parse(r))}catch(a){n?n(a):console.error(a),i.manager.itemError(e)}},s,n)}parse(e){const t=this;function s(B,I){if(B.nodeType!==1)return;const d=y(B);let k=!0,E=null;switch(B.nodeName){case"svg":break;case"style":i(B);break;case"g":I=w(B,I);break;case"path":I=w(B,I),B.hasAttribute("d")&&(E=n(B));break;case"rect":I=w(B,I),E=a(B);break;case"polygon":I=w(B,I),E=h(B);break;case"polyline":I=w(B,I),E=f(B);break;case"circle":I=w(B,I),E=p(B);break;case"ellipse":I=w(B,I),E=m(B);break;case"line":I=w(B,I),E=g(B);break;case"defs":k=!1;break;case"mask":k=!1;break;case"use":I=w(B,I);const L=B.href.baseVal.substring(1),j=B.viewportElement.getElementById(L);j?s(j,I):console.warn("SVGLoader: 'use node' references non-existent node id: "+L);break}if(E&&(I.fill!==void 0&&I.fill!=="none"&&E.color.setStyle(I.fill),P(E,ce),z.push(E),E.userData={node:B,style:I}),k){const L=B.childNodes;for(let j=0;j<L.length;j++)s(L[j],I)}d&&(R.pop(),R.length>0?ce.copy(R[R.length-1]):ce.identity())}function n(B){const I=new c.ShapePath,d=new c.Vector2,k=new c.Vector2,E=new c.Vector2;let L=!0,j=!1;const ee=B.getAttribute("d").match(/[a-df-z][^a-df-z]*/gi);for(let te=0,J=ee.length;te<J;te++){const ge=ee[te],Y=ge.charAt(0),H=ge.substr(1).trim();L===!0&&(j=!0,L=!1);let O;switch(Y){case"M":O=_(H);for(let T=0,$=O.length;T<$;T+=2)d.x=O[T+0],d.y=O[T+1],k.x=d.x,k.y=d.y,T===0?I.moveTo(d.x,d.y):I.lineTo(d.x,d.y),T===0&&E.copy(d);break;case"H":O=_(H);for(let T=0,$=O.length;T<$;T++)d.x=O[T],k.x=d.x,k.y=d.y,I.lineTo(d.x,d.y),T===0&&j===!0&&E.copy(d);break;case"V":O=_(H);for(let T=0,$=O.length;T<$;T++)d.y=O[T],k.x=d.x,k.y=d.y,I.lineTo(d.x,d.y),T===0&&j===!0&&E.copy(d);break;case"L":O=_(H);for(let T=0,$=O.length;T<$;T+=2)d.x=O[T+0],d.y=O[T+1],k.x=d.x,k.y=d.y,I.lineTo(d.x,d.y),T===0&&j===!0&&E.copy(d);break;case"C":O=_(H);for(let T=0,$=O.length;T<$;T+=6)I.bezierCurveTo(O[T+0],O[T+1],O[T+2],O[T+3],O[T+4],O[T+5]),k.x=O[T+2],k.y=O[T+3],d.x=O[T+4],d.y=O[T+5],T===0&&j===!0&&E.copy(d);break;case"S":O=_(H);for(let T=0,$=O.length;T<$;T+=4)I.bezierCurveTo(x(d.x,k.x),x(d.y,k.y),O[T+0],O[T+1],O[T+2],O[T+3]),k.x=O[T+0],k.y=O[T+1],d.x=O[T+2],d.y=O[T+3],T===0&&j===!0&&E.copy(d);break;case"Q":O=_(H);for(let T=0,$=O.length;T<$;T+=4)I.quadraticCurveTo(O[T+0],O[T+1],O[T+2],O[T+3]),k.x=O[T+0],k.y=O[T+1],d.x=O[T+2],d.y=O[T+3],T===0&&j===!0&&E.copy(d);break;case"T":O=_(H);for(let T=0,$=O.length;T<$;T+=2){const de=x(d.x,k.x),be=x(d.y,k.y);I.quadraticCurveTo(de,be,O[T+0],O[T+1]),k.x=de,k.y=be,d.x=O[T+0],d.y=O[T+1],T===0&&j===!0&&E.copy(d)}break;case"A":O=_(H,[3,4],7);for(let T=0,$=O.length;T<$;T+=7){if(O[T+5]==d.x&&O[T+6]==d.y)continue;const de=d.clone();d.x=O[T+5],d.y=O[T+6],k.x=d.x,k.y=d.y,o(I,O[T],O[T+1],O[T+2],O[T+3],O[T+4],de,d),T===0&&j===!0&&E.copy(d)}break;case"m":O=_(H);for(let T=0,$=O.length;T<$;T+=2)d.x+=O[T+0],d.y+=O[T+1],k.x=d.x,k.y=d.y,T===0?I.moveTo(d.x,d.y):I.lineTo(d.x,d.y),T===0&&E.copy(d);break;case"h":O=_(H);for(let T=0,$=O.length;T<$;T++)d.x+=O[T],k.x=d.x,k.y=d.y,I.lineTo(d.x,d.y),T===0&&j===!0&&E.copy(d);break;case"v":O=_(H);for(let T=0,$=O.length;T<$;T++)d.y+=O[T],k.x=d.x,k.y=d.y,I.lineTo(d.x,d.y),T===0&&j===!0&&E.copy(d);break;case"l":O=_(H);for(let T=0,$=O.length;T<$;T+=2)d.x+=O[T+0],d.y+=O[T+1],k.x=d.x,k.y=d.y,I.lineTo(d.x,d.y),T===0&&j===!0&&E.copy(d);break;case"c":O=_(H);for(let T=0,$=O.length;T<$;T+=6)I.bezierCurveTo(d.x+O[T+0],d.y+O[T+1],d.x+O[T+2],d.y+O[T+3],d.x+O[T+4],d.y+O[T+5]),k.x=d.x+O[T+2],k.y=d.y+O[T+3],d.x+=O[T+4],d.y+=O[T+5],T===0&&j===!0&&E.copy(d);break;case"s":O=_(H);for(let T=0,$=O.length;T<$;T+=4)I.bezierCurveTo(x(d.x,k.x),x(d.y,k.y),d.x+O[T+0],d.y+O[T+1],d.x+O[T+2],d.y+O[T+3]),k.x=d.x+O[T+0],k.y=d.y+O[T+1],d.x+=O[T+2],d.y+=O[T+3],T===0&&j===!0&&E.copy(d);break;case"q":O=_(H);for(let T=0,$=O.length;T<$;T+=4)I.quadraticCurveTo(d.x+O[T+0],d.y+O[T+1],d.x+O[T+2],d.y+O[T+3]),k.x=d.x+O[T+0],k.y=d.y+O[T+1],d.x+=O[T+2],d.y+=O[T+3],T===0&&j===!0&&E.copy(d);break;case"t":O=_(H);for(let T=0,$=O.length;T<$;T+=2){const de=x(d.x,k.x),be=x(d.y,k.y);I.quadraticCurveTo(de,be,d.x+O[T+0],d.y+O[T+1]),k.x=de,k.y=be,d.x=d.x+O[T+0],d.y=d.y+O[T+1],T===0&&j===!0&&E.copy(d)}break;case"a":O=_(H,[3,4],7);for(let T=0,$=O.length;T<$;T+=7){if(O[T+5]==0&&O[T+6]==0)continue;const de=d.clone();d.x+=O[T+5],d.y+=O[T+6],k.x=d.x,k.y=d.y,o(I,O[T],O[T+1],O[T+2],O[T+3],O[T+4],de,d),T===0&&j===!0&&E.copy(d)}break;case"Z":case"z":I.currentPath.autoClose=!0,I.currentPath.curves.length>0&&(d.copy(E),I.currentPath.currentPoint.copy(d),L=!0);break;default:console.warn(ge)}j=!1}return I}function i(B){if(!(!B.sheet||!B.sheet.cssRules||!B.sheet.cssRules.length))for(let I=0;I<B.sheet.cssRules.length;I++){const d=B.sheet.cssRules[I];if(d.type!==1)continue;const k=d.selectorText.split(/,/gm).filter(Boolean).map(E=>E.trim());for(let E=0;E<k.length;E++)U[k[E]]=Object.assign(U[k[E]]||{},d.style)}}function o(B,I,d,k,E,L,j,ie){if(I==0||d==0){B.lineTo(ie.x,ie.y);return}k=k*Math.PI/180,I=Math.abs(I),d=Math.abs(d);const ee=(j.x-ie.x)/2,te=(j.y-ie.y)/2,J=Math.cos(k)*ee+Math.sin(k)*te,ge=-Math.sin(k)*ee+Math.cos(k)*te;let Y=I*I,H=d*d;const O=J*J,T=ge*ge,$=O/Y+T/H;if($>1){const Zt=Math.sqrt($);I=Zt*I,d=Zt*d,Y=I*I,H=d*d}const de=Y*T+H*O,be=(Y*H-de)/de;let Te=Math.sqrt(Math.max(0,be));E===L&&(Te=-Te);const Ue=Te*I*ge/d,$e=-Te*d*J/I,Ot=Math.cos(k)*Ue-Math.sin(k)*$e+(j.x+ie.x)/2,Ts=Math.sin(k)*Ue+Math.cos(k)*$e+(j.y+ie.y)/2,Xt=r(1,0,(J-Ue)/I,(ge-$e)/d),Yt=r((J-Ue)/I,(ge-$e)/d,(-J-Ue)/I,(-ge-$e)/d)%(Math.PI*2);B.currentPath.absellipse(Ot,Ts,I,d,Xt,Xt+Yt,L===0,k)}function r(B,I,d,k){const E=B*d+I*k,L=Math.sqrt(B*B+I*I)*Math.sqrt(d*d+k*k);let j=Math.acos(Math.max(-1,Math.min(1,E/L)));return B*k-I*d<0&&(j=-j),j}function a(B){const I=v(B.getAttribute("x")||0),d=v(B.getAttribute("y")||0),k=v(B.getAttribute("rx")||B.getAttribute("ry")||0),E=v(B.getAttribute("ry")||B.getAttribute("rx")||0),L=v(B.getAttribute("width")),j=v(B.getAttribute("height")),ie=1-.551915024494,ee=new c.ShapePath;return ee.moveTo(I+k,d),ee.lineTo(I+L-k,d),(k!==0||E!==0)&&ee.bezierCurveTo(I+L-k*ie,d,I+L,d+E*ie,I+L,d+E),ee.lineTo(I+L,d+j-E),(k!==0||E!==0)&&ee.bezierCurveTo(I+L,d+j-E*ie,I+L-k*ie,d+j,I+L-k,d+j),ee.lineTo(I+k,d+j),(k!==0||E!==0)&&ee.bezierCurveTo(I+k*ie,d+j,I,d+j-E*ie,I,d+j-E),ee.lineTo(I,d+E),(k!==0||E!==0)&&ee.bezierCurveTo(I,d+E*ie,I+k*ie,d,I+k,d),ee}function h(B){function I(L,j,ie){const ee=v(j),te=v(ie);E===0?k.moveTo(ee,te):k.lineTo(ee,te),E++}const d=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,k=new c.ShapePath;let E=0;return B.getAttribute("points").replace(d,I),k.currentPath.autoClose=!0,k}function f(B){function I(L,j,ie){const ee=v(j),te=v(ie);E===0?k.moveTo(ee,te):k.lineTo(ee,te),E++}const d=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,k=new c.ShapePath;let E=0;return B.getAttribute("points").replace(d,I),k.currentPath.autoClose=!1,k}function p(B){const I=v(B.getAttribute("cx")||0),d=v(B.getAttribute("cy")||0),k=v(B.getAttribute("r")||0),E=new c.Path;E.absarc(I,d,k,0,Math.PI*2);const L=new c.ShapePath;return L.subPaths.push(E),L}function m(B){const I=v(B.getAttribute("cx")||0),d=v(B.getAttribute("cy")||0),k=v(B.getAttribute("rx")||0),E=v(B.getAttribute("ry")||0),L=new c.Path;L.absellipse(I,d,k,E,0,Math.PI*2);const j=new c.ShapePath;return j.subPaths.push(L),j}function g(B){const I=v(B.getAttribute("x1")||0),d=v(B.getAttribute("y1")||0),k=v(B.getAttribute("x2")||0),E=v(B.getAttribute("y2")||0),L=new c.ShapePath;return L.moveTo(I,d),L.lineTo(k,E),L.currentPath.autoClose=!1,L}function w(B,I){I=Object.assign({},I);let d={};if(B.hasAttribute("class")){const j=B.getAttribute("class").split(/\s/).filter(Boolean).map(ie=>ie.trim());for(let ie=0;ie<j.length;ie++)d=Object.assign(d,U["."+j[ie]])}B.hasAttribute("id")&&(d=Object.assign(d,U["#"+B.getAttribute("id")]));function k(j,ie,ee){ee===void 0&&(ee=function(J){return J.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),J}),B.hasAttribute(j)&&(I[ie]=ee(B.getAttribute(j))),d[j]&&(I[ie]=ee(d[j])),B.style&&B.style[j]!==""&&(I[ie]=ee(B.style[j]))}function E(j){return Math.max(0,Math.min(1,v(j)))}function L(j){return Math.max(0,v(j))}return k("fill","fill"),k("fill-opacity","fillOpacity",E),k("fill-rule","fillRule"),k("opacity","opacity",E),k("stroke","stroke"),k("stroke-opacity","strokeOpacity",E),k("stroke-width","strokeWidth",L),k("stroke-linejoin","strokeLineJoin"),k("stroke-linecap","strokeLineCap"),k("stroke-miterlimit","strokeMiterLimit",L),k("visibility","visibility"),I}function x(B,I){return B-(I-B)}function _(B,I,d){if(typeof B!="string")throw new TypeError("Invalid input: "+typeof B);const k={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},E=0,L=1,j=2,ie=3;let ee=E,te=!0,J="",ge="";const Y=[];function H(de,be,Te){const Ue=new SyntaxError('Unexpected character "'+de+'" at index '+be+".");throw Ue.partial=Te,Ue}function O(){J!==""&&(ge===""?Y.push(Number(J)):Y.push(Number(J)*Math.pow(10,Number(ge)))),J="",ge=""}let T;const $=B.length;for(let de=0;de<$;de++){if(T=B[de],Array.isArray(I)&&I.includes(Y.length%d)&&k.FLAGS.test(T)){ee=L,J=T,O();continue}if(ee===E){if(k.WHITESPACE.test(T))continue;if(k.DIGIT.test(T)||k.SIGN.test(T)){ee=L,J=T;continue}if(k.POINT.test(T)){ee=j,J=T;continue}k.COMMA.test(T)&&(te&&H(T,de,Y),te=!0)}if(ee===L){if(k.DIGIT.test(T)){J+=T;continue}if(k.POINT.test(T)){J+=T,ee=j;continue}if(k.EXP.test(T)){ee=ie;continue}k.SIGN.test(T)&&J.length===1&&k.SIGN.test(J[0])&&H(T,de,Y)}if(ee===j){if(k.DIGIT.test(T)){J+=T;continue}if(k.EXP.test(T)){ee=ie;continue}k.POINT.test(T)&&J[J.length-1]==="."&&H(T,de,Y)}if(ee===ie){if(k.DIGIT.test(T)){ge+=T;continue}if(k.SIGN.test(T)){if(ge===""){ge+=T;continue}ge.length===1&&k.SIGN.test(ge)&&H(T,de,Y)}}k.WHITESPACE.test(T)?(O(),ee=E,te=!1):k.COMMA.test(T)?(O(),ee=E,te=!0):k.SIGN.test(T)?(O(),ee=L,J=T):k.POINT.test(T)?(O(),ee=j,J=T):H(T,de,Y)}return O(),Y}const S=["mm","cm","in","pt","pc","px"],C={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 v(B){let I="px";if(typeof B=="string"||B instanceof String)for(let k=0,E=S.length;k<E;k++){const L=S[k];if(B.endsWith(L)){I=L,B=B.substring(0,B.length-L.length);break}}let d;return I==="px"&&t.defaultUnit!=="px"?d=C.in[t.defaultUnit]/t.defaultDPI:(d=C[I][t.defaultUnit],d<0&&(d=C[I].in*t.defaultDPI)),d*parseFloat(B)}function y(B){if(!(B.hasAttribute("transform")||B.nodeName==="use"&&(B.hasAttribute("x")||B.hasAttribute("y"))))return null;const I=M(B);return R.length>0&&I.premultiply(R[R.length-1]),ce.copy(I),R.push(I),I}function M(B){const I=new c.Matrix3,d=K;if(B.nodeName==="use"&&(B.hasAttribute("x")||B.hasAttribute("y"))){const k=v(B.getAttribute("x")),E=v(B.getAttribute("y"));I.translate(k,E)}if(B.hasAttribute("transform")){const k=B.getAttribute("transform").split(")");for(let E=k.length-1;E>=0;E--){const L=k[E].trim();if(L==="")continue;const j=L.indexOf("("),ie=L.length;if(j>0&&j<ie){const ee=L.substr(0,j),te=_(L.substr(j+1,ie-j-1));switch(d.identity(),ee){case"translate":if(te.length>=1){const J=te[0];let ge=J;te.length>=2&&(ge=te[1]),d.translate(J,ge)}break;case"rotate":if(te.length>=1){let J=0,ge=0,Y=0;J=-te[0]*Math.PI/180,te.length>=3&&(ge=te[1],Y=te[2]),Z.identity().translate(-ge,-Y),W.identity().rotate(J),pe.multiplyMatrices(W,Z),Z.identity().translate(ge,Y),d.multiplyMatrices(Z,pe)}break;case"scale":if(te.length>=1){const J=te[0];let ge=J;te.length>=2&&(ge=te[1]),d.scale(J,ge)}break;case"skewX":te.length===1&&d.set(1,Math.tan(te[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":te.length===1&&d.set(1,0,0,Math.tan(te[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":te.length===6&&d.set(te[0],te[2],te[4],te[1],te[3],te[5],0,0,1);break}}I.premultiply(d)}}return I}function P(B,I){function d(L){G.set(L.x,L.y,1).applyMatrix3(I),L.set(G.x,G.y)}const k=A(I),E=B.subPaths;for(let L=0,j=E.length;L<j;L++){const ee=E[L].curves;for(let te=0;te<ee.length;te++){const J=ee[te];J.isLineCurve?(d(J.v1),d(J.v2)):J.isCubicBezierCurve?(d(J.v0),d(J.v1),d(J.v2),d(J.v3)):J.isQuadraticBezierCurve?(d(J.v0),d(J.v1),d(J.v2)):J.isEllipseCurve&&(k&&console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented."),Q.set(J.aX,J.aY),d(Q),J.aX=Q.x,J.aY=Q.y,J.xRadius*=b(I),J.yRadius*=D(I))}}}function A(B){return B.elements[1]!==0||B.elements[3]!==0}function b(B){const I=B.elements;return Math.sqrt(I[0]*I[0]+I[1]*I[1])}function D(B){const I=B.elements;return Math.sqrt(I[3]*I[3]+I[4]*I[4])}const z=[],U={},R=[],K=new c.Matrix3,Z=new c.Matrix3,W=new c.Matrix3,pe=new c.Matrix3,Q=new c.Vector2,G=new c.Vector3,ce=new c.Matrix3,se=new DOMParser().parseFromString(e,"image/svg+xml");return s(se.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:z,xml:se.documentElement}}static createShapes(e){const s={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},n={loc:s.ORIGIN,t:0};function i(_,S,C,v){const y=_.x,M=S.x,P=C.x,A=v.x,b=_.y,D=S.y,z=C.y,U=v.y,R=(A-P)*(b-z)-(U-z)*(y-P),K=(M-y)*(b-z)-(D-b)*(y-P),Z=(U-z)*(M-y)-(A-P)*(D-b),W=R/Z,pe=K/Z;if(Z===0&&R!==0||W<=0||W>=1||pe<0||pe>1)return null;if(R===0&&Z===0){for(let Q=0;Q<2;Q++)if(o(Q===0?C:v,_,S),n.loc==s.ORIGIN){const G=Q===0?C:v;return{x:G.x,y:G.y,t:n.t}}else if(n.loc==s.BETWEEN){const G=+(y+n.t*(M-y)).toPrecision(10),ce=+(b+n.t*(D-b)).toPrecision(10);return{x:G,y:ce,t:n.t}}return null}else{for(let ce=0;ce<2;ce++)if(o(ce===0?C:v,_,S),n.loc==s.ORIGIN){const se=ce===0?C:v;return{x:se.x,y:se.y,t:n.t}}const Q=+(y+W*(M-y)).toPrecision(10),G=+(b+W*(D-b)).toPrecision(10);return{x:Q,y:G,t:W}}}function o(_,S,C){const v=C.x-S.x,y=C.y-S.y,M=_.x-S.x,P=_.y-S.y,A=v*P-M*y;if(_.x===S.x&&_.y===S.y){n.loc=s.ORIGIN,n.t=0;return}if(_.x===C.x&&_.y===C.y){n.loc=s.DESTINATION,n.t=1;return}if(A<-Number.EPSILON){n.loc=s.LEFT;return}if(A>Number.EPSILON){n.loc=s.RIGHT;return}if(v*M<0||y*P<0){n.loc=s.BEHIND;return}if(Math.sqrt(v*v+y*y)<Math.sqrt(M*M+P*P)){n.loc=s.BEYOND;return}let b;v!==0?b=M/v:b=P/y,n.loc=s.BETWEEN,n.t=b}function r(_,S){const C=[],v=[];for(let y=1;y<_.length;y++){const M=_[y-1],P=_[y];for(let A=1;A<S.length;A++){const b=S[A-1],D=S[A],z=i(M,P,b,D);z!==null&&C.find(U=>U.t<=z.t+Number.EPSILON&&U.t>=z.t-Number.EPSILON)===void 0&&(C.push(z),v.push(new c.Vector2(z.x,z.y)))}}return v}function a(_,S,C){const v=new c.Vector2;S.getCenter(v);const y=[];return C.forEach(M=>{M.boundingBox.containsPoint(v)&&r(_,M.points).forEach(A=>{y.push({identifier:M.identifier,isCW:M.isCW,point:A})})}),y.sort((M,P)=>M.point.x-P.point.x),y}function h(_,S,C,v,y){(y==null||y==="")&&(y="nonzero");const M=new c.Vector2;_.boundingBox.getCenter(M);const P=[new c.Vector2(C,M.y),new c.Vector2(v,M.y)],A=a(P,_.boundingBox,S);A.sort((K,Z)=>K.point.x-Z.point.x);const b=[],D=[];A.forEach(K=>{K.identifier===_.identifier?b.push(K):D.push(K)});const z=b[0].point.x,U=[];let R=0;for(;R<D.length&&D[R].point.x<z;)U.length>0&&U[U.length-1]===D[R].identifier?U.pop():U.push(D[R].identifier),R++;if(U.push(_.identifier),y==="evenodd"){const K=U.length%2===0,Z=U[U.length-2];return{identifier:_.identifier,isHole:K,for:Z}}else if(y==="nonzero"){let K=!0,Z=null,W=null;for(let pe=0;pe<U.length;pe++){const Q=U[pe];K?(W=S[Q].isCW,K=!1,Z=Q):W!==S[Q].isCW&&(W=S[Q].isCW,K=!0)}return{identifier:_.identifier,isHole:K,for:Z}}else console.warn('fill-rule: "'+y+'" is currently not implemented.')}let f=0,p=999999999,m=-999999999,g=e.subPaths.map(_=>{const S=_.getPoints();let C=-999999999,v=999999999,y=-999999999,M=999999999;for(let P=0;P<S.length;P++){const A=S[P];A.y>C&&(C=A.y),A.y<v&&(v=A.y),A.x>y&&(y=A.x),A.x<M&&(M=A.x)}return m<=y&&(m=y+1),p>=M&&(p=M-1),{curves:_.curves,points:S,isCW:c.ShapeUtils.isClockWise(S),identifier:f++,boundingBox:new c.Box2(new c.Vector2(M,v),new c.Vector2(y,C))}});g=g.filter(_=>_.points.length>1);const w=g.map(_=>h(_,g,p,m,e.userData.style.fillRule)),x=[];return g.forEach(_=>{if(!w[_.identifier].isHole){const C=new c.Shape;C.curves=_.curves,w.filter(y=>y.isHole&&y.for===_.identifier).forEach(y=>{const M=g[y.identifier],P=new c.Path;P.curves=M.curves,C.holes.push(P)}),x.push(C)}}),x}static getStrokeStyle(e,t,s,n,i){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",s=s!==void 0?s:"miter",n=n!==void 0?n:"butt",i=i!==void 0?i:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:s,strokeLineCap:n,strokeMiterLimit:i}}static pointsToStroke(e,t,s,n){const i=[],o=[],r=[];if(wt.pointsToStrokeWithBuffers(e,t,s,n,i,o,r)===0)return null;const a=new c.BufferGeometry;return a.setAttribute("position",new c.Float32BufferAttribute(i,3)),a.setAttribute("normal",new c.Float32BufferAttribute(o,3)),a.setAttribute("uv",new c.Float32BufferAttribute(r,2)),a}static pointsToStrokeWithBuffers(e,t,s,n,i,o,r,a){const h=new c.Vector2,f=new c.Vector2,p=new c.Vector2,m=new c.Vector2,g=new c.Vector2,w=new c.Vector2,x=new c.Vector2,_=new c.Vector2,S=new c.Vector2,C=new c.Vector2,v=new c.Vector2,y=new c.Vector2,M=new c.Vector2,P=new c.Vector2,A=new c.Vector2,b=new c.Vector2,D=new c.Vector2;s=s!==void 0?s:12,n=n!==void 0?n:.001,a=a!==void 0?a:0,e=ge(e);const z=e.length;if(z<2)return 0;const U=e[0].equals(e[z-1]);let R,K=e[0],Z;const W=t.strokeWidth/2,pe=1/(z-1);let Q=0,G,ce,se,ae,B=!1,I=0,d=a*3,k=a*2;E(e[0],e[1],h).multiplyScalar(W),_.copy(e[0]).sub(h),S.copy(e[0]).add(h),C.copy(_),v.copy(S);for(let Y=1;Y<z;Y++){R=e[Y],Y===z-1?U?Z=e[1]:Z=void 0:Z=e[Y+1];const H=h;if(E(K,R,H),p.copy(H).multiplyScalar(W),y.copy(R).sub(p),M.copy(R).add(p),G=Q+pe,ce=!1,Z!==void 0){E(R,Z,f),p.copy(f).multiplyScalar(W),P.copy(R).sub(p),A.copy(R).add(p),se=!0,p.subVectors(Z,K),H.dot(p)<0&&(se=!1),Y===1&&(B=se),p.subVectors(Z,R),p.normalize();const O=Math.abs(H.dot(p));if(O!==0){const T=W/O;p.multiplyScalar(-T),m.subVectors(R,K),g.copy(m).setLength(T).add(p),b.copy(g).negate();const $=g.length(),de=m.length();m.divideScalar(de),w.subVectors(Z,R);const be=w.length();switch(w.divideScalar(be),m.dot(b)<de&&w.dot(b)<be&&(ce=!0),D.copy(g).add(R),b.add(R),ae=!1,ce?se?(A.copy(b),M.copy(b)):(P.copy(b),y.copy(b)):ie(),t.strokeLineJoin){case"bevel":ee(se,ce,G);break;case"round":te(se,ce),se?j(R,y,P,G,0):j(R,A,M,G,1);break;case"miter":case"miter-clip":default:const Te=W*t.strokeMiterLimit/$;if(Te<1)if(t.strokeLineJoin!=="miter-clip"){ee(se,ce,G);break}else te(se,ce),se?(w.subVectors(D,y).multiplyScalar(Te).add(y),x.subVectors(D,P).multiplyScalar(Te).add(P),L(y,G,0),L(w,G,0),L(R,G,.5),L(R,G,.5),L(w,G,0),L(x,G,0),L(R,G,.5),L(x,G,0),L(P,G,0)):(w.subVectors(D,M).multiplyScalar(Te).add(M),x.subVectors(D,A).multiplyScalar(Te).add(A),L(M,G,1),L(w,G,1),L(R,G,.5),L(R,G,.5),L(w,G,1),L(x,G,1),L(R,G,.5),L(x,G,1),L(A,G,1));else ce?(se?(L(S,Q,1),L(_,Q,0),L(D,G,0),L(S,Q,1),L(D,G,0),L(b,G,1)):(L(S,Q,1),L(_,Q,0),L(D,G,1),L(_,Q,0),L(b,G,0),L(D,G,1)),se?P.copy(D):A.copy(D)):se?(L(y,G,0),L(D,G,0),L(R,G,.5),L(R,G,.5),L(D,G,0),L(P,G,0)):(L(M,G,1),L(D,G,1),L(R,G,.5),L(R,G,.5),L(D,G,1),L(A,G,1)),ae=!0;break}}else ie()}else ie();!U&&Y===z-1&&J(e[0],C,v,se,!0,Q),Q=G,K=R,_.copy(P),S.copy(A)}if(!U)J(R,y,M,se,!1,G);else if(ce&&i){let Y=D,H=b;B!==se&&(Y=b,H=D),se?(ae||B)&&(H.toArray(i,0*3),H.toArray(i,3*3),ae&&Y.toArray(i,1*3)):(ae||!B)&&(H.toArray(i,1*3),H.toArray(i,3*3),ae&&Y.toArray(i,0*3))}return I;function E(Y,H,O){return O.subVectors(H,Y),O.set(-O.y,O.x).normalize()}function L(Y,H,O){i&&(i[d]=Y.x,i[d+1]=Y.y,i[d+2]=0,o&&(o[d]=0,o[d+1]=0,o[d+2]=1),d+=3,r&&(r[k]=H,r[k+1]=O,k+=2)),I+=3}function j(Y,H,O,T,$){h.copy(H).sub(Y).normalize(),f.copy(O).sub(Y).normalize();let de=Math.PI;const be=h.dot(f);Math.abs(be)<1&&(de=Math.abs(Math.acos(be))),de/=s,p.copy(H);for(let Te=0,Ue=s-1;Te<Ue;Te++)m.copy(p).rotateAround(Y,de),L(p,T,$),L(m,T,$),L(Y,T,.5),p.copy(m);L(m,T,$),L(O,T,$),L(Y,T,.5)}function ie(){L(S,Q,1),L(_,Q,0),L(y,G,0),L(S,Q,1),L(y,G,1),L(M,G,0)}function ee(Y,H,O){H?Y?(L(S,Q,1),L(_,Q,0),L(y,G,0),L(S,Q,1),L(y,G,0),L(b,G,1),L(y,O,0),L(P,O,0),L(b,O,.5)):(L(S,Q,1),L(_,Q,0),L(M,G,1),L(_,Q,0),L(b,G,0),L(M,G,1),L(M,O,1),L(A,O,0),L(b,O,.5)):Y?(L(y,O,0),L(P,O,0),L(R,O,.5)):(L(M,O,1),L(A,O,0),L(R,O,.5))}function te(Y,H){H&&(Y?(L(S,Q,1),L(_,Q,0),L(y,G,0),L(S,Q,1),L(y,G,0),L(b,G,1),L(y,Q,0),L(R,G,.5),L(b,G,1),L(R,G,.5),L(P,Q,0),L(b,G,1)):(L(S,Q,1),L(_,Q,0),L(M,G,1),L(_,Q,0),L(b,G,0),L(M,G,1),L(M,Q,1),L(b,G,0),L(R,G,.5),L(R,G,.5),L(b,G,0),L(A,Q,1)))}function J(Y,H,O,T,$,de){switch(t.strokeLineCap){case"round":$?j(Y,O,H,de,.5):j(Y,H,O,de,.5);break;case"square":if($)h.subVectors(H,Y),f.set(h.y,-h.x),p.addVectors(h,f).add(Y),m.subVectors(f,h).add(Y),T?(p.toArray(i,1*3),m.toArray(i,0*3),m.toArray(i,3*3)):(p.toArray(i,1*3),p.toArray(i,3*3),m.toArray(i,0*3));else{h.subVectors(O,Y),f.set(h.y,-h.x),p.addVectors(h,f).add(Y),m.subVectors(f,h).add(Y);const be=i.length;T?(p.toArray(i,be-1*3),m.toArray(i,be-2*3),m.toArray(i,be-4*3)):(p.toArray(i,be-2*3),m.toArray(i,be-1*3),m.toArray(i,be-4*3))}break}}function ge(Y){let H=!1;for(let T=1,$=Y.length-1;T<$;T++)if(Y[T].distanceTo(Y[T+1])<n){H=!0;break}if(!H)return Y;const O=[];O.push(Y[0]);for(let T=1,$=Y.length-1;T<$;T++)Y[T].distanceTo(Y[T+1])>=n&&O.push(Y[T]);return O.push(Y[Y.length-1]),O}}}const ls=new WeakMap;class vo extends c.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,s,n){const i=new c.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,o=>{const r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,r).then(t).catch(n)},s,n)}decodeDracoFile(e,t,s,n){const i={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(const a in t.attributeTypes){const h=t.attributeTypes[a];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[a]=h.name)}const s=JSON.stringify(t);if(ls.has(e)){const a=ls.get(e);if(a.key===s)return a.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 n;const i=this.workerNextTaskID++,o=e.byteLength,r=this._getWorker(i,o).then(a=>(n=a,new Promise((h,f)=>{n._callbacks[i]={resolve:h,reject:f},n.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return r.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),ls.set(e,{key:s,promise:r}),r}_createGeometry(e){const t=new c.BufferGeometry;e.index&&t.setIndex(new c.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s],i=n.name,o=n.array,r=n.itemSize;t.setAttribute(i,new c.BufferAttribute(o,r))}return t}_loadLibrary(e,t){const s=new c.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((n,i)=>{s.load(e,n,void 0,i)})}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(s=>{const n=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const i=bo.toString(),o=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
79
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(i){const o=i.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,i){return n._taskLoad>i._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_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 bo(){let l,e;onmessage=function(o){const r=o.data;switch(r.type){case"init":l=r.decoderConfig,e=new Promise(function(f){l.onModuleLoaded=function(p){f({draco:p})},DracoDecoderModule(l)});break;case"decode":const a=r.buffer,h=r.taskConfig;e.then(f=>{const p=f.draco,m=new p.Decoder,g=new p.DecoderBuffer;g.Init(new Int8Array(a),a.byteLength);try{const w=t(p,m,g,h),x=w.attributes.map(_=>_.array.buffer);w.index&&x.push(w.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:w},x)}catch(w){console.error(w),self.postMessage({type:"error",id:r.id,error:w.message})}finally{p.destroy(g),p.destroy(m)}});break}};function t(o,r,a,h){const f=h.attributeIDs,p=h.attributeTypes;let m,g;const w=r.GetEncodedGeometryType(a);if(w===o.TRIANGULAR_MESH)m=new o.Mesh,g=r.DecodeBufferToMesh(a,m);else if(w===o.POINT_CLOUD)m=new o.PointCloud,g=r.DecodeBufferToPointCloud(a,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!g.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());const x={index:null,attributes:[]};for(const _ in f){const S=self[p[_]];let C,v;if(h.useUniqueIDs)v=f[_],C=r.GetAttributeByUniqueId(m,v);else{if(v=r.GetAttributeId(m,o[f[_]]),v===-1)continue;C=r.GetAttribute(m,v)}x.attributes.push(n(o,r,m,_,S,C))}return w===o.TRIANGULAR_MESH&&(x.index=s(o,r,m)),o.destroy(m),x}function s(o,r,a){const f=a.num_faces()*3,p=f*4,m=o._malloc(p);r.GetTrianglesUInt32Array(a,p,m);const g=new Uint32Array(o.HEAPF32.buffer,m,f).slice();return o._free(m),{array:g,itemSize:1}}function n(o,r,a,h,f,p){const m=p.num_components(),w=a.num_points()*m,x=w*f.BYTES_PER_ELEMENT,_=i(o,f),S=o._malloc(x);r.GetAttributeDataArrayForAllPoints(a,p,_,x,S);const C=new f(o.HEAPF32.buffer,S,w).slice();return o._free(S),{name:h,array:C,itemSize:m}}function i(o,r){switch(r){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}const Ao=["args","center"],Mo=u.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(l,{expose:e}){let t,s;const n=l,{center:i,font:o,text:r,needUpdates:a,size:h,height:f,curveSegments:p,bevelEnabled:m,bevelThickness:g,bevelSize:w,bevelOffset:x,bevelSegments:_}=u.toRefs(n),{extend:S}=ue.useTresContext();S({TextGeometry:Ys});const C=new mo,v=u.useSlots(),y=u.computed(()=>{var b;return r!=null&&r.value?r.value:v.default?(b=v.default()[0].children)==null?void 0:b.trim():a.value?"":"TresJS"}),M=u.shallowRef();e({value:M});const P=([t,s]=u.withAsyncContext(()=>new Promise((b,D)=>{try{typeof o.value=="string"?C.load(o.value,z=>{b(z)}):b(o.value)}catch(z){D(console.error("cientos",z))}})),t=await t,s(),t),A=u.computed(()=>({font:P,size:u.toValue(h),height:u.toValue(f),curveSegments:u.toValue(p),bevelEnabled:u.toValue(m),bevelThickness:u.toValue(g),bevelSize:u.toValue(w),bevelOffset:u.toValue(x),bevelSegments:u.toValue(_)}));return u.watchEffect(()=>{M.value&&a.value&&(M.value.geometry.dispose(),M.value.geometry=new Ys(y.value,A.value),i.value&&M.value.geometry.center())}),(b,D)=>u.unref(o)?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:M},[y.value?(u.openBlock(),u.createElementBlock("TresTextGeometry",{key:0,args:[y.value,A.value],center:u.unref(i)},null,8,Ao)):u.createCommentVNode("",!0),u.renderSlot(b.$slots,"default")],512)):u.createCommentVNode("",!0)}});function So(l,e){const t=u.ref(e),s=new c.AnimationMixer(t.value),n=u.shallowReactive({});l.forEach(o=>{const r=s.clipAction(o,t.value);n[o.name]=r});const{onLoop:i}=ue.useRenderLoop();return i(({delta:o})=>{s.update(o)}),{actions:n,mixer:s}}const Po=u.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(l,{expose:e}){const t=l,s=u.shallowRef();e({value:s});const{onLoop:n}=ue.useRenderLoop(),i=u.ref(Math.random()*1e4);return n(({elapsed:o})=>{var h,f;if(!s.value)return;const r=i.value+o;s.value.rotation.x=Math.cos(r/4*t.speed)/8*t.rotationFactor,s.value.rotation.y=Math.sin(r/4*t.speed)/8*t.rotationFactor,s.value.rotation.z=Math.sin(r/4*t.speed)/20*t.rotationFactor;let a=Math.sin(r/4*t.speed)/10;a=c.MathUtils.mapLinear(a,-.1,.1,((h=t.range)==null?void 0:h[0])??-.1,((f=t.range)==null?void 0:f[1])??.1),s.value.position.y=a*t.floatFactor}),(o,r)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps(o.$attrs,{ref_key:"groupRef",ref:s}),[u.renderSlot(o.$slots,"default")],16))}});function tn(l){return u.getCurrentScope()?(u.onScopeDispose(l),!0):!1}function Fe(l){return typeof l=="function"?l():u.unref(l)}const To=typeof window<"u"&&typeof document<"u",Co=Object.prototype.toString,Lo=l=>Co.call(l)==="[object Object]",st=()=>{};function sn(l,e){function t(...s){return new Promise((n,i)=>{Promise.resolve(l(()=>e.apply(this,s),{fn:e,thisArg:this,args:s})).then(n).catch(i)})}return t}function Oo(l,e={}){let t,s,n=st;const i=r=>{clearTimeout(r),n(),n=st};return r=>{const a=Fe(l),h=Fe(e.maxWait);return t&&i(t),a<=0||h!==void 0&&h<=0?(s&&(i(s),s=null),Promise.resolve(r())):new Promise((f,p)=>{n=e.rejectOnCancel?p:f,h&&!s&&(s=setTimeout(()=>{t&&i(t),s=null,f(r())},h)),t=setTimeout(()=>{s&&i(s),s=null,f(r())},a)})}}function Io(l,e=!0,t=!0,s=!1){let n=0,i,o=!0,r=st,a;const h=()=>{i&&(clearTimeout(i),i=void 0,r(),r=st)};return p=>{const m=Fe(l),g=Date.now()-n,w=()=>a=p();return h(),m<=0?(n=Date.now(),w()):(g>m&&(t||!o)?(n=Date.now(),w()):e&&(a=new Promise((x,_)=>{r=s?_:x,i=setTimeout(()=>{n=Date.now(),o=!0,x(w()),h()},Math.max(0,m-g))})),!t&&!i&&(i=setTimeout(()=>o=!0,m)),o=!1,a)}}function Do(l,e=200,t={}){return sn(Oo(e,t),l)}function ko(l,e=200,t=!1,s=!0,n=!1){return sn(Io(e,t,s,n),l)}function Fo(l,e=!0){u.getCurrentInstance()?u.onMounted(l):e?l():u.nextTick(l)}function Bo(l){var e;const t=Fe(l);return(e=t==null?void 0:t.$el)!=null?e:t}const nt=To?window:void 0;function Se(...l){let e,t,s,n;if(typeof l[0]=="string"||Array.isArray(l[0])?([t,s,n]=l,e=nt):[e,t,s,n]=l,!e)return st;Array.isArray(t)||(t=[t]),Array.isArray(s)||(s=[s]);const i=[],o=()=>{i.forEach(f=>f()),i.length=0},r=(f,p,m,g)=>(f.addEventListener(p,m,g),()=>f.removeEventListener(p,m,g)),a=u.watch(()=>[Bo(e),Fe(n)],([f,p])=>{if(o(),!f)return;const m=Lo(p)?{...p}:p;i.push(...t.flatMap(g=>s.map(w=>r(f,g,w,m))))},{immediate:!0,flush:"post"}),h=()=>{a(),o()};return tn(h),h}function Uo(l){return typeof l=="function"?l:typeof l=="string"?e=>e.key===l:Array.isArray(l)?e=>l.includes(e.key):()=>!0}function it(...l){let e,t,s={};l.length===3?(e=l[0],t=l[1],s=l[2]):l.length===2?typeof l[1]=="object"?(e=!0,t=l[0],s=l[1]):(e=l[0],t=l[1]):(e=!0,t=l[0]);const{target:n=nt,eventName:i="keydown",passive:o=!1,dedupe:r=!1}=s,a=Uo(e);return Se(n,i,f=>{f.repeat&&Fe(r)||a(f)&&t(f)},o)}function Vo(){const l=u.ref(!1);return u.getCurrentInstance()&&u.onMounted(()=>{l.value=!0}),l}function No(l){const e=Vo();return u.computed(()=>(e.value,!!l()))}function zo(l,e={}){const{window:t=nt}=e,s=No(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let n;const i=u.ref(!1),o=h=>{i.value=h.matches},r=()=>{n&&("removeEventListener"in n?n.removeEventListener("change",o):n.removeListener(o))},a=u.watchEffect(()=>{s.value&&(r(),n=t.matchMedia(Fe(l)),"addEventListener"in n?n.addEventListener("change",o):n.addListener(o),i.value=n.matches)});return tn(()=>{a(),r(),n=void 0}),i}const nn=1;function Ro(l,e={}){const{throttle:t=0,idle:s=200,onStop:n=st,onScroll:i=st,offset:o={left:0,right:0,top:0,bottom:0},eventListenerOptions:r={capture:!1,passive:!0},behavior:a="auto",window:h=nt}=e,f=u.ref(0),p=u.ref(0),m=u.computed({get(){return f.value},set(P){w(P,void 0)}}),g=u.computed({get(){return p.value},set(P){w(void 0,P)}});function w(P,A){var b,D,z;if(!h)return;const U=Fe(l);U&&((z=U instanceof Document?h.document.body:U)==null||z.scrollTo({top:(b=Fe(A))!=null?b:g.value,left:(D=Fe(P))!=null?D:m.value,behavior:Fe(a)}))}const x=u.ref(!1),_=u.reactive({left:!0,right:!1,top:!0,bottom:!1}),S=u.reactive({left:!1,right:!1,top:!1,bottom:!1}),C=P=>{x.value&&(x.value=!1,S.left=!1,S.right=!1,S.top=!1,S.bottom=!1,n(P))},v=Do(C,t+s),y=P=>{var A;if(!h)return;const b=P.document?P.document.documentElement:(A=P.documentElement)!=null?A:P,{display:D,flexDirection:z}=getComputedStyle(b),U=b.scrollLeft;S.left=U<f.value,S.right=U>f.value;const R=Math.abs(U)<=0+(o.left||0),K=Math.abs(U)+b.clientWidth>=b.scrollWidth-(o.right||0)-nn;D==="flex"&&z==="row-reverse"?(_.left=K,_.right=R):(_.left=R,_.right=K),f.value=U;let Z=b.scrollTop;P===h.document&&!Z&&(Z=h.document.body.scrollTop),S.top=Z<p.value,S.bottom=Z>p.value;const W=Math.abs(Z)<=0+(o.top||0),pe=Math.abs(Z)+b.clientHeight>=b.scrollHeight-(o.bottom||0)-nn;D==="flex"&&z==="column-reverse"?(_.top=pe,_.bottom=W):(_.top=W,_.bottom=pe),p.value=Z},M=P=>{var A;if(!h)return;const b=(A=P.target.documentElement)!=null?A:P.target;y(b),x.value=!0,v(P),i(P)};return Se(l,"scroll",t?ko(M,t,!0,!1):M,r),Se(l,"scrollend",C,r),{x:m,y:g,isScrolling:x,arrivedState:_,directions:S,measure(){const P=Fe(l);h&&P&&y(P)}}}const Go={page:l=>[l.pageX,l.pageY],client:l=>[l.clientX,l.clientY],screen:l=>[l.screenX,l.screenY],movement:l=>l instanceof Touch?null:[l.movementX,l.movementY]};function Eo(l={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:s=!1,initialValue:n={x:0,y:0},window:i=nt,target:o=i,scroll:r=!0,eventFilter:a}=l;let h=null;const f=u.ref(n.x),p=u.ref(n.y),m=u.ref(null),g=typeof e=="function"?e:Go[e],w=M=>{const P=g(M);h=M,P&&([f.value,p.value]=P,m.value="mouse")},x=M=>{if(M.touches.length>0){const P=g(M.touches[0]);P&&([f.value,p.value]=P,m.value="touch")}},_=()=>{if(!h||!i)return;const M=g(h);h instanceof MouseEvent&&M&&(f.value=M[0]+i.scrollX,p.value=M[1]+i.scrollY)},S=()=>{f.value=n.x,p.value=n.y},C=a?M=>a(()=>w(M),{}):M=>w(M),v=a?M=>a(()=>x(M),{}):M=>x(M),y=a?()=>a(()=>_(),{}):()=>_();if(o){const M={passive:!0};Se(o,["mousemove","dragover"],C,M),t&&e!=="movement"&&(Se(o,["touchstart","touchmove"],v,M),s&&Se(o,"touchend",S,M)),r&&e==="page"&&Se(i,"scroll",y,{passive:!0})}return{x:f,y:p,sourceType:m}}function jo({window:l=nt}={}){if(!l)return{x:u.ref(0),y:u.ref(0)};const e=u.ref(l.scrollX),t=u.ref(l.scrollY);return Se(l,"scroll",()=>{e.value=l.scrollX,t.value=l.scrollY},{capture:!1,passive:!0}),{x:e,y:t}}function on(l={}){const{window:e=nt,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:s=Number.POSITIVE_INFINITY,listenOrientation:n=!0,includeScrollbar:i=!0}=l,o=u.ref(t),r=u.ref(s),a=()=>{e&&(i?(o.value=e.innerWidth,r.value=e.innerHeight):(o.value=e.document.documentElement.clientWidth,r.value=e.document.documentElement.clientHeight))};if(a(),Fo(a),Se("resize",a,{passive:!0}),n){const h=zo("(orientation: portrait)");u.watch(h,()=>a())}return{width:o,height:r}}const Xo=u.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(l){const e=l,{camera:t}=ue.useTresContext(),{disabled:s,factor:n,ease:i}=u.toRefs(e),{x:o,y:r}=Eo(),{width:a,height:h}=on(),f=u.ref(),p=u.computed(()=>(o.value/a.value-.5)*n.value),m=u.computed(()=>-(r.value/h.value-.5)*n.value),{onLoop:g}=ue.useRenderLoop();return g(({delta:w})=>{s.value||!f.value||(f.value.position.x+=(p.value-f.value.position.x)*i.value*w,f.value.position.y+=(m.value-f.value.position.y)*i.value*w)}),u.watch(()=>f.value,w=>w==null?void 0:w.add(t.value)),(w,x)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:f},null,512))}});class vt extends c.Mesh{constructor(){super(vt.Geometry,new c.MeshBasicMaterial({opacity:0,transparent:!0})),this.isLensflare=!0,this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;const e=new c.Vector3,t=new c.Vector3,s=new c.FramebufferTexture(16,16),n=new c.FramebufferTexture(16,16),i=vt.Geometry,o=new c.RawShaderMaterial({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:`
73
+ `};function vs(a,e,t){const n=t.length-a-1;if(e>=t[n])return n-1;if(e<=t[a])return a;let s=a,i=n,o=Math.floor((s+i)/2);for(;e<t[o]||e>=t[o+1];)e<t[o]?i=o:s=o,o=Math.floor((s+i)/2);return o}function Go(a,e,t,n){const s=[],i=[],o=[];s[0]=1;for(let r=1;r<=t;++r){i[r]=e-n[a+1-r],o[r]=n[a+r]-e;let l=0;for(let f=0;f<r;++f){const d=o[f+1],u=i[r-f],p=s[f]/(d+u);s[f]=l+d*p,l=u*p}s[r]=l}return s}function Ro(a,e,t,n){const s=vs(a,n,e),i=Go(s,n,a,e),o=new c.Vector4(0,0,0,0);for(let r=0;r<=a;++r){const l=t[s-a+r],f=i[r],d=l.w*f;o.x+=l.x*d,o.y+=l.y*d,o.z+=l.z*d,o.w+=l.w*f}return o}function jo(a,e,t,n,s){const i=[];for(let u=0;u<=t;++u)i[u]=0;const o=[];for(let u=0;u<=n;++u)o[u]=i.slice(0);const r=[];for(let u=0;u<=t;++u)r[u]=i.slice(0);r[0][0]=1;const l=i.slice(0),f=i.slice(0);for(let u=1;u<=t;++u){l[u]=e-s[a+1-u],f[u]=s[a+u]-e;let p=0;for(let g=0;g<u;++g){const x=f[g+1],w=l[u-g];r[u][g]=x+w;const _=r[g][u-1]/r[u][g];r[g][u]=p+x*_,p=w*_}r[u][u]=p}for(let u=0;u<=t;++u)o[0][u]=r[u][t];for(let u=0;u<=t;++u){let p=0,g=1;const x=[];for(let w=0;w<=t;++w)x[w]=i.slice(0);x[0][0]=1;for(let w=1;w<=n;++w){let _=0;const M=u-w,L=t-w;u>=w&&(x[g][0]=x[p][0]/r[L+1][M],_=x[g][0]*r[M][L]);const v=M>=-1?1:-M,y=u-1<=L?w-1:t-u;for(let S=v;S<=y;++S)x[g][S]=(x[p][S]-x[p][S-1])/r[L+1][M+S],_+=x[g][S]*r[M+S][L];u<=L&&(x[g][w]=-x[p][w-1]/r[L+1][u],_+=x[g][w]*r[u][L]),o[w][u]=_;const A=p;p=g,g=A}}let d=t;for(let u=1;u<=n;++u){for(let p=0;p<=t;++p)o[u][p]*=d;d*=t-u}return o}function Eo(a,e,t,n,s){const i=s<a?s:a,o=[],r=vs(a,n,e),l=jo(r,n,a,i,e),f=[];for(let d=0;d<t.length;++d){const u=t[d].clone(),p=u.w;u.x*=p,u.y*=p,u.z*=p,f[d]=u}for(let d=0;d<=i;++d){const u=f[r-a].clone().multiplyScalar(l[d][0]);for(let p=1;p<=a;++p)u.add(f[r-a+p].clone().multiplyScalar(l[d][p]));o[d]=u}for(let d=i+1;d<=s+1;++d)o[d]=new c.Vector4(0,0,0);return o}function Xo(a,e){let t=1;for(let s=2;s<=a;++s)t*=s;let n=1;for(let s=2;s<=e;++s)n*=s;for(let s=2;s<=a-e;++s)n*=s;return t/n}function Yo(a){const e=a.length,t=[],n=[];for(let i=0;i<e;++i){const o=a[i];t[i]=new c.Vector3(o.x,o.y,o.z),n[i]=o.w}const s=[];for(let i=0;i<e;++i){const o=t[i].clone();for(let r=1;r<=i;++r)o.sub(s[i-r].clone().multiplyScalar(Xo(i,r)*n[r]));s[i]=o.divideScalar(n[0])}return s}function Wo(a,e,t,n,s){const i=Eo(a,e,t,n,s);return Yo(i)}class xs extends c.Curve{constructor(e,t,n,s,i){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=s||0,this.endKnot=i||this.knots.length-1;for(let o=0;o<n.length;++o){const r=n[o];this.controlPoints[o]=new c.Vector4(r.x,r.y,r.z,r.w)}}getPoint(e,t){const n=t||new c.Vector3,s=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=Ro(this.degree,this.knots,this.controlPoints,s);return i.w!=1&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(e,t){const n=t||new c.Vector3,s=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=Wo(this.degree,this.knots,this.controlPoints,s,1);return n.copy(i[1]).normalize(),n}}let me,Se,Fe;class Zo extends c.Loader{constructor(e){super(e)}load(e,t,n,s){const i=this,o=i.path===""?c.LoaderUtils.extractUrlBase(e):i.path,r=new c.FileLoader(this.manager);r.setPath(i.path),r.setResponseType("arraybuffer"),r.setRequestHeader(i.requestHeader),r.setWithCredentials(i.withCredentials),r.load(e,function(l){try{t(i.parse(l,o))}catch(f){s?s(f):console.error(f),i.manager.itemError(e)}},n,s)}parse(e,t){if($o(e))me=new Ho().parse(e);else{const s=Ps(e);if(!er(s))throw new Error("THREE.FBXLoader: Unknown format.");if(As(s)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+As(s));me=new Jo().parse(s)}const n=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Qo(n,this.manager).parse(me)}}class Qo{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Se=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),s=this.parseDeformers(),i=new Ko().parse(s);return this.parseScene(s,i,n),Fe}parseConnections(){const e=new Map;return"Connections"in me&&me.Connections.connections.forEach(function(n){const s=n[0],i=n[1],o=n[2];e.has(s)||e.set(s,{parents:[],children:[]});const r={ID:i,relationship:o};e.get(s).parents.push(r),e.has(i)||e.set(i,{parents:[],children:[]});const l={ID:s,relationship:o};e.get(i).children.push(l)}),e}parseImages(){const e={},t={};if("Video"in me.Objects){const n=me.Objects.Video;for(const s in n){const i=n[s],o=parseInt(s);if(e[o]=i.RelativeFilename||i.Filename,"Content"in i){const r=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,l=typeof i.Content=="string"&&i.Content!=="";if(r||l){const f=this.parseImage(n[s]);t[i.RelativeFilename||i.Filename]=f}}}}for(const n in e){const s=e[n];t[s]!==void 0?e[n]=t[s]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,s=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(s){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:console.warn('FBXLoader: Image type "'+s+'" is not supported.');return}if(typeof t=="string")return"data:"+i+";base64,"+t;{const o=new Uint8Array(t);return window.URL.createObjectURL(new Blob([o],{type:i}))}}parseTextures(e){const t=new Map;if("Texture"in me.Objects){const n=me.Objects.Texture;for(const s in n){const i=this.parseTexture(n[s],e);t.set(parseInt(s),i)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const s=e.WrapModeU,i=e.WrapModeV,o=s!==void 0?s.value:0,r=i!==void 0?i.value:0;if(n.wrapS=o===0?c.RepeatWrapping:c.ClampToEdgeWrapping,n.wrapT=r===0?c.RepeatWrapping:c.ClampToEdgeWrapping,"Scaling"in e){const l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}return n}loadTexture(e,t){let n;const s=this.textureLoader.path,i=Se.get(e.id).children;i!==void 0&&i.length>0&&t[i[0].ID]!==void 0&&(n=t[i[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let o;const r=e.FileName.slice(-3).toLowerCase();if(r==="tga"){const l=this.manager.getHandler(".tga");l===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),o=new c.Texture):(l.setPath(this.textureLoader.path),o=l.load(n))}else r==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),o=new c.Texture):o=this.textureLoader.load(n);return this.textureLoader.setPath(s),o}parseMaterials(e){const t=new Map;if("Material"in me.Objects){const n=me.Objects.Material;for(const s in n){const i=this.parseMaterial(n[s],e);i!==null&&t.set(parseInt(s),i)}}return t}parseMaterial(e,t){const n=e.id,s=e.attrName;let i=e.ShadingModel;if(typeof i=="object"&&(i=i.value),!Se.has(n))return null;const o=this.parseParameters(e,t,n);let r;switch(i.toLowerCase()){case"phong":r=new c.MeshPhongMaterial;break;case"lambert":r=new c.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),r=new c.MeshPhongMaterial;break}return r.setValues(o),r.name=s,r}parseParameters(e,t,n){const s={};e.BumpFactor&&(s.bumpScale=e.BumpFactor.value),e.Diffuse?s.color=new c.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(s.color=new c.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(s.displacementScale=e.DisplacementFactor.value),e.Emissive?s.emissive=new c.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(s.emissive=new c.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(s.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(s.opacity=parseFloat(e.Opacity.value)),s.opacity<1&&(s.transparent=!0),e.ReflectionFactor&&(s.reflectivity=e.ReflectionFactor.value),e.Shininess&&(s.shininess=e.Shininess.value),e.Specular?s.specular=new c.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(s.specular=new c.Color().fromArray(e.SpecularColor.value));const i=this;return Se.get(n).children.forEach(function(o){const r=o.relationship;switch(r){case"Bump":s.bumpMap=i.getTexture(t,o.ID);break;case"Maya|TEX_ao_map":s.aoMap=i.getTexture(t,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":s.map=i.getTexture(t,o.ID),s.map!==void 0&&("colorSpace"in s.map?s.map.colorSpace="srgb":s.map.encoding=3001);break;case"DisplacementColor":s.displacementMap=i.getTexture(t,o.ID);break;case"EmissiveColor":s.emissiveMap=i.getTexture(t,o.ID),s.emissiveMap!==void 0&&("colorSpace"in s.emissiveMap?s.emissiveMap.colorSpace="srgb":s.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":s.normalMap=i.getTexture(t,o.ID);break;case"ReflectionColor":s.envMap=i.getTexture(t,o.ID),s.envMap!==void 0&&(s.envMap.mapping=c.EquirectangularReflectionMapping,"colorSpace"in s.envMap?s.envMap.colorSpace="srgb":s.envMap.encoding=3001);break;case"SpecularColor":s.specularMap=i.getTexture(t,o.ID),s.specularMap!==void 0&&("colorSpace"in s.specularMap?s.specularMap.colorSpace="srgb":s.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":s.alphaMap=i.getTexture(t,o.ID),s.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r);break}}),s}getTexture(e,t){return"LayeredTexture"in me.Objects&&t in me.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Se.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in me.Objects){const n=me.Objects.Deformer;for(const s in n){const i=n[s],o=Se.get(parseInt(s));if(i.attrType==="Skin"){const r=this.parseSkeleton(o,n);r.ID=s,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),r.geometryID=o.parents[0].ID,e[s]=r}else if(i.attrType==="BlendShape"){const r={id:s};r.rawTargets=this.parseMorphTargets(o,n),r.id=s,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[s]=r}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(s){const i=t[s.ID];if(i.attrType!=="Cluster")return;const o={ID:s.ID,indices:[],weights:[],transformLink:new c.Matrix4().fromArray(i.TransformLink.a)};"Indexes"in i&&(o.indices=i.Indexes.a,o.weights=i.Weights.a),n.push(o)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let s=0;s<e.children.length;s++){const i=e.children[s],o=t[i.ID],r={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if(o.attrType!=="BlendShapeChannel")return;r.geoID=Se.get(parseInt(i.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(r)}return n}parseScene(e,t,n){Fe=new c.Group;const s=this.parseModels(e.skeletons,t,n),i=me.Objects.Model,o=this;s.forEach(function(l){const f=i[l.ID];o.setLookAtProperties(l,f),Se.get(l.ID).parents.forEach(function(u){const p=s.get(u.ID);p!==void 0&&p.add(l)}),l.parent===null&&Fe.add(l)}),this.bindSkeleton(e.skeletons,t,s),this.createAmbientLight(),Fe.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const f=Ms(l.userData.transformData);l.applyMatrix4(f),l.updateWorldMatrix()}});const r=new qo().parse();Fe.children.length===1&&Fe.children[0].isGroup&&(Fe.children[0].animations=r,Fe=Fe.children[0]),Fe.animations=r}parseModels(e,t,n){const s=new Map,i=me.Objects.Model;for(const o in i){const r=parseInt(o),l=i[o],f=Se.get(r);let d=this.buildSkeleton(f,e,r,l.attrName);if(!d){switch(l.attrType){case"Camera":d=this.createCamera(f);break;case"Light":d=this.createLight(f);break;case"Mesh":d=this.createMesh(f,t,n);break;case"NurbsCurve":d=this.createCurve(f,t);break;case"LimbNode":case"Root":d=new c.Bone;break;case"Null":default:d=new c.Group;break}d.name=l.attrName?c.PropertyBinding.sanitizeNodeName(l.attrName):"",d.ID=r}this.getTransformData(d,l),s.set(r,d)}return s}buildSkeleton(e,t,n,s){let i=null;return e.parents.forEach(function(o){for(const r in t){const l=t[r];l.rawBones.forEach(function(f,d){if(f.ID===o.ID){const u=i;i=new c.Bone,i.matrixWorld.copy(f.transformLink),i.name=s?c.PropertyBinding.sanitizeNodeName(s):"",i.ID=n,l.bones[d]=i,u!==null&&i.add(u)}})}}),i}createCamera(e){let t,n;if(e.children.forEach(function(s){const i=me.Objects.NodeAttribute[s.ID];i!==void 0&&(n=i)}),n===void 0)t=new c.Object3D;else{let s=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(s=1);let i=1;n.NearPlane!==void 0&&(i=n.NearPlane.value/1e3);let o=1e3;n.FarPlane!==void 0&&(o=n.FarPlane.value/1e3);let r=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(r=n.AspectWidth.value,l=n.AspectHeight.value);const f=r/l;let d=45;n.FieldOfView!==void 0&&(d=n.FieldOfView.value);const u=n.FocalLength?n.FocalLength.value:null;switch(s){case 0:t=new c.PerspectiveCamera(d,f,i,o),u!==null&&t.setFocalLength(u);break;case 1:t=new c.OrthographicCamera(-r/2,r/2,l/2,-l/2,i,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+s+"."),t=new c.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(s){const i=me.Objects.NodeAttribute[s.ID];i!==void 0&&(n=i)}),n===void 0)t=new c.Object3D;else{let s;n.LightType===void 0?s=0:s=n.LightType.value;let i=16777215;n.Color!==void 0&&(i=new c.Color().fromArray(n.Color.value));let o=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(o=0);let r=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?r=0:r=n.FarAttenuationEnd.value);const l=1;switch(s){case 0:t=new c.PointLight(i,o,r,l);break;case 1:t=new c.DirectionalLight(i,o);break;case 2:let f=Math.PI/3;n.InnerAngle!==void 0&&(f=c.MathUtils.degToRad(n.InnerAngle.value));let d=0;n.OuterAngle!==void 0&&(d=c.MathUtils.degToRad(n.OuterAngle.value),d=Math.max(d,1)),t=new c.SpotLight(i,o,r,f,d,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new c.PointLight(i,o);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let s,i=null,o=null;const r=[];return e.children.forEach(function(l){t.has(l.ID)&&(i=t.get(l.ID)),n.has(l.ID)&&r.push(n.get(l.ID))}),r.length>1?o=r:r.length>0?o=r[0]:(o=new c.MeshPhongMaterial({color:13421772}),r.push(o)),"color"in i.attributes&&r.forEach(function(l){l.vertexColors=!0}),i.FBX_Deformer?(s=new c.SkinnedMesh(i,o),s.normalizeSkinWeights()):s=new c.Mesh(i,o),s}createCurve(e,t){const n=e.children.reduce(function(i,o){return t.has(o.ID)&&(i=t.get(o.ID)),i},null),s=new c.LineBasicMaterial({color:3342591,linewidth:1});return new c.Line(n,s)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Ss(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&Se.get(e.ID).children.forEach(function(s){if(s.relationship==="LookAtProperty"){const i=me.Objects.Model[s.ID];if("Lcl_Translation"in i){const o=i.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),Fe.add(e.target)):e.lookAt(new c.Vector3().fromArray(o))}}})}bindSkeleton(e,t,n){const s=this.parsePoseNodes();for(const i in e){const o=e[i];Se.get(parseInt(o.ID)).parents.forEach(function(l){if(t.has(l.ID)){const f=l.ID;Se.get(f).parents.forEach(function(u){n.has(u.ID)&&n.get(u.ID).bind(new c.Skeleton(o.bones),s[u.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in me.Objects){const t=me.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const s=t[n].PoseNode;Array.isArray(s)?s.forEach(function(i){e[i.Node]=new c.Matrix4().fromArray(i.Matrix.a)}):e[s.Node]=new c.Matrix4().fromArray(s.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in me&&"AmbientColor"in me.GlobalSettings){const e=me.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],s=e[2];if(t!==0||n!==0||s!==0){const i=new c.Color(t,n,s);Fe.add(new c.AmbientLight(i,1))}}}}class Ko{parse(e){const t=new Map;if("Geometry"in me.Objects){const n=me.Objects.Geometry;for(const s in n){const i=Se.get(parseInt(s)),o=this.parseGeometry(i,n[s],e);t.set(parseInt(s),o)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const s=n.skeletons,i=[],o=e.parents.map(function(u){return me.Objects.Model[u.ID]});if(o.length===0)return;const r=e.children.reduce(function(u,p){return s[p.ID]!==void 0&&(u=s[p.ID]),u},null);e.children.forEach(function(u){n.morphTargets[u.ID]!==void 0&&i.push(n.morphTargets[u.ID])});const l=o[0],f={};"RotationOrder"in l&&(f.eulerOrder=Ss(l.RotationOrder.value)),"InheritType"in l&&(f.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(f.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(f.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(f.scale=l.GeometricScaling.value);const d=Ms(f);return this.genGeometry(t,r,i,d)}genGeometry(e,t,n,s){const i=new c.BufferGeometry;e.attrName&&(i.name=e.attrName);const o=this.parseGeoNode(e,t),r=this.genBuffers(o),l=new c.Float32BufferAttribute(r.vertex,3);if(l.applyMatrix4(s),i.setAttribute("position",l),r.colors.length>0&&i.setAttribute("color",new c.Float32BufferAttribute(r.colors,3)),t&&(i.setAttribute("skinIndex",new c.Uint16BufferAttribute(r.weightsIndices,4)),i.setAttribute("skinWeight",new c.Float32BufferAttribute(r.vertexWeights,4)),i.FBX_Deformer=t),r.normal.length>0){const f=new c.Matrix3().getNormalMatrix(s),d=new c.Float32BufferAttribute(r.normal,3);d.applyNormalMatrix(f),i.setAttribute("normal",d)}if(r.uvs.forEach(function(f,d){let u="uv"+(d+1).toString();d===0&&(u="uv"),i.setAttribute(u,new c.Float32BufferAttribute(r.uvs[d],2))}),o.material&&o.material.mappingType!=="AllSame"){let f=r.materialIndex[0],d=0;if(r.materialIndex.forEach(function(u,p){u!==f&&(i.addGroup(d,p-d,f),f=u,d=p)}),i.groups.length>0){const u=i.groups[i.groups.length-1],p=u.start+u.count;p!==r.materialIndex.length&&i.addGroup(p,r.materialIndex.length-p,f)}i.groups.length===0&&i.addGroup(0,r.materialIndex.length,r.materialIndex[0])}return this.addMorphTargets(i,e,n,s),i}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let s=0;for(;e.LayerElementUV[s];)e.LayerElementUV[s].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[s])),s++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(s,i){s.indices.forEach(function(o,r){n.weightTable[o]===void 0&&(n.weightTable[o]=[]),n.weightTable[o].push({id:i,weight:s.weights[r]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,s=0,i=!1,o=[],r=[],l=[],f=[],d=[],u=[];const p=this;return e.vertexIndices.forEach(function(g,x){let w,_=!1;g<0&&(g=g^-1,_=!0);let M=[],L=[];if(o.push(g*3,g*3+1,g*3+2),e.color){const v=Wt(x,n,g,e.color);l.push(v[0],v[1],v[2])}if(e.skeleton){if(e.weightTable[g]!==void 0&&e.weightTable[g].forEach(function(v){L.push(v.weight),M.push(v.id)}),L.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const v=[0,0,0,0],y=[0,0,0,0];L.forEach(function(A,S){let b=A,P=M[S];y.forEach(function(O,k,V){if(b>O){V[k]=b,b=O;const R=v[k];v[k]=P,P=R}})}),M=v,L=y}for(;L.length<4;)L.push(0),M.push(0);for(let v=0;v<4;++v)d.push(L[v]),u.push(M[v])}if(e.normal){const v=Wt(x,n,g,e.normal);r.push(v[0],v[1],v[2])}e.material&&e.material.mappingType!=="AllSame"&&(w=Wt(x,n,g,e.material)[0]),e.uv&&e.uv.forEach(function(v,y){const A=Wt(x,n,g,v);f[y]===void 0&&(f[y]=[]),f[y].push(A[0]),f[y].push(A[1])}),s++,_&&(p.genFace(t,e,o,w,r,l,f,d,u,s),n++,s=0,o=[],r=[],l=[],f=[],d=[],u=[])}),t}genFace(e,t,n,s,i,o,r,l,f,d){for(let u=2;u<d;u++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(u-1)*3]]),e.vertex.push(t.vertexPositions[n[(u-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(u-1)*3+2]]),e.vertex.push(t.vertexPositions[n[u*3]]),e.vertex.push(t.vertexPositions[n[u*3+1]]),e.vertex.push(t.vertexPositions[n[u*3+2]]),t.skeleton&&(e.vertexWeights.push(l[0]),e.vertexWeights.push(l[1]),e.vertexWeights.push(l[2]),e.vertexWeights.push(l[3]),e.vertexWeights.push(l[(u-1)*4]),e.vertexWeights.push(l[(u-1)*4+1]),e.vertexWeights.push(l[(u-1)*4+2]),e.vertexWeights.push(l[(u-1)*4+3]),e.vertexWeights.push(l[u*4]),e.vertexWeights.push(l[u*4+1]),e.vertexWeights.push(l[u*4+2]),e.vertexWeights.push(l[u*4+3]),e.weightsIndices.push(f[0]),e.weightsIndices.push(f[1]),e.weightsIndices.push(f[2]),e.weightsIndices.push(f[3]),e.weightsIndices.push(f[(u-1)*4]),e.weightsIndices.push(f[(u-1)*4+1]),e.weightsIndices.push(f[(u-1)*4+2]),e.weightsIndices.push(f[(u-1)*4+3]),e.weightsIndices.push(f[u*4]),e.weightsIndices.push(f[u*4+1]),e.weightsIndices.push(f[u*4+2]),e.weightsIndices.push(f[u*4+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[(u-1)*3]),e.colors.push(o[(u-1)*3+1]),e.colors.push(o[(u-1)*3+2]),e.colors.push(o[u*3]),e.colors.push(o[u*3+1]),e.colors.push(o[u*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(s),e.materialIndex.push(s),e.materialIndex.push(s)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[(u-1)*3]),e.normal.push(i[(u-1)*3+1]),e.normal.push(i[(u-1)*3+2]),e.normal.push(i[u*3]),e.normal.push(i[u*3+1]),e.normal.push(i[u*3+2])),t.uv&&t.uv.forEach(function(p,g){e.uvs[g]===void 0&&(e.uvs[g]=[]),e.uvs[g].push(r[g][0]),e.uvs[g].push(r[g][1]),e.uvs[g].push(r[g][(u-1)*2]),e.uvs[g].push(r[g][(u-1)*2+1]),e.uvs[g].push(r[g][u*2]),e.uvs[g].push(r[g][u*2+1])})}addMorphTargets(e,t,n,s){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const i=this;n.forEach(function(o){o.rawTargets.forEach(function(r){const l=me.Objects.Geometry[r.geoID];l!==void 0&&i.genMorphGeometry(e,t,l,s,r.name)})})}genMorphGeometry(e,t,n,s,i){const o=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],r=n.Vertices!==void 0?n.Vertices.a:[],l=n.Indexes!==void 0?n.Indexes.a:[],f=e.attributes.position.count*3,d=new Float32Array(f);for(let x=0;x<l.length;x++){const w=l[x]*3;d[w]=r[x*3],d[w+1]=r[x*3+1],d[w+2]=r[x*3+2]}const u={vertexIndices:o,vertexPositions:d},p=this.genBuffers(u),g=new c.Float32BufferAttribute(p.vertex,3);g.name=i||n.attrName,g.applyMatrix4(s),e.morphAttributes.position.push(g)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Normals.a;let i=[];return n==="IndexToDirect"&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:s,indices:i,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.UV.a;let i=[];return n==="IndexToDirect"&&(i=e.UVIndex.a),{dataSize:2,buffer:s,indices:i,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Colors.a;let i=[];return n==="IndexToDirect"&&(i=e.ColorIndex.a),{dataSize:4,buffer:s,indices:i,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const s=e.Materials.a,i=[];for(let o=0;o<s.length;++o)i.push(o);return{dataSize:1,buffer:s,indices:i,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(xs===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new c.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new c.BufferGeometry;const n=t-1,s=e.KnotVector.a,i=[],o=e.Points.a;for(let u=0,p=o.length;u<p;u+=4)i.push(new c.Vector4().fromArray(o,u));let r,l;if(e.Form==="Closed")i.push(i[0]);else if(e.Form==="Periodic"){r=n,l=s.length-1-r;for(let u=0;u<n;++u)i.push(i[u])}const d=new xs(n,s,i,r,l).getPoints(i.length*12);return new c.BufferGeometry().setFromPoints(d)}}class qo{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const s=t[n],i=this.addClip(s);e.push(i)}return e}parseClips(){if(me.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=me.Objects.AnimationCurveNode,t=new Map;for(const n in e){const s=e[n];if(s.attrName.match(/S|R|T|DeformPercent/)!==null){const i={id:s.id,attr:s.attrName,curves:{}};t.set(i.id,i)}}return t}parseAnimationCurves(e){const t=me.Objects.AnimationCurve;for(const n in t){const s={id:t[n].id,times:t[n].KeyTime.a.map(tr),values:t[n].KeyValueFloat.a},i=Se.get(s.id);if(i!==void 0){const o=i.parents[0].ID,r=i.parents[0].relationship;r.match(/X/)?e.get(o).curves.x=s:r.match(/Y/)?e.get(o).curves.y=s:r.match(/Z/)?e.get(o).curves.z=s:r.match(/d|DeformPercent/)&&e.has(o)&&(e.get(o).curves.morph=s)}}}parseAnimationLayers(e){const t=me.Objects.AnimationLayer,n=new Map;for(const s in t){const i=[],o=Se.get(parseInt(s));o!==void 0&&(o.children.forEach(function(l,f){if(e.has(l.ID)){const d=e.get(l.ID);if(d.curves.x!==void 0||d.curves.y!==void 0||d.curves.z!==void 0){if(i[f]===void 0){const u=Se.get(l.ID).parents.filter(function(p){return p.relationship!==void 0})[0].ID;if(u!==void 0){const p=me.Objects.Model[u.toString()];if(p===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const g={modelName:p.attrName?c.PropertyBinding.sanitizeNodeName(p.attrName):"",ID:p.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Fe.traverse(function(x){x.ID===p.id&&(g.transform=x.matrix,x.userData.transformData&&(g.eulerOrder=x.userData.transformData.eulerOrder))}),g.transform||(g.transform=new c.Matrix4),"PreRotation"in p&&(g.preRotation=p.PreRotation.value),"PostRotation"in p&&(g.postRotation=p.PostRotation.value),i[f]=g}}i[f]&&(i[f][d.attr]=d)}else if(d.curves.morph!==void 0){if(i[f]===void 0){const u=Se.get(l.ID).parents.filter(function(M){return M.relationship!==void 0})[0].ID,p=Se.get(u).parents[0].ID,g=Se.get(p).parents[0].ID,x=Se.get(g).parents[0].ID,w=me.Objects.Model[x],_={modelName:w.attrName?c.PropertyBinding.sanitizeNodeName(w.attrName):"",morphName:me.Objects.Deformer[u].attrName};i[f]=_}i[f][d.attr]=d}}}),n.set(parseInt(s),i))}return n}parseAnimStacks(e){const t=me.Objects.AnimationStack,n={};for(const s in t){const i=Se.get(parseInt(s)).children;i.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const o=e.get(i[0].ID);n[s]={name:t[s].attrName,layer:o}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(s){t=t.concat(n.generateTracks(s))}),new c.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new c.Vector3,s=new c.Quaternion,i=new c.Vector3;if(e.transform&&e.transform.decompose(n,s,i),n=n.toArray(),s=new c.Euler().setFromQuaternion(s,e.eulerOrder).toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");o!==void 0&&t.push(o)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const o=this.generateRotationTrack(e.modelName,e.R.curves,s,e.preRotation,e.postRotation,e.eulerOrder);o!==void 0&&t.push(o)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");o!==void 0&&t.push(o)}if(e.DeformPercent!==void 0){const o=this.generateMorphTrack(e);o!==void 0&&t.push(o)}return t}generateVectorTrack(e,t,n,s){const i=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(i,t,n);return new c.VectorKeyframeTrack(e+"."+s,i,o)}generateRotationTrack(e,t,n,s,i,o){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(c.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(c.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(c.MathUtils.degToRad));const r=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(r,t,n);s!==void 0&&(s=s.map(c.MathUtils.degToRad),s.push(o),s=new c.Euler().fromArray(s),s=new c.Quaternion().setFromEuler(s)),i!==void 0&&(i=i.map(c.MathUtils.degToRad),i.push(o),i=new c.Euler().fromArray(i),i=new c.Quaternion().setFromEuler(i).invert());const f=new c.Quaternion,d=new c.Euler,u=[];for(let p=0;p<l.length;p+=3)d.set(l[p],l[p+1],l[p+2],o),f.setFromEuler(d),s!==void 0&&f.premultiply(s),i!==void 0&&f.multiply(i),f.toArray(u,p/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",r,u)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(i){return i/100}),s=Fe.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new c.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+s+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,s){return n-s}),t.length>1){let n=1,s=t[0];for(let i=1;i<t.length;i++){const o=t[i];o!==s&&(t[n]=o,s=o,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const s=n,i=[];let o=-1,r=-1,l=-1;return e.forEach(function(f){if(t.x&&(o=t.x.times.indexOf(f)),t.y&&(r=t.y.times.indexOf(f)),t.z&&(l=t.z.times.indexOf(f)),o!==-1){const d=t.x.values[o];i.push(d),s[0]=d}else i.push(s[0]);if(r!==-1){const d=t.y.values[r];i.push(d),s[1]=d}else i.push(s[1]);if(l!==-1){const d=t.z.values[l];i.push(d),s[2]=d}else i.push(s[2])}),i}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],s=e.values[t]-n,i=Math.abs(s);if(i>=180){const o=i/180,r=s/o;let l=n+r;const f=e.times[t-1],u=(e.times[t]-f)/o;let p=f+u;const g=[],x=[];for(;p<e.times[t];)g.push(p),p+=u,x.push(l),l+=r;e.times=Cs(e.times,t,g),e.values=Cs(e.values,t,x)}}}}class Jo{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new bs,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(s,i){const o=s.match(/^[\s\t]*;/),r=s.match(/^[\s\t]*$/);if(o||r)return;const l=s.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),f=s.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),d=s.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(s,l):f?t.parseNodeProperty(s,f,n[++i]):d?t.popStack():s.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(s)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),s=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),i={name:n},o=this.parseNodeAttr(s),r=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,i):n in r?(n==="PoseNode"?r.PoseNode.push(i):r[n].id!==void 0&&(r[n]={},r[n][r[n].id]=r[n]),o.id!==""&&(r[n][o.id]=i)):typeof o.id=="number"?(r[n]={},r[n][o.id]=i):n!=="Properties70"&&(n==="PoseNode"?r[n]=[i]:r[n]=i),typeof o.id=="number"&&(i.id=o.id),o.name!==""&&(i.attrName=o.name),o.type!==""&&(i.attrType=o.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",s="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),s=e[2]),{id:t,name:n,type:s}}parseNodeProperty(e,t,n){let s=t[1].replace(/^"/,"").replace(/"$/,"").trim(),i=t[2].replace(/^"/,"").replace(/"$/,"").trim();s==="Content"&&i===","&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(e,s,i);return}if(s==="C"){const l=i.split(",").slice(1),f=parseInt(l[0]),d=parseInt(l[1]);let u=i.split(",").slice(3);u=u.map(function(p){return p.trim().replace(/^"/,"")}),s="connections",i=[f,d],sr(i,u),o[s]===void 0&&(o[s]=[])}s==="Node"&&(o.id=i),s in o&&Array.isArray(o[s])?o[s].push(i):s!=="a"?o[s]=i:o.a=i,this.setCurrentProp(o,s),s==="a"&&i.slice(-1)!==","&&(o.a=Pn(i))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Pn(t.a))}parseNodeSpecialProperty(e,t,n){const s=n.split('",').map(function(d){return d.trim().replace(/^\"/,"").replace(/\s/,"_")}),i=s[0],o=s[1],r=s[2],l=s[3];let f=s[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":f=parseFloat(f);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":f=Pn(f);break}this.getPrevNode()[i]={type:o,type2:r,flag:l,value:f},this.setCurrentProp(this.getPrevNode(),i)}}class Ho{parse(e){const t=new ws(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const s=new bs;for(;!this.endOfContent(t);){const i=this.parseNode(t,n);i!==null&&s.add(i.name,i)}return s}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},s=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),r=e.getString(o);if(s===0)return null;const l=[];for(let p=0;p<i;p++)l.push(this.parseProperty(e));const f=l.length>0?l[0]:"",d=l.length>1?l[1]:"",u=l.length>2?l[2]:"";for(n.singleProperty=i===1&&e.getOffset()===s;s>e.getOffset();){const p=this.parseNode(e,t);p!==null&&this.parseSubNode(r,n,p)}return n.propertyList=l,typeof f=="number"&&(n.id=f),d!==""&&(n.attrName=d),u!==""&&(n.attrType=u),r!==""&&(n.name=r),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const s=n.propertyList[0];Array.isArray(s)?(t[n.name]=n,n.a=s):t[n.name]=s}else if(e==="Connections"&&n.name==="C"){const s=[];n.propertyList.forEach(function(i,o){o!==0&&s.push(i)}),t.connections===void 0&&(t.connections=[]),t.connections.push(s)}else if(n.name==="Properties70")Object.keys(n).forEach(function(i){t[i]=n[i]});else if(e==="Properties70"&&n.name==="P"){let s=n.propertyList[0],i=n.propertyList[1];const o=n.propertyList[2],r=n.propertyList[3];let l;s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),i==="Color"||i==="ColorRGB"||i==="Vector"||i==="Vector3D"||i.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[s]={type:i,type2:o,flag:r,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const s=e.getUint32(),i=e.getUint32(),o=e.getUint32();if(i===0)switch(t){case"b":case"c":return e.getBooleanArray(s);case"d":return e.getFloat64Array(s);case"f":return e.getFloat32Array(s);case"i":return e.getInt32Array(s);case"l":return e.getInt64Array(s)}const r=Ri(new Uint8Array(e.getArrayBuffer(o))),l=new ws(r.buffer);switch(t){case"b":case"c":return l.getBooleanArray(s);case"d":return l.getFloat64Array(s);case"f":return l.getFloat32Array(s);case"i":return l.getInt32Array(s);case"l":return l.getInt64Array(s)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class ws{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let s=0;s<e;s++)t[s]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),c.LoaderUtils.decodeText(new Uint8Array(t))}}class bs{add(e,t){this[e]=t}}function $o(a){const e="Kaydara FBX Binary \0";return a.byteLength>=e.length&&e===Ps(a,0,e.length)}function er(a){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(s){const i=a[s-1];return a=a.slice(t+s),t++,i}for(let s=0;s<e.length;++s)if(n(1)===e[s])return!1;return!0}function As(a){const e=/FBXVersion: (\d+)/,t=a.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function tr(a){return a/46186158e3}const nr=[];function Wt(a,e,t,n){let s;switch(n.mappingType){case"ByPolygonVertex":s=a;break;case"ByPolygon":s=e;break;case"ByVertice":s=t;break;case"AllSame":s=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(s=n.indices[s]);const i=s*n.dataSize,o=i+n.dataSize;return ir(nr,n.buffer,i,o)}const Sn=new c.Euler,wt=new c.Vector3;function Ms(a){const e=new c.Matrix4,t=new c.Matrix4,n=new c.Matrix4,s=new c.Matrix4,i=new c.Matrix4,o=new c.Matrix4,r=new c.Matrix4,l=new c.Matrix4,f=new c.Matrix4,d=new c.Matrix4,u=new c.Matrix4,p=new c.Matrix4,g=a.inheritType?a.inheritType:0;if(a.translation&&e.setPosition(wt.fromArray(a.translation)),a.preRotation){const k=a.preRotation.map(c.MathUtils.degToRad);k.push(a.eulerOrder),t.makeRotationFromEuler(Sn.fromArray(k))}if(a.rotation){const k=a.rotation.map(c.MathUtils.degToRad);k.push(a.eulerOrder),n.makeRotationFromEuler(Sn.fromArray(k))}if(a.postRotation){const k=a.postRotation.map(c.MathUtils.degToRad);k.push(a.eulerOrder),s.makeRotationFromEuler(Sn.fromArray(k)),s.invert()}a.scale&&i.scale(wt.fromArray(a.scale)),a.scalingOffset&&r.setPosition(wt.fromArray(a.scalingOffset)),a.scalingPivot&&o.setPosition(wt.fromArray(a.scalingPivot)),a.rotationOffset&&l.setPosition(wt.fromArray(a.rotationOffset)),a.rotationPivot&&f.setPosition(wt.fromArray(a.rotationPivot)),a.parentMatrixWorld&&(u.copy(a.parentMatrix),d.copy(a.parentMatrixWorld));const x=t.clone().multiply(n).multiply(s),w=new c.Matrix4;w.extractRotation(d);const _=new c.Matrix4;_.copyPosition(d);const M=_.clone().invert().multiply(d),L=w.clone().invert().multiply(M),v=i,y=new c.Matrix4;if(g===0)y.copy(w).multiply(x).multiply(L).multiply(v);else if(g===1)y.copy(w).multiply(L).multiply(x).multiply(v);else{const V=new c.Matrix4().scale(new c.Vector3().setFromMatrixScale(u)).clone().invert(),R=L.clone().multiply(V);y.copy(w).multiply(x).multiply(R).multiply(v)}const A=f.clone().invert(),S=o.clone().invert();let b=e.clone().multiply(l).multiply(f).multiply(t).multiply(n).multiply(s).multiply(A).multiply(r).multiply(o).multiply(i).multiply(S);const P=new c.Matrix4().copyPosition(b),O=d.clone().multiply(P);return p.copyPosition(O),b=p.clone().multiply(y),b.premultiply(d.invert()),b}function Ss(a){a=a||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return a===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[a]}function Pn(a){return a.split(",").map(function(t){return parseFloat(t)})}function Ps(a,e,t){return e===void 0&&(e=0),t===void 0&&(t=a.byteLength),c.LoaderUtils.decodeText(new Uint8Array(a,e,t))}function sr(a,e){for(let t=0,n=a.length,s=e.length;t<s;t++,n++)a[n]=e[t]}function ir(a,e,t,n){for(let s=t,i=0;s<n;s++,i++)a[i]=e[s];return a}function Cs(a,e,t){return a.slice(0,e).concat(t).concat(a.slice(e))}var or=Object.defineProperty,rr=(a,e,t)=>e in a?or(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Cn=(a,e,t)=>(rr(a,typeof e!="symbol"?e+"":e,t),t);class ar extends c.Loader{constructor(e){super(e)}load(e,t,n,s){const i=new c.FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,o=>{if(typeof o!="string")throw new Error("unsupported data type");const r=JSON.parse(o),l=this.parse(r);t&&t(l)},n,s)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new Ln(e)}}class Ln{constructor(e){Cn(this,"data"),this.data=e}generateShapes(e,t=100,n){const s=[],i={letterSpacing:0,lineHeight:1,...n},o=lr(e,t,this.data,i);for(let r=0,l=o.length;r<l;r++)Array.prototype.push.apply(s,o[r].toShapes(!1));return s}}Cn(Ln,"isFont"),Cn(Ln,"type");function lr(a,e,t,n){const s=Array.from(a),i=e/t.resolution,o=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,r=[];let l=0,f=0;for(let d=0;d<s.length;d++){const u=s[d];if(u===`
74
+ `)l=0,f-=o*n.lineHeight;else{const p=cr(u,i,l,f,t);p&&(l+=p.offsetX+n.letterSpacing,r.push(p.path))}}return r}function cr(a,e,t,n,s){const i=s.glyphs[a]||s.glyphs["?"];if(!i){console.error('THREE.Font: character "'+a+'" does not exists in font family '+s.familyName+".");return}const o=new c.ShapePath;let r,l,f,d,u,p,g,x;if(i.o){const w=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let _=0,M=w.length;_<M;)switch(w[_++]){case"m":r=parseInt(w[_++])*e+t,l=parseInt(w[_++])*e+n,o.moveTo(r,l);break;case"l":r=parseInt(w[_++])*e+t,l=parseInt(w[_++])*e+n,o.lineTo(r,l);break;case"q":f=parseInt(w[_++])*e+t,d=parseInt(w[_++])*e+n,u=parseInt(w[_++])*e+t,p=parseInt(w[_++])*e+n,o.quadraticCurveTo(u,p,f,d);break;case"b":f=parseInt(w[_++])*e+t,d=parseInt(w[_++])*e+n,u=parseInt(w[_++])*e+t,p=parseInt(w[_++])*e+n,g=parseInt(w[_++])*e+t,x=parseInt(w[_++])*e+n,o.bezierCurveTo(u,p,g,x,f,d);break}}return{offsetX:i.ha*e,path:o}}class Ls extends c.DataTextureLoader{constructor(e){super(e),this.type=c.HalfFloatType}parse(e){const r=function(v,y){switch(v){case 1:console.error("THREE.RGBELoader Read Error: "+(y||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(y||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(y||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(y||""))}return-1},u=`
75
+ `,p=function(v,y,A){y=y||1024;let b=v.pos,P=-1,O=0,k="",V=String.fromCharCode.apply(null,new Uint16Array(v.subarray(b,b+128)));for(;0>(P=V.indexOf(u))&&O<y&&b<v.byteLength;)k+=V,O+=V.length,b+=128,V+=String.fromCharCode.apply(null,new Uint16Array(v.subarray(b,b+128)));return-1<P?(A!==!1&&(v.pos+=O+P+1),k+V.slice(0,P)):!1},g=function(v){const y=/^#\?(\S+)/,A=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,S=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*FORMAT=(\S+)\s*$/,P=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,O={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let k,V;if(v.pos>=v.byteLength||!(k=p(v)))return r(1,"no header found");if(!(V=k.match(y)))return r(3,"bad initial token");for(O.valid|=1,O.programtype=V[1],O.string+=k+`
76
+ `;k=p(v),k!==!1;){if(O.string+=k+`
77
+ `,k.charAt(0)==="#"){O.comments+=k+`
78
+ `;continue}if((V=k.match(A))&&(O.gamma=parseFloat(V[1])),(V=k.match(S))&&(O.exposure=parseFloat(V[1])),(V=k.match(b))&&(O.valid|=2,O.format=V[1]),(V=k.match(P))&&(O.valid|=4,O.height=parseInt(V[1],10),O.width=parseInt(V[2],10)),O.valid&2&&O.valid&4)break}return O.valid&2?O.valid&4?O:r(3,"missing image size specifier"):r(3,"missing format specifier")},x=function(v,y,A){const S=y;if(S<8||S>32767||v[0]!==2||v[1]!==2||v[2]&128)return new Uint8Array(v);if(S!==(v[2]<<8|v[3]))return r(3,"wrong scanline width");const b=new Uint8Array(4*y*A);if(!b.length)return r(4,"unable to allocate buffer space");let P=0,O=0;const k=4*S,V=new Uint8Array(4),R=new Uint8Array(k);let X=A;for(;X>0&&O<v.byteLength;){if(O+4>v.byteLength)return r(1);if(V[0]=v[O++],V[1]=v[O++],V[2]=v[O++],V[3]=v[O++],V[0]!=2||V[1]!=2||(V[2]<<8|V[3])!=S)return r(3,"bad rgbe scanline format");let K=0,H;for(;K<k&&O<v.byteLength;){H=v[O++];const J=H>128;if(J&&(H-=128),H===0||K+H>k)return r(3,"bad scanline data");if(J){const G=v[O++];for(let oe=0;oe<H;oe++)R[K++]=G}else R.set(v.subarray(O,O+H),K),K+=H,O+=H}const he=S;for(let J=0;J<he;J++){let G=0;b[P]=R[J+G],G+=S,b[P+1]=R[J+G],G+=S,b[P+2]=R[J+G],G+=S,b[P+3]=R[J+G],P+=4}X--}return b},w=function(v,y,A,S){const b=v[y+3],P=Math.pow(2,b-128)/255;A[S+0]=v[y+0]*P,A[S+1]=v[y+1]*P,A[S+2]=v[y+2]*P,A[S+3]=1},_=function(v,y,A,S){const b=v[y+3],P=Math.pow(2,b-128)/255;A[S+0]=c.DataUtils.toHalfFloat(Math.min(v[y+0]*P,65504)),A[S+1]=c.DataUtils.toHalfFloat(Math.min(v[y+1]*P,65504)),A[S+2]=c.DataUtils.toHalfFloat(Math.min(v[y+2]*P,65504)),A[S+3]=c.DataUtils.toHalfFloat(1)},M=new Uint8Array(e);M.pos=0;const L=g(M);if(L!==-1){const v=L.width,y=L.height,A=x(M.subarray(M.pos),v,y);if(A!==-1){let S,b,P;switch(this.type){case c.FloatType:P=A.length/4;const O=new Float32Array(P*4);for(let V=0;V<P;V++)w(A,V*4,O,V*4);S=O,b=c.FloatType;break;case c.HalfFloatType:P=A.length/4;const k=new Uint16Array(P*4);for(let V=0;V<P;V++)_(A,V*4,k,V*4);S=k,b=c.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:v,height:y,data:S,header:L.string,gamma:L.gamma,exposure:L.exposure,type:b}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,s){function i(o,r){switch(o.type){case c.FloatType:case c.HalfFloatType:"colorSpace"in o?o.colorSpace="srgb-linear":o.encoding=3e3,o.minFilter=c.LinearFilter,o.magFilter=c.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,r)}return super.load(e,i,n,s)}}class Dt extends c.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,s){const i=this,o=new c.FileLoader(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,function(r){try{t(i.parse(r))}catch(l){s?s(l):console.error(l),i.manager.itemError(e)}},n,s)}parse(e){const t=this;function n(U,T){if(U.nodeType!==1)return;const m=y(U);let F=!0,j=null;switch(U.nodeName){case"svg":break;case"style":i(U);break;case"g":T=x(U,T);break;case"path":T=x(U,T),U.hasAttribute("d")&&(j=s(U));break;case"rect":T=x(U,T),j=l(U);break;case"polygon":T=x(U,T),j=f(U);break;case"polyline":T=x(U,T),j=d(U);break;case"circle":T=x(U,T),j=u(U);break;case"ellipse":T=x(U,T),j=p(U);break;case"line":T=x(U,T),j=g(U);break;case"defs":F=!1;break;case"mask":F=!1;break;case"use":T=x(U,T);const D=U.href.baseVal.substring(1),E=U.viewportElement.getElementById(D);E?n(E,T):console.warn("SVGLoader: 'use node' references non-existent node id: "+D);break}if(j&&(T.fill!==void 0&&T.fill!=="none"&&j.color.setStyle(T.fill),S(j,oe),k.push(j),j.userData={node:U,style:T}),F){const D=U.childNodes;for(let E=0;E<D.length;E++)n(D[E],T)}m&&(R.pop(),R.length>0?oe.copy(R[R.length-1]):oe.identity())}function s(U){const T=new c.ShapePath,m=new c.Vector2,F=new c.Vector2,j=new c.Vector2;let D=!0,E=!1;const Y=U.getAttribute("d").match(/[a-df-z][^a-df-z]*/gi);for(let $=0,Z=Y.length;$<Z;$++){const fe=Y[$],Q=fe.charAt(0),ee=fe.substr(1).trim();D===!0&&(E=!0,D=!1);let I;switch(Q){case"M":I=_(ee);for(let C=0,te=I.length;C<te;C+=2)m.x=I[C+0],m.y=I[C+1],F.x=m.x,F.y=m.y,C===0?T.moveTo(m.x,m.y):T.lineTo(m.x,m.y),C===0&&j.copy(m);break;case"H":I=_(ee);for(let C=0,te=I.length;C<te;C++)m.x=I[C],F.x=m.x,F.y=m.y,T.lineTo(m.x,m.y),C===0&&E===!0&&j.copy(m);break;case"V":I=_(ee);for(let C=0,te=I.length;C<te;C++)m.y=I[C],F.x=m.x,F.y=m.y,T.lineTo(m.x,m.y),C===0&&E===!0&&j.copy(m);break;case"L":I=_(ee);for(let C=0,te=I.length;C<te;C+=2)m.x=I[C+0],m.y=I[C+1],F.x=m.x,F.y=m.y,T.lineTo(m.x,m.y),C===0&&E===!0&&j.copy(m);break;case"C":I=_(ee);for(let C=0,te=I.length;C<te;C+=6)T.bezierCurveTo(I[C+0],I[C+1],I[C+2],I[C+3],I[C+4],I[C+5]),F.x=I[C+2],F.y=I[C+3],m.x=I[C+4],m.y=I[C+5],C===0&&E===!0&&j.copy(m);break;case"S":I=_(ee);for(let C=0,te=I.length;C<te;C+=4)T.bezierCurveTo(w(m.x,F.x),w(m.y,F.y),I[C+0],I[C+1],I[C+2],I[C+3]),F.x=I[C+0],F.y=I[C+1],m.x=I[C+2],m.y=I[C+3],C===0&&E===!0&&j.copy(m);break;case"Q":I=_(ee);for(let C=0,te=I.length;C<te;C+=4)T.quadraticCurveTo(I[C+0],I[C+1],I[C+2],I[C+3]),F.x=I[C+0],F.y=I[C+1],m.x=I[C+2],m.y=I[C+3],C===0&&E===!0&&j.copy(m);break;case"T":I=_(ee);for(let C=0,te=I.length;C<te;C+=2){const pe=w(m.x,F.x),we=w(m.y,F.y);T.quadraticCurveTo(pe,we,I[C+0],I[C+1]),F.x=pe,F.y=we,m.x=I[C+0],m.y=I[C+1],C===0&&E===!0&&j.copy(m)}break;case"A":I=_(ee,[3,4],7);for(let C=0,te=I.length;C<te;C+=7){if(I[C+5]==m.x&&I[C+6]==m.y)continue;const pe=m.clone();m.x=I[C+5],m.y=I[C+6],F.x=m.x,F.y=m.y,o(T,I[C],I[C+1],I[C+2],I[C+3],I[C+4],pe,m),C===0&&E===!0&&j.copy(m)}break;case"m":I=_(ee);for(let C=0,te=I.length;C<te;C+=2)m.x+=I[C+0],m.y+=I[C+1],F.x=m.x,F.y=m.y,C===0?T.moveTo(m.x,m.y):T.lineTo(m.x,m.y),C===0&&j.copy(m);break;case"h":I=_(ee);for(let C=0,te=I.length;C<te;C++)m.x+=I[C],F.x=m.x,F.y=m.y,T.lineTo(m.x,m.y),C===0&&E===!0&&j.copy(m);break;case"v":I=_(ee);for(let C=0,te=I.length;C<te;C++)m.y+=I[C],F.x=m.x,F.y=m.y,T.lineTo(m.x,m.y),C===0&&E===!0&&j.copy(m);break;case"l":I=_(ee);for(let C=0,te=I.length;C<te;C+=2)m.x+=I[C+0],m.y+=I[C+1],F.x=m.x,F.y=m.y,T.lineTo(m.x,m.y),C===0&&E===!0&&j.copy(m);break;case"c":I=_(ee);for(let C=0,te=I.length;C<te;C+=6)T.bezierCurveTo(m.x+I[C+0],m.y+I[C+1],m.x+I[C+2],m.y+I[C+3],m.x+I[C+4],m.y+I[C+5]),F.x=m.x+I[C+2],F.y=m.y+I[C+3],m.x+=I[C+4],m.y+=I[C+5],C===0&&E===!0&&j.copy(m);break;case"s":I=_(ee);for(let C=0,te=I.length;C<te;C+=4)T.bezierCurveTo(w(m.x,F.x),w(m.y,F.y),m.x+I[C+0],m.y+I[C+1],m.x+I[C+2],m.y+I[C+3]),F.x=m.x+I[C+0],F.y=m.y+I[C+1],m.x+=I[C+2],m.y+=I[C+3],C===0&&E===!0&&j.copy(m);break;case"q":I=_(ee);for(let C=0,te=I.length;C<te;C+=4)T.quadraticCurveTo(m.x+I[C+0],m.y+I[C+1],m.x+I[C+2],m.y+I[C+3]),F.x=m.x+I[C+0],F.y=m.y+I[C+1],m.x+=I[C+2],m.y+=I[C+3],C===0&&E===!0&&j.copy(m);break;case"t":I=_(ee);for(let C=0,te=I.length;C<te;C+=2){const pe=w(m.x,F.x),we=w(m.y,F.y);T.quadraticCurveTo(pe,we,m.x+I[C+0],m.y+I[C+1]),F.x=pe,F.y=we,m.x=m.x+I[C+0],m.y=m.y+I[C+1],C===0&&E===!0&&j.copy(m)}break;case"a":I=_(ee,[3,4],7);for(let C=0,te=I.length;C<te;C+=7){if(I[C+5]==0&&I[C+6]==0)continue;const pe=m.clone();m.x+=I[C+5],m.y+=I[C+6],F.x=m.x,F.y=m.y,o(T,I[C],I[C+1],I[C+2],I[C+3],I[C+4],pe,m),C===0&&E===!0&&j.copy(m)}break;case"Z":case"z":T.currentPath.autoClose=!0,T.currentPath.curves.length>0&&(m.copy(j),T.currentPath.currentPoint.copy(m),D=!0);break;default:console.warn(fe)}E=!1}return T}function i(U){if(!(!U.sheet||!U.sheet.cssRules||!U.sheet.cssRules.length))for(let T=0;T<U.sheet.cssRules.length;T++){const m=U.sheet.cssRules[T];if(m.type!==1)continue;const F=m.selectorText.split(/,/gm).filter(Boolean).map(j=>j.trim());for(let j=0;j<F.length;j++)V[F[j]]=Object.assign(V[F[j]]||{},m.style)}}function o(U,T,m,F,j,D,E,ie){if(T==0||m==0){U.lineTo(ie.x,ie.y);return}F=F*Math.PI/180,T=Math.abs(T),m=Math.abs(m);const Y=(E.x-ie.x)/2,$=(E.y-ie.y)/2,Z=Math.cos(F)*Y+Math.sin(F)*$,fe=-Math.sin(F)*Y+Math.cos(F)*$;let Q=T*T,ee=m*m;const I=Z*Z,C=fe*fe,te=I/Q+C/ee;if(te>1){const Ct=Math.sqrt(te);T=Ct*T,m=Ct*m,Q=T*T,ee=m*m}const pe=Q*C+ee*I,we=(Q*ee-pe)/pe;let Pe=Math.sqrt(Math.max(0,we));j===D&&(Pe=-Pe);const ke=Pe*T*fe/m,Xe=-Pe*m*Z/T,Pt=Math.cos(F)*ke-Math.sin(F)*Xe+(E.x+ie.x)/2,jt=Math.sin(F)*ke+Math.cos(F)*Xe+(E.y+ie.y)/2,Ge=r(1,0,(Z-ke)/T,(fe-Xe)/m),un=r((Z-ke)/T,(fe-Xe)/m,(-Z-ke)/T,(-fe-Xe)/m)%(Math.PI*2);U.currentPath.absellipse(Pt,jt,T,m,Ge,Ge+un,D===0,F)}function r(U,T,m,F){const j=U*m+T*F,D=Math.sqrt(U*U+T*T)*Math.sqrt(m*m+F*F);let E=Math.acos(Math.max(-1,Math.min(1,j/D)));return U*F-T*m<0&&(E=-E),E}function l(U){const T=v(U.getAttribute("x")||0),m=v(U.getAttribute("y")||0),F=v(U.getAttribute("rx")||U.getAttribute("ry")||0),j=v(U.getAttribute("ry")||U.getAttribute("rx")||0),D=v(U.getAttribute("width")),E=v(U.getAttribute("height")),ie=1-.551915024494,Y=new c.ShapePath;return Y.moveTo(T+F,m),Y.lineTo(T+D-F,m),(F!==0||j!==0)&&Y.bezierCurveTo(T+D-F*ie,m,T+D,m+j*ie,T+D,m+j),Y.lineTo(T+D,m+E-j),(F!==0||j!==0)&&Y.bezierCurveTo(T+D,m+E-j*ie,T+D-F*ie,m+E,T+D-F,m+E),Y.lineTo(T+F,m+E),(F!==0||j!==0)&&Y.bezierCurveTo(T+F*ie,m+E,T,m+E-j*ie,T,m+E-j),Y.lineTo(T,m+j),(F!==0||j!==0)&&Y.bezierCurveTo(T,m+j*ie,T+F*ie,m,T+F,m),Y}function f(U){function T(D,E,ie){const Y=v(E),$=v(ie);j===0?F.moveTo(Y,$):F.lineTo(Y,$),j++}const m=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,F=new c.ShapePath;let j=0;return U.getAttribute("points").replace(m,T),F.currentPath.autoClose=!0,F}function d(U){function T(D,E,ie){const Y=v(E),$=v(ie);j===0?F.moveTo(Y,$):F.lineTo(Y,$),j++}const m=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,F=new c.ShapePath;let j=0;return U.getAttribute("points").replace(m,T),F.currentPath.autoClose=!1,F}function u(U){const T=v(U.getAttribute("cx")||0),m=v(U.getAttribute("cy")||0),F=v(U.getAttribute("r")||0),j=new c.Path;j.absarc(T,m,F,0,Math.PI*2);const D=new c.ShapePath;return D.subPaths.push(j),D}function p(U){const T=v(U.getAttribute("cx")||0),m=v(U.getAttribute("cy")||0),F=v(U.getAttribute("rx")||0),j=v(U.getAttribute("ry")||0),D=new c.Path;D.absellipse(T,m,F,j,0,Math.PI*2);const E=new c.ShapePath;return E.subPaths.push(D),E}function g(U){const T=v(U.getAttribute("x1")||0),m=v(U.getAttribute("y1")||0),F=v(U.getAttribute("x2")||0),j=v(U.getAttribute("y2")||0),D=new c.ShapePath;return D.moveTo(T,m),D.lineTo(F,j),D.currentPath.autoClose=!1,D}function x(U,T){T=Object.assign({},T);let m={};if(U.hasAttribute("class")){const E=U.getAttribute("class").split(/\s/).filter(Boolean).map(ie=>ie.trim());for(let ie=0;ie<E.length;ie++)m=Object.assign(m,V["."+E[ie]])}U.hasAttribute("id")&&(m=Object.assign(m,V["#"+U.getAttribute("id")]));function F(E,ie,Y){Y===void 0&&(Y=function(Z){return Z.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),Z}),U.hasAttribute(E)&&(T[ie]=Y(U.getAttribute(E))),m[E]&&(T[ie]=Y(m[E])),U.style&&U.style[E]!==""&&(T[ie]=Y(U.style[E]))}function j(E){return Math.max(0,Math.min(1,v(E)))}function D(E){return Math.max(0,v(E))}return F("fill","fill"),F("fill-opacity","fillOpacity",j),F("fill-rule","fillRule"),F("opacity","opacity",j),F("stroke","stroke"),F("stroke-opacity","strokeOpacity",j),F("stroke-width","strokeWidth",D),F("stroke-linejoin","strokeLineJoin"),F("stroke-linecap","strokeLineCap"),F("stroke-miterlimit","strokeMiterLimit",D),F("visibility","visibility"),T}function w(U,T){return U-(T-U)}function _(U,T,m){if(typeof U!="string")throw new TypeError("Invalid input: "+typeof U);const F={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},j=0,D=1,E=2,ie=3;let Y=j,$=!0,Z="",fe="";const Q=[];function ee(pe,we,Pe){const ke=new SyntaxError('Unexpected character "'+pe+'" at index '+we+".");throw ke.partial=Pe,ke}function I(){Z!==""&&(fe===""?Q.push(Number(Z)):Q.push(Number(Z)*Math.pow(10,Number(fe)))),Z="",fe=""}let C;const te=U.length;for(let pe=0;pe<te;pe++){if(C=U[pe],Array.isArray(T)&&T.includes(Q.length%m)&&F.FLAGS.test(C)){Y=D,Z=C,I();continue}if(Y===j){if(F.WHITESPACE.test(C))continue;if(F.DIGIT.test(C)||F.SIGN.test(C)){Y=D,Z=C;continue}if(F.POINT.test(C)){Y=E,Z=C;continue}F.COMMA.test(C)&&($&&ee(C,pe,Q),$=!0)}if(Y===D){if(F.DIGIT.test(C)){Z+=C;continue}if(F.POINT.test(C)){Z+=C,Y=E;continue}if(F.EXP.test(C)){Y=ie;continue}F.SIGN.test(C)&&Z.length===1&&F.SIGN.test(Z[0])&&ee(C,pe,Q)}if(Y===E){if(F.DIGIT.test(C)){Z+=C;continue}if(F.EXP.test(C)){Y=ie;continue}F.POINT.test(C)&&Z[Z.length-1]==="."&&ee(C,pe,Q)}if(Y===ie){if(F.DIGIT.test(C)){fe+=C;continue}if(F.SIGN.test(C)){if(fe===""){fe+=C;continue}fe.length===1&&F.SIGN.test(fe)&&ee(C,pe,Q)}}F.WHITESPACE.test(C)?(I(),Y=j,$=!1):F.COMMA.test(C)?(I(),Y=j,$=!0):F.SIGN.test(C)?(I(),Y=D,Z=C):F.POINT.test(C)?(I(),Y=E,Z=C):ee(C,pe,Q)}return I(),Q}const M=["mm","cm","in","pt","pc","px"],L={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 v(U){let T="px";if(typeof U=="string"||U instanceof String)for(let F=0,j=M.length;F<j;F++){const D=M[F];if(U.endsWith(D)){T=D,U=U.substring(0,U.length-D.length);break}}let m;return T==="px"&&t.defaultUnit!=="px"?m=L.in[t.defaultUnit]/t.defaultDPI:(m=L[T][t.defaultUnit],m<0&&(m=L[T].in*t.defaultDPI)),m*parseFloat(U)}function y(U){if(!(U.hasAttribute("transform")||U.nodeName==="use"&&(U.hasAttribute("x")||U.hasAttribute("y"))))return null;const T=A(U);return R.length>0&&T.premultiply(R[R.length-1]),oe.copy(T),R.push(T),T}function A(U){const T=new c.Matrix3,m=X;if(U.nodeName==="use"&&(U.hasAttribute("x")||U.hasAttribute("y"))){const F=v(U.getAttribute("x")),j=v(U.getAttribute("y"));T.translate(F,j)}if(U.hasAttribute("transform")){const F=U.getAttribute("transform").split(")");for(let j=F.length-1;j>=0;j--){const D=F[j].trim();if(D==="")continue;const E=D.indexOf("("),ie=D.length;if(E>0&&E<ie){const Y=D.substr(0,E),$=_(D.substr(E+1,ie-E-1));switch(m.identity(),Y){case"translate":if($.length>=1){const Z=$[0];let fe=Z;$.length>=2&&(fe=$[1]),m.translate(Z,fe)}break;case"rotate":if($.length>=1){let Z=0,fe=0,Q=0;Z=-$[0]*Math.PI/180,$.length>=3&&(fe=$[1],Q=$[2]),K.identity().translate(-fe,-Q),H.identity().rotate(Z),he.multiplyMatrices(H,K),K.identity().translate(fe,Q),m.multiplyMatrices(K,he)}break;case"scale":if($.length>=1){const Z=$[0];let fe=Z;$.length>=2&&(fe=$[1]),m.scale(Z,fe)}break;case"skewX":$.length===1&&m.set(1,Math.tan($[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":$.length===1&&m.set(1,0,0,Math.tan($[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":$.length===6&&m.set($[0],$[2],$[4],$[1],$[3],$[5],0,0,1);break}}T.premultiply(m)}}return T}function S(U,T){function m(D){G.set(D.x,D.y,1).applyMatrix3(T),D.set(G.x,G.y)}const F=b(T),j=U.subPaths;for(let D=0,E=j.length;D<E;D++){const Y=j[D].curves;for(let $=0;$<Y.length;$++){const Z=Y[$];Z.isLineCurve?(m(Z.v1),m(Z.v2)):Z.isCubicBezierCurve?(m(Z.v0),m(Z.v1),m(Z.v2),m(Z.v3)):Z.isQuadraticBezierCurve?(m(Z.v0),m(Z.v1),m(Z.v2)):Z.isEllipseCurve&&(F&&console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented."),J.set(Z.aX,Z.aY),m(J),Z.aX=J.x,Z.aY=J.y,Z.xRadius*=P(T),Z.yRadius*=O(T))}}}function b(U){return U.elements[1]!==0||U.elements[3]!==0}function P(U){const T=U.elements;return Math.sqrt(T[0]*T[0]+T[1]*T[1])}function O(U){const T=U.elements;return Math.sqrt(T[3]*T[3]+T[4]*T[4])}const k=[],V={},R=[],X=new c.Matrix3,K=new c.Matrix3,H=new c.Matrix3,he=new c.Matrix3,J=new c.Vector2,G=new c.Vector3,oe=new c.Matrix3,se=new DOMParser().parseFromString(e,"image/svg+xml");return n(se.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:k,xml:se.documentElement}}static createShapes(e){const n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},s={loc:n.ORIGIN,t:0};function i(_,M,L,v){const y=_.x,A=M.x,S=L.x,b=v.x,P=_.y,O=M.y,k=L.y,V=v.y,R=(b-S)*(P-k)-(V-k)*(y-S),X=(A-y)*(P-k)-(O-P)*(y-S),K=(V-k)*(A-y)-(b-S)*(O-P),H=R/K,he=X/K;if(K===0&&R!==0||H<=0||H>=1||he<0||he>1)return null;if(R===0&&K===0){for(let J=0;J<2;J++)if(o(J===0?L:v,_,M),s.loc==n.ORIGIN){const G=J===0?L:v;return{x:G.x,y:G.y,t:s.t}}else if(s.loc==n.BETWEEN){const G=+(y+s.t*(A-y)).toPrecision(10),oe=+(P+s.t*(O-P)).toPrecision(10);return{x:G,y:oe,t:s.t}}return null}else{for(let oe=0;oe<2;oe++)if(o(oe===0?L:v,_,M),s.loc==n.ORIGIN){const se=oe===0?L:v;return{x:se.x,y:se.y,t:s.t}}const J=+(y+H*(A-y)).toPrecision(10),G=+(P+H*(O-P)).toPrecision(10);return{x:J,y:G,t:H}}}function o(_,M,L){const v=L.x-M.x,y=L.y-M.y,A=_.x-M.x,S=_.y-M.y,b=v*S-A*y;if(_.x===M.x&&_.y===M.y){s.loc=n.ORIGIN,s.t=0;return}if(_.x===L.x&&_.y===L.y){s.loc=n.DESTINATION,s.t=1;return}if(b<-Number.EPSILON){s.loc=n.LEFT;return}if(b>Number.EPSILON){s.loc=n.RIGHT;return}if(v*A<0||y*S<0){s.loc=n.BEHIND;return}if(Math.sqrt(v*v+y*y)<Math.sqrt(A*A+S*S)){s.loc=n.BEYOND;return}let P;v!==0?P=A/v:P=S/y,s.loc=n.BETWEEN,s.t=P}function r(_,M){const L=[],v=[];for(let y=1;y<_.length;y++){const A=_[y-1],S=_[y];for(let b=1;b<M.length;b++){const P=M[b-1],O=M[b],k=i(A,S,P,O);k!==null&&L.find(V=>V.t<=k.t+Number.EPSILON&&V.t>=k.t-Number.EPSILON)===void 0&&(L.push(k),v.push(new c.Vector2(k.x,k.y)))}}return v}function l(_,M,L){const v=new c.Vector2;M.getCenter(v);const y=[];return L.forEach(A=>{A.boundingBox.containsPoint(v)&&r(_,A.points).forEach(b=>{y.push({identifier:A.identifier,isCW:A.isCW,point:b})})}),y.sort((A,S)=>A.point.x-S.point.x),y}function f(_,M,L,v,y){(y==null||y==="")&&(y="nonzero");const A=new c.Vector2;_.boundingBox.getCenter(A);const S=[new c.Vector2(L,A.y),new c.Vector2(v,A.y)],b=l(S,_.boundingBox,M);b.sort((X,K)=>X.point.x-K.point.x);const P=[],O=[];b.forEach(X=>{X.identifier===_.identifier?P.push(X):O.push(X)});const k=P[0].point.x,V=[];let R=0;for(;R<O.length&&O[R].point.x<k;)V.length>0&&V[V.length-1]===O[R].identifier?V.pop():V.push(O[R].identifier),R++;if(V.push(_.identifier),y==="evenodd"){const X=V.length%2===0,K=V[V.length-2];return{identifier:_.identifier,isHole:X,for:K}}else if(y==="nonzero"){let X=!0,K=null,H=null;for(let he=0;he<V.length;he++){const J=V[he];X?(H=M[J].isCW,X=!1,K=J):H!==M[J].isCW&&(H=M[J].isCW,X=!0)}return{identifier:_.identifier,isHole:X,for:K}}else console.warn('fill-rule: "'+y+'" is currently not implemented.')}let d=0,u=999999999,p=-999999999,g=e.subPaths.map(_=>{const M=_.getPoints();let L=-999999999,v=999999999,y=-999999999,A=999999999;for(let S=0;S<M.length;S++){const b=M[S];b.y>L&&(L=b.y),b.y<v&&(v=b.y),b.x>y&&(y=b.x),b.x<A&&(A=b.x)}return p<=y&&(p=y+1),u>=A&&(u=A-1),{curves:_.curves,points:M,isCW:c.ShapeUtils.isClockWise(M),identifier:d++,boundingBox:new c.Box2(new c.Vector2(A,v),new c.Vector2(y,L))}});g=g.filter(_=>_.points.length>1);const x=g.map(_=>f(_,g,u,p,e.userData.style.fillRule)),w=[];return g.forEach(_=>{if(!x[_.identifier].isHole){const L=new c.Shape;L.curves=_.curves,x.filter(y=>y.isHole&&y.for===_.identifier).forEach(y=>{const A=g[y.identifier],S=new c.Path;S.curves=A.curves,L.holes.push(S)}),w.push(L)}}),w}static getStrokeStyle(e,t,n,s,i){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",s=s!==void 0?s:"butt",i=i!==void 0?i:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:s,strokeMiterLimit:i}}static pointsToStroke(e,t,n,s){const i=[],o=[],r=[];if(Dt.pointsToStrokeWithBuffers(e,t,n,s,i,o,r)===0)return null;const l=new c.BufferGeometry;return l.setAttribute("position",new c.Float32BufferAttribute(i,3)),l.setAttribute("normal",new c.Float32BufferAttribute(o,3)),l.setAttribute("uv",new c.Float32BufferAttribute(r,2)),l}static pointsToStrokeWithBuffers(e,t,n,s,i,o,r,l){const f=new c.Vector2,d=new c.Vector2,u=new c.Vector2,p=new c.Vector2,g=new c.Vector2,x=new c.Vector2,w=new c.Vector2,_=new c.Vector2,M=new c.Vector2,L=new c.Vector2,v=new c.Vector2,y=new c.Vector2,A=new c.Vector2,S=new c.Vector2,b=new c.Vector2,P=new c.Vector2,O=new c.Vector2;n=n!==void 0?n:12,s=s!==void 0?s:.001,l=l!==void 0?l:0,e=fe(e);const k=e.length;if(k<2)return 0;const V=e[0].equals(e[k-1]);let R,X=e[0],K;const H=t.strokeWidth/2,he=1/(k-1);let J=0,G,oe,se,ce,U=!1,T=0,m=l*3,F=l*2;j(e[0],e[1],f).multiplyScalar(H),_.copy(e[0]).sub(f),M.copy(e[0]).add(f),L.copy(_),v.copy(M);for(let Q=1;Q<k;Q++){R=e[Q],Q===k-1?V?K=e[1]:K=void 0:K=e[Q+1];const ee=f;if(j(X,R,ee),u.copy(ee).multiplyScalar(H),y.copy(R).sub(u),A.copy(R).add(u),G=J+he,oe=!1,K!==void 0){j(R,K,d),u.copy(d).multiplyScalar(H),S.copy(R).sub(u),b.copy(R).add(u),se=!0,u.subVectors(K,X),ee.dot(u)<0&&(se=!1),Q===1&&(U=se),u.subVectors(K,R),u.normalize();const I=Math.abs(ee.dot(u));if(I!==0){const C=H/I;u.multiplyScalar(-C),p.subVectors(R,X),g.copy(p).setLength(C).add(u),P.copy(g).negate();const te=g.length(),pe=p.length();p.divideScalar(pe),x.subVectors(K,R);const we=x.length();switch(x.divideScalar(we),p.dot(P)<pe&&x.dot(P)<we&&(oe=!0),O.copy(g).add(R),P.add(R),ce=!1,oe?se?(b.copy(P),A.copy(P)):(S.copy(P),y.copy(P)):ie(),t.strokeLineJoin){case"bevel":Y(se,oe,G);break;case"round":$(se,oe),se?E(R,y,S,G,0):E(R,b,A,G,1);break;case"miter":case"miter-clip":default:const Pe=H*t.strokeMiterLimit/te;if(Pe<1)if(t.strokeLineJoin!=="miter-clip"){Y(se,oe,G);break}else $(se,oe),se?(x.subVectors(O,y).multiplyScalar(Pe).add(y),w.subVectors(O,S).multiplyScalar(Pe).add(S),D(y,G,0),D(x,G,0),D(R,G,.5),D(R,G,.5),D(x,G,0),D(w,G,0),D(R,G,.5),D(w,G,0),D(S,G,0)):(x.subVectors(O,A).multiplyScalar(Pe).add(A),w.subVectors(O,b).multiplyScalar(Pe).add(b),D(A,G,1),D(x,G,1),D(R,G,.5),D(R,G,.5),D(x,G,1),D(w,G,1),D(R,G,.5),D(w,G,1),D(b,G,1));else oe?(se?(D(M,J,1),D(_,J,0),D(O,G,0),D(M,J,1),D(O,G,0),D(P,G,1)):(D(M,J,1),D(_,J,0),D(O,G,1),D(_,J,0),D(P,G,0),D(O,G,1)),se?S.copy(O):b.copy(O)):se?(D(y,G,0),D(O,G,0),D(R,G,.5),D(R,G,.5),D(O,G,0),D(S,G,0)):(D(A,G,1),D(O,G,1),D(R,G,.5),D(R,G,.5),D(O,G,1),D(b,G,1)),ce=!0;break}}else ie()}else ie();!V&&Q===k-1&&Z(e[0],L,v,se,!0,J),J=G,X=R,_.copy(S),M.copy(b)}if(!V)Z(R,y,A,se,!1,G);else if(oe&&i){let Q=O,ee=P;U!==se&&(Q=P,ee=O),se?(ce||U)&&(ee.toArray(i,0*3),ee.toArray(i,3*3),ce&&Q.toArray(i,1*3)):(ce||!U)&&(ee.toArray(i,1*3),ee.toArray(i,3*3),ce&&Q.toArray(i,0*3))}return T;function j(Q,ee,I){return I.subVectors(ee,Q),I.set(-I.y,I.x).normalize()}function D(Q,ee,I){i&&(i[m]=Q.x,i[m+1]=Q.y,i[m+2]=0,o&&(o[m]=0,o[m+1]=0,o[m+2]=1),m+=3,r&&(r[F]=ee,r[F+1]=I,F+=2)),T+=3}function E(Q,ee,I,C,te){f.copy(ee).sub(Q).normalize(),d.copy(I).sub(Q).normalize();let pe=Math.PI;const we=f.dot(d);Math.abs(we)<1&&(pe=Math.abs(Math.acos(we))),pe/=n,u.copy(ee);for(let Pe=0,ke=n-1;Pe<ke;Pe++)p.copy(u).rotateAround(Q,pe),D(u,C,te),D(p,C,te),D(Q,C,.5),u.copy(p);D(p,C,te),D(I,C,te),D(Q,C,.5)}function ie(){D(M,J,1),D(_,J,0),D(y,G,0),D(M,J,1),D(y,G,1),D(A,G,0)}function Y(Q,ee,I){ee?Q?(D(M,J,1),D(_,J,0),D(y,G,0),D(M,J,1),D(y,G,0),D(P,G,1),D(y,I,0),D(S,I,0),D(P,I,.5)):(D(M,J,1),D(_,J,0),D(A,G,1),D(_,J,0),D(P,G,0),D(A,G,1),D(A,I,1),D(b,I,0),D(P,I,.5)):Q?(D(y,I,0),D(S,I,0),D(R,I,.5)):(D(A,I,1),D(b,I,0),D(R,I,.5))}function $(Q,ee){ee&&(Q?(D(M,J,1),D(_,J,0),D(y,G,0),D(M,J,1),D(y,G,0),D(P,G,1),D(y,J,0),D(R,G,.5),D(P,G,1),D(R,G,.5),D(S,J,0),D(P,G,1)):(D(M,J,1),D(_,J,0),D(A,G,1),D(_,J,0),D(P,G,0),D(A,G,1),D(A,J,1),D(P,G,0),D(R,G,.5),D(R,G,.5),D(P,G,0),D(b,J,1)))}function Z(Q,ee,I,C,te,pe){switch(t.strokeLineCap){case"round":te?E(Q,I,ee,pe,.5):E(Q,ee,I,pe,.5);break;case"square":if(te)f.subVectors(ee,Q),d.set(f.y,-f.x),u.addVectors(f,d).add(Q),p.subVectors(d,f).add(Q),C?(u.toArray(i,1*3),p.toArray(i,0*3),p.toArray(i,3*3)):(u.toArray(i,1*3),u.toArray(i,3*3),p.toArray(i,0*3));else{f.subVectors(I,Q),d.set(f.y,-f.x),u.addVectors(f,d).add(Q),p.subVectors(d,f).add(Q);const we=i.length;C?(u.toArray(i,we-1*3),p.toArray(i,we-2*3),p.toArray(i,we-4*3)):(u.toArray(i,we-2*3),p.toArray(i,we-1*3),p.toArray(i,we-4*3))}break}}function fe(Q){let ee=!1;for(let C=1,te=Q.length-1;C<te;C++)if(Q[C].distanceTo(Q[C+1])<s){ee=!0;break}if(!ee)return Q;const I=[];I.push(Q[0]);for(let C=1,te=Q.length-1;C<te;C++)Q[C].distanceTo(Q[C+1])>=s&&I.push(Q[C]);return I.push(Q[Q.length-1]),I}}}const Tn=new WeakMap;class hr extends c.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,s){const i=new c.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,o=>{const r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,r).then(t).catch(s)},n,s)}decodeDracoFile(e,t,n,s){const i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(const l in t.attributeTypes){const f=t.attributeTypes[l];f.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=f.name)}const n=JSON.stringify(t);if(Tn.has(e)){const l=Tn.get(e);if(l.key===n)return l.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 s;const i=this.workerNextTaskID++,o=e.byteLength,r=this._getWorker(i,o).then(l=>(s=l,new Promise((f,d)=>{s._callbacks[i]={resolve:f,reject:d},s.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return r.catch(()=>!0).then(()=>{s&&i&&this._releaseTask(s,i)}),Tn.set(e,{key:n,promise:r}),r}_createGeometry(e){const t=new c.BufferGeometry;e.index&&t.setIndex(new c.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],i=s.name,o=s.array,r=s.itemSize;t.setAttribute(i,new c.BufferAttribute(o,r))}return t}_loadLibrary(e,t){const n=new c.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,i)=>{n.load(e,s,void 0,i)})}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 s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const i=ur.toString(),o=["/* draco decoder */",s,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
79
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(i){const o=i.data;switch(o.type){case"decode":s._callbacks[o.id].resolve(o);break;case"error":s._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,i){return s._taskLoad>i._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 ur(){let a,e;onmessage=function(o){const r=o.data;switch(r.type){case"init":a=r.decoderConfig,e=new Promise(function(d){a.onModuleLoaded=function(u){d({draco:u})},DracoDecoderModule(a)});break;case"decode":const l=r.buffer,f=r.taskConfig;e.then(d=>{const u=d.draco,p=new u.Decoder,g=new u.DecoderBuffer;g.Init(new Int8Array(l),l.byteLength);try{const x=t(u,p,g,f),w=x.attributes.map(_=>_.array.buffer);x.index&&w.push(x.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:x},w)}catch(x){console.error(x),self.postMessage({type:"error",id:r.id,error:x.message})}finally{u.destroy(g),u.destroy(p)}});break}};function t(o,r,l,f){const d=f.attributeIDs,u=f.attributeTypes;let p,g;const x=r.GetEncodedGeometryType(l);if(x===o.TRIANGULAR_MESH)p=new o.Mesh,g=r.DecodeBufferToMesh(l,p);else if(x===o.POINT_CLOUD)p=new o.PointCloud,g=r.DecodeBufferToPointCloud(l,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!g.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());const w={index:null,attributes:[]};for(const _ in d){const M=self[u[_]];let L,v;if(f.useUniqueIDs)v=d[_],L=r.GetAttributeByUniqueId(p,v);else{if(v=r.GetAttributeId(p,o[d[_]]),v===-1)continue;L=r.GetAttribute(p,v)}w.attributes.push(s(o,r,p,_,M,L))}return x===o.TRIANGULAR_MESH&&(w.index=n(o,r,p)),o.destroy(p),w}function n(o,r,l){const d=l.num_faces()*3,u=d*4,p=o._malloc(u);r.GetTrianglesUInt32Array(l,u,p);const g=new Uint32Array(o.HEAPF32.buffer,p,d).slice();return o._free(p),{array:g,itemSize:1}}function s(o,r,l,f,d,u){const p=u.num_components(),x=l.num_points()*p,w=x*d.BYTES_PER_ELEMENT,_=i(o,d),M=o._malloc(w);r.GetAttributeDataArrayForAllPoints(l,u,_,w,M);const L=new d(o.HEAPF32.buffer,M,x).slice();return o._free(M),{name:f,array:L,itemSize:p}}function i(o,r){switch(r){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}const dr=["args","center"],fr=h.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const s=a,{center:i,font:o,text:r,needUpdates:l,size:f,height:d,curveSegments:u,bevelEnabled:p,bevelThickness:g,bevelSize:x,bevelOffset:w,bevelSegments:_}=h.toRefs(s),{extend:M}=ne.useTresContext();M({TextGeometry:_s});const L=new ar,v=h.useSlots(),y=h.computed(()=>{var P;return r!=null&&r.value?r.value:v.default?(P=v.default()[0].children)==null?void 0:P.trim():l.value?"":"TresJS"}),A=h.shallowRef();e({value:A});const S=([t,n]=h.withAsyncContext(()=>new Promise((P,O)=>{try{typeof o.value=="string"?L.load(o.value,k=>{P(k)}):P(o.value)}catch(k){O(console.error("cientos",k))}})),t=await t,n(),t),b=h.computed(()=>({font:S,size:h.toValue(f),height:h.toValue(d),curveSegments:h.toValue(u),bevelEnabled:h.toValue(p),bevelThickness:h.toValue(g),bevelSize:h.toValue(x),bevelOffset:h.toValue(w),bevelSegments:h.toValue(_)}));return h.watchEffect(()=>{A.value&&l.value&&(A.value.geometry.dispose(),A.value.geometry=new _s(y.value,b.value),i.value&&A.value.geometry.center())}),(P,O)=>h.unref(o)?(h.openBlock(),h.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:A},[y.value?(h.openBlock(),h.createElementBlock("TresTextGeometry",{key:0,args:[y.value,b.value],center:h.unref(i)},null,8,dr)):h.createCommentVNode("",!0),h.renderSlot(P.$slots,"default")],512)):h.createCommentVNode("",!0)}});function pr(a,e){const t=h.ref(e),n=new c.AnimationMixer(t.value),s=h.shallowReactive({});a.forEach(o=>{const r=n.clipAction(o,t.value);s[o.name]=r});const{onLoop:i}=ne.useRenderLoop();return i(({delta:o})=>{n.update(o)}),{actions:s,mixer:n}}const mr=h.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=h.shallowRef();e({value:n});{const l=Math.random()*1e4,{onLoop:f}=ne.useRenderLoop();let d=l;f(({delta:u})=>{if(!n.value)return;d+=u*t.speed;const p=d*.25,g=n.value;g.rotation.x=Math.cos(p)*.125*t.rotationFactor,g.rotation.y=Math.sin(p)*.125*t.rotationFactor,g.rotation.z=Math.sin(p)*.05*t.rotationFactor,g.position.y=c.MathUtils.mapLinear(Math.sin(p),-1,1,t.range[0],t.range[1])*t.floatFactor})}return(s,i)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps(s.$attrs,{ref_key:"groupRef",ref:n}),[h.renderSlot(s.$slots,"default")],16))}});function Ts(a){return h.getCurrentScope()?(h.onScopeDispose(a),!0):!1}function ze(a){return typeof a=="function"?a():h.unref(a)}const gr=typeof window<"u"&&typeof document<"u",yr=Object.prototype.toString,_r=a=>yr.call(a)==="[object Object]",ut=()=>{};function Os(a,e){function t(...n){return new Promise((s,i)=>{Promise.resolve(a(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})).then(s).catch(i)})}return t}function vr(a,e={}){let t,n,s=ut;const i=r=>{clearTimeout(r),s(),s=ut};return r=>{const l=ze(a),f=ze(e.maxWait);return t&&i(t),l<=0||f!==void 0&&f<=0?(n&&(i(n),n=null),Promise.resolve(r())):new Promise((d,u)=>{s=e.rejectOnCancel?u:d,f&&!n&&(n=setTimeout(()=>{t&&i(t),n=null,d(r())},f)),t=setTimeout(()=>{n&&i(n),n=null,d(r())},l)})}}function xr(a,e=!0,t=!0,n=!1){let s=0,i,o=!0,r=ut,l;const f=()=>{i&&(clearTimeout(i),i=void 0,r(),r=ut)};return u=>{const p=ze(a),g=Date.now()-s,x=()=>l=u();return f(),p<=0?(s=Date.now(),x()):(g>p&&(t||!o)?(s=Date.now(),x()):e&&(l=new Promise((w,_)=>{r=n?_:w,i=setTimeout(()=>{s=Date.now(),o=!0,w(x()),f()},Math.max(0,p-g))})),!t&&!i&&(i=setTimeout(()=>o=!0,p)),o=!1,l)}}function wr(a,e=200,t={}){return Os(vr(e,t),a)}function br(a,e=200,t=!1,n=!0,s=!1){return Os(xr(e,t,n,s),a)}function Ar(a,e=!0){h.getCurrentInstance()?h.onMounted(a):e?a():h.nextTick(a)}function Mr(a){var e;const t=ze(a);return(e=t==null?void 0:t.$el)!=null?e:t}const dt=gr?window:void 0;function Ae(...a){let e,t,n,s;if(typeof a[0]=="string"||Array.isArray(a[0])?([t,n,s]=a,e=dt):[e,t,n,s]=a,!e)return ut;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const i=[],o=()=>{i.forEach(d=>d()),i.length=0},r=(d,u,p,g)=>(d.addEventListener(u,p,g),()=>d.removeEventListener(u,p,g)),l=h.watch(()=>[Mr(e),ze(s)],([d,u])=>{if(o(),!d)return;const p=_r(u)?{...u}:u;i.push(...t.flatMap(g=>n.map(x=>r(d,g,x,p))))},{immediate:!0,flush:"post"}),f=()=>{l(),o()};return Ts(f),f}function Sr(a){return typeof a=="function"?a:typeof a=="string"?e=>e.key===a:Array.isArray(a)?e=>a.includes(e.key):()=>!0}function ft(...a){let e,t,n={};a.length===3?(e=a[0],t=a[1],n=a[2]):a.length===2?typeof a[1]=="object"?(e=!0,t=a[0],n=a[1]):(e=a[0],t=a[1]):(e=!0,t=a[0]);const{target:s=dt,eventName:i="keydown",passive:o=!1,dedupe:r=!1}=n,l=Sr(e);return Ae(s,i,d=>{d.repeat&&ze(r)||l(d)&&t(d)},o)}function Pr(){const a=h.ref(!1);return h.getCurrentInstance()&&h.onMounted(()=>{a.value=!0}),a}function Cr(a){const e=Pr();return h.computed(()=>(e.value,!!a()))}function Lr(a,e={}){const{window:t=dt}=e,n=Cr(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let s;const i=h.ref(!1),o=f=>{i.value=f.matches},r=()=>{s&&("removeEventListener"in s?s.removeEventListener("change",o):s.removeListener(o))},l=h.watchEffect(()=>{n.value&&(r(),s=t.matchMedia(ze(a)),"addEventListener"in s?s.addEventListener("change",o):s.addListener(o),i.value=s.matches)});return Ts(()=>{l(),r(),s=void 0}),i}const Ds=1;function Tr(a,e={}){const{throttle:t=0,idle:n=200,onStop:s=ut,onScroll:i=ut,offset:o={left:0,right:0,top:0,bottom:0},eventListenerOptions:r={capture:!1,passive:!0},behavior:l="auto",window:f=dt}=e,d=h.ref(0),u=h.ref(0),p=h.computed({get(){return d.value},set(S){x(S,void 0)}}),g=h.computed({get(){return u.value},set(S){x(void 0,S)}});function x(S,b){var P,O,k;if(!f)return;const V=ze(a);V&&((k=V instanceof Document?f.document.body:V)==null||k.scrollTo({top:(P=ze(b))!=null?P:g.value,left:(O=ze(S))!=null?O:p.value,behavior:ze(l)}))}const w=h.ref(!1),_=h.reactive({left:!0,right:!1,top:!0,bottom:!1}),M=h.reactive({left:!1,right:!1,top:!1,bottom:!1}),L=S=>{w.value&&(w.value=!1,M.left=!1,M.right=!1,M.top=!1,M.bottom=!1,s(S))},v=wr(L,t+n),y=S=>{var b;if(!f)return;const P=S.document?S.document.documentElement:(b=S.documentElement)!=null?b:S,{display:O,flexDirection:k}=getComputedStyle(P),V=P.scrollLeft;M.left=V<d.value,M.right=V>d.value;const R=Math.abs(V)<=0+(o.left||0),X=Math.abs(V)+P.clientWidth>=P.scrollWidth-(o.right||0)-Ds;O==="flex"&&k==="row-reverse"?(_.left=X,_.right=R):(_.left=R,_.right=X),d.value=V;let K=P.scrollTop;S===f.document&&!K&&(K=f.document.body.scrollTop),M.top=K<u.value,M.bottom=K>u.value;const H=Math.abs(K)<=0+(o.top||0),he=Math.abs(K)+P.clientHeight>=P.scrollHeight-(o.bottom||0)-Ds;O==="flex"&&k==="column-reverse"?(_.top=he,_.bottom=H):(_.top=H,_.bottom=he),u.value=K},A=S=>{var b;if(!f)return;const P=(b=S.target.documentElement)!=null?b:S.target;y(P),w.value=!0,v(S),i(S)};return Ae(a,"scroll",t?br(A,t,!0,!1):A,r),Ae(a,"scrollend",L,r),{x:p,y:g,isScrolling:w,arrivedState:_,directions:M,measure(){const S=ze(a);f&&S&&y(S)}}}const Or={page:a=>[a.pageX,a.pageY],client:a=>[a.clientX,a.clientY],screen:a=>[a.screenX,a.screenY],movement:a=>a instanceof Touch?null:[a.movementX,a.movementY]};function Dr(a={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:s={x:0,y:0},window:i=dt,target:o=i,scroll:r=!0,eventFilter:l}=a;let f=null;const d=h.ref(s.x),u=h.ref(s.y),p=h.ref(null),g=typeof e=="function"?e:Or[e],x=A=>{const S=g(A);f=A,S&&([d.value,u.value]=S,p.value="mouse")},w=A=>{if(A.touches.length>0){const S=g(A.touches[0]);S&&([d.value,u.value]=S,p.value="touch")}},_=()=>{if(!f||!i)return;const A=g(f);f instanceof MouseEvent&&A&&(d.value=A[0]+i.scrollX,u.value=A[1]+i.scrollY)},M=()=>{d.value=s.x,u.value=s.y},L=l?A=>l(()=>x(A),{}):A=>x(A),v=l?A=>l(()=>w(A),{}):A=>w(A),y=l?()=>l(()=>_(),{}):()=>_();if(o){const A={passive:!0};Ae(o,["mousemove","dragover"],L,A),t&&e!=="movement"&&(Ae(o,["touchstart","touchmove"],v,A),n&&Ae(o,"touchend",M,A)),r&&e==="page"&&Ae(i,"scroll",y,{passive:!0})}return{x:d,y:u,sourceType:p}}function Ir(a={}){const{window:e=dt}=a;if(!e)return{x:h.ref(0),y:h.ref(0)};const t=h.ref(e.scrollX),n=h.ref(e.scrollY);return Ae(e,"scroll",()=>{t.value=e.scrollX,n.value=e.scrollY},{capture:!1,passive:!0}),{x:t,y:n}}function Is(a={}){const{window:e=dt,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:n=Number.POSITIVE_INFINITY,listenOrientation:s=!0,includeScrollbar:i=!0}=a,o=h.ref(t),r=h.ref(n),l=()=>{e&&(i?(o.value=e.innerWidth,r.value=e.innerHeight):(o.value=e.document.documentElement.clientWidth,r.value=e.document.documentElement.clientHeight))};if(l(),Ar(l),Ae("resize",l,{passive:!0}),s){const f=Lr("(orientation: portrait)");h.watch(f,()=>l())}return{width:o,height:r}}const kr=h.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(a){const e=a,{camera:t}=ne.useTresContext(),{disabled:n,factor:s,ease:i}=h.toRefs(e),{x:o,y:r}=Dr(),{width:l,height:f}=Is(),d=h.ref(),u=h.computed(()=>(o.value/l.value-.5)*s.value),p=h.computed(()=>-(r.value/f.value-.5)*s.value),{onLoop:g}=ne.useRenderLoop();return g(({delta:x})=>{n.value||!d.value||(d.value.position.x+=(u.value-d.value.position.x)*i.value*x,d.value.position.y+=(p.value-d.value.position.y)*i.value*x)}),h.watch(()=>d.value,x=>x==null?void 0:x.add(t.value)),(x,w)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:d},null,512))}}),Fr=h.defineComponent({name:"GlobalAudio",props:["src","loop","volume","playbackRate","playTrigger","stopTrigger"],async setup(a,{expose:e,emit:t}){var u;const{camera:n,renderer:s}=ne.useTresContext(),i=new c.AudioListener;(u=n.value)==null||u.add(i);const o=new c.Audio(i),r=new c.AudioLoader;e({sound:o}),h.onUnmounted(()=>{o&&o.disconnect()}),h.watch(()=>[a.playbackRate],()=>o.setPlaybackRate(a.playbackRate??1),{immediate:!0}),h.watch(()=>[a.volume],()=>o.setVolume(a.volume??.5),{immediate:!0}),h.watch(()=>[a.loop],()=>o.setLoop(a.loop??!1),{immediate:!0}),h.watch(()=>[a.src],async()=>{const p=await r.loadAsync(a.src);o.setBuffer(p)},{immediate:!0});const l=document.getElementById(a.playTrigger??""),f=l||s.value.domElement;Ae(f,"click",()=>{o.isPlaying?o.pause():o.play(),t("isPlaying",o.isPlaying)});const d=document.getElementById(a.stopTrigger??"");return d&&Ae(d,"click",()=>{o.stop(),t("isPlaying",o.isPlaying)}),null}});class It extends c.Mesh{constructor(){super(It.Geometry,new c.MeshBasicMaterial({opacity:0,transparent:!0})),this.isLensflare=!0,this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;const e=new c.Vector3,t=new c.Vector3,n=new c.FramebufferTexture(16,16),s=new c.FramebufferTexture(16,16),i=It.Geometry,o=new c.RawShaderMaterial({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:`
80
80
 
81
81
  precision highp float;
82
82
 
@@ -97,7 +97,7 @@
97
97
 
98
98
  gl_FragColor = vec4( 1.0, 0.0, 1.0, 1.0 );
99
99
 
100
- }`,depthTest:!0,depthWrite:!1,transparent:!1}),r=new c.RawShaderMaterial({uniforms:{map:{value:s},scale:{value:null},screenPosition:{value:null}},vertexShader:`
100
+ }`,depthTest:!0,depthWrite:!1,transparent:!1}),r=new c.RawShaderMaterial({uniforms:{map:{value:n},scale:{value:null},screenPosition:{value:null}},vertexShader:`
101
101
 
102
102
  precision highp float;
103
103
 
@@ -127,7 +127,7 @@
127
127
 
128
128
  gl_FragColor = texture2D( map, vUV );
129
129
 
130
- }`,depthTest:!1,depthWrite:!1,transparent:!1}),a=new c.Mesh(i,o),h=[],f=rn.Shader,p=new c.RawShaderMaterial({uniforms:{map:{value:null},occlusionMap:{value:n},color:{value:new c.Color(16777215)},scale:{value:new c.Vector2},screenPosition:{value:new c.Vector3}},vertexShader:f.vertexShader,fragmentShader:f.fragmentShader,blending:c.AdditiveBlending,transparent:!0,depthWrite:!1}),m=new c.Mesh(i,p);this.addElement=function(S){h.push(S)};const g=new c.Vector2,w=new c.Vector2,x=new c.Box2,_=new c.Vector4;this.onBeforeRender=function(S,C,v){S.getCurrentViewport(_);const y=_.w/_.z,M=_.z/2,P=_.w/2;let A=16/_.w;if(g.set(A*y,A),x.min.set(_.x,_.y),x.max.set(_.x+(_.z-16),_.y+(_.w-16)),t.setFromMatrixPosition(this.matrixWorld),t.applyMatrix4(v.matrixWorldInverse),!(t.z>0)&&(e.copy(t).applyMatrix4(v.projectionMatrix),w.x=_.x+e.x*M+M-8,w.y=_.y+e.y*P+P-8,x.containsPoint(w))){S.copyFramebufferToTexture(w,s);let b=o.uniforms;b.scale.value=g,b.screenPosition.value=e,S.renderBufferDirect(v,null,i,o,a,null),S.copyFramebufferToTexture(w,n),b=r.uniforms,b.scale.value=g,b.screenPosition.value=e,S.renderBufferDirect(v,null,i,r,a,null);const D=-e.x*2,z=-e.y*2;for(let U=0,R=h.length;U<R;U++){const K=h[U],Z=p.uniforms;Z.color.value.copy(K.color),Z.map.value=K.texture,Z.screenPosition.value.x=e.x+D*K.distance,Z.screenPosition.value.y=e.y+z*K.distance,A=K.size/_.w;const W=_.w/_.z;Z.scale.value.set(A*W,A),p.uniformsNeedUpdate=!0,S.renderBufferDirect(v,null,i,p,m,null)}}},this.dispose=function(){o.dispose(),r.dispose(),p.dispose(),s.dispose(),n.dispose();for(let S=0,C=h.length;S<C;S++)h[S].texture.dispose()}}}class rn{constructor(e,t=1,s=0,n=new c.Color(16777215)){this.texture=e,this.size=t,this.distance=s,this.color=n}}rn.Shader={uniforms:{map:{value:null},occlusionMap:{value:null},color:{value:null},scale:{value:null},screenPosition:{value:null}},vertexShader:`
130
+ }`,depthTest:!1,depthWrite:!1,transparent:!1}),l=new c.Mesh(i,o),f=[],d=ks.Shader,u=new c.RawShaderMaterial({uniforms:{map:{value:null},occlusionMap:{value:s},color:{value:new c.Color(16777215)},scale:{value:new c.Vector2},screenPosition:{value:new c.Vector3}},vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,blending:c.AdditiveBlending,transparent:!0,depthWrite:!1}),p=new c.Mesh(i,u);this.addElement=function(M){f.push(M)};const g=new c.Vector2,x=new c.Vector2,w=new c.Box2,_=new c.Vector4;this.onBeforeRender=function(M,L,v){M.getCurrentViewport(_);const y=_.w/_.z,A=_.z/2,S=_.w/2;let b=16/_.w;if(g.set(b*y,b),w.min.set(_.x,_.y),w.max.set(_.x+(_.z-16),_.y+(_.w-16)),t.setFromMatrixPosition(this.matrixWorld),t.applyMatrix4(v.matrixWorldInverse),!(t.z>0)&&(e.copy(t).applyMatrix4(v.projectionMatrix),x.x=_.x+e.x*A+A-8,x.y=_.y+e.y*S+S-8,w.containsPoint(x))){M.copyFramebufferToTexture(x,n);let P=o.uniforms;P.scale.value=g,P.screenPosition.value=e,M.renderBufferDirect(v,null,i,o,l,null),M.copyFramebufferToTexture(x,s),P=r.uniforms,P.scale.value=g,P.screenPosition.value=e,M.renderBufferDirect(v,null,i,r,l,null);const O=-e.x*2,k=-e.y*2;for(let V=0,R=f.length;V<R;V++){const X=f[V],K=u.uniforms;K.color.value.copy(X.color),K.map.value=X.texture,K.screenPosition.value.x=e.x+O*X.distance,K.screenPosition.value.y=e.y+k*X.distance,b=X.size/_.w;const H=_.w/_.z;K.scale.value.set(b*H,b),u.uniformsNeedUpdate=!0,M.renderBufferDirect(v,null,i,u,p,null)}}},this.dispose=function(){o.dispose(),r.dispose(),u.dispose(),n.dispose(),s.dispose();for(let M=0,L=f.length;M<L;M++)f[M].texture.dispose()}}}class ks{constructor(e,t=1,n=0,s=new c.Color(16777215)){this.texture=e,this.size=t,this.distance=n,this.color=s}}ks.Shader={uniforms:{map:{value:null},occlusionMap:{value:null},color:{value:null},scale:{value:null},screenPosition:{value:null}},vertexShader:`
131
131
 
132
132
  precision highp float;
133
133
 
@@ -181,12 +181,12 @@
181
181
  gl_FragColor = texture;
182
182
  gl_FragColor.rgb *= color;
183
183
 
184
- }`},vt.Geometry=function(){const l=new c.BufferGeometry,e=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),t=new c.InterleavedBuffer(e,5);return l.setIndex([0,1,2,0,2,3]),l.setAttribute("position",new c.InterleavedBufferAttribute(t,3,0,!1)),l.setAttribute("uv",new c.InterleavedBufferAttribute(t,2,3,!1)),l}();function Yo(l){return l}function Zo(l){return l*l*l}function Wo(l){return l<.5?4*l*l*l:1-(-2*l+2)**3/2}function Qo(l){return l*l*l*l}function Ko(l){return l<1/2.75?7.5625*l*l:l<2/2.75?7.5625*(l-=1.5/2.75)*l+.75:l<2.5/2.75?7.5625*(l-=2.25/2.75)*l+.9375:7.5625*(l-=2.625/2.75)*l+.984375}const an=c.MathUtils.clamp;class ln{constructor(e=0,t){Ae(this,"_getNext");Ae(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,s){const n=e.length;t=an(t,0,n-1),s=an(s??n-1,0,n-1);const i=this.int(t,s),o=this.shuffle(e.map((a,h)=>h)),r=Math.min(e.length,i);return o.slice(0,r).sort().map(a=>e[a])}shuffle(e){return e.map(t=>({value:t,sort:this._getNext()})).sort((t,s)=>t.sort-s.sort).map(({value:t})=>t)}getMulberry32(e=0){return 0<e&&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 je="https://raw.githubusercontent.com/Tresjs/assets/93976c7d63ac83d4a254a41a10b2362bc17e90c9/textures/lensflare/",cs=`${je}circle.png`,Dt=`${je}circleBlur.png`,qo=`${je}circleRainbow.png`,Jo=`${je}line.png`,cn=`${je}poly6.png`,hn=`${je}polyStroke6.png`,Ho=`${je}rays.png`,kt=`${je}ring.png`,$o=`${je}starThin6.png`,er={texture:[Jo,kt],color:["white"],distance:[0,0],size:[750,1024],length:[0,2]},tr={texture:[Dt],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},sr={texture:[Ho],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},nr={texture:[cs,qo,kt,$o],color:["white"],distance:[0,0],size:[180,512],length:[2,3]},[un,pn]=[3679071,132442],hs=[er,tr,sr,nr,{texture:[Dt,cs,kt,cn,hn],color:["dimgray","gray","darkgray",un,pn],distance:[.5,2.5],size:[20,180],length:[5,21]},{texture:[Dt,cs,kt,cn,hn],color:["dimgray","gray","darkgray",un,pn],distance:[-.6,-.1],size:[180,360],length:[0,5]}],Ft={color:"white",distance:0,size:512,texture:Dt},fn=(l,e,t=void 0,s=void 0,n=Ft)=>{if(l!==void 0&&l.length>0&&(typeof t=="number"||typeof s<"u")){const r=mn(t??0,s??hs),a=r.length,h=l.length;return a>=h?r.map((f,p)=>Object.assign(f,e,p<h?l[p]:{})):l.map((f,p)=>Object.assign({},n,p<a?r[p]:{},e,f))}if(l!==void 0&&l.length>0){const r=Object.assign({},n,e);return l.map(a=>Object.assign({},r,a))}const i=s===void 0||s.length===0?hs:s;return mn(t??0,i).map(r=>Object.assign({},r,e))},ir=[Yo,Zo,Wo,Qo,Ko],dn=c.MathUtils.lerp,mn=(l=0,e=hs)=>{const s=new ln(l).choice(ir);return e.map((n,i)=>{const o=new ln(l*(i*7907+1)+(typeof n.seed=="number"?n.seed:0)),r=o.int(n.length[0],n.length[1]);return new Array(r).fill(0).map(()=>{const a=s(o.rand());return{texture:o.defaultChoice(n.texture,Ft.texture),size:dn(n.size[0],n.size[1],s(1-a)),distance:dn(n.distance[0],n.distance[1],a),color:o.defaultChoice(n.color,Ft.color)}})}).flat()};function or(l){return rr(l,(e,t)=>t in Ft&&e!==void 0)}function rr(l,e){const t={};return Object.keys(l).forEach(s=>{e(l[s],s)&&(t[s]=l[s])}),t}const ar=u.defineComponent({__name:"component",props:{texture:{},size:{},distance:{},color:{},elements:{default:void 0},scale:{default:1},seed:{default:void 0},seedProps:{default:void 0}},setup(l,{expose:e}){const t=l,s=u.shallowRef(),n=u.shallowRef([]),i=u.shallowRef(or(t));e({value:s});const o=new c.TextureLoader,r=new vt,a=[],h=()=>{var g,w,x;for(;a.length;)a.pop();(g=s.value)==null||g.children.forEach(_=>{"dispose"in _&&_.dispose()}),(w=s.value)==null||w.remove(...s.value.children),(x=s.value)==null||x.dispose()},f=g=>{if(typeof g.texture=="string"){const w=g.texture;g.texture=o.load(w),g.texture.name=w}return g.color=ue.normalizeColor(g.color),g},p=()=>{for(;n.value.length>a.length;){const w={...f(n.value[a.length])};a.push(w),r.addElement(w)}n.value.forEach((g,w)=>{const x=a[w],{texture:_,size:S,distance:C,color:v}=g;if(typeof _=="string"){if(x.texture.name!==_){x.texture.dispose();const y=_;x.texture=o.load(y),x.texture.name=y}}else x.texture!==_&&(x.texture.dispose(),x.texture=_);x.size=S,x.distance=C,x.color=ue.normalizeColor(v)}),m()},m=()=>{for(let g=n.value.length-1;g<a.length;g++)a[g].size=0;n.value.forEach((g,w)=>{a[w].size=g.size*t.scale})};return u.onUnmounted(()=>{h()}),u.onMounted(()=>{var g;(g=s.value)==null||g.add(r),n.value=fn(t.elements,i.value,t.seed,t.seedProps)}),u.watch(()=>[t.color,t.distance,t.size,t.texture],()=>{i.value={color:t.color,distance:t.distance,size:t.size,texture:t.texture}}),u.watch(()=>[i.value,t.elements,t.seed,t.seedProps],()=>{n.value=fn(t.elements,i.value,t.seed,t.seedProps)}),u.watch(()=>t.scale,()=>{m()}),u.watch(()=>n.value,()=>{p()}),(g,w)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"lensflareRef",ref:s},null,512))}}),us={sunset:"venice/venice_sunset_4k.hdr"};async function gn({files:l=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],blur:e=0,background:t=!1,path:s="/",preset:n=void 0}){const{scene:i}=ue.useTresContext();if(n){if(!(n in us))throw new Error(`Preset must be one of: ${Object.keys(us).join(", ")}`);l=us[n],s="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/"}const o=Array.isArray(l),r=o?c.CubeTextureLoader:wo,a=await ue.useLoader(r,o?[l]:l,f=>{s&&f.setPath(s)}),h=o?a[0]:a;return h&&(h.mapping=o?c.CubeReflectionMapping:c.EquirectangularReflectionMapping,h.colorSpace=c.SRGBColorSpace),i.value&&(i.value.environment=h,(t||t==="")&&(i.value.background=h),e&&(i.value.backgroundBlurriness=e|0)),h}let Bt=null;function lr(l,e){return t=>{e&&e(t),l.draco&&(Bt||(Bt=new vo),Bt.setDecoderPath(l.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(Bt))}}async function yn(l,e={draco:!1},t){return await ue.useLoader(pi,l,lr(e,t))}const cr=u.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"}},async setup(l,{expose:e}){let t,s;const n=l,i=u.ref();e({value:i});const{scene:o}=([t,s]=u.withAsyncContext(()=>yn(n.path,{draco:n.draco,decoderPath:n.decoderPath})),t=await t,s(),t);return(r,a)=>{const h=u.resolveComponent("primitive");return u.openBlock(),u.createBlock(h,u.mergeProps({ref_key:"modelRef",ref:i,object:u.unref(o)},r.$attrs),null,16,["object"])}}});async function _n(l){return await ue.useLoader(eo,l)}const hr=u.defineComponent({__name:"component",props:{path:{}},async setup(l,{expose:e}){let t,s;const n=l,i=u.ref();e({value:i});const o=([t,s]=u.withAsyncContext(()=>_n(n.path)),t=await t,s(),t);return(r,a)=>{const h=u.resolveComponent("primitive");return u.openBlock(),u.createBlock(h,u.mergeProps({ref_key:"modelRef",ref:i,object:u.unref(o)},r.$attrs),null,16,["object"])}}}),ur=["geometry","render-order"],pr=u.defineComponent({__name:"component",props:{src:{},skipStrokes:{type:Boolean,default:!1},skipFills:{type:Boolean,default:!1},fillMaterial:{},strokeMaterial:{},fillMeshProps:{},strokeMeshProps:{},depth:{default:"renderOrder"}},setup(l,{expose:e}){const t=l,{src:s,skipStrokes:n,skipFills:i,fillMaterial:o,strokeMaterial:r,fillMeshProps:a,strokeMeshProps:h,depth:f}=u.toRefs(t),p=u.shallowRef(),m=u.shallowRef([]),g=u.shallowRef([]);e({value:p}),u.watchEffect(async()=>w(s.value).then(S=>g.value=S.paths)),u.watch([i,n,o,r,g],_);async function w(S){const C=S.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${S}`):S;return ue.useLoader(wt,C)}u.onUnmounted(x);function x(){m.value.forEach(S=>S.geometry.dispose())}function _(){var M,P,A;x();const S=[],[C,v]=(()=>{const b={flat:!1,renderOrder:!1,offsetZ:!0},D={flat:0,renderOrder:0,offsetZ:.025},z=f.value;return typeof z=="number"?[!0,z]:[b[z],D[z]]})();let y=0;for(const b of g.value){const D=((M=b.userData)==null?void 0:M.style)??{},z=Object.assign({color:D.fill,opacity:D.fillOpacity,transparent:!0,side:c.DoubleSide,depthWrite:C},t.fillMaterial);if(!i.value&&D.fill!==void 0&&D.fill!=="none")for(const U of wt.createShapes(b)){const R=new c.ShapeGeometry(U);R.scale(1,-1,1),v&&R.translate(0,0,y++*v),S.push({geometry:R,material:z,isStroke:!1})}if(!n.value&&D.stroke!==void 0&&D.stroke!=="none"){const U=Object.assign({color:(P=b.userData)==null?void 0:P.style.stroke,opacity:(A=b.userData)==null?void 0:A.style.strokeOpacity,transparent:!0,side:c.DoubleSide,depthWrite:C},t.strokeMaterial);for(const R of b.subPaths){const K=R.getPoints().map(W=>new c.Vector2(W.x,-W.y)),Z=wt.pointsToStroke(K,D||"none");v&&Z.translate(0,0,y++*v),S.push({geometry:Z,material:U,isStroke:!0})}}}m.value=S}return(S,C)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"svgRef",ref:p},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(m.value,({geometry:v,material:y,isStroke:M},P)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({key:`${P}`},M?u.unref(h):u.unref(a),{geometry:v,"render-order":u.unref(f)==="renderOrder"?P:0}),[u.createElementVNode("TresMeshBasicMaterial",u.normalizeProps(u.guardReactiveProps(y)),null,16)],16,ur))),128))],512))}}),xn="[TresJS - Cientos ▲ ■ ♥] ";function ps(){function l(s,n){console.error(`${xn} ${s}`,n||"")}function e(s){console.warn(`${xn} ${s}`)}function t(s,n){}return{logError:l,logWarning:e,logMessage:t}}let fs=0;function fr(){const l=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:s}=ps();return new Promise(n=>{c.DefaultLoadingManager.onStart=()=>{l.value=!1},c.DefaultLoadingManager.onLoad=()=>{l.value=!0},c.DefaultLoadingManager.onProgress=(i,o,r)=>{o===r&&(fs=r,l.value=!0,t.value.push(i)),e.value=Math.round((o-fs)/(r-fs)*100||100,2)},c.DefaultLoadingManager.onError=i=>{s("Error loading assets",new Error(i)),l.value=!0},n({items:t,hasFinishLoading:l,progress:e})})}async function dr(l,e){const{logError:t}=ps();if(!l)return t("Error no path provided");const{unsuspend:s,start:n,crossOrigin:i,muted:o,loop:r,...a}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function h(){return new Promise((f,p)=>{const m=Object.assign(document.createElement("video"),{src:typeof l=="string"&&l||void 0,crossOrigin:i,loop:r,muted:o,autoplay:!0,...a}),g=new c.VideoTexture(m);return m.addEventListener(s,()=>f(g)),m.addEventListener("error",()=>p()),g})}try{const f=await h();return n&&f.image&&f.image.play(),f}catch{t("Error loading resource")}}const mr=["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"],gr=u.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!1},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(l,{emit:e}){const t=l,{makeDefault:s,autoRotate:n,autoRotateSpeed:i,enableDamping:o,dampingFactor:r,enablePan:a,keyPanSpeed:h,maxAzimuthAngle:f,minAzimuthAngle:p,maxPolarAngle:m,minPolarAngle:g,minDistance:w,maxDistance:x,minZoom:_,maxZoom:S,enableZoom:C,zoomSpeed:v,enableRotate:y,touches:M,rotateSpeed:P,target:A}=u.toRefs(t),{camera:b,renderer:D,extend:z,controls:U}=ue.useTresContext(),R=u.ref(null);z({OrbitControls:Ns}),u.watch(R,W=>{K(),W&&s.value?U.value=W:U.value=null});function K(){Se(R.value,"change",()=>e("change",R.value)),Se(R.value,"start",()=>e("start",R.value)),Se(R.value,"end",()=>e("end",R.value))}const{onLoop:Z}=ue.useRenderLoop();return Z(()=>{R.value&&(o.value||n.value)&&R.value.update()}),u.onUnmounted(()=>{R.value&&R.value.dispose()}),(W,pe)=>(W.camera||u.unref(b))&&(W.domElement||u.unref(D))?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:R,target:u.unref(A),"auto-rotate":u.unref(n),"auto-rotate-speed":u.unref(i),"enable-damping":u.unref(o),"damping-factor":u.unref(r),"enable-pan":u.unref(a),"key-pan-speed":u.unref(h),keys:W.keys,"max-azimuth-angle":u.unref(f),"min-azimuth-angle":u.unref(p),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(g),"min-distance":u.unref(w),"max-distance":u.unref(x),"min-zoom":u.unref(_),"max-zoom":u.unref(S),touches:u.unref(M),"enable-zoom":u.unref(C),"zoom-speed":u.unref(v),"enable-rotate":u.unref(y),"rotate-speed":u.unref(P),args:[W.camera||u.unref(b),W.domElement||u.unref(D).domElement]},null,8,mr)):u.createCommentVNode("",!0)}}),yr=5,_r=6,xr=.3,wr=u.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(l){var z;const e=l,{forward:t,back:s,left:n,right:i,jump:o,gravity:r,moveSpeed:a,headBobbing:h,is2D:f}=u.toRefs(e),{camera:p,controls:m}=ue.useTresContext(),g=u.ref(0),w=u.ref(0),x=u.ref(!1),_=u.ref(!1),S=u.ref(0),C=u.shallowRef(),v=f.value?"y":"z",y=((z=p.value.position)==null?void 0:z.y)||0;it(t.value,()=>{x.value=!0,w.value=a.value},{eventName:"keydown"}),it(s.value,()=>{x.value=!0,w.value=-a.value},{eventName:"keydown"}),it([...t.value,...s.value],()=>{x.value=!1,w.value=0},{eventName:"keyup"}),it(n.value,()=>{x.value=!0,g.value=-a.value},{eventName:"keydown"}),it(i.value,()=>{x.value=!0,g.value=a.value},{eventName:"keydown"}),it([...n.value,...i.value],()=>{x.value=!1,g.value=0},{eventName:"keyup"}),it(o.value,()=>{_.value||(S.value=Date.now()),_.value=!0});const M=U=>x.value?Math.sin(U*yr)*xr+y:y,P=()=>(Date.now()-S.value)/1e3*3,A=U=>y+_r*U-.5*r.value*U**2,b=()=>{if(_.value){const U=A(P());return U<=y&&(_.value=!1),U}return 0},{onLoop:D}=ue.useRenderLoop();return D(({elapsed:U})=>{var R;m.value instanceof Ht&&((R=m.value)!=null&&R.isLocked)?(m.value.moveForward(w.value),m.value.moveRight(g.value),p.value.position&&(p.value.position.y=h.value?M(U):y,p.value.position.y+=b())):C.value.children.length>0&&!(m.value instanceof Ht)&&(C.value.position.x+=g.value,C.value.position[v]+=f.value?w.value:-w.value)}),(U,R)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:C},[u.renderSlot(U.$slots,"default")],512))}}),vr=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],br=u.defineComponent({__name:"TransformControls",props:{object:{},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(l,{emit:e}){const t=l,{object:s,mode:n,enabled:i,axis:o,translationSnap:r,rotationSnap:a,scaleSnap:h,space:f,size:p,showX:m,showY:g,showZ:w}=u.toRefs(t),x=u.shallowRef(),{controls:_,camera:S,renderer:C,extend:v}=ue.useTresContext();v({TransformControls:ti});const y=P=>{_.value&&(_.value.enabled=!P.value),e("dragging",P.value)};function M(){Se(x.value,"change",()=>e("change")),Se(x.value,"dragging-changed",y),Se(x.value,"mouseDown",()=>e("mouseDown")),Se(x.value,"mouseUp",()=>e("mouseUp")),Se(x.value,"objectChange",()=>e("objectChange"))}return u.watchEffect(()=>{x.value&&M()}),u.onUnmounted(()=>{x.value&&x.value.dispose()}),(P,A)=>u.unref(S)&&u.unref(C)?(u.openBlock(),u.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:x,object:u.unref(s),args:[u.unref(S),u.unref(C).domElement],mode:u.unref(n),enabled:u.unref(i),axis:u.unref(o),"translation-snap":u.unref(r),"rotation-snap":u.unref(a),"scale-snap":u.unref(h),space:u.unref(f),size:u.unref(p),"show-x":u.unref(m),"show-y":u.unref(g),"show-z":u.unref(w),visible:!0},null,8,vr)):u.createCommentVNode("",!0)}}),Ar=["args"],Mr=u.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock"],setup(l,{expose:e,emit:t}){const s=l,{camera:n,renderer:i,extend:o,controls:r}=ue.useTresContext(),a=u.ref(null);let h;o({PointerLockControls:Ht});const f=p=>{t("isLock",p)};return u.watch(a,p=>{p&&s.makeDefault?r.value=p:r.value=null;const m=document.getElementById(s.selector||"");h=m||i.value.domElement,Se(h,"click",()=>{var g,w,x;(g=r.value)==null||g.lock(),(w=r.value)==null||w.addEventListener("lock",()=>f(!0)),(x=r.value)==null||x.addEventListener("unlock",()=>f(!1))})}),u.onUnmounted(()=>{var p,m;(p=r.value)==null||p.removeEventListener("lock",()=>f(!0)),(m=r.value)==null||m.removeEventListener("unlock",()=>f(!1)),a.value&&a.value.dispose()}),e({value:r}),(p,m)=>(p.camera||u.unref(n))&&(p.domElement||u.unref(i))?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:a,args:[p.camera||u.unref(n),p.domElement||u.unref(i).domElement]},null,8,Ar)):u.createCommentVNode("",!0)}}),Sr=["args"],Pr=u.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(l){const e=l,{camera:t,renderer:s,extend:n,controls:i}=ue.useTresContext(),o=u.ref(null);return n({MapControls:ui}),u.watch(i,r=>{r&&e.makeDefault?i.value=r:i.value=null}),u.onUnmounted(()=>{o.value&&o.value.dispose()}),(r,a)=>(r.camera||u.unref(t))&&(r.domElement||u.unref(s))?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:o,args:[r.camera||u.unref(t),r.domElement||u.unref(s).domElement]},null,8,Sr)):u.createCommentVNode("",!0)}}),Tr=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(l,{emit:e}){const t=l,{logWarning:s}=ue.useLogger();t.smoothScroll<0&&s("SmoothControl must be greater than zero"),t.pages<0&&s("Pages must be greater than zero");const{camera:n,controls:i,renderer:o}=ue.useTresContext(),r=u.shallowRef(),a=document.createElement("div"),{y:h}=jo(),{x:f,y:p,isScrolling:m}=Ro(a),{height:g,width:w}=on();let x=0;const _=u.ref(!1),S=u.ref(0),C=u.ref(0),v=u.ref(0),y=t.horizontal?"x":"y",M=u.watch(n,A=>{if(_.value){M();return}x=t.horizontal?(A==null?void 0:A.position.x)||0:(A==null?void 0:A.position.y)||0,_.value=!0},{immediate:!0});u.watch(m,A=>{i.value&&(i.value.enabled=!A)},{immediate:!0}),u.watch(h,A=>{!m.value&&!t.htmlScroll||(C.value=A/g.value/(v.value/g.value-1),S.value=-1*C.value,e("update:modelValue",C.value))}),u.watch(p,A=>{C.value=A/g.value/(v.value/g.value),S.value=-1*C.value,e("update:modelValue",C.value)}),u.watch(f,A=>{C.value=A/w.value/(v.value/w.value-1),S.value=+C.value,e("update:modelValue",C.value)}),u.watch(o,A=>{var D,z;const b=A==null?void 0:A.domElement;if(t.htmlScroll&&(A!=null&&A.domElement))b!=null&&b.style.width&&(b!=null&&b.style.position)&&(b!=null&&b.style.top)&&(b!=null&&b.style.left)&&(b.style.width="100%",b.style.position="fixed",b.style.zIndex=" -99999",b.style.top="0",b.style.left="0"),v.value=document.body.scrollHeight;else{const U=document.createElement("div"),R=document.createElement("div");a.style[t.horizontal?"overflowX":"overflowY"]="auto",a.style[t.horizontal?"overflowY":"overflowX"]="hidden",a.style.position="absolute",a.style.width="100%",a.style.height=" 100%",a.style.top="0",a.style.left="0",a.classList.add("scrollContainer"),U.style.position="sticky",U.style.top="0px",U.style.left="0px",U.style.width="100%",U.style.height="100%",U.style.overflow="hidden",a.appendChild(U),R.style.height=t.horizontal?"100%":`${g.value*t.pages}px`,R.style.width=t.horizontal?`${w.value*t.pages}px`:"100vw",R.style.pointerEvents="none",b.style.position="fixed",b.style.zIndex="0",b!=null&&b.style.width&&(b.style.width="100%"),a.appendChild(R),A.domElement.parentNode.style.position="relative",(z=(D=A==null?void 0:A.domElement)==null?void 0:D.parentNode)==null||z.appendChild(a),v.value=t.horizontal?w.value*t.pages:g.value*t.pages}},{immediate:!0});const{onLoop:P}=ue.useRenderLoop();return P(()=>{var A;if((A=n.value)!=null&&A.position){const b=(S.value*t.distance-n.value.position[y]+x)*t.smoothScroll;n.value.position[y]+=b,r.value.children.length>0&&(r.value.position[y]+=b)}}),(A,b)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:r},[u.renderSlot(A.$slots,"default")],512))}});/*!
184
+ }`},It.Geometry=function(){const a=new c.BufferGeometry,e=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),t=new c.InterleavedBuffer(e,5);return a.setIndex([0,1,2,0,2,3]),a.setAttribute("position",new c.InterleavedBufferAttribute(t,3,0,!1)),a.setAttribute("uv",new c.InterleavedBufferAttribute(t,2,3,!1)),a}();function Br(a){return a}function Ur(a){return a*a*a}function Vr(a){return a<.5?4*a*a*a:1-(-2*a+2)**3/2}function zr(a){return a*a*a*a}function Nr(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 Fs=c.MathUtils.clamp;class Bs{constructor(e=0,t){Me(this,"_getNext");Me(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 s=e.length;t=Fs(t,0,s-1),n=Fs(n??s-1,0,s-1);const i=this.int(t,n),o=this.shuffle(e.map((l,f)=>f)),r=Math.min(e.length,i);return o.slice(0,r).sort().map(l=>e[l])}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 0<e&&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 qe="https://raw.githubusercontent.com/Tresjs/assets/93976c7d63ac83d4a254a41a10b2362bc17e90c9/textures/lensflare/",On=`${qe}circle.png`,Zt=`${qe}circleBlur.png`,Gr=`${qe}circleRainbow.png`,Rr=`${qe}line.png`,Us=`${qe}poly6.png`,Vs=`${qe}polyStroke6.png`,jr=`${qe}rays.png`,Qt=`${qe}ring.png`,Er=`${qe}starThin6.png`,Xr={texture:[Rr,Qt],color:["white"],distance:[0,0],size:[750,1024],length:[0,2]},Yr={texture:[Zt],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},Wr={texture:[jr],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},Zr={texture:[On,Gr,Qt,Er],color:["white"],distance:[0,0],size:[180,512],length:[2,3]},[zs,Ns]=[3679071,132442],Dn=[Xr,Yr,Wr,Zr,{texture:[Zt,On,Qt,Us,Vs],color:["dimgray","gray","darkgray",zs,Ns],distance:[.5,2.5],size:[20,180],length:[5,21]},{texture:[Zt,On,Qt,Us,Vs],color:["dimgray","gray","darkgray",zs,Ns],distance:[-.6,-.1],size:[180,360],length:[0,5]}],Kt={color:"white",distance:0,size:512,texture:Zt},Gs=(a,e,t=void 0,n=void 0,s=Kt)=>{if(a!==void 0&&a.length>0&&(typeof t=="number"||typeof n<"u")){const r=js(t??0,n??Dn),l=r.length,f=a.length;return l>=f?r.map((d,u)=>Object.assign(d,e,u<f?a[u]:{})):a.map((d,u)=>Object.assign({},s,u<l?r[u]:{},e,d))}if(a!==void 0&&a.length>0){const r=Object.assign({},s,e);return a.map(l=>Object.assign({},r,l))}const i=n===void 0||n.length===0?Dn:n;return js(t??0,i).map(r=>Object.assign({},r,e))},Qr=[Br,Ur,Vr,zr,Nr],Rs=c.MathUtils.lerp,js=(a=0,e=Dn)=>{const n=new Bs(a).choice(Qr);return e.map((s,i)=>{const o=new Bs(a*(i*7907+1)+(typeof s.seed=="number"?s.seed:0)),r=o.int(s.length[0],s.length[1]);return new Array(r).fill(0).map(()=>{const l=n(o.rand());return{texture:o.defaultChoice(s.texture,Kt.texture),size:Rs(s.size[0],s.size[1],n(1-l)),distance:Rs(s.distance[0],s.distance[1],l),color:o.defaultChoice(s.color,Kt.color)}})}).flat()};function Kr(a){return qr(a,(e,t)=>t in Kt&&e!==void 0)}function qr(a,e){const t={};return Object.keys(a).forEach(n=>{e(a[n],n)&&(t[n]=a[n])}),t}const Jr=h.defineComponent({__name:"component",props:{texture:{},size:{},distance:{},color:{},elements:{default:void 0},scale:{default:1},seed:{default:void 0},seedProps:{default:void 0}},setup(a,{expose:e}){const t=a,n=h.shallowRef(),s=h.shallowRef([]),i=h.shallowRef(Kr(t));e({value:n});const o=new c.TextureLoader,r=new It,l=[],f=()=>{var g,x,w;for(;l.length;)l.pop();(g=n.value)==null||g.children.forEach(_=>{"dispose"in _&&_.dispose()}),(x=n.value)==null||x.remove(...n.value.children),(w=n.value)==null||w.dispose()},d=g=>{if(typeof g.texture=="string"){const x=g.texture;g.texture=o.load(x),g.texture.name=x}return g.color=ne.normalizeColor(g.color),g},u=()=>{for(;s.value.length>l.length;){const x={...d(s.value[l.length])};l.push(x),r.addElement(x)}s.value.forEach((g,x)=>{const w=l[x],{texture:_,size:M,distance:L,color:v}=g;if(typeof _=="string"){if(w.texture.name!==_){w.texture.dispose();const y=_;w.texture=o.load(y),w.texture.name=y}}else w.texture!==_&&(w.texture.dispose(),w.texture=_);w.size=M,w.distance=L,w.color=ne.normalizeColor(v)}),p()},p=()=>{for(let g=s.value.length-1;g<l.length;g++)l[g].size=0;s.value.forEach((g,x)=>{l[x].size=g.size*t.scale})};return h.onUnmounted(()=>{f()}),h.onMounted(()=>{var g;(g=n.value)==null||g.add(r),s.value=Gs(t.elements,i.value,t.seed,t.seedProps)}),h.watch(()=>[t.color,t.distance,t.size,t.texture],()=>{i.value={color:t.color,distance:t.distance,size:t.size,texture:t.texture}}),h.watch(()=>[i.value,t.elements,t.seed,t.seedProps],()=>{s.value=Gs(t.elements,i.value,t.seed,t.seedProps)}),h.watch(()=>t.scale,()=>{p()}),h.watch(()=>s.value,()=>{u()}),(g,x)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"lensflareRef",ref:n},null,512))}});function Es(a){const e=h.ref(null),{height:t,width:n,settings:s,depth:i}=h.isReactive(a)?h.toRefs(a):h.toRefs(h.reactive(a)),{onLoop:o}=ne.useRenderLoop(),{camera:r,renderer:l,scene:f,sizes:d}=ne.useTresContext();return h.watchEffect(()=>{var u;(u=e.value)==null||u.dispose(),e.value=new c.WebGLRenderTarget((n==null?void 0:n.value)||d.width.value,(t==null?void 0:t.value)||d.height.value,{minFilter:c.LinearFilter,magFilter:c.LinearFilter,type:c.HalfFloatType,...s==null?void 0:s.value}),i!=null&&i.value&&(e.value.depthTexture=new c.DepthTexture((n==null?void 0:n.value)||d.width.value,(t==null?void 0:t.value)||d.height.value,c.FloatType))}),o(()=>{l.value.setRenderTarget(e.value),l.value.clear(),l.value.render(f.value,r.value),l.value.setRenderTarget(null)}),h.onBeforeUnmount(()=>{var u;(u=e.value)==null||u.dispose()}),e}const Hr=h.defineComponent({__name:"component",props:{width:{},height:{},depth:{type:Boolean,default:!1},settings:{default:void 0}},setup(a,{expose:e}){const n=Es(a);return e({value:n}),()=>{}}}),qt={sunset:"venice/venice_sunset_1k.hdr",studio:"studio/poly_haven_studio_1k.hdr",city:"city/canary_wharf_1k.hdr",umbrellas:"outdoor/outdoor_umbrellas_1k.hdr",night:"outdoor/satara_night_1k.hdr",forest:"outood/mossy_forest_1k.hdr",snow:"outdoor/snowy_forest_path_01_1k.hdr",dawn:"kiara/kiara_1_dawn_1k.hdr",hangar:"indoor/small_hangar_01_1k.hdr",urban:"indoor/abandoned_games_room_02_1k.hdr",modern:"city/modern_buildings_2_1k.hdr",shangai:"city/shanghai_bund_1k.hdr"},$r="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";async function Xs(a){const{scene:e}=ne.useTresContext(),{preset:t,blur:n,files:s=[],path:i="",background:o}=h.toRefs(a),r=h.ref(),l=h.computed(()=>Array.isArray(s.value)),f=h.computed(()=>l.value?c.CubeTextureLoader:Ls),d=h.ref(null);return h.watch(()=>[s,i],async([u,p])=>{if(u.value.length>0&&!t.value){try{d.value=await ne.useLoader(h.unref(f),l.value?[h.unref(u)]:h.unref(u),g=>{p.value&&g.setPath(h.unref(p))})}catch(g){throw new Error(`Failed to load environment map: ${g}`)}d.value&&(r.value=l.value?d.value[0]:d.value,r.value.mapping=l.value?c.CubeReflectionMapping:c.EquirectangularReflectionMapping)}},{immediate:!0}),h.watch(()=>r.value,u=>{e.value&&(e.value.environment=u)},{immediate:!0}),h.watch(()=>[o.value,r.value],([u,p])=>{e.value&&(e.value.background=u?p:void 0)},{immediate:!0}),h.watch(()=>n==null?void 0:n.value,u=>{e.value&&(e.value.backgroundBlurriness=u)},{immediate:!0}),h.watch(t,async u=>{if(u&&u in qt){const p=$r,g=qt[u];try{d.value=await ne.useLoader(Ls,g,x=>{p&&x.setPath(p)})}catch(x){throw new Error(`Failed to load environment map: ${x}`)}d.value&&(r.value=d.value,r.value.mapping=c.EquirectangularReflectionMapping)}else if(u&&!(u in qt))throw new Error(`Preset must be one of: ${Object.keys(qt).join(", ")}`)},{immediate:!0}),{texture:r}}let Jt=null;function ea(a,e){return t=>{e&&e(t),a.draco&&(Jt||(Jt=new hr),Jt.setDecoderPath(a.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(Jt))}}async function Ys(a,e={draco:!1},t){return await ne.useLoader(io,a,ea(e,t))}const ta=["object"],na=h.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"}},async setup(a,{expose:e}){let t,n;const s=a,i=h.ref();e({value:i});const{scene:o}=([t,n]=h.withAsyncContext(()=>Ys(s.path,{draco:s.draco,decoderPath:s.decoderPath})),t=await t,n(),t);return(r,l)=>(h.openBlock(),h.createElementBlock("primitive",h.mergeProps({ref_key:"modelRef",ref:i,object:h.unref(o)},r.$attrs),null,16,ta))}});async function Ws(a){return await ne.useLoader(Zo,a)}const sa=["object"],ia=h.defineComponent({__name:"component",props:{path:{}},async setup(a,{expose:e}){let t,n;const s=a,i=h.ref();e({value:i});const o=([t,n]=h.withAsyncContext(()=>Ws(s.path)),t=await t,n(),t);return(r,l)=>(h.openBlock(),h.createElementBlock("primitive",h.mergeProps({ref_key:"modelRef",ref:i,object:h.unref(o)},r.$attrs),null,16,sa))}}),oa=["geometry","render-order"],ra=h.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,{src:n,skipStrokes:s,skipFills:i,fillMaterial:o,strokeMaterial:r,fillMeshProps:l,strokeMeshProps:f,depth:d}=h.toRefs(t),u=h.shallowRef(),p=h.shallowRef([]),g=h.shallowRef([]);e({value:u}),h.watchEffect(async()=>x(n.value).then(M=>g.value=M.paths)),h.watch([i,s,o,r,g],_);async function x(M){const L=M.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${M}`):M;return ne.useLoader(Dt,L)}h.onUnmounted(w);function w(){p.value.forEach(M=>M.geometry.dispose())}function _(){var A,S,b;w();const M=[],[L,v]=(()=>{const P={flat:!1,renderOrder:!1,offsetZ:!0},O={flat:0,renderOrder:0,offsetZ:.025},k=d.value;return typeof k=="number"?[!0,k]:[P[k],O[k]]})();let y=0;for(const P of g.value){const O=((A=P.userData)==null?void 0:A.style)??{},k=Object.assign({color:O.fill,opacity:O.fillOpacity,transparent:!0,side:c.DoubleSide,depthWrite:L},t.fillMaterial);if(!i.value&&O.fill!==void 0&&O.fill!=="none")for(const V of Dt.createShapes(P)){const R=new c.ShapeGeometry(V);R.scale(1,-1,1),v&&R.translate(0,0,y++*v),M.push({geometry:R,material:k,isStroke:!1})}if(!s.value&&O.stroke!==void 0&&O.stroke!=="none"){const V=Object.assign({color:(S=P.userData)==null?void 0:S.style.stroke,opacity:(b=P.userData)==null?void 0:b.style.strokeOpacity,transparent:!0,side:c.DoubleSide,depthWrite:L},t.strokeMaterial);for(const R of P.subPaths){const X=R.getPoints().map(H=>new c.Vector2(H.x,-H.y)),K=Dt.pointsToStroke(X,O||"none");v&&K.translate(0,0,y++*v),M.push({geometry:K,material:V,isStroke:!0})}}}p.value=M}return(M,L)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"svgRef",ref:u},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(p.value,({geometry:v,material:y,isStroke:A},S)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({key:`${S}`},A?h.unref(f):h.unref(l),{geometry:v,"render-order":h.unref(d)==="renderOrder"?S:0}),[h.createElementVNode("TresMeshBasicMaterial",h.normalizeProps(h.guardReactiveProps(y)),null,16)],16,oa))),128))],512))}}),Zs="[TresJS - Cientos ▲ ■ ♥] ";function In(){function a(n,s){console.error(`${Zs} ${n}`,s||"")}function e(n){console.warn(`${Zs} ${n}`)}function t(n,s){}return{logError:a,logWarning:e,logMessage:t}}let kn=0;function aa(){const a=h.ref(!1),e=h.ref(0),t=h.ref([]),{logError:n}=In();return new Promise(s=>{c.DefaultLoadingManager.onStart=()=>{a.value=!1},c.DefaultLoadingManager.onLoad=()=>{a.value=!0},c.DefaultLoadingManager.onProgress=(i,o,r)=>{o===r&&(kn=r,a.value=!0,t.value.push(i)),e.value=Math.round((o-kn)/(r-kn)*100||100,2)},c.DefaultLoadingManager.onError=i=>{n("Error loading assets",new Error(i)),a.value=!0},s({items:t,hasFinishLoading:a,progress:e})})}async function la(a,e){const{logError:t}=In();if(!a)return t("Error no path provided");const{unsuspend:n,start:s,crossOrigin:i,muted:o,loop:r,...l}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function f(){return new Promise((d,u)=>{const p=Object.assign(document.createElement("video"),{src:typeof a=="string"&&a||void 0,crossOrigin:i,loop:r,muted:o,autoplay:!0,...l}),g=new c.VideoTexture(p);return p.addEventListener(n,()=>d(g)),p.addEventListener("error",()=>u()),g})}try{const d=await f();return s&&d.image&&d.image.play(),d}catch{t("Error loading resource")}}const ca=["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"],ha=h.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!1},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:c.TOUCH.ROTATE,TWO:c.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,{makeDefault:s,autoRotate:i,autoRotateSpeed:o,enableDamping:r,dampingFactor:l,enablePan:f,keyPanSpeed:d,maxAzimuthAngle:u,minAzimuthAngle:p,maxPolarAngle:g,minPolarAngle:x,minDistance:w,maxDistance:_,minZoom:M,maxZoom:L,enableZoom:v,zoomSpeed:y,enableRotate:A,touches:S,rotateSpeed:b,target:P}=h.toRefs(n),{camera:O,renderer:k,extend:V,controls:R}=ne.useTresContext(),X=h.ref(null);V({OrbitControls:us}),h.watch(X,he=>{K(),he&&s.value?R.value=he:R.value=null});function K(){Ae(X.value,"change",()=>t("change",X.value)),Ae(X.value,"start",()=>t("start",X.value)),Ae(X.value,"end",()=>t("end",X.value))}const{onLoop:H}=ne.useRenderLoop();return H(()=>{X.value&&(r.value||i.value)&&X.value.update()}),h.onUnmounted(()=>{X.value&&X.value.dispose()}),e({value:X}),(he,J)=>(he.camera||h.unref(O))&&(he.domElement||h.unref(k))?(h.openBlock(),h.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:X,target:h.unref(P),"auto-rotate":h.unref(i),"auto-rotate-speed":h.unref(o),"enable-damping":h.unref(r),"damping-factor":h.unref(l),"enable-pan":h.unref(f),"key-pan-speed":h.unref(d),keys:he.keys,"max-azimuth-angle":h.unref(u),"min-azimuth-angle":h.unref(p),"max-polar-angle":h.unref(g),"min-polar-angle":h.unref(x),"min-distance":h.unref(w),"max-distance":h.unref(_),"min-zoom":h.unref(M),"max-zoom":h.unref(L),touches:h.unref(S),"enable-zoom":h.unref(v),"zoom-speed":h.unref(y),"enable-rotate":h.unref(A),"rotate-speed":h.unref(b),args:[he.camera||h.unref(O),he.domElement||h.unref(k).domElement]},null,8,ca)):h.createCommentVNode("",!0)}}),ua=5,da=6,fa=.3,pa=h.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(a){var k;const e=a,{forward:t,back:n,left:s,right:i,jump:o,gravity:r,moveSpeed:l,headBobbing:f,is2D:d}=h.toRefs(e),{camera:u,controls:p}=ne.useTresContext(),g=h.ref(0),x=h.ref(0),w=h.ref(!1),_=h.ref(!1),M=h.ref(0),L=h.shallowRef(),v=d.value?"y":"z",y=((k=u.value.position)==null?void 0:k.y)||0;ft(t.value,()=>{w.value=!0,x.value=l.value},{eventName:"keydown"}),ft(n.value,()=>{w.value=!0,x.value=-l.value},{eventName:"keydown"}),ft([...t.value,...n.value],()=>{w.value=!1,x.value=0},{eventName:"keyup"}),ft(s.value,()=>{w.value=!0,g.value=-l.value},{eventName:"keydown"}),ft(i.value,()=>{w.value=!0,g.value=l.value},{eventName:"keydown"}),ft([...s.value,...i.value],()=>{w.value=!1,g.value=0},{eventName:"keyup"}),ft(o.value,()=>{_.value||(M.value=Date.now()),_.value=!0});const A=V=>w.value?Math.sin(V*ua)*fa+y:y,S=()=>(Date.now()-M.value)/1e3*3,b=V=>y+da*V-.5*r.value*V**2,P=()=>{if(_.value){const V=b(S());return V<=y&&(_.value=!1),V}return 0},{onLoop:O}=ne.useRenderLoop();return O(({elapsed:V})=>{var R;p.value instanceof vn&&((R=p.value)!=null&&R.isLocked)?(p.value.moveForward(x.value),p.value.moveRight(g.value),u.value.position&&(u.value.position.y=f.value?A(V):y,u.value.position.y+=P())):L.value.children.length>0&&!(p.value instanceof vn)&&(L.value.position.x+=g.value,L.value.position[v]+=d.value?x.value:-x.value)}),(V,R)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:L},[h.renderSlot(V.$slots,"default")],512))}}),ma=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],ga=h.defineComponent({__name:"TransformControls",props:{object:{},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,{emit:e}){const t=a,{object:n,mode:s,enabled:i,axis:o,translationSnap:r,rotationSnap:l,scaleSnap:f,space:d,size:u,showX:p,showY:g,showZ:x}=h.toRefs(t),w=h.shallowRef(),{controls:_,camera:M,renderer:L,extend:v}=ne.useTresContext();v({TransformControls:Wi});const y=S=>{_.value&&(_.value.enabled=!S.value),e("dragging",S.value)};function A(){Ae(w.value,"change",()=>e("change")),Ae(w.value,"dragging-changed",y),Ae(w.value,"mouseDown",()=>e("mouseDown")),Ae(w.value,"mouseUp",()=>e("mouseUp")),Ae(w.value,"objectChange",()=>e("objectChange"))}return h.watchEffect(()=>{w.value&&A()}),h.onUnmounted(()=>{w.value&&w.value.dispose()}),(S,b)=>h.unref(M)&&h.unref(L)?(h.openBlock(),h.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:w,object:h.unref(n),args:[h.unref(M),h.unref(L).domElement],mode:h.unref(s),enabled:h.unref(i),axis:h.unref(o),"translation-snap":h.unref(r),"rotation-snap":h.unref(l),"scale-snap":h.unref(f),space:h.unref(d),size:h.unref(u),"show-x":h.unref(p),"show-y":h.unref(g),"show-z":h.unref(x),visible:!0},null,8,ma)):h.createCommentVNode("",!0)}}),ya=["args"],_a=h.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock"],setup(a,{expose:e,emit:t}){const n=a,{camera:s,renderer:i,extend:o,controls:r}=ne.useTresContext(),l=h.ref(null);let f;o({PointerLockControls:vn});const d=u=>{t("isLock",u)};return h.watch(l,u=>{u&&n.makeDefault?r.value=u:r.value=null;const p=document.getElementById(n.selector||"");f=p||i.value.domElement,Ae(f,"click",()=>{var g,x,w;(g=r.value)==null||g.lock(),(x=r.value)==null||x.addEventListener("lock",()=>d(!0)),(w=r.value)==null||w.addEventListener("unlock",()=>d(!1))})}),h.onUnmounted(()=>{var u,p;(u=r.value)==null||u.removeEventListener("lock",()=>d(!0)),(p=r.value)==null||p.removeEventListener("unlock",()=>d(!1)),l.value&&l.value.dispose()}),e({value:r}),(u,p)=>(u.camera||h.unref(s))&&(u.domElement||h.unref(i))?(h.openBlock(),h.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:l,args:[u.camera||h.unref(s),u.domElement||h.unref(i).domElement]},null,8,ya)):h.createCommentVNode("",!0)}}),va=["args"],xa=h.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(a){const e=a,{camera:t,renderer:n,extend:s,controls:i}=ne.useTresContext(),o=h.ref(null);return s({MapControls:so}),h.watch(i,r=>{r&&e.makeDefault?i.value=r:i.value=null}),h.onUnmounted(()=>{o.value&&o.value.dispose()}),(r,l)=>(r.camera||h.unref(t))&&(r.domElement||h.unref(n))?(h.openBlock(),h.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:o,args:[r.camera||h.unref(t),r.domElement||h.unref(n).domElement]},null,8,va)):h.createCommentVNode("",!0)}}),wa=h.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,{emit:e}){const t=a,{logWarning:n}=ne.useLogger();t.smoothScroll<0&&n("SmoothControl must be greater than zero"),t.pages<0&&n("Pages must be greater than zero");const{camera:s,controls:i,renderer:o}=ne.useTresContext(),r=h.shallowRef(),l=document.createElement("div"),{y:f}=Ir(),{x:d,y:u,isScrolling:p}=Tr(l),{height:g,width:x}=Is();let w=0;const _=h.ref(!1),M=h.ref(0),L=h.ref(0),v=h.ref(0),y=t.horizontal?"x":"y",A=h.watch(s,b=>{if(_.value){A();return}w=t.horizontal?(b==null?void 0:b.position.x)||0:(b==null?void 0:b.position.y)||0,_.value=!0},{immediate:!0});h.watch(p,b=>{i.value&&(i.value.enabled=!b)},{immediate:!0}),h.watch(f,b=>{!p.value&&!t.htmlScroll||(L.value=b/g.value/(v.value/g.value-1),M.value=-1*L.value,e("update:modelValue",L.value))}),h.watch(u,b=>{L.value=b/g.value/(v.value/g.value),M.value=-1*L.value,e("update:modelValue",L.value)}),h.watch(d,b=>{L.value=b/x.value/(v.value/x.value-1),M.value=+L.value,e("update:modelValue",L.value)}),h.watch(o,b=>{var O,k;const P=b==null?void 0:b.domElement;if(t.htmlScroll&&(b!=null&&b.domElement))P!=null&&P.style.width&&(P!=null&&P.style.position)&&(P!=null&&P.style.top)&&(P!=null&&P.style.left)&&(P.style.width="100%",P.style.position="fixed",P.style.zIndex=" -99999",P.style.top="0",P.style.left="0"),v.value=document.body.scrollHeight;else{const V=document.createElement("div"),R=document.createElement("div");l.style[t.horizontal?"overflowX":"overflowY"]="auto",l.style[t.horizontal?"overflowY":"overflowX"]="hidden",l.style.position="absolute",l.style.width="100%",l.style.height=" 100%",l.style.top="0",l.style.left="0",l.classList.add("scrollContainer"),V.style.position="sticky",V.style.top="0px",V.style.left="0px",V.style.width="100%",V.style.height="100%",V.style.overflow="hidden",l.appendChild(V),R.style.height=t.horizontal?"100%":`${g.value*t.pages}px`,R.style.width=t.horizontal?`${x.value*t.pages}px`:"100vw",R.style.pointerEvents="none",P.style.position="fixed",P.style.zIndex="0",P!=null&&P.style.width&&(P.style.width="100%"),l.appendChild(R),b.domElement.parentNode.style.position="relative",(k=(O=b==null?void 0:b.domElement)==null?void 0:O.parentNode)==null||k.appendChild(l),v.value=t.horizontal?x.value*t.pages:g.value*t.pages}},{immediate:!0});const{onLoop:S}=ne.useRenderLoop();return S(()=>{var b;if((b=s.value)!=null&&b.position){const P=(M.value*t.distance-s.value.position[y]+w)*t.smoothScroll;s.value.position[y]+=P,r.value.children.length>0&&(r.value.position[y]+=P)}}),(b,P)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:r},[h.renderSlot(b.$slots,"default")],512))}});/*!
185
185
  * camera-controls
186
186
  * https://github.com/yomotsu/camera-controls
187
187
  * (c) 2017 @yomotsu
188
188
  * Released under the MIT License.
189
- */const oe={LEFT:1,RIGHT:2,MIDDLE:4},N=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 ot(l){return l.isPerspectiveCamera}function He(l){return l.isOrthographicCamera}const dt=Math.PI*2,wn=Math.PI/2,vn=1e-5,bt=Math.PI/180;function Ne(l,e,t){return Math.max(e,Math.min(t,l))}function we(l,e=vn){return Math.abs(l)<e}function _e(l,e,t=vn){return we(l-e,t)}function bn(l,e){return Math.round(l/e)*e}function At(l){return isFinite(l)?l:l<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Mt(l){return Math.abs(l)<Number.MAX_VALUE?l:l*(1/0)}function Ut(l,e,t,s,n=1/0,i){s=Math.max(1e-4,s);const o=2/s,r=o*i,a=1/(1+r+.48*r*r+.235*r*r*r);let h=l-e;const f=e,p=n*s;h=Ne(h,-p,p),e=l-h;const m=(t.value+o*h)*i;t.value=(t.value-o*m)*a;let g=e+(h+m)*a;return f-l>0==g>f&&(g=f,t.value=(g-f)/i),g}function An(l,e,t,s,n=1/0,i,o){s=Math.max(1e-4,s);const r=2/s,a=r*i,h=1/(1+a+.48*a*a+.235*a*a*a);let f=e.x,p=e.y,m=e.z,g=l.x-f,w=l.y-p,x=l.z-m;const _=f,S=p,C=m,v=n*s,y=v*v,M=g*g+w*w+x*x;if(M>y){const W=Math.sqrt(M);g=g/W*v,w=w/W*v,x=x/W*v}f=l.x-g,p=l.y-w,m=l.z-x;const P=(t.x+r*g)*i,A=(t.y+r*w)*i,b=(t.z+r*x)*i;t.x=(t.x-r*P)*h,t.y=(t.y-r*A)*h,t.z=(t.z-r*b)*h,o.x=f+(g+P)*h,o.y=p+(w+A)*h,o.z=m+(x+b)*h;const D=_-l.x,z=S-l.y,U=C-l.z,R=o.x-_,K=o.y-S,Z=o.z-C;return D*R+z*K+U*Z>0&&(o.x=_,o.y=S,o.z=C,t.x=(o.x-_)/i,t.y=(o.y-S)/i,t.z=(o.z-C)/i),o}function ds(l,e){e.set(0,0),l.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=l.length,e.y/=l.length}function ms(l,e){return He(l)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Cr{constructor(){this._listeners={}}addEventListener(e,t){const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners[e];if(n!==void 0){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const s=this._listeners[e.type];if(s!==void 0){e.target=this;const n=s.slice(0);for(let i=0,o=n.length;i<o;i++)n[i].call(this,e)}}}const Lr="2.7.2",Vt=1/8,Mn=typeof window<"u",Or=Mn&&/Mac/.test(navigator.platform),Ir=!(Mn&&"PointerEvent"in window);let ne,Sn,Nt,gs,Ie,he,ye,mt,St,Ge,Ee,rt,Pn,Tn,Be,Pt,gt,Cn,ys,Ln,_s,xs,zt;class Tt extends Cr{static install(e){ne=e.THREE,Sn=Object.freeze(new ne.Vector3(0,0,0)),Nt=Object.freeze(new ne.Vector3(0,1,0)),gs=Object.freeze(new ne.Vector3(0,0,1)),Ie=new ne.Vector2,he=new ne.Vector3,ye=new ne.Vector3,mt=new ne.Vector3,St=new ne.Vector3,Ge=new ne.Vector3,Ee=new ne.Vector3,rt=new ne.Vector3,Pn=new ne.Vector3,Tn=new ne.Vector3,Be=new ne.Spherical,Pt=new ne.Spherical,gt=new ne.Box3,Cn=new ne.Box3,ys=new ne.Sphere,Ln=new ne.Quaternion,_s=new ne.Quaternion,xs=new ne.Matrix4,zt=new ne.Raycaster}static get ACTION(){return N}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=N.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._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 ne.Vector3,this._focalOffsetVelocity=new ne.Vector3,this._zoomVelocity={value:0},this._truckInternal=(y,M,P)=>{let A,b;if(ot(this._camera)){const D=he.copy(this._camera.position).sub(this._target),z=this._camera.getEffectiveFOV()*bt,U=D.length()*Math.tan(z*.5);A=this.truckSpeed*y*U/this._elementRect.height,b=this.truckSpeed*M*U/this._elementRect.height}else if(He(this._camera)){const D=this._camera;A=y*(D.right-D.left)/D.zoom/this._elementRect.width,b=M*(D.top-D.bottom)/D.zoom/this._elementRect.height}else return;this.verticalDragToForward?(P?this.setFocalOffset(this._focalOffsetEnd.x+A,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(A,0,!0),this.forward(-b,!0)):P?this.setFocalOffset(this._focalOffsetEnd.x+A,this._focalOffsetEnd.y+b,this._focalOffsetEnd.z,!0):this.truck(A,b,!0)},this._rotateInternal=(y,M)=>{const P=dt*this.azimuthRotateSpeed*y/this._elementRect.height,A=dt*this.polarRotateSpeed*M/this._elementRect.height;this.rotate(P,A,!0)},this._dollyInternal=(y,M,P)=>{const A=Math.pow(.95,-y*this.dollySpeed),b=this._sphericalEnd.radius,D=this._sphericalEnd.radius*A,z=Ne(D,this.minDistance,this.maxDistance),U=z-D;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(D,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(U,!0),this._dollyToNoClamp(z,!0)):this._dollyToNoClamp(z,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?D:z)-b,this._dollyControlCoord.set(M,P)),this._lastDollyDirection=Math.sign(-y)},this._zoomInternal=(y,M,P)=>{const A=Math.pow(.95,y*this.dollySpeed),b=this._zoom,D=this._zoom*A;this.zoomTo(D,!0),this.dollyToCursor&&(this._changedZoom+=D-b,this._dollyControlCoord.set(M,P))},typeof ne>"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 ne.Quaternion().setFromUnitVectors(this._camera.up,Nt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=N.NONE,this._target=new ne.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new ne.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new ne.Spherical().setFromVector3(he.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 ne.Vector3,new ne.Vector3,new ne.Vector3,new ne.Vector3],this._updateNearPlaneCorners(),this._boundary=new ne.Box3(new ne.Vector3(-1/0,-1/0,-1/0),new ne.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 ne.Vector2,this.mouseButtons={left:N.ROTATE,middle:N.DOLLY,right:N.TRUCK,wheel:ot(this._camera)?N.DOLLY:He(this._camera)?N.ZOOM:N.NONE},this.touches={one:N.TOUCH_ROTATE,two:ot(this._camera)?N.TOUCH_DOLLY_TRUCK:He(this._camera)?N.TOUCH_ZOOM_TRUCK:N.NONE,three:N.TOUCH_TRUCK};const s=new ne.Vector2,n=new ne.Vector2,i=new ne.Vector2,o=y=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const A=this._domElement.getBoundingClientRect(),b=y.clientX/A.width,D=y.clientY/A.height;if(b<this._interactiveArea.left||b>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const M=y.pointerType!=="mouse"?null:(y.buttons&oe.LEFT)===oe.LEFT?oe.LEFT:(y.buttons&oe.MIDDLE)===oe.MIDDLE?oe.MIDDLE:(y.buttons&oe.RIGHT)===oe.RIGHT?oe.RIGHT:null;if(M!==null){const A=this._findPointerByMouseButton(M);A&&this._disposePointer(A)}if((y.buttons&oe.LEFT)===oe.LEFT&&this._lockedPointer)return;const P={pointerId:y.pointerId,clientX:y.clientX,clientY:y.clientY,deltaX:0,deltaY:0,mouseButton:M};this._activePointers.push(P),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",f),this._isDragging=!0,x(y)},r=y=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const A=this._domElement.getBoundingClientRect(),b=y.clientX/A.width,D=y.clientY/A.height;if(b<this._interactiveArea.left||b>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const M=(y.buttons&oe.LEFT)===oe.LEFT?oe.LEFT:(y.buttons&oe.MIDDLE)===oe.MIDDLE?oe.MIDDLE:(y.buttons&oe.RIGHT)===oe.RIGHT?oe.RIGHT:null;if(M!==null){const A=this._findPointerByMouseButton(M);A&&this._disposePointer(A)}const P={pointerId:1,clientX:y.clientX,clientY:y.clientY,deltaX:0,deltaY:0,mouseButton:(y.buttons&oe.LEFT)===oe.LEFT?oe.LEFT:(y.buttons&oe.MIDDLE)===oe.LEFT?oe.MIDDLE:(y.buttons&oe.RIGHT)===oe.LEFT?oe.RIGHT:null};this._activePointers.push(P),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",p),this._domElement.ownerDocument.addEventListener("mousemove",h),this._domElement.ownerDocument.addEventListener("mouseup",p),this._isDragging=!0,x(y)},a=y=>{y.cancelable&&y.preventDefault();const M=y.pointerId,P=this._lockedPointer||this._findPointerById(M);if(P){if(P.clientX=y.clientX,P.clientY=y.clientY,P.deltaX=y.movementX,P.deltaY=y.movementY,this._state=0,y.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&&(y.buttons&oe.LEFT)===oe.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(y.buttons&oe.MIDDLE)===oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(y.buttons&oe.RIGHT)===oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);_()}},h=y=>{const M=this._lockedPointer||this._findPointerById(1);M&&(M.clientX=y.clientX,M.clientY=y.clientY,M.deltaX=y.movementX,M.deltaY=y.movementY,this._state=0,(this._lockedPointer||(y.buttons&oe.LEFT)===oe.LEFT)&&(this._state=this._state|this.mouseButtons.left),(y.buttons&oe.MIDDLE)===oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(y.buttons&oe.RIGHT)===oe.RIGHT&&(this._state=this._state|this.mouseButtons.right),_())},f=y=>{const M=this._findPointerById(y.pointerId);if(!(M&&M===this._lockedPointer)){if(M&&this._disposePointer(M),y.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=N.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=N.NONE;S()}},p=()=>{const y=this._findPointerById(1);y&&y===this._lockedPointer||(y&&this._disposePointer(y),this._state=N.NONE,S())};let m=-1;const g=y=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===N.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const D=this._domElement.getBoundingClientRect(),z=y.clientX/D.width,U=y.clientY/D.height;if(z<this._interactiveArea.left||z>this._interactiveArea.right||U<this._interactiveArea.top||U>this._interactiveArea.bottom)return}if(y.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===N.ROTATE||this.mouseButtons.wheel===N.TRUCK){const D=performance.now();m-D<1e3&&this._getClientRect(this._elementRect),m=D}const M=Or?-1:-3,P=y.deltaMode===1?y.deltaY/M:y.deltaY/(M*10),A=this.dollyToCursor?(y.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,b=this.dollyToCursor?(y.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case N.ROTATE:{this._rotateInternal(y.deltaX,y.deltaY),this._isUserControllingRotate=!0;break}case N.TRUCK:{this._truckInternal(y.deltaX,y.deltaY,!1),this._isUserControllingTruck=!0;break}case N.OFFSET:{this._truckInternal(y.deltaX,y.deltaY,!0),this._isUserControllingOffset=!0;break}case N.DOLLY:{this._dollyInternal(-P,A,b),this._isUserControllingDolly=!0;break}case N.ZOOM:{this._zoomInternal(-P,A,b),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},w=y=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Tt.ACTION.NONE){const M=y instanceof PointerEvent?y.pointerId:(y instanceof MouseEvent,0),P=this._findPointerById(M);P&&this._disposePointer(P),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",p);return}y.preventDefault()}},x=y=>{if(!this._enabled)return;if(ds(this._activePointers,Ie),this._getClientRect(this._elementRect),s.copy(Ie),n.copy(Ie),this._activePointers.length>=2){const P=Ie.x-this._activePointers[1].clientX,A=Ie.y-this._activePointers[1].clientY,b=Math.sqrt(P*P+A*A);i.set(0,b);const D=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,z=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(D,z)}if(this._state=0,!y)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in y&&y.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&&(y.buttons&oe.LEFT)===oe.LEFT&&(this._state=this._state|this.mouseButtons.left),(y.buttons&oe.MIDDLE)===oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(y.buttons&oe.RIGHT)===oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&N.ROTATE)===N.ROTATE||(this._state&N.TOUCH_ROTATE)===N.TOUCH_ROTATE||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE||(this._state&N.TOUCH_ZOOM_ROTATE)===N.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&N.TRUCK)===N.TRUCK||(this._state&N.TOUCH_TRUCK)===N.TOUCH_TRUCK||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_ZOOM_TRUCK)===N.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&N.DOLLY)===N.DOLLY||(this._state&N.TOUCH_DOLLY)===N.TOUCH_DOLLY||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&N.ZOOM)===N.ZOOM||(this._state&N.TOUCH_ZOOM)===N.TOUCH_ZOOM||(this._state&N.TOUCH_ZOOM_TRUCK)===N.TOUCH_ZOOM_TRUCK||(this._state&N.TOUCH_ZOOM_OFFSET)===N.TOUCH_ZOOM_OFFSET||(this._state&N.TOUCH_ZOOM_ROTATE)===N.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&N.OFFSET)===N.OFFSET||(this._state&N.TOUCH_OFFSET)===N.TOUCH_OFFSET||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET||(this._state&N.TOUCH_ZOOM_OFFSET)===N.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},_=()=>{if(!this._enabled)return;ds(this._activePointers,Ie);const M=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,P=M?-M.deltaX:n.x-Ie.x,A=M?-M.deltaY:n.y-Ie.y;if(n.copy(Ie),((this._state&N.ROTATE)===N.ROTATE||(this._state&N.TOUCH_ROTATE)===N.TOUCH_ROTATE||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE||(this._state&N.TOUCH_ZOOM_ROTATE)===N.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(P,A),this._isUserControllingRotate=!0),(this._state&N.DOLLY)===N.DOLLY||(this._state&N.ZOOM)===N.ZOOM){const b=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,D=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,z=this.dollyDragInverted?-1:1;(this._state&N.DOLLY)===N.DOLLY?(this._dollyInternal(z*A*Vt,b,D),this._isUserControllingDolly=!0):(this._zoomInternal(z*A*Vt,b,D),this._isUserControllingZoom=!0)}if((this._state&N.TOUCH_DOLLY)===N.TOUCH_DOLLY||(this._state&N.TOUCH_ZOOM)===N.TOUCH_ZOOM||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_ZOOM_TRUCK)===N.TOUCH_ZOOM_TRUCK||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET||(this._state&N.TOUCH_ZOOM_OFFSET)===N.TOUCH_ZOOM_OFFSET||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE||(this._state&N.TOUCH_ZOOM_ROTATE)===N.TOUCH_ZOOM_ROTATE){const b=Ie.x-this._activePointers[1].clientX,D=Ie.y-this._activePointers[1].clientY,z=Math.sqrt(b*b+D*D),U=i.y-z;i.set(0,z);const R=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,K=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&N.TOUCH_DOLLY)===N.TOUCH_DOLLY||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET?(this._dollyInternal(U*Vt,R,K),this._isUserControllingDolly=!0):(this._zoomInternal(U*Vt,R,K),this._isUserControllingZoom=!0)}((this._state&N.TRUCK)===N.TRUCK||(this._state&N.TOUCH_TRUCK)===N.TOUCH_TRUCK||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_ZOOM_TRUCK)===N.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(P,A,!1),this._isUserControllingTruck=!0),((this._state&N.OFFSET)===N.OFFSET||(this._state&N.TOUCH_OFFSET)===N.TOUCH_OFFSET||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET||(this._state&N.TOUCH_ZOOM_OFFSET)===N.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(P,A,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},S=()=>{ds(this._activePointers,Ie),n.copy(Ie),(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.ownerDocument.removeEventListener("mouseup",p),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",C),this._domElement.ownerDocument.addEventListener("pointerlockerror",v),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",f),x())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",C),this._domElement.ownerDocument.removeEventListener("pointerlockerror",v))};const C=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},v=()=>{this.unlockPointer()};this._addAllEventListeners=y=>{this._domElement=y,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),Ir&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",f),this._domElement.addEventListener("wheel",g,{passive:!1}),this._domElement.addEventListener("contextmenu",w)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("mousedown",r),this._domElement.removeEventListener("pointercancel",f),this._domElement.removeEventListener("wheel",g,{passive:!1}),this._domElement.removeEventListener("contextmenu",w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("pointerup",f),this._domElement.ownerDocument.removeEventListener("mouseup",p),this._domElement.ownerDocument.removeEventListener("pointerlockchange",C),this._domElement.ownerDocument.removeEventListener("pointerlockerror",v))},this.cancel=()=>{this._state!==N.NONE&&(this._state=N.NONE,this._activePointers.length=0,S())},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=Ne(e.width,0,1),this._interactiveArea.height=Ne(e.height,0,1),this._interactiveArea.x=Ne(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ne(e.x,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,s=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,s)}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,s=!1){this._isUserControllingRotate=!1;const n=Ne(e,this.minAzimuthAngle,this.maxAzimuthAngle),i=Ne(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=i,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!s||_e(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&_e(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}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(Ne(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),r=_e(o,this._spherical.radius);if(!(s>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const i=!t||_e(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(i)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(St).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||_e(this._target.x,this._targetEnd.x,this.restThreshold)&&_e(this._target.y,this._targetEnd.y,this.restThreshold)&&_e(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Ne(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||_e(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(e,t,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,s)}truck(e,t,s=!1){this._camera.updateMatrix(),Ge.setFromMatrixColumn(this._camera.matrix,0),Ee.setFromMatrixColumn(this._camera.matrix,1),Ge.multiplyScalar(e),Ee.multiplyScalar(-t);const n=he.copy(Ge).add(Ee),i=ye.copy(this._targetEnd).add(n);return this.moveTo(i.x,i.y,i.z,s)}forward(e,t=!1){he.setFromMatrixColumn(this._camera.matrix,0),he.crossVectors(this._camera.up,he),he.multiplyScalar(e);const s=ye.copy(this._targetEnd).add(he);return this.moveTo(s.x,s.y,s.z,t)}elevate(e,t=!1){return he.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+he.x,this._targetEnd.y+he.y,this._targetEnd.z+he.z,t)}moveTo(e,t,s,n=!1){this._isUserControllingTruck=!1;const i=he.set(e,t,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,i,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const o=!n||_e(this._target.x,this._targetEnd.x,this.restThreshold)&&_e(this._target.y,this._targetEnd.y,this.restThreshold)&&_e(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,s,n=!1){const r=he.set(e,t,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,n)}fitToBox(e,t,{cover:s=!1,paddingLeft:n=0,paddingRight:i=0,paddingBottom:o=0,paddingTop:r=0}={}){const a=[],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 f=bn(this._sphericalEnd.theta,wn),p=bn(this._sphericalEnd.phi,wn);a.push(this.rotateTo(f,p,t));const m=he.setFromSpherical(this._sphericalEnd).normalize(),g=Ln.setFromUnitVectors(m,gs),w=_e(Math.abs(m.y),1);w&&g.multiply(_s.setFromAxisAngle(Nt,f)),g.multiply(this._yAxisUpSpaceInverse);const x=Cn.makeEmpty();ye.copy(h.min).applyQuaternion(g),x.expandByPoint(ye),ye.copy(h.min).setX(h.max.x).applyQuaternion(g),x.expandByPoint(ye),ye.copy(h.min).setY(h.max.y).applyQuaternion(g),x.expandByPoint(ye),ye.copy(h.max).setZ(h.min.z).applyQuaternion(g),x.expandByPoint(ye),ye.copy(h.min).setZ(h.max.z).applyQuaternion(g),x.expandByPoint(ye),ye.copy(h.max).setY(h.min.y).applyQuaternion(g),x.expandByPoint(ye),ye.copy(h.max).setX(h.min.x).applyQuaternion(g),x.expandByPoint(ye),ye.copy(h.max).applyQuaternion(g),x.expandByPoint(ye),x.min.x-=n,x.min.y-=o,x.max.x+=i,x.max.y+=r,g.setFromUnitVectors(gs,m),w&&g.premultiply(_s.invert()),g.premultiply(this._yAxisUpSpace);const _=x.getSize(he),S=x.getCenter(ye).applyQuaternion(g);if(ot(this._camera)){const C=this.getDistanceToFitBox(_.x,_.y,_.z,s);a.push(this.moveTo(S.x,S.y,S.z,t)),a.push(this.dollyTo(C,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(He(this._camera)){const C=this._camera,v=C.right-C.left,y=C.top-C.bottom,M=s?Math.max(v/_.x,y/_.y):Math.min(v/_.x,y/_.y);a.push(this.moveTo(S.x,S.y,S.z,t)),a.push(this.zoomTo(M,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const s=[],i=e instanceof ne.Sphere?ys.copy(e):Tt.createBoundingSphere(e,ys);if(s.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),ot(this._camera)){const o=this.getDistanceToFitSphere(i.radius);s.push(this.dollyTo(o,t))}else if(He(this._camera)){const o=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*i.radius,h=Math.min(o/a,r/a);s.push(this.zoomTo(h,t))}return s.push(this.setFocalOffset(0,0,0,t)),Promise.all(s)}setLookAt(e,t,s,n,i,o,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=ft.NONE,this._changedDolly=0;const a=ye.set(n,i,o),h=he.set(e,t,s);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(h.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const f=!r||_e(this._target.x,this._targetEnd.x,this.restThreshold)&&_e(this._target.y,this._targetEnd.y,this.restThreshold)&&_e(this._target.z,this._targetEnd.z,this.restThreshold)&&_e(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&_e(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&_e(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(f)}lerpLookAt(e,t,s,n,i,o,r,a,h,f,p,m,g,w=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=ft.NONE,this._changedDolly=0;const x=he.set(n,i,o),_=ye.set(e,t,s);Be.setFromVector3(_.sub(x).applyQuaternion(this._yAxisUpSpace));const S=mt.set(f,p,m),C=ye.set(r,a,h);Pt.setFromVector3(C.sub(S).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(x.lerp(S,g));const v=Pt.theta-Be.theta,y=Pt.phi-Be.phi,M=Pt.radius-Be.radius;this._sphericalEnd.set(Be.radius+M*g,Be.phi+y*g,Be.theta+v*g),this.normalizeRotations(),this._needsUpdate=!0,w||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const P=!w||_e(this._target.x,this._targetEnd.x,this.restThreshold)&&_e(this._target.y,this._targetEnd.y,this.restThreshold)&&_e(this._target.z,this._targetEnd.z,this.restThreshold)&&_e(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&_e(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&_e(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(P)}setPosition(e,t,s,n=!1){return this.setLookAt(e,t,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,n)}setTarget(e,t,s,n=!1){const i=this.getPosition(he),o=this.setLookAt(i.x,i.y,i.z,e,t,s,n);return this._sphericalEnd.phi=Ne(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,s,n=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,s),this._needsUpdate=!0,n||this._focalOffset.copy(this._focalOffsetEnd);const i=!n||_e(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&_e(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&_e(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),Ge.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Ee.setFromMatrixColumn(this._camera.matrixWorldInverse,1),rt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=he.set(e,t,s),i=n.distanceTo(this._camera.position),o=n.sub(this._camera.position);Ge.multiplyScalar(o.x),Ee.multiplyScalar(o.y),rt.multiplyScalar(o.z),he.copy(Ge).add(Ee).add(rt),he.z=he.z+i,this.dollyTo(i,!1),this.setFocalOffset(-he.x,he.y,-he.z,!1),this.moveTo(e,t,s,!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,s,n){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new ne.Vector4,typeof e=="number"?this._viewport.set(e,t,s,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,n=!1){if(ms(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const i=e/t,o=this._camera.getEffectiveFOV()*bt,r=this._camera.aspect;return((n?i>r:i<r)?t:e/r)*.5/Math.tan(o*.5)+s*.5}getDistanceToFitSphere(e){if(ms(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*bt,s=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,n=1<this._camera.aspect?t:s;return e/Math.sin(n*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new ne.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new ne.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof ne.Spherical?e:new ne.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new ne.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%dt,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=dt),this._spherical.theta+=dt*Math.round((this._sphericalEnd.theta-this._spherical.theta)/dt)}reset(e=!1){if(!_e(this._camera.up.x,this._cameraUp0.x)||!_e(this._camera.up.y,this._cameraUp0.y)||!_e(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(he);this.updateCameraUp(),this.setPosition(s.x,s.y,s.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,Nt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=he.subVectors(this._target,this._camera.position).normalize(),t=ye.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(he);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,s=this._sphericalEnd.phi-this._spherical.phi,n=this._sphericalEnd.radius-this._spherical.radius,i=Pn.subVectors(this._targetEnd,this._target),o=Tn.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(we(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Ut(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,p,1/0,e),this._needsUpdate=!0}if(we(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Ut(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,p,1/0,e),this._needsUpdate=!0}if(we(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const p=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Ut(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,p,this.maxSpeed,e),this._needsUpdate=!0}if(we(i.x)&&we(i.y)&&we(i.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const p=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;An(this._target,this._targetEnd,this._targetVelocity,p,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(we(o.x)&&we(o.y)&&we(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const p=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;An(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,p,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(we(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const p=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Ut(this._zoom,this._zoomEnd,this._zoomVelocity,p,1/0,e)}if(this.dollyToCursor){if(ot(this._camera)&&this._changedDolly!==0){const p=this._spherical.radius-this._lastDistance,m=this._camera,g=this._getCameraDirection(St),w=he.copy(g).cross(m.up).normalize();w.lengthSq()===0&&(w.x=1);const x=ye.crossVectors(w,g),_=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*bt*.5),C=(this._sphericalEnd.radius-p-this._sphericalEnd.radius)/this._sphericalEnd.radius,v=mt.copy(this._targetEnd).add(w.multiplyScalar(this._dollyControlCoord.x*_*m.aspect)).add(x.multiplyScalar(this._dollyControlCoord.y*_)),y=he.copy(this._targetEnd).lerp(v,C),M=this._lastDollyDirection===ft.IN&&this._spherical.radius<=this.minDistance,P=this._lastDollyDirection===ft.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(M||P)){this._sphericalEnd.radius-=p,this._spherical.radius-=p;const b=ye.copy(g).multiplyScalar(-p);y.add(b)}this._boundary.clampPoint(y,y);const A=ye.subVectors(y,this._targetEnd);this._targetEnd.copy(y),this._target.add(A),this._changedDolly-=p,we(this._changedDolly)&&(this._changedDolly=0)}else if(He(this._camera)&&this._changedZoom!==0){const p=this._zoom-this._lastZoom,m=this._camera,g=he.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),w=ye.set(0,0,-1).applyQuaternion(m.quaternion),x=mt.copy(g).add(w.multiplyScalar(-g.dot(m.up))),S=-(this._zoom-p-this._zoom)/this._zoom,C=this._getCameraDirection(St),v=this._targetEnd.dot(C),y=he.copy(this._targetEnd).lerp(x,S),M=y.dot(C),P=C.multiplyScalar(M-v);y.sub(P),this._boundary.clampPoint(y,y);const A=ye.subVectors(y,this._targetEnd);this._targetEnd.copy(y),this._target.add(A),this._changedZoom-=p,we(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0);const a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!we(this._focalOffset.x)||!we(this._focalOffset.y)||!we(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Ge.setFromMatrixColumn(this._camera.matrix,0),Ee.setFromMatrixColumn(this._camera.matrix,1),rt.setFromMatrixColumn(this._camera.matrix,2),Ge.multiplyScalar(this._focalOffset.x),Ee.multiplyScalar(-this._focalOffset.y),rt.multiplyScalar(this._focalOffset.z),he.copy(Ge).add(Ee).add(rt),this._camera.position.add(he)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),he.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const f=this._needsUpdate;return f&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):f?(this.dispatchEvent({type:"update"}),we(t,this.restThreshold)&&we(s,this.restThreshold)&&we(n,this.restThreshold)&&we(i.x,this.restThreshold)&&we(i.y,this.restThreshold)&&we(i.z,this.restThreshold)&&we(o.x,this.restThreshold)&&we(o.y,this.restThreshold)&&we(o.z,this.restThreshold)&&we(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!f&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=f,this._needsUpdate=!1,f}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:At(this.maxDistance),minZoom:this.minZoom,maxZoom:At(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:At(this.maxPolarAngle),minAzimuthAngle:At(this.minAzimuthAngle),maxAzimuthAngle:At(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:he.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 s=JSON.parse(e);this.enabled=s.enabled,this.minDistance=s.minDistance,this.maxDistance=Mt(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=Mt(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=Mt(s.maxPolarAngle),this.minAzimuthAngle=Mt(s.minAzimuthAngle),this.maxAzimuthAngle=Mt(s.maxAzimuthAngle),this.smoothTime=s.smoothTime,this.draggingSmoothTime=s.draggingSmoothTime,this.dollySpeed=s.dollySpeed,this.truckSpeed=s.truckSpeed,this.dollyToCursor=s.dollyToCursor,this.verticalDragToForward=s.verticalDragToForward,this._target0.fromArray(s.target0),this._position0.fromArray(s.position0),this._zoom0=s.zoom0,this._focalOffset0.fromArray(s.focalOffset0),this.moveTo(s.target[0],s.target[1],s.target[2],t),Be.setFromVector3(he.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Be.theta,Be.phi,t),this.dollyTo(Be.radius,t),this.zoomTo(s.zoom,t),this.setFocalOffset(s.focalOffset[0],s.focalOffset[1],s.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",Lr),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,s){const n=t.lengthSq();if(n===0)return e;const i=ye.copy(t).add(e),r=this._boundary.clampPoint(i,mt).sub(i),a=r.lengthSq();if(a===0)return e.add(t);if(a===n)return e;if(s===0)return e.add(t).add(r);{const h=1+s*a/t.dot(r);return e.add(ye.copy(t).multiplyScalar(h)).add(r.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(ot(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*bt,n=Math.tan(s*.5)*t,i=n*e.aspect;this._nearPlaneCorners[0].set(-i,-n,0),this._nearPlaneCorners[1].set(i,-n,0),this._nearPlaneCorners[2].set(i,n,0),this._nearPlaneCorners[3].set(-i,n,0)}else if(He(this._camera)){const e=this._camera,t=1/e.zoom,s=e.left*t,n=e.right*t,i=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(s,i,0),this._nearPlaneCorners[1].set(n,i,0),this._nearPlaneCorners[2].set(n,o,0),this._nearPlaneCorners[3].set(s,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||ms(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(St);xs.lookAt(Sn,s,this._camera.up);for(let n=0;n<4;n++){const i=ye.copy(this._nearPlaneCorners[n]);i.applyMatrix4(xs);const o=mt.addVectors(this._target,i);zt.set(o,s),zt.far=this._spherical.radius+1;const r=zt.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<e&&(e=r[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 s=()=>{this.removeEventListener("rest",s),t()};this.addEventListener("rest",s)}))}_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 ne.Sphere){const s=t,n=s.center;gt.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&gt.expandByObject(o)}),gt.getCenter(n);let i=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const r=o,a=r.geometry.clone();a.applyMatrix4(r.matrixWorld);const f=a.attributes.position;for(let p=0,m=f.count;p<m;p++)he.fromBufferAttribute(f,p),i=Math.max(i,n.distanceToSquared(he))}),s.radius=Math.sqrt(i),s}}const Dr=["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"],kr=u.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},distance:{default:()=>ue.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:1/0},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:1/0},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:1/0},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:{},touches:{}},emits:["change","start","end"],setup(l,{expose:e,emit:t}){const s=l,{makeDefault:n,minPolarAngle:i,maxPolarAngle:o,minAzimuthAngle:r,maxAzimuthAngle:a,distance:h,minDistance:f,maxDistance:p,infinityDolly:m,minZoom:g,maxZoom:w,smoothTime:x,draggingSmoothTime:_,maxSpeed:S,azimuthRotateSpeed:C,polarRotateSpeed:v,dollySpeed:y,dollyDragInverted:M,truckSpeed:P,dollyToCursor:A,dragToOffset:b,verticalDragToForward:D,boundaryFriction:z,restThreshold:U,colliderMeshes:R}=u.toRefs(s),K={Box3:c.Box3,MathUtils:{clamp:c.MathUtils.clamp},Matrix4:c.Matrix4,Quaternion:c.Quaternion,Raycaster:c.Raycaster,Sphere:c.Sphere,Spherical:c.Spherical,Vector2:c.Vector2,Vector3:c.Vector3,Vector4:c.Vector4};Tt.install({THREE:K});const{camera:Z,renderer:W,extend:pe,controls:Q}=ue.useTresContext(),G=u.ref(null);pe({CameraControls:Tt}),u.watchEffect(()=>{ce(),G.value&&n.value?Q.value=G.value:Q.value=null});function ce(){Se(G.value,"update",()=>t("change",G.value)),Se(G.value,"controlend",()=>t("end",G.value)),Se(G.value,"controlstart",()=>t("start",G.value))}const{onLoop:se}=ue.useRenderLoop();return se(({delta:ae})=>{var B,I;(B=G.value)!=null&&B.enabled&&((I=G.value)==null||I.update(ae))}),u.onUnmounted(()=>{G.value&&G.value.disconnect()}),e({value:G}),(ae,B)=>(ae.camera||u.unref(Z))&&(ae.domElement||u.unref(W))?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:G,"min-polar-angle":u.unref(i),"max-polar-angle":u.unref(o),"min-azimuth-angle":u.unref(r),"max-azimuth-angle":u.unref(a),distance:u.unref(h),"min-distance":u.unref(f),"max-distance":u.unref(p),"infinity-dolly":u.unref(m),"min-zoom":u.unref(g),"max-zoom":u.unref(w),"smooth-time":u.unref(x),"dragging-smooth-time":u.unref(_),"max-speed":u.unref(S),"azimuth-rotate-speed":u.unref(C),"polar-rotate-speed":u.unref(v),"dolly-speed":u.unref(y),"dolly-drag-inverted":u.unref(M),"truck-speed":u.unref(P),"dolly-to-cursor":u.unref(A),"drag-to-offset":u.unref(b),"vertical-drag-to-forward":u.unref(D),"boundary-friction":u.unref(z),"rest-threshold":u.unref(U),"collider-meshes":u.unref(R),args:[ae.camera||u.unref(Z),ae.domElement||u.unref(W).domElement]},null,8,Dr)):u.createCommentVNode("",!0)}});class Fr extends c.MeshStandardMaterial{constructor(t={}){super(t);Ae(this,"_time");Ae(this,"_factor");this.setValues(t),this._time={value:0},this._factor={value:1}}onBeforeCompile(t){t.uniforms||(t.uniforms={}),t.uniforms.time=this._time,t.uniforms.factor=this._factor,t.vertexShader=`
189
+ */const le={LEFT:1,RIGHT:2,MIDDLE:4},N=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}),bt={NONE:0,IN:1,OUT:-1};function pt(a){return a.isPerspectiveCamera}function rt(a){return a.isOrthographicCamera}const At=Math.PI*2,Qs=Math.PI/2,Ks=1e-5,kt=Math.PI/180;function je(a,e,t){return Math.max(e,Math.min(t,a))}function xe(a,e=Ks){return Math.abs(a)<e}function ve(a,e,t=Ks){return xe(a-e,t)}function qs(a,e){return Math.round(a/e)*e}function Ft(a){return isFinite(a)?a:a<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Bt(a){return Math.abs(a)<Number.MAX_VALUE?a:a*(1/0)}function Ht(a,e,t,n,s=1/0,i){n=Math.max(1e-4,n);const o=2/n,r=o*i,l=1/(1+r+.48*r*r+.235*r*r*r);let f=a-e;const d=e,u=s*n;f=je(f,-u,u),e=a-f;const p=(t.value+o*f)*i;t.value=(t.value-o*p)*l;let g=e+(f+p)*l;return d-a>0==g>d&&(g=d,t.value=(g-d)/i),g}function Js(a,e,t,n,s=1/0,i,o){n=Math.max(1e-4,n);const r=2/n,l=r*i,f=1/(1+l+.48*l*l+.235*l*l*l);let d=e.x,u=e.y,p=e.z,g=a.x-d,x=a.y-u,w=a.z-p;const _=d,M=u,L=p,v=s*n,y=v*v,A=g*g+x*x+w*w;if(A>y){const H=Math.sqrt(A);g=g/H*v,x=x/H*v,w=w/H*v}d=a.x-g,u=a.y-x,p=a.z-w;const S=(t.x+r*g)*i,b=(t.y+r*x)*i,P=(t.z+r*w)*i;t.x=(t.x-r*S)*f,t.y=(t.y-r*b)*f,t.z=(t.z-r*P)*f,o.x=d+(g+S)*f,o.y=u+(x+b)*f,o.z=p+(w+P)*f;const O=_-a.x,k=M-a.y,V=L-a.z,R=o.x-_,X=o.y-M,K=o.z-L;return O*R+k*X+V*K>0&&(o.x=_,o.y=M,o.z=L,t.x=(o.x-_)/i,t.y=(o.y-M)/i,t.z=(o.z-L)/i),o}function Fn(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 Bn(a,e){return rt(a)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class ba{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 s=this._listeners[e];if(s!==void 0){const i=s.indexOf(t);i!==-1&&s.splice(i,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 s=n.slice(0);for(let i=0,o=s.length;i<o;i++)s[i].call(this,e)}}}const Aa="2.7.2",$t=1/8,Hs=typeof window<"u",Ma=Hs&&/Mac/.test(navigator.platform),Sa=!(Hs&&"PointerEvent"in window);let re,$s,en,Un,Be,de,ye,Mt,Ut,Ye,We,mt,ei,ti,Ne,Vt,St,ni,Vn,si,zn,Nn,tn;class zt extends ba{static install(e){re=e.THREE,$s=Object.freeze(new re.Vector3(0,0,0)),en=Object.freeze(new re.Vector3(0,1,0)),Un=Object.freeze(new re.Vector3(0,0,1)),Be=new re.Vector2,de=new re.Vector3,ye=new re.Vector3,Mt=new re.Vector3,Ut=new re.Vector3,Ye=new re.Vector3,We=new re.Vector3,mt=new re.Vector3,ei=new re.Vector3,ti=new re.Vector3,Ne=new re.Spherical,Vt=new re.Spherical,St=new re.Box3,ni=new re.Box3,Vn=new re.Sphere,si=new re.Quaternion,zn=new re.Quaternion,Nn=new re.Matrix4,tn=new re.Raycaster}static get ACTION(){return N}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=N.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._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=bt.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new re.Vector3,this._focalOffsetVelocity=new re.Vector3,this._zoomVelocity={value:0},this._truckInternal=(y,A,S)=>{let b,P;if(pt(this._camera)){const O=de.copy(this._camera.position).sub(this._target),k=this._camera.getEffectiveFOV()*kt,V=O.length()*Math.tan(k*.5);b=this.truckSpeed*y*V/this._elementRect.height,P=this.truckSpeed*A*V/this._elementRect.height}else if(rt(this._camera)){const O=this._camera;b=y*(O.right-O.left)/O.zoom/this._elementRect.width,P=A*(O.top-O.bottom)/O.zoom/this._elementRect.height}else return;this.verticalDragToForward?(S?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(b,0,!0),this.forward(-P,!0)):S?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y+P,this._focalOffsetEnd.z,!0):this.truck(b,P,!0)},this._rotateInternal=(y,A)=>{const S=At*this.azimuthRotateSpeed*y/this._elementRect.height,b=At*this.polarRotateSpeed*A/this._elementRect.height;this.rotate(S,b,!0)},this._dollyInternal=(y,A,S)=>{const b=Math.pow(.95,-y*this.dollySpeed),P=this._sphericalEnd.radius,O=this._sphericalEnd.radius*b,k=je(O,this.minDistance,this.maxDistance),V=k-O;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(O,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(V,!0),this._dollyToNoClamp(k,!0)):this._dollyToNoClamp(k,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?O:k)-P,this._dollyControlCoord.set(A,S)),this._lastDollyDirection=Math.sign(-y)},this._zoomInternal=(y,A,S)=>{const b=Math.pow(.95,y*this.dollySpeed),P=this._zoom,O=this._zoom*b;this.zoomTo(O,!0),this.dollyToCursor&&(this._changedZoom+=O-P,this._dollyControlCoord.set(A,S))},typeof re>"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 re.Quaternion().setFromUnitVectors(this._camera.up,en),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=N.NONE,this._target=new re.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new re.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new re.Spherical().setFromVector3(de.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 re.Vector3,new re.Vector3,new re.Vector3,new re.Vector3],this._updateNearPlaneCorners(),this._boundary=new re.Box3(new re.Vector3(-1/0,-1/0,-1/0),new re.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 re.Vector2,this.mouseButtons={left:N.ROTATE,middle:N.DOLLY,right:N.TRUCK,wheel:pt(this._camera)?N.DOLLY:rt(this._camera)?N.ZOOM:N.NONE},this.touches={one:N.TOUCH_ROTATE,two:pt(this._camera)?N.TOUCH_DOLLY_TRUCK:rt(this._camera)?N.TOUCH_ZOOM_TRUCK:N.NONE,three:N.TOUCH_TRUCK};const n=new re.Vector2,s=new re.Vector2,i=new re.Vector2,o=y=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const b=this._domElement.getBoundingClientRect(),P=y.clientX/b.width,O=y.clientY/b.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const A=y.pointerType!=="mouse"?null:(y.buttons&le.LEFT)===le.LEFT?le.LEFT:(y.buttons&le.MIDDLE)===le.MIDDLE?le.MIDDLE:(y.buttons&le.RIGHT)===le.RIGHT?le.RIGHT:null;if(A!==null){const b=this._findPointerByMouseButton(A);b&&this._disposePointer(b)}if((y.buttons&le.LEFT)===le.LEFT&&this._lockedPointer)return;const S={pointerId:y.pointerId,clientX:y.clientX,clientY:y.clientY,deltaX:0,deltaY:0,mouseButton:A};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),this._isDragging=!0,w(y)},r=y=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const b=this._domElement.getBoundingClientRect(),P=y.clientX/b.width,O=y.clientY/b.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}const A=(y.buttons&le.LEFT)===le.LEFT?le.LEFT:(y.buttons&le.MIDDLE)===le.MIDDLE?le.MIDDLE:(y.buttons&le.RIGHT)===le.RIGHT?le.RIGHT:null;if(A!==null){const b=this._findPointerByMouseButton(A);b&&this._disposePointer(b)}const S={pointerId:1,clientX:y.clientX,clientY:y.clientY,deltaX:0,deltaY:0,mouseButton:(y.buttons&le.LEFT)===le.LEFT?le.LEFT:(y.buttons&le.MIDDLE)===le.LEFT?le.MIDDLE:(y.buttons&le.RIGHT)===le.LEFT?le.RIGHT:null};this._activePointers.push(S),this._domElement.ownerDocument.removeEventListener("mousemove",f),this._domElement.ownerDocument.removeEventListener("mouseup",u),this._domElement.ownerDocument.addEventListener("mousemove",f),this._domElement.ownerDocument.addEventListener("mouseup",u),this._isDragging=!0,w(y)},l=y=>{y.cancelable&&y.preventDefault();const A=y.pointerId,S=this._lockedPointer||this._findPointerById(A);if(S){if(S.clientX=y.clientX,S.clientY=y.clientY,S.deltaX=y.movementX,S.deltaY=y.movementY,this._state=0,y.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&&(y.buttons&le.LEFT)===le.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(y.buttons&le.MIDDLE)===le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(y.buttons&le.RIGHT)===le.RIGHT&&(this._state=this._state|this.mouseButtons.right);_()}},f=y=>{const A=this._lockedPointer||this._findPointerById(1);A&&(A.clientX=y.clientX,A.clientY=y.clientY,A.deltaX=y.movementX,A.deltaY=y.movementY,this._state=0,(this._lockedPointer||(y.buttons&le.LEFT)===le.LEFT)&&(this._state=this._state|this.mouseButtons.left),(y.buttons&le.MIDDLE)===le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(y.buttons&le.RIGHT)===le.RIGHT&&(this._state=this._state|this.mouseButtons.right),_())},d=y=>{const A=this._findPointerById(y.pointerId);if(!(A&&A===this._lockedPointer)){if(A&&this._disposePointer(A),y.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=N.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=N.NONE;M()}},u=()=>{const y=this._findPointerById(1);y&&y===this._lockedPointer||(y&&this._disposePointer(y),this._state=N.NONE,M())};let p=-1;const g=y=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===N.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const O=this._domElement.getBoundingClientRect(),k=y.clientX/O.width,V=y.clientY/O.height;if(k<this._interactiveArea.left||k>this._interactiveArea.right||V<this._interactiveArea.top||V>this._interactiveArea.bottom)return}if(y.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===N.ROTATE||this.mouseButtons.wheel===N.TRUCK){const O=performance.now();p-O<1e3&&this._getClientRect(this._elementRect),p=O}const A=Ma?-1:-3,S=y.deltaMode===1?y.deltaY/A:y.deltaY/(A*10),b=this.dollyToCursor?(y.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,P=this.dollyToCursor?(y.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case N.ROTATE:{this._rotateInternal(y.deltaX,y.deltaY),this._isUserControllingRotate=!0;break}case N.TRUCK:{this._truckInternal(y.deltaX,y.deltaY,!1),this._isUserControllingTruck=!0;break}case N.OFFSET:{this._truckInternal(y.deltaX,y.deltaY,!0),this._isUserControllingOffset=!0;break}case N.DOLLY:{this._dollyInternal(-S,b,P),this._isUserControllingDolly=!0;break}case N.ZOOM:{this._zoomInternal(-S,b,P),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},x=y=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===zt.ACTION.NONE){const A=y instanceof PointerEvent?y.pointerId:(y instanceof MouseEvent,0),S=this._findPointerById(A);S&&this._disposePointer(S),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mousemove",f),this._domElement.ownerDocument.removeEventListener("mouseup",u);return}y.preventDefault()}},w=y=>{if(!this._enabled)return;if(Fn(this._activePointers,Be),this._getClientRect(this._elementRect),n.copy(Be),s.copy(Be),this._activePointers.length>=2){const S=Be.x-this._activePointers[1].clientX,b=Be.y-this._activePointers[1].clientY,P=Math.sqrt(S*S+b*b);i.set(0,P);const O=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,k=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;s.set(O,k)}if(this._state=0,!y)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in y&&y.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&&(y.buttons&le.LEFT)===le.LEFT&&(this._state=this._state|this.mouseButtons.left),(y.buttons&le.MIDDLE)===le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(y.buttons&le.RIGHT)===le.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&N.ROTATE)===N.ROTATE||(this._state&N.TOUCH_ROTATE)===N.TOUCH_ROTATE||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE||(this._state&N.TOUCH_ZOOM_ROTATE)===N.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&N.TRUCK)===N.TRUCK||(this._state&N.TOUCH_TRUCK)===N.TOUCH_TRUCK||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_ZOOM_TRUCK)===N.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&N.DOLLY)===N.DOLLY||(this._state&N.TOUCH_DOLLY)===N.TOUCH_DOLLY||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&N.ZOOM)===N.ZOOM||(this._state&N.TOUCH_ZOOM)===N.TOUCH_ZOOM||(this._state&N.TOUCH_ZOOM_TRUCK)===N.TOUCH_ZOOM_TRUCK||(this._state&N.TOUCH_ZOOM_OFFSET)===N.TOUCH_ZOOM_OFFSET||(this._state&N.TOUCH_ZOOM_ROTATE)===N.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&N.OFFSET)===N.OFFSET||(this._state&N.TOUCH_OFFSET)===N.TOUCH_OFFSET||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET||(this._state&N.TOUCH_ZOOM_OFFSET)===N.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},_=()=>{if(!this._enabled)return;Fn(this._activePointers,Be);const A=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,S=A?-A.deltaX:s.x-Be.x,b=A?-A.deltaY:s.y-Be.y;if(s.copy(Be),((this._state&N.ROTATE)===N.ROTATE||(this._state&N.TOUCH_ROTATE)===N.TOUCH_ROTATE||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE||(this._state&N.TOUCH_ZOOM_ROTATE)===N.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(S,b),this._isUserControllingRotate=!0),(this._state&N.DOLLY)===N.DOLLY||(this._state&N.ZOOM)===N.ZOOM){const P=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,O=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,k=this.dollyDragInverted?-1:1;(this._state&N.DOLLY)===N.DOLLY?(this._dollyInternal(k*b*$t,P,O),this._isUserControllingDolly=!0):(this._zoomInternal(k*b*$t,P,O),this._isUserControllingZoom=!0)}if((this._state&N.TOUCH_DOLLY)===N.TOUCH_DOLLY||(this._state&N.TOUCH_ZOOM)===N.TOUCH_ZOOM||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_ZOOM_TRUCK)===N.TOUCH_ZOOM_TRUCK||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET||(this._state&N.TOUCH_ZOOM_OFFSET)===N.TOUCH_ZOOM_OFFSET||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE||(this._state&N.TOUCH_ZOOM_ROTATE)===N.TOUCH_ZOOM_ROTATE){const P=Be.x-this._activePointers[1].clientX,O=Be.y-this._activePointers[1].clientY,k=Math.sqrt(P*P+O*O),V=i.y-k;i.set(0,k);const R=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,X=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&N.TOUCH_DOLLY)===N.TOUCH_DOLLY||(this._state&N.TOUCH_DOLLY_ROTATE)===N.TOUCH_DOLLY_ROTATE||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET?(this._dollyInternal(V*$t,R,X),this._isUserControllingDolly=!0):(this._zoomInternal(V*$t,R,X),this._isUserControllingZoom=!0)}((this._state&N.TRUCK)===N.TRUCK||(this._state&N.TOUCH_TRUCK)===N.TOUCH_TRUCK||(this._state&N.TOUCH_DOLLY_TRUCK)===N.TOUCH_DOLLY_TRUCK||(this._state&N.TOUCH_ZOOM_TRUCK)===N.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(S,b,!1),this._isUserControllingTruck=!0),((this._state&N.OFFSET)===N.OFFSET||(this._state&N.TOUCH_OFFSET)===N.TOUCH_OFFSET||(this._state&N.TOUCH_DOLLY_OFFSET)===N.TOUCH_DOLLY_OFFSET||(this._state&N.TOUCH_ZOOM_OFFSET)===N.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(S,b,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},M=()=>{Fn(this._activePointers,Be),s.copy(Be),(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",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",f),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",u),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",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",L),this._domElement.ownerDocument.addEventListener("pointerlockerror",v),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),w())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",L),this._domElement.ownerDocument.removeEventListener("pointerlockerror",v))};const L=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},v=()=>{this.unlockPointer()};this._addAllEventListeners=y=>{this._domElement=y,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),Sa&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",d),this._domElement.addEventListener("wheel",g,{passive:!1}),this._domElement.addEventListener("contextmenu",x)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("mousedown",r),this._domElement.removeEventListener("pointercancel",d),this._domElement.removeEventListener("wheel",g,{passive:!1}),this._domElement.removeEventListener("contextmenu",x),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",f),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",u),this._domElement.ownerDocument.removeEventListener("pointerlockchange",L),this._domElement.ownerDocument.removeEventListener("pointerlockerror",v))},this.cancel=()=>{this._state!==N.NONE&&(this._state=N.NONE,this._activePointers.length=0,M())},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=je(e.width,0,1),this._interactiveArea.height=je(e.height,0,1),this._interactiveArea.x=je(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=je(e.x,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 s=je(e,this.minAzimuthAngle,this.maxAzimuthAngle),i=je(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=i,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!n||ve(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ve(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=bt.NONE,this._changedDolly=0,this._dollyToNoClamp(je(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),r=ve(o,this._spherical.radius);if(!(n>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const i=!t||ve(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(i)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Ut).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||ve(this._target.x,this._targetEnd.x,this.restThreshold)&&ve(this._target.y,this._targetEnd.y,this.restThreshold)&&ve(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=je(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||ve(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(),Ye.setFromMatrixColumn(this._camera.matrix,0),We.setFromMatrixColumn(this._camera.matrix,1),Ye.multiplyScalar(e),We.multiplyScalar(-t);const s=de.copy(Ye).add(We),i=ye.copy(this._targetEnd).add(s);return this.moveTo(i.x,i.y,i.z,n)}forward(e,t=!1){de.setFromMatrixColumn(this._camera.matrix,0),de.crossVectors(this._camera.up,de),de.multiplyScalar(e);const n=ye.copy(this._targetEnd).add(de);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return de.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+de.x,this._targetEnd.y+de.y,this._targetEnd.z+de.z,t)}moveTo(e,t,n,s=!1){this._isUserControllingTruck=!1;const i=de.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,i,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const o=!s||ve(this._target.x,this._targetEnd.x,this.restThreshold)&&ve(this._target.y,this._targetEnd.y,this.restThreshold)&&ve(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,n,s=!1){const r=de.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,s)}fitToBox(e,t,{cover:n=!1,paddingLeft:s=0,paddingRight:i=0,paddingBottom:o=0,paddingTop:r=0}={}){const l=[],f=e.isBox3?St.copy(e):St.setFromObject(e);f.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const d=qs(this._sphericalEnd.theta,Qs),u=qs(this._sphericalEnd.phi,Qs);l.push(this.rotateTo(d,u,t));const p=de.setFromSpherical(this._sphericalEnd).normalize(),g=si.setFromUnitVectors(p,Un),x=ve(Math.abs(p.y),1);x&&g.multiply(zn.setFromAxisAngle(en,d)),g.multiply(this._yAxisUpSpaceInverse);const w=ni.makeEmpty();ye.copy(f.min).applyQuaternion(g),w.expandByPoint(ye),ye.copy(f.min).setX(f.max.x).applyQuaternion(g),w.expandByPoint(ye),ye.copy(f.min).setY(f.max.y).applyQuaternion(g),w.expandByPoint(ye),ye.copy(f.max).setZ(f.min.z).applyQuaternion(g),w.expandByPoint(ye),ye.copy(f.min).setZ(f.max.z).applyQuaternion(g),w.expandByPoint(ye),ye.copy(f.max).setY(f.min.y).applyQuaternion(g),w.expandByPoint(ye),ye.copy(f.max).setX(f.min.x).applyQuaternion(g),w.expandByPoint(ye),ye.copy(f.max).applyQuaternion(g),w.expandByPoint(ye),w.min.x-=s,w.min.y-=o,w.max.x+=i,w.max.y+=r,g.setFromUnitVectors(Un,p),x&&g.premultiply(zn.invert()),g.premultiply(this._yAxisUpSpace);const _=w.getSize(de),M=w.getCenter(ye).applyQuaternion(g);if(pt(this._camera)){const L=this.getDistanceToFitBox(_.x,_.y,_.z,n);l.push(this.moveTo(M.x,M.y,M.z,t)),l.push(this.dollyTo(L,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(rt(this._camera)){const L=this._camera,v=L.right-L.left,y=L.top-L.bottom,A=n?Math.max(v/_.x,y/_.y):Math.min(v/_.x,y/_.y);l.push(this.moveTo(M.x,M.y,M.z,t)),l.push(this.zoomTo(A,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const n=[],i=e instanceof re.Sphere?Vn.copy(e):zt.createBoundingSphere(e,Vn);if(n.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),pt(this._camera)){const o=this.getDistanceToFitSphere(i.radius);n.push(this.dollyTo(o,t))}else if(rt(this._camera)){const o=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,l=2*i.radius,f=Math.min(o/l,r/l);n.push(this.zoomTo(f,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,s,i,o,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bt.NONE,this._changedDolly=0;const l=ye.set(s,i,o),f=de.set(e,t,n);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(f.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const d=!r||ve(this._target.x,this._targetEnd.x,this.restThreshold)&&ve(this._target.y,this._targetEnd.y,this.restThreshold)&&ve(this._target.z,this._targetEnd.z,this.restThreshold)&&ve(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ve(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&ve(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(d)}lerpLookAt(e,t,n,s,i,o,r,l,f,d,u,p,g,x=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bt.NONE,this._changedDolly=0;const w=de.set(s,i,o),_=ye.set(e,t,n);Ne.setFromVector3(_.sub(w).applyQuaternion(this._yAxisUpSpace));const M=Mt.set(d,u,p),L=ye.set(r,l,f);Vt.setFromVector3(L.sub(M).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(w.lerp(M,g));const v=Vt.theta-Ne.theta,y=Vt.phi-Ne.phi,A=Vt.radius-Ne.radius;this._sphericalEnd.set(Ne.radius+A*g,Ne.phi+y*g,Ne.theta+v*g),this.normalizeRotations(),this._needsUpdate=!0,x||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const S=!x||ve(this._target.x,this._targetEnd.x,this.restThreshold)&&ve(this._target.y,this._targetEnd.y,this.restThreshold)&&ve(this._target.z,this._targetEnd.z,this.restThreshold)&&ve(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&ve(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&ve(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(S)}setPosition(e,t,n,s=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,t,n,s=!1){const i=this.getPosition(de),o=this.setLookAt(i.x,i.y,i.z,e,t,n,s);return this._sphericalEnd.phi=je(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,n,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const i=!s||ve(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&ve(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&ve(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Ye.setFromMatrixColumn(this._camera.matrixWorldInverse,0),We.setFromMatrixColumn(this._camera.matrixWorldInverse,1),mt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=de.set(e,t,n),i=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);Ye.multiplyScalar(o.x),We.multiplyScalar(o.y),mt.multiplyScalar(o.z),de.copy(Ye).add(We).add(mt),de.z=de.z+i,this.dollyTo(i,!1),this.setFocalOffset(-de.x,de.y,-de.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,s){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new re.Vector4,typeof e=="number"?this._viewport.set(e,t,n,s):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,s=!1){if(Bn(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const i=e/t,o=this._camera.getEffectiveFOV()*kt,r=this._camera.aspect;return((s?i>r:i<r)?t:e/r)*.5/Math.tan(o*.5)+n*.5}getDistanceToFitSphere(e){if(Bn(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*kt,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,s=1<this._camera.aspect?t:n;return e/Math.sin(s*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new re.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new re.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof re.Spherical?e:new re.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new re.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%At,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=At),this._spherical.theta+=At*Math.round((this._sphericalEnd.theta-this._spherical.theta)/At)}reset(e=!1){if(!ve(this._camera.up.x,this._cameraUp0.x)||!ve(this._camera.up.y,this._cameraUp0.y)||!ve(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(de);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,en),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=de.subVectors(this._target,this._camera.position).normalize(),t=ye.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(de);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,s=this._sphericalEnd.radius-this._spherical.radius,i=ei.subVectors(this._targetEnd,this._target),o=ti.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(xe(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const u=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Ht(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,u,1/0,e),this._needsUpdate=!0}if(xe(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const u=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Ht(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,u,1/0,e),this._needsUpdate=!0}if(xe(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const u=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Ht(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,u,this.maxSpeed,e),this._needsUpdate=!0}if(xe(i.x)&&xe(i.y)&&xe(i.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const u=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Js(this._target,this._targetEnd,this._targetVelocity,u,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(xe(o.x)&&xe(o.y)&&xe(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const u=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Js(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,u,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(xe(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const u=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Ht(this._zoom,this._zoomEnd,this._zoomVelocity,u,1/0,e)}if(this.dollyToCursor){if(pt(this._camera)&&this._changedDolly!==0){const u=this._spherical.radius-this._lastDistance,p=this._camera,g=this._getCameraDirection(Ut),x=de.copy(g).cross(p.up).normalize();x.lengthSq()===0&&(x.x=1);const w=ye.crossVectors(x,g),_=this._sphericalEnd.radius*Math.tan(p.getEffectiveFOV()*kt*.5),L=(this._sphericalEnd.radius-u-this._sphericalEnd.radius)/this._sphericalEnd.radius,v=Mt.copy(this._targetEnd).add(x.multiplyScalar(this._dollyControlCoord.x*_*p.aspect)).add(w.multiplyScalar(this._dollyControlCoord.y*_)),y=de.copy(this._targetEnd).lerp(v,L),A=this._lastDollyDirection===bt.IN&&this._spherical.radius<=this.minDistance,S=this._lastDollyDirection===bt.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(A||S)){this._sphericalEnd.radius-=u,this._spherical.radius-=u;const P=ye.copy(g).multiplyScalar(-u);y.add(P)}this._boundary.clampPoint(y,y);const b=ye.subVectors(y,this._targetEnd);this._targetEnd.copy(y),this._target.add(b),this._changedDolly-=u,xe(this._changedDolly)&&(this._changedDolly=0)}else if(rt(this._camera)&&this._changedZoom!==0){const u=this._zoom-this._lastZoom,p=this._camera,g=de.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(p.near+p.far)/(p.near-p.far)).unproject(p),x=ye.set(0,0,-1).applyQuaternion(p.quaternion),w=Mt.copy(g).add(x.multiplyScalar(-g.dot(p.up))),M=-(this._zoom-u-this._zoom)/this._zoom,L=this._getCameraDirection(Ut),v=this._targetEnd.dot(L),y=de.copy(this._targetEnd).lerp(w,M),A=y.dot(L),S=L.multiplyScalar(A-v);y.sub(S),this._boundary.clampPoint(y,y);const b=ye.subVectors(y,this._targetEnd);this._targetEnd.copy(y),this._target.add(b),this._changedZoom-=u,xe(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0);const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!xe(this._focalOffset.x)||!xe(this._focalOffset.y)||!xe(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Ye.setFromMatrixColumn(this._camera.matrix,0),We.setFromMatrixColumn(this._camera.matrix,1),mt.setFromMatrixColumn(this._camera.matrix,2),Ye.multiplyScalar(this._focalOffset.x),We.multiplyScalar(-this._focalOffset.y),mt.multiplyScalar(this._focalOffset.z),de.copy(Ye).add(We).add(mt),this._camera.position.add(de)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),de.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const d=this._needsUpdate;return d&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):d?(this.dispatchEvent({type:"update"}),xe(t,this.restThreshold)&&xe(n,this.restThreshold)&&xe(s,this.restThreshold)&&xe(i.x,this.restThreshold)&&xe(i.y,this.restThreshold)&&xe(i.z,this.restThreshold)&&xe(o.x,this.restThreshold)&&xe(o.y,this.restThreshold)&&xe(o.z,this.restThreshold)&&xe(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!d&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=d,this._needsUpdate=!1,d}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Ft(this.maxDistance),minZoom:this.minZoom,maxZoom:Ft(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Ft(this.maxPolarAngle),minAzimuthAngle:Ft(this.minAzimuthAngle),maxAzimuthAngle:Ft(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:de.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=Bt(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=Bt(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=Bt(n.maxPolarAngle),this.minAzimuthAngle=Bt(n.minAzimuthAngle),this.maxAzimuthAngle=Bt(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),Ne.setFromVector3(de.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Ne.theta,Ne.phi,t),this.dollyTo(Ne.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",Aa),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 s=t.lengthSq();if(s===0)return e;const i=ye.copy(t).add(e),r=this._boundary.clampPoint(i,Mt).sub(i),l=r.lengthSq();if(l===0)return e.add(t);if(l===s)return e;if(n===0)return e.add(t).add(r);{const f=1+n*l/t.dot(r);return e.add(ye.copy(t).multiplyScalar(f)).add(r.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(pt(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*kt,s=Math.tan(n*.5)*t,i=s*e.aspect;this._nearPlaneCorners[0].set(-i,-s,0),this._nearPlaneCorners[1].set(i,-s,0),this._nearPlaneCorners[2].set(i,s,0),this._nearPlaneCorners[3].set(-i,s,0)}else if(rt(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,s=e.right*t,i=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(n,i,0),this._nearPlaneCorners[1].set(s,i,0),this._nearPlaneCorners[2].set(s,o,0),this._nearPlaneCorners[3].set(n,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Bn(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(Ut);Nn.lookAt($s,n,this._camera.up);for(let s=0;s<4;s++){const i=ye.copy(this._nearPlaneCorners[s]);i.applyMatrix4(Nn);const o=Mt.addVectors(this._target,i);tn.set(o,n),tn.far=this._spherical.radius+1;const r=tn.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<e&&(e=r[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 re.Sphere){const n=t,s=n.center;St.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&St.expandByObject(o)}),St.getCenter(s);let i=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const r=o,l=r.geometry.clone();l.applyMatrix4(r.matrixWorld);const d=l.attributes.position;for(let u=0,p=d.count;u<p;u++)de.fromBufferAttribute(d,u),i=Math.max(i,s.distanceToSquared(de))}),n.radius=Math.sqrt(i),n}}const Pa=["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"],Ca=h.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},distance:{default:()=>ne.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:1/0},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:1/0},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:1/0},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:{},touches:{}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,{makeDefault:s,minPolarAngle:i,maxPolarAngle:o,minAzimuthAngle:r,maxAzimuthAngle:l,distance:f,minDistance:d,maxDistance:u,infinityDolly:p,minZoom:g,maxZoom:x,smoothTime:w,draggingSmoothTime:_,maxSpeed:M,azimuthRotateSpeed:L,polarRotateSpeed:v,dollySpeed:y,dollyDragInverted:A,truckSpeed:S,dollyToCursor:b,dragToOffset:P,verticalDragToForward:O,boundaryFriction:k,restThreshold:V,colliderMeshes:R}=h.toRefs(n),X={Box3:c.Box3,MathUtils:{clamp:c.MathUtils.clamp},Matrix4:c.Matrix4,Quaternion:c.Quaternion,Raycaster:c.Raycaster,Sphere:c.Sphere,Spherical:c.Spherical,Vector2:c.Vector2,Vector3:c.Vector3,Vector4:c.Vector4};zt.install({THREE:X});const{camera:K,renderer:H,extend:he,controls:J}=ne.useTresContext(),G=h.ref(null);he({CameraControls:zt}),h.watchEffect(()=>{oe(),G.value&&s.value?J.value=G.value:J.value=null});function oe(){Ae(G.value,"update",()=>t("change",G.value)),Ae(G.value,"controlend",()=>t("end",G.value)),Ae(G.value,"controlstart",()=>t("start",G.value))}const{onLoop:se}=ne.useRenderLoop();return se(({delta:ce})=>{var U,T;(U=G.value)!=null&&U.enabled&&((T=G.value)==null||T.update(ce))}),h.onUnmounted(()=>{G.value&&G.value.disconnect()}),e({value:G}),(ce,U)=>(ce.camera||h.unref(K))&&(ce.domElement||h.unref(H))?(h.openBlock(),h.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:G,"min-polar-angle":h.unref(i),"max-polar-angle":h.unref(o),"min-azimuth-angle":h.unref(r),"max-azimuth-angle":h.unref(l),distance:h.unref(f),"min-distance":h.unref(d),"max-distance":h.unref(u),"infinity-dolly":h.unref(p),"min-zoom":h.unref(g),"max-zoom":h.unref(x),"smooth-time":h.unref(w),"dragging-smooth-time":h.unref(_),"max-speed":h.unref(M),"azimuth-rotate-speed":h.unref(L),"polar-rotate-speed":h.unref(v),"dolly-speed":h.unref(y),"dolly-drag-inverted":h.unref(A),"truck-speed":h.unref(S),"dolly-to-cursor":h.unref(b),"drag-to-offset":h.unref(P),"vertical-drag-to-forward":h.unref(O),"boundary-friction":h.unref(k),"rest-threshold":h.unref(V),"collider-meshes":h.unref(R),args:[ce.camera||h.unref(K),ce.domElement||h.unref(H).domElement]},null,8,Pa)):h.createCommentVNode("",!0)}});class La extends c.MeshStandardMaterial{constructor(t={}){super(t);Me(this,"_time");Me(this,"_factor");this.setValues(t),this._time={value:0},this._factor={value:1}}onBeforeCompile(t){t.uniforms||(t.uniforms={}),t.uniforms.time=this._time,t.uniforms.factor=this._factor,t.vertexShader=`
190
190
  uniform float time;
191
191
  uniform float factor;
192
192
  ${t.vertexShader}
@@ -195,9 +195,396 @@
195
195
  float s = sin( theta );
196
196
  mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );
197
197
  vec3 transformed = vec3( position ) * m;
198
- vNormal = vNormal * m;`)}get time(){return this._time.value}set time(t){this._time.value=t}get factor(){return this._factor.value}set factor(t){this._factor.value=t}}const Br=["factor"],Ur=u.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(l){const e=l,t=u.shallowRef(),{extend:s}=ue.useTresContext();s({MeshWobbleMaterial:Fr});const{onLoop:n}=ue.useRenderLoop();return n(({elapsed:i})=>{t.value&&(t.value.time=i*(e==null?void 0:e.speed))}),(i,o)=>(u.openBlock(),u.createElementBlock("TresMeshWobbleMaterial",u.mergeProps({ref_key:"materialRef",ref:t,factor:i.factor},i.$attrs),null,16,Br))}});function at(l,e,t){return Math.max(e,Math.min(t,l))}function Vr(l,e){return(l%e+e)%e}function ws(l,e,t){return(1-t)*l+t*e}class vs{constructor(e=0,t=0){vs.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(at(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const s=Math.cos(t),n=Math.sin(t),i=this.x-e.x,o=this.y-e.y;return this.x=i*s-o*n+e.x,this.y=i*n+o*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}const Xe="srgb",bs="srgb-linear",On="display-p3";class Ct{constructor(e,t,s,n,i,o,r,a,h){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,s,n,i,o,r,a,h)}set(e,t,s,n,i,o,r,a,h){const f=this.elements;return f[0]=e,f[1]=n,f[2]=r,f[3]=t,f[4]=i,f[5]=a,f[6]=s,f[7]=o,f[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,n=t.elements,i=this.elements,o=s[0],r=s[3],a=s[6],h=s[1],f=s[4],p=s[7],m=s[2],g=s[5],w=s[8],x=n[0],_=n[3],S=n[6],C=n[1],v=n[4],y=n[7],M=n[2],P=n[5],A=n[8];return i[0]=o*x+r*C+a*M,i[3]=o*_+r*v+a*P,i[6]=o*S+r*y+a*A,i[1]=h*x+f*C+p*M,i[4]=h*_+f*v+p*P,i[7]=h*S+f*y+p*A,i[2]=m*x+g*C+w*M,i[5]=m*_+g*v+w*P,i[8]=m*S+g*y+w*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],n=e[2],i=e[3],o=e[4],r=e[5],a=e[6],h=e[7],f=e[8];return t*o*f-t*r*h-s*i*f+s*r*a+n*i*h-n*o*a}invert(){const e=this.elements,t=e[0],s=e[1],n=e[2],i=e[3],o=e[4],r=e[5],a=e[6],h=e[7],f=e[8],p=f*o-r*h,m=r*a-f*i,g=h*i-o*a,w=t*p+s*m+n*g;if(w===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/w;return e[0]=p*x,e[1]=(n*h-f*s)*x,e[2]=(r*s-n*o)*x,e[3]=m*x,e[4]=(f*t-n*a)*x,e[5]=(n*i-r*t)*x,e[6]=g*x,e[7]=(s*a-h*t)*x,e[8]=(o*t-s*i)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,s,n,i,o,r){const a=Math.cos(i),h=Math.sin(i);return this.set(s*a,s*h,-s*(a*o+h*r)+o+e,-n*h,n*a,-n*(-h*o+a*r)+r+t,0,0,1),this}scale(e,t){return this.premultiply(As.makeScale(e,t)),this}rotate(e){return this.premultiply(As.makeRotation(-e)),this}translate(e,t){return this.premultiply(As.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let n=0;n<9;n++)if(t[n]!==s[n])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const As=new Ct;function Ms(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}function Ss(l){return l<.0031308?l*12.92:1.055*Math.pow(l,.41666)-.055}const Nr=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),zr=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function Rr(l){return l.convertSRGBToLinear().applyMatrix3(zr)}function Gr(l){return l.applyMatrix3(Nr).convertLinearToSRGB()}const Er={[bs]:l=>l,[Xe]:l=>l.convertSRGBToLinear(),[On]:Rr},jr={[bs]:l=>l,[Xe]:l=>l.convertLinearToSRGB(),[On]:Gr},ze={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(l){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!l},get workingColorSpace(){return bs},set workingColorSpace(l){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(l,e,t){if(this.enabled===!1||e===t||!e||!t)return l;const s=Er[e],n=jr[t];if(s===void 0||n===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);return n(s(l))},fromWorkingColorSpace:function(l,e){return this.convert(l,this.workingColorSpace,e)},toWorkingColorSpace:function(l,e){return this.convert(l,e,this.workingColorSpace)}},In={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Re={h:0,s:0,l:0},Rt={h:0,s:0,l:0};function Ps(l,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?l+(e-l)*6*t:t<1/2?e:t<2/3?l+(e-l)*6*(2/3-t):l}class Gt{constructor(e,t,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,s)}set(e,t,s){if(t===void 0&&s===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Xe){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ze.toWorkingColorSpace(this,t),this}setRGB(e,t,s,n=ze.workingColorSpace){return this.r=e,this.g=t,this.b=s,ze.toWorkingColorSpace(this,n),this}setHSL(e,t,s,n=ze.workingColorSpace){if(e=Vr(e,1),t=at(t,0,1),s=at(s,0,1),t===0)this.r=this.g=this.b=s;else{const i=s<=.5?s*(1+t):s+t-s*t,o=2*s-i;this.r=Ps(o,i,e+1/3),this.g=Ps(o,i,e),this.b=Ps(o,i,e-1/3)}return ze.toWorkingColorSpace(this,n),this}setStyle(e,t=Xe){function s(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const o=n[1],r=n[2];switch(o){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return s(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return s(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return s(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const i=n[1],o=i.length;if(o===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Xe){const s=In[e.toLowerCase()];return s!==void 0?this.setHex(s,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ms(e.r),this.g=Ms(e.g),this.b=Ms(e.b),this}copyLinearToSRGB(e){return this.r=Ss(e.r),this.g=Ss(e.g),this.b=Ss(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Xe){return ze.fromWorkingColorSpace(Ce.copy(this),e),Math.round(at(Ce.r*255,0,255))*65536+Math.round(at(Ce.g*255,0,255))*256+Math.round(at(Ce.b*255,0,255))}getHexString(e=Xe){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ze.workingColorSpace){ze.fromWorkingColorSpace(Ce.copy(this),t);const s=Ce.r,n=Ce.g,i=Ce.b,o=Math.max(s,n,i),r=Math.min(s,n,i);let a,h;const f=(r+o)/2;if(r===o)a=0,h=0;else{const p=o-r;switch(h=f<=.5?p/(o+r):p/(2-o-r),o){case s:a=(n-i)/p+(n<i?6:0);break;case n:a=(i-s)/p+2;break;case i:a=(s-n)/p+4;break}a/=6}return e.h=a,e.s=h,e.l=f,e}getRGB(e,t=ze.workingColorSpace){return ze.fromWorkingColorSpace(Ce.copy(this),t),e.r=Ce.r,e.g=Ce.g,e.b=Ce.b,e}getStyle(e=Xe){ze.fromWorkingColorSpace(Ce.copy(this),e);const t=Ce.r,s=Ce.g,n=Ce.b;return e!==Xe?`color(${e} ${t.toFixed(3)} ${s.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(s*255)},${Math.round(n*255)})`}offsetHSL(e,t,s){return this.getHSL(Re),Re.h+=e,Re.s+=t,Re.l+=s,this.setHSL(Re.h,Re.s,Re.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,s){return this.r=e.r+(t.r-e.r)*s,this.g=e.g+(t.g-e.g)*s,this.b=e.b+(t.b-e.b)*s,this}lerpHSL(e,t){this.getHSL(Re),e.getHSL(Rt);const s=ws(Re.h,Rt.h,t),n=ws(Re.s,Rt.s,t),i=ws(Re.l,Rt.l,t);return this.setHSL(s,n,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,s=this.g,n=this.b,i=e.elements;return this.r=i[0]*t+i[3]*s+i[6]*n,this.g=i[1]*t+i[4]*s+i[7]*n,this.b=i[2]*t+i[5]*s+i[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ce=new Gt;Gt.NAMES=In;class Xr extends c.MeshStandardMaterial{constructor(t={}){super();Ae(this,"isMeshPhysicalMaterial");Ae(this,"clearcoatMap");Ae(this,"clearcoatRoughness");Ae(this,"clearcoatRoughnessMap");Ae(this,"clearcoatNormalScale");Ae(this,"clearcoatNormalMap");Ae(this,"ior");Ae(this,"transmissionMap");Ae(this,"thickness");Ae(this,"thicknessMap");Ae(this,"attenuationDistance");Ae(this,"attenuationColor");Ae(this,"specularIntensity");Ae(this,"specularIntensityMap");Ae(this,"specularColor");Ae(this,"specularColorMap");Ae(this,"_clearcoat");Ae(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new vs(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return at(2.5*(this.ior-1)/(this.ior+1),0,1)},set(s){this.ior=(1+.4*s)/(1-.4*s)}}),this.roughness=0,this.transmissionMap=null,this.thickness=.5,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Gt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Gt(1,1,1),this.specularColorMap=null,this._clearcoat=.5,this._transmission=1,this.setValues(t)}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}const Yr=Xr,Zr=u.defineComponent({__name:"index",setup(l,{expose:e}){const t=u.shallowRef(),{extend:s}=ue.useTresContext();return s({MeshGlassMaterial:Yr}),e({MeshGlassMaterialClass:t}),(n,i)=>(u.openBlock(),u.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}}),Wr=["args"],Qr=["color"],Kr=u.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"boxRef",ref:i},o.$attrs),[u.createElementVNode("TresBoxGeometry",{args:u.unref(s)},null,8,Wr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Qr)])],16))}}),qr=["args"],Jr=["color"],Hr=u.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"circleRef",ref:i},o.$attrs),[u.createElementVNode("TresCircleGeometry",{args:u.unref(s)},null,8,qr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Jr)])],16))}}),$r=["args"],ea=["color"],ta=u.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"coneRef",ref:i},o.$attrs),[u.createElementVNode("TresConeGeometry",{args:u.unref(s)},null,8,$r),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,ea)])],16))}}),sa=["args"],na=["color"],ia=u.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"dodecahedronRef",ref:i},o.$attrs),[u.createElementVNode("TresDodecahedronGeometry",{args:u.unref(s)},null,8,sa),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,na)])],16))}}),oa=["args"],ra=["color"],aa=u.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"icosahedronRef",ref:i},o.$attrs),[u.createElementVNode("TresIcosahedronGeometry",{args:u.unref(s)},null,8,oa),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,ra)])],16))}}),la=["args"],ca=["color"],ha=u.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"octahedronRef",ref:i},o.$attrs),[u.createElementVNode("TresOctahedronGeometry",{args:u.unref(s)},null,8,la),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,ca)])],16))}}),ua=["rotation"],pa=["args"],fa=["color"],da=u.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"planeRef",ref:i,rotation:[-Math.PI/2,0,0]},o.$attrs),[u.createElementVNode("TresPlaneGeometry",{args:u.unref(s)},null,8,pa),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,fa)])],16,ua))}}),ma=["args"],ga=["color"],ya=u.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"ringRef",ref:i},o.$attrs),[u.createElementVNode("TresRingGeometry",{args:u.unref(s)},null,8,ma),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,ga)])],16))}}),_a=["args"],xa=["color"],wa=u.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"sphereRef",ref:i},o.$attrs),[u.createElementVNode("TresSphereGeometry",{args:u.unref(s)},null,8,_a),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,xa)])],16))}}),va=["rotation"],ba=["args"],Aa=["color"],Ma=u.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tetrahedronRef",ref:i,rotation:[-Math.PI/2,0,0]},o.$attrs),[u.createElementVNode("TresTetrahedronGeometry",{args:u.unref(s)},null,8,ba),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Aa)])],16,va))}}),Sa=["args"],Pa=["color"],Ta=u.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusRef",ref:i},o.$attrs),[u.createElementVNode("TresTorusGeometry",{args:u.unref(s)},null,8,Sa),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Pa)])],16))}}),Ca=["args"],La=["color"],Oa=u.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusKnotRef",ref:i},o.$attrs),[u.createElementVNode("TresTorusKnotGeometry",{args:u.unref(s)},null,8,Ca),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,La)])],16))}}),Ia=["args"],Da=["color"],ka=u.defineComponent({__name:"Tube",props:{args:{default:()=>[new c.QuadraticBezierCurve3(new c.Vector3(-1,0,0),new c.Vector3(0,1,0),new c.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tubeRef",ref:i},o.$attrs),[u.createElementVNode("TresTubeGeometry",{args:u.unref(s)},null,8,Ia),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Da)])],16))}}),Fa=u.defineComponent({name:"Environment",props:["background","blur","files","encoding","path","preset"],async setup(l,{expose:e}){let t=null;return e({getTexture:()=>t}),t=await gn(l),()=>{}}}),Ba=["receive-shadow","rotation"],Ua=["args"],Va=u.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Na=u.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(l){const e=l,t=r=>r===0?0:2**(10*r-10),{floor:s,segments:n,receiveShadow:i}=u.toRefs(e),o=u.ref(null);return u.watch(()=>[n.value,s.value,o.value],([r,a,h])=>{if(!h||r===null)return;let f=0;const p=r/r/2,m=h.attributes.position;for(let g=0;g<r+1;g++)for(let w=0;w<r+1;w++)m.setXYZ(f++,g/r-p+(g===0?-a:0),w/r-p,t(g/r));m.needsUpdate=!0,h.computeVertexNormals()}),(r,a)=>(u.openBlock(),u.createElementBlock("TresGroup",u.normalizeProps(u.guardReactiveProps(r.$attrs)),[u.createElementVNode("TresMesh",{"receive-shadow":u.unref(i),rotation:[-Math.PI/2,0,Math.PI/2]},[u.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:o,args:[1,1,u.unref(n),u.unref(n)]},null,8,Ua),u.renderSlot(r.$slots,"default",{},()=>[Va])],8,Ba)],16))}}),za=["geometry"],Ra=["map","opacity","depth-write"],Ga=["args"],Ea=["rotation","args"],ja=u.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(l,{expose:e}){const t=l,s=u.shallowRef(),n=u.shallowRef();e(s);let i,o,r,a,h;const{renderer:f,scene:p}=ue.useTresContext(),m=u.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),g=u.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));u.watchEffect(()=>{i&&i.dispose(),o&&o.dispose(),r&&r.dispose(),a&&a.geometry.dispose(),i=new c.WebGLRenderTarget(t.resolution,t.resolution),o=new c.WebGLRenderTarget(t.resolution,t.resolution),o.texture.generateMipmaps=i.texture.generateMipmaps=!1,n.value=new c.OrthographicCamera(-m.value/2,m.value/2,g.value/2,-g.value/2,0,t.far),r=new c.PlaneGeometry(m.value,g.value).rotateX(Math.PI/2),a=new c.Mesh(r),a.visible=!1}),u.watchEffect(()=>{t.color&&(h&&h.dispose(),h=new c.MeshDepthMaterial,h.depthTest=h.depthWrite=!1,h.onBeforeCompile=M=>{M.uniforms={...M.uniforms,ucolor:{value:t.color?new c.Color(t.color):new c.Color}},M.fragmentShader=M.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
198
+ vNormal = vNormal * m;`)}get time(){return this._time.value}set time(t){this._time.value=t}get factor(){return this._factor.value}set factor(t){this._factor.value=t}}const Ta=["factor"],Oa=h.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(a){const e=a,t=h.shallowRef(),{extend:n}=ne.useTresContext();n({MeshWobbleMaterial:La});const{onLoop:s}=ne.useRenderLoop();return s(({elapsed:i})=>{t.value&&(t.value.time=i*(e==null?void 0:e.speed))}),(i,o)=>(h.openBlock(),h.createElementBlock("TresMeshWobbleMaterial",h.mergeProps({ref_key:"materialRef",ref:t,factor:i.factor},i.$attrs),null,16,Ta))}});function gt(a,e,t){return Math.max(e,Math.min(t,a))}function Da(a,e){return(a%e+e)%e}function Gn(a,e,t){return(1-t)*a+t*e}class Rn{constructor(e=0,t=0){Rn.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(gt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),i=this.x-e.x,o=this.y-e.y;return this.x=i*n-o*s+e.x,this.y=i*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}const Ia="",at="srgb",jn="srgb-linear",ka="display-p3",ii="display-p3-linear",En="linear",oi="srgb",ri="rec709",ai="p3";class Nt{constructor(e,t,n,s,i,o,r,l,f){Nt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,i,o,r,l,f)}set(e,t,n,s,i,o,r,l,f){const d=this.elements;return d[0]=e,d[1]=s,d[2]=r,d[3]=t,d[4]=i,d[5]=l,d[6]=n,d[7]=o,d[8]=f,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,i=this.elements,o=n[0],r=n[3],l=n[6],f=n[1],d=n[4],u=n[7],p=n[2],g=n[5],x=n[8],w=s[0],_=s[3],M=s[6],L=s[1],v=s[4],y=s[7],A=s[2],S=s[5],b=s[8];return i[0]=o*w+r*L+l*A,i[3]=o*_+r*v+l*S,i[6]=o*M+r*y+l*b,i[1]=f*w+d*L+u*A,i[4]=f*_+d*v+u*S,i[7]=f*M+d*y+u*b,i[2]=p*w+g*L+x*A,i[5]=p*_+g*v+x*S,i[8]=p*M+g*y+x*b,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],i=e[3],o=e[4],r=e[5],l=e[6],f=e[7],d=e[8];return t*o*d-t*r*f-n*i*d+n*r*l+s*i*f-s*o*l}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],i=e[3],o=e[4],r=e[5],l=e[6],f=e[7],d=e[8],u=d*o-r*f,p=r*l-d*i,g=f*i-o*l,x=t*u+n*p+s*g;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/x;return e[0]=u*w,e[1]=(s*f-d*n)*w,e[2]=(r*n-s*o)*w,e[3]=p*w,e[4]=(d*t-s*l)*w,e[5]=(s*i-r*t)*w,e[6]=g*w,e[7]=(n*l-f*t)*w,e[8]=(o*t-n*i)*w,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,i,o,r){const l=Math.cos(i),f=Math.sin(i);return this.set(n*l,n*f,-n*(l*o+f*r)+o+e,-s*f,s*l,-s*(-f*o+l*r)+r+t,0,0,1),this}scale(e,t){return this.premultiply(Xn.makeScale(e,t)),this}rotate(e){return this.premultiply(Xn.makeRotation(-e)),this}translate(e,t){return this.premultiply(Xn.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Xn=new Nt,li=new Nt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),ci=new Nt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),nn={[jn]:{transfer:En,primaries:ri,toReference:a=>a,fromReference:a=>a},[at]:{transfer:oi,primaries:ri,toReference:a=>a.convertSRGBToLinear(),fromReference:a=>a.convertLinearToSRGB()},[ii]:{transfer:En,primaries:ai,toReference:a=>a.applyMatrix3(ci),fromReference:a=>a.applyMatrix3(li)},[ka]:{transfer:oi,primaries:ai,toReference:a=>a.convertSRGBToLinear().applyMatrix3(ci),fromReference:a=>a.applyMatrix3(li).convertLinearToSRGB()}},Fa=new Set([jn,ii]),Ee={enabled:!0,_workingColorSpace:jn,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(a){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!a},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(a){if(!Fa.has(a))throw new Error(`Unsupported working color space, "${a}".`);this._workingColorSpace=a},convert:function(a,e,t){if(this.enabled===!1||e===t||!e||!t)return a;const n=nn[e].toReference,s=nn[t].fromReference;return s(n(a))},fromWorkingColorSpace:function(a,e){return this.convert(a,this._workingColorSpace,e)},toWorkingColorSpace:function(a,e){return this.convert(a,e,this._workingColorSpace)},getPrimaries:function(a){return nn[a].primaries},getTransfer:function(a){return a===Ia?En:nn[a].transfer}};function Yn(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function Wn(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}const hi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},lt={h:0,s:0,l:0},sn={h:0,s:0,l:0};function Zn(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?a+(e-a)*6*t:t<1/2?e:t<2/3?a+(e-a)*6*(2/3-t):a}class on{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=at){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ee.toWorkingColorSpace(this,t),this}setRGB(e,t,n,s=Ee.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ee.toWorkingColorSpace(this,s),this}setHSL(e,t,n,s=Ee.workingColorSpace){if(e=Da(e,1),t=gt(t,0,1),n=gt(n,0,1),t===0)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,o=2*n-i;this.r=Zn(o,i,e+1/3),this.g=Zn(o,i,e),this.b=Zn(o,i,e-1/3)}return Ee.toWorkingColorSpace(this,s),this}setStyle(e,t=at){function n(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const o=s[1],r=s[2];switch(o){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const i=s[1],o=i.length;if(o===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=at){const n=hi[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Yn(e.r),this.g=Yn(e.g),this.b=Yn(e.b),this}copyLinearToSRGB(e){return this.r=Wn(e.r),this.g=Wn(e.g),this.b=Wn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=at){return Ee.fromWorkingColorSpace(Ie.copy(this),e),Math.round(gt(Ie.r*255,0,255))*65536+Math.round(gt(Ie.g*255,0,255))*256+Math.round(gt(Ie.b*255,0,255))}getHexString(e=at){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ee.workingColorSpace){Ee.fromWorkingColorSpace(Ie.copy(this),t);const n=Ie.r,s=Ie.g,i=Ie.b,o=Math.max(n,s,i),r=Math.min(n,s,i);let l,f;const d=(r+o)/2;if(r===o)l=0,f=0;else{const u=o-r;switch(f=d<=.5?u/(o+r):u/(2-o-r),o){case n:l=(s-i)/u+(s<i?6:0);break;case s:l=(i-n)/u+2;break;case i:l=(n-s)/u+4;break}l/=6}return e.h=l,e.s=f,e.l=d,e}getRGB(e,t=Ee.workingColorSpace){return Ee.fromWorkingColorSpace(Ie.copy(this),t),e.r=Ie.r,e.g=Ie.g,e.b=Ie.b,e}getStyle(e=at){Ee.fromWorkingColorSpace(Ie.copy(this),e);const t=Ie.r,n=Ie.g,s=Ie.b;return e!==at?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(lt),this.setHSL(lt.h+e,lt.s+t,lt.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(lt),e.getHSL(sn);const n=Gn(lt.h,sn.h,t),s=Gn(lt.s,sn.s,t),i=Gn(lt.l,sn.l,t);return this.setHSL(n,s,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,s=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*s,this.g=i[1]*t+i[4]*n+i[7]*s,this.b=i[2]*t+i[5]*n+i[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ie=new on;on.NAMES=hi;class Ba extends c.MeshStandardMaterial{constructor(t={}){super();Me(this,"isMeshPhysicalMaterial");Me(this,"clearcoatMap");Me(this,"clearcoatRoughness");Me(this,"clearcoatRoughnessMap");Me(this,"clearcoatNormalScale");Me(this,"clearcoatNormalMap");Me(this,"ior");Me(this,"transmissionMap");Me(this,"thickness");Me(this,"thicknessMap");Me(this,"attenuationDistance");Me(this,"attenuationColor");Me(this,"specularIntensity");Me(this,"specularIntensityMap");Me(this,"specularColor");Me(this,"specularColorMap");Me(this,"_clearcoat");Me(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Rn(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set(n){this.ior=(1+.4*n)/(1-.4*n)}}),this.roughness=0,this.transmissionMap=null,this.thickness=.5,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new on(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new on(1,1,1),this.specularColorMap=null,this._clearcoat=.5,this._transmission=1,this.setValues(t)}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}const Ua=Ba,Va=h.defineComponent({__name:"index",setup(a,{expose:e}){const t=h.shallowRef(),{extend:n}=ne.useTresContext();return n({MeshGlassMaterial:Ua}),e({MeshGlassMaterialClass:t}),(s,i)=>(h.openBlock(),h.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}}),za=["args"],Na=["color"],Ga=h.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"boxRef",ref:i},o.$attrs),[h.createElementVNode("TresBoxGeometry",{args:h.unref(n)},null,8,za),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Na)])],16))}}),ui=new c.Box3,rn=new c.Vector3;class di extends c.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 c.Float32BufferAttribute(e,3)),this.setAttribute("uv",new c.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 c.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new c.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new c.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new c.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new c.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new c.InterleavedBufferAttribute(n,3,3)),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 c.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 c.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),ui.setFromBufferAttribute(t),this.boundingBox.union(ui))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new c.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 s=0;for(let i=0,o=e.count;i<o;i++)rn.fromBufferAttribute(e,i),s=Math.max(s,n.distanceToSquared(rn)),rn.fromBufferAttribute(t,i),s=Math.max(s,n.distanceToSquared(rn));this.boundingSphere.radius=Math.sqrt(s),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)}}c.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new c.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},c.ShaderLib.line={uniforms:c.UniformsUtils.merge([c.UniformsLib.common,c.UniformsLib.fog,c.UniformsLib.line]),vertexShader:`
199
+ #include <common>
200
+ #include <color_pars_vertex>
201
+ #include <fog_pars_vertex>
202
+ #include <logdepthbuf_pars_vertex>
203
+ #include <clipping_planes_pars_vertex>
204
+
205
+ uniform float linewidth;
206
+ uniform vec2 resolution;
207
+
208
+ attribute vec3 instanceStart;
209
+ attribute vec3 instanceEnd;
210
+
211
+ attribute vec3 instanceColorStart;
212
+ attribute vec3 instanceColorEnd;
213
+
214
+ #ifdef WORLD_UNITS
215
+
216
+ varying vec4 worldPos;
217
+ varying vec3 worldStart;
218
+ varying vec3 worldEnd;
219
+
220
+ #ifdef USE_DASH
221
+
222
+ varying vec2 vUv;
223
+
224
+ #endif
225
+
226
+ #else
227
+
228
+ varying vec2 vUv;
229
+
230
+ #endif
231
+
232
+ #ifdef USE_DASH
233
+
234
+ uniform float dashScale;
235
+ attribute float instanceDistanceStart;
236
+ attribute float instanceDistanceEnd;
237
+ varying float vLineDistance;
238
+
239
+ #endif
240
+
241
+ void trimSegment( const in vec4 start, inout vec4 end ) {
242
+
243
+ // trim end segment so it terminates between the camera plane and the near plane
244
+
245
+ // conservative estimate of the near plane
246
+ float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
247
+ float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
248
+ float nearEstimate = - 0.5 * b / a;
249
+
250
+ float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
251
+
252
+ end.xyz = mix( start.xyz, end.xyz, alpha );
253
+
254
+ }
255
+
256
+ void main() {
257
+
258
+ #ifdef USE_COLOR
259
+
260
+ vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
261
+
262
+ #endif
263
+
264
+ #ifdef USE_DASH
265
+
266
+ vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
267
+ vUv = uv;
268
+
269
+ #endif
270
+
271
+ float aspect = resolution.x / resolution.y;
272
+
273
+ // camera space
274
+ vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
275
+ vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
276
+
277
+ #ifdef WORLD_UNITS
278
+
279
+ worldStart = start.xyz;
280
+ worldEnd = end.xyz;
281
+
282
+ #else
283
+
284
+ vUv = uv;
285
+
286
+ #endif
287
+
288
+ // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
289
+ // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
290
+ // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
291
+ // perhaps there is a more elegant solution -- WestLangley
292
+
293
+ bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
294
+
295
+ if ( perspective ) {
296
+
297
+ if ( start.z < 0.0 && end.z >= 0.0 ) {
298
+
299
+ trimSegment( start, end );
300
+
301
+ } else if ( end.z < 0.0 && start.z >= 0.0 ) {
302
+
303
+ trimSegment( end, start );
304
+
305
+ }
306
+
307
+ }
308
+
309
+ // clip space
310
+ vec4 clipStart = projectionMatrix * start;
311
+ vec4 clipEnd = projectionMatrix * end;
312
+
313
+ // ndc space
314
+ vec3 ndcStart = clipStart.xyz / clipStart.w;
315
+ vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
316
+
317
+ // direction
318
+ vec2 dir = ndcEnd.xy - ndcStart.xy;
319
+
320
+ // account for clip-space aspect ratio
321
+ dir.x *= aspect;
322
+ dir = normalize( dir );
323
+
324
+ #ifdef WORLD_UNITS
325
+
326
+ // get the offset direction as perpendicular to the view vector
327
+ vec3 worldDir = normalize( end.xyz - start.xyz );
328
+ vec3 offset;
329
+ if ( position.y < 0.5 ) {
330
+
331
+ offset = normalize( cross( start.xyz, worldDir ) );
332
+
333
+ } else {
334
+
335
+ offset = normalize( cross( end.xyz, worldDir ) );
336
+
337
+ }
338
+
339
+ // sign flip
340
+ if ( position.x < 0.0 ) offset *= - 1.0;
341
+
342
+ float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
343
+
344
+ // don't extend the line if we're rendering dashes because we
345
+ // won't be rendering the endcaps
346
+ #ifndef USE_DASH
347
+
348
+ // extend the line bounds to encompass endcaps
349
+ start.xyz += - worldDir * linewidth * 0.5;
350
+ end.xyz += worldDir * linewidth * 0.5;
351
+
352
+ // shift the position of the quad so it hugs the forward edge of the line
353
+ offset.xy -= dir * forwardOffset;
354
+ offset.z += 0.5;
355
+
356
+ #endif
357
+
358
+ // endcaps
359
+ if ( position.y > 1.0 || position.y < 0.0 ) {
360
+
361
+ offset.xy += dir * 2.0 * forwardOffset;
362
+
363
+ }
364
+
365
+ // adjust for linewidth
366
+ offset *= linewidth * 0.5;
367
+
368
+ // set the world position
369
+ worldPos = ( position.y < 0.5 ) ? start : end;
370
+ worldPos.xyz += offset;
371
+
372
+ // project the worldpos
373
+ vec4 clip = projectionMatrix * worldPos;
374
+
375
+ // shift the depth of the projected points so the line
376
+ // segments overlap neatly
377
+ vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
378
+ clip.z = clipPose.z * clip.w;
379
+
380
+ #else
381
+
382
+ vec2 offset = vec2( dir.y, - dir.x );
383
+ // undo aspect ratio adjustment
384
+ dir.x /= aspect;
385
+ offset.x /= aspect;
386
+
387
+ // sign flip
388
+ if ( position.x < 0.0 ) offset *= - 1.0;
389
+
390
+ // endcaps
391
+ if ( position.y < 0.0 ) {
392
+
393
+ offset += - dir;
394
+
395
+ } else if ( position.y > 1.0 ) {
396
+
397
+ offset += dir;
398
+
399
+ }
400
+
401
+ // adjust for linewidth
402
+ offset *= linewidth;
403
+
404
+ // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
405
+ offset /= resolution.y;
406
+
407
+ // select end
408
+ vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
409
+
410
+ // back to clip space
411
+ offset *= clip.w;
412
+
413
+ clip.xy += offset;
414
+
415
+ #endif
416
+
417
+ gl_Position = clip;
418
+
419
+ vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
420
+
421
+ #include <logdepthbuf_vertex>
422
+ #include <clipping_planes_vertex>
423
+ #include <fog_vertex>
424
+
425
+ }
426
+ `,fragmentShader:`
427
+ uniform vec3 diffuse;
428
+ uniform float opacity;
429
+ uniform float linewidth;
430
+
431
+ #ifdef USE_DASH
432
+
433
+ uniform float dashOffset;
434
+ uniform float dashSize;
435
+ uniform float gapSize;
436
+
437
+ #endif
438
+
439
+ varying float vLineDistance;
440
+
441
+ #ifdef WORLD_UNITS
442
+
443
+ varying vec4 worldPos;
444
+ varying vec3 worldStart;
445
+ varying vec3 worldEnd;
446
+
447
+ #ifdef USE_DASH
448
+
449
+ varying vec2 vUv;
450
+
451
+ #endif
452
+
453
+ #else
454
+
455
+ varying vec2 vUv;
456
+
457
+ #endif
458
+
459
+ #include <common>
460
+ #include <color_pars_fragment>
461
+ #include <fog_pars_fragment>
462
+ #include <logdepthbuf_pars_fragment>
463
+ #include <clipping_planes_pars_fragment>
464
+
465
+ vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
466
+
467
+ float mua;
468
+ float mub;
469
+
470
+ vec3 p13 = p1 - p3;
471
+ vec3 p43 = p4 - p3;
472
+
473
+ vec3 p21 = p2 - p1;
474
+
475
+ float d1343 = dot( p13, p43 );
476
+ float d4321 = dot( p43, p21 );
477
+ float d1321 = dot( p13, p21 );
478
+ float d4343 = dot( p43, p43 );
479
+ float d2121 = dot( p21, p21 );
480
+
481
+ float denom = d2121 * d4343 - d4321 * d4321;
482
+
483
+ float numer = d1343 * d4321 - d1321 * d4343;
484
+
485
+ mua = numer / denom;
486
+ mua = clamp( mua, 0.0, 1.0 );
487
+ mub = ( d1343 + d4321 * ( mua ) ) / d4343;
488
+ mub = clamp( mub, 0.0, 1.0 );
489
+
490
+ return vec2( mua, mub );
491
+
492
+ }
493
+
494
+ void main() {
495
+
496
+ #include <clipping_planes_fragment>
497
+
498
+ #ifdef USE_DASH
499
+
500
+ if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
501
+
502
+ if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
503
+
504
+ #endif
505
+
506
+ float alpha = opacity;
507
+
508
+ #ifdef WORLD_UNITS
509
+
510
+ // Find the closest points on the view ray and the line segment
511
+ vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
512
+ vec3 lineDir = worldEnd - worldStart;
513
+ vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
514
+
515
+ vec3 p1 = worldStart + lineDir * params.x;
516
+ vec3 p2 = rayEnd * params.y;
517
+ vec3 delta = p1 - p2;
518
+ float len = length( delta );
519
+ float norm = len / linewidth;
520
+
521
+ #ifndef USE_DASH
522
+
523
+ #ifdef USE_ALPHA_TO_COVERAGE
524
+
525
+ float dnorm = fwidth( norm );
526
+ alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
527
+
528
+ #else
529
+
530
+ if ( norm > 0.5 ) {
531
+
532
+ discard;
533
+
534
+ }
535
+
536
+ #endif
537
+
538
+ #endif
539
+
540
+ #else
541
+
542
+ #ifdef USE_ALPHA_TO_COVERAGE
543
+
544
+ // artifacts appear on some hardware if a derivative is taken within a conditional
545
+ float a = vUv.x;
546
+ float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
547
+ float len2 = a * a + b * b;
548
+ float dlen = fwidth( len2 );
549
+
550
+ if ( abs( vUv.y ) > 1.0 ) {
551
+
552
+ alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
553
+
554
+ }
555
+
556
+ #else
557
+
558
+ if ( abs( vUv.y ) > 1.0 ) {
559
+
560
+ float a = vUv.x;
561
+ float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
562
+ float len2 = a * a + b * b;
563
+
564
+ if ( len2 > 1.0 ) discard;
565
+
566
+ }
567
+
568
+ #endif
569
+
570
+ #endif
571
+
572
+ vec4 diffuseColor = vec4( diffuse, alpha );
573
+
574
+ #include <logdepthbuf_fragment>
575
+ #include <color_fragment>
576
+
577
+ gl_FragColor = vec4( diffuseColor.rgb, alpha );
578
+
579
+ #include <tonemapping_fragment>
580
+ #include <colorspace_fragment>
581
+ #include <fog_fragment>
582
+ #include <premultiplied_alpha_fragment>
583
+
584
+ }
585
+ `};class Qn extends c.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const fi=new c.Vector3,pi=new c.Vector3,Te=new c.Vector4,Oe=new c.Vector4,Ze=new c.Vector4,Kn=new c.Vector3,qn=new c.Matrix4,De=new c.Line3,mi=new c.Vector3,an=new c.Box3,ln=new c.Sphere,Qe=new c.Vector4;let Ke,yt;function gi(a,e,t){return Qe.set(0,0,-e,1).applyMatrix4(a.projectionMatrix),Qe.multiplyScalar(1/Qe.w),Qe.x=yt/t.width,Qe.y=yt/t.height,Qe.applyMatrix4(a.projectionMatrixInverse),Qe.multiplyScalar(1/Qe.w),Math.abs(Math.max(Qe.x,Qe.y))}function Ra(a,e){const t=a.matrixWorld,n=a.geometry,s=n.attributes.instanceStart,i=n.attributes.instanceEnd,o=Math.min(n.instanceCount,s.count);for(let r=0,l=o;r<l;r++){De.start.fromBufferAttribute(s,r),De.end.fromBufferAttribute(i,r),De.applyMatrix4(t);const f=new c.Vector3,d=new c.Vector3;Ke.distanceSqToSegment(De.start,De.end,d,f),d.distanceTo(f)<yt*.5&&e.push({point:d,pointOnLine:f,distance:Ke.origin.distanceTo(d),object:a,face:null,faceIndex:r,uv:null,uv1:null})}}function ja(a,e,t){const n=e.projectionMatrix,i=a.material.resolution,o=a.matrixWorld,r=a.geometry,l=r.attributes.instanceStart,f=r.attributes.instanceEnd,d=Math.min(r.instanceCount,l.count),u=-e.near;Ke.at(1,Ze),Ze.w=1,Ze.applyMatrix4(e.matrixWorldInverse),Ze.applyMatrix4(n),Ze.multiplyScalar(1/Ze.w),Ze.x*=i.x/2,Ze.y*=i.y/2,Ze.z=0,Kn.copy(Ze),qn.multiplyMatrices(e.matrixWorldInverse,o);for(let p=0,g=d;p<g;p++){if(Te.fromBufferAttribute(l,p),Oe.fromBufferAttribute(f,p),Te.w=1,Oe.w=1,Te.applyMatrix4(qn),Oe.applyMatrix4(qn),Te.z>u&&Oe.z>u)continue;if(Te.z>u){const v=Te.z-Oe.z,y=(Te.z-u)/v;Te.lerp(Oe,y)}else if(Oe.z>u){const v=Oe.z-Te.z,y=(Oe.z-u)/v;Oe.lerp(Te,y)}Te.applyMatrix4(n),Oe.applyMatrix4(n),Te.multiplyScalar(1/Te.w),Oe.multiplyScalar(1/Oe.w),Te.x*=i.x/2,Te.y*=i.y/2,Oe.x*=i.x/2,Oe.y*=i.y/2,De.start.copy(Te),De.start.z=0,De.end.copy(Oe),De.end.z=0;const w=De.closestPointToPointParameter(Kn,!0);De.at(w,mi);const _=c.MathUtils.lerp(Te.z,Oe.z,w),M=_>=-1&&_<=1,L=Kn.distanceTo(mi)<yt*.5;if(M&&L){De.start.fromBufferAttribute(l,p),De.end.fromBufferAttribute(f,p),De.start.applyMatrix4(o),De.end.applyMatrix4(o);const v=new c.Vector3,y=new c.Vector3;Ke.distanceSqToSegment(De.start,De.end,y,v),t.push({point:y,pointOnLine:v,distance:Ke.origin.distanceTo(y),object:a,face:null,faceIndex:p,uv:null,uv1:null})}}}class Ea extends c.Mesh{constructor(e=new di,t=new Qn({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,s=new Float32Array(2*t.count);for(let o=0,r=0,l=t.count;o<l;o++,r+=2)fi.fromBufferAttribute(t,o),pi.fromBufferAttribute(n,o),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+fi.distanceTo(pi);const i=new c.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new c.InterleavedBufferAttribute(i,1,0)),e.setAttribute("instanceDistanceEnd",new c.InterleavedBufferAttribute(i,1,1)),this}raycast(e,t){const n=this.material.worldUnits,s=e.camera;s===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const i=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Ke=e.ray;const o=this.matrixWorld,r=this.geometry,l=this.material;yt=l.linewidth+i,r.boundingSphere===null&&r.computeBoundingSphere(),ln.copy(r.boundingSphere).applyMatrix4(o);let f;if(n)f=yt*.5;else{const u=Math.max(s.near,ln.distanceToPoint(Ke.origin));f=gi(s,u,l.resolution)}if(ln.radius+=f,Ke.intersectsSphere(ln)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),an.copy(r.boundingBox).applyMatrix4(o);let d;if(n)d=yt*.5;else{const u=Math.max(s.near,an.distanceToPoint(Ke.origin));d=gi(s,u,l.resolution)}an.expandByScalar(d),Ke.intersectsBox(an)!==!1&&(n?Ra(this,t):ja(this,s,t))}}class yi extends di{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let s=0;s<t;s+=3)n[2*s]=e[s],n[2*s+1]=e[s+1],n[2*s+2]=e[s+2],n[2*s+3]=e[s+3],n[2*s+4]=e[s+4],n[2*s+5]=e[s+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let s=0;s<t;s+=3)n[2*s]=e[s],n[2*s+1]=e[s+1],n[2*s+2]=e[s+2],n[2*s+3]=e[s+3],n[2*s+4]=e[s+4],n[2*s+5]=e[s+5];return super.setColors(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class Xa extends Ea{constructor(e=new yi,t=new Qn({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const Ya=["object"],_i=h.defineComponent({__name:"Line2",props:{points:{},vertexColors:{default:null},color:{default:"white"},lineWidth:{default:1},worldUnits:{type:Boolean,default:!1},alphaToCoverage:{type:Boolean,default:!1},dashed:{type:Boolean,default:!1},dashSize:{default:1},gapSize:{default:1},dashScale:{default:1},dashOffset:{default:0}},setup(a){const e=a;function t(d,u){if(!d||d.length===0)return new Array(u).fill(ne.normalizeColor(e.color));if(d.length===1)return new Array(u).fill(ne.normalizeColor(d[0]));if(d.length===u)return d.map(ne.normalizeColor);const p=u-1,g=d.map(ne.normalizeColor);closed&&g.push(g[0].clone());const x=[g[0]],w=p/(g.length-1);for(let _=1;_<p;_++){const M=_%w/w,L=Math.floor(_/w);x.push(g[L].clone().lerp(g[L+1],M))}return x.push(g[g.length-1]),x}function n(d,u,p){const g=u.map(w=>w instanceof c.Vector3?[w.x,w.y,w.z]:w instanceof c.Vector2?[w.x,w.y,0]:Array.isArray(w)&&w.length===2?[w[0],w[1],0]:w).flat();d.setPositions(g.flat());const x=t(p,u.length).map(w=>w.toArray()).flat();d.setColors(x),r.computeLineDistances()}function s(d,u){d.color=ne.normalizeColor(u.color),d.linewidth=u.lineWidth,d.alphaToCoverage=u.alphaToCoverage,d.worldUnits=u.worldUnits,d.vertexColors=Array.isArray(u.vertexColors),d.dashed=u.dashed,d.dashScale=u.dashScale,d.dashSize=u.dashSize,d.dashOffset=u.dashOffset,d.gapSize=u.gapSize,d.needsUpdate=!0}const i=new Qn,o=new yi,r=new Xa(o,i),l=ne.useTresContext().sizes,f=h.computed(()=>Array.isArray(e.vertexColors));return s(i,e),n(o,e.points,e.vertexColors),r.computeLineDistances(),h.watch(()=>[e.color,e.lineWidth,e.alphaToCoverage,e.worldUnits,f,e.dashed,e.dashScale,e.dashSize,e.dashOffset],()=>s(i,e)),h.watch([e.points,e.vertexColors],()=>n(o,e.points,e.vertexColors)),h.watch(()=>e.vertexColors,()=>n(o,e.points,e.vertexColors)),h.watch(()=>e.points,()=>n(o,e.points,e.vertexColors)),h.watch([l.height,l.width],()=>i.resolution=new c.Vector2(l.width.value,l.height.value)),h.onUnmounted(()=>{o.dispose(),i.dispose()}),(d,u)=>(h.openBlock(),h.createElementBlock("primitive",{object:h.unref(r)},null,8,Ya))}}),Wa=h.defineComponent({__name:"CatmullRomCurve3",props:{segments:{default:20},closed:{type:Boolean,default:!1},curveType:{default:"centripetal"},tension:{default:.5},points:{},vertexColors:{},color:{},lineWidth:{},alphaToCoverage:{type:Boolean},dashed:{type:Boolean},dashSize:{},dashScale:{},dashOffset:{},gapSize:{},worldUnits:{type:Boolean}},setup(a){const e=a;function t(o,r,l,f){const d=o.map(u=>u instanceof c.Vector3?u:new c.Vector3(...u));return new c.CatmullRomCurve3(d,r,l,f)}function n(o,r){return o.getPoints(r)}const s=h.computed(()=>t(e.points,e.closed,e.curveType,e.tension)),i=h.computed(()=>n(s.value,e.segments));return(o,r)=>(h.openBlock(),h.createBlock(_i,{points:i.value,"vertex-colors":e.vertexColors,color:e.color,lineWidth:e.lineWidth,alphaToCoverage:e.alphaToCoverage,dashed:e.dashed,dashSize:e.dashSize,dashScale:e.dashScale,dashOffset:e.dashOffset,gapSize:e.gapSize,worldUnits:e.worldUnits},null,8,["points","vertex-colors","color","lineWidth","alphaToCoverage","dashed","dashSize","dashScale","dashOffset","gapSize","worldUnits"]))}}),Za=["args"],Qa=["color"],Ka=h.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"circleRef",ref:i},o.$attrs),[h.createElementVNode("TresCircleGeometry",{args:h.unref(n)},null,8,Za),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Qa)])],16))}}),qa=["args"],Ja=["color"],Ha=h.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"coneRef",ref:i},o.$attrs),[h.createElementVNode("TresConeGeometry",{args:h.unref(n)},null,8,qa),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Ja)])],16))}}),$a=["args"],el=["color"],tl=h.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"dodecahedronRef",ref:i},o.$attrs),[h.createElementVNode("TresDodecahedronGeometry",{args:h.unref(n)},null,8,$a),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,el)])],16))}}),nl=["args"],sl=["color"],il=h.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"icosahedronRef",ref:i},o.$attrs),[h.createElementVNode("TresIcosahedronGeometry",{args:h.unref(n)},null,8,nl),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,sl)])],16))}}),ol=["args"],rl=["color"],al=h.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"octahedronRef",ref:i},o.$attrs),[h.createElementVNode("TresOctahedronGeometry",{args:h.unref(n)},null,8,ol),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,rl)])],16))}}),ll=["rotation"],cl=["args"],hl=["color"],ul=h.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"planeRef",ref:i,rotation:[-Math.PI/2,0,0]},o.$attrs),[h.createElementVNode("TresPlaneGeometry",{args:h.unref(n)},null,8,cl),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,hl)])],16,ll))}}),dl=["args"],fl=["color"],pl=h.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"ringRef",ref:i},o.$attrs),[h.createElementVNode("TresRingGeometry",{args:h.unref(n)},null,8,dl),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,fl)])],16))}}),ml=["args"],gl=["color"],yl=h.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"sphereRef",ref:i},o.$attrs),[h.createElementVNode("TresSphereGeometry",{args:h.unref(n)},null,8,ml),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,gl)])],16))}}),_l=["rotation"],vl=["args"],xl=["color"],wl=h.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"tetrahedronRef",ref:i,rotation:[-Math.PI/2,0,0]},o.$attrs),[h.createElementVNode("TresTetrahedronGeometry",{args:h.unref(n)},null,8,vl),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,xl)])],16,_l))}}),bl=["args"],Al=["color"],Ml=h.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"torusRef",ref:i},o.$attrs),[h.createElementVNode("TresTorusGeometry",{args:h.unref(n)},null,8,bl),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Al)])],16))}}),Sl=["args"],Pl=["color"],Cl=h.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"torusKnotRef",ref:i},o.$attrs),[h.createElementVNode("TresTorusKnotGeometry",{args:h.unref(n)},null,8,Sl),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Pl)])],16))}}),Ll=["args"],Tl=["color"],Ol=h.defineComponent({__name:"Tube",props:{args:{default:()=>[new c.QuadraticBezierCurve3(new c.Vector3(-1,0,0),new c.Vector3(0,1,0),new c.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:s}=h.toRefs(t),i=h.shallowRef();return e({value:i}),(o,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"tubeRef",ref:i},o.$attrs),[h.createElementVNode("TresTubeGeometry",{args:h.unref(n)},null,8,Ll),h.renderSlot(o.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Tl)])],16))}}),Dl=h.defineComponent({__name:"component",props:{background:{type:[Boolean,String],default:!1},blur:{default:0},files:{default:[]},path:{default:""},preset:{default:void 0}},async setup(a,{expose:e}){let t,n;const s=a,i=h.ref(null);return e(i),i.value=([t,n]=h.withAsyncContext(()=>Xs(s).texture),t=await t,n(),t),()=>{}}}),Il=["receive-shadow","rotation"],kl=["args"],Fl=h.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Bl=h.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(a){const e=a,t=r=>r===0?0:2**(10*r-10),{floor:n,segments:s,receiveShadow:i}=h.toRefs(e),o=h.ref(null);return h.watch(()=>[s.value,n.value,o.value],([r,l,f])=>{if(!f||r===null)return;let d=0;const u=r/r/2,p=f.attributes.position;for(let g=0;g<r+1;g++)for(let x=0;x<r+1;x++)p.setXYZ(d++,g/r-u+(g===0?-l:0),x/r-u,t(g/r));p.needsUpdate=!0,f.computeVertexNormals()}),(r,l)=>(h.openBlock(),h.createElementBlock("TresGroup",h.normalizeProps(h.guardReactiveProps(r.$attrs)),[h.createElementVNode("TresMesh",{"receive-shadow":h.unref(i),rotation:[-Math.PI/2,0,Math.PI/2]},[h.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:o,args:[1,1,h.unref(s),h.unref(s)]},null,8,kl),h.renderSlot(r.$slots,"default",{},()=>[Fl])],8,Il)],16))}}),Ul=["geometry"],Vl=["map","opacity","depth-write"],zl=["object"],Nl=["args"],Gl=["rotation","args"],Rl=h.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,n=h.shallowRef(),s=h.shallowRef();e(n);let i,o,r,l,f;const{renderer:d,scene:u}=ne.useTresContext(),p=h.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),g=h.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));h.watchEffect(()=>{i&&i.dispose(),o&&o.dispose(),r&&r.dispose(),l&&l.geometry.dispose(),i=new c.WebGLRenderTarget(t.resolution,t.resolution),o=new c.WebGLRenderTarget(t.resolution,t.resolution),o.texture.generateMipmaps=i.texture.generateMipmaps=!1,s.value=new c.OrthographicCamera(-p.value/2,p.value/2,g.value/2,-g.value/2,0,t.far),r=new c.PlaneGeometry(p.value,g.value).rotateX(Math.PI/2),l=new c.Mesh(r),l.visible=!1}),h.watchEffect(()=>{t.color&&(f&&f.dispose(),f=new c.MeshDepthMaterial,f.depthTest=f.depthWrite=!1,f.onBeforeCompile=A=>{A.uniforms={...A.uniforms,ucolor:{value:t.color?new c.Color(t.color):new c.Color}},A.fragmentShader=A.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
199
586
  void main() {
200
- `),M.fragmentShader=M.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const w=new c.ShaderMaterial(Yi),x=new c.ShaderMaterial(Zi);x.depthTest=w.depthTest=!1;function _(M){!f.value||!n.value||(a.visible=!0,a.material=w,w.uniforms.tDiffuse.value=i.texture,w.uniforms.h.value=M/256,f.value.setRenderTarget(o),f.value.render(a,n.value),a.material=x,x.uniforms.tDiffuse.value=o.texture,x.uniforms.v.value=M/256,f.value.setRenderTarget(i),f.value.render(a,n.value),a.visible=!1)}const{onLoop:S}=ue.useRenderLoop();let C=0,v,y;return S(()=>{!n.value||p.value===void 0||f.value===void 0||(t.frames===1/0||C<t.frames)&&(C++,v=p.value.background,y=p.value.overrideMaterial,s.value.visible=!1,p.value.background=null,p.value.overrideMaterial=h,f.value.setRenderTarget(i),f.value.render(p.value,n.value),_(t.blur),t.smooth&&_(t.blur*.4),f.value.setRenderTarget(null),s.value.visible=!0,p.value.background=v,p.value.overrideMaterial=y)}),(M,P)=>{const A=u.resolveComponent("primitive");return u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"groupRef",ref:s},M.$attrs),[u.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:u.unref(r)},[u.createElementVNode("TresMeshBasicMaterial",{map:u.unref(i).texture,opacity:M.opacity,"depth-write":M.depthWrite,transparent:!0},null,8,Ra)],8,za),u.createVNode(A,{object:u.unref(a)},null,8,["object"]),n.value&&M.helper?(u.openBlock(),u.createElementBlock("TresCameraHelper",{key:0,args:[n.value]},null,8,Ga)):u.createCommentVNode("",!0),u.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:n,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-m.value/2,m.value/2,g.value/2,-g.value/2,0,M.far]},null,8,Ea)],16)}}}),Xa=["position","a-scale"],Ya=["size","size-attenuation","transparent","alpha-test","alpha-map"],Za=u.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(l,{expose:e}){const t=l,s=u.ref(),n=u.ref(),{radius:i,depth:o,count:r,size:a,sizeAttenuation:h,transparent:f,alphaMap:p,alphaTest:m}=u.toRefs(t),g=()=>{let x=i.value+o.value;const _=u.computed(()=>o.value/r.value),S=[],C=Array.from({length:r.value},()=>(.5+.5*Math.random())*4),v=y=>new c.Vector3().setFromSpherical(new c.Spherical(y,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let y=0;y<r.value;y++)x-=_.value*Math.random(),S.push(...v(x));s.value=new Float32Array(S),n.value=new Float32Array(C)};u.watchEffect(()=>{g()});const w=u.shallowRef();return e({value:w}),(x,_)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"starsRef",ref:w},[u.createElementVNode("TresBufferGeometry",{position:[s.value,3],"a-scale":[n.value,1]},null,8,Xa),u.createElementVNode("TresPointsMaterial",{size:u.unref(a),"size-attenuation":u.unref(h),transparent:u.unref(f),"alpha-test":u.unref(m),"alpha-map":u.unref(p)},null,8,Ya)],512))}}),Wa=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Qa=["position","velocity"],Ka=u.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(l){const e=l,{size:t,area:s,color:n,alphaMap:i,map:o,opacity:r,alphaTest:a,depthWrite:h,transparent:f,sizeAttenuation:p,count:m,speed:g,randomness:w}=u.toRefs(e),x=u.shallowRef();let _=[],S=[];const C=()=>{_=new Float32Array(m.value*3);for(let M=0;M<m.value;M++){const P=M*3;_[P]=(Math.random()-.5)*s.value[0],_[P+1]=(Math.random()-.5)*s.value[1],_[P+2]=(Math.random()-.5)*s.value[2]}},v=()=>{S=new Float32Array(m.value*2);for(let M=0;M<m.value*2;M+=2)S[M]=(Math.random()-.5)/5*g.value*w.value,S[M+1]=Math.random()/5*g.value+.01};v(),C(),u.watchEffect(()=>{v(),C()});const{onLoop:y}=ue.useRenderLoop();return y(()=>{var M,P;if((M=x.value)!=null&&M.attributes.position.array&&((P=x.value)!=null&&P.attributes.position.count)){const A=x.value.attributes.position.array;for(let b=0;b<x.value.attributes.position.count;b++){const D=S[b*2],z=S[b*2+1];A[b*3]+=D,A[b*3+1]-=z,(A[b*3]<=-s.value[0]/2||A[b*3]>=s.value[0]/2)&&(A[b*3]=A[b*3]*-1),(A[b*3+1]<=-s.value[1]/2||A[b*3+1]>=s.value[1]/2)&&(A[b*3+1]=A[b*3+1]*-1)}x.value.attributes.position.needsUpdate=!0}}),(M,P)=>(u.openBlock(),u.createElementBlock("TresPoints",null,[u.createElementVNode("TresPointsMaterial",{size:u.unref(t),color:u.unref(n),"alpha-map":u.unref(i),map:u.unref(o),opacity:u.unref(r),"alpha-test":u.unref(a),"depth-write":u.unref(h),transparent:u.unref(f),"size-attenuation":u.unref(p)},null,8,Wa),u.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:x,position:[u.unref(_),3],velocity:[u.unref(S)]},null,8,Qa)]))}}),qa=["position"],Ja=["position"],Ha=["scale"],$a=["map","depth-test","color-space","color","opacity"],el=u.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(l,{expose:e}){let t,s;const n=l,{width:i,depth:o,segments:r,texture:a,color:h,depthTest:f,opacity:p,speed:m}=u.toRefs(n),g=u.shallowRef(),w=u.shallowRef();e({value:g});const x=[...new Array(r)].map((P,A)=>({x:i.value/2-Math.random()*i.value,y:i.value/2-Math.random()*i.value,scale:.4+Math.sin((A+1)/r.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*m.value})),_=(P,A)=>P/6*A*p.value,{map:S}=([t,s]=u.withAsyncContext(()=>ue.useTexture({map:a.value})),t=await t,s(),t),{renderer:C,camera:v}=ue.useTresContext(),y=u.computed(()=>{var P;return(P=C.value)==null?void 0:P.outputColorSpace}),{onLoop:M}=ue.useRenderLoop();return M(()=>{var P,A;g.value&&v.value&&w.value&&((P=w.value)==null||P.children.forEach((b,D)=>{b.rotation.z+=x[D].rotation}),g.value.lookAt((A=v.value)==null?void 0:A.position))}),(P,A)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"smokeRef",ref:g},P.$attrs),[u.createElementVNode("TresGroup",{ref_key:"groupRef",ref:w,position:[0,0,u.unref(r)/2*u.unref(o)]},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(u.unref(x),({scale:b,x:D,y:z,density:U},R)=>(u.openBlock(),u.createElementBlock("TresMesh",{key:`${R}`,position:[D,z,-R*u.unref(o)]},[u.createElementVNode("TresPlaneGeometry",{scale:[b,b,b],rotation:[0,0,0]},null,8,Ha),u.createElementVNode("TresMeshStandardMaterial",{map:u.unref(S),"depth-test":u.unref(f),"color-space":y.value,color:u.unref(h),"depth-write":!1,transparent:"",opacity:_(b,U)},null,8,$a)],8,Ja))),128))],8,qa)],16))}});class Et extends c.Mesh{constructor(){const e=Et.SkyShader,t=new c.ShaderMaterial({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:c.UniformsUtils.clone(e.uniforms),side:c.BackSide,depthWrite:!1});super(new c.BoxGeometry(1,1,1),t),this.isSky=!0}}Et.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new c.Vector3},up:{value:new c.Vector3(0,1,0)}},vertexShader:`
587
+ `),A.fragmentShader=A.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const x=new c.ShaderMaterial(zo),w=new c.ShaderMaterial(No);w.depthTest=x.depthTest=!1;function _(A){!d.value||!s.value||(l.visible=!0,l.material=x,x.uniforms.tDiffuse.value=i.texture,x.uniforms.h.value=A/256,d.value.setRenderTarget(o),d.value.render(l,s.value),l.material=w,w.uniforms.tDiffuse.value=o.texture,w.uniforms.v.value=A/256,d.value.setRenderTarget(i),d.value.render(l,s.value),l.visible=!1)}const{onLoop:M}=ne.useRenderLoop();let L=0,v,y;return M(()=>{!s.value||u.value===void 0||d.value===void 0||(t.frames===1/0||L<t.frames)&&(L++,v=u.value.background,y=u.value.overrideMaterial,n.value.visible=!1,u.value.background=null,u.value.overrideMaterial=f,d.value.setRenderTarget(i),d.value.render(u.value,s.value),_(t.blur),t.smooth&&_(t.blur*.4),d.value.setRenderTarget(null),n.value.visible=!0,u.value.background=v,u.value.overrideMaterial=y)}),(A,S)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps({ref_key:"groupRef",ref:n},A.$attrs),[h.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:h.unref(r)},[h.createElementVNode("TresMeshBasicMaterial",{map:h.unref(i).texture,opacity:A.opacity,"depth-write":A.depthWrite,transparent:!0},null,8,Vl)],8,Ul),h.createElementVNode("primitive",{object:h.unref(l)},null,8,zl),s.value&&A.helper?(h.openBlock(),h.createElementBlock("TresCameraHelper",{key:0,args:[s.value]},null,8,Nl)):h.createCommentVNode("",!0),h.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:s,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-p.value/2,p.value/2,g.value/2,-g.value/2,0,A.far]},null,8,Gl)],16))}}),jl=["position","a-scale"],El=["size","size-attenuation","transparent","alpha-test","alpha-map"],Xl=h.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(a,{expose:e}){const t=a,n=h.ref(),s=h.ref(),{radius:i,depth:o,count:r,size:l,sizeAttenuation:f,transparent:d,alphaMap:u,alphaTest:p}=h.toRefs(t),g=()=>{let w=i.value+o.value;const _=h.computed(()=>o.value/r.value),M=[],L=Array.from({length:r.value},()=>(.5+.5*Math.random())*4),v=y=>new c.Vector3().setFromSpherical(new c.Spherical(y,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let y=0;y<r.value;y++)w-=_.value*Math.random(),M.push(...v(w));n.value=new Float32Array(M),s.value=new Float32Array(L)};h.watchEffect(()=>{g()});const x=h.shallowRef();return e({value:x}),(w,_)=>(h.openBlock(),h.createElementBlock("TresPoints",{ref_key:"starsRef",ref:x},[h.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[s.value,1]},null,8,jl),h.createElementVNode("TresPointsMaterial",{size:h.unref(l),"size-attenuation":h.unref(f),transparent:h.unref(d),"alpha-test":h.unref(p),"alpha-map":h.unref(u)},null,8,El)],512))}}),Yl=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Wl=["position","velocity"],Zl=h.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(a){const e=a,{size:t,area:n,color:s,alphaMap:i,map:o,opacity:r,alphaTest:l,depthWrite:f,transparent:d,sizeAttenuation:u,count:p,speed:g,randomness:x}=h.toRefs(e),w=h.shallowRef();let _=[],M=[];const L=()=>{_=new Float32Array(p.value*3);for(let A=0;A<p.value;A++){const S=A*3;_[S]=(Math.random()-.5)*n.value[0],_[S+1]=(Math.random()-.5)*n.value[1],_[S+2]=(Math.random()-.5)*n.value[2]}},v=()=>{M=new Float32Array(p.value*2);for(let A=0;A<p.value*2;A+=2)M[A]=(Math.random()-.5)/5*g.value*x.value,M[A+1]=Math.random()/5*g.value+.01};v(),L(),h.watchEffect(()=>{v(),L()});const{onLoop:y}=ne.useRenderLoop();return y(()=>{var A,S;if((A=w.value)!=null&&A.attributes.position.array&&((S=w.value)!=null&&S.attributes.position.count)){const b=w.value.attributes.position.array;for(let P=0;P<w.value.attributes.position.count;P++){const O=M[P*2],k=M[P*2+1];b[P*3]+=O,b[P*3+1]-=k,(b[P*3]<=-n.value[0]/2||b[P*3]>=n.value[0]/2)&&(b[P*3]=b[P*3]*-1),(b[P*3+1]<=-n.value[1]/2||b[P*3+1]>=n.value[1]/2)&&(b[P*3+1]=b[P*3+1]*-1)}w.value.attributes.position.needsUpdate=!0}}),(A,S)=>(h.openBlock(),h.createElementBlock("TresPoints",null,[h.createElementVNode("TresPointsMaterial",{size:h.unref(t),color:h.unref(s),"alpha-map":h.unref(i),map:h.unref(o),opacity:h.unref(r),"alpha-test":h.unref(l),"depth-write":h.unref(f),transparent:h.unref(d),"size-attenuation":h.unref(u)},null,8,Yl),h.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:w,position:[h.unref(_),3],velocity:[h.unref(M)]},null,8,Wl)]))}}),Ql=["position"],Kl=["position"],ql=["scale"],Jl=["map","depth-test","color-space","color","opacity"],Hl=h.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(a,{expose:e}){let t,n;const s=a,{width:i,depth:o,segments:r,texture:l,color:f,depthTest:d,opacity:u,speed:p}=h.toRefs(s),g=h.shallowRef(),x=h.shallowRef();e({value:g});const w=[...new Array(r)].map((S,b)=>({x:i.value/2-Math.random()*i.value,y:i.value/2-Math.random()*i.value,scale:.4+Math.sin((b+1)/r.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*p.value})),_=(S,b)=>S/6*b*u.value,{map:M}=([t,n]=h.withAsyncContext(()=>ne.useTexture({map:l.value})),t=await t,n(),t),{renderer:L,camera:v}=ne.useTresContext(),y=h.computed(()=>{var S;return(S=L.value)==null?void 0:S.outputColorSpace}),{onLoop:A}=ne.useRenderLoop();return A(()=>{var S,b;g.value&&v.value&&x.value&&((S=x.value)==null||S.children.forEach((P,O)=>{P.rotation.z+=w[O].rotation}),g.value.lookAt((b=v.value)==null?void 0:b.position))}),(S,b)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps({ref_key:"smokeRef",ref:g},S.$attrs),[h.createElementVNode("TresGroup",{ref_key:"groupRef",ref:x,position:[0,0,h.unref(r)/2*h.unref(o)]},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(h.unref(w),({scale:P,x:O,y:k,density:V},R)=>(h.openBlock(),h.createElementBlock("TresMesh",{key:`${R}`,position:[O,k,-R*h.unref(o)]},[h.createElementVNode("TresPlaneGeometry",{scale:[P,P,P],rotation:[0,0,0]},null,8,ql),h.createElementVNode("TresMeshStandardMaterial",{map:h.unref(M),"depth-test":h.unref(d),"color-space":y.value,color:h.unref(f),"depth-write":!1,transparent:"",opacity:_(P,V)},null,8,Jl)],8,Kl))),128))],8,Ql)],16))}});class cn extends c.Mesh{constructor(){const e=cn.SkyShader,t=new c.ShaderMaterial({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:c.UniformsUtils.clone(e.uniforms),side:c.BackSide,depthWrite:!1});super(new c.BoxGeometry(1,1,1),t),this.isSky=!0}}cn.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new c.Vector3},up:{value:new c.Vector3(0,1,0)}},vertexShader:`
201
588
  uniform vec3 sunPosition;
202
589
  uniform float rayleigh;
203
590
  uniform float turbidity;
@@ -278,8 +665,6 @@
278
665
  uniform float mieDirectionalG;
279
666
  uniform vec3 up;
280
667
 
281
- const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );
282
-
283
668
  // constants for atmospheric scattering
284
669
  const float pi = 3.141592653589793238462643383279502884197169;
285
670
 
@@ -309,7 +694,7 @@
309
694
 
310
695
  void main() {
311
696
 
312
- vec3 direction = normalize( vWorldPosition - cameraPos );
697
+ vec3 direction = normalize( vWorldPosition - cameraPosition );
313
698
 
314
699
  // optical length
315
700
  // cutoff angle at 90 to avoid singularity in next formula.
@@ -352,4 +737,31 @@
352
737
  #include <tonemapping_fragment>
353
738
  #include <colorspace_fragment>
354
739
 
355
- }`};const tl=u.defineComponent({__name:"Sky",props:{turbidity:{default:3.4},rayleigh:{default:3},mieCoefficient:{default:.005},mieDirectionalG:{default:.7},elevation:{default:.6},azimuth:{default:180},distance:{default:45e4}},setup(l){const e=l,t=new Et,s=u.computed(()=>n(e.azimuth,e.elevation));function n(i,o){const r=c.MathUtils.degToRad(90-o),a=c.MathUtils.degToRad(i);return new c.Vector3().setFromSphericalCoords(1,r,a)}return(i,o)=>{const r=u.resolveComponent("primitive");return u.openBlock(),u.createBlock(r,{object:u.unref(t),"material-uniforms-turbidity-value":e.turbidity,"material-uniforms-rayleigh-value":e.rayleigh,"material-uniforms-mieCoefficient-value":e.mieCoefficient,"material-uniforms-mieDirectionalG-value":e.mieDirectionalG,"material-uniforms-sunPosition-value":s.value,scale:e.distance},null,8,["object","material-uniforms-turbidity-value","material-uniforms-rayleigh-value","material-uniforms-mieCoefficient-value","material-uniforms-mieDirectionalG-value","material-uniforms-sunPosition-value","scale"])}}});let Ye;const sl=(l="body")=>{Ye||(Ye=new Nn.Pane({container:document.querySelector(l)}),Ye.element.style.position="absolute",Ye.element.style.top="1rem",Ye.element.style.right="1rem",Ye.element.style.zIndex="9999");const{logWarning:e}=ps();e("useTweakPane is going to be deprecated soon and will no longer be part of this package, please start migrating to @tresjs/leches package https://github.com/Tresjs/leches or v-tweakpane https://github.com/vinayakkulkarni/v-tweakpane instead.");function t(){Ye&&Ye.dispose()}return u.onMounted(()=>{const{resume:s}=ue.useRenderLoop();s()}),u.onUnmounted(()=>{t()}),{pane:Ye,disposeTweakPane:t}};var Dn={exports:{}};(function(l,e){(function(t,s){l.exports=s()})(_o,function(){var t=function(){function s(g){return o.appendChild(g.dom),g}function n(g){for(var w=0;w<o.children.length;w++)o.children[w].style.display=w===g?"block":"none";i=g}var i=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(g){g.preventDefault(),n(++i%o.children.length)},!1);var r=(performance||Date).now(),a=r,h=0,f=s(new t.Panel("FPS","#0ff","#002")),p=s(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=s(new t.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:o,addPanel:s,showPanel:n,begin:function(){r=(performance||Date).now()},end:function(){h++;var g=(performance||Date).now();if(p.update(g-r,200),g>a+1e3&&(f.update(1e3*h/(g-a),100),a=g,h=0,m)){var w=performance.memory;m.update(w.usedJSHeapSize/1048576,w.jsHeapSizeLimit/1048576)}return g},update:function(){r=this.end()},domElement:o,setMode:n}};return t.Panel=function(s,n,i){var o=1/0,r=0,a=Math.round,h=a(window.devicePixelRatio||1),f=80*h,p=48*h,m=3*h,g=2*h,w=3*h,x=15*h,_=74*h,S=30*h,C=document.createElement("canvas");C.width=f,C.height=p,C.style.cssText="width:80px;height:48px";var v=C.getContext("2d");return v.font="bold "+9*h+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=i,v.fillRect(0,0,f,p),v.fillStyle=n,v.fillText(s,m,g),v.fillRect(w,x,_,S),v.fillStyle=i,v.globalAlpha=.9,v.fillRect(w,x,_,S),{dom:C,update:function(y,M){o=Math.min(o,y),r=Math.max(r,y),v.fillStyle=i,v.globalAlpha=1,v.fillRect(0,0,f,x),v.fillStyle=n,v.fillText(a(y)+" "+s+" ("+a(o)+"-"+a(r)+")",m,g),v.drawImage(C,w+h,x,_-h,S,w,x,_-h,S),v.fillRect(w+_-h,x,h,S),v.fillStyle=i,v.globalAlpha=.9,v.fillRect(w+_-h,x,h,a((1-y/M)*S))}}},t})})(Dn);var nl=Dn.exports;const il=xo(nl),ol=(l=0)=>{const e=new il;if(e){const t=document.body;e.showPanel(l),t==null||t.appendChild(e.dom),u.onMounted(()=>{const{onBeforeLoop:s,onAfterLoop:n,resume:i}=ue.useRenderLoop();i(),s(()=>e.begin()),n(()=>e.end())}),u.onUnmounted(()=>{t==null||t.removeChild(e.dom)})}return null};class rl{constructor(e,t,s){this.name=e,this.fg=t,this.bg=s,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=90*this.PR,this.canvas.height=48*this.PR,this.canvas.style.width="90px",this.canvas.style.position="absolute",this.canvas.style.height="48px",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",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.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,s,n,i=0){let o=1/0,r=0;this.context&&(o=Math.min(o,e),r=Math.max(s,e),n=Math.max(n,t),this.context.fillStyle=this.bg,this.context.globalAlpha=1,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(e.toFixed(i)+" "+this.name+" ("+o.toFixed(i)+"-"+parseFloat(r.toFixed(i))+")",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),this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,(1-t/n)*this.GRAPH_HEIGHT))}}const kn=class Wt{constructor({logsPerSecond:e=20,samplesLog:t=100,samplesGraph:s=10,precision:n=2,minimal:i=!1,horizontal:o=!0,mode:r=0}={}){this.mode=r,this.horizontal=o,this.container=document.createElement("div"),this.container.style.cssText="position:fixed;top:0;left:0;opacity:0.9;z-index:10000;",i&&(this.container.style.cssText+="cursor:pointer"),this.canvasGpu=null,this.gl=null,this.query=null,this.minimal=i,this.beginTime=(performance||Date).now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.frames=0,this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.queryCreated=!1,this.fpsPanel=this.addPanel(new Wt.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new Wt.Panel("CPU","#0f0","#020"),1),this.gpuPanel=null,this.samplesLog=t,this.samplesGraph=s,this.precision=n,this.logsPerSecond=e,this.minimal?(this.container.addEventListener("click",a=>{a.preventDefault(),this.showPanel(++this.mode%this.container.children.length)},!1),this.mode=r,this.showPanel(this.mode)):window.addEventListener("resize",()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2)})}resizePanel(e,t){e.canvas.style.position="absolute",this.minimal?e.canvas.style.display="none":(e.canvas.style.display="block",this.horizontal?(e.canvas.style.top="0px",e.canvas.style.left=t*e.WIDTH/e.PR+"px"):(e.canvas.style.left="0px",e.canvas.style.top=t*e.HEIGHT/e.PR+"px"))}addPanel(e,t){return e.canvas&&(this.container.appendChild(e.canvas),this.resizePanel(e,t)),e}showPanel(e){for(let t=0;t<this.container.children.length;t++){const s=this.container.children[t];s.style.display=t===e?"block":"none"}this.mode=e}init(e){this.canvasGpu=e,this.canvasGpu&&(this.gl=this.canvasGpu.getContext("webgl2"),this.ext=this.gl?this.gl.getExtension("EXT_disjoint_timer_query_webgl2"):null,this.ext&&(this.gpuPanel=this.addPanel(new Wt.Panel("GPU","#ff0","#220"),2)))}begin(){if(this.beginProfiling("cpu-started"),!(!this.gl||!this.ext)){if(this.query){const e=this.gl.getQueryParameter(this.query,this.gl.QUERY_RESULT_AVAILABLE);if(this.disjoint=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT),e&&!this.disjoint){this.ns=this.gl.getQueryParameter(this.query,this.gl.QUERY_RESULT);const t=this.ns*1e-6;(e||this.disjoint)&&(this.gl.deleteQuery(this.query),this.query=null),e&&this.addToAverage(t,this.averageGpu)}}this.query||(this.queryCreated=!0,this.query=this.gl.createQuery(),this.query&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.query))}}end(){this.beginTime=this.endInternal(),this.endProfiling("cpu-started","cpu-finished","cpu-duration",this.averageCpu),!(!this.gl||!this.ext)&&this.queryCreated&&this.gl.getQuery(this.ext.TIME_ELAPSED_EXT,this.gl.CURRENT_QUERY)&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT)}endInternal(){this.frames++;const e=(performance||Date).now();if(e>=this.prevCpuTime+1e3/this.logsPerSecond&&(this.updatePanel(this.msPanel,this.averageCpu),this.updatePanel(this.gpuPanel,this.averageGpu),this.prevCpuTime=e),e>=this.prevTime+1e3){const t=this.frames*1e3/(e-this.prevTime);this.fpsPanel.update(t,t,100,100,0),this.prevTime=e,this.frames=0}return e}addToAverage(e,t){t.logs.push(e),t.logs.length>this.samplesLog&&t.logs.shift(),t.graph.push(e),t.graph.length>this.samplesGraph&&t.graph.shift()}beginProfiling(e){window.performance&&window.performance.mark(e)}endProfiling(e,t,s,n){if(window.performance&&t){window.performance.mark(t);const i=performance.measure(s,e,t);this.addToAverage(i.duration,n)}}updatePanel(e,t){if(t.logs.length>0){let s=0,n=.01;for(let r=0;r<t.logs.length;r++)s+=t.logs[r],t.logs[r]>n&&(n=t.logs[r]);let i=0,o=.01;for(let r=0;r<t.graph.length;r++)i+=t.graph[r],t.graph[r]>o&&(o=t.graph[r]);e&&e.update(s/Math.min(t.logs.length,this.samplesLog),i/Math.min(t.graph.length,this.samplesGraph),n,o,this.precision)}}};kn.Panel=rl;let al=kn;const ll=u.defineComponent({name:"StatsGl",props:["logsPerSecond","samplesLog","samplesGraph","precision","horizontal","minimal","mode"],async setup(l,{expose:e}){const t=new al({logsPerSecond:l.logsPerSecond,samplesLog:l.samplesLog,samplesGraph:l.samplesGraph,precision:l.precision,horizontal:l.horizontal,minimal:l.minimal,mode:l.mode});e({statsGl:t});const s=document.body;s==null||s.appendChild(t.container);const{renderer:n}=ue.useTresContext(),{onBeforeLoop:i,onAfterLoop:o,resume:r}=ue.useRenderLoop();return t.init(n.value.domElement),r(),i(()=>t.begin()),o(()=>t.end()),null}}),cl={updated:(l,e)=>{if(e.arg){console.log(`v-log:${e.arg}`,l[e.arg]);return}console.log("v-log",l)}},{logWarning:Fn}=ue.useLogger(),hl={mounted:l=>{if(!l.isLight){Fn(`${l.type} is not a light`);return}jt=ul[l.type],l.parent.add(new jt(l))},updated:l=>{Lt=l.parent.children.find(e=>e instanceof jt),Lt.update()},unmounted:l=>{if(!l.isLight){Fn(`${l.type} is not a light`);return}Lt=l.parent.children.find(e=>e instanceof jt),Lt.dispose(),l.parent.remove(Lt)}};let jt,Lt;const ul={DirectionalLight:c.DirectionalLightHelper,PointLight:c.PointLightHelper,SpotLight:c.SpotLightHelper,HemisphereLight:c.HemisphereLightHelper},pl={updated:(l,e)=>{var n,i;let t=e.value;e.value&&((i=(n=e.value)==null?void 0:n.value)!=null&&i.isMesh)&&(t=e.value.value.position),Array.isArray(e.value)&&(t=new c.Vector3(...t));const{onLoop:s}=ue.useRenderLoop();s(()=>{l.lookAt(t)})}};function fl(l,e){const t={};for(const s of e)Object.prototype.hasOwnProperty.call(l,s)&&(t[s]=l[s]);return t}function dl(l,e){const t=`set${e[0].toUpperCase()}${e.slice(1)}`;return l[t]!==void 0}q.Backdrop=Na,q.Box=Kr,q.CameraControls=kr,q.Circle=Hr,q.Cone=ta,q.ContactShadows=ja,q.Dodecahedron=ia,q.Environment=Fa,q.FBXModel=hr,q.GLTFModel=cr,q.Icosahedron=aa,q.KeyboardControls=wr,q.Lensflare=ar,q.Levioso=Po,q.MapControls=Pr,q.MeshGlassMaterial=Zr,q.MeshWobbleMaterial=Ur,q.MouseParallax=Xo,q.Octahedron=ha,q.OrbitControls=gr,q.Plane=da,q.PointerLockControls=Mr,q.Precipitation=Ka,q.Ring=ya,q.SVG=pr,q.ScrollControls=Tr,q.Sky=tl,q.Smoke=el,q.Sphere=wa,q.Stars=Za,q.Stats=ol,q.StatsGl=ll,q.Tetrahedron=Ma,q.Text3D=Mo,q.Torus=Ta,q.TorusKnot=Oa,q.TransformControls=br,q.Tube=ka,q.hasSetter=dl,q.pick=fl,q.useAnimations=So,q.useEnvironment=gn,q.useFBX=_n,q.useGLTF=yn,q.useProgress=fr,q.useTweakPane=sl,q.useVideoTexture=dr,q.vAlwaysLookAt=pl,q.vLightHelper=hl,q.vLog=cl,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});
740
+ }`};const $l=["object","material-uniforms-turbidity-value","material-uniforms-rayleigh-value","material-uniforms-mieCoefficient-value","material-uniforms-mieDirectionalG-value","material-uniforms-sunPosition-value","scale"],ec=h.defineComponent({__name:"Sky",props:{turbidity:{default:3.4},rayleigh:{default:3},mieCoefficient:{default:.005},mieDirectionalG:{default:.7},elevation:{default:.6},azimuth:{default:180},distance:{default:45e4}},setup(a){const e=a,t=new cn,n=h.computed(()=>s(e.azimuth,e.elevation));function s(i,o){const r=c.MathUtils.degToRad(90-o),l=c.MathUtils.degToRad(i);return new c.Vector3().setFromSphericalCoords(1,r,l)}return(i,o)=>(h.openBlock(),h.createElementBlock("primitive",{object:h.unref(t),"material-uniforms-turbidity-value":e.turbidity,"material-uniforms-rayleigh-value":e.rayleigh,"material-uniforms-mieCoefficient-value":e.mieCoefficient,"material-uniforms-mieDirectionalG-value":e.mieDirectionalG,"material-uniforms-sunPosition-value":n.value,scale:e.distance},null,8,$l))}});let Je;const tc=(a="body")=>{Je||(Je=new Li.Pane({container:document.querySelector(a)}),Je.element.style.position="absolute",Je.element.style.top="1rem",Je.element.style.right="1rem",Je.element.style.zIndex="9999");const{logWarning:e}=In();e("useTweakPane is going to be deprecated soon and will no longer be part of this package, please start migrating to @tresjs/leches package https://github.com/Tresjs/leches or v-tweakpane https://github.com/vinayakkulkarni/v-tweakpane instead.");function t(){Je&&Je.dispose()}return h.onMounted(()=>{const{resume:n}=ne.useRenderLoop();n()}),h.onUnmounted(()=>{t()}),{pane:Je,disposeTweakPane:t}};var nc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sc(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var vi={exports:{}};(function(a,e){(function(t,n){a.exports=n()})(nc,function(){var t=function(){function n(g){return o.appendChild(g.dom),g}function s(g){for(var x=0;x<o.children.length;x++)o.children[x].style.display=x===g?"block":"none";i=g}var i=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(g){g.preventDefault(),s(++i%o.children.length)},!1);var r=(performance||Date).now(),l=r,f=0,d=n(new t.Panel("FPS","#0ff","#002")),u=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=n(new t.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:o,addPanel:n,showPanel:s,begin:function(){r=(performance||Date).now()},end:function(){f++;var g=(performance||Date).now();if(u.update(g-r,200),g>l+1e3&&(d.update(1e3*f/(g-l),100),l=g,f=0,p)){var x=performance.memory;p.update(x.usedJSHeapSize/1048576,x.jsHeapSizeLimit/1048576)}return g},update:function(){r=this.end()},domElement:o,setMode:s}};return t.Panel=function(n,s,i){var o=1/0,r=0,l=Math.round,f=l(window.devicePixelRatio||1),d=80*f,u=48*f,p=3*f,g=2*f,x=3*f,w=15*f,_=74*f,M=30*f,L=document.createElement("canvas");L.width=d,L.height=u,L.style.cssText="width:80px;height:48px";var v=L.getContext("2d");return v.font="bold "+9*f+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=i,v.fillRect(0,0,d,u),v.fillStyle=s,v.fillText(n,p,g),v.fillRect(x,w,_,M),v.fillStyle=i,v.globalAlpha=.9,v.fillRect(x,w,_,M),{dom:L,update:function(y,A){o=Math.min(o,y),r=Math.max(r,y),v.fillStyle=i,v.globalAlpha=1,v.fillRect(0,0,d,w),v.fillStyle=s,v.fillText(l(y)+" "+n+" ("+l(o)+"-"+l(r)+")",p,g),v.drawImage(L,x+f,w,_-f,M,x,w,_-f,M),v.fillRect(x+_-f,w,f,M),v.fillStyle=i,v.globalAlpha=.9,v.fillRect(x+_-f,w,f,l((1-y/A)*M))}}},t})})(vi);var ic=vi.exports;const oc=sc(ic),rc=h.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(a,{expose:e}){const t=new oc;e({stats:t});const n=document.body;t.showPanel(a.showPanel||0),n==null||n.appendChild(t.dom);const{onBeforeLoop:s,onAfterLoop:i,resume:o}=ne.useRenderLoop();return o(),s(()=>t.begin()),i(()=>t.end()),h.onUnmounted(()=>{n==null||n.removeChild(t.dom)}),null}});class ac{constructor(e,t,n){this.name=e,this.fg=t,this.bg=n,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=90*this.PR,this.canvas.height=48*this.PR,this.canvas.style.width="90px",this.canvas.style.position="absolute",this.canvas.style.height="48px",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",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.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,s,i=0){let o=1/0,r=0;this.context&&(o=Math.min(o,e),r=Math.max(n,e),s=Math.max(s,t),this.context.fillStyle=this.bg,this.context.globalAlpha=1,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(e.toFixed(i)+" "+this.name+" ("+o.toFixed(i)+"-"+parseFloat(r.toFixed(i))+")",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),this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,(1-t/s)*this.GRAPH_HEIGHT))}}const xi=class pn{constructor({logsPerSecond:e=20,samplesLog:t=100,samplesGraph:n=10,precision:s=2,minimal:i=!1,horizontal:o=!0,mode:r=0}={}){this.mode=r,this.horizontal=o,this.container=document.createElement("div"),this.container.style.cssText="position:fixed;top:0;left:0;opacity:0.9;z-index:10000;",i&&(this.container.style.cssText+="cursor:pointer"),this.canvasGpu=null,this.gl=null,this.query=null,this.minimal=i,this.beginTime=(performance||Date).now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.frames=0,this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.queryCreated=!1,this.fpsPanel=this.addPanel(new pn.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new pn.Panel("CPU","#0f0","#020"),1),this.gpuPanel=null,this.samplesLog=t,this.samplesGraph=n,this.precision=s,this.logsPerSecond=e,this.minimal?(this.container.addEventListener("click",l=>{l.preventDefault(),this.showPanel(++this.mode%this.container.children.length)},!1),this.mode=r,this.showPanel(this.mode)):window.addEventListener("resize",()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2)})}resizePanel(e,t){e.canvas.style.position="absolute",this.minimal?e.canvas.style.display="none":(e.canvas.style.display="block",this.horizontal?(e.canvas.style.top="0px",e.canvas.style.left=t*e.WIDTH/e.PR+"px"):(e.canvas.style.left="0px",e.canvas.style.top=t*e.HEIGHT/e.PR+"px"))}addPanel(e,t){return e.canvas&&(this.container.appendChild(e.canvas),this.resizePanel(e,t)),e}showPanel(e){for(let t=0;t<this.container.children.length;t++){const n=this.container.children[t];n.style.display=t===e?"block":"none"}this.mode=e}init(e){this.canvasGpu=e,this.canvasGpu&&(this.gl=this.canvasGpu.getContext("webgl2"),this.ext=this.gl?this.gl.getExtension("EXT_disjoint_timer_query_webgl2"):null,this.ext&&(this.gpuPanel=this.addPanel(new pn.Panel("GPU","#ff0","#220"),2)))}begin(){if(this.beginProfiling("cpu-started"),!(!this.gl||!this.ext)){if(this.query){const e=this.gl.getQueryParameter(this.query,this.gl.QUERY_RESULT_AVAILABLE);if(this.disjoint=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT),e&&!this.disjoint){this.ns=this.gl.getQueryParameter(this.query,this.gl.QUERY_RESULT);const t=this.ns*1e-6;(e||this.disjoint)&&(this.gl.deleteQuery(this.query),this.query=null),e&&this.addToAverage(t,this.averageGpu)}}this.query||(this.queryCreated=!0,this.query=this.gl.createQuery(),this.query&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.query))}}end(){this.beginTime=this.endInternal(),this.endProfiling("cpu-started","cpu-finished","cpu-duration",this.averageCpu),!(!this.gl||!this.ext)&&this.queryCreated&&this.gl.getQuery(this.ext.TIME_ELAPSED_EXT,this.gl.CURRENT_QUERY)&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT)}endInternal(){this.frames++;const e=(performance||Date).now();if(e>=this.prevCpuTime+1e3/this.logsPerSecond&&(this.updatePanel(this.msPanel,this.averageCpu),this.updatePanel(this.gpuPanel,this.averageGpu),this.prevCpuTime=e),e>=this.prevTime+1e3){const t=this.frames*1e3/(e-this.prevTime);this.fpsPanel.update(t,t,100,100,0),this.prevTime=e,this.frames=0}return e}addToAverage(e,t){t.logs.push(e),t.logs.length>this.samplesLog&&t.logs.shift(),t.graph.push(e),t.graph.length>this.samplesGraph&&t.graph.shift()}beginProfiling(e){window.performance&&window.performance.mark(e)}endProfiling(e,t,n,s){if(window.performance&&t){window.performance.mark(t);const i=performance.measure(n,e,t);this.addToAverage(i.duration,s)}}updatePanel(e,t){if(t.logs.length>0){let n=0,s=.01;for(let r=0;r<t.logs.length;r++)n+=t.logs[r],t.logs[r]>s&&(s=t.logs[r]);let i=0,o=.01;for(let r=0;r<t.graph.length;r++)i+=t.graph[r],t.graph[r]>o&&(o=t.graph[r]);e&&e.update(n/Math.min(t.logs.length,this.samplesLog),i/Math.min(t.graph.length,this.samplesGraph),s,o,this.precision)}}};xi.Panel=ac;let lc=xi;const cc=h.defineComponent({name:"StatsGl",props:["logsPerSecond","samplesLog","samplesGraph","precision","horizontal","minimal","mode"],async setup(a,{expose:e}){const t=new lc({logsPerSecond:a.logsPerSecond,samplesLog:a.samplesLog,samplesGraph:a.samplesGraph,precision:a.precision,horizontal:a.horizontal,minimal:a.minimal,mode:a.mode});e({statsGl:t});const n=document.body;n==null||n.appendChild(t.container);const{renderer:s}=ne.useTresContext(),{onBeforeLoop:i,onAfterLoop:o,resume:r}=ne.useRenderLoop();return t.init(s.value.domElement),r(),i(()=>t.begin()),o(()=>t.end()),h.onUnmounted(()=>{n==null||n.removeChild(t.container)}),null}});var hc=`#include <common>
741
+
742
+ void main() {
743
+ vec2 center = vec2(0., 1.);
744
+ float rotation = 0.0;
745
+
746
+
747
+
748
+ float size = 0.03;
749
+
750
+ vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
751
+ vec2 scale;
752
+ scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
753
+ scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
754
+
755
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
756
+ if ( isPerspective ) scale *= - mvPosition.z;
757
+
758
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
759
+ vec2 rotatedPosition;
760
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
761
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
762
+ mvPosition.xy += rotatedPosition;
763
+
764
+ gl_Position = projectionMatrix * mvPosition;
765
+ }`,uc=`void main() {
766
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
767
+ }`;const Gt=new c.Vector3(0,0,0),Jn=new c.Vector3(0,0,0),dc=new c.Vector3(0,0,0);function wi(a,e,t){const n=Gt.setFromMatrixPosition(a.matrixWorld);n.project(e);const s=t.width/2,i=t.height/2;return[(Number.isNaN(n.x)?0:n.x)*s+s,-(n.y*i)+i]}function fc(a,e){const t=Gt.setFromMatrixPosition(a.matrixWorld),n=Jn.setFromMatrixPosition(e.matrixWorld),s=t.sub(n),i=e.getWorldDirection(dc);return s.angleTo(i)>Math.PI/2}function pc(a,e,t,n){const s=Gt.setFromMatrixPosition(a.matrixWorld),i=s.clone();i.project(e),t.setFromCamera(new c.Vector2(i.x,i.y),e);const o=t.intersectObjects(n,!0);if(o.length>0){const r=o[0].distance;return s.distanceTo(t.ray.origin)<r}return!0}function mc(a,e){if(e instanceof c.OrthographicCamera)return e.zoom;if(e instanceof c.PerspectiveCamera){const t=Gt.setFromMatrixPosition(a.matrixWorld),n=Jn.setFromMatrixPosition(e.matrixWorld),s=e.fov*Math.PI/180,i=t.distanceTo(n);return 1/(2*Math.tan(s/2)*i)}else return 1}function gc(a,e,t){if(e instanceof c.PerspectiveCamera||e instanceof c.OrthographicCamera){const n=Gt.setFromMatrixPosition(a.matrixWorld),s=Jn.setFromMatrixPosition(e.matrixWorld),i=n.distanceTo(s),o=(t[1]-t[0])/(e.far-e.near),r=t[1]-o*e.far;return Math.round(o*i+r)}}const Hn=a=>Math.abs(a)<1e-10?0:a;function bi(a,e,t=""){let n="matrix3d(";for(let s=0;s!==16;s++)n+=Hn(e[s]*a.elements[s])+(s!==15?",":")");return t+n}const yc=(a=>e=>bi(e,a))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),_c=(a=>(e,t)=>bi(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]),vc=["geometry","material"],xc=h.defineComponent({__name:"HTML",props:{geometry:{default:new c.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:[Array,Boolean,String]}},emits:["onOcclude"],setup(a,{emit:e}){const t=a,n=h.useAttrs(),s=h.useSlots(),i=h.ref(),o=h.ref(),{geometry:r,material:l,as:f,transform:d,portal:u,wrapperClass:p,eps:g,distanceFactor:x,fullscreen:w,center:_,pointerEvents:M,sprite:L,occlude:v,zIndexRange:y}=h.toRefs(t),{renderer:A,scene:S,camera:b,raycaster:P,sizes:O}=ne.useTresContext(),k=h.computed(()=>document.createElement(f.value)),V=h.ref([0,0]),R=h.ref(0),X=h.ref(),K=h.computed(()=>d.value?{position:"absolute",top:0,left:0,width:`${O.width.value}px`,height:`${O.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2,willChange:"transform"}:{position:"absolute",transform:_.value?"translate3d(-50%,-50%,0)":"none",...w.value&&{top:-O.height.value/2,left:-O.width.value/2,width:`${O.width.value}px`,height:`${O.height.value}px`},zIndex:2,...n.style,willChange:"transform"}),H=h.computed(()=>({position:"absolute",pointerEvents:M.value})),he=h.ref(null),J=h.ref(!1),G=h.computed(()=>(v==null?void 0:v.value)&&(v==null?void 0:v.value)!=="blending"||Array.isArray(v==null?void 0:v.value)&&(v==null?void 0:v.value.length)&&h.isRef(v.value[0]));h.watch(()=>v,T=>{T&&T==="blending"?(k.value.style.zIndex=`${Math.floor(y.value[0]/2)}`,k.value.style.position="absolute",k.value.style.pointerEvents="none"):(k.value.style.zIndex=null,k.value.style.position=null,k.value.style.pointerEvents=null)}),h.watch(()=>{var T;return[i.value,A.value,O.width.value,O.height.value,(T=s.default)==null?void 0:T.call(s)]},([T,m])=>{var F,j,D,E,ie,Y;if(T&&m){const $=(u==null?void 0:u.value)||m.domElement;if((F=S.value)==null||F.updateMatrixWorld(),d.value)k.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const Z=wi(T,b.value,{width:O.width.value,height:O.height.value});k.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${Z[0]}px,${Z[1]}px,0);transform-origin:0 0;`}$&&((j=$.parentNode)==null||j.appendChild(k.value)),d.value?X.value=h.createVNode("div",{id:"outer",style:K.value},[h.createVNode("div",{id:"inner",style:H.value},[h.createVNode("div",{key:(D=o.value)==null?void 0:D.uuid,id:S==null?void 0:S.value.uuid,class:n.class,style:n.style},(E=s.default)==null?void 0:E.call(s))])]):X.value=h.createVNode("div",{key:(ie=o.value)==null?void 0:ie.uuid,id:S==null?void 0:S.value.uuid,style:K.value},(Y=s.default)==null?void 0:Y.call(s)),h.render(X.value,k.value)}}),h.watchEffect(()=>{p!=null&&p.value&&(k.value.className=p.value)});const oe=h.ref(!0),{onLoop:se}=ne.useRenderLoop();se(()=>{var T,m,F,j,D,E,ie;if(i.value&&b.value&&A.value){(T=b.value)==null||T.updateMatrixWorld(),i.value.updateWorldMatrix(!0,!1);const Y=d.value?V.value:wi(i.value,b.value,{width:O.width.value||0,height:O.height.value||0});if(d.value||Math.abs(R.value-b.value.zoom)>g.value||Math.abs(V.value[0]-Y[0])>g.value||Math.abs(V.value[1]-Y[1])>g.value){const $=fc(i.value,b.value);let Z=!1;G.value&&(Array.isArray(v==null?void 0:v.value)?Z=v==null?void 0:v.value:(v==null?void 0:v.value)!=="blending"&&(Z=[S.value]));const fe=oe.value;if(Z){const I=pc(i.value,b.value,P.value,Z);oe.value=I&&!$}else oe.value=!$;fe!==oe.value&&(e("onOcclude",!oe.value),k.value.style.display=oe.value?"block":"none");const Q=Math.floor(y.value[0]/2),ee=v!=null&&v.value?G.value?[y.value[0],Q]:[Q-1,0]:y.value;if(k.value.style.zIndex=`${gc(i.value,b.value,ee)}`,k.value.style.willChange="transform",d.value){const[I,C]=[O.width.value/2,O.height.value/2],te=b.value.projectionMatrix.elements[5]*C,{isOrthographicCamera:pe,top:we,left:Pe,bottom:ke,right:Xe}=b.value,Pt=yc(b.value.matrixWorldInverse),jt=pe?`scale(${te})translate(${Hn(-(Xe+Pe)/2)}px,${Hn((we+ke)/2)}px)`:`translateZ(${te}px)`;let Ge=i.value.matrixWorld;L.value&&(Ge=b.value.matrixWorldInverse.clone().transpose().copyPosition(Ge).scale(i.value.scale),Ge.elements[3]=Ge.elements[7]=Ge.elements[11]=0,Ge.elements[15]=1),k.value.style.width=`${O.width.value}px`,k.value.style.height=`${O.height.value}px`,k.value.style.perspective=pe?"":`${te}px`,(m=X.value)!=null&&m.el&&((F=X.value)!=null&&F.children)&&(X.value.el.style.willChange="transform",X.value.el.style.transform=`${jt}${Pt}translate(${I}px,${C}px)`,X.value.children[0].willChange="transform",X.value.children[0].el.style.transform=_c(Ge,1/(((x==null?void 0:x.value)||10)/400)))}else{const I=(x==null?void 0:x.value)===void 0?1:mc(i.value,b.value)*(x==null?void 0:x.value);k.value.style.transform=`translate3d(${Y[0]}px,${Y[1]}px,0) scale(${I})`}}V.value=Y,R.value=b.value.zoom}if(!G.value&&o.value&&!J.value)if(d.value){if((j=X.value)!=null&&j.el&&((D=X.value)!=null&&D.children)){const Y=(E=X.value)==null?void 0:E.children[0];if(Y!=null&&Y.clientWidth&&(Y!=null&&Y.clientHeight)){const{isOrthographicCamera:$}=b.value;if($||r)n.scale&&(Array.isArray(n.scale)?n.scale instanceof c.Vector3?o.value.scale.copy(n.scale.clone().divideScalar(1)):o.value.scale.set(1/n.scale[0],1/n.scale[1],1/n.scale[2]):o.value.scale.setScalar(1/n.scale));else{const Z=((x==null?void 0:x.value)||10)/400,fe=Y.clientWidth*Z,Q=Y.clientHeight*Z;o.value.scale.set(fe,Q,1)}J.value=!0}}}else{const Y=k.value.children[0];if(Y!=null&&Y.clientWidth&&(Y!=null&&Y.clientHeight)){const Z=Y.clientWidth*1,fe=Y.clientHeight*1;o.value.scale.set(Z,fe,1),J.value=!0}he.value.lookAt((ie=b.value)==null?void 0:ie.position)}});const ce=h.computed(()=>({vertexShader:d.value?void 0:hc,fragmentShader:uc})),U=h.computed(()=>{const T=ce.value;return l.value||new c.ShaderMaterial({vertexShader:T.vertexShader,fragmentShader:T.fragmentShader,side:c.DoubleSide})});return h.onUnmounted(()=>{U.value&&U.value.dispose()}),(T,m)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"groupRef",ref:i},[h.unref(v)&&!G.value?(h.openBlock(),h.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:o,geometry:h.unref(r),material:U.value},null,8,vc)):h.createCommentVNode("",!0)],512))}}),wc={mounted:(a,e)=>{if(e.arg){console.log(`v-log:${e.arg}`,a[e.arg]);return}console.log("v-log",a)}},{logWarning:Ai}=ne.useLogger(),bc={mounted:a=>{if(!a.isLight){Ai(`${a.type} is not a light`);return}hn=Ac[a.type],a.parent.add(new hn(a))},updated:a=>{Rt=a.parent.children.find(e=>e instanceof hn),Rt.update()},unmounted:a=>{if(!a.isLight){Ai(`${a.type} is not a light`);return}Rt=a.parent.children.find(e=>e instanceof hn),Rt.dispose(),a.parent.remove(Rt)}};let hn,Rt;const Ac={DirectionalLight:c.DirectionalLightHelper,PointLight:c.PointLightHelper,SpotLight:c.SpotLightHelper,HemisphereLight:c.HemisphereLightHelper};function Mc(a,e){const t={};for(const n of e)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n]);return t}function Sc(a,e){const t=`set${e[0].toUpperCase()}${e.slice(1)}`;return a[t]!==void 0}function $n(a){var t,n;let e=a.value;return a.value&&((n=(t=a.value)==null?void 0:t.value)!=null&&n.isMesh)&&(e=a.value.value.position),Array.isArray(a.value)&&(e=new c.Vector3(...e)),e}const{logWarning:Pc}=ne.useLogger(),Cc={updated:(a,e)=>{const t=$n(e);if(!t){Pc(`v-always-look-at: problem with binding value: ${e.value}`);return}const{onLoop:n}=ne.useRenderLoop();n(()=>{a.lookAt(t)})}},{logWarning:Lc}=ne.useLogger(),Tc={updated:(a,e)=>{var s;const t=$n(e);if(!t){Lc(`v-distance-to: problem with binding value: ${e.value}`);return}He&&(He.dispose(),a.parent.remove(He));const n=t.clone().sub(a.position);n.normalize(),He=new c.ArrowHelper(n,a.position,a.position.distanceTo(t)/1.5,16776960),a.parent.add(He),console.table([["Distance:",a.position.distanceTo(t)],[`origin: ${a.name||a.type}`,`x:${a.position.x}, y:${a.position.y}, z:${(s=a.position)==null?void 0:s.z}`],[`Destiny: ${a.name||a.type}`,`x:${t.x}, y:${t.y}, z:${t==null?void 0:t.z}`]])},unmounted:a=>{He==null||He.dispose(),a.parent.remove(He)}};let He=null;q.Backdrop=Bl,q.Box=Ga,q.CameraControls=Ca,q.CatmullRomCurve3=Wa,q.Circle=Ka,q.Cone=Ha,q.ContactShadows=Rl,q.Dodecahedron=tl,q.Environment=Dl,q.FBXModel=ia,q.Fbo=Hr,q.GLTFModel=na,q.GlobalAudio=Fr,q.Html=xc,q.Icosahedron=il,q.KeyboardControls=pa,q.Lensflare=Jr,q.Levioso=mr,q.Line2=_i,q.MapControls=xa,q.MeshGlassMaterial=Va,q.MeshWobbleMaterial=Oa,q.MouseParallax=kr,q.Octahedron=al,q.OrbitControls=ha,q.Plane=ul,q.PointerLockControls=_a,q.Precipitation=Zl,q.Ring=pl,q.SVG=ra,q.ScrollControls=wa,q.Sky=ec,q.Smoke=Hl,q.Sphere=yl,q.Stars=Xl,q.Stats=rc,q.StatsGl=cc,q.Tetrahedron=wl,q.Text3D=fr,q.Torus=Ml,q.TorusKnot=Cl,q.TransformControls=ga,q.Tube=Ol,q.extractBindingPosition=$n,q.hasSetter=Sc,q.pick=Mc,q.useAnimations=pr,q.useEnvironment=Xs,q.useFBO=Es,q.useFBX=Ws,q.useGLTF=Ys,q.useProgress=aa,q.useTweakPane=tc,q.useVideoTexture=la,q.vAlwaysLookAt=Cc,q.vDistanceTo=Tc,q.vLightHelper=bc,q.vLog=wc,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});