@tresjs/cientos 3.2.0 → 3.2.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.2.0
3
+ * version: v3.2.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(U,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):(U=typeof globalThis<"u"?globalThis:U||self,u(U.trescientos={},U.Vue,U.Three,U.TresjsCore,U.tweakpane))})(this,function(U,u,c,q,nn){"use strict";var la=Object.defineProperty;var ca=(U,u,c)=>u in U?la(U,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):U[u]=c;var re=(U,u,c)=>(ca(U,typeof u!="symbol"?u+"":u,c),c);function ts(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 ge=Uint8Array,Ie=Uint16Array,xt=Uint32Array,ss=new ge([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]),ns=new ge([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]),on=new ge([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),is=function(l,e){for(var t=new Ie(31),s=0;s<31;++s)t[s]=e+=1<<l[s-1];for(var n=new xt(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]},os=is(ss,2),rs=os[0],rn=os[1];rs[28]=258,rn[258]=28;for(var an=is(ns,0),ln=an[0],vt=new Ie(32768),ne=0;ne<32768;++ne){var Fe=(ne&43690)>>>1|(ne&21845)<<1;Fe=(Fe&52428)>>>2|(Fe&13107)<<2,Fe=(Fe&61680)>>>4|(Fe&3855)<<4,vt[ne]=((Fe&65280)>>>8|(Fe&255)<<8)>>>1}for(var tt=function(l,e,t){for(var s=l.length,n=0,i=new Ie(e);n<s;++n)++i[l[n]-1];var o=new Ie(e);for(n=0;n<e;++n)o[n]=o[n-1]+i[n-1]<<1;var r;if(t){r=new Ie(1<<e);var a=15-e;for(n=0;n<s;++n)if(l[n])for(var h=n<<4|l[n],p=e-l[n],d=o[l[n]-1]++<<p,m=d|(1<<p)-1;d<=m;++d)r[vt[d]>>>a]=h}else for(r=new Ie(s),n=0;n<s;++n)l[n]&&(r[n]=vt[o[l[n]-1]++]>>>15-l[n]);return r},st=new ge(288),ne=0;ne<144;++ne)st[ne]=8;for(var ne=144;ne<256;++ne)st[ne]=9;for(var ne=256;ne<280;++ne)st[ne]=7;for(var ne=280;ne<288;++ne)st[ne]=8;for(var as=new ge(32),ne=0;ne<32;++ne)as[ne]=5;var cn=tt(st,9,1),hn=tt(as,5,1),At=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},Mt=function(l,e){var t=e/8|0;return(l[t]|l[t+1]<<8|l[t+2]<<16)>>(e&7)},un=function(l){return(l/8|0)+(l&7&&1)},pn=function(l,e,t){(e==null||e<0)&&(e=0),(t==null||t>l.length)&&(t=l.length);var s=new(l instanceof Ie?Ie:l instanceof xt?xt:ge)(t-e);return s.set(l.subarray(e,t)),s},dn=function(l,e,t){var s=l.length;if(!s||t&&!t.l&&s<5)return e||new ge(0);var n=!e||t,i=!t||t.i;t||(t={}),e||(e=new ge(s*3));var o=function(xe){var Se=e.length;if(xe>Se){var Ne=new ge(Math.max(Se*2,xe));Ne.set(e),e=Ne}},r=t.f||0,a=t.p||0,h=t.b||0,p=t.l,d=t.d,m=t.m,f=t.n,w=s*8;do{if(!p){t.f=r=ve(l,a,1);var y=ve(l,a+1,3);if(a+=3,y)if(y==1)p=cn,d=hn,m=9,f=5;else if(y==2){var b=ve(l,a,31)+257,g=ve(l,a+10,15)+4,S=b+ve(l,a+5,31)+1;a+=14;for(var A=new ge(S),_=new ge(19),x=0;x<g;++x)_[on[x]]=ve(l,a+x*3,7);a+=g*3;for(var D=At(_),F=(1<<D)-1,I=tt(_,D,1),x=0;x<S;){var B=I[ve(l,a,F)];a+=B&15;var v=B>>>4;if(v<16)A[x++]=v;else{var R=0,H=0;for(v==16?(H=3+ve(l,a,3),a+=2,R=A[x-1]):v==17?(H=3+ve(l,a,7),a+=3):v==18&&(H=11+ve(l,a,127),a+=7);H--;)A[x++]=R}}var G=A.subarray(0,b),se=A.subarray(b);m=At(G),f=At(se),p=tt(G,m,1),d=tt(se,f,1)}else throw"invalid block type";else{var v=un(a)+4,M=l[v-4]|l[v-3]<<8,L=v+M;if(L>s){if(i)throw"unexpected EOF";break}n&&o(h+M),e.set(l.subarray(v,L),h),t.b=h+=M,t.p=a=L*8;continue}if(a>w){if(i)throw"unexpected EOF";break}}n&&o(h+131072);for(var X=(1<<m)-1,le=(1<<f)-1,oe=a;;oe=a){var R=p[Mt(l,a)&X],$=R>>>4;if(a+=R&15,a>w){if(i)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if($<256)e[h++]=$;else if($==256){oe=a,p=null;break}else{var Q=$-254;if($>264){var x=$-257,K=ss[x];Q=ve(l,a,(1<<K)-1)+rs[x],a+=K}var he=d[Mt(l,a)&le],C=he>>>4;if(!he)throw"invalid distance";a+=he&15;var se=ln[C];if(C>3){var K=ns[C];se+=Mt(l,a)&(1<<K)-1,a+=K}if(a>w){if(i)throw"unexpected EOF";break}n&&o(h+131072);for(var fe=h+Q;h<fe;h+=4)e[h]=e[h-se],e[h+1]=e[h+1-se],e[h+2]=e[h+2-se],e[h+3]=e[h+3-se];h=fe}}t.l=p,t.p=oe,t.b=h,p&&(r=1,t.m=m,t.d=d,t.n=f)}while(!r);return h==e.length?e:pn(e,0,h)},mn=new ge(0),fn=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 gn(l,e){return dn((fn(l),l.subarray(2,-4)),e)}var yn=typeof TextDecoder<"u"&&new TextDecoder,_n=0;try{yn.decode(mn,{stream:!0}),_n=1}catch{}var wn=Object.defineProperty,xn=(l,e,t)=>e in l?wn(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,O=(l,e,t)=>(xn(l,typeof e!="symbol"?e+"":e,t),t);class vn extends c.Object3D{constructor(e,t){super(),O(this,"isTransformControls",!0),O(this,"visible",!1),O(this,"domElement"),O(this,"raycaster",new c.Raycaster),O(this,"gizmo"),O(this,"plane"),O(this,"tempVector",new c.Vector3),O(this,"tempVector2",new c.Vector3),O(this,"tempQuaternion",new c.Quaternion),O(this,"unit",{X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)}),O(this,"pointStart",new c.Vector3),O(this,"pointEnd",new c.Vector3),O(this,"offset",new c.Vector3),O(this,"rotationAxis",new c.Vector3),O(this,"startNorm",new c.Vector3),O(this,"endNorm",new c.Vector3),O(this,"rotationAngle",0),O(this,"cameraPosition",new c.Vector3),O(this,"cameraQuaternion",new c.Quaternion),O(this,"cameraScale",new c.Vector3),O(this,"parentPosition",new c.Vector3),O(this,"parentQuaternion",new c.Quaternion),O(this,"parentQuaternionInv",new c.Quaternion),O(this,"parentScale",new c.Vector3),O(this,"worldPositionStart",new c.Vector3),O(this,"worldQuaternionStart",new c.Quaternion),O(this,"worldScaleStart",new c.Vector3),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"worldQuaternionInv",new c.Quaternion),O(this,"worldScale",new c.Vector3),O(this,"eye",new c.Vector3),O(this,"positionStart",new c.Vector3),O(this,"quaternionStart",new c.Quaternion),O(this,"scaleStart",new c.Vector3),O(this,"camera"),O(this,"object"),O(this,"enabled",!0),O(this,"axis",null),O(this,"mode","translate"),O(this,"translationSnap",null),O(this,"rotationSnap",null),O(this,"scaleSnap",null),O(this,"space","world"),O(this,"size",1),O(this,"dragging",!1),O(this,"showX",!0),O(this,"showY",!0),O(this,"showZ",!0),O(this,"changeEvent",{type:"change"}),O(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),O(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),O(this,"objectChangeEvent",{type:"objectChange"}),O(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}),O(this,"attach",n=>(this.object=n,this.visible=!0,this)),O(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),O(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),O(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()}),O(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}),O(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)}}),O(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 p=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(p*=-1),this.tempVector2.set(p,p,p)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),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 p=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))*p):(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())*p),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)}}),O(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)}),O(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}}}),O(this,"onPointerHover",n=>{if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(n));break}}),O(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)))}),O(this,"onPointerMove",n=>{this.enabled&&this.pointerMove(this.getPointer(n))}),O(this,"onPointerUp",n=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(n)))}),O(this,"getMode",()=>this.mode),O(this,"setMode",n=>{this.mode=n}),O(this,"setTranslationSnap",n=>{this.translationSnap=n}),O(this,"setRotationSnap",n=>{this.rotationSnap=n}),O(this,"setScaleSnap",n=>{this.scaleSnap=n}),O(this,"setSize",n=>{this.size=n}),O(this,"setSpace",n=>{this.space=n}),O(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),O(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)}),O(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(p=>{const d=p;d.geometry&&d.geometry.dispose(),d.material&&d.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new An,this.add(this.gizmo),this.plane=new Mn,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 An extends c.Object3D{constructor(){super(),O(this,"isTransformControlsGizmo",!0),O(this,"type","TransformControlsGizmo"),O(this,"tempVector",new c.Vector3(0,0,0)),O(this,"tempEuler",new c.Euler),O(this,"alignVector",new c.Vector3(0,1,0)),O(this,"zeroVector",new c.Vector3(0,0,0)),O(this,"lookAtMatrix",new c.Matrix4),O(this,"tempQuaternion",new c.Quaternion),O(this,"tempQuaternion2",new c.Quaternion),O(this,"identityQuaternion",new c.Quaternion),O(this,"unitX",new c.Vector3(1,0,0)),O(this,"unitY",new c.Vector3(0,1,0)),O(this,"unitZ",new c.Vector3(0,0,1)),O(this,"gizmo"),O(this,"picker"),O(this,"helper"),O(this,"rotationAxis",new c.Vector3),O(this,"cameraPosition",new c.Vector3),O(this,"worldPositionStart",new c.Vector3),O(this,"worldQuaternionStart",new c.Quaternion),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"eye",new c.Vector3),O(this,"camera",null),O(this,"enabled",!0),O(this,"axis",null),O(this,"mode","translate"),O(this,"space","world"),O(this,"size",1),O(this,"dragging",!1),O(this,"showX",!0),O(this,"showY",!0),O(this,"showZ",!0),O(this,"updateMatrixWorld",()=>{let $=this.space;this.mode==="scale"&&($="local");const Q=$==="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 K=[];K=K.concat(this.picker[this.mode].children),K=K.concat(this.gizmo[this.mode].children),K=K.concat(this.helper[this.mode].children);for(let he=0;he<K.length;he++){const C=K[he];C.visible=!0,C.rotation.set(0,0,0),C.position.copy(this.worldPosition);let fe;if(this.camera.isOrthographicCamera?fe=(this.camera.top-this.camera.bottom)/this.camera.zoom:fe=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),C.scale.set(1,1,1).multiplyScalar(fe*this.size/7),C.tag==="helper"){C.visible=!1,C.name==="AXIS"?(C.position.copy(this.worldPositionStart),C.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),C.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),C.quaternion.multiply(this.tempQuaternion),C.visible=this.dragging),this.axis==="E"&&(C.visible=!1)):C.name==="START"?(C.position.copy(this.worldPositionStart),C.visible=this.dragging):C.name==="END"?(C.position.copy(this.worldPosition),C.visible=this.dragging):C.name==="DELTA"?(C.position.copy(this.worldPositionStart),C.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()),C.scale.copy(this.tempVector),C.visible=this.dragging):(C.quaternion.copy(Q),this.dragging?C.position.copy(this.worldPositionStart):C.position.copy(this.worldPosition),this.axis&&(C.visible=this.axis.search(C.name)!==-1));continue}C.quaternion.copy(Q),this.mode==="translate"||this.mode==="scale"?((C.name==="X"||C.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),(C.name==="Y"||C.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),(C.name==="Z"||C.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.x*=-1:C.tag==="bwd"&&(C.visible=!1)),C.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.y*=-1:C.tag==="bwd"&&(C.visible=!1)),C.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.z*=-1:C.tag==="bwd"&&(C.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(Q),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(Q).invert()),C.name.search("E")!==-1&&C.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),C.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion)),C.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion)),C.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion))),C.visible=C.visible&&(C.name.indexOf("X")===-1||this.showX),C.visible=C.visible&&(C.name.indexOf("Y")===-1||this.showY),C.visible=C.visible&&(C.name.indexOf("Z")===-1||this.showZ),C.visible=C.visible&&(C.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),C.material.tempOpacity=C.material.tempOpacity||C.material.opacity,C.material.tempColor=C.material.tempColor||C.material.color.clone(),C.material.color.copy(C.material.tempColor),C.material.opacity=C.material.tempOpacity,this.enabled?this.axis&&(C.name===this.axis?(C.material.opacity=1,C.material.color.lerp(new c.Color(1,1,1),.5)):this.axis.split("").some(function(xe){return C.name===xe})?(C.material.opacity=1,C.material.color.lerp(new c.Color(1,1,1),.5)):(C.material.opacity*=.25,C.material.color.lerp(new c.Color(1,1,1),.5))):(C.material.opacity*=.5,C.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 p=a.clone();p.color.set(65535);const d=a.clone();d.color.set(16711935),e.clone().color.set(16776960);const f=t.clone();f.color.set(16711680);const w=t.clone();w.color.set(65280);const y=t.clone();y.color.set(255);const v=t.clone();v.color.set(65535);const M=t.clone();M.color.set(16711935);const L=t.clone();L.color.set(16776960);const b=t.clone();b.color.set(7895160);const g=L.clone();g.opacity=.25;const S=new c.CylinderGeometry(0,.05,.2,12,1,!1),A=new c.BoxGeometry(.125,.125,.125),_=new c.BufferGeometry;_.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3));const x=($,Q)=>{const K=new c.BufferGeometry,he=[];for(let C=0;C<=64*Q;++C)he.push(0,Math.cos(C/32*Math.PI)*$,Math.sin(C/32*Math.PI)*$);return K.setAttribute("position",new c.Float32BufferAttribute(he,3)),K},D=()=>{const $=new c.BufferGeometry;return $.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),$},F={X:[[new c.Mesh(S,i),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new c.Mesh(S,i),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new c.Line(_,f)]],Y:[[new c.Mesh(S,o),[0,1,0],null,null,"fwd"],[new c.Mesh(S,o),[0,1,0],[Math.PI,0,0],null,"bwd"],[new c.Line(_,w),null,[0,0,Math.PI/2]]],Z:[[new c.Mesh(S,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new c.Mesh(S,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new c.Line(_,y),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(_,L),[.18,.3,0],null,[.125,1,1]],[new c.Line(_,L),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),p.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new c.Line(_,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(_,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new c.Line(_,M),[.18,0,.3],null,[.125,1,1]],[new c.Line(_,M),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={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]]]},B={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(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={X:[[new c.Line(x(1,.5),f)],[new c.Mesh(new c.OctahedronGeometry(.04,0),i),[0,0,.99],null,[1,3,1]]],Y:[[new c.Line(x(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(x(1,.5),y),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(x(1.25,1),g),null,[0,Math.PI/2,0]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new c.Line(x(1,1),b),null,[0,Math.PI/2,0]]]},H={AXIS:[[new c.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},G={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)]]},se={X:[[new c.Mesh(A,i),[.8,0,0],[0,0,-Math.PI/2]],[new c.Line(_,f),null,null,[.8,1,1]]],Y:[[new c.Mesh(A,o),[0,.8,0]],[new c.Line(_,w),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new c.Mesh(A,r),[0,0,.8],[Math.PI/2,0,0]],[new c.Line(_,y),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new c.Mesh(A,h),[.85,.85,0],null,[2,2,.2]],[new c.Line(_,L),[.855,.98,0],null,[.125,1,1]],[new c.Line(_,L),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(A,p),[0,.85,.85],null,[.2,2,2]],[new c.Line(_,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(_,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(A,d),[.85,0,.85],null,[2,.2,2]],[new c.Line(_,M),[.855,0,.98],null,[.125,1,1]],[new c.Line(_,M),[.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]]]},X={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(A,s),[.85,.85,0],null,[3,3,.2]]],YZ:[[new c.Mesh(A,s),[0,.85,.85],null,[.2,3,3]]],XZ:[[new c.Mesh(A,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]]]},le={X:[[new c.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},oe=$=>{const Q=new c.Object3D;for(let K in $)for(let he=$[K].length;he--;){const C=$[K][he][0].clone(),fe=$[K][he][1],xe=$[K][he][2],Se=$[K][he][3],Ne=$[K][he][4];C.name=K,C.tag=Ne,fe&&C.position.set(fe[0],fe[1],fe[2]),xe&&C.rotation.set(xe[0],xe[1],xe[2]),Se&&C.scale.set(Se[0],Se[1],Se[2]),C.updateMatrix();const ut=C.geometry.clone();ut.applyMatrix4(C.matrix),C.geometry=ut,C.renderOrder=1/0,C.position.set(0,0,0),C.rotation.set(0,0,0),C.scale.set(1,1,1),Q.add(C)}return Q};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=oe(F)),this.add(this.gizmo.rotate=oe(R)),this.add(this.gizmo.scale=oe(se)),this.add(this.picker.translate=oe(I)),this.add(this.picker.rotate=oe(G)),this.add(this.picker.scale=oe(X)),this.add(this.helper.translate=oe(B)),this.add(this.helper.rotate=oe(H)),this.add(this.helper.scale=oe(le)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class Mn 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})),O(this,"isTransformControlsPlane",!0),O(this,"type","TransformControlsPlane"),O(this,"unitX",new c.Vector3(1,0,0)),O(this,"unitY",new c.Vector3(0,1,0)),O(this,"unitZ",new c.Vector3(0,0,1)),O(this,"tempVector",new c.Vector3),O(this,"dirVector",new c.Vector3),O(this,"alignVector",new c.Vector3),O(this,"tempMatrix",new c.Matrix4),O(this,"identityQuaternion",new c.Quaternion),O(this,"cameraQuaternion",new c.Quaternion),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"eye",new c.Vector3),O(this,"axis",null),O(this,"mode","translate"),O(this,"space","world"),O(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 bn=Object.defineProperty,Sn=(l,e,t)=>e in l?bn(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,ce=(l,e,t)=>(Sn(l,typeof e!="symbol"?e+"":e,t),t);const Qe=new c.Euler(0,0,0,"YXZ"),Ke=new c.Vector3,Tn={type:"change"},Ln={type:"lock"},Cn={type:"unlock"},ls=Math.PI/2;class bt 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",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;Qe.setFromQuaternion(this.camera.quaternion),Qe.y-=n*.002*this.pointerSpeed,Qe.x-=i*.002*this.pointerSpeed,Qe.x=Math.max(ls-this.maxPolarAngle,Math.min(ls-this.minPolarAngle,Qe.x)),this.camera.quaternion.setFromEuler(Qe),this.dispatchEvent(Tn)}),ce(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(Ln),this.isLocked=!0):(this.dispatchEvent(Cn),this.isLocked=!1))}),ce(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),ce(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))}),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",s=>s.copy(this.direction).applyQuaternion(this.camera.quaternion)),ce(this,"moveForward",s=>{Ke.setFromMatrixColumn(this.camera.matrix,0),Ke.crossVectors(this.camera.up,Ke),this.camera.position.addScaledVector(Ke,s)}),ce(this,"moveRight",s=>{Ke.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(Ke,s)}),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 On=Object.defineProperty,Pn=(l,e,t)=>e in l?On(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,E=(l,e,t)=>(Pn(l,typeof e!="symbol"?e+"":e,t),t);const cs=(l,e)=>(l%e+e)%e;class hs extends c.EventDispatcher{constructor(e,t){super(),E(this,"object"),E(this,"domElement"),E(this,"enabled",!0),E(this,"target",new c.Vector3),E(this,"minDistance",0),E(this,"maxDistance",1/0),E(this,"minZoom",0),E(this,"maxZoom",1/0),E(this,"minPolarAngle",0),E(this,"maxPolarAngle",Math.PI),E(this,"minAzimuthAngle",-1/0),E(this,"maxAzimuthAngle",1/0),E(this,"enableDamping",!1),E(this,"dampingFactor",.05),E(this,"enableZoom",!0),E(this,"zoomSpeed",1),E(this,"enableRotate",!0),E(this,"rotateSpeed",1),E(this,"enablePan",!0),E(this,"panSpeed",1),E(this,"screenSpacePanning",!0),E(this,"keyPanSpeed",7),E(this,"autoRotate",!1),E(this,"autoRotateSpeed",2),E(this,"reverseOrbit",!1),E(this,"reverseHorizontalOrbit",!1),E(this,"reverseVerticalOrbit",!1),E(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),E(this,"mouseButtons",{LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN}),E(this,"touches",{ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN}),E(this,"target0"),E(this,"position0"),E(this,"zoom0"),E(this,"_domElementKeyEvents",null),E(this,"getPolarAngle"),E(this,"getAzimuthalAngle"),E(this,"setPolarAngle"),E(this,"setAzimuthalAngle"),E(this,"getDistance"),E(this,"listenToKeyEvents"),E(this,"stopListenToKeyEvents"),E(this,"saveState"),E(this,"reset"),E(this,"update"),E(this,"connect"),E(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=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=T=>{let k=cs(T,2*Math.PI),z=p.phi;z<0&&(z+=2*Math.PI),k<0&&(k+=2*Math.PI);let ee=Math.abs(k-z);2*Math.PI-ee<ee&&(k<z?k+=2*Math.PI:z+=2*Math.PI),d.phi=k-z,s.update()},this.setAzimuthalAngle=T=>{let k=cs(T,2*Math.PI),z=p.theta;z<0&&(z+=2*Math.PI),k<0&&(k+=2*Math.PI);let ee=Math.abs(k-z);2*Math.PI-ee<ee&&(k<z?k+=2*Math.PI:z+=2*Math.PI),d.theta=k-z,s.update()},this.getDistance=()=>s.object.position.distanceTo(s.target),this.listenToKeyEvents=T=>{T.addEventListener("keydown",$t),this._domElementKeyEvents=T},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",$t),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 T=new c.Vector3,k=new c.Vector3(0,1,0),z=new c.Quaternion().setFromUnitVectors(e.up,k),ee=z.clone().invert(),pe=new c.Vector3,Ze=new c.Quaternion,Ve=2*Math.PI;return function(){const sn=s.object.position;z.setFromUnitVectors(e.up,k),ee.copy(z).invert(),T.copy(sn).sub(s.target),T.applyQuaternion(z),p.setFromVector3(T),s.autoRotate&&a===r.NONE&&B(F()),s.enableDamping?(p.theta+=d.theta*s.dampingFactor,p.phi+=d.phi*s.dampingFactor):(p.theta+=d.theta,p.phi+=d.phi);let Pe=s.minAzimuthAngle,De=s.maxAzimuthAngle;return isFinite(Pe)&&isFinite(De)&&(Pe<-Math.PI?Pe+=Ve:Pe>Math.PI&&(Pe-=Ve),De<-Math.PI?De+=Ve:De>Math.PI&&(De-=Ve),Pe<=De?p.theta=Math.max(Pe,Math.min(De,p.theta)):p.theta=p.theta>(Pe+De)/2?Math.max(Pe,p.theta):Math.min(De,p.theta)),p.phi=Math.max(s.minPolarAngle,Math.min(s.maxPolarAngle,p.phi)),p.makeSafe(),p.radius*=m,p.radius=Math.max(s.minDistance,Math.min(s.maxDistance,p.radius)),s.enableDamping===!0?s.target.addScaledVector(f,s.dampingFactor):s.target.add(f),T.setFromSpherical(p),T.applyQuaternion(ee),sn.copy(s.target).add(T),s.object.lookAt(s.target),s.enableDamping===!0?(d.theta*=1-s.dampingFactor,d.phi*=1-s.dampingFactor,f.multiplyScalar(1-s.dampingFactor)):(d.set(0,0,0),f.set(0,0,0)),m=1,w||pe.distanceToSquared(s.object.position)>h||8*(1-Ze.dot(s.object.quaternion))>h?(s.dispatchEvent(n),pe.copy(s.object.position),Ze.copy(s.object.quaternion),w=!1,!0):!1}})(),this.connect=T=>{T===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),s.domElement=T,s.domElement.style.touchAction="none",s.domElement.addEventListener("contextmenu",$s),s.domElement.addEventListener("pointerdown",qs),s.domElement.addEventListener("pointercancel",Js),s.domElement.addEventListener("wheel",Hs)},this.dispose=()=>{var T,k,z,ee,pe,Ze;(T=s.domElement)==null||T.removeEventListener("contextmenu",$s),(k=s.domElement)==null||k.removeEventListener("pointerdown",qs),(z=s.domElement)==null||z.removeEventListener("pointercancel",Js),(ee=s.domElement)==null||ee.removeEventListener("wheel",Hs),(pe=s.domElement)==null||pe.ownerDocument.removeEventListener("pointermove",Jt),(Ze=s.domElement)==null||Ze.ownerDocument.removeEventListener("pointerup",Ht),s._domElementKeyEvents!==null&&s._domElementKeyEvents.removeEventListener("keydown",$t)};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,p=new c.Spherical,d=new c.Spherical;let m=1;const f=new c.Vector3;let w=!1;const y=new c.Vector2,v=new c.Vector2,M=new c.Vector2,L=new c.Vector2,b=new c.Vector2,g=new c.Vector2,S=new c.Vector2,A=new c.Vector2,_=new c.Vector2,x=[],D={};function F(){return 2*Math.PI/60/60*s.autoRotateSpeed}function I(){return Math.pow(.95,s.zoomSpeed)}function B(T){s.reverseOrbit||s.reverseHorizontalOrbit?d.theta+=T:d.theta-=T}function R(T){s.reverseOrbit||s.reverseVerticalOrbit?d.phi+=T:d.phi-=T}const H=(()=>{const T=new c.Vector3;return function(z,ee){T.setFromMatrixColumn(ee,0),T.multiplyScalar(-z),f.add(T)}})(),G=(()=>{const T=new c.Vector3;return function(z,ee){s.screenSpacePanning===!0?T.setFromMatrixColumn(ee,1):(T.setFromMatrixColumn(ee,0),T.crossVectors(s.object.up,T)),T.multiplyScalar(z),f.add(T)}})(),se=(()=>{const T=new c.Vector3;return function(z,ee){const pe=s.domElement;if(pe&&s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera){const Ze=s.object.position;T.copy(Ze).sub(s.target);let Ve=T.length();Ve*=Math.tan(s.object.fov/2*Math.PI/180),H(2*z*Ve/pe.clientHeight,s.object.matrix),G(2*ee*Ve/pe.clientHeight,s.object.matrix)}else pe&&s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(H(z*(s.object.right-s.object.left)/s.object.zoom/pe.clientWidth,s.object.matrix),G(ee*(s.object.top-s.object.bottom)/s.object.zoom/pe.clientHeight,s.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),s.enablePan=!1)}})();function X(T){s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera?m/=T:s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(s.object.zoom=Math.max(s.minZoom,Math.min(s.maxZoom,s.object.zoom*T)),s.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),s.enableZoom=!1)}function le(T){s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera?m*=T:s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(s.object.zoom=Math.max(s.minZoom,Math.min(s.maxZoom,s.object.zoom/T)),s.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),s.enableZoom=!1)}function oe(T){y.set(T.clientX,T.clientY)}function $(T){S.set(T.clientX,T.clientY)}function Q(T){L.set(T.clientX,T.clientY)}function K(T){v.set(T.clientX,T.clientY),M.subVectors(v,y).multiplyScalar(s.rotateSpeed);const k=s.domElement;k&&(B(2*Math.PI*M.x/k.clientHeight),R(2*Math.PI*M.y/k.clientHeight)),y.copy(v),s.update()}function he(T){A.set(T.clientX,T.clientY),_.subVectors(A,S),_.y>0?X(I()):_.y<0&&le(I()),S.copy(A),s.update()}function C(T){b.set(T.clientX,T.clientY),g.subVectors(b,L).multiplyScalar(s.panSpeed),se(g.x,g.y),L.copy(b),s.update()}function fe(T){T.deltaY<0?le(I()):T.deltaY>0&&X(I()),s.update()}function xe(T){let k=!1;switch(T.code){case s.keys.UP:se(0,s.keyPanSpeed),k=!0;break;case s.keys.BOTTOM:se(0,-s.keyPanSpeed),k=!0;break;case s.keys.LEFT:se(s.keyPanSpeed,0),k=!0;break;case s.keys.RIGHT:se(-s.keyPanSpeed,0),k=!0;break}k&&(T.preventDefault(),s.update())}function Se(){if(x.length==1)y.set(x[0].pageX,x[0].pageY);else{const T=.5*(x[0].pageX+x[1].pageX),k=.5*(x[0].pageY+x[1].pageY);y.set(T,k)}}function Ne(){if(x.length==1)L.set(x[0].pageX,x[0].pageY);else{const T=.5*(x[0].pageX+x[1].pageX),k=.5*(x[0].pageY+x[1].pageY);L.set(T,k)}}function ut(){const T=x[0].pageX-x[1].pageX,k=x[0].pageY-x[1].pageY,z=Math.sqrt(T*T+k*k);S.set(0,z)}function $r(){s.enableZoom&&ut(),s.enablePan&&Ne()}function ea(){s.enableZoom&&ut(),s.enableRotate&&Se()}function Qs(T){if(x.length==1)v.set(T.pageX,T.pageY);else{const z=es(T),ee=.5*(T.pageX+z.x),pe=.5*(T.pageY+z.y);v.set(ee,pe)}M.subVectors(v,y).multiplyScalar(s.rotateSpeed);const k=s.domElement;k&&(B(2*Math.PI*M.x/k.clientHeight),R(2*Math.PI*M.y/k.clientHeight)),y.copy(v)}function Ks(T){if(x.length==1)b.set(T.pageX,T.pageY);else{const k=es(T),z=.5*(T.pageX+k.x),ee=.5*(T.pageY+k.y);b.set(z,ee)}g.subVectors(b,L).multiplyScalar(s.panSpeed),se(g.x,g.y),L.copy(b)}function Ws(T){const k=es(T),z=T.pageX-k.x,ee=T.pageY-k.y,pe=Math.sqrt(z*z+ee*ee);A.set(0,pe),_.set(0,Math.pow(A.y/S.y,s.zoomSpeed)),X(_.y),S.copy(A)}function ta(T){s.enableZoom&&Ws(T),s.enablePan&&Ks(T)}function sa(T){s.enableZoom&&Ws(T),s.enableRotate&&Qs(T)}function qs(T){var k,z;s.enabled!==!1&&(x.length===0&&((k=s.domElement)==null||k.ownerDocument.addEventListener("pointermove",Jt),(z=s.domElement)==null||z.ownerDocument.addEventListener("pointerup",Ht)),aa(T),T.pointerType==="touch"?oa(T):na(T))}function Jt(T){s.enabled!==!1&&(T.pointerType==="touch"?ra(T):ia(T))}function Ht(T){var k,z,ee;en(T),x.length===0&&((k=s.domElement)==null||k.releasePointerCapture(T.pointerId),(z=s.domElement)==null||z.ownerDocument.removeEventListener("pointermove",Jt),(ee=s.domElement)==null||ee.ownerDocument.removeEventListener("pointerup",Ht)),s.dispatchEvent(o),a=r.NONE}function Js(T){en(T)}function na(T){let k;switch(T.button){case 0:k=s.mouseButtons.LEFT;break;case 1:k=s.mouseButtons.MIDDLE;break;case 2:k=s.mouseButtons.RIGHT;break;default:k=-1}switch(k){case c.MOUSE.DOLLY:if(s.enableZoom===!1)return;$(T),a=r.DOLLY;break;case c.MOUSE.ROTATE:if(T.ctrlKey||T.metaKey||T.shiftKey){if(s.enablePan===!1)return;Q(T),a=r.PAN}else{if(s.enableRotate===!1)return;oe(T),a=r.ROTATE}break;case c.MOUSE.PAN:if(T.ctrlKey||T.metaKey||T.shiftKey){if(s.enableRotate===!1)return;oe(T),a=r.ROTATE}else{if(s.enablePan===!1)return;Q(T),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&s.dispatchEvent(i)}function ia(T){if(s.enabled!==!1)switch(a){case r.ROTATE:if(s.enableRotate===!1)return;K(T);break;case r.DOLLY:if(s.enableZoom===!1)return;he(T);break;case r.PAN:if(s.enablePan===!1)return;C(T);break}}function Hs(T){s.enabled===!1||s.enableZoom===!1||a!==r.NONE&&a!==r.ROTATE||(T.preventDefault(),s.dispatchEvent(i),fe(T),s.dispatchEvent(o))}function $t(T){s.enabled===!1||s.enablePan===!1||xe(T)}function oa(T){switch(tn(T),x.length){case 1:switch(s.touches.ONE){case c.TOUCH.ROTATE:if(s.enableRotate===!1)return;Se(),a=r.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(s.enablePan===!1)return;Ne(),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;$r(),a=r.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(s.enableZoom===!1&&s.enableRotate===!1)return;ea(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&s.dispatchEvent(i)}function ra(T){switch(tn(T),a){case r.TOUCH_ROTATE:if(s.enableRotate===!1)return;Qs(T),s.update();break;case r.TOUCH_PAN:if(s.enablePan===!1)return;Ks(T),s.update();break;case r.TOUCH_DOLLY_PAN:if(s.enableZoom===!1&&s.enablePan===!1)return;ta(T),s.update();break;case r.TOUCH_DOLLY_ROTATE:if(s.enableZoom===!1&&s.enableRotate===!1)return;sa(T),s.update();break;default:a=r.NONE}}function $s(T){s.enabled!==!1&&T.preventDefault()}function aa(T){x.push(T)}function en(T){delete D[T.pointerId];for(let k=0;k<x.length;k++)if(x[k].pointerId==T.pointerId){x.splice(k,1);return}}function tn(T){let k=D[T.pointerId];k===void 0&&(k=new c.Vector2,D[T.pointerId]=k),k.set(T.pageX,T.pageY)}function es(T){const k=T.pointerId===x[0].pointerId?x[1]:x[0];return D[k.pointerId]}t!==void 0&&this.connect(t),this.update()}}class Dn extends hs{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 In extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Nn(t)}),this.register(function(t){return new Xn(t)}),this.register(function(t){return new Zn(t)}),this.register(function(t){return new Qn(t)}),this.register(function(t){return new En(t)}),this.register(function(t){return new zn(t)}),this.register(function(t){return new Rn(t)}),this.register(function(t){return new Gn(t)}),this.register(function(t){return new Un(t)}),this.register(function(t){return new Yn(t)}),this.register(function(t){return new Vn(t)}),this.register(function(t){return new jn(t)}),this.register(function(t){return new kn(t)}),this.register(function(t){return new Kn(t)}),this.register(function(t){return new Wn(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(p){t(p),i.manager.itemEnd(e)},r)}catch(p){r(p)}},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)))===us){try{o[Z.KHR_BINARY_GLTF]=new qn(e)}catch(p){n&&n(p);return}i=JSON.parse(o[Z.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 ci(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 p=this.pluginCallbacks[h](a);r[p.name]=p,o[p.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const p=i.extensionsUsed[h],d=i.extensionsRequired||[];switch(p){case Z.KHR_MATERIALS_UNLIT:o[p]=new Bn;break;case Z.KHR_DRACO_MESH_COMPRESSION:o[p]=new Jn(i,this.dracoLoader);break;case Z.KHR_TEXTURE_TRANSFORM:o[p]=new Hn;break;case Z.KHR_MESH_QUANTIZATION:o[p]=new $n;break;default:d.indexOf(p)>=0&&r[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}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 Fn(){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 Z={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 kn{constructor(e){this.parser=e,this.name=Z.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 p=new c.Color(16777215);a.color!==void 0&&p.fromArray(a.color);const d=a.range!==void 0?a.range:0;switch(a.type){case"directional":h=new c.DirectionalLight(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new c.PointLight(p),h.distance=d;break;case"spot":h=new c.SpotLight(p),h.distance=d,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,Be(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 Bn{constructor(){this.name=Z.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 Un{constructor(e){this.parser=e,this.name=Z.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 Nn{constructor(e){this.parser=e,this.name=Z.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 Vn{constructor(e){this.parser=e,this.name=Z.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 En{constructor(e){this.parser=e,this.name=Z.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 zn{constructor(e){this.parser=e,this.name=Z.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 Rn{constructor(e){this.parser=e,this.name=Z.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 Gn{constructor(e){this.parser=e,this.name=Z.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 Yn{constructor(e){this.parser=e,this.name=Z.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 jn{constructor(e){this.parser=e,this.name=Z.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 Xn{constructor(e){this.parser=e,this.name=Z.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 Zn{constructor(e){this.parser=e,this.name=Z.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 Qn{constructor(e){this.parser=e,this.name=Z.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 Kn{constructor(e){this.name=Z.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,p=n.count,d=n.byteStride,m=new Uint8Array(r,a,h);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(p,d,m,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(p*d);return o.decodeGltfBuffer(new Uint8Array(f),p,d,m,n.mode,n.filter),f})})}else return null}}class Wn{constructor(e){this.name=Z.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!==ye.TRIANGLES&&h.mode!==ye.TRIANGLE_STRIP&&h.mode!==ye.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(p=>(a[h]=p,a[h])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(h=>{const p=h.pop(),d=p.isGroup?p.children:[p],m=h[0].count,f=[];for(const w of d){const y=new c.Matrix4,v=new c.Vector3,M=new c.Quaternion,L=new c.Vector3(1,1,1),b=new c.InstancedMesh(w.geometry,w.material,m);for(let g=0;g<m;g++)a.TRANSLATION&&v.fromBufferAttribute(a.TRANSLATION,g),a.ROTATION&&M.fromBufferAttribute(a.ROTATION,g),a.SCALE&&L.fromBufferAttribute(a.SCALE,g),b.setMatrixAt(g,y.compose(v,M,L));for(const g in a)g!=="TRANSLATION"&&g!=="ROTATION"&&g!=="SCALE"&&w.geometry.setAttribute(g,a[g]);c.Object3D.prototype.copy.call(b,w),this.parser.assignFinalMaterial(b),f.push(b)}return p.isGroup?(p.clear(),p.add(...f),p):f[0]}))}}const us="glTF",nt=12,ps={JSON:1313821514,BIN:5130562};class qn{constructor(e){this.name=Z.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,nt);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!==us)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-nt,n=new DataView(e,nt);let i=0;for(;i<s;){const o=n.getUint32(i,!0);i+=4;const r=n.getUint32(i,!0);if(i+=4,r===ps.JSON){const a=new Uint8Array(e,nt+i,o);this.content=c.LoaderUtils.decodeText(a)}else if(r===ps.BIN){const a=nt+i;this.body=e.slice(a,a+o)}i+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Jn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Z.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 p in o){const d=Tt[p]||p.toLowerCase();r[d]=o[p]}for(const p in e.attributes){const d=Tt[p]||p.toLowerCase();if(o[p]!==void 0){const m=s.accessors[e.attributes[p]],f=We[m.componentType];h[d]=f.name,a[d]=m.normalized===!0}}return t.getDependency("bufferView",i).then(function(p){return new Promise(function(d){n.decodeDracoFile(p,function(m){for(const f in m.attributes){const w=m.attributes[f],y=a[f];y!==void 0&&(w.normalized=y)}d(m)},r,h)})})}}class Hn{constructor(){this.name=Z.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 $n{constructor(){this.name=Z.KHR_MESH_QUANTIZATION}}class ds 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,p=n-t,d=(s-t)/p,m=d*d,f=m*d,w=e*h,y=w-h,v=-2*f+3*m,M=f-m,L=1-v,b=M-m+d;for(let g=0;g!==r;g++){const S=o[y+g+r],A=o[y+g+a]*p,_=o[w+g+r],x=o[w+g]*p;i[g]=L*S+b*A+v*_+M*x}return i}}const ei=new c.Quaternion;class ti extends ds{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return ei.fromArray(i).normalize().toArray(i),i}}const ye={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},We={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},fs={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},St={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Tt={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"},ke={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},si={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},Lt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ni(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 Ee(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 Be(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 ii(l,e,t){let s=!1,n=!1,i=!1;for(let h=0,p=e.length;h<p;h++){const d=e[h];if(d.POSITION!==void 0&&(s=!0),d.NORMAL!==void 0&&(n=!0),d.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,p=e.length;h<p;h++){const d=e[h];if(s){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):l.attributes.position;o.push(m)}if(n){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):l.attributes.normal;r.push(m)}if(i){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):l.attributes.color;a.push(m)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a)]).then(function(h){const p=h[0],d=h[1],m=h[2];return s&&(l.morphAttributes.position=p),n&&(l.morphAttributes.normal=d),i&&(l.morphAttributes.color=m),l.morphTargetsRelative=!0,l})}function oi(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[Z.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ct(t.attributes):e=l.indices+":"+Ct(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+Ct(l.targets[s]);return e}function Ct(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 Ot(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 ai(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 li=new c.Matrix4;class ci{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Fn,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=!1,i=-1;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:{}};Ee(i,r,n),Be(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,p]of o.children.entries())i(p,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[Z.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=St[n.type],r=We[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=St[n.type],h=We[n.componentType],p=h.BYTES_PER_ELEMENT,d=p*a,m=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,w=n.normalized===!0;let y,v;if(f&&f!==d){const M=Math.floor(m/f),L="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+M+":"+n.count;let b=t.cache.get(L);b||(y=new h(r,M*f,n.count*f/p),b=new c.InterleavedBuffer(y,f/p),t.cache.add(L,b)),v=new c.InterleavedBufferAttribute(b,a,m%f/p,w)}else r===null?y=new h(n.count*a):y=new h(r,m,n.count*a),v=new c.BufferAttribute(y,a,w);if(n.sparse!==void 0){const M=St.SCALAR,L=We[n.sparse.indices.componentType],b=n.sparse.indices.byteOffset||0,g=n.sparse.values.byteOffset||0,S=new L(o[1],b,n.sparse.count*M),A=new h(o[2],g,n.sparse.count*a);r!==null&&(v=new c.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let _=0,x=S.length;_<x;_++){const D=S[_];if(v.setX(D,A[_*a]),a>=2&&v.setY(D,A[_*a+1]),a>=3&&v.setZ(D,A[_*a+2]),a>=4&&v.setW(D,A[_*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}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(p){p.flipY=!1,p.name=o.name||r.name||"",p.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(p.name=r.uri);const m=(i.samplers||{})[o.sampler]||{};return p.magFilter=ms[m.magFilter]||c.LinearFilter,p.minFilter=ms[m.minFilter]||c.LinearMipmapLinearFilter,p.wrapS=fs[m.wrapS]||c.RepeatWrapping,p.wrapT=fs[m.wrapT]||c.RepeatWrapping,n.associations.set(p,{textures:e}),p}).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(d=>d.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(d){h=!0;const m=new Blob([d],{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 p=Promise.resolve(a).then(function(d){return new Promise(function(m,f){let w=m;t.isImageBitmapLoader===!0&&(w=function(y){const v=new c.Texture(y);v.needsUpdate=!0,m(v)}),t.load(c.LoaderUtils.resolveURL(d,i.path),w,void 0,f)})}).then(function(d){return h===!0&&r.revokeObjectURL(a),d.userData.mimeType=o.mimeType||ai(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),d});return this.sourceCache[e]=p,p}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[Z.KHR_TEXTURE_TRANSFORM]){const r=s.extensions!==void 0?s.extensions[Z.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=i.associations.get(o);o=i.extensions[Z.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[Z.KHR_MATERIALS_UNLIT]){const d=n[Z.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),h.push(d.extendParams(r,i,t))}else{const d=i.pbrMetallicRoughness||{};if(r.color=new c.Color(1,1,1),r.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;r.color.fromArray(m),r.opacity=m[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(r,"map",d.baseColorTexture,3001)),r.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,r.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(r,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(r,"roughnessMap",d.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 p=i.alphaMode||Lt.OPAQUE;if(p===Lt.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,p===Lt.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 d=i.normalTexture.scale;r.normalScale.set(d,d)}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 d=new o(r);return i.name&&(d.name=i.name),Be(d,i),t.associations.set(d,{materials:e}),i.extensions&&Ee(n,d,i),d})}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[Z.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return gs(a,r,t)})}const o=[];for(let r=0,a=e.length;r<a;r++){const h=e[r],p=ri(h),d=n[p];if(d)o.push(d.promise);else{let m;h.extensions&&h.extensions[Z.KHR_DRACO_MESH_COMPRESSION]?m=i(h):m=gs(new c.BufferGeometry,h,t),n[p]={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 p=o[a].material===void 0?ni(this.cache):this.getDependency("material",o[a].material);r.push(p)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(a){const h=a.slice(0,a.length-1),p=a[a.length-1],d=[];for(let f=0,w=p.length;f<w;f++){const y=p[f],v=o[f];let M;const L=h[f];if(v.mode===ye.TRIANGLES||v.mode===ye.TRIANGLE_STRIP||v.mode===ye.TRIANGLE_FAN||v.mode===void 0)M=i.isSkinnedMesh===!0?new c.SkinnedMesh(y,L):new c.Mesh(y,L),M.isSkinnedMesh===!0&&M.normalizeSkinWeights(),v.mode===ye.TRIANGLE_STRIP?M.geometry=ts(M.geometry,c.TriangleStripDrawMode):v.mode===ye.TRIANGLE_FAN&&(M.geometry=ts(M.geometry,c.TriangleFanDrawMode));else if(v.mode===ye.LINES)M=new c.LineSegments(y,L);else if(v.mode===ye.LINE_STRIP)M=new c.Line(y,L);else if(v.mode===ye.LINE_LOOP)M=new c.LineLoop(y,L);else if(v.mode===ye.POINTS)M=new c.Points(y,L);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(M.geometry.morphAttributes).length>0&&oi(M,i),M.name=t.createUniqueName(i.name||"mesh_"+e),Be(M,i),v.extensions&&Ee(n,M,v),t.assignFinalMaterial(M),d.push(M)}for(let f=0,w=d.length;f<w;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return i.extensions&&Ee(n,d[0],i),d[0];const m=new c.Group;i.extensions&&Ee(n,m,i),t.associations.set(m,{meshes:e});for(let f=0,w=d.length;f<w;f++)m.add(d[f]);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)),Be(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,p=o.length;h<p;h++){const d=o[h];if(d){r.push(d);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 p=0,d=s.channels.length;p<d;p++){const m=s.channels[p],f=s.samplers[m.sampler],w=m.target,y=w.node,v=s.parameters!==void 0?s.parameters[f.input]:f.input,M=s.parameters!==void 0?s.parameters[f.output]:f.output;w.node!==void 0&&(i.push(this.getDependency("node",y)),o.push(this.getDependency("accessor",v)),r.push(this.getDependency("accessor",M)),a.push(f),h.push(w))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(r),Promise.all(a),Promise.all(h)]).then(function(p){const d=p[0],m=p[1],f=p[2],w=p[3],y=p[4],v=[];for(let M=0,L=d.length;M<L;M++){const b=d[M],g=m[M],S=f[M],A=w[M],_=y[M];if(b===void 0)continue;b.updateMatrix();let x;switch(ke[_.path]){case ke.weights:x=c.NumberKeyframeTrack;break;case ke.rotation:x=c.QuaternionKeyframeTrack;break;case ke.position:case ke.scale:default:x=c.VectorKeyframeTrack;break}const D=b.name?b.name:b.uuid,F=A.interpolation!==void 0?si[A.interpolation]:c.InterpolateLinear,I=[];ke[_.path]===ke.weights?b.traverse(function(R){R.morphTargetInfluences&&I.push(R.name?R.name:R.uuid)}):I.push(D);let B=S.array;if(S.normalized){const R=Ot(B.constructor),H=new Float32Array(B.length);for(let G=0,se=B.length;G<se;G++)H[G]=B[G]*R;B=H}for(let R=0,H=I.length;R<H;R++){const G=new x(I[R]+"."+ke[_.path],g.array,B,F);A.interpolation==="CUBICSPLINE"&&(G.createInterpolant=function(X){const le=this instanceof c.QuaternionKeyframeTrack?ti:ds;return new le(this.times,this.values,this.getValueSize()/3,X)},G.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),v.push(G)}}return new c.AnimationClip(n,void 0,v)})}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,p=r.length;h<p;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 p=h[0],d=h[1],m=h[2];m!==null&&p.traverse(function(f){f.isSkinnedMesh&&f.bind(m,li)});for(let f=0,w=d.length;f<w;f++)p.add(d[f]);return p})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",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 p;if(i.isBone===!0?p=new c.Bone:h.length>1?p=new c.Group:h.length===1?p=h[0]:p=new c.Object3D,p!==h[0])for(let d=0,m=h.length;d<m;d++)p.add(h[d]);if(i.name&&(p.userData.name=i.name,p.name=o),Be(p,i),i.extensions&&Ee(s,p,i),i.matrix!==void 0){const d=new c.Matrix4;d.fromArray(i.matrix),p.applyMatrix4(d)}else i.translation!==void 0&&p.position.fromArray(i.translation),i.rotation!==void 0&&p.quaternion.fromArray(i.rotation),i.scale!==void 0&&p.scale.fromArray(i.scale);return n.associations.has(p)||n.associations.set(p,{}),n.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new c.Group;s.name&&(i.name=n.createUniqueName(s.name)),Be(i,s),s.extensions&&Ee(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 p=0,d=a.length;p<d;p++)i.add(a[p]);const h=p=>{const d=new Map;for(const[m,f]of n.associations)(m instanceof c.Material||m instanceof c.Texture)&&d.set(m,f);return p.traverse(m=>{const f=n.associations.get(m);f!=null&&d.set(m,f)}),d};return n.associations=h(i),i})}}function hi(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 p=Ot(We[r.componentType]);n.min.multiplyScalar(p),n.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new c.Vector3,a=new c.Vector3;for(let h=0,p=i.length;h<p;h++){const d=i[h];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],f=m.min,w=m.max;if(f!==void 0&&w!==void 0){if(a.setX(Math.max(Math.abs(f[0]),Math.abs(w[0]))),a.setY(Math.max(Math.abs(f[1]),Math.abs(w[1]))),a.setZ(Math.max(Math.abs(f[2]),Math.abs(w[2]))),m.normalized){const y=Ot(We[m.componentType]);a.multiplyScalar(y)}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 gs(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=Tt[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 Be(l,e),hi(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ii(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:p=0,...d}=t;if(o===void 0)super();else{const m=o.generateShapes(e,a,{lineHeight:h,letterSpacing:p});super(m,{...d,bevelEnabled:s,bevelSize:n,bevelThickness:i,depth:r})}this.type="TextGeometry"}}const ui={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
8
+ (function(U,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):(U=typeof globalThis<"u"?globalThis:U||self,u(U.trescientos={},U.Vue,U.Three,U.TresjsCore,U.tweakpane))})(this,function(U,u,c,q,nn){"use strict";var la=Object.defineProperty;var ca=(U,u,c)=>u in U?la(U,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):U[u]=c;var re=(U,u,c)=>(ca(U,typeof u!="symbol"?u+"":u,c),c);function ts(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 ge=Uint8Array,Ie=Uint16Array,xt=Uint32Array,ss=new ge([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]),ns=new ge([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]),on=new ge([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),is=function(l,e){for(var t=new Ie(31),s=0;s<31;++s)t[s]=e+=1<<l[s-1];for(var n=new xt(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]},os=is(ss,2),rs=os[0],rn=os[1];rs[28]=258,rn[258]=28;for(var an=is(ns,0),ln=an[0],vt=new Ie(32768),ne=0;ne<32768;++ne){var ke=(ne&43690)>>>1|(ne&21845)<<1;ke=(ke&52428)>>>2|(ke&13107)<<2,ke=(ke&61680)>>>4|(ke&3855)<<4,vt[ne]=((ke&65280)>>>8|(ke&255)<<8)>>>1}for(var tt=function(l,e,t){for(var s=l.length,n=0,i=new Ie(e);n<s;++n)++i[l[n]-1];var o=new Ie(e);for(n=0;n<e;++n)o[n]=o[n-1]+i[n-1]<<1;var r;if(t){r=new Ie(1<<e);var a=15-e;for(n=0;n<s;++n)if(l[n])for(var h=n<<4|l[n],p=e-l[n],d=o[l[n]-1]++<<p,m=d|(1<<p)-1;d<=m;++d)r[vt[d]>>>a]=h}else for(r=new Ie(s),n=0;n<s;++n)l[n]&&(r[n]=vt[o[l[n]-1]++]>>>15-l[n]);return r},st=new ge(288),ne=0;ne<144;++ne)st[ne]=8;for(var ne=144;ne<256;++ne)st[ne]=9;for(var ne=256;ne<280;++ne)st[ne]=7;for(var ne=280;ne<288;++ne)st[ne]=8;for(var as=new ge(32),ne=0;ne<32;++ne)as[ne]=5;var cn=tt(st,9,1),hn=tt(as,5,1),At=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},Mt=function(l,e){var t=e/8|0;return(l[t]|l[t+1]<<8|l[t+2]<<16)>>(e&7)},un=function(l){return(l/8|0)+(l&7&&1)},pn=function(l,e,t){(e==null||e<0)&&(e=0),(t==null||t>l.length)&&(t=l.length);var s=new(l instanceof Ie?Ie:l instanceof xt?xt:ge)(t-e);return s.set(l.subarray(e,t)),s},dn=function(l,e,t){var s=l.length;if(!s||t&&!t.l&&s<5)return e||new ge(0);var n=!e||t,i=!t||t.i;t||(t={}),e||(e=new ge(s*3));var o=function(xe){var Se=e.length;if(xe>Se){var Ne=new ge(Math.max(Se*2,xe));Ne.set(e),e=Ne}},r=t.f||0,a=t.p||0,h=t.b||0,p=t.l,d=t.d,m=t.m,f=t.n,w=s*8;do{if(!p){t.f=r=ve(l,a,1);var y=ve(l,a+1,3);if(a+=3,y)if(y==1)p=cn,d=hn,m=9,f=5;else if(y==2){var b=ve(l,a,31)+257,g=ve(l,a+10,15)+4,S=b+ve(l,a+5,31)+1;a+=14;for(var A=new ge(S),_=new ge(19),x=0;x<g;++x)_[on[x]]=ve(l,a+x*3,7);a+=g*3;for(var D=At(_),k=(1<<D)-1,I=tt(_,D,1),x=0;x<S;){var B=I[ve(l,a,k)];a+=B&15;var v=B>>>4;if(v<16)A[x++]=v;else{var R=0,H=0;for(v==16?(H=3+ve(l,a,3),a+=2,R=A[x-1]):v==17?(H=3+ve(l,a,7),a+=3):v==18&&(H=11+ve(l,a,127),a+=7);H--;)A[x++]=R}}var G=A.subarray(0,b),se=A.subarray(b);m=At(G),f=At(se),p=tt(G,m,1),d=tt(se,f,1)}else throw"invalid block type";else{var v=un(a)+4,M=l[v-4]|l[v-3]<<8,L=v+M;if(L>s){if(i)throw"unexpected EOF";break}n&&o(h+M),e.set(l.subarray(v,L),h),t.b=h+=M,t.p=a=L*8;continue}if(a>w){if(i)throw"unexpected EOF";break}}n&&o(h+131072);for(var X=(1<<m)-1,le=(1<<f)-1,oe=a;;oe=a){var R=p[Mt(l,a)&X],$=R>>>4;if(a+=R&15,a>w){if(i)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if($<256)e[h++]=$;else if($==256){oe=a,p=null;break}else{var Q=$-254;if($>264){var x=$-257,K=ss[x];Q=ve(l,a,(1<<K)-1)+rs[x],a+=K}var he=d[Mt(l,a)&le],C=he>>>4;if(!he)throw"invalid distance";a+=he&15;var se=ln[C];if(C>3){var K=ns[C];se+=Mt(l,a)&(1<<K)-1,a+=K}if(a>w){if(i)throw"unexpected EOF";break}n&&o(h+131072);for(var fe=h+Q;h<fe;h+=4)e[h]=e[h-se],e[h+1]=e[h+1-se],e[h+2]=e[h+2-se],e[h+3]=e[h+3-se];h=fe}}t.l=p,t.p=oe,t.b=h,p&&(r=1,t.m=m,t.d=d,t.n=f)}while(!r);return h==e.length?e:pn(e,0,h)},mn=new ge(0),fn=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 gn(l,e){return dn((fn(l),l.subarray(2,-4)),e)}var yn=typeof TextDecoder<"u"&&new TextDecoder,_n=0;try{yn.decode(mn,{stream:!0}),_n=1}catch{}var wn=Object.defineProperty,xn=(l,e,t)=>e in l?wn(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,O=(l,e,t)=>(xn(l,typeof e!="symbol"?e+"":e,t),t);class vn extends c.Object3D{constructor(e,t){super(),O(this,"isTransformControls",!0),O(this,"visible",!1),O(this,"domElement"),O(this,"raycaster",new c.Raycaster),O(this,"gizmo"),O(this,"plane"),O(this,"tempVector",new c.Vector3),O(this,"tempVector2",new c.Vector3),O(this,"tempQuaternion",new c.Quaternion),O(this,"unit",{X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)}),O(this,"pointStart",new c.Vector3),O(this,"pointEnd",new c.Vector3),O(this,"offset",new c.Vector3),O(this,"rotationAxis",new c.Vector3),O(this,"startNorm",new c.Vector3),O(this,"endNorm",new c.Vector3),O(this,"rotationAngle",0),O(this,"cameraPosition",new c.Vector3),O(this,"cameraQuaternion",new c.Quaternion),O(this,"cameraScale",new c.Vector3),O(this,"parentPosition",new c.Vector3),O(this,"parentQuaternion",new c.Quaternion),O(this,"parentQuaternionInv",new c.Quaternion),O(this,"parentScale",new c.Vector3),O(this,"worldPositionStart",new c.Vector3),O(this,"worldQuaternionStart",new c.Quaternion),O(this,"worldScaleStart",new c.Vector3),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"worldQuaternionInv",new c.Quaternion),O(this,"worldScale",new c.Vector3),O(this,"eye",new c.Vector3),O(this,"positionStart",new c.Vector3),O(this,"quaternionStart",new c.Quaternion),O(this,"scaleStart",new c.Vector3),O(this,"camera"),O(this,"object"),O(this,"enabled",!0),O(this,"axis",null),O(this,"mode","translate"),O(this,"translationSnap",null),O(this,"rotationSnap",null),O(this,"scaleSnap",null),O(this,"space","world"),O(this,"size",1),O(this,"dragging",!1),O(this,"showX",!0),O(this,"showY",!0),O(this,"showZ",!0),O(this,"changeEvent",{type:"change"}),O(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),O(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),O(this,"objectChangeEvent",{type:"objectChange"}),O(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}),O(this,"attach",n=>(this.object=n,this.visible=!0,this)),O(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),O(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),O(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()}),O(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}),O(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)}}),O(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 p=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(p*=-1),this.tempVector2.set(p,p,p)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),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 p=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))*p):(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())*p),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)}}),O(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)}),O(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}}}),O(this,"onPointerHover",n=>{if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(n));break}}),O(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)))}),O(this,"onPointerMove",n=>{this.enabled&&this.pointerMove(this.getPointer(n))}),O(this,"onPointerUp",n=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(n)))}),O(this,"getMode",()=>this.mode),O(this,"setMode",n=>{this.mode=n}),O(this,"setTranslationSnap",n=>{this.translationSnap=n}),O(this,"setRotationSnap",n=>{this.rotationSnap=n}),O(this,"setScaleSnap",n=>{this.scaleSnap=n}),O(this,"setSize",n=>{this.size=n}),O(this,"setSpace",n=>{this.space=n}),O(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),O(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)}),O(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(p=>{const d=p;d.geometry&&d.geometry.dispose(),d.material&&d.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new An,this.add(this.gizmo),this.plane=new Mn,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 An extends c.Object3D{constructor(){super(),O(this,"isTransformControlsGizmo",!0),O(this,"type","TransformControlsGizmo"),O(this,"tempVector",new c.Vector3(0,0,0)),O(this,"tempEuler",new c.Euler),O(this,"alignVector",new c.Vector3(0,1,0)),O(this,"zeroVector",new c.Vector3(0,0,0)),O(this,"lookAtMatrix",new c.Matrix4),O(this,"tempQuaternion",new c.Quaternion),O(this,"tempQuaternion2",new c.Quaternion),O(this,"identityQuaternion",new c.Quaternion),O(this,"unitX",new c.Vector3(1,0,0)),O(this,"unitY",new c.Vector3(0,1,0)),O(this,"unitZ",new c.Vector3(0,0,1)),O(this,"gizmo"),O(this,"picker"),O(this,"helper"),O(this,"rotationAxis",new c.Vector3),O(this,"cameraPosition",new c.Vector3),O(this,"worldPositionStart",new c.Vector3),O(this,"worldQuaternionStart",new c.Quaternion),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"eye",new c.Vector3),O(this,"camera",null),O(this,"enabled",!0),O(this,"axis",null),O(this,"mode","translate"),O(this,"space","world"),O(this,"size",1),O(this,"dragging",!1),O(this,"showX",!0),O(this,"showY",!0),O(this,"showZ",!0),O(this,"updateMatrixWorld",()=>{let $=this.space;this.mode==="scale"&&($="local");const Q=$==="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 K=[];K=K.concat(this.picker[this.mode].children),K=K.concat(this.gizmo[this.mode].children),K=K.concat(this.helper[this.mode].children);for(let he=0;he<K.length;he++){const C=K[he];C.visible=!0,C.rotation.set(0,0,0),C.position.copy(this.worldPosition);let fe;if(this.camera.isOrthographicCamera?fe=(this.camera.top-this.camera.bottom)/this.camera.zoom:fe=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),C.scale.set(1,1,1).multiplyScalar(fe*this.size/7),C.tag==="helper"){C.visible=!1,C.name==="AXIS"?(C.position.copy(this.worldPositionStart),C.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),C.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),C.quaternion.multiply(this.tempQuaternion),C.visible=this.dragging),this.axis==="E"&&(C.visible=!1)):C.name==="START"?(C.position.copy(this.worldPositionStart),C.visible=this.dragging):C.name==="END"?(C.position.copy(this.worldPosition),C.visible=this.dragging):C.name==="DELTA"?(C.position.copy(this.worldPositionStart),C.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()),C.scale.copy(this.tempVector),C.visible=this.dragging):(C.quaternion.copy(Q),this.dragging?C.position.copy(this.worldPositionStart):C.position.copy(this.worldPosition),this.axis&&(C.visible=this.axis.search(C.name)!==-1));continue}C.quaternion.copy(Q),this.mode==="translate"||this.mode==="scale"?((C.name==="X"||C.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),(C.name==="Y"||C.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),(C.name==="Z"||C.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.x*=-1:C.tag==="bwd"&&(C.visible=!1)),C.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.y*=-1:C.tag==="bwd"&&(C.visible=!1)),C.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.z*=-1:C.tag==="bwd"&&(C.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(Q),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(Q).invert()),C.name.search("E")!==-1&&C.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),C.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion)),C.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion)),C.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion))),C.visible=C.visible&&(C.name.indexOf("X")===-1||this.showX),C.visible=C.visible&&(C.name.indexOf("Y")===-1||this.showY),C.visible=C.visible&&(C.name.indexOf("Z")===-1||this.showZ),C.visible=C.visible&&(C.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),C.material.tempOpacity=C.material.tempOpacity||C.material.opacity,C.material.tempColor=C.material.tempColor||C.material.color.clone(),C.material.color.copy(C.material.tempColor),C.material.opacity=C.material.tempOpacity,this.enabled?this.axis&&(C.name===this.axis?(C.material.opacity=1,C.material.color.lerp(new c.Color(1,1,1),.5)):this.axis.split("").some(function(xe){return C.name===xe})?(C.material.opacity=1,C.material.color.lerp(new c.Color(1,1,1),.5)):(C.material.opacity*=.25,C.material.color.lerp(new c.Color(1,1,1),.5))):(C.material.opacity*=.5,C.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 p=a.clone();p.color.set(65535);const d=a.clone();d.color.set(16711935),e.clone().color.set(16776960);const f=t.clone();f.color.set(16711680);const w=t.clone();w.color.set(65280);const y=t.clone();y.color.set(255);const v=t.clone();v.color.set(65535);const M=t.clone();M.color.set(16711935);const L=t.clone();L.color.set(16776960);const b=t.clone();b.color.set(7895160);const g=L.clone();g.opacity=.25;const S=new c.CylinderGeometry(0,.05,.2,12,1,!1),A=new c.BoxGeometry(.125,.125,.125),_=new c.BufferGeometry;_.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3));const x=($,Q)=>{const K=new c.BufferGeometry,he=[];for(let C=0;C<=64*Q;++C)he.push(0,Math.cos(C/32*Math.PI)*$,Math.sin(C/32*Math.PI)*$);return K.setAttribute("position",new c.Float32BufferAttribute(he,3)),K},D=()=>{const $=new c.BufferGeometry;return $.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),$},k={X:[[new c.Mesh(S,i),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new c.Mesh(S,i),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new c.Line(_,f)]],Y:[[new c.Mesh(S,o),[0,1,0],null,null,"fwd"],[new c.Mesh(S,o),[0,1,0],[Math.PI,0,0],null,"bwd"],[new c.Line(_,w),null,[0,0,Math.PI/2]]],Z:[[new c.Mesh(S,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new c.Mesh(S,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new c.Line(_,y),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(_,L),[.18,.3,0],null,[.125,1,1]],[new c.Line(_,L),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),p.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new c.Line(_,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(_,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new c.Line(_,M),[.18,0,.3],null,[.125,1,1]],[new c.Line(_,M),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={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]]]},B={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(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={X:[[new c.Line(x(1,.5),f)],[new c.Mesh(new c.OctahedronGeometry(.04,0),i),[0,0,.99],null,[1,3,1]]],Y:[[new c.Line(x(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(x(1,.5),y),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(x(1.25,1),g),null,[0,Math.PI/2,0]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new c.Line(x(1,1),b),null,[0,Math.PI/2,0]]]},H={AXIS:[[new c.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},G={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)]]},se={X:[[new c.Mesh(A,i),[.8,0,0],[0,0,-Math.PI/2]],[new c.Line(_,f),null,null,[.8,1,1]]],Y:[[new c.Mesh(A,o),[0,.8,0]],[new c.Line(_,w),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new c.Mesh(A,r),[0,0,.8],[Math.PI/2,0,0]],[new c.Line(_,y),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new c.Mesh(A,h),[.85,.85,0],null,[2,2,.2]],[new c.Line(_,L),[.855,.98,0],null,[.125,1,1]],[new c.Line(_,L),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(A,p),[0,.85,.85],null,[.2,2,2]],[new c.Line(_,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(_,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(A,d),[.85,0,.85],null,[2,.2,2]],[new c.Line(_,M),[.855,0,.98],null,[.125,1,1]],[new c.Line(_,M),[.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]]]},X={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(A,s),[.85,.85,0],null,[3,3,.2]]],YZ:[[new c.Mesh(A,s),[0,.85,.85],null,[.2,3,3]]],XZ:[[new c.Mesh(A,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]]]},le={X:[[new c.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},oe=$=>{const Q=new c.Object3D;for(let K in $)for(let he=$[K].length;he--;){const C=$[K][he][0].clone(),fe=$[K][he][1],xe=$[K][he][2],Se=$[K][he][3],Ne=$[K][he][4];C.name=K,C.tag=Ne,fe&&C.position.set(fe[0],fe[1],fe[2]),xe&&C.rotation.set(xe[0],xe[1],xe[2]),Se&&C.scale.set(Se[0],Se[1],Se[2]),C.updateMatrix();const ut=C.geometry.clone();ut.applyMatrix4(C.matrix),C.geometry=ut,C.renderOrder=1/0,C.position.set(0,0,0),C.rotation.set(0,0,0),C.scale.set(1,1,1),Q.add(C)}return Q};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=oe(k)),this.add(this.gizmo.rotate=oe(R)),this.add(this.gizmo.scale=oe(se)),this.add(this.picker.translate=oe(I)),this.add(this.picker.rotate=oe(G)),this.add(this.picker.scale=oe(X)),this.add(this.helper.translate=oe(B)),this.add(this.helper.rotate=oe(H)),this.add(this.helper.scale=oe(le)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class Mn 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})),O(this,"isTransformControlsPlane",!0),O(this,"type","TransformControlsPlane"),O(this,"unitX",new c.Vector3(1,0,0)),O(this,"unitY",new c.Vector3(0,1,0)),O(this,"unitZ",new c.Vector3(0,0,1)),O(this,"tempVector",new c.Vector3),O(this,"dirVector",new c.Vector3),O(this,"alignVector",new c.Vector3),O(this,"tempMatrix",new c.Matrix4),O(this,"identityQuaternion",new c.Quaternion),O(this,"cameraQuaternion",new c.Quaternion),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"eye",new c.Vector3),O(this,"axis",null),O(this,"mode","translate"),O(this,"space","world"),O(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 bn=Object.defineProperty,Sn=(l,e,t)=>e in l?bn(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,ce=(l,e,t)=>(Sn(l,typeof e!="symbol"?e+"":e,t),t);const Qe=new c.Euler(0,0,0,"YXZ"),Ke=new c.Vector3,Tn={type:"change"},Ln={type:"lock"},Cn={type:"unlock"},ls=Math.PI/2;class bt 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",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;Qe.setFromQuaternion(this.camera.quaternion),Qe.y-=n*.002*this.pointerSpeed,Qe.x-=i*.002*this.pointerSpeed,Qe.x=Math.max(ls-this.maxPolarAngle,Math.min(ls-this.minPolarAngle,Qe.x)),this.camera.quaternion.setFromEuler(Qe),this.dispatchEvent(Tn)}),ce(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(Ln),this.isLocked=!0):(this.dispatchEvent(Cn),this.isLocked=!1))}),ce(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),ce(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))}),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",s=>s.copy(this.direction).applyQuaternion(this.camera.quaternion)),ce(this,"moveForward",s=>{Ke.setFromMatrixColumn(this.camera.matrix,0),Ke.crossVectors(this.camera.up,Ke),this.camera.position.addScaledVector(Ke,s)}),ce(this,"moveRight",s=>{Ke.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(Ke,s)}),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 On=Object.defineProperty,Pn=(l,e,t)=>e in l?On(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,E=(l,e,t)=>(Pn(l,typeof e!="symbol"?e+"":e,t),t);const cs=(l,e)=>(l%e+e)%e;class hs extends c.EventDispatcher{constructor(e,t){super(),E(this,"object"),E(this,"domElement"),E(this,"enabled",!0),E(this,"target",new c.Vector3),E(this,"minDistance",0),E(this,"maxDistance",1/0),E(this,"minZoom",0),E(this,"maxZoom",1/0),E(this,"minPolarAngle",0),E(this,"maxPolarAngle",Math.PI),E(this,"minAzimuthAngle",-1/0),E(this,"maxAzimuthAngle",1/0),E(this,"enableDamping",!1),E(this,"dampingFactor",.05),E(this,"enableZoom",!0),E(this,"zoomSpeed",1),E(this,"enableRotate",!0),E(this,"rotateSpeed",1),E(this,"enablePan",!0),E(this,"panSpeed",1),E(this,"screenSpacePanning",!0),E(this,"keyPanSpeed",7),E(this,"autoRotate",!1),E(this,"autoRotateSpeed",2),E(this,"reverseOrbit",!1),E(this,"reverseHorizontalOrbit",!1),E(this,"reverseVerticalOrbit",!1),E(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),E(this,"mouseButtons",{LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN}),E(this,"touches",{ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN}),E(this,"target0"),E(this,"position0"),E(this,"zoom0"),E(this,"_domElementKeyEvents",null),E(this,"getPolarAngle"),E(this,"getAzimuthalAngle"),E(this,"setPolarAngle"),E(this,"setAzimuthalAngle"),E(this,"getDistance"),E(this,"listenToKeyEvents"),E(this,"stopListenToKeyEvents"),E(this,"saveState"),E(this,"reset"),E(this,"update"),E(this,"connect"),E(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=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=T=>{let F=cs(T,2*Math.PI),z=p.phi;z<0&&(z+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-z);2*Math.PI-ee<ee&&(F<z?F+=2*Math.PI:z+=2*Math.PI),d.phi=F-z,s.update()},this.setAzimuthalAngle=T=>{let F=cs(T,2*Math.PI),z=p.theta;z<0&&(z+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-z);2*Math.PI-ee<ee&&(F<z?F+=2*Math.PI:z+=2*Math.PI),d.theta=F-z,s.update()},this.getDistance=()=>s.object.position.distanceTo(s.target),this.listenToKeyEvents=T=>{T.addEventListener("keydown",$t),this._domElementKeyEvents=T},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",$t),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 T=new c.Vector3,F=new c.Vector3(0,1,0),z=new c.Quaternion().setFromUnitVectors(e.up,F),ee=z.clone().invert(),pe=new c.Vector3,Ze=new c.Quaternion,Ve=2*Math.PI;return function(){const sn=s.object.position;z.setFromUnitVectors(e.up,F),ee.copy(z).invert(),T.copy(sn).sub(s.target),T.applyQuaternion(z),p.setFromVector3(T),s.autoRotate&&a===r.NONE&&B(k()),s.enableDamping?(p.theta+=d.theta*s.dampingFactor,p.phi+=d.phi*s.dampingFactor):(p.theta+=d.theta,p.phi+=d.phi);let Pe=s.minAzimuthAngle,De=s.maxAzimuthAngle;return isFinite(Pe)&&isFinite(De)&&(Pe<-Math.PI?Pe+=Ve:Pe>Math.PI&&(Pe-=Ve),De<-Math.PI?De+=Ve:De>Math.PI&&(De-=Ve),Pe<=De?p.theta=Math.max(Pe,Math.min(De,p.theta)):p.theta=p.theta>(Pe+De)/2?Math.max(Pe,p.theta):Math.min(De,p.theta)),p.phi=Math.max(s.minPolarAngle,Math.min(s.maxPolarAngle,p.phi)),p.makeSafe(),p.radius*=m,p.radius=Math.max(s.minDistance,Math.min(s.maxDistance,p.radius)),s.enableDamping===!0?s.target.addScaledVector(f,s.dampingFactor):s.target.add(f),T.setFromSpherical(p),T.applyQuaternion(ee),sn.copy(s.target).add(T),s.object.lookAt(s.target),s.enableDamping===!0?(d.theta*=1-s.dampingFactor,d.phi*=1-s.dampingFactor,f.multiplyScalar(1-s.dampingFactor)):(d.set(0,0,0),f.set(0,0,0)),m=1,w||pe.distanceToSquared(s.object.position)>h||8*(1-Ze.dot(s.object.quaternion))>h?(s.dispatchEvent(n),pe.copy(s.object.position),Ze.copy(s.object.quaternion),w=!1,!0):!1}})(),this.connect=T=>{T===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),s.domElement=T,s.domElement.style.touchAction="none",s.domElement.addEventListener("contextmenu",$s),s.domElement.addEventListener("pointerdown",qs),s.domElement.addEventListener("pointercancel",Js),s.domElement.addEventListener("wheel",Hs)},this.dispose=()=>{var T,F,z,ee,pe,Ze;(T=s.domElement)==null||T.removeEventListener("contextmenu",$s),(F=s.domElement)==null||F.removeEventListener("pointerdown",qs),(z=s.domElement)==null||z.removeEventListener("pointercancel",Js),(ee=s.domElement)==null||ee.removeEventListener("wheel",Hs),(pe=s.domElement)==null||pe.ownerDocument.removeEventListener("pointermove",Jt),(Ze=s.domElement)==null||Ze.ownerDocument.removeEventListener("pointerup",Ht),s._domElementKeyEvents!==null&&s._domElementKeyEvents.removeEventListener("keydown",$t)};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,p=new c.Spherical,d=new c.Spherical;let m=1;const f=new c.Vector3;let w=!1;const y=new c.Vector2,v=new c.Vector2,M=new c.Vector2,L=new c.Vector2,b=new c.Vector2,g=new c.Vector2,S=new c.Vector2,A=new c.Vector2,_=new c.Vector2,x=[],D={};function k(){return 2*Math.PI/60/60*s.autoRotateSpeed}function I(){return Math.pow(.95,s.zoomSpeed)}function B(T){s.reverseOrbit||s.reverseHorizontalOrbit?d.theta+=T:d.theta-=T}function R(T){s.reverseOrbit||s.reverseVerticalOrbit?d.phi+=T:d.phi-=T}const H=(()=>{const T=new c.Vector3;return function(z,ee){T.setFromMatrixColumn(ee,0),T.multiplyScalar(-z),f.add(T)}})(),G=(()=>{const T=new c.Vector3;return function(z,ee){s.screenSpacePanning===!0?T.setFromMatrixColumn(ee,1):(T.setFromMatrixColumn(ee,0),T.crossVectors(s.object.up,T)),T.multiplyScalar(z),f.add(T)}})(),se=(()=>{const T=new c.Vector3;return function(z,ee){const pe=s.domElement;if(pe&&s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera){const Ze=s.object.position;T.copy(Ze).sub(s.target);let Ve=T.length();Ve*=Math.tan(s.object.fov/2*Math.PI/180),H(2*z*Ve/pe.clientHeight,s.object.matrix),G(2*ee*Ve/pe.clientHeight,s.object.matrix)}else pe&&s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(H(z*(s.object.right-s.object.left)/s.object.zoom/pe.clientWidth,s.object.matrix),G(ee*(s.object.top-s.object.bottom)/s.object.zoom/pe.clientHeight,s.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),s.enablePan=!1)}})();function X(T){s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera?m/=T:s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(s.object.zoom=Math.max(s.minZoom,Math.min(s.maxZoom,s.object.zoom*T)),s.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),s.enableZoom=!1)}function le(T){s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera?m*=T:s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(s.object.zoom=Math.max(s.minZoom,Math.min(s.maxZoom,s.object.zoom/T)),s.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),s.enableZoom=!1)}function oe(T){y.set(T.clientX,T.clientY)}function $(T){S.set(T.clientX,T.clientY)}function Q(T){L.set(T.clientX,T.clientY)}function K(T){v.set(T.clientX,T.clientY),M.subVectors(v,y).multiplyScalar(s.rotateSpeed);const F=s.domElement;F&&(B(2*Math.PI*M.x/F.clientHeight),R(2*Math.PI*M.y/F.clientHeight)),y.copy(v),s.update()}function he(T){A.set(T.clientX,T.clientY),_.subVectors(A,S),_.y>0?X(I()):_.y<0&&le(I()),S.copy(A),s.update()}function C(T){b.set(T.clientX,T.clientY),g.subVectors(b,L).multiplyScalar(s.panSpeed),se(g.x,g.y),L.copy(b),s.update()}function fe(T){T.deltaY<0?le(I()):T.deltaY>0&&X(I()),s.update()}function xe(T){let F=!1;switch(T.code){case s.keys.UP:se(0,s.keyPanSpeed),F=!0;break;case s.keys.BOTTOM:se(0,-s.keyPanSpeed),F=!0;break;case s.keys.LEFT:se(s.keyPanSpeed,0),F=!0;break;case s.keys.RIGHT:se(-s.keyPanSpeed,0),F=!0;break}F&&(T.preventDefault(),s.update())}function Se(){if(x.length==1)y.set(x[0].pageX,x[0].pageY);else{const T=.5*(x[0].pageX+x[1].pageX),F=.5*(x[0].pageY+x[1].pageY);y.set(T,F)}}function Ne(){if(x.length==1)L.set(x[0].pageX,x[0].pageY);else{const T=.5*(x[0].pageX+x[1].pageX),F=.5*(x[0].pageY+x[1].pageY);L.set(T,F)}}function ut(){const T=x[0].pageX-x[1].pageX,F=x[0].pageY-x[1].pageY,z=Math.sqrt(T*T+F*F);S.set(0,z)}function $r(){s.enableZoom&&ut(),s.enablePan&&Ne()}function ea(){s.enableZoom&&ut(),s.enableRotate&&Se()}function Qs(T){if(x.length==1)v.set(T.pageX,T.pageY);else{const z=es(T),ee=.5*(T.pageX+z.x),pe=.5*(T.pageY+z.y);v.set(ee,pe)}M.subVectors(v,y).multiplyScalar(s.rotateSpeed);const F=s.domElement;F&&(B(2*Math.PI*M.x/F.clientHeight),R(2*Math.PI*M.y/F.clientHeight)),y.copy(v)}function Ks(T){if(x.length==1)b.set(T.pageX,T.pageY);else{const F=es(T),z=.5*(T.pageX+F.x),ee=.5*(T.pageY+F.y);b.set(z,ee)}g.subVectors(b,L).multiplyScalar(s.panSpeed),se(g.x,g.y),L.copy(b)}function Ws(T){const F=es(T),z=T.pageX-F.x,ee=T.pageY-F.y,pe=Math.sqrt(z*z+ee*ee);A.set(0,pe),_.set(0,Math.pow(A.y/S.y,s.zoomSpeed)),X(_.y),S.copy(A)}function ta(T){s.enableZoom&&Ws(T),s.enablePan&&Ks(T)}function sa(T){s.enableZoom&&Ws(T),s.enableRotate&&Qs(T)}function qs(T){var F,z;s.enabled!==!1&&(x.length===0&&((F=s.domElement)==null||F.ownerDocument.addEventListener("pointermove",Jt),(z=s.domElement)==null||z.ownerDocument.addEventListener("pointerup",Ht)),aa(T),T.pointerType==="touch"?oa(T):na(T))}function Jt(T){s.enabled!==!1&&(T.pointerType==="touch"?ra(T):ia(T))}function Ht(T){var F,z,ee;en(T),x.length===0&&((F=s.domElement)==null||F.releasePointerCapture(T.pointerId),(z=s.domElement)==null||z.ownerDocument.removeEventListener("pointermove",Jt),(ee=s.domElement)==null||ee.ownerDocument.removeEventListener("pointerup",Ht)),s.dispatchEvent(o),a=r.NONE}function Js(T){en(T)}function na(T){let F;switch(T.button){case 0:F=s.mouseButtons.LEFT;break;case 1:F=s.mouseButtons.MIDDLE;break;case 2:F=s.mouseButtons.RIGHT;break;default:F=-1}switch(F){case c.MOUSE.DOLLY:if(s.enableZoom===!1)return;$(T),a=r.DOLLY;break;case c.MOUSE.ROTATE:if(T.ctrlKey||T.metaKey||T.shiftKey){if(s.enablePan===!1)return;Q(T),a=r.PAN}else{if(s.enableRotate===!1)return;oe(T),a=r.ROTATE}break;case c.MOUSE.PAN:if(T.ctrlKey||T.metaKey||T.shiftKey){if(s.enableRotate===!1)return;oe(T),a=r.ROTATE}else{if(s.enablePan===!1)return;Q(T),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&s.dispatchEvent(i)}function ia(T){if(s.enabled!==!1)switch(a){case r.ROTATE:if(s.enableRotate===!1)return;K(T);break;case r.DOLLY:if(s.enableZoom===!1)return;he(T);break;case r.PAN:if(s.enablePan===!1)return;C(T);break}}function Hs(T){s.enabled===!1||s.enableZoom===!1||a!==r.NONE&&a!==r.ROTATE||(T.preventDefault(),s.dispatchEvent(i),fe(T),s.dispatchEvent(o))}function $t(T){s.enabled===!1||s.enablePan===!1||xe(T)}function oa(T){switch(tn(T),x.length){case 1:switch(s.touches.ONE){case c.TOUCH.ROTATE:if(s.enableRotate===!1)return;Se(),a=r.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(s.enablePan===!1)return;Ne(),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;$r(),a=r.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(s.enableZoom===!1&&s.enableRotate===!1)return;ea(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&s.dispatchEvent(i)}function ra(T){switch(tn(T),a){case r.TOUCH_ROTATE:if(s.enableRotate===!1)return;Qs(T),s.update();break;case r.TOUCH_PAN:if(s.enablePan===!1)return;Ks(T),s.update();break;case r.TOUCH_DOLLY_PAN:if(s.enableZoom===!1&&s.enablePan===!1)return;ta(T),s.update();break;case r.TOUCH_DOLLY_ROTATE:if(s.enableZoom===!1&&s.enableRotate===!1)return;sa(T),s.update();break;default:a=r.NONE}}function $s(T){s.enabled!==!1&&T.preventDefault()}function aa(T){x.push(T)}function en(T){delete D[T.pointerId];for(let F=0;F<x.length;F++)if(x[F].pointerId==T.pointerId){x.splice(F,1);return}}function tn(T){let F=D[T.pointerId];F===void 0&&(F=new c.Vector2,D[T.pointerId]=F),F.set(T.pageX,T.pageY)}function es(T){const F=T.pointerId===x[0].pointerId?x[1]:x[0];return D[F.pointerId]}t!==void 0&&this.connect(t),this.update()}}class Dn extends hs{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 In extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Nn(t)}),this.register(function(t){return new Xn(t)}),this.register(function(t){return new Zn(t)}),this.register(function(t){return new Qn(t)}),this.register(function(t){return new En(t)}),this.register(function(t){return new zn(t)}),this.register(function(t){return new Rn(t)}),this.register(function(t){return new Gn(t)}),this.register(function(t){return new Un(t)}),this.register(function(t){return new Yn(t)}),this.register(function(t){return new Vn(t)}),this.register(function(t){return new jn(t)}),this.register(function(t){return new Fn(t)}),this.register(function(t){return new Kn(t)}),this.register(function(t){return new Wn(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(p){t(p),i.manager.itemEnd(e)},r)}catch(p){r(p)}},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)))===us){try{o[Z.KHR_BINARY_GLTF]=new qn(e)}catch(p){n&&n(p);return}i=JSON.parse(o[Z.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 ci(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 p=this.pluginCallbacks[h](a);r[p.name]=p,o[p.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const p=i.extensionsUsed[h],d=i.extensionsRequired||[];switch(p){case Z.KHR_MATERIALS_UNLIT:o[p]=new Bn;break;case Z.KHR_DRACO_MESH_COMPRESSION:o[p]=new Jn(i,this.dracoLoader);break;case Z.KHR_TEXTURE_TRANSFORM:o[p]=new Hn;break;case Z.KHR_MESH_QUANTIZATION:o[p]=new $n;break;default:d.indexOf(p)>=0&&r[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}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 kn(){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 Z={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 Fn{constructor(e){this.parser=e,this.name=Z.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 p=new c.Color(16777215);a.color!==void 0&&p.fromArray(a.color);const d=a.range!==void 0?a.range:0;switch(a.type){case"directional":h=new c.DirectionalLight(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new c.PointLight(p),h.distance=d;break;case"spot":h=new c.SpotLight(p),h.distance=d,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,Be(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 Bn{constructor(){this.name=Z.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 Un{constructor(e){this.parser=e,this.name=Z.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 Nn{constructor(e){this.parser=e,this.name=Z.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 Vn{constructor(e){this.parser=e,this.name=Z.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 En{constructor(e){this.parser=e,this.name=Z.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 zn{constructor(e){this.parser=e,this.name=Z.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 Rn{constructor(e){this.parser=e,this.name=Z.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 Gn{constructor(e){this.parser=e,this.name=Z.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 Yn{constructor(e){this.parser=e,this.name=Z.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 jn{constructor(e){this.parser=e,this.name=Z.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 Xn{constructor(e){this.parser=e,this.name=Z.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 Zn{constructor(e){this.parser=e,this.name=Z.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 Qn{constructor(e){this.parser=e,this.name=Z.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 Kn{constructor(e){this.name=Z.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,p=n.count,d=n.byteStride,m=new Uint8Array(r,a,h);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(p,d,m,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(p*d);return o.decodeGltfBuffer(new Uint8Array(f),p,d,m,n.mode,n.filter),f})})}else return null}}class Wn{constructor(e){this.name=Z.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!==ye.TRIANGLES&&h.mode!==ye.TRIANGLE_STRIP&&h.mode!==ye.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(p=>(a[h]=p,a[h])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(h=>{const p=h.pop(),d=p.isGroup?p.children:[p],m=h[0].count,f=[];for(const w of d){const y=new c.Matrix4,v=new c.Vector3,M=new c.Quaternion,L=new c.Vector3(1,1,1),b=new c.InstancedMesh(w.geometry,w.material,m);for(let g=0;g<m;g++)a.TRANSLATION&&v.fromBufferAttribute(a.TRANSLATION,g),a.ROTATION&&M.fromBufferAttribute(a.ROTATION,g),a.SCALE&&L.fromBufferAttribute(a.SCALE,g),b.setMatrixAt(g,y.compose(v,M,L));for(const g in a)g!=="TRANSLATION"&&g!=="ROTATION"&&g!=="SCALE"&&w.geometry.setAttribute(g,a[g]);c.Object3D.prototype.copy.call(b,w),this.parser.assignFinalMaterial(b),f.push(b)}return p.isGroup?(p.clear(),p.add(...f),p):f[0]}))}}const us="glTF",nt=12,ps={JSON:1313821514,BIN:5130562};class qn{constructor(e){this.name=Z.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,nt);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!==us)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-nt,n=new DataView(e,nt);let i=0;for(;i<s;){const o=n.getUint32(i,!0);i+=4;const r=n.getUint32(i,!0);if(i+=4,r===ps.JSON){const a=new Uint8Array(e,nt+i,o);this.content=c.LoaderUtils.decodeText(a)}else if(r===ps.BIN){const a=nt+i;this.body=e.slice(a,a+o)}i+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Jn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Z.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 p in o){const d=Tt[p]||p.toLowerCase();r[d]=o[p]}for(const p in e.attributes){const d=Tt[p]||p.toLowerCase();if(o[p]!==void 0){const m=s.accessors[e.attributes[p]],f=We[m.componentType];h[d]=f.name,a[d]=m.normalized===!0}}return t.getDependency("bufferView",i).then(function(p){return new Promise(function(d){n.decodeDracoFile(p,function(m){for(const f in m.attributes){const w=m.attributes[f],y=a[f];y!==void 0&&(w.normalized=y)}d(m)},r,h)})})}}class Hn{constructor(){this.name=Z.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 $n{constructor(){this.name=Z.KHR_MESH_QUANTIZATION}}class ds 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,p=n-t,d=(s-t)/p,m=d*d,f=m*d,w=e*h,y=w-h,v=-2*f+3*m,M=f-m,L=1-v,b=M-m+d;for(let g=0;g!==r;g++){const S=o[y+g+r],A=o[y+g+a]*p,_=o[w+g+r],x=o[w+g]*p;i[g]=L*S+b*A+v*_+M*x}return i}}const ei=new c.Quaternion;class ti extends ds{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return ei.fromArray(i).normalize().toArray(i),i}}const ye={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},We={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},fs={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},St={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Tt={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"},Fe={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},si={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},Lt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ni(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 Ee(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 Be(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 ii(l,e,t){let s=!1,n=!1,i=!1;for(let h=0,p=e.length;h<p;h++){const d=e[h];if(d.POSITION!==void 0&&(s=!0),d.NORMAL!==void 0&&(n=!0),d.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,p=e.length;h<p;h++){const d=e[h];if(s){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):l.attributes.position;o.push(m)}if(n){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):l.attributes.normal;r.push(m)}if(i){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):l.attributes.color;a.push(m)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a)]).then(function(h){const p=h[0],d=h[1],m=h[2];return s&&(l.morphAttributes.position=p),n&&(l.morphAttributes.normal=d),i&&(l.morphAttributes.color=m),l.morphTargetsRelative=!0,l})}function oi(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[Z.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ct(t.attributes):e=l.indices+":"+Ct(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+Ct(l.targets[s]);return e}function Ct(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 Ot(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 ai(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 li=new c.Matrix4;class ci{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new kn,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:{}};Ee(i,r,n),Be(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,p]of o.children.entries())i(p,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[Z.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=St[n.type],r=We[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=St[n.type],h=We[n.componentType],p=h.BYTES_PER_ELEMENT,d=p*a,m=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,w=n.normalized===!0;let y,v;if(f&&f!==d){const M=Math.floor(m/f),L="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+M+":"+n.count;let b=t.cache.get(L);b||(y=new h(r,M*f,n.count*f/p),b=new c.InterleavedBuffer(y,f/p),t.cache.add(L,b)),v=new c.InterleavedBufferAttribute(b,a,m%f/p,w)}else r===null?y=new h(n.count*a):y=new h(r,m,n.count*a),v=new c.BufferAttribute(y,a,w);if(n.sparse!==void 0){const M=St.SCALAR,L=We[n.sparse.indices.componentType],b=n.sparse.indices.byteOffset||0,g=n.sparse.values.byteOffset||0,S=new L(o[1],b,n.sparse.count*M),A=new h(o[2],g,n.sparse.count*a);r!==null&&(v=new c.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let _=0,x=S.length;_<x;_++){const D=S[_];if(v.setX(D,A[_*a]),a>=2&&v.setY(D,A[_*a+1]),a>=3&&v.setZ(D,A[_*a+2]),a>=4&&v.setW(D,A[_*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}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(p){p.flipY=!1,p.name=o.name||r.name||"",p.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(p.name=r.uri);const m=(i.samplers||{})[o.sampler]||{};return p.magFilter=ms[m.magFilter]||c.LinearFilter,p.minFilter=ms[m.minFilter]||c.LinearMipmapLinearFilter,p.wrapS=fs[m.wrapS]||c.RepeatWrapping,p.wrapT=fs[m.wrapT]||c.RepeatWrapping,n.associations.set(p,{textures:e}),p}).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(d=>d.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(d){h=!0;const m=new Blob([d],{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 p=Promise.resolve(a).then(function(d){return new Promise(function(m,f){let w=m;t.isImageBitmapLoader===!0&&(w=function(y){const v=new c.Texture(y);v.needsUpdate=!0,m(v)}),t.load(c.LoaderUtils.resolveURL(d,i.path),w,void 0,f)})}).then(function(d){return h===!0&&r.revokeObjectURL(a),d.userData.mimeType=o.mimeType||ai(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),d});return this.sourceCache[e]=p,p}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[Z.KHR_TEXTURE_TRANSFORM]){const r=s.extensions!==void 0?s.extensions[Z.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=i.associations.get(o);o=i.extensions[Z.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[Z.KHR_MATERIALS_UNLIT]){const d=n[Z.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),h.push(d.extendParams(r,i,t))}else{const d=i.pbrMetallicRoughness||{};if(r.color=new c.Color(1,1,1),r.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;r.color.fromArray(m),r.opacity=m[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(r,"map",d.baseColorTexture,3001)),r.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,r.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(r,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(r,"roughnessMap",d.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 p=i.alphaMode||Lt.OPAQUE;if(p===Lt.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,p===Lt.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 d=i.normalTexture.scale;r.normalScale.set(d,d)}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 d=new o(r);return i.name&&(d.name=i.name),Be(d,i),t.associations.set(d,{materials:e}),i.extensions&&Ee(n,d,i),d})}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[Z.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return gs(a,r,t)})}const o=[];for(let r=0,a=e.length;r<a;r++){const h=e[r],p=ri(h),d=n[p];if(d)o.push(d.promise);else{let m;h.extensions&&h.extensions[Z.KHR_DRACO_MESH_COMPRESSION]?m=i(h):m=gs(new c.BufferGeometry,h,t),n[p]={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 p=o[a].material===void 0?ni(this.cache):this.getDependency("material",o[a].material);r.push(p)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(a){const h=a.slice(0,a.length-1),p=a[a.length-1],d=[];for(let f=0,w=p.length;f<w;f++){const y=p[f],v=o[f];let M;const L=h[f];if(v.mode===ye.TRIANGLES||v.mode===ye.TRIANGLE_STRIP||v.mode===ye.TRIANGLE_FAN||v.mode===void 0)M=i.isSkinnedMesh===!0?new c.SkinnedMesh(y,L):new c.Mesh(y,L),M.isSkinnedMesh===!0&&M.normalizeSkinWeights(),v.mode===ye.TRIANGLE_STRIP?M.geometry=ts(M.geometry,c.TriangleStripDrawMode):v.mode===ye.TRIANGLE_FAN&&(M.geometry=ts(M.geometry,c.TriangleFanDrawMode));else if(v.mode===ye.LINES)M=new c.LineSegments(y,L);else if(v.mode===ye.LINE_STRIP)M=new c.Line(y,L);else if(v.mode===ye.LINE_LOOP)M=new c.LineLoop(y,L);else if(v.mode===ye.POINTS)M=new c.Points(y,L);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(M.geometry.morphAttributes).length>0&&oi(M,i),M.name=t.createUniqueName(i.name||"mesh_"+e),Be(M,i),v.extensions&&Ee(n,M,v),t.assignFinalMaterial(M),d.push(M)}for(let f=0,w=d.length;f<w;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return i.extensions&&Ee(n,d[0],i),d[0];const m=new c.Group;i.extensions&&Ee(n,m,i),t.associations.set(m,{meshes:e});for(let f=0,w=d.length;f<w;f++)m.add(d[f]);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)),Be(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,p=o.length;h<p;h++){const d=o[h];if(d){r.push(d);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 p=0,d=s.channels.length;p<d;p++){const m=s.channels[p],f=s.samplers[m.sampler],w=m.target,y=w.node,v=s.parameters!==void 0?s.parameters[f.input]:f.input,M=s.parameters!==void 0?s.parameters[f.output]:f.output;w.node!==void 0&&(i.push(this.getDependency("node",y)),o.push(this.getDependency("accessor",v)),r.push(this.getDependency("accessor",M)),a.push(f),h.push(w))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(r),Promise.all(a),Promise.all(h)]).then(function(p){const d=p[0],m=p[1],f=p[2],w=p[3],y=p[4],v=[];for(let M=0,L=d.length;M<L;M++){const b=d[M],g=m[M],S=f[M],A=w[M],_=y[M];if(b===void 0)continue;b.updateMatrix();let x;switch(Fe[_.path]){case Fe.weights:x=c.NumberKeyframeTrack;break;case Fe.rotation:x=c.QuaternionKeyframeTrack;break;case Fe.position:case Fe.scale:default:x=c.VectorKeyframeTrack;break}const D=b.name?b.name:b.uuid,k=A.interpolation!==void 0?si[A.interpolation]:c.InterpolateLinear,I=[];Fe[_.path]===Fe.weights?b.traverse(function(R){R.morphTargetInfluences&&I.push(R.name?R.name:R.uuid)}):I.push(D);let B=S.array;if(S.normalized){const R=Ot(B.constructor),H=new Float32Array(B.length);for(let G=0,se=B.length;G<se;G++)H[G]=B[G]*R;B=H}for(let R=0,H=I.length;R<H;R++){const G=new x(I[R]+"."+Fe[_.path],g.array,B,k);A.interpolation==="CUBICSPLINE"&&(G.createInterpolant=function(X){const le=this instanceof c.QuaternionKeyframeTrack?ti:ds;return new le(this.times,this.values,this.getValueSize()/3,X)},G.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),v.push(G)}}return new c.AnimationClip(n,void 0,v)})}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,p=r.length;h<p;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 p=h[0],d=h[1],m=h[2];m!==null&&p.traverse(function(f){f.isSkinnedMesh&&f.bind(m,li)});for(let f=0,w=d.length;f<w;f++)p.add(d[f]);return p})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",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 p;if(i.isBone===!0?p=new c.Bone:h.length>1?p=new c.Group:h.length===1?p=h[0]:p=new c.Object3D,p!==h[0])for(let d=0,m=h.length;d<m;d++)p.add(h[d]);if(i.name&&(p.userData.name=i.name,p.name=o),Be(p,i),i.extensions&&Ee(s,p,i),i.matrix!==void 0){const d=new c.Matrix4;d.fromArray(i.matrix),p.applyMatrix4(d)}else i.translation!==void 0&&p.position.fromArray(i.translation),i.rotation!==void 0&&p.quaternion.fromArray(i.rotation),i.scale!==void 0&&p.scale.fromArray(i.scale);return n.associations.has(p)||n.associations.set(p,{}),n.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new c.Group;s.name&&(i.name=n.createUniqueName(s.name)),Be(i,s),s.extensions&&Ee(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 p=0,d=a.length;p<d;p++)i.add(a[p]);const h=p=>{const d=new Map;for(const[m,f]of n.associations)(m instanceof c.Material||m instanceof c.Texture)&&d.set(m,f);return p.traverse(m=>{const f=n.associations.get(m);f!=null&&d.set(m,f)}),d};return n.associations=h(i),i})}}function hi(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 p=Ot(We[r.componentType]);n.min.multiplyScalar(p),n.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new c.Vector3,a=new c.Vector3;for(let h=0,p=i.length;h<p;h++){const d=i[h];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],f=m.min,w=m.max;if(f!==void 0&&w!==void 0){if(a.setX(Math.max(Math.abs(f[0]),Math.abs(w[0]))),a.setY(Math.max(Math.abs(f[1]),Math.abs(w[1]))),a.setZ(Math.max(Math.abs(f[2]),Math.abs(w[2]))),m.normalized){const y=Ot(We[m.componentType]);a.multiplyScalar(y)}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 gs(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=Tt[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 Be(l,e),hi(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ii(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:p=0,...d}=t;if(o===void 0)super();else{const m=o.generateShapes(e,a,{lineHeight:h,letterSpacing:p});super(m,{...d,bevelEnabled:s,bevelSize:n,bevelThickness:i,depth:r})}this.type="TextGeometry"}}const ui={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
9
9
  varying vec2 vUv;
10
10
 
11
11
  void main() {
@@ -70,20 +70,20 @@
70
70
  gl_FragColor = sum;
71
71
 
72
72
  }
73
- `};function _s(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 di(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 p=o[h+1],d=i[r-h],m=n[h]/(p+d);n[h]=a+p*m,a=d*m}n[r]=a}return n}function mi(l,e,t,s){const n=_s(l,s,e),i=di(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],p=a.w*h;o.x+=a.x*p,o.y+=a.y*p,o.z+=a.z*p,o.w+=a.w*h}return o}function fi(l,e,t,s,n){const i=[];for(let d=0;d<=t;++d)i[d]=0;const o=[];for(let d=0;d<=s;++d)o[d]=i.slice(0);const r=[];for(let d=0;d<=t;++d)r[d]=i.slice(0);r[0][0]=1;const a=i.slice(0),h=i.slice(0);for(let d=1;d<=t;++d){a[d]=e-n[l+1-d],h[d]=n[l+d]-e;let m=0;for(let f=0;f<d;++f){const w=h[f+1],y=a[d-f];r[d][f]=w+y;const v=r[f][d-1]/r[d][f];r[f][d]=m+w*v,m=y*v}r[d][d]=m}for(let d=0;d<=t;++d)o[0][d]=r[d][t];for(let d=0;d<=t;++d){let m=0,f=1;const w=[];for(let y=0;y<=t;++y)w[y]=i.slice(0);w[0][0]=1;for(let y=1;y<=s;++y){let v=0;const M=d-y,L=t-y;d>=y&&(w[f][0]=w[m][0]/r[L+1][M],v=w[f][0]*r[M][L]);const b=M>=-1?1:-M,g=d-1<=L?y-1:t-d;for(let A=b;A<=g;++A)w[f][A]=(w[m][A]-w[m][A-1])/r[L+1][M+A],v+=w[f][A]*r[M+A][L];d<=L&&(w[f][y]=-w[m][y-1]/r[L+1][d],v+=w[f][y]*r[d][L]),o[y][d]=v;const S=m;m=f,f=S}}let p=t;for(let d=1;d<=s;++d){for(let m=0;m<=t;++m)o[d][m]*=p;p*=t-d}return o}function gi(l,e,t,s,n){const i=n<l?n:l,o=[],r=_s(l,s,e),a=fi(r,s,l,i,e),h=[];for(let p=0;p<t.length;++p){const d=t[p].clone(),m=d.w;d.x*=m,d.y*=m,d.z*=m,h[p]=d}for(let p=0;p<=i;++p){const d=h[r-l].clone().multiplyScalar(a[p][0]);for(let m=1;m<=l;++m)d.add(h[r-l+m].clone().multiplyScalar(a[p][m]));o[p]=d}for(let p=i+1;p<=n+1;++p)o[p]=new c.Vector4(0,0,0);return o}function yi(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 _i(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(yi(i,r)*s[r]));n[i]=o.divideScalar(s[0])}return n}function wi(l,e,t,s,n){const i=gi(l,e,t,s,n);return _i(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=mi(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=wi(this.degree,this.knots,this.controlPoints,n,1);return s.copy(i[1]).normalize(),s}}let j,ie,de;class xi 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(Ti(e))j=new Si().parse(e);else{const n=Ss(e);if(!Li(n))throw new Error("THREE.FBXLoader: Unknown format.");if(As(n)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+As(n));j=new bi().parse(n)}const s=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new vi(s,this.manager).parse(j)}}class vi{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){ie=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),s=this.parseMaterials(t),n=this.parseDeformers(),i=new Ai().parse(n);return this.parseScene(n,i,s),de}parseConnections(){const e=new Map;return"Connections"in j&&j.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 j.Objects){const s=j.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 j.Objects){const s=j.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=ie.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 j.Objects){const s=j.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),!ie.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 ie.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 j.Objects&&t in j.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=ie.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in j.Objects){const s=j.Objects.Deformer;for(const n in s){const i=s[n],o=ie.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=ie.get(parseInt(i.ID)).children.filter(function(a){return a.relationship===void 0})[0].ID,s.push(r)}return s}parseScene(e,t,s){de=new c.Group;const n=this.parseModels(e.skeletons,t,s),i=j.Objects.Model,o=this;n.forEach(function(a){const h=i[a.ID];o.setLookAtProperties(a,h),ie.get(a.ID).parents.forEach(function(d){const m=n.get(d.ID);m!==void 0&&m.add(a)}),a.parent===null&&de.add(a)}),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),de.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=Ms(a.userData.transformData);a.applyMatrix4(h),a.updateWorldMatrix()}});const r=new Mi().parse();de.children.length===1&&de.children[0].isGroup&&(de.children[0].animations=r,de=de.children[0]),de.animations=r}parseModels(e,t,s){const n=new Map,i=j.Objects.Model;for(const o in i){const r=parseInt(o),a=i[o],h=ie.get(r);let p=this.buildSkeleton(h,e,r,a.attrName);if(!p){switch(a.attrType){case"Camera":p=this.createCamera(h);break;case"Light":p=this.createLight(h);break;case"Mesh":p=this.createMesh(h,t,s);break;case"NurbsCurve":p=this.createCurve(h,t);break;case"LimbNode":case"Root":p=new c.Bone;break;case"Null":default:p=new c.Group;break}p.name=a.attrName?c.PropertyBinding.sanitizeNodeName(a.attrName):"",p.ID=r}this.getTransformData(p,a),n.set(r,p)}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,p){if(h.ID===o.ID){const d=i;i=new c.Bone,i.matrixWorld.copy(h.transformLink),i.name=n?c.PropertyBinding.sanitizeNodeName(n):"",i.ID=s,a.bones[p]=i,d!==null&&i.add(d)}})}}),i}createCamera(e){let t,s;if(e.children.forEach(function(n){const i=j.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 p=45;s.FieldOfView!==void 0&&(p=s.FieldOfView.value);const d=s.FocalLength?s.FocalLength.value:null;switch(n){case 0:t=new c.PerspectiveCamera(p,h,i,o),d!==null&&t.setFocalLength(d);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=j.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 p=0;s.OuterAngle!==void 0&&(p=c.MathUtils.degToRad(s.OuterAngle.value),p=Math.max(p,1)),t=new c.SpotLight(i,o,r,h,p,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=bs(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&&ie.get(e.ID).children.forEach(function(n){if(n.relationship==="LookAtProperty"){const i=j.Objects.Model[n.ID];if("Lcl_Translation"in i){const o=i.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),de.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];ie.get(parseInt(o.ID)).parents.forEach(function(a){if(t.has(a.ID)){const h=a.ID;ie.get(h).parents.forEach(function(d){s.has(d.ID)&&s.get(d.ID).bind(new c.Skeleton(o.bones),n[d.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in j.Objects){const t=j.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 j&&"AmbientColor"in j.GlobalSettings){const e=j.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);de.add(new c.AmbientLight(i,1))}}}}class Ai{parse(e){const t=new Map;if("Geometry"in j.Objects){const s=j.Objects.Geometry;for(const n in s){const i=ie.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(d){return j.Objects.Model[d.ID]});if(o.length===0)return;const r=e.children.reduce(function(d,m){return n[m.ID]!==void 0&&(d=n[m.ID]),d},null);e.children.forEach(function(d){s.morphTargets[d.ID]!==void 0&&i.push(s.morphTargets[d.ID])});const a=o[0],h={};"RotationOrder"in a&&(h.eulerOrder=bs(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 p=Ms(h);return this.genGeometry(t,r,i,p)}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),p=new c.Float32BufferAttribute(r.normal,3);p.applyNormalMatrix(h),i.setAttribute("normal",p)}if(r.uvs.forEach(function(h,p){let d="uv"+(p+1).toString();p===0&&(d="uv"),i.setAttribute(d,new c.Float32BufferAttribute(r.uvs[p],2))}),o.material&&o.material.mappingType!=="AllSame"){let h=r.materialIndex[0],p=0;if(r.materialIndex.forEach(function(d,m){d!==h&&(i.addGroup(p,m-p,h),h=d,p=m)}),i.groups.length>0){const d=i.groups[i.groups.length-1],m=d.start+d.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=[],p=[],d=[];const m=this;return e.vertexIndices.forEach(function(f,w){let y,v=!1;f<0&&(f=f^-1,v=!0);let M=[],L=[];if(o.push(f*3,f*3+1,f*3+2),e.color){const b=pt(w,s,f,e.color);a.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(b){L.push(b.weight),M.push(b.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 b=[0,0,0,0],g=[0,0,0,0];L.forEach(function(S,A){let _=S,x=M[A];g.forEach(function(D,F,I){if(_>D){I[F]=_,_=D;const B=b[F];b[F]=x,x=B}})}),M=b,L=g}for(;L.length<4;)L.push(0),M.push(0);for(let b=0;b<4;++b)p.push(L[b]),d.push(M[b])}if(e.normal){const b=pt(w,s,f,e.normal);r.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(y=pt(w,s,f,e.material)[0]),e.uv&&e.uv.forEach(function(b,g){const S=pt(w,s,f,b);h[g]===void 0&&(h[g]=[]),h[g].push(S[0]),h[g].push(S[1])}),n++,v&&(m.genFace(t,e,o,y,r,a,h,p,d,n),s++,n=0,o=[],r=[],a=[],h=[],p=[],d=[])}),t}genFace(e,t,s,n,i,o,r,a,h,p){for(let d=2;d<p;d++)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[(d-1)*3]]),e.vertex.push(t.vertexPositions[s[(d-1)*3+1]]),e.vertex.push(t.vertexPositions[s[(d-1)*3+2]]),e.vertex.push(t.vertexPositions[s[d*3]]),e.vertex.push(t.vertexPositions[s[d*3+1]]),e.vertex.push(t.vertexPositions[s[d*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[(d-1)*4]),e.vertexWeights.push(a[(d-1)*4+1]),e.vertexWeights.push(a[(d-1)*4+2]),e.vertexWeights.push(a[(d-1)*4+3]),e.vertexWeights.push(a[d*4]),e.vertexWeights.push(a[d*4+1]),e.vertexWeights.push(a[d*4+2]),e.vertexWeights.push(a[d*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[(d-1)*4]),e.weightsIndices.push(h[(d-1)*4+1]),e.weightsIndices.push(h[(d-1)*4+2]),e.weightsIndices.push(h[(d-1)*4+3]),e.weightsIndices.push(h[d*4]),e.weightsIndices.push(h[d*4+1]),e.weightsIndices.push(h[d*4+2]),e.weightsIndices.push(h[d*4+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[(d-1)*3]),e.colors.push(o[(d-1)*3+1]),e.colors.push(o[(d-1)*3+2]),e.colors.push(o[d*3]),e.colors.push(o[d*3+1]),e.colors.push(o[d*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[(d-1)*3]),e.normal.push(i[(d-1)*3+1]),e.normal.push(i[(d-1)*3+2]),e.normal.push(i[d*3]),e.normal.push(i[d*3+1]),e.normal.push(i[d*3+2])),t.uv&&t.uv.forEach(function(m,f){e.uvs[f]===void 0&&(e.uvs[f]=[]),e.uvs[f].push(r[f][0]),e.uvs[f].push(r[f][1]),e.uvs[f].push(r[f][(d-1)*2]),e.uvs[f].push(r[f][(d-1)*2+1]),e.uvs[f].push(r[f][d*2]),e.uvs[f].push(r[f][d*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=j.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,p=new Float32Array(h);for(let w=0;w<a.length;w++){const y=a[w]*3;p[y]=r[w*3],p[y+1]=r[w*3+1],p[y+2]=r[w*3+2]}const d={vertexIndices:o,vertexPositions:p},m=this.genBuffers(d),f=new c.Float32BufferAttribute(m.vertex,3);f.name=i||s.attrName,f.applyMatrix4(n),e.morphAttributes.position.push(f)}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 d=0,m=o.length;d<m;d+=4)i.push(new c.Vector4().fromArray(o,d));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 d=0;d<s;++d)i.push(i[d])}const p=new ws(s,n,i,r,a).getPoints(i.length*12);return new c.BufferGeometry().setFromPoints(p)}}class Mi{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(j.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=j.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=j.Objects.AnimationCurve;for(const s in t){const n={id:t[s].id,times:t[s].KeyTime.a.map(Ci),values:t[s].KeyValueFloat.a},i=ie.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=j.Objects.AnimationLayer,s=new Map;for(const n in t){const i=[],o=ie.get(parseInt(n));o!==void 0&&(o.children.forEach(function(a,h){if(e.has(a.ID)){const p=e.get(a.ID);if(p.curves.x!==void 0||p.curves.y!==void 0||p.curves.z!==void 0){if(i[h]===void 0){const d=ie.get(a.ID).parents.filter(function(m){return m.relationship!==void 0})[0].ID;if(d!==void 0){const m=j.Objects.Model[d.toString()];if(m===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",a);return}const f={modelName:m.attrName?c.PropertyBinding.sanitizeNodeName(m.attrName):"",ID:m.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};de.traverse(function(w){w.ID===m.id&&(f.transform=w.matrix,w.userData.transformData&&(f.eulerOrder=w.userData.transformData.eulerOrder))}),f.transform||(f.transform=new c.Matrix4),"PreRotation"in m&&(f.preRotation=m.PreRotation.value),"PostRotation"in m&&(f.postRotation=m.PostRotation.value),i[h]=f}}i[h]&&(i[h][p.attr]=p)}else if(p.curves.morph!==void 0){if(i[h]===void 0){const d=ie.get(a.ID).parents.filter(function(M){return M.relationship!==void 0})[0].ID,m=ie.get(d).parents[0].ID,f=ie.get(m).parents[0].ID,w=ie.get(f).parents[0].ID,y=j.Objects.Model[w],v={modelName:y.attrName?c.PropertyBinding.sanitizeNodeName(y.attrName):"",morphName:j.Objects.Deformer[d].attrName};i[h]=v}i[h][p.attr]=p}}}),s.set(parseInt(n),i))}return s}parseAnimStacks(e){const t=j.Objects.AnimationStack,s={};for(const n in t){const i=ie.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,p=new c.Euler,d=[];for(let m=0;m<a.length;m+=3)p.set(a[m],a[m+1],a[m+2],o),h.setFromEuler(p),n!==void 0&&h.premultiply(n),i!==void 0&&h.multiply(i),h.toArray(d,m/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",r,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,s=t.values.map(function(i){return i/100}),n=de.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 p=t.x.values[o];i.push(p),n[0]=p}else i.push(n[0]);if(r!==-1){const p=t.y.values[r];i.push(p),n[1]=p}else i.push(n[1]);if(a!==-1){const p=t.z.values[a];i.push(p),n[2]=p}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],d=(e.times[t]-h)/o;let m=h+d;const f=[],w=[];for(;m<e.times[t];)f.push(m),m+=d,w.push(a),a+=r;e.times=Ts(e.times,t,f),e.values=Ts(e.values,t,w)}}}}class bi{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 vs,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](.*)"),p=n.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(n,a):h?t.parseNodeProperty(n,h,s[++i]):p?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]),p=parseInt(a[1]);let d=i.split(",").slice(3);d=d.map(function(m){return m.trim().replace(/^"/,"")}),n="connections",i=[h,p],Pi(i,d),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=Dt(i))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Dt(t.a))}parseNodeSpecialProperty(e,t,s){const n=s.split('",').map(function(p){return p.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=Dt(h);break}this.getPrevNode()[i]={type:o,type2:r,flag:a,value:h},this.setCurrentProp(this.getPrevNode(),i)}}class Si{parse(e){const t=new xs(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 vs;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]:"",p=a.length>1?a[1]:"",d=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),p!==""&&(s.attrName=p),d!==""&&(s.attrType=d),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=gn(new Uint8Array(e.getArrayBuffer(o))),a=new xs(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 xs{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 vs{add(e,t){this[e]=t}}function Ti(l){const e="Kaydara FBX Binary \0";return l.byteLength>=e.length&&e===Ss(l,0,e.length)}function Li(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 As(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 Ci(l){return l/46186158e3}const Oi=[];function pt(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 Di(Oi,s.buffer,i,o)}const Pt=new c.Euler,qe=new c.Vector3;function Ms(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,p=new c.Matrix4,d=new c.Matrix4,m=new c.Matrix4,f=l.inheritType?l.inheritType:0;if(l.translation&&e.setPosition(qe.fromArray(l.translation)),l.preRotation){const F=l.preRotation.map(c.MathUtils.degToRad);F.push(l.eulerOrder),t.makeRotationFromEuler(Pt.fromArray(F))}if(l.rotation){const F=l.rotation.map(c.MathUtils.degToRad);F.push(l.eulerOrder),s.makeRotationFromEuler(Pt.fromArray(F))}if(l.postRotation){const F=l.postRotation.map(c.MathUtils.degToRad);F.push(l.eulerOrder),n.makeRotationFromEuler(Pt.fromArray(F)),n.invert()}l.scale&&i.scale(qe.fromArray(l.scale)),l.scalingOffset&&r.setPosition(qe.fromArray(l.scalingOffset)),l.scalingPivot&&o.setPosition(qe.fromArray(l.scalingPivot)),l.rotationOffset&&a.setPosition(qe.fromArray(l.rotationOffset)),l.rotationPivot&&h.setPosition(qe.fromArray(l.rotationPivot)),l.parentMatrixWorld&&(d.copy(l.parentMatrix),p.copy(l.parentMatrixWorld));const w=t.clone().multiply(s).multiply(n),y=new c.Matrix4;y.extractRotation(p);const v=new c.Matrix4;v.copyPosition(p);const M=v.clone().invert().multiply(p),L=y.clone().invert().multiply(M),b=i,g=new c.Matrix4;if(f===0)g.copy(y).multiply(w).multiply(L).multiply(b);else if(f===1)g.copy(y).multiply(L).multiply(w).multiply(b);else{const I=new c.Matrix4().scale(new c.Vector3().setFromMatrixScale(d)).clone().invert(),B=L.clone().multiply(I);g.copy(y).multiply(w).multiply(B).multiply(b)}const S=h.clone().invert(),A=o.clone().invert();let _=e.clone().multiply(a).multiply(h).multiply(t).multiply(s).multiply(n).multiply(S).multiply(r).multiply(o).multiply(i).multiply(A);const x=new c.Matrix4().copyPosition(_),D=p.clone().multiply(x);return m.copyPosition(D),_=m.clone().multiply(g),_.premultiply(p.invert()),_}function bs(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 Dt(l){return l.split(",").map(function(t){return parseFloat(t)})}function Ss(l,e,t){return e===void 0&&(e=0),t===void 0&&(t=l.byteLength),c.LoaderUtils.decodeText(new Uint8Array(l,e,t))}function Pi(l,e){for(let t=0,s=l.length,n=e.length;t<n;t++,s++)l[s]=e[t]}function Di(l,e,t,s){for(let n=t,i=0;n<s;n++,i++)l[i]=e[n];return l}function Ts(l,e,t){return l.slice(0,e).concat(t).concat(l.slice(e))}var Ii=Object.defineProperty,Fi=(l,e,t)=>e in l?Ii(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,It=(l,e,t)=>(Fi(l,typeof e!="symbol"?e+"":e,t),t);class ki 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 Ft(e)}}class Ft{constructor(e){It(this,"data"),this.data=e}generateShapes(e,t=100,s){const n=[],i={letterSpacing:0,lineHeight:1,...s},o=Bi(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}}It(Ft,"isFont"),It(Ft,"type");function Bi(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 p=0;p<n.length;p++){const d=n[p];if(d===`
73
+ `};function _s(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 di(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 p=o[h+1],d=i[r-h],m=n[h]/(p+d);n[h]=a+p*m,a=d*m}n[r]=a}return n}function mi(l,e,t,s){const n=_s(l,s,e),i=di(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],p=a.w*h;o.x+=a.x*p,o.y+=a.y*p,o.z+=a.z*p,o.w+=a.w*h}return o}function fi(l,e,t,s,n){const i=[];for(let d=0;d<=t;++d)i[d]=0;const o=[];for(let d=0;d<=s;++d)o[d]=i.slice(0);const r=[];for(let d=0;d<=t;++d)r[d]=i.slice(0);r[0][0]=1;const a=i.slice(0),h=i.slice(0);for(let d=1;d<=t;++d){a[d]=e-n[l+1-d],h[d]=n[l+d]-e;let m=0;for(let f=0;f<d;++f){const w=h[f+1],y=a[d-f];r[d][f]=w+y;const v=r[f][d-1]/r[d][f];r[f][d]=m+w*v,m=y*v}r[d][d]=m}for(let d=0;d<=t;++d)o[0][d]=r[d][t];for(let d=0;d<=t;++d){let m=0,f=1;const w=[];for(let y=0;y<=t;++y)w[y]=i.slice(0);w[0][0]=1;for(let y=1;y<=s;++y){let v=0;const M=d-y,L=t-y;d>=y&&(w[f][0]=w[m][0]/r[L+1][M],v=w[f][0]*r[M][L]);const b=M>=-1?1:-M,g=d-1<=L?y-1:t-d;for(let A=b;A<=g;++A)w[f][A]=(w[m][A]-w[m][A-1])/r[L+1][M+A],v+=w[f][A]*r[M+A][L];d<=L&&(w[f][y]=-w[m][y-1]/r[L+1][d],v+=w[f][y]*r[d][L]),o[y][d]=v;const S=m;m=f,f=S}}let p=t;for(let d=1;d<=s;++d){for(let m=0;m<=t;++m)o[d][m]*=p;p*=t-d}return o}function gi(l,e,t,s,n){const i=n<l?n:l,o=[],r=_s(l,s,e),a=fi(r,s,l,i,e),h=[];for(let p=0;p<t.length;++p){const d=t[p].clone(),m=d.w;d.x*=m,d.y*=m,d.z*=m,h[p]=d}for(let p=0;p<=i;++p){const d=h[r-l].clone().multiplyScalar(a[p][0]);for(let m=1;m<=l;++m)d.add(h[r-l+m].clone().multiplyScalar(a[p][m]));o[p]=d}for(let p=i+1;p<=n+1;++p)o[p]=new c.Vector4(0,0,0);return o}function yi(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 _i(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(yi(i,r)*s[r]));n[i]=o.divideScalar(s[0])}return n}function wi(l,e,t,s,n){const i=gi(l,e,t,s,n);return _i(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=mi(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=wi(this.degree,this.knots,this.controlPoints,n,1);return s.copy(i[1]).normalize(),s}}let j,ie,de;class xi 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(Ti(e))j=new Si().parse(e);else{const n=Ss(e);if(!Li(n))throw new Error("THREE.FBXLoader: Unknown format.");if(As(n)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+As(n));j=new bi().parse(n)}const s=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new vi(s,this.manager).parse(j)}}class vi{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){ie=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),s=this.parseMaterials(t),n=this.parseDeformers(),i=new Ai().parse(n);return this.parseScene(n,i,s),de}parseConnections(){const e=new Map;return"Connections"in j&&j.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 j.Objects){const s=j.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 j.Objects){const s=j.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=ie.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 j.Objects){const s=j.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),!ie.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 ie.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 j.Objects&&t in j.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=ie.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in j.Objects){const s=j.Objects.Deformer;for(const n in s){const i=s[n],o=ie.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=ie.get(parseInt(i.ID)).children.filter(function(a){return a.relationship===void 0})[0].ID,s.push(r)}return s}parseScene(e,t,s){de=new c.Group;const n=this.parseModels(e.skeletons,t,s),i=j.Objects.Model,o=this;n.forEach(function(a){const h=i[a.ID];o.setLookAtProperties(a,h),ie.get(a.ID).parents.forEach(function(d){const m=n.get(d.ID);m!==void 0&&m.add(a)}),a.parent===null&&de.add(a)}),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),de.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=Ms(a.userData.transformData);a.applyMatrix4(h),a.updateWorldMatrix()}});const r=new Mi().parse();de.children.length===1&&de.children[0].isGroup&&(de.children[0].animations=r,de=de.children[0]),de.animations=r}parseModels(e,t,s){const n=new Map,i=j.Objects.Model;for(const o in i){const r=parseInt(o),a=i[o],h=ie.get(r);let p=this.buildSkeleton(h,e,r,a.attrName);if(!p){switch(a.attrType){case"Camera":p=this.createCamera(h);break;case"Light":p=this.createLight(h);break;case"Mesh":p=this.createMesh(h,t,s);break;case"NurbsCurve":p=this.createCurve(h,t);break;case"LimbNode":case"Root":p=new c.Bone;break;case"Null":default:p=new c.Group;break}p.name=a.attrName?c.PropertyBinding.sanitizeNodeName(a.attrName):"",p.ID=r}this.getTransformData(p,a),n.set(r,p)}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,p){if(h.ID===o.ID){const d=i;i=new c.Bone,i.matrixWorld.copy(h.transformLink),i.name=n?c.PropertyBinding.sanitizeNodeName(n):"",i.ID=s,a.bones[p]=i,d!==null&&i.add(d)}})}}),i}createCamera(e){let t,s;if(e.children.forEach(function(n){const i=j.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 p=45;s.FieldOfView!==void 0&&(p=s.FieldOfView.value);const d=s.FocalLength?s.FocalLength.value:null;switch(n){case 0:t=new c.PerspectiveCamera(p,h,i,o),d!==null&&t.setFocalLength(d);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=j.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 p=0;s.OuterAngle!==void 0&&(p=c.MathUtils.degToRad(s.OuterAngle.value),p=Math.max(p,1)),t=new c.SpotLight(i,o,r,h,p,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=bs(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&&ie.get(e.ID).children.forEach(function(n){if(n.relationship==="LookAtProperty"){const i=j.Objects.Model[n.ID];if("Lcl_Translation"in i){const o=i.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),de.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];ie.get(parseInt(o.ID)).parents.forEach(function(a){if(t.has(a.ID)){const h=a.ID;ie.get(h).parents.forEach(function(d){s.has(d.ID)&&s.get(d.ID).bind(new c.Skeleton(o.bones),n[d.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in j.Objects){const t=j.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 j&&"AmbientColor"in j.GlobalSettings){const e=j.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);de.add(new c.AmbientLight(i,1))}}}}class Ai{parse(e){const t=new Map;if("Geometry"in j.Objects){const s=j.Objects.Geometry;for(const n in s){const i=ie.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(d){return j.Objects.Model[d.ID]});if(o.length===0)return;const r=e.children.reduce(function(d,m){return n[m.ID]!==void 0&&(d=n[m.ID]),d},null);e.children.forEach(function(d){s.morphTargets[d.ID]!==void 0&&i.push(s.morphTargets[d.ID])});const a=o[0],h={};"RotationOrder"in a&&(h.eulerOrder=bs(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 p=Ms(h);return this.genGeometry(t,r,i,p)}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),p=new c.Float32BufferAttribute(r.normal,3);p.applyNormalMatrix(h),i.setAttribute("normal",p)}if(r.uvs.forEach(function(h,p){let d="uv"+(p+1).toString();p===0&&(d="uv"),i.setAttribute(d,new c.Float32BufferAttribute(r.uvs[p],2))}),o.material&&o.material.mappingType!=="AllSame"){let h=r.materialIndex[0],p=0;if(r.materialIndex.forEach(function(d,m){d!==h&&(i.addGroup(p,m-p,h),h=d,p=m)}),i.groups.length>0){const d=i.groups[i.groups.length-1],m=d.start+d.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=[],p=[],d=[];const m=this;return e.vertexIndices.forEach(function(f,w){let y,v=!1;f<0&&(f=f^-1,v=!0);let M=[],L=[];if(o.push(f*3,f*3+1,f*3+2),e.color){const b=pt(w,s,f,e.color);a.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(b){L.push(b.weight),M.push(b.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 b=[0,0,0,0],g=[0,0,0,0];L.forEach(function(S,A){let _=S,x=M[A];g.forEach(function(D,k,I){if(_>D){I[k]=_,_=D;const B=b[k];b[k]=x,x=B}})}),M=b,L=g}for(;L.length<4;)L.push(0),M.push(0);for(let b=0;b<4;++b)p.push(L[b]),d.push(M[b])}if(e.normal){const b=pt(w,s,f,e.normal);r.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(y=pt(w,s,f,e.material)[0]),e.uv&&e.uv.forEach(function(b,g){const S=pt(w,s,f,b);h[g]===void 0&&(h[g]=[]),h[g].push(S[0]),h[g].push(S[1])}),n++,v&&(m.genFace(t,e,o,y,r,a,h,p,d,n),s++,n=0,o=[],r=[],a=[],h=[],p=[],d=[])}),t}genFace(e,t,s,n,i,o,r,a,h,p){for(let d=2;d<p;d++)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[(d-1)*3]]),e.vertex.push(t.vertexPositions[s[(d-1)*3+1]]),e.vertex.push(t.vertexPositions[s[(d-1)*3+2]]),e.vertex.push(t.vertexPositions[s[d*3]]),e.vertex.push(t.vertexPositions[s[d*3+1]]),e.vertex.push(t.vertexPositions[s[d*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[(d-1)*4]),e.vertexWeights.push(a[(d-1)*4+1]),e.vertexWeights.push(a[(d-1)*4+2]),e.vertexWeights.push(a[(d-1)*4+3]),e.vertexWeights.push(a[d*4]),e.vertexWeights.push(a[d*4+1]),e.vertexWeights.push(a[d*4+2]),e.vertexWeights.push(a[d*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[(d-1)*4]),e.weightsIndices.push(h[(d-1)*4+1]),e.weightsIndices.push(h[(d-1)*4+2]),e.weightsIndices.push(h[(d-1)*4+3]),e.weightsIndices.push(h[d*4]),e.weightsIndices.push(h[d*4+1]),e.weightsIndices.push(h[d*4+2]),e.weightsIndices.push(h[d*4+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[(d-1)*3]),e.colors.push(o[(d-1)*3+1]),e.colors.push(o[(d-1)*3+2]),e.colors.push(o[d*3]),e.colors.push(o[d*3+1]),e.colors.push(o[d*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[(d-1)*3]),e.normal.push(i[(d-1)*3+1]),e.normal.push(i[(d-1)*3+2]),e.normal.push(i[d*3]),e.normal.push(i[d*3+1]),e.normal.push(i[d*3+2])),t.uv&&t.uv.forEach(function(m,f){e.uvs[f]===void 0&&(e.uvs[f]=[]),e.uvs[f].push(r[f][0]),e.uvs[f].push(r[f][1]),e.uvs[f].push(r[f][(d-1)*2]),e.uvs[f].push(r[f][(d-1)*2+1]),e.uvs[f].push(r[f][d*2]),e.uvs[f].push(r[f][d*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=j.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,p=new Float32Array(h);for(let w=0;w<a.length;w++){const y=a[w]*3;p[y]=r[w*3],p[y+1]=r[w*3+1],p[y+2]=r[w*3+2]}const d={vertexIndices:o,vertexPositions:p},m=this.genBuffers(d),f=new c.Float32BufferAttribute(m.vertex,3);f.name=i||s.attrName,f.applyMatrix4(n),e.morphAttributes.position.push(f)}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 d=0,m=o.length;d<m;d+=4)i.push(new c.Vector4().fromArray(o,d));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 d=0;d<s;++d)i.push(i[d])}const p=new ws(s,n,i,r,a).getPoints(i.length*12);return new c.BufferGeometry().setFromPoints(p)}}class Mi{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(j.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=j.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=j.Objects.AnimationCurve;for(const s in t){const n={id:t[s].id,times:t[s].KeyTime.a.map(Ci),values:t[s].KeyValueFloat.a},i=ie.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=j.Objects.AnimationLayer,s=new Map;for(const n in t){const i=[],o=ie.get(parseInt(n));o!==void 0&&(o.children.forEach(function(a,h){if(e.has(a.ID)){const p=e.get(a.ID);if(p.curves.x!==void 0||p.curves.y!==void 0||p.curves.z!==void 0){if(i[h]===void 0){const d=ie.get(a.ID).parents.filter(function(m){return m.relationship!==void 0})[0].ID;if(d!==void 0){const m=j.Objects.Model[d.toString()];if(m===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",a);return}const f={modelName:m.attrName?c.PropertyBinding.sanitizeNodeName(m.attrName):"",ID:m.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};de.traverse(function(w){w.ID===m.id&&(f.transform=w.matrix,w.userData.transformData&&(f.eulerOrder=w.userData.transformData.eulerOrder))}),f.transform||(f.transform=new c.Matrix4),"PreRotation"in m&&(f.preRotation=m.PreRotation.value),"PostRotation"in m&&(f.postRotation=m.PostRotation.value),i[h]=f}}i[h]&&(i[h][p.attr]=p)}else if(p.curves.morph!==void 0){if(i[h]===void 0){const d=ie.get(a.ID).parents.filter(function(M){return M.relationship!==void 0})[0].ID,m=ie.get(d).parents[0].ID,f=ie.get(m).parents[0].ID,w=ie.get(f).parents[0].ID,y=j.Objects.Model[w],v={modelName:y.attrName?c.PropertyBinding.sanitizeNodeName(y.attrName):"",morphName:j.Objects.Deformer[d].attrName};i[h]=v}i[h][p.attr]=p}}}),s.set(parseInt(n),i))}return s}parseAnimStacks(e){const t=j.Objects.AnimationStack,s={};for(const n in t){const i=ie.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,p=new c.Euler,d=[];for(let m=0;m<a.length;m+=3)p.set(a[m],a[m+1],a[m+2],o),h.setFromEuler(p),n!==void 0&&h.premultiply(n),i!==void 0&&h.multiply(i),h.toArray(d,m/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",r,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,s=t.values.map(function(i){return i/100}),n=de.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 p=t.x.values[o];i.push(p),n[0]=p}else i.push(n[0]);if(r!==-1){const p=t.y.values[r];i.push(p),n[1]=p}else i.push(n[1]);if(a!==-1){const p=t.z.values[a];i.push(p),n[2]=p}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],d=(e.times[t]-h)/o;let m=h+d;const f=[],w=[];for(;m<e.times[t];)f.push(m),m+=d,w.push(a),a+=r;e.times=Ts(e.times,t,f),e.values=Ts(e.values,t,w)}}}}class bi{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 vs,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](.*)"),p=n.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(n,a):h?t.parseNodeProperty(n,h,s[++i]):p?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]),p=parseInt(a[1]);let d=i.split(",").slice(3);d=d.map(function(m){return m.trim().replace(/^"/,"")}),n="connections",i=[h,p],Pi(i,d),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=Dt(i))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Dt(t.a))}parseNodeSpecialProperty(e,t,s){const n=s.split('",').map(function(p){return p.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=Dt(h);break}this.getPrevNode()[i]={type:o,type2:r,flag:a,value:h},this.setCurrentProp(this.getPrevNode(),i)}}class Si{parse(e){const t=new xs(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 vs;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]:"",p=a.length>1?a[1]:"",d=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),p!==""&&(s.attrName=p),d!==""&&(s.attrType=d),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=gn(new Uint8Array(e.getArrayBuffer(o))),a=new xs(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 xs{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 vs{add(e,t){this[e]=t}}function Ti(l){const e="Kaydara FBX Binary \0";return l.byteLength>=e.length&&e===Ss(l,0,e.length)}function Li(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 As(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 Ci(l){return l/46186158e3}const Oi=[];function pt(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 Di(Oi,s.buffer,i,o)}const Pt=new c.Euler,qe=new c.Vector3;function Ms(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,p=new c.Matrix4,d=new c.Matrix4,m=new c.Matrix4,f=l.inheritType?l.inheritType:0;if(l.translation&&e.setPosition(qe.fromArray(l.translation)),l.preRotation){const k=l.preRotation.map(c.MathUtils.degToRad);k.push(l.eulerOrder),t.makeRotationFromEuler(Pt.fromArray(k))}if(l.rotation){const k=l.rotation.map(c.MathUtils.degToRad);k.push(l.eulerOrder),s.makeRotationFromEuler(Pt.fromArray(k))}if(l.postRotation){const k=l.postRotation.map(c.MathUtils.degToRad);k.push(l.eulerOrder),n.makeRotationFromEuler(Pt.fromArray(k)),n.invert()}l.scale&&i.scale(qe.fromArray(l.scale)),l.scalingOffset&&r.setPosition(qe.fromArray(l.scalingOffset)),l.scalingPivot&&o.setPosition(qe.fromArray(l.scalingPivot)),l.rotationOffset&&a.setPosition(qe.fromArray(l.rotationOffset)),l.rotationPivot&&h.setPosition(qe.fromArray(l.rotationPivot)),l.parentMatrixWorld&&(d.copy(l.parentMatrix),p.copy(l.parentMatrixWorld));const w=t.clone().multiply(s).multiply(n),y=new c.Matrix4;y.extractRotation(p);const v=new c.Matrix4;v.copyPosition(p);const M=v.clone().invert().multiply(p),L=y.clone().invert().multiply(M),b=i,g=new c.Matrix4;if(f===0)g.copy(y).multiply(w).multiply(L).multiply(b);else if(f===1)g.copy(y).multiply(L).multiply(w).multiply(b);else{const I=new c.Matrix4().scale(new c.Vector3().setFromMatrixScale(d)).clone().invert(),B=L.clone().multiply(I);g.copy(y).multiply(w).multiply(B).multiply(b)}const S=h.clone().invert(),A=o.clone().invert();let _=e.clone().multiply(a).multiply(h).multiply(t).multiply(s).multiply(n).multiply(S).multiply(r).multiply(o).multiply(i).multiply(A);const x=new c.Matrix4().copyPosition(_),D=p.clone().multiply(x);return m.copyPosition(D),_=m.clone().multiply(g),_.premultiply(p.invert()),_}function bs(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 Dt(l){return l.split(",").map(function(t){return parseFloat(t)})}function Ss(l,e,t){return e===void 0&&(e=0),t===void 0&&(t=l.byteLength),c.LoaderUtils.decodeText(new Uint8Array(l,e,t))}function Pi(l,e){for(let t=0,s=l.length,n=e.length;t<n;t++,s++)l[s]=e[t]}function Di(l,e,t,s){for(let n=t,i=0;n<s;n++,i++)l[i]=e[n];return l}function Ts(l,e,t){return l.slice(0,e).concat(t).concat(l.slice(e))}var Ii=Object.defineProperty,ki=(l,e,t)=>e in l?Ii(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,It=(l,e,t)=>(ki(l,typeof e!="symbol"?e+"":e,t),t);class Fi 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 kt(e)}}class kt{constructor(e){It(this,"data"),this.data=e}generateShapes(e,t=100,s){const n=[],i={letterSpacing:0,lineHeight:1,...s},o=Bi(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}}It(kt,"isFont"),It(kt,"type");function Bi(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 p=0;p<n.length;p++){const d=n[p];if(d===`
74
74
  `)a=0,h-=o*s.lineHeight;else{const m=Ui(d,i,a,h,t);m&&(a+=m.offsetX+s.letterSpacing,r.push(m.path))}}return r}function Ui(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,p,d,m,f,w;if(i.o){const y=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let v=0,M=y.length;v<M;)switch(y[v++]){case"m":r=parseInt(y[v++])*e+t,a=parseInt(y[v++])*e+s,o.moveTo(r,a);break;case"l":r=parseInt(y[v++])*e+t,a=parseInt(y[v++])*e+s,o.lineTo(r,a);break;case"q":h=parseInt(y[v++])*e+t,p=parseInt(y[v++])*e+s,d=parseInt(y[v++])*e+t,m=parseInt(y[v++])*e+s,o.quadraticCurveTo(d,m,h,p);break;case"b":h=parseInt(y[v++])*e+t,p=parseInt(y[v++])*e+s,d=parseInt(y[v++])*e+t,m=parseInt(y[v++])*e+s,f=parseInt(y[v++])*e+t,w=parseInt(y[v++])*e+s,o.bezierCurveTo(d,m,f,w,h,p);break}}return{offsetX:i.ha*e,path:o}}class Ni extends c.DataTextureLoader{constructor(e){super(e),this.type=c.HalfFloatType}parse(e){const r=function(b,g){switch(b){case 1:console.error("THREE.RGBELoader Read Error: "+(g||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(g||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(g||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(g||""))}return-1},d=`
75
- `,m=function(b,g,S){g=g||1024;let _=b.pos,x=-1,D=0,F="",I=String.fromCharCode.apply(null,new Uint16Array(b.subarray(_,_+128)));for(;0>(x=I.indexOf(d))&&D<g&&_<b.byteLength;)F+=I,D+=I.length,_+=128,I+=String.fromCharCode.apply(null,new Uint16Array(b.subarray(_,_+128)));return-1<x?(S!==!1&&(b.pos+=D+x+1),F+I.slice(0,x)):!1},f=function(b){const g=/^#\?(\S+)/,S=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,A=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,x=/^\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 F,I;if(b.pos>=b.byteLength||!(F=m(b)))return r(1,"no header found");if(!(I=F.match(g)))return r(3,"bad initial token");for(D.valid|=1,D.programtype=I[1],D.string+=F+`
76
- `;F=m(b),F!==!1;){if(D.string+=F+`
77
- `,F.charAt(0)==="#"){D.comments+=F+`
78
- `;continue}if((I=F.match(S))&&(D.gamma=parseFloat(I[1])),(I=F.match(A))&&(D.exposure=parseFloat(I[1])),(I=F.match(_))&&(D.valid|=2,D.format=I[1]),(I=F.match(x))&&(D.valid|=4,D.height=parseInt(I[1],10),D.width=parseInt(I[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(b,g,S){const A=g;if(A<8||A>32767||b[0]!==2||b[1]!==2||b[2]&128)return new Uint8Array(b);if(A!==(b[2]<<8|b[3]))return r(3,"wrong scanline width");const _=new Uint8Array(4*g*S);if(!_.length)return r(4,"unable to allocate buffer space");let x=0,D=0;const F=4*A,I=new Uint8Array(4),B=new Uint8Array(F);let R=S;for(;R>0&&D<b.byteLength;){if(D+4>b.byteLength)return r(1);if(I[0]=b[D++],I[1]=b[D++],I[2]=b[D++],I[3]=b[D++],I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=A)return r(3,"bad rgbe scanline format");let H=0,G;for(;H<F&&D<b.byteLength;){G=b[D++];const X=G>128;if(X&&(G-=128),G===0||H+G>F)return r(3,"bad scanline data");if(X){const le=b[D++];for(let oe=0;oe<G;oe++)B[H++]=le}else B.set(b.subarray(D,D+G),H),H+=G,D+=G}const se=A;for(let X=0;X<se;X++){let le=0;_[x]=B[X+le],le+=A,_[x+1]=B[X+le],le+=A,_[x+2]=B[X+le],le+=A,_[x+3]=B[X+le],x+=4}R--}return _},y=function(b,g,S,A){const _=b[g+3],x=Math.pow(2,_-128)/255;S[A+0]=b[g+0]*x,S[A+1]=b[g+1]*x,S[A+2]=b[g+2]*x,S[A+3]=1},v=function(b,g,S,A){const _=b[g+3],x=Math.pow(2,_-128)/255;S[A+0]=c.DataUtils.toHalfFloat(Math.min(b[g+0]*x,65504)),S[A+1]=c.DataUtils.toHalfFloat(Math.min(b[g+1]*x,65504)),S[A+2]=c.DataUtils.toHalfFloat(Math.min(b[g+2]*x,65504)),S[A+3]=c.DataUtils.toHalfFloat(1)},M=new Uint8Array(e);M.pos=0;const L=f(M);if(L!==-1){const b=L.width,g=L.height,S=w(M.subarray(M.pos),b,g);if(S!==-1){let A,_,x;switch(this.type){case c.FloatType:x=S.length/4;const D=new Float32Array(x*4);for(let I=0;I<x;I++)y(S,I*4,D,I*4);A=D,_=c.FloatType;break;case c.HalfFloatType:x=S.length/4;const F=new Uint16Array(x*4);for(let I=0;I<x;I++)v(S,I*4,F,I*4);A=F,_=c.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:b,height:g,data:A,header:L.string,gamma:L.gamma,exposure:L.exposure,type:_}}}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)}}const kt=new WeakMap;class Vi 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(kt.has(e)){const a=kt.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,p)=>{n._callbacks[i]={resolve:h,reject:p},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)}),kt.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=Ei.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 Ei(){let l,e;onmessage=function(o){const r=o.data;switch(r.type){case"init":l=r.decoderConfig,e=new Promise(function(p){l.onModuleLoaded=function(d){p({draco:d})},DracoDecoderModule(l)});break;case"decode":const a=r.buffer,h=r.taskConfig;e.then(p=>{const d=p.draco,m=new d.Decoder,f=new d.DecoderBuffer;f.Init(new Int8Array(a),a.byteLength);try{const w=t(d,m,f,h),y=w.attributes.map(v=>v.array.buffer);w.index&&y.push(w.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:w},y)}catch(w){console.error(w),self.postMessage({type:"error",id:r.id,error:w.message})}finally{d.destroy(f),d.destroy(m)}});break}};function t(o,r,a,h){const p=h.attributeIDs,d=h.attributeTypes;let m,f;const w=r.GetEncodedGeometryType(a);if(w===o.TRIANGULAR_MESH)m=new o.Mesh,f=r.DecodeBufferToMesh(a,m);else if(w===o.POINT_CLOUD)m=new o.PointCloud,f=r.DecodeBufferToPointCloud(a,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const y={index:null,attributes:[]};for(const v in p){const M=self[d[v]];let L,b;if(h.useUniqueIDs)b=p[v],L=r.GetAttributeByUniqueId(m,b);else{if(b=r.GetAttributeId(m,o[p[v]]),b===-1)continue;L=r.GetAttribute(m,b)}y.attributes.push(n(o,r,m,v,M,L))}return w===o.TRIANGULAR_MESH&&(y.index=s(o,r,m)),o.destroy(m),y}function s(o,r,a){const p=a.num_faces()*3,d=p*4,m=o._malloc(d);r.GetTrianglesUInt32Array(a,d,m);const f=new Uint32Array(o.HEAPF32.buffer,m,p).slice();return o._free(m),{array:f,itemSize:1}}function n(o,r,a,h,p,d){const m=d.num_components(),w=a.num_points()*m,y=w*p.BYTES_PER_ELEMENT,v=i(o,p),M=o._malloc(y);r.GetAttributeDataArrayForAllPoints(a,d,v,y,M);const L=new p(o.HEAPF32.buffer,M,w).slice();return o._free(M),{name:h,array:L,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 zi=["args","center"],Ri=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:p,curveSegments:d,bevelEnabled:m,bevelThickness:f,bevelSize:w,bevelOffset:y,bevelSegments:v}=u.toRefs(n),{extend:M}=q.useTresContext();M({TextGeometry:ys});const L=new ki,b=u.useSlots(),g=u.computed(()=>{var x;return r!=null&&r.value?r.value:b.default?(x=b.default()[0].children)==null?void 0:x.trim():a.value?"":"TresJS"}),S=u.shallowRef();e({value:S});const A=([t,s]=u.withAsyncContext(()=>new Promise((x,D)=>{try{typeof o.value=="string"?L.load(o.value,F=>{x(F)}):x(o.value)}catch(F){D(console.error("cientos",F))}})),t=await t,s(),t),_=u.computed(()=>({font:A,size:u.toValue(h),height:u.toValue(p),curveSegments:u.toValue(d),bevelEnabled:u.toValue(m),bevelThickness:u.toValue(f),bevelSize:u.toValue(w),bevelOffset:u.toValue(y),bevelSegments:u.toValue(v)}));return u.watchEffect(()=>{S.value&&a.value&&(S.value.geometry.dispose(),S.value.geometry=new ys(g.value,_.value),i.value&&S.value.geometry.center())}),(x,D)=>u.unref(o)?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:S},[g.value?(u.openBlock(),u.createElementBlock("TresTextGeometry",{key:0,args:[g.value,_.value],center:u.unref(i)},null,8,zi)):u.createCommentVNode("",!0),u.renderSlot(x.$slots,"default")],512)):u.createCommentVNode("",!0)}});function Gi(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}=q.useRenderLoop();return i(({delta:o})=>{s.update(o)}),{actions:n,mixer:s}}const Bt={sunset:"venice/venice_sunset_4k.hdr"};async function Ls({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}=q.useTresContext();if(n){if(!(n in Bt))throw new Error("Preset must be one of: "+Object.keys(Bt).join(", "));l=Bt[n],s="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/"}const o=Array.isArray(l),r=o?c.CubeTextureLoader:Ni,a=await q.useLoader(r,o?[l]:l,p=>{s&&p.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&&(i.value.background=h),e&&(i.value.backgroundBlurriness=e|0)),h}const Yi=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 Ls(l),()=>{}}}),ji=["position","a-scale"],Xi=["size","size-attenuation","transparent","alpha-test","alpha-map"],Zi=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:p,alphaMap:d,alphaTest:m}=u.toRefs(t),f=()=>{let y=i.value+o.value;const v=u.computed(()=>o.value/r.value),M=[],L=Array.from({length:r.value},()=>(.5+.5*Math.random())*4),b=g=>new c.Vector3().setFromSpherical(new c.Spherical(g,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let g=0;g<r.value;g++)y-=v.value*Math.random(),M.push(...b(y));s.value=new Float32Array(M),n.value=new Float32Array(L)};u.watchEffect(()=>{f()});const w=u.shallowRef();return e({value:w}),(y,v)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"starsRef",ref:w},[u.createElementVNode("TresBufferGeometry",{position:[s.value,3],"a-scale":[n.value,1]},null,8,ji),u.createElementVNode("TresPointsMaterial",{size:u.unref(a),"size-attenuation":u.unref(h),transparent:u.unref(p),"alpha-test":u.unref(m),"alpha-map":u.unref(d)},null,8,Xi)],512))}}),Qi=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Ki=["position","velocity"],Wi=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:p,sizeAttenuation:d,count:m,speed:f,randomness:w}=u.toRefs(e),y=u.shallowRef();let v=[],M=[];const L=()=>{v=new Float32Array(m.value*3);for(let S=0;S<m.value;S++){const A=S*3;v[A]=(Math.random()-.5)*s.value[0],v[A+1]=(Math.random()-.5)*s.value[1],v[A+2]=(Math.random()-.5)*s.value[2]}},b=()=>{M=new Float32Array(m.value*2);for(let S=0;S<m.value*2;S+=2)M[S]=(Math.random()-.5)/5*f.value*w.value,M[S+1]=Math.random()/5*f.value+.01};b(),L(),u.watchEffect(()=>{b(),L()});const{onLoop:g}=q.useRenderLoop();return g(()=>{var S,A;if((S=y.value)!=null&&S.attributes.position.array&&((A=y.value)!=null&&A.attributes.position.count)){const _=y.value.attributes.position.array;for(let x=0;x<y.value.attributes.position.count;x++){const D=M[x*2],F=M[x*2+1];_[x*3]+=D,_[x*3+1]-=F,(_[x*3]<=-s.value[0]/2||_[x*3]>=s.value[0]/2)&&(_[x*3]=_[x*3]*-1),(_[x*3+1]<=-s.value[1]/2||_[x*3+1]>=s.value[1]/2)&&(_[x*3+1]=_[x*3+1]*-1)}y.value.attributes.position.needsUpdate=!0}}),(S,A)=>(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(p),"size-attenuation":u.unref(d)},null,8,Qi),u.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:y,position:[u.unref(v),3],velocity:[u.unref(M)]},null,8,Ki)]))}}),qi=["position"],Ji=["position"],Hi=["scale"],$i=["map","depth-test","color-space","color","opacity"],eo=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:p,opacity:d,speed:m}=u.toRefs(n),f=u.shallowRef(),w=u.shallowRef();e({value:f});const y=[...new Array(r)].map((A,_)=>({x:i.value/2-Math.random()*i.value,y:i.value/2-Math.random()*i.value,scale:.4+Math.sin((_+1)/r.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*m.value})),v=(A,_)=>A/6*_*d.value,{map:M}=([t,s]=u.withAsyncContext(()=>q.useTexture({map:a.value})),t=await t,s(),t),{renderer:L,camera:b}=q.useTresContext(),g=u.computed(()=>{var A;return(A=L.value)==null?void 0:A.outputColorSpace}),{onLoop:S}=q.useRenderLoop();return S(()=>{var A,_;f.value&&b.value&&w.value&&((A=w.value)==null||A.children.forEach((x,D)=>{x.rotation.z+=y[D].rotation}),f.value.lookAt((_=b.value)==null?void 0:_.position))}),(A,_)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"smokeRef",ref:f},A.$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(y),({scale:x,x:D,y:F,density:I},B)=>(u.openBlock(),u.createElementBlock("TresMesh",{key:`${B}`,position:[D,F,-B*u.unref(o)]},[u.createElementVNode("TresPlaneGeometry",{scale:[x,x,x],rotation:[0,0,0]},null,8,Hi),u.createElementVNode("TresMeshStandardMaterial",{map:u.unref(M),"depth-test":u.unref(p),"color-space":g.value,color:u.unref(h),"depth-write":!1,transparent:"",opacity:v(x,I)},null,8,$i)],8,Ji))),128))],8,qi)],16))}}),to=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}=q.useRenderLoop(),i=u.ref(Math.random()*1e4);return n(({elapsed:o})=>{var h,p;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,((p=t.range)==null?void 0:p[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))}}),so=["geometry"],no=["map","opacity","depth-write"],io=["args"],oo=["rotation","args"],ro=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:p,scene:d}=q.useTresContext(),m=u.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),f=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,f.value/2,-f.value/2,0,t.far),r=new c.PlaneGeometry(m.value,f.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=S=>{S.uniforms={...S.uniforms,ucolor:{value:t.color?new c.Color(t.color):new c.Color}},S.fragmentShader=S.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
75
+ `,m=function(b,g,S){g=g||1024;let _=b.pos,x=-1,D=0,k="",I=String.fromCharCode.apply(null,new Uint16Array(b.subarray(_,_+128)));for(;0>(x=I.indexOf(d))&&D<g&&_<b.byteLength;)k+=I,D+=I.length,_+=128,I+=String.fromCharCode.apply(null,new Uint16Array(b.subarray(_,_+128)));return-1<x?(S!==!1&&(b.pos+=D+x+1),k+I.slice(0,x)):!1},f=function(b){const g=/^#\?(\S+)/,S=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,A=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,x=/^\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 k,I;if(b.pos>=b.byteLength||!(k=m(b)))return r(1,"no header found");if(!(I=k.match(g)))return r(3,"bad initial token");for(D.valid|=1,D.programtype=I[1],D.string+=k+`
76
+ `;k=m(b),k!==!1;){if(D.string+=k+`
77
+ `,k.charAt(0)==="#"){D.comments+=k+`
78
+ `;continue}if((I=k.match(S))&&(D.gamma=parseFloat(I[1])),(I=k.match(A))&&(D.exposure=parseFloat(I[1])),(I=k.match(_))&&(D.valid|=2,D.format=I[1]),(I=k.match(x))&&(D.valid|=4,D.height=parseInt(I[1],10),D.width=parseInt(I[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(b,g,S){const A=g;if(A<8||A>32767||b[0]!==2||b[1]!==2||b[2]&128)return new Uint8Array(b);if(A!==(b[2]<<8|b[3]))return r(3,"wrong scanline width");const _=new Uint8Array(4*g*S);if(!_.length)return r(4,"unable to allocate buffer space");let x=0,D=0;const k=4*A,I=new Uint8Array(4),B=new Uint8Array(k);let R=S;for(;R>0&&D<b.byteLength;){if(D+4>b.byteLength)return r(1);if(I[0]=b[D++],I[1]=b[D++],I[2]=b[D++],I[3]=b[D++],I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=A)return r(3,"bad rgbe scanline format");let H=0,G;for(;H<k&&D<b.byteLength;){G=b[D++];const X=G>128;if(X&&(G-=128),G===0||H+G>k)return r(3,"bad scanline data");if(X){const le=b[D++];for(let oe=0;oe<G;oe++)B[H++]=le}else B.set(b.subarray(D,D+G),H),H+=G,D+=G}const se=A;for(let X=0;X<se;X++){let le=0;_[x]=B[X+le],le+=A,_[x+1]=B[X+le],le+=A,_[x+2]=B[X+le],le+=A,_[x+3]=B[X+le],x+=4}R--}return _},y=function(b,g,S,A){const _=b[g+3],x=Math.pow(2,_-128)/255;S[A+0]=b[g+0]*x,S[A+1]=b[g+1]*x,S[A+2]=b[g+2]*x,S[A+3]=1},v=function(b,g,S,A){const _=b[g+3],x=Math.pow(2,_-128)/255;S[A+0]=c.DataUtils.toHalfFloat(Math.min(b[g+0]*x,65504)),S[A+1]=c.DataUtils.toHalfFloat(Math.min(b[g+1]*x,65504)),S[A+2]=c.DataUtils.toHalfFloat(Math.min(b[g+2]*x,65504)),S[A+3]=c.DataUtils.toHalfFloat(1)},M=new Uint8Array(e);M.pos=0;const L=f(M);if(L!==-1){const b=L.width,g=L.height,S=w(M.subarray(M.pos),b,g);if(S!==-1){let A,_,x;switch(this.type){case c.FloatType:x=S.length/4;const D=new Float32Array(x*4);for(let I=0;I<x;I++)y(S,I*4,D,I*4);A=D,_=c.FloatType;break;case c.HalfFloatType:x=S.length/4;const k=new Uint16Array(x*4);for(let I=0;I<x;I++)v(S,I*4,k,I*4);A=k,_=c.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:b,height:g,data:A,header:L.string,gamma:L.gamma,exposure:L.exposure,type:_}}}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)}}const Ft=new WeakMap;class Vi 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(Ft.has(e)){const a=Ft.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,p)=>{n._callbacks[i]={resolve:h,reject:p},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)}),Ft.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=Ei.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 Ei(){let l,e;onmessage=function(o){const r=o.data;switch(r.type){case"init":l=r.decoderConfig,e=new Promise(function(p){l.onModuleLoaded=function(d){p({draco:d})},DracoDecoderModule(l)});break;case"decode":const a=r.buffer,h=r.taskConfig;e.then(p=>{const d=p.draco,m=new d.Decoder,f=new d.DecoderBuffer;f.Init(new Int8Array(a),a.byteLength);try{const w=t(d,m,f,h),y=w.attributes.map(v=>v.array.buffer);w.index&&y.push(w.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:w},y)}catch(w){console.error(w),self.postMessage({type:"error",id:r.id,error:w.message})}finally{d.destroy(f),d.destroy(m)}});break}};function t(o,r,a,h){const p=h.attributeIDs,d=h.attributeTypes;let m,f;const w=r.GetEncodedGeometryType(a);if(w===o.TRIANGULAR_MESH)m=new o.Mesh,f=r.DecodeBufferToMesh(a,m);else if(w===o.POINT_CLOUD)m=new o.PointCloud,f=r.DecodeBufferToPointCloud(a,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const y={index:null,attributes:[]};for(const v in p){const M=self[d[v]];let L,b;if(h.useUniqueIDs)b=p[v],L=r.GetAttributeByUniqueId(m,b);else{if(b=r.GetAttributeId(m,o[p[v]]),b===-1)continue;L=r.GetAttribute(m,b)}y.attributes.push(n(o,r,m,v,M,L))}return w===o.TRIANGULAR_MESH&&(y.index=s(o,r,m)),o.destroy(m),y}function s(o,r,a){const p=a.num_faces()*3,d=p*4,m=o._malloc(d);r.GetTrianglesUInt32Array(a,d,m);const f=new Uint32Array(o.HEAPF32.buffer,m,p).slice();return o._free(m),{array:f,itemSize:1}}function n(o,r,a,h,p,d){const m=d.num_components(),w=a.num_points()*m,y=w*p.BYTES_PER_ELEMENT,v=i(o,p),M=o._malloc(y);r.GetAttributeDataArrayForAllPoints(a,d,v,y,M);const L=new p(o.HEAPF32.buffer,M,w).slice();return o._free(M),{name:h,array:L,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 zi=["args","center"],Ri=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:p,curveSegments:d,bevelEnabled:m,bevelThickness:f,bevelSize:w,bevelOffset:y,bevelSegments:v}=u.toRefs(n),{extend:M}=q.useTresContext();M({TextGeometry:ys});const L=new Fi,b=u.useSlots(),g=u.computed(()=>{var x;return r!=null&&r.value?r.value:b.default?(x=b.default()[0].children)==null?void 0:x.trim():a.value?"":"TresJS"}),S=u.shallowRef();e({value:S});const A=([t,s]=u.withAsyncContext(()=>new Promise((x,D)=>{try{typeof o.value=="string"?L.load(o.value,k=>{x(k)}):x(o.value)}catch(k){D(console.error("cientos",k))}})),t=await t,s(),t),_=u.computed(()=>({font:A,size:u.toValue(h),height:u.toValue(p),curveSegments:u.toValue(d),bevelEnabled:u.toValue(m),bevelThickness:u.toValue(f),bevelSize:u.toValue(w),bevelOffset:u.toValue(y),bevelSegments:u.toValue(v)}));return u.watchEffect(()=>{S.value&&a.value&&(S.value.geometry.dispose(),S.value.geometry=new ys(g.value,_.value),i.value&&S.value.geometry.center())}),(x,D)=>u.unref(o)?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:S},[g.value?(u.openBlock(),u.createElementBlock("TresTextGeometry",{key:0,args:[g.value,_.value],center:u.unref(i)},null,8,zi)):u.createCommentVNode("",!0),u.renderSlot(x.$slots,"default")],512)):u.createCommentVNode("",!0)}});function Gi(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}=q.useRenderLoop();return i(({delta:o})=>{s.update(o)}),{actions:n,mixer:s}}const Bt={sunset:"venice/venice_sunset_4k.hdr"};async function Ls({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}=q.useTresContext();if(n){if(!(n in Bt))throw new Error("Preset must be one of: "+Object.keys(Bt).join(", "));l=Bt[n],s="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/"}const o=Array.isArray(l),r=o?c.CubeTextureLoader:Ni,a=await q.useLoader(r,o?[l]:l,p=>{s&&p.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&&(i.value.background=h),e&&(i.value.backgroundBlurriness=e|0)),h}const Yi=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 Ls(l),()=>{}}}),ji=["position","a-scale"],Xi=["size","size-attenuation","transparent","alpha-test","alpha-map"],Zi=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:p,alphaMap:d,alphaTest:m}=u.toRefs(t),f=()=>{let y=i.value+o.value;const v=u.computed(()=>o.value/r.value),M=[],L=Array.from({length:r.value},()=>(.5+.5*Math.random())*4),b=g=>new c.Vector3().setFromSpherical(new c.Spherical(g,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let g=0;g<r.value;g++)y-=v.value*Math.random(),M.push(...b(y));s.value=new Float32Array(M),n.value=new Float32Array(L)};u.watchEffect(()=>{f()});const w=u.shallowRef();return e({value:w}),(y,v)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"starsRef",ref:w},[u.createElementVNode("TresBufferGeometry",{position:[s.value,3],"a-scale":[n.value,1]},null,8,ji),u.createElementVNode("TresPointsMaterial",{size:u.unref(a),"size-attenuation":u.unref(h),transparent:u.unref(p),"alpha-test":u.unref(m),"alpha-map":u.unref(d)},null,8,Xi)],512))}}),Qi=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Ki=["position","velocity"],Wi=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:p,sizeAttenuation:d,count:m,speed:f,randomness:w}=u.toRefs(e),y=u.shallowRef();let v=[],M=[];const L=()=>{v=new Float32Array(m.value*3);for(let S=0;S<m.value;S++){const A=S*3;v[A]=(Math.random()-.5)*s.value[0],v[A+1]=(Math.random()-.5)*s.value[1],v[A+2]=(Math.random()-.5)*s.value[2]}},b=()=>{M=new Float32Array(m.value*2);for(let S=0;S<m.value*2;S+=2)M[S]=(Math.random()-.5)/5*f.value*w.value,M[S+1]=Math.random()/5*f.value+.01};b(),L(),u.watchEffect(()=>{b(),L()});const{onLoop:g}=q.useRenderLoop();return g(()=>{var S,A;if((S=y.value)!=null&&S.attributes.position.array&&((A=y.value)!=null&&A.attributes.position.count)){const _=y.value.attributes.position.array;for(let x=0;x<y.value.attributes.position.count;x++){const D=M[x*2],k=M[x*2+1];_[x*3]+=D,_[x*3+1]-=k,(_[x*3]<=-s.value[0]/2||_[x*3]>=s.value[0]/2)&&(_[x*3]=_[x*3]*-1),(_[x*3+1]<=-s.value[1]/2||_[x*3+1]>=s.value[1]/2)&&(_[x*3+1]=_[x*3+1]*-1)}y.value.attributes.position.needsUpdate=!0}}),(S,A)=>(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(p),"size-attenuation":u.unref(d)},null,8,Qi),u.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:y,position:[u.unref(v),3],velocity:[u.unref(M)]},null,8,Ki)]))}}),qi=["position"],Ji=["position"],Hi=["scale"],$i=["map","depth-test","color-space","color","opacity"],eo=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:p,opacity:d,speed:m}=u.toRefs(n),f=u.shallowRef(),w=u.shallowRef();e({value:f});const y=[...new Array(r)].map((A,_)=>({x:i.value/2-Math.random()*i.value,y:i.value/2-Math.random()*i.value,scale:.4+Math.sin((_+1)/r.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*m.value})),v=(A,_)=>A/6*_*d.value,{map:M}=([t,s]=u.withAsyncContext(()=>q.useTexture({map:a.value})),t=await t,s(),t),{renderer:L,camera:b}=q.useTresContext(),g=u.computed(()=>{var A;return(A=L.value)==null?void 0:A.outputColorSpace}),{onLoop:S}=q.useRenderLoop();return S(()=>{var A,_;f.value&&b.value&&w.value&&((A=w.value)==null||A.children.forEach((x,D)=>{x.rotation.z+=y[D].rotation}),f.value.lookAt((_=b.value)==null?void 0:_.position))}),(A,_)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"smokeRef",ref:f},A.$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(y),({scale:x,x:D,y:k,density:I},B)=>(u.openBlock(),u.createElementBlock("TresMesh",{key:`${B}`,position:[D,k,-B*u.unref(o)]},[u.createElementVNode("TresPlaneGeometry",{scale:[x,x,x],rotation:[0,0,0]},null,8,Hi),u.createElementVNode("TresMeshStandardMaterial",{map:u.unref(M),"depth-test":u.unref(p),"color-space":g.value,color:u.unref(h),"depth-write":!1,transparent:"",opacity:v(x,I)},null,8,$i)],8,Ji))),128))],8,qi)],16))}}),to=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}=q.useRenderLoop(),i=u.ref(Math.random()*1e4);return n(({elapsed:o})=>{var h,p;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,((p=t.range)==null?void 0:p[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))}}),so=["geometry"],no=["map","opacity","depth-write"],io=["args"],oo=["rotation","args"],ro=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:p,scene:d}=q.useTresContext(),m=u.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),f=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,f.value/2,-f.value/2,0,t.far),r=new c.PlaneGeometry(m.value,f.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=S=>{S.uniforms={...S.uniforms,ucolor:{value:t.color?new c.Color(t.color):new c.Color}},S.fragmentShader=S.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
80
80
  void main() {
81
- `),S.fragmentShader=S.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const w=new c.ShaderMaterial(ui),y=new c.ShaderMaterial(pi);y.depthTest=w.depthTest=!1;function v(S){!p.value||!n.value||(a.visible=!0,a.material=w,w.uniforms.tDiffuse.value=i.texture,w.uniforms.h.value=S/256,p.value.setRenderTarget(o),p.value.render(a,n.value),a.material=y,y.uniforms.tDiffuse.value=o.texture,y.uniforms.v.value=S/256,p.value.setRenderTarget(i),p.value.render(a,n.value),a.visible=!1)}const{onLoop:M}=q.useRenderLoop();let L=0,b,g;return M(()=>{!n.value||d.value===void 0||p.value===void 0||(t.frames===1/0||L<t.frames)&&(L++,b=d.value.background,g=d.value.overrideMaterial,s.value.visible=!1,d.value.background=null,d.value.overrideMaterial=h,p.value.setRenderTarget(i),p.value.render(d.value,n.value),v(t.blur),t.smooth&&v(t.blur*.4),p.value.setRenderTarget(null),s.value.visible=!0,d.value.background=b,d.value.overrideMaterial=g)}),(S,A)=>{const _=u.resolveComponent("primitive");return u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"groupRef",ref:s},S.$attrs),[u.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:u.unref(r)},[u.createElementVNode("TresMeshBasicMaterial",{map:u.unref(i).texture,opacity:S.opacity,"depth-write":S.depthWrite,transparent:!0},null,8,no)],8,so),u.createVNode(_,{object:u.unref(a)},null,8,["object"]),n.value&&S.helper?(u.openBlock(),u.createElementBlock("TresCameraHelper",{key:0,args:[n.value]},null,8,io)):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,f.value/2,-f.value/2,0,S.far]},null,8,oo)],16)}}});function Cs(l){return u.getCurrentScope()?(u.onScopeDispose(l),!0):!1}function _e(l){return typeof l=="function"?l():u.unref(l)}const ao=typeof window<"u",ze=()=>{};function Os(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 lo(l,e={}){let t,s,n=ze;const i=r=>{clearTimeout(r),n(),n=ze};return r=>{const a=_e(l),h=_e(e.maxWait);return t&&i(t),a<=0||h!==void 0&&h<=0?(s&&(i(s),s=null),Promise.resolve(r())):new Promise((p,d)=>{n=e.rejectOnCancel?d:p,h&&!s&&(s=setTimeout(()=>{t&&i(t),s=null,p(r())},h)),t=setTimeout(()=>{s&&i(s),s=null,p(r())},a)})}}function co(l,e=!0,t=!0,s=!1){let n=0,i,o=!0,r=ze,a;const h=()=>{i&&(clearTimeout(i),i=void 0,r(),r=ze)};return d=>{const m=_e(l),f=Date.now()-n,w=()=>a=d();return h(),m<=0?(n=Date.now(),w()):(f>m&&(t||!o)?(n=Date.now(),w()):e&&(a=new Promise((y,v)=>{r=s?v:y,i=setTimeout(()=>{n=Date.now(),o=!0,y(w()),h()},Math.max(0,m-f))})),!t&&!i&&(i=setTimeout(()=>o=!0,m)),o=!1,a)}}function ho(l,e=200,t={}){return Os(lo(e,t),l)}function uo(l,e=200,t=!1,s=!0,n=!1){return Os(co(e,t,s,n),l)}function po(l,e=!0){u.getCurrentInstance()?u.onMounted(l):e?l():u.nextTick(l)}function mo(l){var e;const t=_e(l);return(e=t==null?void 0:t.$el)!=null?e:t}const Re=ao?window:void 0;function ae(...l){let e,t,s,n;if(typeof l[0]=="string"||Array.isArray(l[0])?([t,s,n]=l,e=Re):[e,t,s,n]=l,!e)return ze;Array.isArray(t)||(t=[t]),Array.isArray(s)||(s=[s]);const i=[],o=()=>{i.forEach(p=>p()),i.length=0},r=(p,d,m,f)=>(p.addEventListener(d,m,f),()=>p.removeEventListener(d,m,f)),a=u.watch(()=>[mo(e),_e(n)],([p,d])=>{o(),p&&i.push(...t.flatMap(m=>s.map(f=>r(p,m,f,d))))},{immediate:!0,flush:"post"}),h=()=>{a(),o()};return Cs(h),h}function fo(l){return typeof l=="function"?l:typeof l=="string"?e=>e.key===l:Array.isArray(l)?e=>l.includes(e.key):()=>!0}function Ge(...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=Re,eventName:i="keydown",passive:o=!1,dedupe:r=!1}=s,a=fo(e);return ae(n,i,p=>{p.repeat&&_e(r)||a(p)&&t(p)},o)}function go(){const l=u.ref(!1);return u.getCurrentInstance()&&u.onMounted(()=>{l.value=!0}),l}function yo(l){const e=go();return u.computed(()=>(e.value,!!l()))}function _o(l,e={}){const{window:t=Re}=e,s=yo(()=>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(_e(l)),"addEventListener"in n?n.addEventListener("change",o):n.addListener(o),i.value=n.matches)});return Cs(()=>{a(),r(),n=void 0}),i}const Ps=1;function wo(l,e={}){const{throttle:t=0,idle:s=200,onStop:n=ze,onScroll:i=ze,offset:o={left:0,right:0,top:0,bottom:0},eventListenerOptions:r={capture:!1,passive:!0},behavior:a="auto",window:h=Re}=e,p=u.ref(0),d=u.ref(0),m=u.computed({get(){return p.value},set(A){w(A,void 0)}}),f=u.computed({get(){return d.value},set(A){w(void 0,A)}});function w(A,_){var x,D,F;if(!h)return;const I=_e(l);I&&((F=I instanceof Document?h.document.body:I)==null||F.scrollTo({top:(x=_e(_))!=null?x:f.value,left:(D=_e(A))!=null?D:m.value,behavior:_e(a)}))}const y=u.ref(!1),v=u.reactive({left:!0,right:!1,top:!0,bottom:!1}),M=u.reactive({left:!1,right:!1,top:!1,bottom:!1}),L=A=>{y.value&&(y.value=!1,M.left=!1,M.right=!1,M.top=!1,M.bottom=!1,n(A))},b=ho(L,t+s),g=A=>{if(!h)return;const _=A===h?A.document.documentElement:A===h.document?A.documentElement:A,{display:x,flexDirection:D}=getComputedStyle(_),F=_.scrollLeft;M.left=F<p.value,M.right=F>p.value;const I=Math.abs(F)<=0+(o.left||0),B=Math.abs(F)+_.clientWidth>=_.scrollWidth-(o.right||0)-Ps;x==="flex"&&D==="row-reverse"?(v.left=B,v.right=I):(v.left=I,v.right=B),p.value=F;let R=_.scrollTop;A===h.document&&!R&&(R=h.document.body.scrollTop),M.top=R<d.value,M.bottom=R>d.value;const H=Math.abs(R)<=0+(o.top||0),G=Math.abs(R)+_.clientHeight>=_.scrollHeight-(o.bottom||0)-Ps;x==="flex"&&D==="column-reverse"?(v.top=G,v.bottom=H):(v.top=H,v.bottom=G),d.value=R},S=A=>{if(!h)return;const _=A.target===h.document?A.target.documentElement:A.target;g(_),y.value=!0,b(A),i(A)};return ae(l,"scroll",t?uo(S,t,!0,!1):S,r),ae(l,"scrollend",L,r),{x:m,y:f,isScrolling:y,arrivedState:v,directions:M,measure(){const A=_e(l);h&&A&&g(A)}}}const xo={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 vo(l={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:s=!1,initialValue:n={x:0,y:0},window:i=Re,target:o=i,eventFilter:r}=l,a=u.ref(n.x),h=u.ref(n.y),p=u.ref(null),d=typeof e=="function"?e:xo[e],m=M=>{const L=d(M);L&&([a.value,h.value]=L,p.value="mouse")},f=M=>{if(M.touches.length>0){const L=d(M.touches[0]);L&&([a.value,h.value]=L,p.value="touch")}},w=()=>{a.value=n.x,h.value=n.y},y=r?M=>r(()=>m(M),{}):M=>m(M),v=r?M=>r(()=>f(M),{}):M=>f(M);if(o){const M={passive:!0};ae(o,["mousemove","dragover"],y,M),t&&e!=="movement"&&(ae(o,["touchstart","touchmove"],v,M),s&&ae(o,"touchend",w,M))}return{x:a,y:h,sourceType:p}}function Ao({window:l=Re}={}){if(!l)return{x:u.ref(0),y:u.ref(0)};const e=u.ref(l.scrollX),t=u.ref(l.scrollY);return ae(l,"scroll",()=>{e.value=l.scrollX,t.value=l.scrollY},{capture:!1,passive:!0}),{x:e,y:t}}function Ds(l={}){const{window:e=Re,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(),po(a),ae("resize",a,{passive:!0}),n){const h=_o("(orientation: portrait)");u.watch(h,()=>a())}return{width:o,height:r}}const Mo=u.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(l){const e=l,{camera:t}=q.useTresContext(),{disabled:s,factor:n,ease:i}=u.toRefs(e),{x:o,y:r}=vo(),{width:a,height:h}=Ds(),p=u.ref(),d=u.computed(()=>(o.value/a.value-.5)*n.value),m=u.computed(()=>-(r.value/h.value-.5)*n.value),{onLoop:f}=q.useRenderLoop();return f(({delta:w})=>{s.value||!p.value||(p.value.position.x+=(d.value-p.value.position.x)*i.value*w,p.value.position.y+=(m.value-p.value.position.y)*i.value*w)}),u.watch(()=>p.value,w=>{w==null||w.add(t.value)}),(w,y)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:p},null,512))}});let dt=null;function bo(l,e){return t=>{e&&e(t),l.draco&&(dt||(dt=new Vi),dt.setDecoderPath(l.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(dt))}}async function Is(l,e={draco:!1},t){return await q.useLoader(In,l,bo(e,t))}const So=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(()=>Is(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 Fs(l){return await q.useLoader(xi,l)}const To=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(()=>Fs(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"])}}}),ks="[TresJS - Cientos ▲ ■ ♥] ";function Ut(){function l(s,n){console.error(`${ks} ${s}`,n||"")}function e(s){console.warn(`${ks} ${s}`)}function t(s,n){}return{logError:l,logWarning:e,logMessage:t}}let Nt=0;function Lo(){const l=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:s}=Ut();return new Promise(n=>{c.DefaultLoadingManager.onStart=()=>{l.value=!1},c.DefaultLoadingManager.onLoad=()=>{l.value=!0},c.DefaultLoadingManager.onProgress=(i,o,r)=>{o===r&&(Nt=r,l.value=!0,t.value.push(i)),e.value=Math.round((o-Nt)/(r-Nt)*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 Co(l,e){const{logError:t}=Ut();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((p,d)=>{const m=Object.assign(document.createElement("video"),{src:typeof l=="string"&&l||void 0,crossOrigin:i,loop:r,muted:o,autoplay:!0,...a}),f=new c.VideoTexture(m);return m.addEventListener(s,()=>p(f)),m.addEventListener("error",()=>d()),f})}try{const p=await h();return n&&p.image&&p.image.play(),p}catch{t("Error loading resource")}}const Oo=["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"],Po=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:p,minAzimuthAngle:d,maxPolarAngle:m,minPolarAngle:f,minDistance:w,maxDistance:y,minZoom:v,maxZoom:M,enableZoom:L,zoomSpeed:b,enableRotate:g,touches:S,rotateSpeed:A,target:_}=u.toRefs(t),{camera:x,renderer:D,extend:F,controls:I}=q.useTresContext(),B=u.ref(null);F({OrbitControls:hs}),u.watch(B,G=>{R(),G&&s.value?I.value=G:I.value=null});function R(){ae(B.value,"change",()=>e("change",B.value)),ae(B.value,"start",()=>e("start",B.value)),ae(B.value,"end",()=>e("end",B.value))}const{onLoop:H}=q.useRenderLoop();return H(()=>{B.value&&(o.value||n.value)&&B.value.update()}),u.onUnmounted(()=>{B.value&&B.value.dispose()}),(G,se)=>{var X;return u.unref(x)&&u.unref(D)?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:B,target:u.unref(_),"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:G.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(d),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(f),"min-distance":u.unref(w),"max-distance":u.unref(y),"min-zoom":u.unref(v),"max-zoom":u.unref(M),touches:u.unref(S),"enable-zoom":u.unref(L),"zoom-speed":u.unref(b),"enable-rotate":u.unref(g),"rotate-speed":u.unref(A),args:[u.unref(x)||G.camera,((X=u.unref(D))==null?void 0:X.domElement)||G.domElement]},null,8,Oo)):u.createCommentVNode("",!0)}}}),Do=5,Io=6,Fo=.3,ko=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 F;const e=l,{forward:t,back:s,left:n,right:i,jump:o,gravity:r,moveSpeed:a,headBobbing:h,is2D:p}=u.toRefs(e),{camera:d,controls:m}=q.useTresContext(),f=u.ref(0),w=u.ref(0),y=u.ref(!1),v=u.ref(!1),M=u.ref(0),L=u.shallowRef(),b=p.value?"y":"z";let g=((F=d.value.position)==null?void 0:F.y)||0;Ge(t.value,()=>{y.value=!0,w.value=a.value},{eventName:"keydown"}),Ge(s.value,()=>{y.value=!0,w.value=-a.value},{eventName:"keydown"}),Ge([...t.value,...s.value],()=>{y.value=!1,w.value=0},{eventName:"keyup"}),Ge(n.value,()=>{y.value=!0,f.value=-a.value},{eventName:"keydown"}),Ge(i.value,()=>{y.value=!0,f.value=a.value},{eventName:"keydown"}),Ge([...n.value,...i.value],()=>{y.value=!1,f.value=0},{eventName:"keyup"}),Ge(o.value,()=>{v.value||(M.value=Date.now()),v.value=!0});const S=I=>y.value?Math.sin(I*Do)*Fo+g:g,A=()=>(Date.now()-M.value)/1e3*3,_=I=>g+Io*I-.5*r.value*Math.pow(I,2),x=()=>{if(v.value){const I=_(A());return I<=g&&(v.value=!1),I}return 0},{onLoop:D}=q.useRenderLoop();return D(({elapsed:I})=>{var B;m.value instanceof bt&&((B=m.value)!=null&&B.isLocked)?(m.value.moveForward(w.value),m.value.moveRight(f.value),d.value.position&&(d.value.position.y=h.value?S(I):g,d.value.position.y+=x())):L.value.children.length>0&&!(m.value instanceof bt)&&(L.value.position.x+=f.value,L.value.position[b]+=p.value?w.value:-w.value)}),(I,B)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:L},[u.renderSlot(I.$slots,"default")],512))}}),Bo=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Uo=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:p,size:d,showX:m,showY:f,showZ:w}=u.toRefs(t),y=u.shallowRef(),{controls:v,camera:M,renderer:L,extend:b}=q.useTresContext();b({TransformControls:vn});const g=A=>{v.value&&(v.value.enabled=!A.value),e("dragging",A.value)};function S(){ae(y.value,"change",()=>e("change")),ae(y.value,"dragging-changed",g),ae(y.value,"mouseDown",()=>e("mouseDown")),ae(y.value,"mouseUp",()=>e("mouseUp")),ae(y.value,"objectChange",()=>e("objectChange"))}return u.watchEffect(()=>{y.value&&S()}),u.onUnmounted(()=>{y.value&&y.value.dispose()}),(A,_)=>u.unref(M)&&u.unref(L)?(u.openBlock(),u.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:y,object:u.unref(s),args:[u.unref(M),u.unref(L).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(p),size:u.unref(d),"show-x":u.unref(m),"show-y":u.unref(f),"show-z":u.unref(w),visible:!0},null,8,Bo)):u.createCommentVNode("",!0)}}),No=["args"],Vo=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}=q.useTresContext(),a=u.ref(null);let h;o({PointerLockControls:bt});const p=d=>{t("isLock",d)};return u.watch(a,d=>{d&&s.makeDefault?r.value=d:r.value=null;const m=document.getElementById(s.selector||"");h=m||i.value.domElement,ae(h,"click",()=>{var f,w,y;(f=r.value)==null||f.lock(),(w=r.value)==null||w.addEventListener("lock",()=>p(!0)),(y=r.value)==null||y.addEventListener("unlock",()=>p(!1))})}),u.onUnmounted(()=>{var d,m;(d=r.value)==null||d.removeEventListener("lock",()=>p(!0)),(m=r.value)==null||m.removeEventListener("unlock",()=>p(!1)),a.value&&a.value.dispose()}),e({value:r}),(d,m)=>{var f;return u.unref(n)&&u.unref(i)?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:a,args:[u.unref(n)||d.camera,((f=u.unref(i))==null?void 0:f.domElement)||d.domElement]},null,8,No)):u.createCommentVNode("",!0)}}}),Eo=["args"],zo=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}=q.useTresContext(),o=u.ref(null);return n({MapControls:Dn}),u.watch(i,r=>{r&&e.makeDefault?i.value=r:i.value=null}),u.onUnmounted(()=>{o.value&&o.value.dispose()}),(r,a)=>{var h;return u.unref(t)&&u.unref(s)?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:o,args:[u.unref(t)||r.camera,((h=u.unref(s))==null?void 0:h.domElement)||r.domElement]},null,8,Eo)):u.createCommentVNode("",!0)}}}),Ro=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}=q.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}=q.useTresContext(),r=u.shallowRef(),a=document.createElement("div"),{y:h}=Ao(),{x:p,y:d,isScrolling:m}=wo(a),{height:f,width:w}=Ds();let y=0;const v=u.ref(!1),M=u.ref(0),L=u.ref(0),b=u.ref(0),g=t.horizontal?"x":"y",S=u.watch(n,_=>{if(v.value){S();return}y=t.horizontal?(_==null?void 0:_.position.x)||0:(_==null?void 0:_.position.y)||0,v.value=!0},{immediate:!0});u.watch(m,_=>{i.value&&(i.value.enabled=!_)},{immediate:!0}),u.watch(h,_=>{!m.value&&!t.htmlScroll||(L.value=parseFloat((_/f.value/(b.value/f.value-1)).toFixed(2)),M.value=-1*L.value,e("update:modelValue",L.value))}),u.watch(d,_=>{L.value=parseFloat((_/f.value/(b.value/f.value)).toFixed(2)),M.value=-1*L.value,e("update:modelValue",L.value)}),u.watch(p,_=>{L.value=parseFloat((_/w.value/(b.value/w.value-1)).toFixed(2)),M.value=+L.value,e("update:modelValue",L.value)}),u.watch(o,_=>{var D,F;const x=_==null?void 0:_.domElement;if(t.htmlScroll&&(_!=null&&_.domElement))x!=null&&x.style.width&&(x!=null&&x.style.position)&&(x!=null&&x.style.top)&&(x!=null&&x.style.left)&&(x.style.width="100%",x.style.position="fixed",x.style.zIndex=" -99999",x.style.top="0",x.style.left="0"),b.value=document.body.scrollHeight;else{const I=document.createElement("div"),B=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"),I.style.position="sticky",I.style.top="0px",I.style.left="0px",I.style.width="100%",I.style.height="100%",I.style.overflow="hidden",a.appendChild(I),B.style.height=t.horizontal?"100%":`${f.value*t.pages}px`,B.style.width=t.horizontal?`${w.value*t.pages}px`:"100vw",B.style.pointerEvents="none",x.style.position="fixed",x.style.zIndex="0",x!=null&&x.style.width&&(x.style.width="100%"),a.appendChild(B),_.domElement.parentNode.style.position="relative",(F=(D=_==null?void 0:_.domElement)==null?void 0:D.parentNode)==null||F.appendChild(a),b.value=t.horizontal?w.value*t.pages:f.value*t.pages}},{immediate:!0});const{onLoop:A}=q.useRenderLoop();return A(()=>{var _;if((_=n.value)!=null&&_.position){const x=(M.value*t.distance-n.value.position[g]+y)*t.smoothScroll;n.value.position[g]+=x,r.value.children.length>0&&(r.value.position[g]+=x)}}),(_,x)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:r},[u.renderSlot(_.$slots,"default")],512))}});/*!
81
+ `),S.fragmentShader=S.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const w=new c.ShaderMaterial(ui),y=new c.ShaderMaterial(pi);y.depthTest=w.depthTest=!1;function v(S){!p.value||!n.value||(a.visible=!0,a.material=w,w.uniforms.tDiffuse.value=i.texture,w.uniforms.h.value=S/256,p.value.setRenderTarget(o),p.value.render(a,n.value),a.material=y,y.uniforms.tDiffuse.value=o.texture,y.uniforms.v.value=S/256,p.value.setRenderTarget(i),p.value.render(a,n.value),a.visible=!1)}const{onLoop:M}=q.useRenderLoop();let L=0,b,g;return M(()=>{!n.value||d.value===void 0||p.value===void 0||(t.frames===1/0||L<t.frames)&&(L++,b=d.value.background,g=d.value.overrideMaterial,s.value.visible=!1,d.value.background=null,d.value.overrideMaterial=h,p.value.setRenderTarget(i),p.value.render(d.value,n.value),v(t.blur),t.smooth&&v(t.blur*.4),p.value.setRenderTarget(null),s.value.visible=!0,d.value.background=b,d.value.overrideMaterial=g)}),(S,A)=>{const _=u.resolveComponent("primitive");return u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"groupRef",ref:s},S.$attrs),[u.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:u.unref(r)},[u.createElementVNode("TresMeshBasicMaterial",{map:u.unref(i).texture,opacity:S.opacity,"depth-write":S.depthWrite,transparent:!0},null,8,no)],8,so),u.createVNode(_,{object:u.unref(a)},null,8,["object"]),n.value&&S.helper?(u.openBlock(),u.createElementBlock("TresCameraHelper",{key:0,args:[n.value]},null,8,io)):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,f.value/2,-f.value/2,0,S.far]},null,8,oo)],16)}}});function Cs(l){return u.getCurrentScope()?(u.onScopeDispose(l),!0):!1}function _e(l){return typeof l=="function"?l():u.unref(l)}const ao=typeof window<"u",ze=()=>{};function Os(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 lo(l,e={}){let t,s,n=ze;const i=r=>{clearTimeout(r),n(),n=ze};return r=>{const a=_e(l),h=_e(e.maxWait);return t&&i(t),a<=0||h!==void 0&&h<=0?(s&&(i(s),s=null),Promise.resolve(r())):new Promise((p,d)=>{n=e.rejectOnCancel?d:p,h&&!s&&(s=setTimeout(()=>{t&&i(t),s=null,p(r())},h)),t=setTimeout(()=>{s&&i(s),s=null,p(r())},a)})}}function co(l,e=!0,t=!0,s=!1){let n=0,i,o=!0,r=ze,a;const h=()=>{i&&(clearTimeout(i),i=void 0,r(),r=ze)};return d=>{const m=_e(l),f=Date.now()-n,w=()=>a=d();return h(),m<=0?(n=Date.now(),w()):(f>m&&(t||!o)?(n=Date.now(),w()):e&&(a=new Promise((y,v)=>{r=s?v:y,i=setTimeout(()=>{n=Date.now(),o=!0,y(w()),h()},Math.max(0,m-f))})),!t&&!i&&(i=setTimeout(()=>o=!0,m)),o=!1,a)}}function ho(l,e=200,t={}){return Os(lo(e,t),l)}function uo(l,e=200,t=!1,s=!0,n=!1){return Os(co(e,t,s,n),l)}function po(l,e=!0){u.getCurrentInstance()?u.onMounted(l):e?l():u.nextTick(l)}function mo(l){var e;const t=_e(l);return(e=t==null?void 0:t.$el)!=null?e:t}const Re=ao?window:void 0;function ae(...l){let e,t,s,n;if(typeof l[0]=="string"||Array.isArray(l[0])?([t,s,n]=l,e=Re):[e,t,s,n]=l,!e)return ze;Array.isArray(t)||(t=[t]),Array.isArray(s)||(s=[s]);const i=[],o=()=>{i.forEach(p=>p()),i.length=0},r=(p,d,m,f)=>(p.addEventListener(d,m,f),()=>p.removeEventListener(d,m,f)),a=u.watch(()=>[mo(e),_e(n)],([p,d])=>{o(),p&&i.push(...t.flatMap(m=>s.map(f=>r(p,m,f,d))))},{immediate:!0,flush:"post"}),h=()=>{a(),o()};return Cs(h),h}function fo(l){return typeof l=="function"?l:typeof l=="string"?e=>e.key===l:Array.isArray(l)?e=>l.includes(e.key):()=>!0}function Ge(...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=Re,eventName:i="keydown",passive:o=!1,dedupe:r=!1}=s,a=fo(e);return ae(n,i,p=>{p.repeat&&_e(r)||a(p)&&t(p)},o)}function go(){const l=u.ref(!1);return u.getCurrentInstance()&&u.onMounted(()=>{l.value=!0}),l}function yo(l){const e=go();return u.computed(()=>(e.value,!!l()))}function _o(l,e={}){const{window:t=Re}=e,s=yo(()=>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(_e(l)),"addEventListener"in n?n.addEventListener("change",o):n.addListener(o),i.value=n.matches)});return Cs(()=>{a(),r(),n=void 0}),i}const Ps=1;function wo(l,e={}){const{throttle:t=0,idle:s=200,onStop:n=ze,onScroll:i=ze,offset:o={left:0,right:0,top:0,bottom:0},eventListenerOptions:r={capture:!1,passive:!0},behavior:a="auto",window:h=Re}=e,p=u.ref(0),d=u.ref(0),m=u.computed({get(){return p.value},set(A){w(A,void 0)}}),f=u.computed({get(){return d.value},set(A){w(void 0,A)}});function w(A,_){var x,D,k;if(!h)return;const I=_e(l);I&&((k=I instanceof Document?h.document.body:I)==null||k.scrollTo({top:(x=_e(_))!=null?x:f.value,left:(D=_e(A))!=null?D:m.value,behavior:_e(a)}))}const y=u.ref(!1),v=u.reactive({left:!0,right:!1,top:!0,bottom:!1}),M=u.reactive({left:!1,right:!1,top:!1,bottom:!1}),L=A=>{y.value&&(y.value=!1,M.left=!1,M.right=!1,M.top=!1,M.bottom=!1,n(A))},b=ho(L,t+s),g=A=>{if(!h)return;const _=A===h?A.document.documentElement:A===h.document?A.documentElement:A,{display:x,flexDirection:D}=getComputedStyle(_),k=_.scrollLeft;M.left=k<p.value,M.right=k>p.value;const I=Math.abs(k)<=0+(o.left||0),B=Math.abs(k)+_.clientWidth>=_.scrollWidth-(o.right||0)-Ps;x==="flex"&&D==="row-reverse"?(v.left=B,v.right=I):(v.left=I,v.right=B),p.value=k;let R=_.scrollTop;A===h.document&&!R&&(R=h.document.body.scrollTop),M.top=R<d.value,M.bottom=R>d.value;const H=Math.abs(R)<=0+(o.top||0),G=Math.abs(R)+_.clientHeight>=_.scrollHeight-(o.bottom||0)-Ps;x==="flex"&&D==="column-reverse"?(v.top=G,v.bottom=H):(v.top=H,v.bottom=G),d.value=R},S=A=>{if(!h)return;const _=A.target===h.document?A.target.documentElement:A.target;g(_),y.value=!0,b(A),i(A)};return ae(l,"scroll",t?uo(S,t,!0,!1):S,r),ae(l,"scrollend",L,r),{x:m,y:f,isScrolling:y,arrivedState:v,directions:M,measure(){const A=_e(l);h&&A&&g(A)}}}const xo={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 vo(l={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:s=!1,initialValue:n={x:0,y:0},window:i=Re,target:o=i,eventFilter:r}=l,a=u.ref(n.x),h=u.ref(n.y),p=u.ref(null),d=typeof e=="function"?e:xo[e],m=M=>{const L=d(M);L&&([a.value,h.value]=L,p.value="mouse")},f=M=>{if(M.touches.length>0){const L=d(M.touches[0]);L&&([a.value,h.value]=L,p.value="touch")}},w=()=>{a.value=n.x,h.value=n.y},y=r?M=>r(()=>m(M),{}):M=>m(M),v=r?M=>r(()=>f(M),{}):M=>f(M);if(o){const M={passive:!0};ae(o,["mousemove","dragover"],y,M),t&&e!=="movement"&&(ae(o,["touchstart","touchmove"],v,M),s&&ae(o,"touchend",w,M))}return{x:a,y:h,sourceType:p}}function Ao({window:l=Re}={}){if(!l)return{x:u.ref(0),y:u.ref(0)};const e=u.ref(l.scrollX),t=u.ref(l.scrollY);return ae(l,"scroll",()=>{e.value=l.scrollX,t.value=l.scrollY},{capture:!1,passive:!0}),{x:e,y:t}}function Ds(l={}){const{window:e=Re,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(),po(a),ae("resize",a,{passive:!0}),n){const h=_o("(orientation: portrait)");u.watch(h,()=>a())}return{width:o,height:r}}const Mo=u.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(l){const e=l,{camera:t}=q.useTresContext(),{disabled:s,factor:n,ease:i}=u.toRefs(e),{x:o,y:r}=vo(),{width:a,height:h}=Ds(),p=u.ref(),d=u.computed(()=>(o.value/a.value-.5)*n.value),m=u.computed(()=>-(r.value/h.value-.5)*n.value),{onLoop:f}=q.useRenderLoop();return f(({delta:w})=>{s.value||!p.value||(p.value.position.x+=(d.value-p.value.position.x)*i.value*w,p.value.position.y+=(m.value-p.value.position.y)*i.value*w)}),u.watch(()=>p.value,w=>{w==null||w.add(t.value)}),(w,y)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:p},null,512))}});let dt=null;function bo(l,e){return t=>{e&&e(t),l.draco&&(dt||(dt=new Vi),dt.setDecoderPath(l.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(dt))}}async function Is(l,e={draco:!1},t){return await q.useLoader(In,l,bo(e,t))}const So=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(()=>Is(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 ks(l){return await q.useLoader(xi,l)}const To=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(()=>ks(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"])}}}),Fs="[TresJS - Cientos ▲ ■ ♥] ";function Ut(){function l(s,n){console.error(`${Fs} ${s}`,n||"")}function e(s){console.warn(`${Fs} ${s}`)}function t(s,n){}return{logError:l,logWarning:e,logMessage:t}}let Nt=0;function Lo(){const l=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:s}=Ut();return new Promise(n=>{c.DefaultLoadingManager.onStart=()=>{l.value=!1},c.DefaultLoadingManager.onLoad=()=>{l.value=!0},c.DefaultLoadingManager.onProgress=(i,o,r)=>{o===r&&(Nt=r,l.value=!0,t.value.push(i)),e.value=Math.round((o-Nt)/(r-Nt)*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 Co(l,e){const{logError:t}=Ut();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((p,d)=>{const m=Object.assign(document.createElement("video"),{src:typeof l=="string"&&l||void 0,crossOrigin:i,loop:r,muted:o,autoplay:!0,...a}),f=new c.VideoTexture(m);return m.addEventListener(s,()=>p(f)),m.addEventListener("error",()=>d()),f})}try{const p=await h();return n&&p.image&&p.image.play(),p}catch{t("Error loading resource")}}const Oo=["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"],Po=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:p,minAzimuthAngle:d,maxPolarAngle:m,minPolarAngle:f,minDistance:w,maxDistance:y,minZoom:v,maxZoom:M,enableZoom:L,zoomSpeed:b,enableRotate:g,touches:S,rotateSpeed:A,target:_}=u.toRefs(t),{camera:x,renderer:D,extend:k,controls:I}=q.useTresContext(),B=u.ref(null);k({OrbitControls:hs}),u.watch(B,G=>{R(),G&&s.value?I.value=G:I.value=null});function R(){ae(B.value,"change",()=>e("change",B.value)),ae(B.value,"start",()=>e("start",B.value)),ae(B.value,"end",()=>e("end",B.value))}const{onLoop:H}=q.useRenderLoop();return H(()=>{B.value&&(o.value||n.value)&&B.value.update()}),u.onUnmounted(()=>{B.value&&B.value.dispose()}),(G,se)=>{var X;return u.unref(x)&&u.unref(D)?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:B,target:u.unref(_),"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:G.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(d),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(f),"min-distance":u.unref(w),"max-distance":u.unref(y),"min-zoom":u.unref(v),"max-zoom":u.unref(M),touches:u.unref(S),"enable-zoom":u.unref(L),"zoom-speed":u.unref(b),"enable-rotate":u.unref(g),"rotate-speed":u.unref(A),args:[u.unref(x)||G.camera,((X=u.unref(D))==null?void 0:X.domElement)||G.domElement]},null,8,Oo)):u.createCommentVNode("",!0)}}}),Do=5,Io=6,ko=.3,Fo=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 k;const e=l,{forward:t,back:s,left:n,right:i,jump:o,gravity:r,moveSpeed:a,headBobbing:h,is2D:p}=u.toRefs(e),{camera:d,controls:m}=q.useTresContext(),f=u.ref(0),w=u.ref(0),y=u.ref(!1),v=u.ref(!1),M=u.ref(0),L=u.shallowRef(),b=p.value?"y":"z";let g=((k=d.value.position)==null?void 0:k.y)||0;Ge(t.value,()=>{y.value=!0,w.value=a.value},{eventName:"keydown"}),Ge(s.value,()=>{y.value=!0,w.value=-a.value},{eventName:"keydown"}),Ge([...t.value,...s.value],()=>{y.value=!1,w.value=0},{eventName:"keyup"}),Ge(n.value,()=>{y.value=!0,f.value=-a.value},{eventName:"keydown"}),Ge(i.value,()=>{y.value=!0,f.value=a.value},{eventName:"keydown"}),Ge([...n.value,...i.value],()=>{y.value=!1,f.value=0},{eventName:"keyup"}),Ge(o.value,()=>{v.value||(M.value=Date.now()),v.value=!0});const S=I=>y.value?Math.sin(I*Do)*ko+g:g,A=()=>(Date.now()-M.value)/1e3*3,_=I=>g+Io*I-.5*r.value*Math.pow(I,2),x=()=>{if(v.value){const I=_(A());return I<=g&&(v.value=!1),I}return 0},{onLoop:D}=q.useRenderLoop();return D(({elapsed:I})=>{var B;m.value instanceof bt&&((B=m.value)!=null&&B.isLocked)?(m.value.moveForward(w.value),m.value.moveRight(f.value),d.value.position&&(d.value.position.y=h.value?S(I):g,d.value.position.y+=x())):L.value.children.length>0&&!(m.value instanceof bt)&&(L.value.position.x+=f.value,L.value.position[b]+=p.value?w.value:-w.value)}),(I,B)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:L},[u.renderSlot(I.$slots,"default")],512))}}),Bo=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Uo=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:p,size:d,showX:m,showY:f,showZ:w}=u.toRefs(t),y=u.shallowRef(),{controls:v,camera:M,renderer:L,extend:b}=q.useTresContext();b({TransformControls:vn});const g=A=>{v.value&&(v.value.enabled=!A.value),e("dragging",A.value)};function S(){ae(y.value,"change",()=>e("change")),ae(y.value,"dragging-changed",g),ae(y.value,"mouseDown",()=>e("mouseDown")),ae(y.value,"mouseUp",()=>e("mouseUp")),ae(y.value,"objectChange",()=>e("objectChange"))}return u.watchEffect(()=>{y.value&&S()}),u.onUnmounted(()=>{y.value&&y.value.dispose()}),(A,_)=>u.unref(M)&&u.unref(L)?(u.openBlock(),u.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:y,object:u.unref(s),args:[u.unref(M),u.unref(L).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(p),size:u.unref(d),"show-x":u.unref(m),"show-y":u.unref(f),"show-z":u.unref(w),visible:!0},null,8,Bo)):u.createCommentVNode("",!0)}}),No=["args"],Vo=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}=q.useTresContext(),a=u.ref(null);let h;o({PointerLockControls:bt});const p=d=>{t("isLock",d)};return u.watch(a,d=>{d&&s.makeDefault?r.value=d:r.value=null;const m=document.getElementById(s.selector||"");h=m||i.value.domElement,ae(h,"click",()=>{var f,w,y;(f=r.value)==null||f.lock(),(w=r.value)==null||w.addEventListener("lock",()=>p(!0)),(y=r.value)==null||y.addEventListener("unlock",()=>p(!1))})}),u.onUnmounted(()=>{var d,m;(d=r.value)==null||d.removeEventListener("lock",()=>p(!0)),(m=r.value)==null||m.removeEventListener("unlock",()=>p(!1)),a.value&&a.value.dispose()}),e({value:r}),(d,m)=>{var f;return u.unref(n)&&u.unref(i)?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:a,args:[u.unref(n)||d.camera,((f=u.unref(i))==null?void 0:f.domElement)||d.domElement]},null,8,No)):u.createCommentVNode("",!0)}}}),Eo=["args"],zo=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}=q.useTresContext(),o=u.ref(null);return n({MapControls:Dn}),u.watch(i,r=>{r&&e.makeDefault?i.value=r:i.value=null}),u.onUnmounted(()=>{o.value&&o.value.dispose()}),(r,a)=>{var h;return u.unref(t)&&u.unref(s)?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:o,args:[u.unref(t)||r.camera,((h=u.unref(s))==null?void 0:h.domElement)||r.domElement]},null,8,Eo)):u.createCommentVNode("",!0)}}}),Ro=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}=q.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}=q.useTresContext(),r=u.shallowRef(),a=document.createElement("div"),{y:h}=Ao(),{x:p,y:d,isScrolling:m}=wo(a),{height:f,width:w}=Ds();let y=0;const v=u.ref(!1),M=u.ref(0),L=u.ref(0),b=u.ref(0),g=t.horizontal?"x":"y",S=u.watch(n,_=>{if(v.value){S();return}y=t.horizontal?(_==null?void 0:_.position.x)||0:(_==null?void 0:_.position.y)||0,v.value=!0},{immediate:!0});u.watch(m,_=>{i.value&&(i.value.enabled=!_)},{immediate:!0}),u.watch(h,_=>{!m.value&&!t.htmlScroll||(L.value=_/f.value/(b.value/f.value-1),M.value=-1*L.value,e("update:modelValue",L.value))}),u.watch(d,_=>{L.value=_/f.value/(b.value/f.value),M.value=-1*L.value,e("update:modelValue",L.value)}),u.watch(p,_=>{L.value=_/w.value/(b.value/w.value-1),M.value=+L.value,e("update:modelValue",L.value)}),u.watch(o,_=>{var D,k;const x=_==null?void 0:_.domElement;if(t.htmlScroll&&(_!=null&&_.domElement))x!=null&&x.style.width&&(x!=null&&x.style.position)&&(x!=null&&x.style.top)&&(x!=null&&x.style.left)&&(x.style.width="100%",x.style.position="fixed",x.style.zIndex=" -99999",x.style.top="0",x.style.left="0"),b.value=document.body.scrollHeight;else{const I=document.createElement("div"),B=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"),I.style.position="sticky",I.style.top="0px",I.style.left="0px",I.style.width="100%",I.style.height="100%",I.style.overflow="hidden",a.appendChild(I),B.style.height=t.horizontal?"100%":`${f.value*t.pages}px`,B.style.width=t.horizontal?`${w.value*t.pages}px`:"100vw",B.style.pointerEvents="none",x.style.position="fixed",x.style.zIndex="0",x!=null&&x.style.width&&(x.style.width="100%"),a.appendChild(B),_.domElement.parentNode.style.position="relative",(k=(D=_==null?void 0:_.domElement)==null?void 0:D.parentNode)==null||k.appendChild(a),b.value=t.horizontal?w.value*t.pages:f.value*t.pages}},{immediate:!0});const{onLoop:A}=q.useRenderLoop();return A(()=>{var _;if((_=n.value)!=null&&_.position){const x=(M.value*t.distance-n.value.position[g]+y)*t.smoothScroll;n.value.position[g]+=x,r.value.children.length>0&&(r.value.position[g]+=x)}}),(_,x)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:r},[u.renderSlot(_.$slots,"default")],512))}});/*!
82
82
  * camera-controls
83
83
  * https://github.com/yomotsu/camera-controls
84
84
  * (c) 2017 @yomotsu
85
85
  * Released under the MIT License.
86
- */const V={LEFT:1,RIGHT:2,MIDDLE:4},P=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}),Je={NONE:0,IN:1,OUT:-1};function Ye(l){return l.isPerspectiveCamera}function Ue(l){return l.isOrthographicCamera}const He=Math.PI*2,Bs=Math.PI/2,Us=1e-5,it=Math.PI/180;function Ae(l,e,t){return Math.max(e,Math.min(t,l))}function te(l,e=Us){return Math.abs(l)<e}function J(l,e,t=Us){return te(l-e,t)}function Ns(l,e){return Math.round(l/e)*e}function ot(l){return isFinite(l)?l:l<0?-Number.MAX_VALUE:Number.MAX_VALUE}function rt(l){return Math.abs(l)<Number.MAX_VALUE?l:l*(1/0)}function mt(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 p=e,d=n*s;h=Ae(h,-d,d),e=l-h;const m=(t.value+o*h)*i;t.value=(t.value-o*m)*a;let f=e+(h+m)*a;return p-l>0==f>p&&(f=p,t.value=(f-p)/i),f}function Vs(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 p=e.x,d=e.y,m=e.z,f=l.x-p,w=l.y-d,y=l.z-m;const v=p,M=d,L=m,b=n*s,g=b*b,S=f*f+w*w+y*y;if(S>g){const G=Math.sqrt(S);f=f/G*b,w=w/G*b,y=y/G*b}p=l.x-f,d=l.y-w,m=l.z-y;const A=(t.x+r*f)*i,_=(t.y+r*w)*i,x=(t.z+r*y)*i;t.x=(t.x-r*A)*h,t.y=(t.y-r*_)*h,t.z=(t.z-r*x)*h,o.x=p+(f+A)*h,o.y=d+(w+_)*h,o.z=m+(y+x)*h;const D=v-l.x,F=M-l.y,I=L-l.z,B=o.x-v,R=o.y-M,H=o.z-L;return D*B+F*R+I*H>0&&(o.x=v,o.y=M,o.z=L,t.x=(o.x-v)/i,t.y=(o.y-M)/i,t.z=(o.z-L)/i),o}function Vt(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 Et(l,e){return Ue(l)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Go{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 Yo="2.7.1",ft=1/8,Es=typeof window<"u",jo=Es&&/Mac/.test(navigator.platform),Xo=!(Es&&"PointerEvent"in window);let N,zs,gt,zt,me,Y,W,$e,at,Te,Le,je,Rs,Gs,we,lt,et,Ys,Rt,js,Gt,Yt,yt;class ct extends Go{static install(e){N=e.THREE,zs=Object.freeze(new N.Vector3(0,0,0)),gt=Object.freeze(new N.Vector3(0,1,0)),zt=Object.freeze(new N.Vector3(0,0,1)),me=new N.Vector2,Y=new N.Vector3,W=new N.Vector3,$e=new N.Vector3,at=new N.Vector3,Te=new N.Vector3,Le=new N.Vector3,je=new N.Vector3,Rs=new N.Vector3,Gs=new N.Vector3,we=new N.Spherical,lt=new N.Spherical,et=new N.Box3,Ys=new N.Box3,Rt=new N.Sphere,js=new N.Quaternion,Gt=new N.Quaternion,Yt=new N.Matrix4,yt=new N.Raycaster}static get ACTION(){return P}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=P.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=Je.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new N.Vector3,this._focalOffsetVelocity=new N.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,S,A)=>{let _,x;if(Ye(this._camera)){const D=Y.copy(this._camera.position).sub(this._target),F=this._camera.getEffectiveFOV()*it,I=D.length()*Math.tan(F*.5);_=this.truckSpeed*g*I/this._elementRect.height,x=this.truckSpeed*S*I/this._elementRect.height}else if(Ue(this._camera)){const D=this._camera;_=g*(D.right-D.left)/D.zoom/this._elementRect.width,x=S*(D.top-D.bottom)/D.zoom/this._elementRect.height}else return;this.verticalDragToForward?(A?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(_,0,!0),this.forward(-x,!0)):A?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(_,x,!0)},this._rotateInternal=(g,S)=>{const A=He*this.azimuthRotateSpeed*g/this._elementRect.height,_=He*this.polarRotateSpeed*S/this._elementRect.height;this.rotate(A,_,!0)},this._dollyInternal=(g,S,A)=>{const _=Math.pow(.95,-g*this.dollySpeed),x=this._sphericalEnd.radius,D=this._sphericalEnd.radius*_,F=Ae(D,this.minDistance,this.maxDistance),I=F-D;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(D,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(I,!0),this._dollyToNoClamp(F,!0)):this._dollyToNoClamp(F,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?D:F)-x,this._dollyControlCoord.set(S,A)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,S,A)=>{const _=Math.pow(.95,g*this.dollySpeed),x=this._zoom,D=this._zoom*_;this.zoomTo(D,!0),this.dollyToCursor&&(this._changedZoom+=D-x,this._dollyControlCoord.set(S,A))},typeof N>"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 N.Quaternion().setFromUnitVectors(this._camera.up,gt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=P.NONE,this._target=new N.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new N.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new N.Spherical().setFromVector3(Y.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 N.Vector3,new N.Vector3,new N.Vector3,new N.Vector3],this._updateNearPlaneCorners(),this._boundary=new N.Box3(new N.Vector3(-1/0,-1/0,-1/0),new N.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 N.Vector2,this.mouseButtons={left:P.ROTATE,middle:P.DOLLY,right:P.TRUCK,wheel:Ye(this._camera)?P.DOLLY:Ue(this._camera)?P.ZOOM:P.NONE},this.touches={one:P.TOUCH_ROTATE,two:Ye(this._camera)?P.TOUCH_DOLLY_TRUCK:Ue(this._camera)?P.TOUCH_ZOOM_TRUCK:P.NONE,three:P.TOUCH_TRUCK};const s=new N.Vector2,n=new N.Vector2,i=new N.Vector2,o=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const _=this._domElement.getBoundingClientRect(),x=g.clientX/_.width,D=g.clientY/_.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const S=g.pointerType!=="mouse"?null:(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(g.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(S!==null){const _=this._findPointerByMouseButton(S);_&&this._disposePointer(_)}if((g.buttons&V.LEFT)===V.LEFT&&this._lockedPointer)return;const A={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:S};this._activePointers.push(A),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",p),this._isDragging=!0,y(g)},r=g=>{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 _=this._domElement.getBoundingClientRect(),x=g.clientX/_.width,D=g.clientY/_.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const S=(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(g.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(S!==null){const _=this._findPointerByMouseButton(S);_&&this._disposePointer(_)}const A={pointerId:1,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.LEFT?V.MIDDLE:(g.buttons&V.RIGHT)===V.LEFT?V.RIGHT:null};this._activePointers.push(A),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.addEventListener("mousemove",h),this._domElement.ownerDocument.addEventListener("mouseup",d),this._isDragging=!0,y(g)},a=g=>{g.cancelable&&g.preventDefault();const S=g.pointerId,A=this._lockedPointer||this._findPointerById(S);if(A){if(A.clientX=g.clientX,A.clientY=g.clientY,A.deltaX=g.movementX,A.deltaY=g.movementY,this._state=0,g.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&&(g.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);v()}},h=g=>{const S=this._lockedPointer||this._findPointerById(1);S&&(S.clientX=g.clientX,S.clientY=g.clientY,S.deltaX=g.movementX,S.deltaY=g.movementY,this._state=0,(this._lockedPointer||(g.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right),v())},p=g=>{const S=this._findPointerById(g.pointerId);if(!(S&&S===this._lockedPointer)){if(S&&this._disposePointer(S),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=P.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=P.NONE;M()}},d=()=>{const g=this._findPointerById(1);g&&g===this._lockedPointer||(g&&this._disposePointer(g),this._state=P.NONE,M())};let m=-1;const f=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===P.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const D=this._domElement.getBoundingClientRect(),F=g.clientX/D.width,I=g.clientY/D.height;if(F<this._interactiveArea.left||F>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===P.ROTATE||this.mouseButtons.wheel===P.TRUCK){const D=performance.now();m-D<1e3&&this._getClientRect(this._elementRect),m=D}const S=jo?-1:-3,A=g.deltaMode===1?g.deltaY/S:g.deltaY/(S*10),_=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case P.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case P.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case P.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case P.DOLLY:{this._dollyInternal(-A,_,x),this._isUserControllingDolly=!0;break}case P.ZOOM:{this._zoomInternal(-A,_,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},w=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===ct.ACTION.NONE){const S=g instanceof PointerEvent?g.pointerId:(g instanceof MouseEvent,0),A=this._findPointerById(S);A&&this._disposePointer(A),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",d);return}g.preventDefault()}},y=g=>{if(!this._enabled)return;if(Vt(this._activePointers,me),this._getClientRect(this._elementRect),s.copy(me),n.copy(me),this._activePointers.length>=2){const A=me.x-this._activePointers[1].clientX,_=me.y-this._activePointers[1].clientY,x=Math.sqrt(A*A+_*_);i.set(0,x);const D=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,F=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(D,F)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.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&&(g.buttons&V.LEFT)===V.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&P.ROTATE)===P.ROTATE||(this._state&P.TOUCH_ROTATE)===P.TOUCH_ROTATE||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.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&P.TRUCK)===P.TRUCK||(this._state&P.TOUCH_TRUCK)===P.TOUCH_TRUCK||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&P.DOLLY)===P.DOLLY||(this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&P.ZOOM)===P.ZOOM||(this._state&P.TOUCH_ZOOM)===P.TOUCH_ZOOM||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&P.OFFSET)===P.OFFSET||(this._state&P.TOUCH_OFFSET)===P.TOUCH_OFFSET||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},v=()=>{if(!this._enabled)return;Vt(this._activePointers,me);const S=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,A=S?-S.deltaX:n.x-me.x,_=S?-S.deltaY:n.y-me.y;if(n.copy(me),((this._state&P.ROTATE)===P.ROTATE||(this._state&P.TOUCH_ROTATE)===P.TOUCH_ROTATE||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(A,_),this._isUserControllingRotate=!0),(this._state&P.DOLLY)===P.DOLLY||(this._state&P.ZOOM)===P.ZOOM){const x=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,F=this.dollyDragInverted?-1:1;(this._state&P.DOLLY)===P.DOLLY?(this._dollyInternal(F*_*ft,x,D),this._isUserControllingDolly=!0):(this._zoomInternal(F*_*ft,x,D),this._isUserControllingZoom=!0)}if((this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_ZOOM)===P.TOUCH_ZOOM||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE){const x=me.x-this._activePointers[1].clientX,D=me.y-this._activePointers[1].clientY,F=Math.sqrt(x*x+D*D),I=i.y-F;i.set(0,F);const B=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,R=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET?(this._dollyInternal(I*ft,B,R),this._isUserControllingDolly=!0):(this._zoomInternal(I*ft,B,R),this._isUserControllingZoom=!0)}((this._state&P.TRUCK)===P.TRUCK||(this._state&P.TOUCH_TRUCK)===P.TOUCH_TRUCK||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(A,_,!1),this._isUserControllingTruck=!0),((this._state&P.OFFSET)===P.OFFSET||(this._state&P.TOUCH_OFFSET)===P.TOUCH_OFFSET||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(A,_,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},M=()=>{Vt(this._activePointers,me),n.copy(me),(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",p),this._domElement.ownerDocument.removeEventListener("mouseup",d),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",p),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",L),this._domElement.ownerDocument.addEventListener("pointerlockerror",b),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",p),y())},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",b))};const L=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},b=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),Xo&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",p),this._domElement.addEventListener("wheel",f,{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",p),this._domElement.removeEventListener("wheel",f,{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",p),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.removeEventListener("pointerlockchange",L),this._domElement.ownerDocument.removeEventListener("pointerlockerror",b))},this.cancel=()=>{this._state!==P.NONE&&(this._state=P.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=Ae(e.width,0,1),this._interactiveArea.height=Ae(e.height,0,1),this._interactiveArea.x=Ae(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ae(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=Ae(e,this.minAzimuthAngle,this.maxAzimuthAngle),i=Ae(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||J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(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=Je.NONE,this._changedDolly=0,this._dollyToNoClamp(Ae(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=J(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||J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(i)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(at).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(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=Ae(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||J(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(),Te.setFromMatrixColumn(this._camera.matrix,0),Le.setFromMatrixColumn(this._camera.matrix,1),Te.multiplyScalar(e),Le.multiplyScalar(-t);const n=Y.copy(Te).add(Le),i=W.copy(this._targetEnd).add(n);return this.moveTo(i.x,i.y,i.z,s)}forward(e,t=!1){Y.setFromMatrixColumn(this._camera.matrix,0),Y.crossVectors(this._camera.up,Y),Y.multiplyScalar(e);const s=W.copy(this._targetEnd).add(Y);return this.moveTo(s.x,s.y,s.z,t)}elevate(e,t=!1){return Y.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+Y.x,this._targetEnd.y+Y.y,this._targetEnd.z+Y.z,t)}moveTo(e,t,s,n=!1){this._isUserControllingTruck=!1;const i=Y.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||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,s,n=!1){const r=Y.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?et.copy(e):et.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=Ns(this._sphericalEnd.theta,Bs),d=Ns(this._sphericalEnd.phi,Bs);a.push(this.rotateTo(p,d,t));const m=Y.setFromSpherical(this._sphericalEnd).normalize(),f=js.setFromUnitVectors(m,zt),w=J(Math.abs(m.y),1);w&&f.multiply(Gt.setFromAxisAngle(gt,p)),f.multiply(this._yAxisUpSpaceInverse);const y=Ys.makeEmpty();W.copy(h.min).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setX(h.max.x).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setY(h.max.y).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setZ(h.min.z).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setZ(h.max.z).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setY(h.min.y).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setX(h.min.x).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).applyQuaternion(f),y.expandByPoint(W),y.min.x-=n,y.min.y-=o,y.max.x+=i,y.max.y+=r,f.setFromUnitVectors(zt,m),w&&f.premultiply(Gt.invert()),f.premultiply(this._yAxisUpSpace);const v=y.getSize(Y),M=y.getCenter(W).applyQuaternion(f);if(Ye(this._camera)){const L=this.getDistanceToFitBox(v.x,v.y,v.z,s);a.push(this.moveTo(M.x,M.y,M.z,t)),a.push(this.dollyTo(L,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(Ue(this._camera)){const L=this._camera,b=L.right-L.left,g=L.top-L.bottom,S=s?Math.max(b/v.x,g/v.y):Math.min(b/v.x,g/v.y);a.push(this.moveTo(M.x,M.y,M.z,t)),a.push(this.zoomTo(S,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const s=[],i=e instanceof N.Sphere?Rt.copy(e):ct.createBoundingSphere(e,Rt);if(s.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),Ye(this._camera)){const o=this.getDistanceToFitSphere(i.radius);s.push(this.dollyTo(o,t))}else if(Ue(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=Je.NONE,this._changedDolly=0;const a=W.set(n,i,o),h=Y.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 p=!r||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold)&&J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,s,n,i,o,r,a,h,p,d,m,f,w=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Je.NONE,this._changedDolly=0;const y=Y.set(n,i,o),v=W.set(e,t,s);we.setFromVector3(v.sub(y).applyQuaternion(this._yAxisUpSpace));const M=$e.set(p,d,m),L=W.set(r,a,h);lt.setFromVector3(L.sub(M).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(M,f));const b=lt.theta-we.theta,g=lt.phi-we.phi,S=lt.radius-we.radius;this._sphericalEnd.set(we.radius+S*f,we.phi+g*f,we.theta+b*f),this.normalizeRotations(),this._needsUpdate=!0,w||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const A=!w||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold)&&J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(A)}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(Y),o=this.setLookAt(i.x,i.y,i.z,e,t,s,n);return this._sphericalEnd.phi=Ae(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||J(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&J(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&J(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),Te.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Le.setFromMatrixColumn(this._camera.matrixWorldInverse,1),je.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=Y.set(e,t,s),i=n.distanceTo(this._camera.position),o=n.sub(this._camera.position);Te.multiplyScalar(o.x),Le.multiplyScalar(o.y),je.multiplyScalar(o.z),Y.copy(Te).add(Le).add(je),Y.z=Y.z+i,this.dollyTo(i,!1),this.setFocalOffset(-Y.x,Y.y,-Y.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 N.Vector4,typeof e=="number"?this._viewport.set(e,t,s,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,n=!1){if(Et(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const i=e/t,o=this._camera.getEffectiveFOV()*it,r=this._camera.aspect;return((n?i>r:i<r)?t:e/r)*.5/Math.tan(o*.5)+s*.5}getDistanceToFitSphere(e){if(Et(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*it,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 N.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new N.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof N.Spherical?e:new N.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new N.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%He,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=He),this._spherical.theta+=He*Math.round((this._sphericalEnd.theta-this._spherical.theta)/He)}reset(e=!1){if(!J(this._camera.up.x,this._cameraUp0.x)||!J(this._camera.up.y,this._cameraUp0.y)||!J(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(Y);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,gt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=Y.subVectors(this._target,this._camera.position).normalize(),t=W.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(Y);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=Rs.subVectors(this._targetEnd,this._target),o=Gs.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(te(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=mt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,d,1/0,e),this._needsUpdate=!0}if(te(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=mt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,d,1/0,e),this._needsUpdate=!0}if(te(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const d=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=mt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,d,this.maxSpeed,e),this._needsUpdate=!0}if(te(i.x)&&te(i.y)&&te(i.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const d=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Vs(this._target,this._targetEnd,this._targetVelocity,d,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(te(o.x)&&te(o.y)&&te(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const d=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Vs(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,d,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(te(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const d=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=mt(this._zoom,this._zoomEnd,this._zoomVelocity,d,1/0,e)}if(this.dollyToCursor){if(Ye(this._camera)&&this._changedDolly!==0){const d=this._spherical.radius-this._lastDistance,m=this._camera,f=this._getCameraDirection(at),w=Y.copy(f).cross(m.up).normalize();w.lengthSq()===0&&(w.x=1);const y=W.crossVectors(w,f),v=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*it*.5),L=(this._sphericalEnd.radius-d-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=$e.copy(this._targetEnd).add(w.multiplyScalar(this._dollyControlCoord.x*v*m.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*v)),g=Y.copy(this._targetEnd).lerp(b,L),S=this._lastDollyDirection===Je.IN&&this._spherical.radius<=this.minDistance,A=this._lastDollyDirection===Je.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(S||A)){this._sphericalEnd.radius-=d,this._spherical.radius-=d;const x=W.copy(f).multiplyScalar(-d);g.add(x)}this._boundary.clampPoint(g,g);const _=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(_),this._changedDolly-=d,te(this._changedDolly)&&(this._changedDolly=0)}else if(Ue(this._camera)&&this._changedZoom!==0){const d=this._zoom-this._lastZoom,m=this._camera,f=Y.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),w=W.set(0,0,-1).applyQuaternion(m.quaternion),y=$e.copy(f).add(w.multiplyScalar(-f.dot(m.up))),M=-(this._zoom-d-this._zoom)/this._zoom,L=this._getCameraDirection(at),b=this._targetEnd.dot(L),g=Y.copy(this._targetEnd).lerp(y,M),S=g.dot(L),A=L.multiplyScalar(S-b);g.sub(A),this._boundary.clampPoint(g,g);const _=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(_),this._changedZoom-=d,te(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),(!te(this._focalOffset.x)||!te(this._focalOffset.y)||!te(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Te.setFromMatrixColumn(this._camera.matrix,0),Le.setFromMatrixColumn(this._camera.matrix,1),je.setFromMatrixColumn(this._camera.matrix,2),Te.multiplyScalar(this._focalOffset.x),Le.multiplyScalar(-this._focalOffset.y),je.multiplyScalar(this._focalOffset.z),Y.copy(Te).add(Le).add(je),this._camera.position.add(Y)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Y.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),te(t,this.restThreshold)&&te(s,this.restThreshold)&&te(n,this.restThreshold)&&te(i.x,this.restThreshold)&&te(i.y,this.restThreshold)&&te(i.z,this.restThreshold)&&te(o.x,this.restThreshold)&&te(o.y,this.restThreshold)&&te(o.z,this.restThreshold)&&te(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ot(this.maxDistance),minZoom:this.minZoom,maxZoom:ot(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ot(this.maxPolarAngle),minAzimuthAngle:ot(this.minAzimuthAngle),maxAzimuthAngle:ot(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:Y.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=rt(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=rt(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=rt(s.maxPolarAngle),this.minAzimuthAngle=rt(s.minAzimuthAngle),this.maxAzimuthAngle=rt(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),we.setFromVector3(Y.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(we.theta,we.phi,t),this.dollyTo(we.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",Yo),this._addAllEventListeners(e)}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=W.copy(t).add(e),r=this._boundary.clampPoint(i,$e).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(W.copy(t).multiplyScalar(h)).add(r.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(Ye(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*it,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(Ue(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)||Et(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(at);Yt.lookAt(zs,s,this._camera.up);for(let n=0;n<4;n++){const i=W.copy(this._nearPlaneCorners[n]);i.applyMatrix4(Yt);const o=$e.addVectors(this._target,i);yt.set(o,s),yt.far=this._spherical.radius+1;const r=yt.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 N.Sphere){const s=t,n=s.center;et.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&et.expandByObject(o)}),et.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 p=a.attributes.position;for(let d=0,m=p.count;d<m;d++)Y.fromBufferAttribute(p,d),i=Math.max(i,n.distanceToSquared(Y))}),s.radius=Math.sqrt(i),s}}const Zo=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","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"],Qo=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},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,minDistance:h,maxDistance:p,infinityDolly:d,minZoom:m,maxZoom:f,smoothTime:w,draggingSmoothTime:y,maxSpeed:v,azimuthRotateSpeed:M,polarRotateSpeed:L,dollySpeed:b,dollyDragInverted:g,truckSpeed:S,dollyToCursor:A,dragToOffset:_,verticalDragToForward:x,boundaryFriction:D,restThreshold:F,colliderMeshes:I}=u.toRefs(s),B={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};ct.install({THREE:B});const{camera:R,renderer:H,extend:G,controls:se}=q.useTresContext(),X=u.ref(null);G({CameraControls:ct}),u.watchEffect(()=>{le(),X.value&&n.value?se.value=X.value:se.value=null});function le(){ae(X.value,"update",()=>t("change",X.value)),ae(X.value,"controlend",()=>t("end",X.value)),ae(X.value,"controlstart",()=>t("start",X.value))}const{onLoop:oe}=q.useRenderLoop();return oe(({delta:$})=>{var Q,K;(Q=X.value)!=null&&Q.enabled&&((K=X.value)==null||K.update($))}),u.onUnmounted(()=>{X.value&&X.value.disconnect()}),e({value:X}),($,Q)=>{var K;return u.unref(R)&&u.unref(H)?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:X,"min-polar-angle":u.unref(i),"max-polar-angle":u.unref(o),"min-azimuth-angle":u.unref(r),"max-azimuth-angle":u.unref(a),"min-distance":u.unref(h),"max-distance":u.unref(p),"infinity-dolly":u.unref(d),"min-zoom":u.unref(m),"max-zoom":u.unref(f),"smooth-time":u.unref(w),"dragging-smooth-time":u.unref(y),"max-speed":u.unref(v),"azimuth-rotate-speed":u.unref(M),"polar-rotate-speed":u.unref(L),"dolly-speed":u.unref(b),"dolly-drag-inverted":u.unref(g),"truck-speed":u.unref(S),"dolly-to-cursor":u.unref(A),"drag-to-offset":u.unref(_),"vertical-drag-to-forward":u.unref(x),"boundary-friction":u.unref(D),"rest-threshold":u.unref(F),"collider-meshes":u.unref(I),args:[u.unref(R)||$.camera,((K=u.unref(H))==null?void 0:K.domElement)||$.domElement]},null,8,Zo)):u.createCommentVNode("",!0)}}});class Ko extends c.MeshStandardMaterial{constructor(t={}){super(t);re(this,"_time");re(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=`
86
+ */const V={LEFT:1,RIGHT:2,MIDDLE:4},P=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}),Je={NONE:0,IN:1,OUT:-1};function Ye(l){return l.isPerspectiveCamera}function Ue(l){return l.isOrthographicCamera}const He=Math.PI*2,Bs=Math.PI/2,Us=1e-5,it=Math.PI/180;function Ae(l,e,t){return Math.max(e,Math.min(t,l))}function te(l,e=Us){return Math.abs(l)<e}function J(l,e,t=Us){return te(l-e,t)}function Ns(l,e){return Math.round(l/e)*e}function ot(l){return isFinite(l)?l:l<0?-Number.MAX_VALUE:Number.MAX_VALUE}function rt(l){return Math.abs(l)<Number.MAX_VALUE?l:l*(1/0)}function mt(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 p=e,d=n*s;h=Ae(h,-d,d),e=l-h;const m=(t.value+o*h)*i;t.value=(t.value-o*m)*a;let f=e+(h+m)*a;return p-l>0==f>p&&(f=p,t.value=(f-p)/i),f}function Vs(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 p=e.x,d=e.y,m=e.z,f=l.x-p,w=l.y-d,y=l.z-m;const v=p,M=d,L=m,b=n*s,g=b*b,S=f*f+w*w+y*y;if(S>g){const G=Math.sqrt(S);f=f/G*b,w=w/G*b,y=y/G*b}p=l.x-f,d=l.y-w,m=l.z-y;const A=(t.x+r*f)*i,_=(t.y+r*w)*i,x=(t.z+r*y)*i;t.x=(t.x-r*A)*h,t.y=(t.y-r*_)*h,t.z=(t.z-r*x)*h,o.x=p+(f+A)*h,o.y=d+(w+_)*h,o.z=m+(y+x)*h;const D=v-l.x,k=M-l.y,I=L-l.z,B=o.x-v,R=o.y-M,H=o.z-L;return D*B+k*R+I*H>0&&(o.x=v,o.y=M,o.z=L,t.x=(o.x-v)/i,t.y=(o.y-M)/i,t.z=(o.z-L)/i),o}function Vt(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 Et(l,e){return Ue(l)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Go{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 Yo="2.7.1",ft=1/8,Es=typeof window<"u",jo=Es&&/Mac/.test(navigator.platform),Xo=!(Es&&"PointerEvent"in window);let N,zs,gt,zt,me,Y,W,$e,at,Te,Le,je,Rs,Gs,we,lt,et,Ys,Rt,js,Gt,Yt,yt;class ct extends Go{static install(e){N=e.THREE,zs=Object.freeze(new N.Vector3(0,0,0)),gt=Object.freeze(new N.Vector3(0,1,0)),zt=Object.freeze(new N.Vector3(0,0,1)),me=new N.Vector2,Y=new N.Vector3,W=new N.Vector3,$e=new N.Vector3,at=new N.Vector3,Te=new N.Vector3,Le=new N.Vector3,je=new N.Vector3,Rs=new N.Vector3,Gs=new N.Vector3,we=new N.Spherical,lt=new N.Spherical,et=new N.Box3,Ys=new N.Box3,Rt=new N.Sphere,js=new N.Quaternion,Gt=new N.Quaternion,Yt=new N.Matrix4,yt=new N.Raycaster}static get ACTION(){return P}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=P.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=Je.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new N.Vector3,this._focalOffsetVelocity=new N.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,S,A)=>{let _,x;if(Ye(this._camera)){const D=Y.copy(this._camera.position).sub(this._target),k=this._camera.getEffectiveFOV()*it,I=D.length()*Math.tan(k*.5);_=this.truckSpeed*g*I/this._elementRect.height,x=this.truckSpeed*S*I/this._elementRect.height}else if(Ue(this._camera)){const D=this._camera;_=g*(D.right-D.left)/D.zoom/this._elementRect.width,x=S*(D.top-D.bottom)/D.zoom/this._elementRect.height}else return;this.verticalDragToForward?(A?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(_,0,!0),this.forward(-x,!0)):A?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(_,x,!0)},this._rotateInternal=(g,S)=>{const A=He*this.azimuthRotateSpeed*g/this._elementRect.height,_=He*this.polarRotateSpeed*S/this._elementRect.height;this.rotate(A,_,!0)},this._dollyInternal=(g,S,A)=>{const _=Math.pow(.95,-g*this.dollySpeed),x=this._sphericalEnd.radius,D=this._sphericalEnd.radius*_,k=Ae(D,this.minDistance,this.maxDistance),I=k-D;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(D,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(I,!0),this._dollyToNoClamp(k,!0)):this._dollyToNoClamp(k,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?D:k)-x,this._dollyControlCoord.set(S,A)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,S,A)=>{const _=Math.pow(.95,g*this.dollySpeed),x=this._zoom,D=this._zoom*_;this.zoomTo(D,!0),this.dollyToCursor&&(this._changedZoom+=D-x,this._dollyControlCoord.set(S,A))},typeof N>"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 N.Quaternion().setFromUnitVectors(this._camera.up,gt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=P.NONE,this._target=new N.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new N.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new N.Spherical().setFromVector3(Y.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 N.Vector3,new N.Vector3,new N.Vector3,new N.Vector3],this._updateNearPlaneCorners(),this._boundary=new N.Box3(new N.Vector3(-1/0,-1/0,-1/0),new N.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 N.Vector2,this.mouseButtons={left:P.ROTATE,middle:P.DOLLY,right:P.TRUCK,wheel:Ye(this._camera)?P.DOLLY:Ue(this._camera)?P.ZOOM:P.NONE},this.touches={one:P.TOUCH_ROTATE,two:Ye(this._camera)?P.TOUCH_DOLLY_TRUCK:Ue(this._camera)?P.TOUCH_ZOOM_TRUCK:P.NONE,three:P.TOUCH_TRUCK};const s=new N.Vector2,n=new N.Vector2,i=new N.Vector2,o=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const _=this._domElement.getBoundingClientRect(),x=g.clientX/_.width,D=g.clientY/_.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const S=g.pointerType!=="mouse"?null:(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(g.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(S!==null){const _=this._findPointerByMouseButton(S);_&&this._disposePointer(_)}if((g.buttons&V.LEFT)===V.LEFT&&this._lockedPointer)return;const A={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:S};this._activePointers.push(A),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",p),this._isDragging=!0,y(g)},r=g=>{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 _=this._domElement.getBoundingClientRect(),x=g.clientX/_.width,D=g.clientY/_.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const S=(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(g.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(S!==null){const _=this._findPointerByMouseButton(S);_&&this._disposePointer(_)}const A={pointerId:1,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.LEFT?V.MIDDLE:(g.buttons&V.RIGHT)===V.LEFT?V.RIGHT:null};this._activePointers.push(A),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.addEventListener("mousemove",h),this._domElement.ownerDocument.addEventListener("mouseup",d),this._isDragging=!0,y(g)},a=g=>{g.cancelable&&g.preventDefault();const S=g.pointerId,A=this._lockedPointer||this._findPointerById(S);if(A){if(A.clientX=g.clientX,A.clientY=g.clientY,A.deltaX=g.movementX,A.deltaY=g.movementY,this._state=0,g.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&&(g.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);v()}},h=g=>{const S=this._lockedPointer||this._findPointerById(1);S&&(S.clientX=g.clientX,S.clientY=g.clientY,S.deltaX=g.movementX,S.deltaY=g.movementY,this._state=0,(this._lockedPointer||(g.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right),v())},p=g=>{const S=this._findPointerById(g.pointerId);if(!(S&&S===this._lockedPointer)){if(S&&this._disposePointer(S),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=P.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=P.NONE;M()}},d=()=>{const g=this._findPointerById(1);g&&g===this._lockedPointer||(g&&this._disposePointer(g),this._state=P.NONE,M())};let m=-1;const f=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===P.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const D=this._domElement.getBoundingClientRect(),k=g.clientX/D.width,I=g.clientY/D.height;if(k<this._interactiveArea.left||k>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===P.ROTATE||this.mouseButtons.wheel===P.TRUCK){const D=performance.now();m-D<1e3&&this._getClientRect(this._elementRect),m=D}const S=jo?-1:-3,A=g.deltaMode===1?g.deltaY/S:g.deltaY/(S*10),_=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case P.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case P.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case P.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case P.DOLLY:{this._dollyInternal(-A,_,x),this._isUserControllingDolly=!0;break}case P.ZOOM:{this._zoomInternal(-A,_,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},w=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===ct.ACTION.NONE){const S=g instanceof PointerEvent?g.pointerId:(g instanceof MouseEvent,0),A=this._findPointerById(S);A&&this._disposePointer(A),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",d);return}g.preventDefault()}},y=g=>{if(!this._enabled)return;if(Vt(this._activePointers,me),this._getClientRect(this._elementRect),s.copy(me),n.copy(me),this._activePointers.length>=2){const A=me.x-this._activePointers[1].clientX,_=me.y-this._activePointers[1].clientY,x=Math.sqrt(A*A+_*_);i.set(0,x);const D=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,k=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(D,k)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.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&&(g.buttons&V.LEFT)===V.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&P.ROTATE)===P.ROTATE||(this._state&P.TOUCH_ROTATE)===P.TOUCH_ROTATE||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.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&P.TRUCK)===P.TRUCK||(this._state&P.TOUCH_TRUCK)===P.TOUCH_TRUCK||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&P.DOLLY)===P.DOLLY||(this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&P.ZOOM)===P.ZOOM||(this._state&P.TOUCH_ZOOM)===P.TOUCH_ZOOM||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&P.OFFSET)===P.OFFSET||(this._state&P.TOUCH_OFFSET)===P.TOUCH_OFFSET||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},v=()=>{if(!this._enabled)return;Vt(this._activePointers,me);const S=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,A=S?-S.deltaX:n.x-me.x,_=S?-S.deltaY:n.y-me.y;if(n.copy(me),((this._state&P.ROTATE)===P.ROTATE||(this._state&P.TOUCH_ROTATE)===P.TOUCH_ROTATE||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(A,_),this._isUserControllingRotate=!0),(this._state&P.DOLLY)===P.DOLLY||(this._state&P.ZOOM)===P.ZOOM){const x=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,k=this.dollyDragInverted?-1:1;(this._state&P.DOLLY)===P.DOLLY?(this._dollyInternal(k*_*ft,x,D),this._isUserControllingDolly=!0):(this._zoomInternal(k*_*ft,x,D),this._isUserControllingZoom=!0)}if((this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_ZOOM)===P.TOUCH_ZOOM||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE){const x=me.x-this._activePointers[1].clientX,D=me.y-this._activePointers[1].clientY,k=Math.sqrt(x*x+D*D),I=i.y-k;i.set(0,k);const B=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,R=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET?(this._dollyInternal(I*ft,B,R),this._isUserControllingDolly=!0):(this._zoomInternal(I*ft,B,R),this._isUserControllingZoom=!0)}((this._state&P.TRUCK)===P.TRUCK||(this._state&P.TOUCH_TRUCK)===P.TOUCH_TRUCK||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(A,_,!1),this._isUserControllingTruck=!0),((this._state&P.OFFSET)===P.OFFSET||(this._state&P.TOUCH_OFFSET)===P.TOUCH_OFFSET||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(A,_,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},M=()=>{Vt(this._activePointers,me),n.copy(me),(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",p),this._domElement.ownerDocument.removeEventListener("mouseup",d),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",p),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",L),this._domElement.ownerDocument.addEventListener("pointerlockerror",b),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",p),y())},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",b))};const L=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},b=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),Xo&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",p),this._domElement.addEventListener("wheel",f,{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",p),this._domElement.removeEventListener("wheel",f,{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",p),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.removeEventListener("pointerlockchange",L),this._domElement.ownerDocument.removeEventListener("pointerlockerror",b))},this.cancel=()=>{this._state!==P.NONE&&(this._state=P.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=Ae(e.width,0,1),this._interactiveArea.height=Ae(e.height,0,1),this._interactiveArea.x=Ae(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ae(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=Ae(e,this.minAzimuthAngle,this.maxAzimuthAngle),i=Ae(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||J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(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=Je.NONE,this._changedDolly=0,this._dollyToNoClamp(Ae(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=J(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||J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(i)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(at).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(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=Ae(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||J(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(),Te.setFromMatrixColumn(this._camera.matrix,0),Le.setFromMatrixColumn(this._camera.matrix,1),Te.multiplyScalar(e),Le.multiplyScalar(-t);const n=Y.copy(Te).add(Le),i=W.copy(this._targetEnd).add(n);return this.moveTo(i.x,i.y,i.z,s)}forward(e,t=!1){Y.setFromMatrixColumn(this._camera.matrix,0),Y.crossVectors(this._camera.up,Y),Y.multiplyScalar(e);const s=W.copy(this._targetEnd).add(Y);return this.moveTo(s.x,s.y,s.z,t)}elevate(e,t=!1){return Y.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+Y.x,this._targetEnd.y+Y.y,this._targetEnd.z+Y.z,t)}moveTo(e,t,s,n=!1){this._isUserControllingTruck=!1;const i=Y.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||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,s,n=!1){const r=Y.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?et.copy(e):et.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=Ns(this._sphericalEnd.theta,Bs),d=Ns(this._sphericalEnd.phi,Bs);a.push(this.rotateTo(p,d,t));const m=Y.setFromSpherical(this._sphericalEnd).normalize(),f=js.setFromUnitVectors(m,zt),w=J(Math.abs(m.y),1);w&&f.multiply(Gt.setFromAxisAngle(gt,p)),f.multiply(this._yAxisUpSpaceInverse);const y=Ys.makeEmpty();W.copy(h.min).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setX(h.max.x).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setY(h.max.y).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setZ(h.min.z).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setZ(h.max.z).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setY(h.min.y).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setX(h.min.x).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).applyQuaternion(f),y.expandByPoint(W),y.min.x-=n,y.min.y-=o,y.max.x+=i,y.max.y+=r,f.setFromUnitVectors(zt,m),w&&f.premultiply(Gt.invert()),f.premultiply(this._yAxisUpSpace);const v=y.getSize(Y),M=y.getCenter(W).applyQuaternion(f);if(Ye(this._camera)){const L=this.getDistanceToFitBox(v.x,v.y,v.z,s);a.push(this.moveTo(M.x,M.y,M.z,t)),a.push(this.dollyTo(L,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(Ue(this._camera)){const L=this._camera,b=L.right-L.left,g=L.top-L.bottom,S=s?Math.max(b/v.x,g/v.y):Math.min(b/v.x,g/v.y);a.push(this.moveTo(M.x,M.y,M.z,t)),a.push(this.zoomTo(S,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const s=[],i=e instanceof N.Sphere?Rt.copy(e):ct.createBoundingSphere(e,Rt);if(s.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),Ye(this._camera)){const o=this.getDistanceToFitSphere(i.radius);s.push(this.dollyTo(o,t))}else if(Ue(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=Je.NONE,this._changedDolly=0;const a=W.set(n,i,o),h=Y.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 p=!r||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold)&&J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,s,n,i,o,r,a,h,p,d,m,f,w=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Je.NONE,this._changedDolly=0;const y=Y.set(n,i,o),v=W.set(e,t,s);we.setFromVector3(v.sub(y).applyQuaternion(this._yAxisUpSpace));const M=$e.set(p,d,m),L=W.set(r,a,h);lt.setFromVector3(L.sub(M).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(M,f));const b=lt.theta-we.theta,g=lt.phi-we.phi,S=lt.radius-we.radius;this._sphericalEnd.set(we.radius+S*f,we.phi+g*f,we.theta+b*f),this.normalizeRotations(),this._needsUpdate=!0,w||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const A=!w||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold)&&J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(A)}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(Y),o=this.setLookAt(i.x,i.y,i.z,e,t,s,n);return this._sphericalEnd.phi=Ae(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||J(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&J(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&J(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),Te.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Le.setFromMatrixColumn(this._camera.matrixWorldInverse,1),je.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=Y.set(e,t,s),i=n.distanceTo(this._camera.position),o=n.sub(this._camera.position);Te.multiplyScalar(o.x),Le.multiplyScalar(o.y),je.multiplyScalar(o.z),Y.copy(Te).add(Le).add(je),Y.z=Y.z+i,this.dollyTo(i,!1),this.setFocalOffset(-Y.x,Y.y,-Y.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 N.Vector4,typeof e=="number"?this._viewport.set(e,t,s,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,n=!1){if(Et(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const i=e/t,o=this._camera.getEffectiveFOV()*it,r=this._camera.aspect;return((n?i>r:i<r)?t:e/r)*.5/Math.tan(o*.5)+s*.5}getDistanceToFitSphere(e){if(Et(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*it,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 N.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new N.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof N.Spherical?e:new N.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new N.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%He,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=He),this._spherical.theta+=He*Math.round((this._sphericalEnd.theta-this._spherical.theta)/He)}reset(e=!1){if(!J(this._camera.up.x,this._cameraUp0.x)||!J(this._camera.up.y,this._cameraUp0.y)||!J(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(Y);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,gt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=Y.subVectors(this._target,this._camera.position).normalize(),t=W.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(Y);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=Rs.subVectors(this._targetEnd,this._target),o=Gs.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(te(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=mt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,d,1/0,e),this._needsUpdate=!0}if(te(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=mt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,d,1/0,e),this._needsUpdate=!0}if(te(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const d=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=mt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,d,this.maxSpeed,e),this._needsUpdate=!0}if(te(i.x)&&te(i.y)&&te(i.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const d=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Vs(this._target,this._targetEnd,this._targetVelocity,d,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(te(o.x)&&te(o.y)&&te(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const d=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Vs(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,d,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(te(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const d=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=mt(this._zoom,this._zoomEnd,this._zoomVelocity,d,1/0,e)}if(this.dollyToCursor){if(Ye(this._camera)&&this._changedDolly!==0){const d=this._spherical.radius-this._lastDistance,m=this._camera,f=this._getCameraDirection(at),w=Y.copy(f).cross(m.up).normalize();w.lengthSq()===0&&(w.x=1);const y=W.crossVectors(w,f),v=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*it*.5),L=(this._sphericalEnd.radius-d-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=$e.copy(this._targetEnd).add(w.multiplyScalar(this._dollyControlCoord.x*v*m.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*v)),g=Y.copy(this._targetEnd).lerp(b,L),S=this._lastDollyDirection===Je.IN&&this._spherical.radius<=this.minDistance,A=this._lastDollyDirection===Je.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(S||A)){this._sphericalEnd.radius-=d,this._spherical.radius-=d;const x=W.copy(f).multiplyScalar(-d);g.add(x)}this._boundary.clampPoint(g,g);const _=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(_),this._changedDolly-=d,te(this._changedDolly)&&(this._changedDolly=0)}else if(Ue(this._camera)&&this._changedZoom!==0){const d=this._zoom-this._lastZoom,m=this._camera,f=Y.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),w=W.set(0,0,-1).applyQuaternion(m.quaternion),y=$e.copy(f).add(w.multiplyScalar(-f.dot(m.up))),M=-(this._zoom-d-this._zoom)/this._zoom,L=this._getCameraDirection(at),b=this._targetEnd.dot(L),g=Y.copy(this._targetEnd).lerp(y,M),S=g.dot(L),A=L.multiplyScalar(S-b);g.sub(A),this._boundary.clampPoint(g,g);const _=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(_),this._changedZoom-=d,te(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),(!te(this._focalOffset.x)||!te(this._focalOffset.y)||!te(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Te.setFromMatrixColumn(this._camera.matrix,0),Le.setFromMatrixColumn(this._camera.matrix,1),je.setFromMatrixColumn(this._camera.matrix,2),Te.multiplyScalar(this._focalOffset.x),Le.multiplyScalar(-this._focalOffset.y),je.multiplyScalar(this._focalOffset.z),Y.copy(Te).add(Le).add(je),this._camera.position.add(Y)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Y.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),te(t,this.restThreshold)&&te(s,this.restThreshold)&&te(n,this.restThreshold)&&te(i.x,this.restThreshold)&&te(i.y,this.restThreshold)&&te(i.z,this.restThreshold)&&te(o.x,this.restThreshold)&&te(o.y,this.restThreshold)&&te(o.z,this.restThreshold)&&te(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ot(this.maxDistance),minZoom:this.minZoom,maxZoom:ot(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ot(this.maxPolarAngle),minAzimuthAngle:ot(this.minAzimuthAngle),maxAzimuthAngle:ot(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:Y.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=rt(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=rt(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=rt(s.maxPolarAngle),this.minAzimuthAngle=rt(s.minAzimuthAngle),this.maxAzimuthAngle=rt(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),we.setFromVector3(Y.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(we.theta,we.phi,t),this.dollyTo(we.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",Yo),this._addAllEventListeners(e)}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=W.copy(t).add(e),r=this._boundary.clampPoint(i,$e).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(W.copy(t).multiplyScalar(h)).add(r.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(Ye(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*it,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(Ue(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)||Et(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(at);Yt.lookAt(zs,s,this._camera.up);for(let n=0;n<4;n++){const i=W.copy(this._nearPlaneCorners[n]);i.applyMatrix4(Yt);const o=$e.addVectors(this._target,i);yt.set(o,s),yt.far=this._spherical.radius+1;const r=yt.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 N.Sphere){const s=t,n=s.center;et.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&et.expandByObject(o)}),et.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 p=a.attributes.position;for(let d=0,m=p.count;d<m;d++)Y.fromBufferAttribute(p,d),i=Math.max(i,n.distanceToSquared(Y))}),s.radius=Math.sqrt(i),s}}const Zo=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","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"],Qo=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},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,minDistance:h,maxDistance:p,infinityDolly:d,minZoom:m,maxZoom:f,smoothTime:w,draggingSmoothTime:y,maxSpeed:v,azimuthRotateSpeed:M,polarRotateSpeed:L,dollySpeed:b,dollyDragInverted:g,truckSpeed:S,dollyToCursor:A,dragToOffset:_,verticalDragToForward:x,boundaryFriction:D,restThreshold:k,colliderMeshes:I}=u.toRefs(s),B={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};ct.install({THREE:B});const{camera:R,renderer:H,extend:G,controls:se}=q.useTresContext(),X=u.ref(null);G({CameraControls:ct}),u.watchEffect(()=>{le(),X.value&&n.value?se.value=X.value:se.value=null});function le(){ae(X.value,"update",()=>t("change",X.value)),ae(X.value,"controlend",()=>t("end",X.value)),ae(X.value,"controlstart",()=>t("start",X.value))}const{onLoop:oe}=q.useRenderLoop();return oe(({delta:$})=>{var Q,K;(Q=X.value)!=null&&Q.enabled&&((K=X.value)==null||K.update($))}),u.onUnmounted(()=>{X.value&&X.value.disconnect()}),e({value:X}),($,Q)=>{var K;return u.unref(R)&&u.unref(H)?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:X,"min-polar-angle":u.unref(i),"max-polar-angle":u.unref(o),"min-azimuth-angle":u.unref(r),"max-azimuth-angle":u.unref(a),"min-distance":u.unref(h),"max-distance":u.unref(p),"infinity-dolly":u.unref(d),"min-zoom":u.unref(m),"max-zoom":u.unref(f),"smooth-time":u.unref(w),"dragging-smooth-time":u.unref(y),"max-speed":u.unref(v),"azimuth-rotate-speed":u.unref(M),"polar-rotate-speed":u.unref(L),"dolly-speed":u.unref(b),"dolly-drag-inverted":u.unref(g),"truck-speed":u.unref(S),"dolly-to-cursor":u.unref(A),"drag-to-offset":u.unref(_),"vertical-drag-to-forward":u.unref(x),"boundary-friction":u.unref(D),"rest-threshold":u.unref(k),"collider-meshes":u.unref(I),args:[u.unref(R)||$.camera,((K=u.unref(H))==null?void 0:K.domElement)||$.domElement]},null,8,Zo)):u.createCommentVNode("",!0)}}});class Ko extends c.MeshStandardMaterial{constructor(t={}){super(t);re(this,"_time");re(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=`
87
87
  uniform float time;
88
88
  uniform float factor;
89
89
  ${t.vertexShader}
@@ -92,4 +92,4 @@
92
92
  float s = sin( theta );
93
93
  mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );
94
94
  vec3 transformed = vec3( position ) * m;
95
- 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 Wo=["factor"],qo=u.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(l){const e=l,t=u.shallowRef(),{extend:s}=q.useTresContext();s({MeshWobbleMaterial:Ko});const{onLoop:n}=q.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,Wo))}});function Xe(l,e,t){return Math.max(e,Math.min(t,l))}function Jo(l,e){return(l%e+e)%e}function jt(l,e,t){return(1-t)*l+t*e}class Xt{constructor(e=0,t=0){Xt.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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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(Xe(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 Ce="srgb",Zt="srgb-linear",Xs="display-p3";class ht{constructor(e,t,s,n,i,o,r,a,h){ht.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 p=this.elements;return p[0]=e,p[1]=n,p[2]=r,p[3]=t,p[4]=i,p[5]=a,p[6]=s,p[7]=o,p[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],p=s[4],d=s[7],m=s[2],f=s[5],w=s[8],y=n[0],v=n[3],M=n[6],L=n[1],b=n[4],g=n[7],S=n[2],A=n[5],_=n[8];return i[0]=o*y+r*L+a*S,i[3]=o*v+r*b+a*A,i[6]=o*M+r*g+a*_,i[1]=h*y+p*L+d*S,i[4]=h*v+p*b+d*A,i[7]=h*M+p*g+d*_,i[2]=m*y+f*L+w*S,i[5]=m*v+f*b+w*A,i[8]=m*M+f*g+w*_,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],p=e[8];return t*o*p-t*r*h-s*i*p+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],p=e[8],d=p*o-r*h,m=r*a-p*i,f=h*i-o*a,w=t*d+s*m+n*f;if(w===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/w;return e[0]=d*y,e[1]=(n*h-p*s)*y,e[2]=(r*s-n*o)*y,e[3]=m*y,e[4]=(p*t-n*a)*y,e[5]=(n*i-r*t)*y,e[6]=f*y,e[7]=(s*a-h*t)*y,e[8]=(o*t-s*i)*y,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(Qt.makeScale(e,t)),this}rotate(e){return this.premultiply(Qt.makeRotation(-e)),this}translate(e,t){return this.premultiply(Qt.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 Qt=new ht;function Kt(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}function Wt(l){return l<.0031308?l*12.92:1.055*Math.pow(l,.41666)-.055}const Ho=new ht().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),$o=new ht().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function er(l){return l.convertSRGBToLinear().applyMatrix3($o)}function tr(l){return l.applyMatrix3(Ho).convertLinearToSRGB()}const sr={[Zt]:l=>l,[Ce]:l=>l.convertSRGBToLinear(),[Xs]:er},nr={[Zt]:l=>l,[Ce]:l=>l.convertLinearToSRGB(),[Xs]:tr},Me={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 Zt},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=sr[e],n=nr[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)}},Zs={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},be={h:0,s:0,l:0},_t={h:0,s:0,l:0};function qt(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 wt{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=Ce){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Me.toWorkingColorSpace(this,t),this}setRGB(e,t,s,n=Me.workingColorSpace){return this.r=e,this.g=t,this.b=s,Me.toWorkingColorSpace(this,n),this}setHSL(e,t,s,n=Me.workingColorSpace){if(e=Jo(e,1),t=Xe(t,0,1),s=Xe(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=qt(o,i,e+1/3),this.g=qt(o,i,e),this.b=qt(o,i,e-1/3)}return Me.toWorkingColorSpace(this,n),this}setStyle(e,t=Ce){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=Ce){const s=Zs[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=Kt(e.r),this.g=Kt(e.g),this.b=Kt(e.b),this}copyLinearToSRGB(e){return this.r=Wt(e.r),this.g=Wt(e.g),this.b=Wt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ce){return Me.fromWorkingColorSpace(ue.copy(this),e),Math.round(Xe(ue.r*255,0,255))*65536+Math.round(Xe(ue.g*255,0,255))*256+Math.round(Xe(ue.b*255,0,255))}getHexString(e=Ce){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Me.workingColorSpace){Me.fromWorkingColorSpace(ue.copy(this),t);const s=ue.r,n=ue.g,i=ue.b,o=Math.max(s,n,i),r=Math.min(s,n,i);let a,h;const p=(r+o)/2;if(r===o)a=0,h=0;else{const d=o-r;switch(h=p<=.5?d/(o+r):d/(2-o-r),o){case s:a=(n-i)/d+(n<i?6:0);break;case n:a=(i-s)/d+2;break;case i:a=(s-n)/d+4;break}a/=6}return e.h=a,e.s=h,e.l=p,e}getRGB(e,t=Me.workingColorSpace){return Me.fromWorkingColorSpace(ue.copy(this),t),e.r=ue.r,e.g=ue.g,e.b=ue.b,e}getStyle(e=Ce){Me.fromWorkingColorSpace(ue.copy(this),e);const t=ue.r,s=ue.g,n=ue.b;return e!==Ce?`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(be),be.h+=e,be.s+=t,be.l+=s,this.setHSL(be.h,be.s,be.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(be),e.getHSL(_t);const s=jt(be.h,_t.h,t),n=jt(be.s,_t.s,t),i=jt(be.l,_t.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 ue=new wt;wt.NAMES=Zs;class ir extends c.MeshStandardMaterial{constructor(t={}){super();re(this,"isMeshPhysicalMaterial");re(this,"clearcoatMap");re(this,"clearcoatRoughness");re(this,"clearcoatRoughnessMap");re(this,"clearcoatNormalScale");re(this,"clearcoatNormalMap");re(this,"ior");re(this,"transmissionMap");re(this,"thickness");re(this,"thicknessMap");re(this,"attenuationDistance");re(this,"attenuationColor");re(this,"specularIntensity");re(this,"specularIntensityMap");re(this,"specularColor");re(this,"specularColorMap");re(this,"_clearcoat");re(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Xt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Xe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(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 wt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new wt(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 or=ir,rr=u.defineComponent({__name:"index",setup(l,{expose:e}){const t=u.shallowRef(),{extend:s}=q.useTresContext();return s({MeshGlassMaterial:or}),e({MeshGlassMaterialClass:t}),(n,i)=>(u.openBlock(),u.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}}),ar=["args"],lr=["color"],cr=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,ar),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,lr)])],16))}}),hr=["args"],ur=["color"],pr=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,hr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,ur)])],16))}}),dr=["args"],mr=["color"],fr=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,dr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,mr)])],16))}}),gr=["args"],yr=["color"],_r=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,gr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,yr)])],16))}}),wr=["args"],xr=["color"],vr=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,wr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,xr)])],16))}}),Ar=["args"],Mr=["color"],br=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,Ar),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Mr)])],16))}}),Sr=["rotation"],Tr=["args"],Lr=["color"],Cr=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,Tr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Lr)])],16,Sr))}}),Or=["args"],Pr=["color"],Dr=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,Or),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Pr)])],16))}}),Ir=["args"],Fr=["color"],kr=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,Ir),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Fr)])],16))}}),Br=["rotation"],Ur=["args"],Nr=["color"],Vr=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,Ur),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Nr)])],16,Br))}}),Er=["args"],zr=["color"],Rr=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,Er),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,zr)])],16))}}),Gr=["args"],Yr=["color"],jr=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,Gr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Yr)])],16))}}),Xr=["args"],Zr=["color"],Qr=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,Xr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Zr)])],16))}}),Kr=["receive-shadow","rotation"],Wr=["args"],qr=u.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Jr=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:Math.pow(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 p=0;const d=r/r/2,m=h.attributes.position;for(let f=0;f<r+1;f++)for(let w=0;w<r+1;w++)m.setXYZ(p++,f/r-d+(f===0?-a:0),w/r-d,t(f/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,Wr),u.renderSlot(r.$slots,"default",{},()=>[qr])],8,Kr)],16))}});let Oe;const Hr=(l="body")=>{Oe||(Oe=new nn.Pane({container:document.querySelector(l)}),Oe.element.style.position="absolute",Oe.element.style.top="1rem",Oe.element.style.right="1rem",Oe.element.style.zIndex="9999");const{logWarning:e}=Ut();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(){Oe&&Oe.dispose()}return u.onMounted(()=>{const{resume:s}=q.useRenderLoop();s()}),u.onUnmounted(()=>{t()}),{pane:Oe,disposeTweakPane:t}};U.Backdrop=Jr,U.Box=cr,U.CameraControls=Qo,U.Circle=pr,U.Cone=fr,U.ContactShadows=ro,U.Dodecahedron=_r,U.Environment=Yi,U.FBXModel=To,U.GLTFModel=So,U.Icosahedron=vr,U.KeyboardControls=ko,U.Levioso=to,U.MapControls=zo,U.MeshGlassMaterial=rr,U.MeshWobbleMaterial=qo,U.MouseParallax=Mo,U.Octahedron=br,U.OrbitControls=Po,U.Plane=Cr,U.PointerLockControls=Vo,U.Precipitation=Wi,U.Ring=Dr,U.ScrollControls=Ro,U.Smoke=eo,U.Sphere=kr,U.Stars=Zi,U.Tetrahedron=Vr,U.Text3D=Ri,U.Torus=Rr,U.TorusKnot=jr,U.TransformControls=Uo,U.Tube=Qr,U.useAnimations=Gi,U.useEnvironment=Ls,U.useFBX=Fs,U.useGLTF=Is,U.useProgress=Lo,U.useTweakPane=Hr,U.useVideoTexture=Co,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
95
+ 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 Wo=["factor"],qo=u.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(l){const e=l,t=u.shallowRef(),{extend:s}=q.useTresContext();s({MeshWobbleMaterial:Ko});const{onLoop:n}=q.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,Wo))}});function Xe(l,e,t){return Math.max(e,Math.min(t,l))}function Jo(l,e){return(l%e+e)%e}function jt(l,e,t){return(1-t)*l+t*e}class Xt{constructor(e=0,t=0){Xt.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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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(Xe(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 Ce="srgb",Zt="srgb-linear",Xs="display-p3";class ht{constructor(e,t,s,n,i,o,r,a,h){ht.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 p=this.elements;return p[0]=e,p[1]=n,p[2]=r,p[3]=t,p[4]=i,p[5]=a,p[6]=s,p[7]=o,p[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],p=s[4],d=s[7],m=s[2],f=s[5],w=s[8],y=n[0],v=n[3],M=n[6],L=n[1],b=n[4],g=n[7],S=n[2],A=n[5],_=n[8];return i[0]=o*y+r*L+a*S,i[3]=o*v+r*b+a*A,i[6]=o*M+r*g+a*_,i[1]=h*y+p*L+d*S,i[4]=h*v+p*b+d*A,i[7]=h*M+p*g+d*_,i[2]=m*y+f*L+w*S,i[5]=m*v+f*b+w*A,i[8]=m*M+f*g+w*_,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],p=e[8];return t*o*p-t*r*h-s*i*p+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],p=e[8],d=p*o-r*h,m=r*a-p*i,f=h*i-o*a,w=t*d+s*m+n*f;if(w===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/w;return e[0]=d*y,e[1]=(n*h-p*s)*y,e[2]=(r*s-n*o)*y,e[3]=m*y,e[4]=(p*t-n*a)*y,e[5]=(n*i-r*t)*y,e[6]=f*y,e[7]=(s*a-h*t)*y,e[8]=(o*t-s*i)*y,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(Qt.makeScale(e,t)),this}rotate(e){return this.premultiply(Qt.makeRotation(-e)),this}translate(e,t){return this.premultiply(Qt.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 Qt=new ht;function Kt(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}function Wt(l){return l<.0031308?l*12.92:1.055*Math.pow(l,.41666)-.055}const Ho=new ht().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),$o=new ht().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function er(l){return l.convertSRGBToLinear().applyMatrix3($o)}function tr(l){return l.applyMatrix3(Ho).convertLinearToSRGB()}const sr={[Zt]:l=>l,[Ce]:l=>l.convertSRGBToLinear(),[Xs]:er},nr={[Zt]:l=>l,[Ce]:l=>l.convertLinearToSRGB(),[Xs]:tr},Me={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 Zt},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=sr[e],n=nr[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)}},Zs={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},be={h:0,s:0,l:0},_t={h:0,s:0,l:0};function qt(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 wt{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=Ce){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Me.toWorkingColorSpace(this,t),this}setRGB(e,t,s,n=Me.workingColorSpace){return this.r=e,this.g=t,this.b=s,Me.toWorkingColorSpace(this,n),this}setHSL(e,t,s,n=Me.workingColorSpace){if(e=Jo(e,1),t=Xe(t,0,1),s=Xe(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=qt(o,i,e+1/3),this.g=qt(o,i,e),this.b=qt(o,i,e-1/3)}return Me.toWorkingColorSpace(this,n),this}setStyle(e,t=Ce){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=Ce){const s=Zs[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=Kt(e.r),this.g=Kt(e.g),this.b=Kt(e.b),this}copyLinearToSRGB(e){return this.r=Wt(e.r),this.g=Wt(e.g),this.b=Wt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ce){return Me.fromWorkingColorSpace(ue.copy(this),e),Math.round(Xe(ue.r*255,0,255))*65536+Math.round(Xe(ue.g*255,0,255))*256+Math.round(Xe(ue.b*255,0,255))}getHexString(e=Ce){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Me.workingColorSpace){Me.fromWorkingColorSpace(ue.copy(this),t);const s=ue.r,n=ue.g,i=ue.b,o=Math.max(s,n,i),r=Math.min(s,n,i);let a,h;const p=(r+o)/2;if(r===o)a=0,h=0;else{const d=o-r;switch(h=p<=.5?d/(o+r):d/(2-o-r),o){case s:a=(n-i)/d+(n<i?6:0);break;case n:a=(i-s)/d+2;break;case i:a=(s-n)/d+4;break}a/=6}return e.h=a,e.s=h,e.l=p,e}getRGB(e,t=Me.workingColorSpace){return Me.fromWorkingColorSpace(ue.copy(this),t),e.r=ue.r,e.g=ue.g,e.b=ue.b,e}getStyle(e=Ce){Me.fromWorkingColorSpace(ue.copy(this),e);const t=ue.r,s=ue.g,n=ue.b;return e!==Ce?`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(be),be.h+=e,be.s+=t,be.l+=s,this.setHSL(be.h,be.s,be.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(be),e.getHSL(_t);const s=jt(be.h,_t.h,t),n=jt(be.s,_t.s,t),i=jt(be.l,_t.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 ue=new wt;wt.NAMES=Zs;class ir extends c.MeshStandardMaterial{constructor(t={}){super();re(this,"isMeshPhysicalMaterial");re(this,"clearcoatMap");re(this,"clearcoatRoughness");re(this,"clearcoatRoughnessMap");re(this,"clearcoatNormalScale");re(this,"clearcoatNormalMap");re(this,"ior");re(this,"transmissionMap");re(this,"thickness");re(this,"thicknessMap");re(this,"attenuationDistance");re(this,"attenuationColor");re(this,"specularIntensity");re(this,"specularIntensityMap");re(this,"specularColor");re(this,"specularColorMap");re(this,"_clearcoat");re(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Xt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Xe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(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 wt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new wt(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 or=ir,rr=u.defineComponent({__name:"index",setup(l,{expose:e}){const t=u.shallowRef(),{extend:s}=q.useTresContext();return s({MeshGlassMaterial:or}),e({MeshGlassMaterialClass:t}),(n,i)=>(u.openBlock(),u.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}}),ar=["args"],lr=["color"],cr=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,ar),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,lr)])],16))}}),hr=["args"],ur=["color"],pr=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,hr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,ur)])],16))}}),dr=["args"],mr=["color"],fr=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,dr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,mr)])],16))}}),gr=["args"],yr=["color"],_r=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,gr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,yr)])],16))}}),wr=["args"],xr=["color"],vr=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,wr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,xr)])],16))}}),Ar=["args"],Mr=["color"],br=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,Ar),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Mr)])],16))}}),Sr=["rotation"],Tr=["args"],Lr=["color"],Cr=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,Tr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Lr)])],16,Sr))}}),Or=["args"],Pr=["color"],Dr=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,Or),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Pr)])],16))}}),Ir=["args"],kr=["color"],Fr=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,Ir),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,kr)])],16))}}),Br=["rotation"],Ur=["args"],Nr=["color"],Vr=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,Ur),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Nr)])],16,Br))}}),Er=["args"],zr=["color"],Rr=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,Er),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,zr)])],16))}}),Gr=["args"],Yr=["color"],jr=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,Gr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Yr)])],16))}}),Xr=["args"],Zr=["color"],Qr=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,Xr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Zr)])],16))}}),Kr=["receive-shadow","rotation"],Wr=["args"],qr=u.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Jr=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:Math.pow(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 p=0;const d=r/r/2,m=h.attributes.position;for(let f=0;f<r+1;f++)for(let w=0;w<r+1;w++)m.setXYZ(p++,f/r-d+(f===0?-a:0),w/r-d,t(f/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,Wr),u.renderSlot(r.$slots,"default",{},()=>[qr])],8,Kr)],16))}});let Oe;const Hr=(l="body")=>{Oe||(Oe=new nn.Pane({container:document.querySelector(l)}),Oe.element.style.position="absolute",Oe.element.style.top="1rem",Oe.element.style.right="1rem",Oe.element.style.zIndex="9999");const{logWarning:e}=Ut();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(){Oe&&Oe.dispose()}return u.onMounted(()=>{const{resume:s}=q.useRenderLoop();s()}),u.onUnmounted(()=>{t()}),{pane:Oe,disposeTweakPane:t}};U.Backdrop=Jr,U.Box=cr,U.CameraControls=Qo,U.Circle=pr,U.Cone=fr,U.ContactShadows=ro,U.Dodecahedron=_r,U.Environment=Yi,U.FBXModel=To,U.GLTFModel=So,U.Icosahedron=vr,U.KeyboardControls=Fo,U.Levioso=to,U.MapControls=zo,U.MeshGlassMaterial=rr,U.MeshWobbleMaterial=qo,U.MouseParallax=Mo,U.Octahedron=br,U.OrbitControls=Po,U.Plane=Cr,U.PointerLockControls=Vo,U.Precipitation=Wi,U.Ring=Dr,U.ScrollControls=Ro,U.Smoke=eo,U.Sphere=Fr,U.Stars=Zi,U.Tetrahedron=Vr,U.Text3D=Ri,U.Torus=Rr,U.TorusKnot=jr,U.TransformControls=Uo,U.Tube=Qr,U.useAnimations=Gi,U.useEnvironment=Ls,U.useFBX=ks,U.useGLTF=Is,U.useProgress=Lo,U.useTweakPane=Hr,U.useVideoTexture=Co,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});