@tresjs/cientos 3.1.0 → 3.2.0-next.0

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.1.0
3
+ * version: v3.2.0-next.0
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(B,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("vue"),require("three"),require("@tresjs/core"),require("tweakpane"),require("@tweakpane/plugin-essentials")):typeof define=="function"&&define.amd?define(["exports","vue","three","@tresjs/core","tweakpane","@tweakpane/plugin-essentials"],h):(B=typeof globalThis<"u"?globalThis:B||self,h(B.trescientos={},B.Vue,B.Three,B.TresjsCore,B.tweakpane,B.EssentialsPlugin))})(this,function(B,h,l,q,En,Gn){"use strict";var zr=Object.defineProperty;var Rr=(B,h,l)=>h in B?zr(B,h,{enumerable:!0,configurable:!0,writable:!0,value:l}):B[h]=l;var Nt=(B,h,l)=>(Rr(B,typeof h!="symbol"?h+"":h,l),l);function jn(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>c[t]})}}return e.default=c,Object.freeze(e)}const Yn=jn(Gn);function zt(c,e){if(e===l.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),c;if(e===l.TriangleFanDrawMode||e===l.TriangleStripDrawMode){let t=c.getIndex();if(t===null){const i=[],r=c.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)i.push(a);c.setIndex(i),t=c.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),c}const n=t.count-2,s=[];if(t)if(e===l.TriangleFanDrawMode)for(let i=1;i<=n;i++)s.push(t.getX(0)),s.push(t.getX(i)),s.push(t.getX(i+1));else for(let i=0;i<n;i++)i%2===0?(s.push(t.getX(i)),s.push(t.getX(i+1)),s.push(t.getX(i+2))):(s.push(t.getX(i+2)),s.push(t.getX(i+1)),s.push(t.getX(i)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=c.clone();return o.setIndex(s),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),c}var fe=Uint8Array,Oe=Uint16Array,pt=Uint32Array,Rt=new fe([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]),Et=new fe([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]),Xn=new fe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Gt=function(c,e){for(var t=new Oe(31),n=0;n<31;++n)t[n]=e+=1<<c[n-1];for(var s=new pt(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)s[o]=o-t[n]<<5|n;return[t,s]},jt=Gt(Rt,2),Yt=jt[0],Zn=jt[1];Yt[28]=258,Zn[258]=28;for(var Qn=Gt(Et,0),Kn=Qn[0],dt=new Oe(32768),se=0;se<32768;++se){var Pe=(se&43690)>>>1|(se&21845)<<1;Pe=(Pe&52428)>>>2|(Pe&13107)<<2,Pe=(Pe&61680)>>>4|(Pe&3855)<<4,dt[se]=((Pe&65280)>>>8|(Pe&255)<<8)>>>1}for(var Ke=function(c,e,t){for(var n=c.length,s=0,o=new Oe(e);s<n;++s)++o[c[s]-1];var i=new Oe(e);for(s=0;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;var r;if(t){r=new Oe(1<<e);var a=15-e;for(s=0;s<n;++s)if(c[s])for(var u=s<<4|c[s],d=e-c[s],p=i[c[s]-1]++<<d,f=p|(1<<d)-1;p<=f;++p)r[dt[p]>>>a]=u}else for(r=new Oe(n),s=0;s<n;++s)c[s]&&(r[s]=dt[i[c[s]-1]++]>>>15-c[s]);return r},We=new fe(288),se=0;se<144;++se)We[se]=8;for(var se=144;se<256;++se)We[se]=9;for(var se=256;se<280;++se)We[se]=7;for(var se=280;se<288;++se)We[se]=8;for(var Xt=new fe(32),se=0;se<32;++se)Xt[se]=5;var Wn=Ke(We,9,1),qn=Ke(Xt,5,1),ft=function(c){for(var e=c[0],t=1;t<c.length;++t)c[t]>e&&(e=c[t]);return e},ye=function(c,e,t){var n=e/8|0;return(c[n]|c[n+1]<<8)>>(e&7)&t},mt=function(c,e){var t=e/8|0;return(c[t]|c[t+1]<<8|c[t+2]<<16)>>(e&7)},Jn=function(c){return(c/8|0)+(c&7&&1)},Hn=function(c,e,t){(e==null||e<0)&&(e=0),(t==null||t>c.length)&&(t=c.length);var n=new(c instanceof Oe?Oe:c instanceof pt?pt:fe)(t-e);return n.set(c.subarray(e,t)),n},$n=function(c,e,t){var n=c.length;if(!n||t&&!t.l&&n<5)return e||new fe(0);var s=!e||t,o=!t||t.i;t||(t={}),e||(e=new fe(n*3));var i=function(_e){var Ae=e.length;if(_e>Ae){var Fe=new fe(Math.max(Ae*2,_e));Fe.set(e),e=Fe}},r=t.f||0,a=t.p||0,u=t.b||0,d=t.l,p=t.d,f=t.m,m=t.n,y=n*8;do{if(!d){t.f=r=ye(c,a,1);var _=ye(c,a+1,3);if(a+=3,_)if(_==1)d=Wn,p=qn,f=9,m=5;else if(_==2){var M=ye(c,a,31)+257,g=ye(c,a+10,15)+4,A=M+ye(c,a+5,31)+1;a+=14;for(var b=new fe(A),w=new fe(19),v=0;v<g;++v)w[Xn[v]]=ye(c,a+v*3,7);a+=g*3;for(var C=ft(w),k=(1<<C)-1,I=Ke(w,C,1),v=0;v<A;){var U=I[ye(c,a,k)];a+=U&15;var x=U>>>4;if(x<16)b[v++]=x;else{var j=0,H=0;for(x==16?(H=3+ye(c,a,3),a+=2,j=b[v-1]):x==17?(H=3+ye(c,a,7),a+=3):x==18&&(H=11+ye(c,a,127),a+=7);H--;)b[v++]=j}}var G=b.subarray(0,M),ne=b.subarray(M);f=ft(G),m=ft(ne),d=Ke(G,f,1),p=Ke(ne,m,1)}else throw"invalid block type";else{var x=Jn(a)+4,S=c[x-4]|c[x-3]<<8,O=x+S;if(O>n){if(o)throw"unexpected EOF";break}s&&i(u+S),e.set(c.subarray(x,O),u),t.b=u+=S,t.p=a=O*8;continue}if(a>y){if(o)throw"unexpected EOF";break}}s&&i(u+131072);for(var X=(1<<f)-1,ae=(1<<m)-1,re=a;;re=a){var j=d[mt(c,a)&X],$=j>>>4;if(a+=j&15,a>y){if(o)throw"unexpected EOF";break}if(!j)throw"invalid length/literal";if($<256)e[u++]=$;else if($==256){re=a,d=null;break}else{var Q=$-254;if($>264){var v=$-257,K=Rt[v];Q=ye(c,a,(1<<K)-1)+Yt[v],a+=K}var ce=p[mt(c,a)&ae],L=ce>>>4;if(!ce)throw"invalid distance";a+=ce&15;var ne=Kn[L];if(L>3){var K=Et[L];ne+=mt(c,a)&(1<<K)-1,a+=K}if(a>y){if(o)throw"unexpected EOF";break}s&&i(u+131072);for(var de=u+Q;u<de;u+=4)e[u]=e[u-ne],e[u+1]=e[u+1-ne],e[u+2]=e[u+2-ne],e[u+3]=e[u+3-ne];u=de}}t.l=d,t.p=re,t.b=u,d&&(r=1,t.m=f,t.d=p,t.n=m)}while(!r);return u==e.length?e:Hn(e,0,u)},es=new fe(0),ts=function(c){if((c[0]&15)!=8||c[0]>>>4>7||(c[0]<<8|c[1])%31)throw"invalid zlib data";if(c[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function ns(c,e){return $n((ts(c),c.subarray(2,-4)),e)}var ss=typeof TextDecoder<"u"&&new TextDecoder,os=0;try{ss.decode(es,{stream:!0}),os=1}catch{}var is=Object.defineProperty,rs=(c,e,t)=>e in c?is(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,P=(c,e,t)=>(rs(c,typeof e!="symbol"?e+"":e,t),t);class as extends l.Object3D{constructor(e,t){super(),P(this,"isTransformControls",!0),P(this,"visible",!1),P(this,"domElement"),P(this,"raycaster",new l.Raycaster),P(this,"gizmo"),P(this,"plane"),P(this,"tempVector",new l.Vector3),P(this,"tempVector2",new l.Vector3),P(this,"tempQuaternion",new l.Quaternion),P(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),P(this,"pointStart",new l.Vector3),P(this,"pointEnd",new l.Vector3),P(this,"offset",new l.Vector3),P(this,"rotationAxis",new l.Vector3),P(this,"startNorm",new l.Vector3),P(this,"endNorm",new l.Vector3),P(this,"rotationAngle",0),P(this,"cameraPosition",new l.Vector3),P(this,"cameraQuaternion",new l.Quaternion),P(this,"cameraScale",new l.Vector3),P(this,"parentPosition",new l.Vector3),P(this,"parentQuaternion",new l.Quaternion),P(this,"parentQuaternionInv",new l.Quaternion),P(this,"parentScale",new l.Vector3),P(this,"worldPositionStart",new l.Vector3),P(this,"worldQuaternionStart",new l.Quaternion),P(this,"worldScaleStart",new l.Vector3),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"worldQuaternionInv",new l.Quaternion),P(this,"worldScale",new l.Vector3),P(this,"eye",new l.Vector3),P(this,"positionStart",new l.Vector3),P(this,"quaternionStart",new l.Quaternion),P(this,"scaleStart",new l.Vector3),P(this,"camera"),P(this,"object"),P(this,"enabled",!0),P(this,"axis",null),P(this,"mode","translate"),P(this,"translationSnap",null),P(this,"rotationSnap",null),P(this,"scaleSnap",null),P(this,"space","world"),P(this,"size",1),P(this,"dragging",!1),P(this,"showX",!0),P(this,"showY",!0),P(this,"showZ",!0),P(this,"changeEvent",{type:"change"}),P(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),P(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),P(this,"objectChangeEvent",{type:"objectChange"}),P(this,"intersectObjectWithRay",(s,o,i)=>{const r=o.intersectObject(s,!0);for(let a=0;a<r.length;a++)if(r[a].object.visible||i)return r[a];return!1}),P(this,"attach",s=>(this.object=s,this.visible=!0,this)),P(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),P(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),P(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()}),P(this,"pointerHover",s=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(s,this.camera);const o=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);o?this.axis=o.object.name:this.axis=null}),P(this,"pointerDown",s=>{if(!(this.object===void 0||this.dragging===!0||s.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(s,this.camera);const o=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(o){let i=this.space;if(this.mode==="scale"?i="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(i="world"),i==="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(o.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),P(this,"pointerMove",s=>{const o=this.axis,i=this.mode,r=this.object;let a=this.space;if(i==="scale"?a="local":(o==="E"||o==="XYZE"||o==="XYZ")&&(a="world"),r===void 0||o===null||this.dragging===!1||s.button!==-1)return;this.raycaster.setFromCamera(s,this.camera);const u=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(u){if(this.pointEnd.copy(u.point).sub(this.worldPositionStart),i==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&o!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),o.indexOf("X")===-1&&(this.offset.x=0),o.indexOf("Y")===-1&&(this.offset.y=0),o.indexOf("Z")===-1&&(this.offset.z=0),a==="local"&&o!=="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()),o.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),o.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),o.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)),o.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),o.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),o.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(i==="scale"){if(o.search("XYZ")!==-1){let d=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(d*=-1),this.tempVector2.set(d,d,d)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),o.search("X")===-1&&(this.tempVector2.x=1),o.search("Y")===-1&&(this.tempVector2.y=1),o.search("Z")===-1&&(this.tempVector2.z=1);r.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(o.search("X")!==-1&&(this.object.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),o.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),o.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const d=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));o==="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):o==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*d):(o==="X"||o==="Y"||o==="Z")&&(this.rotationAxis.copy(this.unit[o]),this.tempVector.copy(this.unit[o]),a==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*d),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&o!=="E"&&o!=="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)}}),P(this,"pointerUp",s=>{s.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),P(this,"getPointer",s=>{var o,i;if(this.domElement&&((o=this.domElement.ownerDocument)!=null&&o.pointerLockElement))return{x:0,y:0,button:s.button};{const r=s.changedTouches?s.changedTouches[0]:s,a=(i=this.domElement)==null?void 0:i.getBoundingClientRect();return{x:(r.clientX-a.left)/a.width*2-1,y:-(r.clientY-a.top)/a.height*2+1,button:s.button}}}),P(this,"onPointerHover",s=>{if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(s));break}}),P(this,"onPointerDown",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(s)),this.pointerDown(this.getPointer(s)))}),P(this,"onPointerMove",s=>{this.enabled&&this.pointerMove(this.getPointer(s))}),P(this,"onPointerUp",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(s)))}),P(this,"getMode",()=>this.mode),P(this,"setMode",s=>{this.mode=s}),P(this,"setTranslationSnap",s=>{this.translationSnap=s}),P(this,"setRotationSnap",s=>{this.rotationSnap=s}),P(this,"setScaleSnap",s=>{this.scaleSnap=s}),P(this,"setSize",s=>{this.size=s}),P(this,"setSpace",s=>{this.space=s}),P(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),P(this,"connect",s=>{s===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=s,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),P(this,"dispose",()=>{var s,o,i,r,a,u;(s=this.domElement)==null||s.removeEventListener("pointerdown",this.onPointerDown),(o=this.domElement)==null||o.removeEventListener("pointermove",this.onPointerHover),(r=(i=this.domElement)==null?void 0:i.ownerDocument)==null||r.removeEventListener("pointermove",this.onPointerMove),(u=(a=this.domElement)==null?void 0:a.ownerDocument)==null||u.removeEventListener("pointerup",this.onPointerUp),this.traverse(d=>{const p=d;p.geometry&&p.geometry.dispose(),p.material&&p.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new ls,this.add(this.gizmo),this.plane=new cs,this.add(this.plane);const n=(s,o)=>{let i=o;Object.defineProperty(this,s,{get:function(){return i!==void 0?i:o},set:function(r){i!==r&&(i=r,this.plane[s]=r,this.gizmo[s]=r,this.dispatchEvent({type:s+"-changed",value:r}),this.dispatchEvent(this.changeEvent))}}),this[s]=o,this.plane[s]=o,this.gizmo[s]=o};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class ls extends l.Object3D{constructor(){super(),P(this,"isTransformControlsGizmo",!0),P(this,"type","TransformControlsGizmo"),P(this,"tempVector",new l.Vector3(0,0,0)),P(this,"tempEuler",new l.Euler),P(this,"alignVector",new l.Vector3(0,1,0)),P(this,"zeroVector",new l.Vector3(0,0,0)),P(this,"lookAtMatrix",new l.Matrix4),P(this,"tempQuaternion",new l.Quaternion),P(this,"tempQuaternion2",new l.Quaternion),P(this,"identityQuaternion",new l.Quaternion),P(this,"unitX",new l.Vector3(1,0,0)),P(this,"unitY",new l.Vector3(0,1,0)),P(this,"unitZ",new l.Vector3(0,0,1)),P(this,"gizmo"),P(this,"picker"),P(this,"helper"),P(this,"rotationAxis",new l.Vector3),P(this,"cameraPosition",new l.Vector3),P(this,"worldPositionStart",new l.Vector3),P(this,"worldQuaternionStart",new l.Quaternion),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"eye",new l.Vector3),P(this,"camera",null),P(this,"enabled",!0),P(this,"axis",null),P(this,"mode","translate"),P(this,"space","world"),P(this,"size",1),P(this,"dragging",!1),P(this,"showX",!0),P(this,"showY",!0),P(this,"showZ",!0),P(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 ce=0;ce<K.length;ce++){const L=K[ce];L.visible=!0,L.rotation.set(0,0,0),L.position.copy(this.worldPosition);let de;if(this.camera.isOrthographicCamera?de=(this.camera.top-this.camera.bottom)/this.camera.zoom:de=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),L.scale.set(1,1,1).multiplyScalar(de*this.size/7),L.tag==="helper"){L.visible=!1,L.name==="AXIS"?(L.position.copy(this.worldPositionStart),L.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),L.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),L.quaternion.multiply(this.tempQuaternion),L.visible=this.dragging),this.axis==="E"&&(L.visible=!1)):L.name==="START"?(L.position.copy(this.worldPositionStart),L.visible=this.dragging):L.name==="END"?(L.position.copy(this.worldPosition),L.visible=this.dragging):L.name==="DELTA"?(L.position.copy(this.worldPositionStart),L.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()),L.scale.copy(this.tempVector),L.visible=this.dragging):(L.quaternion.copy(Q),this.dragging?L.position.copy(this.worldPositionStart):L.position.copy(this.worldPosition),this.axis&&(L.visible=this.axis.search(L.name)!==-1));continue}L.quaternion.copy(Q),this.mode==="translate"||this.mode==="scale"?((L.name==="X"||L.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),(L.name==="Y"||L.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),(L.name==="Z"||L.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.x*=-1:L.tag==="bwd"&&(L.visible=!1)),L.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.y*=-1:L.tag==="bwd"&&(L.visible=!1)),L.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.z*=-1:L.tag==="bwd"&&(L.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(Q),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(Q).invert()),L.name.search("E")!==-1&&L.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),L.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion)),L.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion)),L.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion))),L.visible=L.visible&&(L.name.indexOf("X")===-1||this.showX),L.visible=L.visible&&(L.name.indexOf("Y")===-1||this.showY),L.visible=L.visible&&(L.name.indexOf("Z")===-1||this.showZ),L.visible=L.visible&&(L.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),L.material.tempOpacity=L.material.tempOpacity||L.material.opacity,L.material.tempColor=L.material.tempColor||L.material.color.clone(),L.material.color.copy(L.material.tempColor),L.material.opacity=L.material.tempOpacity,this.enabled?this.axis&&(L.name===this.axis?(L.material.opacity=1,L.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(_e){return L.name===_e})?(L.material.opacity=1,L.material.color.lerp(new l.Color(1,1,1),.5)):(L.material.opacity*=.25,L.material.color.lerp(new l.Color(1,1,1),.5))):(L.material.opacity*=.5,L.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const s=e.clone();s.opacity=.33;const o=e.clone();o.color.set(16711680);const i=e.clone();i.color.set(65280);const r=e.clone();r.color.set(255);const a=e.clone();a.opacity=.25;const u=a.clone();u.color.set(16776960);const d=a.clone();d.color.set(65535);const p=a.clone();p.color.set(16711935),e.clone().color.set(16776960);const m=t.clone();m.color.set(16711680);const y=t.clone();y.color.set(65280);const _=t.clone();_.color.set(255);const x=t.clone();x.color.set(65535);const S=t.clone();S.color.set(16711935);const O=t.clone();O.color.set(16776960);const M=t.clone();M.color.set(7895160);const g=O.clone();g.opacity=.25;const A=new l.CylinderGeometry(0,.05,.2,12,1,!1),b=new l.BoxGeometry(.125,.125,.125),w=new l.BufferGeometry;w.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const v=($,Q)=>{const K=new l.BufferGeometry,ce=[];for(let L=0;L<=64*Q;++L)ce.push(0,Math.cos(L/32*Math.PI)*$,Math.sin(L/32*Math.PI)*$);return K.setAttribute("position",new l.Float32BufferAttribute(ce,3)),K},C=()=>{const $=new l.BufferGeometry;return $.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),$},k={X:[[new l.Mesh(A,o),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(A,o),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(w,m)]],Y:[[new l.Mesh(A,i),[0,1,0],null,null,"fwd"],[new l.Mesh(A,i),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(w,y),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(A,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(A,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(w,_),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),a.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),u.clone()),[.15,.15,0]],[new l.Line(w,O),[.18,.3,0],null,[.125,1,1]],[new l.Line(w,O),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),d.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(w,x),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(w,x),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),p.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(w,S),[.18,0,.3],null,[.125,1,1]],[new l.Line(w,S),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},U={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new l.Line(C(),s),null,null,null,"helper"]],X:[[new l.Line(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(w,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(w,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},j={X:[[new l.Line(v(1,.5),m)],[new l.Mesh(new l.OctahedronGeometry(.04,0),o),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(v(1,.5),y),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(v(1,.5),_),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),r),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(v(1.25,1),g),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(v(1,1),M),null,[0,Math.PI/2,0]]]},H={AXIS:[[new l.Line(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},G={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},ne={X:[[new l.Mesh(b,o),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(w,m),null,null,[.8,1,1]]],Y:[[new l.Mesh(b,i),[0,.8,0]],[new l.Line(w,y),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(b,r),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(w,_),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(b,u),[.85,.85,0],null,[2,2,.2]],[new l.Line(w,O),[.855,.98,0],null,[.125,1,1]],[new l.Line(w,O),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(b,d),[0,.85,.85],null,[.2,2,2]],[new l.Line(w,x),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(w,x),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(b,p),[.85,0,.85],null,[2,.2,2]],[new l.Line(w,S),[.855,0,.98],null,[.125,1,1]],[new l.Line(w,S),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[0,0,1.1]]]},X={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(b,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(b,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(b,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},ae={X:[[new l.Line(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(w,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(w,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},re=$=>{const Q=new l.Object3D;for(let K in $)for(let ce=$[K].length;ce--;){const L=$[K][ce][0].clone(),de=$[K][ce][1],_e=$[K][ce][2],Ae=$[K][ce][3],Fe=$[K][ce][4];L.name=K,L.tag=Fe,de&&L.position.set(de[0],de[1],de[2]),_e&&L.rotation.set(_e[0],_e[1],_e[2]),Ae&&L.scale.set(Ae[0],Ae[1],Ae[2]),L.updateMatrix();const st=L.geometry.clone();st.applyMatrix4(L.matrix),L.geometry=st,L.renderOrder=1/0,L.position.set(0,0,0),L.rotation.set(0,0,0),L.scale.set(1,1,1),Q.add(L)}return Q};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=re(k)),this.add(this.gizmo.rotate=re(j)),this.add(this.gizmo.scale=re(ne)),this.add(this.picker.translate=re(I)),this.add(this.picker.rotate=re(G)),this.add(this.picker.scale=re(X)),this.add(this.helper.translate=re(U)),this.add(this.helper.rotate=re(H)),this.add(this.helper.scale=re(ae)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class cs extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),P(this,"isTransformControlsPlane",!0),P(this,"type","TransformControlsPlane"),P(this,"unitX",new l.Vector3(1,0,0)),P(this,"unitY",new l.Vector3(0,1,0)),P(this,"unitZ",new l.Vector3(0,0,1)),P(this,"tempVector",new l.Vector3),P(this,"dirVector",new l.Vector3),P(this,"alignVector",new l.Vector3),P(this,"tempMatrix",new l.Matrix4),P(this,"identityQuaternion",new l.Quaternion),P(this,"cameraQuaternion",new l.Quaternion),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"eye",new l.Vector3),P(this,"axis",null),P(this,"mode","translate"),P(this,"space","world"),P(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 hs=Object.defineProperty,us=(c,e,t)=>e in c?hs(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,le=(c,e,t)=>(us(c,typeof e!="symbol"?e+"":e,t),t);const ze=new l.Euler(0,0,0,"YXZ"),Re=new l.Vector3,ps={type:"change"},ds={type:"lock"},fs={type:"unlock"},Zt=Math.PI/2;class gt extends l.EventDispatcher{constructor(e,t){super(),le(this,"camera"),le(this,"domElement"),le(this,"isLocked"),le(this,"minPolarAngle"),le(this,"maxPolarAngle"),le(this,"pointerSpeed"),le(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const s=n.movementX||n.mozMovementX||n.webkitMovementX||0,o=n.movementY||n.mozMovementY||n.webkitMovementY||0;ze.setFromQuaternion(this.camera.quaternion),ze.y-=s*.002*this.pointerSpeed,ze.x-=o*.002*this.pointerSpeed,ze.x=Math.max(Zt-this.maxPolarAngle,Math.min(Zt-this.minPolarAngle,ze.x)),this.camera.quaternion.setFromEuler(ze),this.dispatchEvent(ps)}),le(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(ds),this.isLocked=!0):(this.dispatchEvent(fs),this.isLocked=!1))}),le(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),le(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),le(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))}),le(this,"dispose",()=>{this.disconnect()}),le(this,"getObject",()=>this.camera),le(this,"direction",new l.Vector3(0,0,-1)),le(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),le(this,"moveForward",n=>{Re.setFromMatrixColumn(this.camera.matrix,0),Re.crossVectors(this.camera.up,Re),this.camera.position.addScaledVector(Re,n)}),le(this,"moveRight",n=>{Re.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(Re,n)}),le(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),le(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 ms=Object.defineProperty,gs=(c,e,t)=>e in c?ms(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,z=(c,e,t)=>(gs(c,typeof e!="symbol"?e+"":e,t),t);const Qt=(c,e)=>(c%e+e)%e;class Kt extends l.EventDispatcher{constructor(e,t){super(),z(this,"object"),z(this,"domElement"),z(this,"enabled",!0),z(this,"target",new l.Vector3),z(this,"minDistance",0),z(this,"maxDistance",1/0),z(this,"minZoom",0),z(this,"maxZoom",1/0),z(this,"minPolarAngle",0),z(this,"maxPolarAngle",Math.PI),z(this,"minAzimuthAngle",-1/0),z(this,"maxAzimuthAngle",1/0),z(this,"enableDamping",!1),z(this,"dampingFactor",.05),z(this,"enableZoom",!0),z(this,"zoomSpeed",1),z(this,"enableRotate",!0),z(this,"rotateSpeed",1),z(this,"enablePan",!0),z(this,"panSpeed",1),z(this,"screenSpacePanning",!0),z(this,"keyPanSpeed",7),z(this,"autoRotate",!1),z(this,"autoRotateSpeed",2),z(this,"reverseOrbit",!1),z(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),z(this,"mouseButtons",{LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),z(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN}),z(this,"target0"),z(this,"position0"),z(this,"zoom0"),z(this,"_domElementKeyEvents",null),z(this,"getPolarAngle"),z(this,"getAzimuthalAngle"),z(this,"setPolarAngle"),z(this,"setAzimuthalAngle"),z(this,"getDistance"),z(this,"listenToKeyEvents"),z(this,"saveState"),z(this,"reset"),z(this,"update"),z(this,"connect"),z(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>d.phi,this.getAzimuthalAngle=()=>d.theta,this.setPolarAngle=T=>{let F=Qt(T,2*Math.PI),E=d.phi;E<0&&(E+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-E);2*Math.PI-ee<ee&&(F<E?F+=2*Math.PI:E+=2*Math.PI),p.phi=F-E,n.update()},this.setAzimuthalAngle=T=>{let F=Qt(T,2*Math.PI),E=d.theta;E<0&&(E+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-E);2*Math.PI-ee<ee&&(F<E?F+=2*Math.PI:E+=2*Math.PI),p.theta=F-E,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=T=>{T.addEventListener("keydown",Bn),this._domElementKeyEvents=T},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(s),n.update(),a=r.NONE},this.update=(()=>{const T=new l.Vector3,F=new l.Quaternion().setFromUnitVectors(e.up,new l.Vector3(0,1,0)),E=F.clone().invert(),ee=new l.Vector3,he=new l.Quaternion,Te=2*Math.PI;return function(){const Rn=n.object.position;T.copy(Rn).sub(n.target),T.applyQuaternion(F),d.setFromVector3(T),n.autoRotate&&a===r.NONE&&U(k()),n.enableDamping?(d.theta+=p.theta*n.dampingFactor,d.phi+=p.phi*n.dampingFactor):(d.theta+=p.theta,d.phi+=p.phi);let Se=n.minAzimuthAngle,Le=n.maxAzimuthAngle;return isFinite(Se)&&isFinite(Le)&&(Se<-Math.PI?Se+=Te:Se>Math.PI&&(Se-=Te),Le<-Math.PI?Le+=Te:Le>Math.PI&&(Le-=Te),Se<=Le?d.theta=Math.max(Se,Math.min(Le,d.theta)):d.theta=d.theta>(Se+Le)/2?Math.max(Se,d.theta):Math.min(Le,d.theta)),d.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,d.phi)),d.makeSafe(),d.radius*=f,d.radius=Math.max(n.minDistance,Math.min(n.maxDistance,d.radius)),n.enableDamping===!0?n.target.addScaledVector(m,n.dampingFactor):n.target.add(m),T.setFromSpherical(d),T.applyQuaternion(E),Rn.copy(n.target).add(T),n.object.lookAt(n.target),n.enableDamping===!0?(p.theta*=1-n.dampingFactor,p.phi*=1-n.dampingFactor,m.multiplyScalar(1-n.dampingFactor)):(p.set(0,0,0),m.set(0,0,0)),f=1,y||ee.distanceToSquared(n.object.position)>u||8*(1-he.dot(n.object.quaternion))>u?(n.dispatchEvent(s),ee.copy(n.object.position),he.copy(n.object.quaternion),y=!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.'),n.domElement=T,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Vn),n.domElement.addEventListener("pointerdown",kn),n.domElement.addEventListener("pointercancel",Fn),n.domElement.addEventListener("wheel",Un)},this.dispose=()=>{var T,F,E,ee,he,Te;(T=n.domElement)==null||T.removeEventListener("contextmenu",Vn),(F=n.domElement)==null||F.removeEventListener("pointerdown",kn),(E=n.domElement)==null||E.removeEventListener("pointercancel",Fn),(ee=n.domElement)==null||ee.removeEventListener("wheel",Un),(he=n.domElement)==null||he.ownerDocument.removeEventListener("pointermove",Ut),(Te=n.domElement)==null||Te.ownerDocument.removeEventListener("pointerup",Bt),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Bn)};const n=this,s={type:"change"},o={type:"start"},i={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 u=1e-6,d=new l.Spherical,p=new l.Spherical;let f=1;const m=new l.Vector3;let y=!1;const _=new l.Vector2,x=new l.Vector2,S=new l.Vector2,O=new l.Vector2,M=new l.Vector2,g=new l.Vector2,A=new l.Vector2,b=new l.Vector2,w=new l.Vector2,v=[],C={};function k(){return 2*Math.PI/60/60*n.autoRotateSpeed}function I(){return Math.pow(.95,n.zoomSpeed)}function U(T){n.reverseOrbit?p.theta+=T:p.theta-=T}function j(T){n.reverseOrbit?p.phi+=T:p.phi-=T}const H=(()=>{const T=new l.Vector3;return function(E,ee){T.setFromMatrixColumn(ee,0),T.multiplyScalar(-E),m.add(T)}})(),G=(()=>{const T=new l.Vector3;return function(E,ee){n.screenSpacePanning===!0?T.setFromMatrixColumn(ee,1):(T.setFromMatrixColumn(ee,0),T.crossVectors(n.object.up,T)),T.multiplyScalar(E),m.add(T)}})(),ne=(()=>{const T=new l.Vector3;return function(E,ee){const he=n.domElement;if(he&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const Te=n.object.position;T.copy(Te).sub(n.target);let ut=T.length();ut*=Math.tan(n.object.fov/2*Math.PI/180),H(2*E*ut/he.clientHeight,n.object.matrix),G(2*ee*ut/he.clientHeight,n.object.matrix)}else he&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(H(E*(n.object.right-n.object.left)/n.object.zoom/he.clientWidth,n.object.matrix),G(ee*(n.object.top-n.object.bottom)/n.object.zoom/he.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function X(T){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera?f/=T:n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*T)),n.object.updateProjectionMatrix(),y=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ae(T){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera?f*=T:n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/T)),n.object.updateProjectionMatrix(),y=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function re(T){_.set(T.clientX,T.clientY)}function $(T){A.set(T.clientX,T.clientY)}function Q(T){O.set(T.clientX,T.clientY)}function K(T){x.set(T.clientX,T.clientY),S.subVectors(x,_).multiplyScalar(n.rotateSpeed);const F=n.domElement;F&&(U(2*Math.PI*S.x/F.clientHeight),j(2*Math.PI*S.y/F.clientHeight)),_.copy(x),n.update()}function ce(T){b.set(T.clientX,T.clientY),w.subVectors(b,A),w.y>0?X(I()):w.y<0&&ae(I()),A.copy(b),n.update()}function L(T){M.set(T.clientX,T.clientY),g.subVectors(M,O).multiplyScalar(n.panSpeed),ne(g.x,g.y),O.copy(M),n.update()}function de(T){T.deltaY<0?ae(I()):T.deltaY>0&&X(I()),n.update()}function _e(T){let F=!1;switch(T.code){case n.keys.UP:ne(0,n.keyPanSpeed),F=!0;break;case n.keys.BOTTOM:ne(0,-n.keyPanSpeed),F=!0;break;case n.keys.LEFT:ne(n.keyPanSpeed,0),F=!0;break;case n.keys.RIGHT:ne(-n.keyPanSpeed,0),F=!0;break}F&&(T.preventDefault(),n.update())}function Ae(){if(v.length==1)_.set(v[0].pageX,v[0].pageY);else{const T=.5*(v[0].pageX+v[1].pageX),F=.5*(v[0].pageY+v[1].pageY);_.set(T,F)}}function Fe(){if(v.length==1)O.set(v[0].pageX,v[0].pageY);else{const T=.5*(v[0].pageX+v[1].pageX),F=.5*(v[0].pageY+v[1].pageY);O.set(T,F)}}function st(){const T=v[0].pageX-v[1].pageX,F=v[0].pageY-v[1].pageY,E=Math.sqrt(T*T+F*F);A.set(0,E)}function Cr(){n.enableZoom&&st(),n.enablePan&&Fe()}function Dr(){n.enableZoom&&st(),n.enableRotate&&Ae()}function Cn(T){if(v.length==1)x.set(T.pageX,T.pageY);else{const E=Vt(T),ee=.5*(T.pageX+E.x),he=.5*(T.pageY+E.y);x.set(ee,he)}S.subVectors(x,_).multiplyScalar(n.rotateSpeed);const F=n.domElement;F&&(U(2*Math.PI*S.x/F.clientHeight),j(2*Math.PI*S.y/F.clientHeight)),_.copy(x)}function Dn(T){if(v.length==1)M.set(T.pageX,T.pageY);else{const F=Vt(T),E=.5*(T.pageX+F.x),ee=.5*(T.pageY+F.y);M.set(E,ee)}g.subVectors(M,O).multiplyScalar(n.panSpeed),ne(g.x,g.y),O.copy(M)}function In(T){const F=Vt(T),E=T.pageX-F.x,ee=T.pageY-F.y,he=Math.sqrt(E*E+ee*ee);b.set(0,he),w.set(0,Math.pow(b.y/A.y,n.zoomSpeed)),X(w.y),A.copy(b)}function Ir(T){n.enableZoom&&In(T),n.enablePan&&Dn(T)}function kr(T){n.enableZoom&&In(T),n.enableRotate&&Cn(T)}function kn(T){var F,E;n.enabled!==!1&&(v.length===0&&((F=n.domElement)==null||F.ownerDocument.addEventListener("pointermove",Ut),(E=n.domElement)==null||E.ownerDocument.addEventListener("pointerup",Bt)),Nr(T),T.pointerType==="touch"?Br(T):Fr(T))}function Ut(T){n.enabled!==!1&&(T.pointerType==="touch"?Vr(T):Ur(T))}function Bt(T){var F,E,ee;Nn(T),v.length===0&&((F=n.domElement)==null||F.releasePointerCapture(T.pointerId),(E=n.domElement)==null||E.ownerDocument.removeEventListener("pointermove",Ut),(ee=n.domElement)==null||ee.ownerDocument.removeEventListener("pointerup",Bt)),n.dispatchEvent(i),a=r.NONE}function Fn(T){Nn(T)}function Fr(T){let F;switch(T.button){case 0:F=n.mouseButtons.LEFT;break;case 1:F=n.mouseButtons.MIDDLE;break;case 2:F=n.mouseButtons.RIGHT;break;default:F=-1}switch(F){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;$(T),a=r.DOLLY;break;case l.MOUSE.ROTATE:if(T.ctrlKey||T.metaKey||T.shiftKey){if(n.enablePan===!1)return;Q(T),a=r.PAN}else{if(n.enableRotate===!1)return;re(T),a=r.ROTATE}break;case l.MOUSE.PAN:if(T.ctrlKey||T.metaKey||T.shiftKey){if(n.enableRotate===!1)return;re(T),a=r.ROTATE}else{if(n.enablePan===!1)return;Q(T),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&n.dispatchEvent(o)}function Ur(T){if(n.enabled!==!1)switch(a){case r.ROTATE:if(n.enableRotate===!1)return;K(T);break;case r.DOLLY:if(n.enableZoom===!1)return;ce(T);break;case r.PAN:if(n.enablePan===!1)return;L(T);break}}function Un(T){n.enabled===!1||n.enableZoom===!1||a!==r.NONE&&a!==r.ROTATE||(T.preventDefault(),n.dispatchEvent(o),de(T),n.dispatchEvent(i))}function Bn(T){n.enabled===!1||n.enablePan===!1||_e(T)}function Br(T){switch(zn(T),v.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;Ae(),a=r.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;Fe(),a=r.TOUCH_PAN;break;default:a=r.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Cr(),a=r.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Dr(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&n.dispatchEvent(o)}function Vr(T){switch(zn(T),a){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;Cn(T),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;Dn(T),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ir(T),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;kr(T),n.update();break;default:a=r.NONE}}function Vn(T){n.enabled!==!1&&T.preventDefault()}function Nr(T){v.push(T)}function Nn(T){delete C[T.pointerId];for(let F=0;F<v.length;F++)if(v[F].pointerId==T.pointerId){v.splice(F,1);return}}function zn(T){let F=C[T.pointerId];F===void 0&&(F=new l.Vector2,C[T.pointerId]=F),F.set(T.pageX,T.pageY)}function Vt(T){const F=T.pointerId===v[0].pointerId?v[1]:v[0];return C[F.pointerId]}t!==void 0&&this.connect(t),this.update()}}class _s extends Kt{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}class ys extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ms(t)}),this.register(function(t){return new Ds(t)}),this.register(function(t){return new Is(t)}),this.register(function(t){return new ks(t)}),this.register(function(t){return new Ts(t)}),this.register(function(t){return new Ss(t)}),this.register(function(t){return new Ls(t)}),this.register(function(t){return new Os(t)}),this.register(function(t){return new xs(t)}),this.register(function(t){return new Ps(t)}),this.register(function(t){return new bs(t)}),this.register(function(t){return new Cs(t)}),this.register(function(t){return new vs(t)}),this.register(function(t){return new Fs(t)}),this.register(function(t){return new Us(t)})}load(e,t,n,s){const o=this;let i;this.resourcePath!==""?i=this.resourcePath:this.path!==""?i=this.path:i=l.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const r=function(u){s?s(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},a=new l.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(u){try{o.parse(u,i,function(d){t(d),o.manager.itemEnd(e)},r)}catch(d){r(d)}},n,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let o;const i={},r={};if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===Wt){try{i[Z.KHR_BINARY_GLTF]=new Bs(e)}catch(d){s&&s(d);return}o=JSON.parse(i[Z.KHR_BINARY_GLTF].content)}else o=JSON.parse(l.LoaderUtils.decodeText(new Uint8Array(e)));else o=e;if(o.asset===void 0||o.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const a=new Ws(o,{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 u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](a);r[d.name]=d,i[d.name]=!0}if(o.extensionsUsed)for(let u=0;u<o.extensionsUsed.length;++u){const d=o.extensionsUsed[u],p=o.extensionsRequired||[];switch(d){case Z.KHR_MATERIALS_UNLIT:i[d]=new As;break;case Z.KHR_DRACO_MESH_COMPRESSION:i[d]=new Vs(o,this.dracoLoader);break;case Z.KHR_TEXTURE_TRANSFORM:i[d]=new Ns;break;case Z.KHR_MESH_QUANTIZATION:i[d]=new zs;break;default:p.indexOf(d)>=0&&r[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}a.setExtensions(i),a.setPlugins(r),a.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,o){n.parse(e,t,s,o)})}}function ws(){let c={};return{get:function(e){return c[e]},add:function(e,t){c[e]=t},remove:function(e){delete c[e]},removeAll:function(){c={}}}}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 vs{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 n=0,s=t.length;n<s;n++){const o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const o=t.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const d=new l.Color(16777215);a.color!==void 0&&d.fromArray(a.color);const p=a.range!==void 0?a.range:0;switch(a.type){case"directional":u=new l.DirectionalLight(d),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new l.PointLight(d),u.distance=p;break;case"spot":u=new l.SpotLight(d),u.distance=p,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,u.angle=a.spot.outerConeAngle,u.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return u.position.set(0,0,0),u.decay=2,De(u,a),a.intensity!==void 0&&(u.intensity=a.intensity),u.name=t.createUniqueName(a.name||"light_"+e),s=Promise.resolve(u),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],r=(o.extensions&&o.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return n._getNodeRef(t.cache,r,a)})}}class As{constructor(){this.name=Z.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new l.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const i=o.baseColorFactor;e.color.fromArray(i),e.opacity=i[3]}o.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",o.baseColorTexture,3001))}return Promise.all(s)}}class xs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class Ms{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const r=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(r,r)}return Promise.all(o)}}class bs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(o)}}class Ts{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=s.extensions[this.name];return i.sheenColorFactor!==void 0&&t.sheenColor.fromArray(i.sheenColorFactor),i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,3001)),i.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(o)}}class Ss{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(o)}}class Ls{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const r=i.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color(r[0],r[1],r[2]),Promise.all(o)}}class Os{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class Ps{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const r=i.specularColorFactor||[1,1,1];return t.specularColor=new l.Color(r[0],r[1],r[2]),i.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,3001)),Promise.all(o)}}class Cs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(o)}}class Ds{constructor(e){this.parser=e,this.name=Z.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const o=s.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,i)}}class Is{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],r=s.images[i.source];let a=n.textureLoader;if(r.uri){const u=n.options.manager.getHandler(r.uri);u!==null&&(a=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ks{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],r=s.images[i.source];let a=n.textureLoader;if(r.uri){const u=n.options.manager.getHandler(r.uri);u!==null&&(a=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Fs{constructor(e){this.name=Z.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],o=this.parser.getDependency("buffer",s.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(r){const a=s.byteOffset||0,u=s.byteLength||0,d=s.count,p=s.byteStride,f=new Uint8Array(r,a,u);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(d,p,f,s.mode,s.filter).then(function(m){return m.buffer}):i.ready.then(function(){const m=new ArrayBuffer(d*p);return i.decodeGltfBuffer(new Uint8Array(m),d,p,f,s.mode,s.filter),m})})}else return null}}class Us{constructor(e){this.name=Z.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const u of s.primitives)if(u.mode!==me.TRIANGLES&&u.mode!==me.TRIANGLE_STRIP&&u.mode!==me.TRIANGLE_FAN&&u.mode!==void 0)return null;const i=n.extensions[this.name].attributes,r=[],a={};for(const u in i)r.push(this.parser.getDependency("accessor",i[u]).then(d=>(a[u]=d,a[u])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(u=>{const d=u.pop(),p=d.isGroup?d.children:[d],f=u[0].count,m=[];for(const y of p){const _=new l.Matrix4,x=new l.Vector3,S=new l.Quaternion,O=new l.Vector3(1,1,1),M=new l.InstancedMesh(y.geometry,y.material,f);for(let g=0;g<f;g++)a.TRANSLATION&&x.fromBufferAttribute(a.TRANSLATION,g),a.ROTATION&&S.fromBufferAttribute(a.ROTATION,g),a.SCALE&&O.fromBufferAttribute(a.SCALE,g),M.setMatrixAt(g,_.compose(x,S,O));for(const g in a)g!=="TRANSLATION"&&g!=="ROTATION"&&g!=="SCALE"&&y.geometry.setAttribute(g,a[g]);l.Object3D.prototype.copy.call(M,y),this.parser.assignFinalMaterial(M),m.push(M)}return d.isGroup?(d.clear(),d.add(...m),d):m[0]}))}}const Wt="glTF",qe=12,qt={JSON:1313821514,BIN:5130562};class Bs{constructor(e){this.name=Z.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,qe);if(this.header={magic:l.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Wt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-qe,s=new DataView(e,qe);let o=0;for(;o<n;){const i=s.getUint32(o,!0);o+=4;const r=s.getUint32(o,!0);if(o+=4,r===qt.JSON){const a=new Uint8Array(e,qe+o,i);this.content=l.LoaderUtils.decodeText(a)}else if(r===qt.BIN){const a=qe+o;this.body=e.slice(a,a+i)}o+=i}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Vs{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 n=this.json,s=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,r={},a={},u={};for(const d in i){const p=yt[d]||d.toLowerCase();r[p]=i[d]}for(const d in e.attributes){const p=yt[d]||d.toLowerCase();if(i[d]!==void 0){const f=n.accessors[e.attributes[d]],m=Ee[f.componentType];u[p]=m.name,a[p]=f.normalized===!0}}return t.getDependency("bufferView",o).then(function(d){return new Promise(function(p){s.decodeDracoFile(d,function(f){for(const m in f.attributes){const y=f.attributes[m],_=a[m];_!==void 0&&(y.normalized=_)}p(f)},r,u)})})}}class Ns{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 zs{constructor(){this.name=Z.KHR_MESH_QUANTIZATION}}class Jt extends l.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,o=e*s*3+s;for(let i=0;i!==s;i++)t[i]=n[o+i];return t}interpolate_(e,t,n,s){const o=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=r*2,u=r*3,d=s-t,p=(n-t)/d,f=p*p,m=f*p,y=e*u,_=y-u,x=-2*m+3*f,S=m-f,O=1-x,M=S-f+p;for(let g=0;g!==r;g++){const A=i[_+g+r],b=i[_+g+a]*d,w=i[y+g+r],v=i[y+g]*d;o[g]=O*A+M*b+x*w+S*v}return o}}const Rs=new l.Quaternion;class Es extends Jt{interpolate_(e,t,n,s){const o=super.interpolate_(e,t,n,s);return Rs.fromArray(o).normalize().toArray(o),o}}const me={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},Ee={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ht={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},$t={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},_t={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...l.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"},Ce={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Gs={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},wt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function js(c){return c.DefaultMaterial===void 0&&(c.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),c.DefaultMaterial}function Ue(c,e,t){for(const n in t.extensions)c[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function De(c,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(c.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Ys(c,e,t){let n=!1,s=!1,o=!1;for(let u=0,d=e.length;u<d;u++){const p=e[u];if(p.POSITION!==void 0&&(n=!0),p.NORMAL!==void 0&&(s=!0),p.COLOR_0!==void 0&&(o=!0),n&&s&&o)break}if(!n&&!s&&!o)return Promise.resolve(c);const i=[],r=[],a=[];for(let u=0,d=e.length;u<d;u++){const p=e[u];if(n){const f=p.POSITION!==void 0?t.getDependency("accessor",p.POSITION):c.attributes.position;i.push(f)}if(s){const f=p.NORMAL!==void 0?t.getDependency("accessor",p.NORMAL):c.attributes.normal;r.push(f)}if(o){const f=p.COLOR_0!==void 0?t.getDependency("accessor",p.COLOR_0):c.attributes.color;a.push(f)}}return Promise.all([Promise.all(i),Promise.all(r),Promise.all(a)]).then(function(u){const d=u[0],p=u[1],f=u[2];return n&&(c.morphAttributes.position=d),s&&(c.morphAttributes.normal=p),o&&(c.morphAttributes.color=f),c.morphTargetsRelative=!0,c})}function Xs(c,e){if(c.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)c.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(c.morphTargetInfluences.length===t.length){c.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)c.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Zs(c){let e;const t=c.extensions&&c.extensions[Z.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+vt(t.attributes):e=c.indices+":"+vt(c.attributes)+":"+c.mode,c.targets!==void 0)for(let n=0,s=c.targets.length;n<s;n++)e+=":"+vt(c.targets[n]);return e}function vt(c){let e="";const t=Object.keys(c).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+c[t[n]]+";";return e}function At(c){switch(c){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 Qs(c){return c.search(/\.jpe?g($|\?)/i)>0||c.search(/^data\:image\/jpeg/)===0?"image/jpeg":c.search(/\.webp($|\?)/i)>0||c.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Ks=new l.Matrix4;class Ws{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ws,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=!1,o=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||s&&o<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){const r={scene:i[0][s.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:s.asset,parser:n,userData:{}};Ue(o,r,s),De(r,s),Promise.all(n._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||[],n=this.json.meshes||[];for(let s=0,o=t.length;s<o;s++){const i=t[s].joints;for(let r=0,a=i.length;r<a;r++)e[i[r]].isBone=!0}for(let s=0,o=e.length;s<o;s++){const i=e[s];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),o=(i,r)=>{const a=this.associations.get(i);a!=null&&this.associations.set(r,a);for(const[u,d]of i.children.entries())o(d,r.children[u])};return o(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const o=e(t[s]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":s=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(o,i){return n.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Z.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(o,i){n.load(l.LoaderUtils.resolveURL(t.uri,s.path),o,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const i=_t[s.type],r=Ee[s.componentType],a=s.normalized===!0,u=new r(s.count*i);return Promise.resolve(new l.BufferAttribute(u,i,a))}const o=[];return s.bufferView!==void 0?o.push(this.getDependency("bufferView",s.bufferView)):o.push(null),s.sparse!==void 0&&(o.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(o).then(function(i){const r=i[0],a=_t[s.type],u=Ee[s.componentType],d=u.BYTES_PER_ELEMENT,p=d*a,f=s.byteOffset||0,m=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,y=s.normalized===!0;let _,x;if(m&&m!==p){const S=Math.floor(f/m),O="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+S+":"+s.count;let M=t.cache.get(O);M||(_=new u(r,S*m,s.count*m/d),M=new l.InterleavedBuffer(_,m/d),t.cache.add(O,M)),x=new l.InterleavedBufferAttribute(M,a,f%m/d,y)}else r===null?_=new u(s.count*a):_=new u(r,f,s.count*a),x=new l.BufferAttribute(_,a,y);if(s.sparse!==void 0){const S=_t.SCALAR,O=Ee[s.sparse.indices.componentType],M=s.sparse.indices.byteOffset||0,g=s.sparse.values.byteOffset||0,A=new O(i[1],M,s.sparse.count*S),b=new u(i[2],g,s.sparse.count*a);r!==null&&(x=new l.BufferAttribute(x.array.slice(),x.itemSize,x.normalized));for(let w=0,v=A.length;w<v;w++){const C=A[w];if(x.setX(C,b[w*a]),a>=2&&x.setY(C,b[w*a+1]),a>=3&&x.setZ(C,b[w*a+2]),a>=4&&x.setW(C,b[w*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return x})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,i=t.images[o];let r=this.textureLoader;if(i.uri){const a=n.manager.getHandler(i.uri);a!==null&&(r=a)}return this.loadTextureImage(e,o,r)}loadTextureImage(e,t,n){const s=this,o=this.json,i=o.textures[e],r=o.images[t],a=(r.uri||r.bufferView)+":"+i.sampler;if(this.textureCache[a])return this.textureCache[a];const u=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=i.name||r.name||"",d.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(d.name=r.uri);const f=(o.samplers||{})[i.sampler]||{};return d.magFilter=Ht[f.magFilter]||l.LinearFilter,d.minFilter=Ht[f.minFilter]||l.LinearMipmapLinearFilter,d.wrapS=$t[f.wrapS]||l.RepeatWrapping,d.wrapT=$t[f.wrapT]||l.RepeatWrapping,s.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[a]=u,u}loadImageSource(e,t){const n=this,s=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(p=>p.clone());const i=s.images[e],r=self.URL||self.webkitURL;let a=i.uri||"",u=!1;if(i.bufferView!==void 0)a=n.getDependency("bufferView",i.bufferView).then(function(p){u=!0;const f=new Blob([p],{type:i.mimeType});return a=r.createObjectURL(f),a});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(a).then(function(p){return new Promise(function(f,m){let y=f;t.isImageBitmapLoader===!0&&(y=function(_){const x=new l.Texture(_);x.needsUpdate=!0,f(x)}),t.load(l.LoaderUtils.resolveURL(p,o.path),y,void 0,m)})}).then(function(p){return u===!0&&r.revokeObjectURL(a),p.userData.mimeType=i.mimeType||Qs(i.uri),p}).catch(function(p){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),p});return this.sourceCache[e]=d,d}assignTexture(e,t,n,s){const o=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),o.extensions[Z.KHR_TEXTURE_TRANSFORM]){const r=n.extensions!==void 0?n.extensions[Z.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=o.associations.get(i);i=o.extensions[Z.KHR_TEXTURE_TRANSFORM].extendTexture(i,r),o.associations.set(i,a)}}return s!==void 0&&("colorSpace"in i?i.colorSpace=s===3001?"srgb":"srgb-linear":i.encoding=s),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new l.PointsMaterial,l.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(r,a)),n=a}else if(e.isLine){const r="LineBasicMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new l.LineBasicMaterial,l.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(r,a)),n=a}if(s||o||i){let r="ClonedMaterial:"+n.uuid+":";s&&(r+="derivative-tangents:"),o&&(r+="vertex-colors:"),i&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=n.clone(),o&&(a.vertexColors=!0),i&&(a.flatShading=!0),s&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(n))),n=a}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,o=n.materials[e];let i;const r={},a=o.extensions||{},u=[];if(a[Z.KHR_MATERIALS_UNLIT]){const p=s[Z.KHR_MATERIALS_UNLIT];i=p.getMaterialType(),u.push(p.extendParams(r,o,t))}else{const p=o.pbrMetallicRoughness||{};if(r.color=new l.Color(1,1,1),r.opacity=1,Array.isArray(p.baseColorFactor)){const f=p.baseColorFactor;r.color.fromArray(f),r.opacity=f[3]}p.baseColorTexture!==void 0&&u.push(t.assignTexture(r,"map",p.baseColorTexture,3001)),r.metalness=p.metallicFactor!==void 0?p.metallicFactor:1,r.roughness=p.roughnessFactor!==void 0?p.roughnessFactor:1,p.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(r,"metalnessMap",p.metallicRoughnessTexture)),u.push(t.assignTexture(r,"roughnessMap",p.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,r)})))}o.doubleSided===!0&&(r.side=l.DoubleSide);const d=o.alphaMode||wt.OPAQUE;if(d===wt.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===wt.MASK&&(r.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&i!==l.MeshBasicMaterial&&(u.push(t.assignTexture(r,"normalMap",o.normalTexture)),r.normalScale=new l.Vector2(1,1),o.normalTexture.scale!==void 0)){const p=o.normalTexture.scale;r.normalScale.set(p,p)}return o.occlusionTexture!==void 0&&i!==l.MeshBasicMaterial&&(u.push(t.assignTexture(r,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&i!==l.MeshBasicMaterial&&(r.emissive=new l.Color().fromArray(o.emissiveFactor)),o.emissiveTexture!==void 0&&i!==l.MeshBasicMaterial&&u.push(t.assignTexture(r,"emissiveMap",o.emissiveTexture,3001)),Promise.all(u).then(function(){const p=new i(r);return o.name&&(p.name=o.name),De(p,o),t.associations.set(p,{materials:e}),o.extensions&&Ue(s,p,o),p})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function o(r){return n[Z.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return en(a,r,t)})}const i=[];for(let r=0,a=e.length;r<a;r++){const u=e[r],d=Zs(u),p=s[d];if(p)i.push(p.promise);else{let f;u.extensions&&u.extensions[Z.KHR_DRACO_MESH_COMPRESSION]?f=o(u):f=en(new l.BufferGeometry,u,t),s[d]={primitive:u,promise:f},i.push(f)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,s=this.extensions,o=n.meshes[e],i=o.primitives,r=[];for(let a=0,u=i.length;a<u;a++){const d=i[a].material===void 0?js(this.cache):this.getDependency("material",i[a].material);r.push(d)}return r.push(t.loadGeometries(i)),Promise.all(r).then(function(a){const u=a.slice(0,a.length-1),d=a[a.length-1],p=[];for(let m=0,y=d.length;m<y;m++){const _=d[m],x=i[m];let S;const O=u[m];if(x.mode===me.TRIANGLES||x.mode===me.TRIANGLE_STRIP||x.mode===me.TRIANGLE_FAN||x.mode===void 0)S=o.isSkinnedMesh===!0?new l.SkinnedMesh(_,O):new l.Mesh(_,O),S.isSkinnedMesh===!0&&S.normalizeSkinWeights(),x.mode===me.TRIANGLE_STRIP?S.geometry=zt(S.geometry,l.TriangleStripDrawMode):x.mode===me.TRIANGLE_FAN&&(S.geometry=zt(S.geometry,l.TriangleFanDrawMode));else if(x.mode===me.LINES)S=new l.LineSegments(_,O);else if(x.mode===me.LINE_STRIP)S=new l.Line(_,O);else if(x.mode===me.LINE_LOOP)S=new l.LineLoop(_,O);else if(x.mode===me.POINTS)S=new l.Points(_,O);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(S.geometry.morphAttributes).length>0&&Xs(S,o),S.name=t.createUniqueName(o.name||"mesh_"+e),De(S,o),x.extensions&&Ue(s,S,x),t.assignFinalMaterial(S),p.push(S)}for(let m=0,y=p.length;m<y;m++)t.associations.set(p[m],{meshes:e,primitives:m});if(p.length===1)return o.extensions&&Ue(s,p[0],o),p[0];const f=new l.Group;o.extensions&&Ue(s,f,o),t.associations.set(f,{meshes:e});for(let m=0,y=p.length;m<y;m++)f.add(p[m]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),De(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,o=t.joints.length;s<o;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const o=s.pop(),i=s,r=[],a=[];for(let u=0,d=i.length;u<d;u++){const p=i[u];if(p){r.push(p);const f=new l.Matrix4;o!==null&&f.fromArray(o.array,u*16),a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new l.Skeleton(r,a)})}loadAnimation(e){const n=this.json.animations[e],s=n.name?n.name:"animation_"+e,o=[],i=[],r=[],a=[],u=[];for(let d=0,p=n.channels.length;d<p;d++){const f=n.channels[d],m=n.samplers[f.sampler],y=f.target,_=y.node,x=n.parameters!==void 0?n.parameters[m.input]:m.input,S=n.parameters!==void 0?n.parameters[m.output]:m.output;y.node!==void 0&&(o.push(this.getDependency("node",_)),i.push(this.getDependency("accessor",x)),r.push(this.getDependency("accessor",S)),a.push(m),u.push(y))}return Promise.all([Promise.all(o),Promise.all(i),Promise.all(r),Promise.all(a),Promise.all(u)]).then(function(d){const p=d[0],f=d[1],m=d[2],y=d[3],_=d[4],x=[];for(let S=0,O=p.length;S<O;S++){const M=p[S],g=f[S],A=m[S],b=y[S],w=_[S];if(M===void 0)continue;M.updateMatrix();let v;switch(Ce[w.path]){case Ce.weights:v=l.NumberKeyframeTrack;break;case Ce.rotation:v=l.QuaternionKeyframeTrack;break;case Ce.position:case Ce.scale:default:v=l.VectorKeyframeTrack;break}const C=M.name?M.name:M.uuid,k=b.interpolation!==void 0?Gs[b.interpolation]:l.InterpolateLinear,I=[];Ce[w.path]===Ce.weights?M.traverse(function(j){j.morphTargetInfluences&&I.push(j.name?j.name:j.uuid)}):I.push(C);let U=A.array;if(A.normalized){const j=At(U.constructor),H=new Float32Array(U.length);for(let G=0,ne=U.length;G<ne;G++)H[G]=U[G]*j;U=H}for(let j=0,H=I.length;j<H;j++){const G=new v(I[j]+"."+Ce[w.path],g.array,U,k);b.interpolation==="CUBICSPLINE"&&(G.createInterpolant=function(X){const ae=this instanceof l.QuaternionKeyframeTrack?Es:Jt;return new ae(this.times,this.values,this.getValueSize()/3,X)},G.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),x.push(G)}}return new l.AnimationClip(s,void 0,x)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(o){const i=n._getNodeRef(n.meshCache,s.mesh,o);return s.weights!==void 0&&i.traverse(function(r){if(r.isMesh)for(let a=0,u=s.weights.length;a<u;a++)r.morphTargetInfluences[a]=s.weights[a]}),i})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],o=n._loadNodeShallow(e),i=[],r=s.children||[];for(let u=0,d=r.length;u<d;u++)i.push(n.getDependency("node",r[u]));const a=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([o,Promise.all(i),a]).then(function(u){const d=u[0],p=u[1],f=u[2];f!==null&&d.traverse(function(m){m.isSkinnedMesh&&m.bind(f,Ks)});for(let m=0,y=p.length;m<y;m++)d.add(p[m]);return d})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],i=o.name?s.createUniqueName(o.name):"",r=[],a=s._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return a&&r.push(a),o.camera!==void 0&&r.push(s.getDependency("camera",o.camera).then(function(u){return s._getNodeRef(s.cameraCache,o.camera,u)})),s._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){r.push(u)}),this.nodeCache[e]=Promise.all(r).then(function(u){let d;if(o.isBone===!0?d=new l.Bone:u.length>1?d=new l.Group:u.length===1?d=u[0]:d=new l.Object3D,d!==u[0])for(let p=0,f=u.length;p<f;p++)d.add(u[p]);if(o.name&&(d.userData.name=o.name,d.name=i),De(d,o),o.extensions&&Ue(n,d,o),o.matrix!==void 0){const p=new l.Matrix4;p.fromArray(o.matrix),d.applyMatrix4(p)}else o.translation!==void 0&&d.position.fromArray(o.translation),o.rotation!==void 0&&d.quaternion.fromArray(o.rotation),o.scale!==void 0&&d.scale.fromArray(o.scale);return s.associations.has(d)||s.associations.set(d,{}),s.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,o=new l.Group;n.name&&(o.name=s.createUniqueName(n.name)),De(o,n),n.extensions&&Ue(t,o,n);const i=n.nodes||[],r=[];for(let a=0,u=i.length;a<u;a++)r.push(s.getDependency("node",i[a]));return Promise.all(r).then(function(a){for(let d=0,p=a.length;d<p;d++)o.add(a[d]);const u=d=>{const p=new Map;for(const[f,m]of s.associations)(f instanceof l.Material||f instanceof l.Texture)&&p.set(f,m);return d.traverse(f=>{const m=s.associations.get(f);m!=null&&p.set(f,m)}),p};return s.associations=u(o),o})}}function qs(c,e,t){const n=e.attributes,s=new l.Box3;if(n.POSITION!==void 0){const r=t.json.accessors[n.POSITION],a=r.min,u=r.max;if(a!==void 0&&u!==void 0){if(s.set(new l.Vector3(a[0],a[1],a[2]),new l.Vector3(u[0],u[1],u[2])),r.normalized){const d=At(Ee[r.componentType]);s.min.multiplyScalar(d),s.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const r=new l.Vector3,a=new l.Vector3;for(let u=0,d=o.length;u<d;u++){const p=o[u];if(p.POSITION!==void 0){const f=t.json.accessors[p.POSITION],m=f.min,y=f.max;if(m!==void 0&&y!==void 0){if(a.setX(Math.max(Math.abs(m[0]),Math.abs(y[0]))),a.setY(Math.max(Math.abs(m[1]),Math.abs(y[1]))),a.setZ(Math.max(Math.abs(m[2]),Math.abs(y[2]))),f.normalized){const _=At(Ee[f.componentType]);a.multiplyScalar(_)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(r)}c.boundingBox=s;const i=new l.Sphere;s.getCenter(i.center),i.radius=s.min.distanceTo(s.max)/2,c.boundingSphere=i}function en(c,e,t){const n=e.attributes,s=[];function o(i,r){return t.getDependency("accessor",i).then(function(a){c.setAttribute(r,a)})}for(const i in n){const r=yt[i]||i.toLowerCase();r in c.attributes||s.push(o(n[i],r))}if(e.indices!==void 0&&!c.index){const i=t.getDependency("accessor",e.indices).then(function(r){c.setIndex(r)});s.push(i)}return De(c,e),qs(c,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Ys(c,e.targets,t):c})}class tn extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:s=8,bevelThickness:o=10,font:i,height:r=50,size:a=100,lineHeight:u=1,letterSpacing:d=0,...p}=t;if(i===void 0)super();else{const f=i.generateShapes(e,a,{lineHeight:u,letterSpacing:d});super(f,{...p,bevelEnabled:n,bevelSize:s,bevelThickness:o,depth:r})}this.type="TextGeometry"}}const Js={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
8
+ (function(B,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("vue"),require("three"),require("@tresjs/core"),require("tweakpane")):typeof define=="function"&&define.amd?define(["exports","vue","three","@tresjs/core","tweakpane"],h):(B=typeof globalThis<"u"?globalThis:B||self,h(B.trescientos={},B.Vue,B.Three,B.TresjsCore,B.tweakpane))})(this,function(B,h,l,q,Gn){"use strict";var Br=Object.defineProperty;var Vr=(B,h,l)=>h in B?Br(B,h,{enumerable:!0,configurable:!0,writable:!0,value:l}):B[h]=l;var Nt=(B,h,l)=>(Vr(B,typeof h!="symbol"?h+"":h,l),l);function zt(c,e){if(e===l.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),c;if(e===l.TriangleFanDrawMode||e===l.TriangleStripDrawMode){let t=c.getIndex();if(t===null){const i=[],r=c.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)i.push(a);c.setIndex(i),t=c.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),c}const n=t.count-2,s=[];if(t)if(e===l.TriangleFanDrawMode)for(let i=1;i<=n;i++)s.push(t.getX(0)),s.push(t.getX(i)),s.push(t.getX(i+1));else for(let i=0;i<n;i++)i%2===0?(s.push(t.getX(i)),s.push(t.getX(i+1)),s.push(t.getX(i+2))):(s.push(t.getX(i+2)),s.push(t.getX(i+1)),s.push(t.getX(i)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=c.clone();return o.setIndex(s),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),c}var fe=Uint8Array,Oe=Uint16Array,pt=Uint32Array,Rt=new fe([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]),Et=new fe([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]),jn=new fe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Gt=function(c,e){for(var t=new Oe(31),n=0;n<31;++n)t[n]=e+=1<<c[n-1];for(var s=new pt(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)s[o]=o-t[n]<<5|n;return[t,s]},jt=Gt(Rt,2),Yt=jt[0],Yn=jt[1];Yt[28]=258,Yn[258]=28;for(var Xn=Gt(Et,0),Zn=Xn[0],dt=new Oe(32768),se=0;se<32768;++se){var Pe=(se&43690)>>>1|(se&21845)<<1;Pe=(Pe&52428)>>>2|(Pe&13107)<<2,Pe=(Pe&61680)>>>4|(Pe&3855)<<4,dt[se]=((Pe&65280)>>>8|(Pe&255)<<8)>>>1}for(var Ke=function(c,e,t){for(var n=c.length,s=0,o=new Oe(e);s<n;++s)++o[c[s]-1];var i=new Oe(e);for(s=0;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;var r;if(t){r=new Oe(1<<e);var a=15-e;for(s=0;s<n;++s)if(c[s])for(var u=s<<4|c[s],d=e-c[s],p=i[c[s]-1]++<<d,f=p|(1<<d)-1;p<=f;++p)r[dt[p]>>>a]=u}else for(r=new Oe(n),s=0;s<n;++s)c[s]&&(r[s]=dt[i[c[s]-1]++]>>>15-c[s]);return r},We=new fe(288),se=0;se<144;++se)We[se]=8;for(var se=144;se<256;++se)We[se]=9;for(var se=256;se<280;++se)We[se]=7;for(var se=280;se<288;++se)We[se]=8;for(var Xt=new fe(32),se=0;se<32;++se)Xt[se]=5;var Qn=Ke(We,9,1),Kn=Ke(Xt,5,1),ft=function(c){for(var e=c[0],t=1;t<c.length;++t)c[t]>e&&(e=c[t]);return e},we=function(c,e,t){var n=e/8|0;return(c[n]|c[n+1]<<8)>>(e&7)&t},mt=function(c,e){var t=e/8|0;return(c[t]|c[t+1]<<8|c[t+2]<<16)>>(e&7)},Wn=function(c){return(c/8|0)+(c&7&&1)},qn=function(c,e,t){(e==null||e<0)&&(e=0),(t==null||t>c.length)&&(t=c.length);var n=new(c instanceof Oe?Oe:c instanceof pt?pt:fe)(t-e);return n.set(c.subarray(e,t)),n},Jn=function(c,e,t){var n=c.length;if(!n||t&&!t.l&&n<5)return e||new fe(0);var s=!e||t,o=!t||t.i;t||(t={}),e||(e=new fe(n*3));var i=function(ye){var Ae=e.length;if(ye>Ae){var ke=new fe(Math.max(Ae*2,ye));ke.set(e),e=ke}},r=t.f||0,a=t.p||0,u=t.b||0,d=t.l,p=t.d,f=t.m,m=t.n,v=n*8;do{if(!d){t.f=r=we(c,a,1);var _=we(c,a+1,3);if(a+=3,_)if(_==1)d=Qn,p=Kn,f=9,m=5;else if(_==2){var b=we(c,a,31)+257,g=we(c,a+10,15)+4,T=b+we(c,a+5,31)+1;a+=14;for(var x=new fe(T),y=new fe(19),w=0;w<g;++w)y[jn[w]]=we(c,a+w*3,7);a+=g*3;for(var D=ft(y),k=(1<<D)-1,I=Ke(y,D,1),w=0;w<T;){var U=I[we(c,a,k)];a+=U&15;var A=U>>>4;if(A<16)x[w++]=A;else{var R=0,H=0;for(A==16?(H=3+we(c,a,3),a+=2,R=x[w-1]):A==17?(H=3+we(c,a,7),a+=3):A==18&&(H=11+we(c,a,127),a+=7);H--;)x[w++]=R}}var E=x.subarray(0,b),ne=x.subarray(b);f=ft(E),m=ft(ne),d=Ke(E,f,1),p=Ke(ne,m,1)}else throw"invalid block type";else{var A=Wn(a)+4,M=c[A-4]|c[A-3]<<8,O=A+M;if(O>n){if(o)throw"unexpected EOF";break}s&&i(u+M),e.set(c.subarray(A,O),u),t.b=u+=M,t.p=a=O*8;continue}if(a>v){if(o)throw"unexpected EOF";break}}s&&i(u+131072);for(var X=(1<<f)-1,ae=(1<<m)-1,ie=a;;ie=a){var R=d[mt(c,a)&X],$=R>>>4;if(a+=R&15,a>v){if(o)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if($<256)e[u++]=$;else if($==256){ie=a,d=null;break}else{var Q=$-254;if($>264){var w=$-257,K=Rt[w];Q=we(c,a,(1<<K)-1)+Yt[w],a+=K}var ce=p[mt(c,a)&ae],L=ce>>>4;if(!ce)throw"invalid distance";a+=ce&15;var ne=Zn[L];if(L>3){var K=Et[L];ne+=mt(c,a)&(1<<K)-1,a+=K}if(a>v){if(o)throw"unexpected EOF";break}s&&i(u+131072);for(var de=u+Q;u<de;u+=4)e[u]=e[u-ne],e[u+1]=e[u+1-ne],e[u+2]=e[u+2-ne],e[u+3]=e[u+3-ne];u=de}}t.l=d,t.p=ie,t.b=u,d&&(r=1,t.m=f,t.d=p,t.n=m)}while(!r);return u==e.length?e:qn(e,0,u)},Hn=new fe(0),$n=function(c){if((c[0]&15)!=8||c[0]>>>4>7||(c[0]<<8|c[1])%31)throw"invalid zlib data";if(c[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function es(c,e){return Jn(($n(c),c.subarray(2,-4)),e)}var ts=typeof TextDecoder<"u"&&new TextDecoder,ns=0;try{ts.decode(Hn,{stream:!0}),ns=1}catch{}var ss=Object.defineProperty,os=(c,e,t)=>e in c?ss(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,P=(c,e,t)=>(os(c,typeof e!="symbol"?e+"":e,t),t);class is extends l.Object3D{constructor(e,t){super(),P(this,"isTransformControls",!0),P(this,"visible",!1),P(this,"domElement"),P(this,"raycaster",new l.Raycaster),P(this,"gizmo"),P(this,"plane"),P(this,"tempVector",new l.Vector3),P(this,"tempVector2",new l.Vector3),P(this,"tempQuaternion",new l.Quaternion),P(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),P(this,"pointStart",new l.Vector3),P(this,"pointEnd",new l.Vector3),P(this,"offset",new l.Vector3),P(this,"rotationAxis",new l.Vector3),P(this,"startNorm",new l.Vector3),P(this,"endNorm",new l.Vector3),P(this,"rotationAngle",0),P(this,"cameraPosition",new l.Vector3),P(this,"cameraQuaternion",new l.Quaternion),P(this,"cameraScale",new l.Vector3),P(this,"parentPosition",new l.Vector3),P(this,"parentQuaternion",new l.Quaternion),P(this,"parentQuaternionInv",new l.Quaternion),P(this,"parentScale",new l.Vector3),P(this,"worldPositionStart",new l.Vector3),P(this,"worldQuaternionStart",new l.Quaternion),P(this,"worldScaleStart",new l.Vector3),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"worldQuaternionInv",new l.Quaternion),P(this,"worldScale",new l.Vector3),P(this,"eye",new l.Vector3),P(this,"positionStart",new l.Vector3),P(this,"quaternionStart",new l.Quaternion),P(this,"scaleStart",new l.Vector3),P(this,"camera"),P(this,"object"),P(this,"enabled",!0),P(this,"axis",null),P(this,"mode","translate"),P(this,"translationSnap",null),P(this,"rotationSnap",null),P(this,"scaleSnap",null),P(this,"space","world"),P(this,"size",1),P(this,"dragging",!1),P(this,"showX",!0),P(this,"showY",!0),P(this,"showZ",!0),P(this,"changeEvent",{type:"change"}),P(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),P(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),P(this,"objectChangeEvent",{type:"objectChange"}),P(this,"intersectObjectWithRay",(s,o,i)=>{const r=o.intersectObject(s,!0);for(let a=0;a<r.length;a++)if(r[a].object.visible||i)return r[a];return!1}),P(this,"attach",s=>(this.object=s,this.visible=!0,this)),P(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),P(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),P(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()}),P(this,"pointerHover",s=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(s,this.camera);const o=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);o?this.axis=o.object.name:this.axis=null}),P(this,"pointerDown",s=>{if(!(this.object===void 0||this.dragging===!0||s.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(s,this.camera);const o=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(o){let i=this.space;if(this.mode==="scale"?i="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(i="world"),i==="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(o.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),P(this,"pointerMove",s=>{const o=this.axis,i=this.mode,r=this.object;let a=this.space;if(i==="scale"?a="local":(o==="E"||o==="XYZE"||o==="XYZ")&&(a="world"),r===void 0||o===null||this.dragging===!1||s.button!==-1)return;this.raycaster.setFromCamera(s,this.camera);const u=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(u){if(this.pointEnd.copy(u.point).sub(this.worldPositionStart),i==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&o!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),o.indexOf("X")===-1&&(this.offset.x=0),o.indexOf("Y")===-1&&(this.offset.y=0),o.indexOf("Z")===-1&&(this.offset.z=0),a==="local"&&o!=="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()),o.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),o.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),o.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)),o.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),o.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),o.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(i==="scale"){if(o.search("XYZ")!==-1){let d=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(d*=-1),this.tempVector2.set(d,d,d)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),o.search("X")===-1&&(this.tempVector2.x=1),o.search("Y")===-1&&(this.tempVector2.y=1),o.search("Z")===-1&&(this.tempVector2.z=1);r.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(o.search("X")!==-1&&(this.object.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),o.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),o.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const d=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));o==="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):o==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*d):(o==="X"||o==="Y"||o==="Z")&&(this.rotationAxis.copy(this.unit[o]),this.tempVector.copy(this.unit[o]),a==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*d),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&o!=="E"&&o!=="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)}}),P(this,"pointerUp",s=>{s.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),P(this,"getPointer",s=>{var o,i;if(this.domElement&&((o=this.domElement.ownerDocument)!=null&&o.pointerLockElement))return{x:0,y:0,button:s.button};{const r=s.changedTouches?s.changedTouches[0]:s,a=(i=this.domElement)==null?void 0:i.getBoundingClientRect();return{x:(r.clientX-a.left)/a.width*2-1,y:-(r.clientY-a.top)/a.height*2+1,button:s.button}}}),P(this,"onPointerHover",s=>{if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(s));break}}),P(this,"onPointerDown",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(s)),this.pointerDown(this.getPointer(s)))}),P(this,"onPointerMove",s=>{this.enabled&&this.pointerMove(this.getPointer(s))}),P(this,"onPointerUp",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(s)))}),P(this,"getMode",()=>this.mode),P(this,"setMode",s=>{this.mode=s}),P(this,"setTranslationSnap",s=>{this.translationSnap=s}),P(this,"setRotationSnap",s=>{this.rotationSnap=s}),P(this,"setScaleSnap",s=>{this.scaleSnap=s}),P(this,"setSize",s=>{this.size=s}),P(this,"setSpace",s=>{this.space=s}),P(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),P(this,"connect",s=>{s===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=s,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),P(this,"dispose",()=>{var s,o,i,r,a,u;(s=this.domElement)==null||s.removeEventListener("pointerdown",this.onPointerDown),(o=this.domElement)==null||o.removeEventListener("pointermove",this.onPointerHover),(r=(i=this.domElement)==null?void 0:i.ownerDocument)==null||r.removeEventListener("pointermove",this.onPointerMove),(u=(a=this.domElement)==null?void 0:a.ownerDocument)==null||u.removeEventListener("pointerup",this.onPointerUp),this.traverse(d=>{const p=d;p.geometry&&p.geometry.dispose(),p.material&&p.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new rs,this.add(this.gizmo),this.plane=new as,this.add(this.plane);const n=(s,o)=>{let i=o;Object.defineProperty(this,s,{get:function(){return i!==void 0?i:o},set:function(r){i!==r&&(i=r,this.plane[s]=r,this.gizmo[s]=r,this.dispatchEvent({type:s+"-changed",value:r}),this.dispatchEvent(this.changeEvent))}}),this[s]=o,this.plane[s]=o,this.gizmo[s]=o};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class rs extends l.Object3D{constructor(){super(),P(this,"isTransformControlsGizmo",!0),P(this,"type","TransformControlsGizmo"),P(this,"tempVector",new l.Vector3(0,0,0)),P(this,"tempEuler",new l.Euler),P(this,"alignVector",new l.Vector3(0,1,0)),P(this,"zeroVector",new l.Vector3(0,0,0)),P(this,"lookAtMatrix",new l.Matrix4),P(this,"tempQuaternion",new l.Quaternion),P(this,"tempQuaternion2",new l.Quaternion),P(this,"identityQuaternion",new l.Quaternion),P(this,"unitX",new l.Vector3(1,0,0)),P(this,"unitY",new l.Vector3(0,1,0)),P(this,"unitZ",new l.Vector3(0,0,1)),P(this,"gizmo"),P(this,"picker"),P(this,"helper"),P(this,"rotationAxis",new l.Vector3),P(this,"cameraPosition",new l.Vector3),P(this,"worldPositionStart",new l.Vector3),P(this,"worldQuaternionStart",new l.Quaternion),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"eye",new l.Vector3),P(this,"camera",null),P(this,"enabled",!0),P(this,"axis",null),P(this,"mode","translate"),P(this,"space","world"),P(this,"size",1),P(this,"dragging",!1),P(this,"showX",!0),P(this,"showY",!0),P(this,"showZ",!0),P(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 ce=0;ce<K.length;ce++){const L=K[ce];L.visible=!0,L.rotation.set(0,0,0),L.position.copy(this.worldPosition);let de;if(this.camera.isOrthographicCamera?de=(this.camera.top-this.camera.bottom)/this.camera.zoom:de=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),L.scale.set(1,1,1).multiplyScalar(de*this.size/7),L.tag==="helper"){L.visible=!1,L.name==="AXIS"?(L.position.copy(this.worldPositionStart),L.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),L.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.9&&(L.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),L.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),L.quaternion.multiply(this.tempQuaternion),L.visible=this.dragging),this.axis==="E"&&(L.visible=!1)):L.name==="START"?(L.position.copy(this.worldPositionStart),L.visible=this.dragging):L.name==="END"?(L.position.copy(this.worldPosition),L.visible=this.dragging):L.name==="DELTA"?(L.position.copy(this.worldPositionStart),L.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()),L.scale.copy(this.tempVector),L.visible=this.dragging):(L.quaternion.copy(Q),this.dragging?L.position.copy(this.worldPositionStart):L.position.copy(this.worldPosition),this.axis&&(L.visible=this.axis.search(L.name)!==-1));continue}L.quaternion.copy(Q),this.mode==="translate"||this.mode==="scale"?((L.name==="X"||L.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),(L.name==="Y"||L.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),(L.name==="Z"||L.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.99&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))<.2&&(L.scale.set(1e-10,1e-10,1e-10),L.visible=!1),L.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.x*=-1:L.tag==="bwd"&&(L.visible=!1)),L.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.y*=-1:L.tag==="bwd"&&(L.visible=!1)),L.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye)<0?L.tag==="fwd"?L.visible=!1:L.scale.z*=-1:L.tag==="bwd"&&(L.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(Q),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(Q).invert()),L.name.search("E")!==-1&&L.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),L.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion)),L.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion)),L.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),L.quaternion.copy(this.tempQuaternion))),L.visible=L.visible&&(L.name.indexOf("X")===-1||this.showX),L.visible=L.visible&&(L.name.indexOf("Y")===-1||this.showY),L.visible=L.visible&&(L.name.indexOf("Z")===-1||this.showZ),L.visible=L.visible&&(L.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),L.material.tempOpacity=L.material.tempOpacity||L.material.opacity,L.material.tempColor=L.material.tempColor||L.material.color.clone(),L.material.color.copy(L.material.tempColor),L.material.opacity=L.material.tempOpacity,this.enabled?this.axis&&(L.name===this.axis?(L.material.opacity=1,L.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(ye){return L.name===ye})?(L.material.opacity=1,L.material.color.lerp(new l.Color(1,1,1),.5)):(L.material.opacity*=.25,L.material.color.lerp(new l.Color(1,1,1),.5))):(L.material.opacity*=.5,L.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const s=e.clone();s.opacity=.33;const o=e.clone();o.color.set(16711680);const i=e.clone();i.color.set(65280);const r=e.clone();r.color.set(255);const a=e.clone();a.opacity=.25;const u=a.clone();u.color.set(16776960);const d=a.clone();d.color.set(65535);const p=a.clone();p.color.set(16711935),e.clone().color.set(16776960);const m=t.clone();m.color.set(16711680);const v=t.clone();v.color.set(65280);const _=t.clone();_.color.set(255);const A=t.clone();A.color.set(65535);const M=t.clone();M.color.set(16711935);const O=t.clone();O.color.set(16776960);const b=t.clone();b.color.set(7895160);const g=O.clone();g.opacity=.25;const T=new l.CylinderGeometry(0,.05,.2,12,1,!1),x=new l.BoxGeometry(.125,.125,.125),y=new l.BufferGeometry;y.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const w=($,Q)=>{const K=new l.BufferGeometry,ce=[];for(let L=0;L<=64*Q;++L)ce.push(0,Math.cos(L/32*Math.PI)*$,Math.sin(L/32*Math.PI)*$);return K.setAttribute("position",new l.Float32BufferAttribute(ce,3)),K},D=()=>{const $=new l.BufferGeometry;return $.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),$},k={X:[[new l.Mesh(T,o),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(T,o),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(y,m)]],Y:[[new l.Mesh(T,i),[0,1,0],null,null,"fwd"],[new l.Mesh(T,i),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(y,v),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(T,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(T,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(y,_),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),a.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),u.clone()),[.15,.15,0]],[new l.Line(y,O),[.18,.3,0],null,[.125,1,1]],[new l.Line(y,O),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),d.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(y,A),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(y,A),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),p.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(y,M),[.18,0,.3],null,[.125,1,1]],[new l.Line(y,M),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},U={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new l.Line(D(),s),null,null,null,"helper"]],X:[[new l.Line(y,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(y,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(y,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={X:[[new l.Line(w(1,.5),m)],[new l.Mesh(new l.OctahedronGeometry(.04,0),o),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(w(1,.5),v),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(w(1,.5),_),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),r),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(w(1.25,1),g),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(w(1,1),b),null,[0,Math.PI/2,0]]]},H={AXIS:[[new l.Line(y,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},E={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},ne={X:[[new l.Mesh(x,o),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(y,m),null,null,[.8,1,1]]],Y:[[new l.Mesh(x,i),[0,.8,0]],[new l.Line(y,v),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(x,r),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(y,_),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(x,u),[.85,.85,0],null,[2,2,.2]],[new l.Line(y,O),[.855,.98,0],null,[.125,1,1]],[new l.Line(y,O),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(x,d),[0,.85,.85],null,[.2,2,2]],[new l.Line(y,A),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(y,A),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(x,p),[.85,0,.85],null,[2,.2,2]],[new l.Line(y,M),[.855,0,.98],null,[.125,1,1]],[new l.Line(y,M),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),a.clone()),[0,0,1.1]]]},X={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(x,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(x,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(x,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},ae={X:[[new l.Line(y,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(y,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(y,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ie=$=>{const Q=new l.Object3D;for(let K in $)for(let ce=$[K].length;ce--;){const L=$[K][ce][0].clone(),de=$[K][ce][1],ye=$[K][ce][2],Ae=$[K][ce][3],ke=$[K][ce][4];L.name=K,L.tag=ke,de&&L.position.set(de[0],de[1],de[2]),ye&&L.rotation.set(ye[0],ye[1],ye[2]),Ae&&L.scale.set(Ae[0],Ae[1],Ae[2]),L.updateMatrix();const st=L.geometry.clone();st.applyMatrix4(L.matrix),L.geometry=st,L.renderOrder=1/0,L.position.set(0,0,0),L.rotation.set(0,0,0),L.scale.set(1,1,1),Q.add(L)}return Q};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=ie(k)),this.add(this.gizmo.rotate=ie(R)),this.add(this.gizmo.scale=ie(ne)),this.add(this.picker.translate=ie(I)),this.add(this.picker.rotate=ie(E)),this.add(this.picker.scale=ie(X)),this.add(this.helper.translate=ie(U)),this.add(this.helper.rotate=ie(H)),this.add(this.helper.scale=ie(ae)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class as extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),P(this,"isTransformControlsPlane",!0),P(this,"type","TransformControlsPlane"),P(this,"unitX",new l.Vector3(1,0,0)),P(this,"unitY",new l.Vector3(0,1,0)),P(this,"unitZ",new l.Vector3(0,0,1)),P(this,"tempVector",new l.Vector3),P(this,"dirVector",new l.Vector3),P(this,"alignVector",new l.Vector3),P(this,"tempMatrix",new l.Matrix4),P(this,"identityQuaternion",new l.Quaternion),P(this,"cameraQuaternion",new l.Quaternion),P(this,"worldPosition",new l.Vector3),P(this,"worldQuaternion",new l.Quaternion),P(this,"eye",new l.Vector3),P(this,"axis",null),P(this,"mode","translate"),P(this,"space","world"),P(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 ls=Object.defineProperty,cs=(c,e,t)=>e in c?ls(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,le=(c,e,t)=>(cs(c,typeof e!="symbol"?e+"":e,t),t);const Re=new l.Euler(0,0,0,"YXZ"),Ee=new l.Vector3,hs={type:"change"},us={type:"lock"},ps={type:"unlock"},Zt=Math.PI/2;class gt extends l.EventDispatcher{constructor(e,t){super(),le(this,"camera"),le(this,"domElement"),le(this,"isLocked"),le(this,"minPolarAngle"),le(this,"maxPolarAngle"),le(this,"pointerSpeed"),le(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const s=n.movementX||n.mozMovementX||n.webkitMovementX||0,o=n.movementY||n.mozMovementY||n.webkitMovementY||0;Re.setFromQuaternion(this.camera.quaternion),Re.y-=s*.002*this.pointerSpeed,Re.x-=o*.002*this.pointerSpeed,Re.x=Math.max(Zt-this.maxPolarAngle,Math.min(Zt-this.minPolarAngle,Re.x)),this.camera.quaternion.setFromEuler(Re),this.dispatchEvent(hs)}),le(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(us),this.isLocked=!0):(this.dispatchEvent(ps),this.isLocked=!1))}),le(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),le(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),le(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))}),le(this,"dispose",()=>{this.disconnect()}),le(this,"getObject",()=>this.camera),le(this,"direction",new l.Vector3(0,0,-1)),le(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),le(this,"moveForward",n=>{Ee.setFromMatrixColumn(this.camera.matrix,0),Ee.crossVectors(this.camera.up,Ee),this.camera.position.addScaledVector(Ee,n)}),le(this,"moveRight",n=>{Ee.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(Ee,n)}),le(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),le(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 ds=Object.defineProperty,fs=(c,e,t)=>e in c?ds(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,z=(c,e,t)=>(fs(c,typeof e!="symbol"?e+"":e,t),t);const Qt=(c,e)=>(c%e+e)%e;class Kt extends l.EventDispatcher{constructor(e,t){super(),z(this,"object"),z(this,"domElement"),z(this,"enabled",!0),z(this,"target",new l.Vector3),z(this,"minDistance",0),z(this,"maxDistance",1/0),z(this,"minZoom",0),z(this,"maxZoom",1/0),z(this,"minPolarAngle",0),z(this,"maxPolarAngle",Math.PI),z(this,"minAzimuthAngle",-1/0),z(this,"maxAzimuthAngle",1/0),z(this,"enableDamping",!1),z(this,"dampingFactor",.05),z(this,"enableZoom",!0),z(this,"zoomSpeed",1),z(this,"enableRotate",!0),z(this,"rotateSpeed",1),z(this,"enablePan",!0),z(this,"panSpeed",1),z(this,"screenSpacePanning",!0),z(this,"keyPanSpeed",7),z(this,"autoRotate",!1),z(this,"autoRotateSpeed",2),z(this,"reverseOrbit",!1),z(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),z(this,"mouseButtons",{LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),z(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN}),z(this,"target0"),z(this,"position0"),z(this,"zoom0"),z(this,"_domElementKeyEvents",null),z(this,"getPolarAngle"),z(this,"getAzimuthalAngle"),z(this,"setPolarAngle"),z(this,"setAzimuthalAngle"),z(this,"getDistance"),z(this,"listenToKeyEvents"),z(this,"saveState"),z(this,"reset"),z(this,"update"),z(this,"connect"),z(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>d.phi,this.getAzimuthalAngle=()=>d.theta,this.setPolarAngle=S=>{let F=Qt(S,2*Math.PI),j=d.phi;j<0&&(j+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-j);2*Math.PI-ee<ee&&(F<j?F+=2*Math.PI:j+=2*Math.PI),p.phi=F-j,n.update()},this.setAzimuthalAngle=S=>{let F=Qt(S,2*Math.PI),j=d.theta;j<0&&(j+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-j);2*Math.PI-ee<ee&&(F<j?F+=2*Math.PI:j+=2*Math.PI),p.theta=F-j,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=S=>{S.addEventListener("keydown",Vn),this._domElementKeyEvents=S},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(s),n.update(),a=r.NONE},this.update=(()=>{const S=new l.Vector3,F=new l.Quaternion().setFromUnitVectors(e.up,new l.Vector3(0,1,0)),j=F.clone().invert(),ee=new l.Vector3,he=new l.Quaternion,Te=2*Math.PI;return function(){const En=n.object.position;S.copy(En).sub(n.target),S.applyQuaternion(F),d.setFromVector3(S),n.autoRotate&&a===r.NONE&&U(k()),n.enableDamping?(d.theta+=p.theta*n.dampingFactor,d.phi+=p.phi*n.dampingFactor):(d.theta+=p.theta,d.phi+=p.phi);let Se=n.minAzimuthAngle,Le=n.maxAzimuthAngle;return isFinite(Se)&&isFinite(Le)&&(Se<-Math.PI?Se+=Te:Se>Math.PI&&(Se-=Te),Le<-Math.PI?Le+=Te:Le>Math.PI&&(Le-=Te),Se<=Le?d.theta=Math.max(Se,Math.min(Le,d.theta)):d.theta=d.theta>(Se+Le)/2?Math.max(Se,d.theta):Math.min(Le,d.theta)),d.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,d.phi)),d.makeSafe(),d.radius*=f,d.radius=Math.max(n.minDistance,Math.min(n.maxDistance,d.radius)),n.enableDamping===!0?n.target.addScaledVector(m,n.dampingFactor):n.target.add(m),S.setFromSpherical(d),S.applyQuaternion(j),En.copy(n.target).add(S),n.object.lookAt(n.target),n.enableDamping===!0?(p.theta*=1-n.dampingFactor,p.phi*=1-n.dampingFactor,m.multiplyScalar(1-n.dampingFactor)):(p.set(0,0,0),m.set(0,0,0)),f=1,v||ee.distanceToSquared(n.object.position)>u||8*(1-he.dot(n.object.quaternion))>u?(n.dispatchEvent(s),ee.copy(n.object.position),he.copy(n.object.quaternion),v=!1,!0):!1}})(),this.connect=S=>{S===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=S,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Nn),n.domElement.addEventListener("pointerdown",Fn),n.domElement.addEventListener("pointercancel",Un),n.domElement.addEventListener("wheel",Bn)},this.dispose=()=>{var S,F,j,ee,he,Te;(S=n.domElement)==null||S.removeEventListener("contextmenu",Nn),(F=n.domElement)==null||F.removeEventListener("pointerdown",Fn),(j=n.domElement)==null||j.removeEventListener("pointercancel",Un),(ee=n.domElement)==null||ee.removeEventListener("wheel",Bn),(he=n.domElement)==null||he.ownerDocument.removeEventListener("pointermove",Ut),(Te=n.domElement)==null||Te.ownerDocument.removeEventListener("pointerup",Bt),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Vn)};const n=this,s={type:"change"},o={type:"start"},i={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 u=1e-6,d=new l.Spherical,p=new l.Spherical;let f=1;const m=new l.Vector3;let v=!1;const _=new l.Vector2,A=new l.Vector2,M=new l.Vector2,O=new l.Vector2,b=new l.Vector2,g=new l.Vector2,T=new l.Vector2,x=new l.Vector2,y=new l.Vector2,w=[],D={};function k(){return 2*Math.PI/60/60*n.autoRotateSpeed}function I(){return Math.pow(.95,n.zoomSpeed)}function U(S){n.reverseOrbit?p.theta+=S:p.theta-=S}function R(S){n.reverseOrbit?p.phi+=S:p.phi-=S}const H=(()=>{const S=new l.Vector3;return function(j,ee){S.setFromMatrixColumn(ee,0),S.multiplyScalar(-j),m.add(S)}})(),E=(()=>{const S=new l.Vector3;return function(j,ee){n.screenSpacePanning===!0?S.setFromMatrixColumn(ee,1):(S.setFromMatrixColumn(ee,0),S.crossVectors(n.object.up,S)),S.multiplyScalar(j),m.add(S)}})(),ne=(()=>{const S=new l.Vector3;return function(j,ee){const he=n.domElement;if(he&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const Te=n.object.position;S.copy(Te).sub(n.target);let ut=S.length();ut*=Math.tan(n.object.fov/2*Math.PI/180),H(2*j*ut/he.clientHeight,n.object.matrix),E(2*ee*ut/he.clientHeight,n.object.matrix)}else he&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(H(j*(n.object.right-n.object.left)/n.object.zoom/he.clientWidth,n.object.matrix),E(ee*(n.object.top-n.object.bottom)/n.object.zoom/he.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function X(S){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera?f/=S:n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*S)),n.object.updateProjectionMatrix(),v=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ae(S){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera?f*=S:n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/S)),n.object.updateProjectionMatrix(),v=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ie(S){_.set(S.clientX,S.clientY)}function $(S){T.set(S.clientX,S.clientY)}function Q(S){O.set(S.clientX,S.clientY)}function K(S){A.set(S.clientX,S.clientY),M.subVectors(A,_).multiplyScalar(n.rotateSpeed);const F=n.domElement;F&&(U(2*Math.PI*M.x/F.clientHeight),R(2*Math.PI*M.y/F.clientHeight)),_.copy(A),n.update()}function ce(S){x.set(S.clientX,S.clientY),y.subVectors(x,T),y.y>0?X(I()):y.y<0&&ae(I()),T.copy(x),n.update()}function L(S){b.set(S.clientX,S.clientY),g.subVectors(b,O).multiplyScalar(n.panSpeed),ne(g.x,g.y),O.copy(b),n.update()}function de(S){S.deltaY<0?ae(I()):S.deltaY>0&&X(I()),n.update()}function ye(S){let F=!1;switch(S.code){case n.keys.UP:ne(0,n.keyPanSpeed),F=!0;break;case n.keys.BOTTOM:ne(0,-n.keyPanSpeed),F=!0;break;case n.keys.LEFT:ne(n.keyPanSpeed,0),F=!0;break;case n.keys.RIGHT:ne(-n.keyPanSpeed,0),F=!0;break}F&&(S.preventDefault(),n.update())}function Ae(){if(w.length==1)_.set(w[0].pageX,w[0].pageY);else{const S=.5*(w[0].pageX+w[1].pageX),F=.5*(w[0].pageY+w[1].pageY);_.set(S,F)}}function ke(){if(w.length==1)O.set(w[0].pageX,w[0].pageY);else{const S=.5*(w[0].pageX+w[1].pageX),F=.5*(w[0].pageY+w[1].pageY);O.set(S,F)}}function st(){const S=w[0].pageX-w[1].pageX,F=w[0].pageY-w[1].pageY,j=Math.sqrt(S*S+F*F);T.set(0,j)}function Lr(){n.enableZoom&&st(),n.enablePan&&ke()}function Or(){n.enableZoom&&st(),n.enableRotate&&Ae()}function Dn(S){if(w.length==1)A.set(S.pageX,S.pageY);else{const j=Vt(S),ee=.5*(S.pageX+j.x),he=.5*(S.pageY+j.y);A.set(ee,he)}M.subVectors(A,_).multiplyScalar(n.rotateSpeed);const F=n.domElement;F&&(U(2*Math.PI*M.x/F.clientHeight),R(2*Math.PI*M.y/F.clientHeight)),_.copy(A)}function In(S){if(w.length==1)b.set(S.pageX,S.pageY);else{const F=Vt(S),j=.5*(S.pageX+F.x),ee=.5*(S.pageY+F.y);b.set(j,ee)}g.subVectors(b,O).multiplyScalar(n.panSpeed),ne(g.x,g.y),O.copy(b)}function kn(S){const F=Vt(S),j=S.pageX-F.x,ee=S.pageY-F.y,he=Math.sqrt(j*j+ee*ee);x.set(0,he),y.set(0,Math.pow(x.y/T.y,n.zoomSpeed)),X(y.y),T.copy(x)}function Pr(S){n.enableZoom&&kn(S),n.enablePan&&In(S)}function Cr(S){n.enableZoom&&kn(S),n.enableRotate&&Dn(S)}function Fn(S){var F,j;n.enabled!==!1&&(w.length===0&&((F=n.domElement)==null||F.ownerDocument.addEventListener("pointermove",Ut),(j=n.domElement)==null||j.ownerDocument.addEventListener("pointerup",Bt)),Ur(S),S.pointerType==="touch"?kr(S):Dr(S))}function Ut(S){n.enabled!==!1&&(S.pointerType==="touch"?Fr(S):Ir(S))}function Bt(S){var F,j,ee;zn(S),w.length===0&&((F=n.domElement)==null||F.releasePointerCapture(S.pointerId),(j=n.domElement)==null||j.ownerDocument.removeEventListener("pointermove",Ut),(ee=n.domElement)==null||ee.ownerDocument.removeEventListener("pointerup",Bt)),n.dispatchEvent(i),a=r.NONE}function Un(S){zn(S)}function Dr(S){let F;switch(S.button){case 0:F=n.mouseButtons.LEFT;break;case 1:F=n.mouseButtons.MIDDLE;break;case 2:F=n.mouseButtons.RIGHT;break;default:F=-1}switch(F){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;$(S),a=r.DOLLY;break;case l.MOUSE.ROTATE:if(S.ctrlKey||S.metaKey||S.shiftKey){if(n.enablePan===!1)return;Q(S),a=r.PAN}else{if(n.enableRotate===!1)return;ie(S),a=r.ROTATE}break;case l.MOUSE.PAN:if(S.ctrlKey||S.metaKey||S.shiftKey){if(n.enableRotate===!1)return;ie(S),a=r.ROTATE}else{if(n.enablePan===!1)return;Q(S),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&n.dispatchEvent(o)}function Ir(S){if(n.enabled!==!1)switch(a){case r.ROTATE:if(n.enableRotate===!1)return;K(S);break;case r.DOLLY:if(n.enableZoom===!1)return;ce(S);break;case r.PAN:if(n.enablePan===!1)return;L(S);break}}function Bn(S){n.enabled===!1||n.enableZoom===!1||a!==r.NONE&&a!==r.ROTATE||(S.preventDefault(),n.dispatchEvent(o),de(S),n.dispatchEvent(i))}function Vn(S){n.enabled===!1||n.enablePan===!1||ye(S)}function kr(S){switch(Rn(S),w.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;Ae(),a=r.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;ke(),a=r.TOUCH_PAN;break;default:a=r.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Lr(),a=r.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Or(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&n.dispatchEvent(o)}function Fr(S){switch(Rn(S),a){case r.TOUCH_ROTATE:if(n.enableRotate===!1)return;Dn(S),n.update();break;case r.TOUCH_PAN:if(n.enablePan===!1)return;In(S),n.update();break;case r.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Pr(S),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Cr(S),n.update();break;default:a=r.NONE}}function Nn(S){n.enabled!==!1&&S.preventDefault()}function Ur(S){w.push(S)}function zn(S){delete D[S.pointerId];for(let F=0;F<w.length;F++)if(w[F].pointerId==S.pointerId){w.splice(F,1);return}}function Rn(S){let F=D[S.pointerId];F===void 0&&(F=new l.Vector2,D[S.pointerId]=F),F.set(S.pageX,S.pageY)}function Vt(S){const F=S.pointerId===w[0].pointerId?w[1]:w[0];return D[F.pointerId]}t!==void 0&&this.connect(t),this.update()}}class ms extends Kt{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}class gs extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new As(t)}),this.register(function(t){return new Ps(t)}),this.register(function(t){return new Cs(t)}),this.register(function(t){return new Ds(t)}),this.register(function(t){return new Ms(t)}),this.register(function(t){return new bs(t)}),this.register(function(t){return new Ts(t)}),this.register(function(t){return new Ss(t)}),this.register(function(t){return new vs(t)}),this.register(function(t){return new Ls(t)}),this.register(function(t){return new xs(t)}),this.register(function(t){return new Os(t)}),this.register(function(t){return new ys(t)}),this.register(function(t){return new Is(t)}),this.register(function(t){return new ks(t)})}load(e,t,n,s){const o=this;let i;this.resourcePath!==""?i=this.resourcePath:this.path!==""?i=this.path:i=l.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const r=function(u){s?s(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},a=new l.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(u){try{o.parse(u,i,function(d){t(d),o.manager.itemEnd(e)},r)}catch(d){r(d)}},n,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let o;const i={},r={};if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===Wt){try{i[Z.KHR_BINARY_GLTF]=new Fs(e)}catch(d){s&&s(d);return}o=JSON.parse(i[Z.KHR_BINARY_GLTF].content)}else o=JSON.parse(l.LoaderUtils.decodeText(new Uint8Array(e)));else o=e;if(o.asset===void 0||o.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const a=new Qs(o,{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 u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](a);r[d.name]=d,i[d.name]=!0}if(o.extensionsUsed)for(let u=0;u<o.extensionsUsed.length;++u){const d=o.extensionsUsed[u],p=o.extensionsRequired||[];switch(d){case Z.KHR_MATERIALS_UNLIT:i[d]=new ws;break;case Z.KHR_DRACO_MESH_COMPRESSION:i[d]=new Us(o,this.dracoLoader);break;case Z.KHR_TEXTURE_TRANSFORM:i[d]=new Bs;break;case Z.KHR_MESH_QUANTIZATION:i[d]=new Vs;break;default:p.indexOf(d)>=0&&r[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}a.setExtensions(i),a.setPlugins(r),a.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,o){n.parse(e,t,s,o)})}}function _s(){let c={};return{get:function(e){return c[e]},add:function(e,t){c[e]=t},remove:function(e){delete c[e]},removeAll:function(){c={}}}}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 ys{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 n=0,s=t.length;n<s;n++){const o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const o=t.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const d=new l.Color(16777215);a.color!==void 0&&d.fromArray(a.color);const p=a.range!==void 0?a.range:0;switch(a.type){case"directional":u=new l.DirectionalLight(d),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new l.PointLight(d),u.distance=p;break;case"spot":u=new l.SpotLight(d),u.distance=p,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,u.angle=a.spot.outerConeAngle,u.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return u.position.set(0,0,0),u.decay=2,De(u,a),a.intensity!==void 0&&(u.intensity=a.intensity),u.name=t.createUniqueName(a.name||"light_"+e),s=Promise.resolve(u),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],r=(o.extensions&&o.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return n._getNodeRef(t.cache,r,a)})}}class ws{constructor(){this.name=Z.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new l.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const i=o.baseColorFactor;e.color.fromArray(i),e.opacity=i[3]}o.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",o.baseColorTexture,3001))}return Promise.all(s)}}class vs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class As{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const r=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(r,r)}return Promise.all(o)}}class xs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(o)}}class Ms{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=s.extensions[this.name];return i.sheenColorFactor!==void 0&&t.sheenColor.fromArray(i.sheenColorFactor),i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,3001)),i.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(o)}}class bs{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(o)}}class Ts{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const r=i.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color(r[0],r[1],r[2]),Promise.all(o)}}class Ss{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class Ls{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const r=i.specularColorFactor||[1,1,1];return t.specularColor=new l.Color(r[0],r[1],r[2]),i.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,3001)),Promise.all(o)}}class Os{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],i=s.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(o)}}class Ps{constructor(e){this.parser=e,this.name=Z.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const o=s.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,i)}}class Cs{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],r=s.images[i.source];let a=n.textureLoader;if(r.uri){const u=n.options.manager.getHandler(r.uri);u!==null&&(a=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ds{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],r=s.images[i.source];let a=n.textureLoader;if(r.uri){const u=n.options.manager.getHandler(r.uri);u!==null&&(a=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Is{constructor(e){this.name=Z.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],o=this.parser.getDependency("buffer",s.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(r){const a=s.byteOffset||0,u=s.byteLength||0,d=s.count,p=s.byteStride,f=new Uint8Array(r,a,u);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(d,p,f,s.mode,s.filter).then(function(m){return m.buffer}):i.ready.then(function(){const m=new ArrayBuffer(d*p);return i.decodeGltfBuffer(new Uint8Array(m),d,p,f,s.mode,s.filter),m})})}else return null}}class ks{constructor(e){this.name=Z.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const u of s.primitives)if(u.mode!==me.TRIANGLES&&u.mode!==me.TRIANGLE_STRIP&&u.mode!==me.TRIANGLE_FAN&&u.mode!==void 0)return null;const i=n.extensions[this.name].attributes,r=[],a={};for(const u in i)r.push(this.parser.getDependency("accessor",i[u]).then(d=>(a[u]=d,a[u])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(u=>{const d=u.pop(),p=d.isGroup?d.children:[d],f=u[0].count,m=[];for(const v of p){const _=new l.Matrix4,A=new l.Vector3,M=new l.Quaternion,O=new l.Vector3(1,1,1),b=new l.InstancedMesh(v.geometry,v.material,f);for(let g=0;g<f;g++)a.TRANSLATION&&A.fromBufferAttribute(a.TRANSLATION,g),a.ROTATION&&M.fromBufferAttribute(a.ROTATION,g),a.SCALE&&O.fromBufferAttribute(a.SCALE,g),b.setMatrixAt(g,_.compose(A,M,O));for(const g in a)g!=="TRANSLATION"&&g!=="ROTATION"&&g!=="SCALE"&&v.geometry.setAttribute(g,a[g]);l.Object3D.prototype.copy.call(b,v),this.parser.assignFinalMaterial(b),m.push(b)}return d.isGroup?(d.clear(),d.add(...m),d):m[0]}))}}const Wt="glTF",qe=12,qt={JSON:1313821514,BIN:5130562};class Fs{constructor(e){this.name=Z.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,qe);if(this.header={magic:l.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Wt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-qe,s=new DataView(e,qe);let o=0;for(;o<n;){const i=s.getUint32(o,!0);o+=4;const r=s.getUint32(o,!0);if(o+=4,r===qt.JSON){const a=new Uint8Array(e,qe+o,i);this.content=l.LoaderUtils.decodeText(a)}else if(r===qt.BIN){const a=qe+o;this.body=e.slice(a,a+i)}o+=i}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Us{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 n=this.json,s=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,r={},a={},u={};for(const d in i){const p=yt[d]||d.toLowerCase();r[p]=i[d]}for(const d in e.attributes){const p=yt[d]||d.toLowerCase();if(i[d]!==void 0){const f=n.accessors[e.attributes[d]],m=Ge[f.componentType];u[p]=m.name,a[p]=f.normalized===!0}}return t.getDependency("bufferView",o).then(function(d){return new Promise(function(p){s.decodeDracoFile(d,function(f){for(const m in f.attributes){const v=f.attributes[m],_=a[m];_!==void 0&&(v.normalized=_)}p(f)},r,u)})})}}class Bs{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 Vs{constructor(){this.name=Z.KHR_MESH_QUANTIZATION}}class Jt extends l.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,o=e*s*3+s;for(let i=0;i!==s;i++)t[i]=n[o+i];return t}interpolate_(e,t,n,s){const o=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=r*2,u=r*3,d=s-t,p=(n-t)/d,f=p*p,m=f*p,v=e*u,_=v-u,A=-2*m+3*f,M=m-f,O=1-A,b=M-f+p;for(let g=0;g!==r;g++){const T=i[_+g+r],x=i[_+g+a]*d,y=i[v+g+r],w=i[v+g]*d;o[g]=O*T+b*x+A*y+M*w}return o}}const Ns=new l.Quaternion;class zs extends Jt{interpolate_(e,t,n,s){const o=super.interpolate_(e,t,n,s);return Ns.fromArray(o).normalize().toArray(o),o}}const me={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},Ge={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ht={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},$t={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},_t={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...l.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"},Ce={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Rs={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},wt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Es(c){return c.DefaultMaterial===void 0&&(c.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),c.DefaultMaterial}function Fe(c,e,t){for(const n in t.extensions)c[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function De(c,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(c.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Gs(c,e,t){let n=!1,s=!1,o=!1;for(let u=0,d=e.length;u<d;u++){const p=e[u];if(p.POSITION!==void 0&&(n=!0),p.NORMAL!==void 0&&(s=!0),p.COLOR_0!==void 0&&(o=!0),n&&s&&o)break}if(!n&&!s&&!o)return Promise.resolve(c);const i=[],r=[],a=[];for(let u=0,d=e.length;u<d;u++){const p=e[u];if(n){const f=p.POSITION!==void 0?t.getDependency("accessor",p.POSITION):c.attributes.position;i.push(f)}if(s){const f=p.NORMAL!==void 0?t.getDependency("accessor",p.NORMAL):c.attributes.normal;r.push(f)}if(o){const f=p.COLOR_0!==void 0?t.getDependency("accessor",p.COLOR_0):c.attributes.color;a.push(f)}}return Promise.all([Promise.all(i),Promise.all(r),Promise.all(a)]).then(function(u){const d=u[0],p=u[1],f=u[2];return n&&(c.morphAttributes.position=d),s&&(c.morphAttributes.normal=p),o&&(c.morphAttributes.color=f),c.morphTargetsRelative=!0,c})}function js(c,e){if(c.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)c.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(c.morphTargetInfluences.length===t.length){c.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)c.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ys(c){let e;const t=c.extensions&&c.extensions[Z.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+vt(t.attributes):e=c.indices+":"+vt(c.attributes)+":"+c.mode,c.targets!==void 0)for(let n=0,s=c.targets.length;n<s;n++)e+=":"+vt(c.targets[n]);return e}function vt(c){let e="";const t=Object.keys(c).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+c[t[n]]+";";return e}function At(c){switch(c){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 Xs(c){return c.search(/\.jpe?g($|\?)/i)>0||c.search(/^data\:image\/jpeg/)===0?"image/jpeg":c.search(/\.webp($|\?)/i)>0||c.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Zs=new l.Matrix4;class Qs{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new _s,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=!1,o=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||s&&o<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){const r={scene:i[0][s.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:s.asset,parser:n,userData:{}};Fe(o,r,s),De(r,s),Promise.all(n._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||[],n=this.json.meshes||[];for(let s=0,o=t.length;s<o;s++){const i=t[s].joints;for(let r=0,a=i.length;r<a;r++)e[i[r]].isBone=!0}for(let s=0,o=e.length;s<o;s++){const i=e[s];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),o=(i,r)=>{const a=this.associations.get(i);a!=null&&this.associations.set(r,a);for(const[u,d]of i.children.entries())o(d,r.children[u])};return o(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const o=e(t[s]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":s=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(o,i){return n.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Z.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(o,i){n.load(l.LoaderUtils.resolveURL(t.uri,s.path),o,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const i=_t[s.type],r=Ge[s.componentType],a=s.normalized===!0,u=new r(s.count*i);return Promise.resolve(new l.BufferAttribute(u,i,a))}const o=[];return s.bufferView!==void 0?o.push(this.getDependency("bufferView",s.bufferView)):o.push(null),s.sparse!==void 0&&(o.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(o).then(function(i){const r=i[0],a=_t[s.type],u=Ge[s.componentType],d=u.BYTES_PER_ELEMENT,p=d*a,f=s.byteOffset||0,m=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,v=s.normalized===!0;let _,A;if(m&&m!==p){const M=Math.floor(f/m),O="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+M+":"+s.count;let b=t.cache.get(O);b||(_=new u(r,M*m,s.count*m/d),b=new l.InterleavedBuffer(_,m/d),t.cache.add(O,b)),A=new l.InterleavedBufferAttribute(b,a,f%m/d,v)}else r===null?_=new u(s.count*a):_=new u(r,f,s.count*a),A=new l.BufferAttribute(_,a,v);if(s.sparse!==void 0){const M=_t.SCALAR,O=Ge[s.sparse.indices.componentType],b=s.sparse.indices.byteOffset||0,g=s.sparse.values.byteOffset||0,T=new O(i[1],b,s.sparse.count*M),x=new u(i[2],g,s.sparse.count*a);r!==null&&(A=new l.BufferAttribute(A.array.slice(),A.itemSize,A.normalized));for(let y=0,w=T.length;y<w;y++){const D=T[y];if(A.setX(D,x[y*a]),a>=2&&A.setY(D,x[y*a+1]),a>=3&&A.setZ(D,x[y*a+2]),a>=4&&A.setW(D,x[y*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return A})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,i=t.images[o];let r=this.textureLoader;if(i.uri){const a=n.manager.getHandler(i.uri);a!==null&&(r=a)}return this.loadTextureImage(e,o,r)}loadTextureImage(e,t,n){const s=this,o=this.json,i=o.textures[e],r=o.images[t],a=(r.uri||r.bufferView)+":"+i.sampler;if(this.textureCache[a])return this.textureCache[a];const u=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=i.name||r.name||"",d.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(d.name=r.uri);const f=(o.samplers||{})[i.sampler]||{};return d.magFilter=Ht[f.magFilter]||l.LinearFilter,d.minFilter=Ht[f.minFilter]||l.LinearMipmapLinearFilter,d.wrapS=$t[f.wrapS]||l.RepeatWrapping,d.wrapT=$t[f.wrapT]||l.RepeatWrapping,s.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[a]=u,u}loadImageSource(e,t){const n=this,s=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(p=>p.clone());const i=s.images[e],r=self.URL||self.webkitURL;let a=i.uri||"",u=!1;if(i.bufferView!==void 0)a=n.getDependency("bufferView",i.bufferView).then(function(p){u=!0;const f=new Blob([p],{type:i.mimeType});return a=r.createObjectURL(f),a});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(a).then(function(p){return new Promise(function(f,m){let v=f;t.isImageBitmapLoader===!0&&(v=function(_){const A=new l.Texture(_);A.needsUpdate=!0,f(A)}),t.load(l.LoaderUtils.resolveURL(p,o.path),v,void 0,m)})}).then(function(p){return u===!0&&r.revokeObjectURL(a),p.userData.mimeType=i.mimeType||Xs(i.uri),p}).catch(function(p){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),p});return this.sourceCache[e]=d,d}assignTexture(e,t,n,s){const o=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),o.extensions[Z.KHR_TEXTURE_TRANSFORM]){const r=n.extensions!==void 0?n.extensions[Z.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=o.associations.get(i);i=o.extensions[Z.KHR_TEXTURE_TRANSFORM].extendTexture(i,r),o.associations.set(i,a)}}return s!==void 0&&("colorSpace"in i?i.colorSpace=s===3001?"srgb":"srgb-linear":i.encoding=s),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new l.PointsMaterial,l.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(r,a)),n=a}else if(e.isLine){const r="LineBasicMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new l.LineBasicMaterial,l.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(r,a)),n=a}if(s||o||i){let r="ClonedMaterial:"+n.uuid+":";s&&(r+="derivative-tangents:"),o&&(r+="vertex-colors:"),i&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=n.clone(),o&&(a.vertexColors=!0),i&&(a.flatShading=!0),s&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(n))),n=a}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,o=n.materials[e];let i;const r={},a=o.extensions||{},u=[];if(a[Z.KHR_MATERIALS_UNLIT]){const p=s[Z.KHR_MATERIALS_UNLIT];i=p.getMaterialType(),u.push(p.extendParams(r,o,t))}else{const p=o.pbrMetallicRoughness||{};if(r.color=new l.Color(1,1,1),r.opacity=1,Array.isArray(p.baseColorFactor)){const f=p.baseColorFactor;r.color.fromArray(f),r.opacity=f[3]}p.baseColorTexture!==void 0&&u.push(t.assignTexture(r,"map",p.baseColorTexture,3001)),r.metalness=p.metallicFactor!==void 0?p.metallicFactor:1,r.roughness=p.roughnessFactor!==void 0?p.roughnessFactor:1,p.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(r,"metalnessMap",p.metallicRoughnessTexture)),u.push(t.assignTexture(r,"roughnessMap",p.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,r)})))}o.doubleSided===!0&&(r.side=l.DoubleSide);const d=o.alphaMode||wt.OPAQUE;if(d===wt.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,d===wt.MASK&&(r.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&i!==l.MeshBasicMaterial&&(u.push(t.assignTexture(r,"normalMap",o.normalTexture)),r.normalScale=new l.Vector2(1,1),o.normalTexture.scale!==void 0)){const p=o.normalTexture.scale;r.normalScale.set(p,p)}return o.occlusionTexture!==void 0&&i!==l.MeshBasicMaterial&&(u.push(t.assignTexture(r,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&i!==l.MeshBasicMaterial&&(r.emissive=new l.Color().fromArray(o.emissiveFactor)),o.emissiveTexture!==void 0&&i!==l.MeshBasicMaterial&&u.push(t.assignTexture(r,"emissiveMap",o.emissiveTexture,3001)),Promise.all(u).then(function(){const p=new i(r);return o.name&&(p.name=o.name),De(p,o),t.associations.set(p,{materials:e}),o.extensions&&Fe(s,p,o),p})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function o(r){return n[Z.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return en(a,r,t)})}const i=[];for(let r=0,a=e.length;r<a;r++){const u=e[r],d=Ys(u),p=s[d];if(p)i.push(p.promise);else{let f;u.extensions&&u.extensions[Z.KHR_DRACO_MESH_COMPRESSION]?f=o(u):f=en(new l.BufferGeometry,u,t),s[d]={primitive:u,promise:f},i.push(f)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,s=this.extensions,o=n.meshes[e],i=o.primitives,r=[];for(let a=0,u=i.length;a<u;a++){const d=i[a].material===void 0?Es(this.cache):this.getDependency("material",i[a].material);r.push(d)}return r.push(t.loadGeometries(i)),Promise.all(r).then(function(a){const u=a.slice(0,a.length-1),d=a[a.length-1],p=[];for(let m=0,v=d.length;m<v;m++){const _=d[m],A=i[m];let M;const O=u[m];if(A.mode===me.TRIANGLES||A.mode===me.TRIANGLE_STRIP||A.mode===me.TRIANGLE_FAN||A.mode===void 0)M=o.isSkinnedMesh===!0?new l.SkinnedMesh(_,O):new l.Mesh(_,O),M.isSkinnedMesh===!0&&M.normalizeSkinWeights(),A.mode===me.TRIANGLE_STRIP?M.geometry=zt(M.geometry,l.TriangleStripDrawMode):A.mode===me.TRIANGLE_FAN&&(M.geometry=zt(M.geometry,l.TriangleFanDrawMode));else if(A.mode===me.LINES)M=new l.LineSegments(_,O);else if(A.mode===me.LINE_STRIP)M=new l.Line(_,O);else if(A.mode===me.LINE_LOOP)M=new l.LineLoop(_,O);else if(A.mode===me.POINTS)M=new l.Points(_,O);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(M.geometry.morphAttributes).length>0&&js(M,o),M.name=t.createUniqueName(o.name||"mesh_"+e),De(M,o),A.extensions&&Fe(s,M,A),t.assignFinalMaterial(M),p.push(M)}for(let m=0,v=p.length;m<v;m++)t.associations.set(p[m],{meshes:e,primitives:m});if(p.length===1)return o.extensions&&Fe(s,p[0],o),p[0];const f=new l.Group;o.extensions&&Fe(s,f,o),t.associations.set(f,{meshes:e});for(let m=0,v=p.length;m<v;m++)f.add(p[m]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),De(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,o=t.joints.length;s<o;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const o=s.pop(),i=s,r=[],a=[];for(let u=0,d=i.length;u<d;u++){const p=i[u];if(p){r.push(p);const f=new l.Matrix4;o!==null&&f.fromArray(o.array,u*16),a.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new l.Skeleton(r,a)})}loadAnimation(e){const n=this.json.animations[e],s=n.name?n.name:"animation_"+e,o=[],i=[],r=[],a=[],u=[];for(let d=0,p=n.channels.length;d<p;d++){const f=n.channels[d],m=n.samplers[f.sampler],v=f.target,_=v.node,A=n.parameters!==void 0?n.parameters[m.input]:m.input,M=n.parameters!==void 0?n.parameters[m.output]:m.output;v.node!==void 0&&(o.push(this.getDependency("node",_)),i.push(this.getDependency("accessor",A)),r.push(this.getDependency("accessor",M)),a.push(m),u.push(v))}return Promise.all([Promise.all(o),Promise.all(i),Promise.all(r),Promise.all(a),Promise.all(u)]).then(function(d){const p=d[0],f=d[1],m=d[2],v=d[3],_=d[4],A=[];for(let M=0,O=p.length;M<O;M++){const b=p[M],g=f[M],T=m[M],x=v[M],y=_[M];if(b===void 0)continue;b.updateMatrix();let w;switch(Ce[y.path]){case Ce.weights:w=l.NumberKeyframeTrack;break;case Ce.rotation:w=l.QuaternionKeyframeTrack;break;case Ce.position:case Ce.scale:default:w=l.VectorKeyframeTrack;break}const D=b.name?b.name:b.uuid,k=x.interpolation!==void 0?Rs[x.interpolation]:l.InterpolateLinear,I=[];Ce[y.path]===Ce.weights?b.traverse(function(R){R.morphTargetInfluences&&I.push(R.name?R.name:R.uuid)}):I.push(D);let U=T.array;if(T.normalized){const R=At(U.constructor),H=new Float32Array(U.length);for(let E=0,ne=U.length;E<ne;E++)H[E]=U[E]*R;U=H}for(let R=0,H=I.length;R<H;R++){const E=new w(I[R]+"."+Ce[y.path],g.array,U,k);x.interpolation==="CUBICSPLINE"&&(E.createInterpolant=function(X){const ae=this instanceof l.QuaternionKeyframeTrack?zs:Jt;return new ae(this.times,this.values,this.getValueSize()/3,X)},E.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),A.push(E)}}return new l.AnimationClip(s,void 0,A)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(o){const i=n._getNodeRef(n.meshCache,s.mesh,o);return s.weights!==void 0&&i.traverse(function(r){if(r.isMesh)for(let a=0,u=s.weights.length;a<u;a++)r.morphTargetInfluences[a]=s.weights[a]}),i})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],o=n._loadNodeShallow(e),i=[],r=s.children||[];for(let u=0,d=r.length;u<d;u++)i.push(n.getDependency("node",r[u]));const a=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([o,Promise.all(i),a]).then(function(u){const d=u[0],p=u[1],f=u[2];f!==null&&d.traverse(function(m){m.isSkinnedMesh&&m.bind(f,Zs)});for(let m=0,v=p.length;m<v;m++)d.add(p[m]);return d})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],i=o.name?s.createUniqueName(o.name):"",r=[],a=s._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return a&&r.push(a),o.camera!==void 0&&r.push(s.getDependency("camera",o.camera).then(function(u){return s._getNodeRef(s.cameraCache,o.camera,u)})),s._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){r.push(u)}),this.nodeCache[e]=Promise.all(r).then(function(u){let d;if(o.isBone===!0?d=new l.Bone:u.length>1?d=new l.Group:u.length===1?d=u[0]:d=new l.Object3D,d!==u[0])for(let p=0,f=u.length;p<f;p++)d.add(u[p]);if(o.name&&(d.userData.name=o.name,d.name=i),De(d,o),o.extensions&&Fe(n,d,o),o.matrix!==void 0){const p=new l.Matrix4;p.fromArray(o.matrix),d.applyMatrix4(p)}else o.translation!==void 0&&d.position.fromArray(o.translation),o.rotation!==void 0&&d.quaternion.fromArray(o.rotation),o.scale!==void 0&&d.scale.fromArray(o.scale);return s.associations.has(d)||s.associations.set(d,{}),s.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,o=new l.Group;n.name&&(o.name=s.createUniqueName(n.name)),De(o,n),n.extensions&&Fe(t,o,n);const i=n.nodes||[],r=[];for(let a=0,u=i.length;a<u;a++)r.push(s.getDependency("node",i[a]));return Promise.all(r).then(function(a){for(let d=0,p=a.length;d<p;d++)o.add(a[d]);const u=d=>{const p=new Map;for(const[f,m]of s.associations)(f instanceof l.Material||f instanceof l.Texture)&&p.set(f,m);return d.traverse(f=>{const m=s.associations.get(f);m!=null&&p.set(f,m)}),p};return s.associations=u(o),o})}}function Ks(c,e,t){const n=e.attributes,s=new l.Box3;if(n.POSITION!==void 0){const r=t.json.accessors[n.POSITION],a=r.min,u=r.max;if(a!==void 0&&u!==void 0){if(s.set(new l.Vector3(a[0],a[1],a[2]),new l.Vector3(u[0],u[1],u[2])),r.normalized){const d=At(Ge[r.componentType]);s.min.multiplyScalar(d),s.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const r=new l.Vector3,a=new l.Vector3;for(let u=0,d=o.length;u<d;u++){const p=o[u];if(p.POSITION!==void 0){const f=t.json.accessors[p.POSITION],m=f.min,v=f.max;if(m!==void 0&&v!==void 0){if(a.setX(Math.max(Math.abs(m[0]),Math.abs(v[0]))),a.setY(Math.max(Math.abs(m[1]),Math.abs(v[1]))),a.setZ(Math.max(Math.abs(m[2]),Math.abs(v[2]))),f.normalized){const _=At(Ge[f.componentType]);a.multiplyScalar(_)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(r)}c.boundingBox=s;const i=new l.Sphere;s.getCenter(i.center),i.radius=s.min.distanceTo(s.max)/2,c.boundingSphere=i}function en(c,e,t){const n=e.attributes,s=[];function o(i,r){return t.getDependency("accessor",i).then(function(a){c.setAttribute(r,a)})}for(const i in n){const r=yt[i]||i.toLowerCase();r in c.attributes||s.push(o(n[i],r))}if(e.indices!==void 0&&!c.index){const i=t.getDependency("accessor",e.indices).then(function(r){c.setIndex(r)});s.push(i)}return De(c,e),Ks(c,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Gs(c,e.targets,t):c})}class tn extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:s=8,bevelThickness:o=10,font:i,height:r=50,size:a=100,lineHeight:u=1,letterSpacing:d=0,...p}=t;if(i===void 0)super();else{const f=i.generateShapes(e,a,{lineHeight:u,letterSpacing:d});super(f,{...p,bevelEnabled:n,bevelSize:s,bevelThickness:o,depth:r})}this.type="TextGeometry"}}const Ws={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
9
9
  varying vec2 vUv;
10
10
 
11
11
  void main() {
@@ -37,7 +37,7 @@
37
37
  gl_FragColor = sum;
38
38
 
39
39
  }
40
- `},Hs={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`
40
+ `},qs={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`
41
41
  varying vec2 vUv;
42
42
 
43
43
  void main() {
@@ -70,20 +70,20 @@
70
70
  gl_FragColor = sum;
71
71
 
72
72
  }
73
- `};function nn(c,e,t){const n=t.length-c-1;if(e>=t[n])return n-1;if(e<=t[c])return c;let s=c,o=n,i=Math.floor((s+o)/2);for(;e<t[i]||e>=t[i+1];)e<t[i]?o=i:s=i,i=Math.floor((s+o)/2);return i}function $s(c,e,t,n){const s=[],o=[],i=[];s[0]=1;for(let r=1;r<=t;++r){o[r]=e-n[c+1-r],i[r]=n[c+r]-e;let a=0;for(let u=0;u<r;++u){const d=i[u+1],p=o[r-u],f=s[u]/(d+p);s[u]=a+d*f,a=p*f}s[r]=a}return s}function eo(c,e,t,n){const s=nn(c,n,e),o=$s(s,n,c,e),i=new l.Vector4(0,0,0,0);for(let r=0;r<=c;++r){const a=t[s-c+r],u=o[r],d=a.w*u;i.x+=a.x*d,i.y+=a.y*d,i.z+=a.z*d,i.w+=a.w*u}return i}function to(c,e,t,n,s){const o=[];for(let p=0;p<=t;++p)o[p]=0;const i=[];for(let p=0;p<=n;++p)i[p]=o.slice(0);const r=[];for(let p=0;p<=t;++p)r[p]=o.slice(0);r[0][0]=1;const a=o.slice(0),u=o.slice(0);for(let p=1;p<=t;++p){a[p]=e-s[c+1-p],u[p]=s[c+p]-e;let f=0;for(let m=0;m<p;++m){const y=u[m+1],_=a[p-m];r[p][m]=y+_;const x=r[m][p-1]/r[p][m];r[m][p]=f+y*x,f=_*x}r[p][p]=f}for(let p=0;p<=t;++p)i[0][p]=r[p][t];for(let p=0;p<=t;++p){let f=0,m=1;const y=[];for(let _=0;_<=t;++_)y[_]=o.slice(0);y[0][0]=1;for(let _=1;_<=n;++_){let x=0;const S=p-_,O=t-_;p>=_&&(y[m][0]=y[f][0]/r[O+1][S],x=y[m][0]*r[S][O]);const M=S>=-1?1:-S,g=p-1<=O?_-1:t-p;for(let b=M;b<=g;++b)y[m][b]=(y[f][b]-y[f][b-1])/r[O+1][S+b],x+=y[m][b]*r[S+b][O];p<=O&&(y[m][_]=-y[f][_-1]/r[O+1][p],x+=y[m][_]*r[p][O]),i[_][p]=x;const A=f;f=m,m=A}}let d=t;for(let p=1;p<=n;++p){for(let f=0;f<=t;++f)i[p][f]*=d;d*=t-p}return i}function no(c,e,t,n,s){const o=s<c?s:c,i=[],r=nn(c,n,e),a=to(r,n,c,o,e),u=[];for(let d=0;d<t.length;++d){const p=t[d].clone(),f=p.w;p.x*=f,p.y*=f,p.z*=f,u[d]=p}for(let d=0;d<=o;++d){const p=u[r-c].clone().multiplyScalar(a[d][0]);for(let f=1;f<=c;++f)p.add(u[r-c+f].clone().multiplyScalar(a[d][f]));i[d]=p}for(let d=o+1;d<=s+1;++d)i[d]=new l.Vector4(0,0,0);return i}function so(c,e){let t=1;for(let s=2;s<=c;++s)t*=s;let n=1;for(let s=2;s<=e;++s)n*=s;for(let s=2;s<=c-e;++s)n*=s;return t/n}function oo(c){const e=c.length,t=[],n=[];for(let o=0;o<e;++o){const i=c[o];t[o]=new l.Vector3(i.x,i.y,i.z),n[o]=i.w}const s=[];for(let o=0;o<e;++o){const i=t[o].clone();for(let r=1;r<=o;++r)i.sub(s[o-r].clone().multiplyScalar(so(o,r)*n[r]));s[o]=i.divideScalar(n[0])}return s}function io(c,e,t,n,s){const o=no(c,e,t,n,s);return oo(o)}class sn extends l.Curve{constructor(e,t,n,s,o){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=s||0,this.endKnot=o||this.knots.length-1;for(let i=0;i<n.length;++i){const r=n[i];this.controlPoints[i]=new l.Vector4(r.x,r.y,r.z,r.w)}}getPoint(e,t){const n=t||new l.Vector3,s=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),o=eo(this.degree,this.knots,this.controlPoints,s);return o.w!=1&&o.divideScalar(o.w),n.set(o.x,o.y,o.z)}getTangent(e,t){const n=t||new l.Vector3,s=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),o=io(this.degree,this.knots,this.controlPoints,s,1);return n.copy(o[1]).normalize(),n}}let Y,ie,ue;class ro extends l.Loader{constructor(e){super(e)}load(e,t,n,s){const o=this,i=o.path===""?l.LoaderUtils.extractUrlBase(e):o.path,r=new l.FileLoader(this.manager);r.setPath(o.path),r.setResponseType("arraybuffer"),r.setRequestHeader(o.requestHeader),r.setWithCredentials(o.withCredentials),r.load(e,function(a){try{t(o.parse(a,i))}catch(u){s?s(u):console.error(u),o.manager.itemError(e)}},n,s)}parse(e,t){if(po(e))Y=new uo().parse(e);else{const s=hn(e);if(!fo(s))throw new Error("THREE.FBXLoader: Unknown format.");if(an(s)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+an(s));Y=new ho().parse(s)}const n=new l.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new ao(n,this.manager).parse(Y)}}class ao{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){ie=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),s=this.parseDeformers(),o=new lo().parse(s);return this.parseScene(s,o,n),ue}parseConnections(){const e=new Map;return"Connections"in Y&&Y.Connections.connections.forEach(function(n){const s=n[0],o=n[1],i=n[2];e.has(s)||e.set(s,{parents:[],children:[]});const r={ID:o,relationship:i};e.get(s).parents.push(r),e.has(o)||e.set(o,{parents:[],children:[]});const a={ID:s,relationship:i};e.get(o).children.push(a)}),e}parseImages(){const e={},t={};if("Video"in Y.Objects){const n=Y.Objects.Video;for(const s in n){const o=n[s],i=parseInt(s);if(e[i]=o.RelativeFilename||o.Filename,"Content"in o){const r=o.Content instanceof ArrayBuffer&&o.Content.byteLength>0,a=typeof o.Content=="string"&&o.Content!=="";if(r||a){const u=this.parseImage(n[s]);t[o.RelativeFilename||o.Filename]=u}}}}for(const n in e){const s=e[n];t[s]!==void 0?e[n]=t[s]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,s=n.slice(n.lastIndexOf(".")+1).toLowerCase();let o;switch(s){case"bmp":o="image/bmp";break;case"jpg":case"jpeg":o="image/jpeg";break;case"png":o="image/png";break;case"tif":o="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),o="image/tga";break;default:console.warn('FBXLoader: Image type "'+s+'" is not supported.');return}if(typeof t=="string")return"data:"+o+";base64,"+t;{const i=new Uint8Array(t);return window.URL.createObjectURL(new Blob([i],{type:o}))}}parseTextures(e){const t=new Map;if("Texture"in Y.Objects){const n=Y.Objects.Texture;for(const s in n){const o=this.parseTexture(n[s],e);t.set(parseInt(s),o)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const s=e.WrapModeU,o=e.WrapModeV,i=s!==void 0?s.value:0,r=o!==void 0?o.value:0;if(n.wrapS=i===0?l.RepeatWrapping:l.ClampToEdgeWrapping,n.wrapT=r===0?l.RepeatWrapping:l.ClampToEdgeWrapping,"Scaling"in e){const a=e.Scaling.value;n.repeat.x=a[0],n.repeat.y=a[1]}return n}loadTexture(e,t){let n;const s=this.textureLoader.path,o=ie.get(e.id).children;o!==void 0&&o.length>0&&t[o[0].ID]!==void 0&&(n=t[o[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let i;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),i=new l.Texture):(a.setPath(this.textureLoader.path),i=a.load(n))}else r==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),i=new l.Texture):i=this.textureLoader.load(n);return this.textureLoader.setPath(s),i}parseMaterials(e){const t=new Map;if("Material"in Y.Objects){const n=Y.Objects.Material;for(const s in n){const o=this.parseMaterial(n[s],e);o!==null&&t.set(parseInt(s),o)}}return t}parseMaterial(e,t){const n=e.id,s=e.attrName;let o=e.ShadingModel;if(typeof o=="object"&&(o=o.value),!ie.has(n))return null;const i=this.parseParameters(e,t,n);let r;switch(o.toLowerCase()){case"phong":r=new l.MeshPhongMaterial;break;case"lambert":r=new l.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),r=new l.MeshPhongMaterial;break}return r.setValues(i),r.name=s,r}parseParameters(e,t,n){const s={};e.BumpFactor&&(s.bumpScale=e.BumpFactor.value),e.Diffuse?s.color=new l.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(s.color=new l.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(s.displacementScale=e.DisplacementFactor.value),e.Emissive?s.emissive=new l.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(s.emissive=new l.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(s.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(s.opacity=parseFloat(e.Opacity.value)),s.opacity<1&&(s.transparent=!0),e.ReflectionFactor&&(s.reflectivity=e.ReflectionFactor.value),e.Shininess&&(s.shininess=e.Shininess.value),e.Specular?s.specular=new l.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(s.specular=new l.Color().fromArray(e.SpecularColor.value));const o=this;return ie.get(n).children.forEach(function(i){const r=i.relationship;switch(r){case"Bump":s.bumpMap=o.getTexture(t,i.ID);break;case"Maya|TEX_ao_map":s.aoMap=o.getTexture(t,i.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":s.map=o.getTexture(t,i.ID),s.map!==void 0&&("colorSpace"in s.map?s.map.colorSpace="srgb":s.map.encoding=3001);break;case"DisplacementColor":s.displacementMap=o.getTexture(t,i.ID);break;case"EmissiveColor":s.emissiveMap=o.getTexture(t,i.ID),s.emissiveMap!==void 0&&("colorSpace"in s.emissiveMap?s.emissiveMap.colorSpace="srgb":s.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":s.normalMap=o.getTexture(t,i.ID);break;case"ReflectionColor":s.envMap=o.getTexture(t,i.ID),s.envMap!==void 0&&(s.envMap.mapping=l.EquirectangularReflectionMapping,"colorSpace"in s.envMap?s.envMap.colorSpace="srgb":s.envMap.encoding=3001);break;case"SpecularColor":s.specularMap=o.getTexture(t,i.ID),s.specularMap!==void 0&&("colorSpace"in s.specularMap?s.specularMap.colorSpace="srgb":s.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":s.alphaMap=o.getTexture(t,i.ID),s.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r);break}}),s}getTexture(e,t){return"LayeredTexture"in Y.Objects&&t in Y.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 Y.Objects){const n=Y.Objects.Deformer;for(const s in n){const o=n[s],i=ie.get(parseInt(s));if(o.attrType==="Skin"){const r=this.parseSkeleton(i,n);r.ID=s,i.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),r.geometryID=i.parents[0].ID,e[s]=r}else if(o.attrType==="BlendShape"){const r={id:s};r.rawTargets=this.parseMorphTargets(i,n),r.id=s,i.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[s]=r}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(s){const o=t[s.ID];if(o.attrType!=="Cluster")return;const i={ID:s.ID,indices:[],weights:[],transformLink:new l.Matrix4().fromArray(o.TransformLink.a)};"Indexes"in o&&(i.indices=o.Indexes.a,i.weights=o.Weights.a),n.push(i)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let s=0;s<e.children.length;s++){const o=e.children[s],i=t[o.ID],r={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if(i.attrType!=="BlendShapeChannel")return;r.geoID=ie.get(parseInt(o.ID)).children.filter(function(a){return a.relationship===void 0})[0].ID,n.push(r)}return n}parseScene(e,t,n){ue=new l.Group;const s=this.parseModels(e.skeletons,t,n),o=Y.Objects.Model,i=this;s.forEach(function(a){const u=o[a.ID];i.setLookAtProperties(a,u),ie.get(a.ID).parents.forEach(function(p){const f=s.get(p.ID);f!==void 0&&f.add(a)}),a.parent===null&&ue.add(a)}),this.bindSkeleton(e.skeletons,t,s),this.createAmbientLight(),ue.traverse(function(a){if(a.userData.transformData){a.parent&&(a.userData.transformData.parentMatrix=a.parent.matrix,a.userData.transformData.parentMatrixWorld=a.parent.matrixWorld);const u=ln(a.userData.transformData);a.applyMatrix4(u),a.updateWorldMatrix()}});const r=new co().parse();ue.children.length===1&&ue.children[0].isGroup&&(ue.children[0].animations=r,ue=ue.children[0]),ue.animations=r}parseModels(e,t,n){const s=new Map,o=Y.Objects.Model;for(const i in o){const r=parseInt(i),a=o[i],u=ie.get(r);let d=this.buildSkeleton(u,e,r,a.attrName);if(!d){switch(a.attrType){case"Camera":d=this.createCamera(u);break;case"Light":d=this.createLight(u);break;case"Mesh":d=this.createMesh(u,t,n);break;case"NurbsCurve":d=this.createCurve(u,t);break;case"LimbNode":case"Root":d=new l.Bone;break;case"Null":default:d=new l.Group;break}d.name=a.attrName?l.PropertyBinding.sanitizeNodeName(a.attrName):"",d.ID=r}this.getTransformData(d,a),s.set(r,d)}return s}buildSkeleton(e,t,n,s){let o=null;return e.parents.forEach(function(i){for(const r in t){const a=t[r];a.rawBones.forEach(function(u,d){if(u.ID===i.ID){const p=o;o=new l.Bone,o.matrixWorld.copy(u.transformLink),o.name=s?l.PropertyBinding.sanitizeNodeName(s):"",o.ID=n,a.bones[d]=o,p!==null&&o.add(p)}})}}),o}createCamera(e){let t,n;if(e.children.forEach(function(s){const o=Y.Objects.NodeAttribute[s.ID];o!==void 0&&(n=o)}),n===void 0)t=new l.Object3D;else{let s=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(s=1);let o=1;n.NearPlane!==void 0&&(o=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let r=window.innerWidth,a=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(r=n.AspectWidth.value,a=n.AspectHeight.value);const u=r/a;let d=45;n.FieldOfView!==void 0&&(d=n.FieldOfView.value);const p=n.FocalLength?n.FocalLength.value:null;switch(s){case 0:t=new l.PerspectiveCamera(d,u,o,i),p!==null&&t.setFocalLength(p);break;case 1:t=new l.OrthographicCamera(-r/2,r/2,a/2,-a/2,o,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+s+"."),t=new l.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(s){const o=Y.Objects.NodeAttribute[s.ID];o!==void 0&&(n=o)}),n===void 0)t=new l.Object3D;else{let s;n.LightType===void 0?s=0:s=n.LightType.value;let o=16777215;n.Color!==void 0&&(o=new l.Color().fromArray(n.Color.value));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let r=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?r=0:r=n.FarAttenuationEnd.value);const a=1;switch(s){case 0:t=new l.PointLight(o,i,r,a);break;case 1:t=new l.DirectionalLight(o,i);break;case 2:let u=Math.PI/3;n.InnerAngle!==void 0&&(u=l.MathUtils.degToRad(n.InnerAngle.value));let d=0;n.OuterAngle!==void 0&&(d=l.MathUtils.degToRad(n.OuterAngle.value),d=Math.max(d,1)),t=new l.SpotLight(o,i,r,u,d,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new l.PointLight(o,i);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let s,o=null,i=null;const r=[];return e.children.forEach(function(a){t.has(a.ID)&&(o=t.get(a.ID)),n.has(a.ID)&&r.push(n.get(a.ID))}),r.length>1?i=r:r.length>0?i=r[0]:(i=new l.MeshPhongMaterial({color:13421772}),r.push(i)),"color"in o.attributes&&r.forEach(function(a){a.vertexColors=!0}),o.FBX_Deformer?(s=new l.SkinnedMesh(o,i),s.normalizeSkinWeights()):s=new l.Mesh(o,i),s}createCurve(e,t){const n=e.children.reduce(function(o,i){return t.has(i.ID)&&(o=t.get(i.ID)),o},null),s=new l.LineBasicMaterial({color:3342591,linewidth:1});return new l.Line(n,s)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=cn(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&ie.get(e.ID).children.forEach(function(s){if(s.relationship==="LookAtProperty"){const o=Y.Objects.Model[s.ID];if("Lcl_Translation"in o){const i=o.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),ue.add(e.target)):e.lookAt(new l.Vector3().fromArray(i))}}})}bindSkeleton(e,t,n){const s=this.parsePoseNodes();for(const o in e){const i=e[o];ie.get(parseInt(i.ID)).parents.forEach(function(a){if(t.has(a.ID)){const u=a.ID;ie.get(u).parents.forEach(function(p){n.has(p.ID)&&n.get(p.ID).bind(new l.Skeleton(i.bones),s[p.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in Y.Objects){const t=Y.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const s=t[n].PoseNode;Array.isArray(s)?s.forEach(function(o){e[o.Node]=new l.Matrix4().fromArray(o.Matrix.a)}):e[s.Node]=new l.Matrix4().fromArray(s.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Y&&"AmbientColor"in Y.GlobalSettings){const e=Y.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],s=e[2];if(t!==0||n!==0||s!==0){const o=new l.Color(t,n,s);ue.add(new l.AmbientLight(o,1))}}}}class lo{parse(e){const t=new Map;if("Geometry"in Y.Objects){const n=Y.Objects.Geometry;for(const s in n){const o=ie.get(parseInt(s)),i=this.parseGeometry(o,n[s],e);t.set(parseInt(s),i)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const s=n.skeletons,o=[],i=e.parents.map(function(p){return Y.Objects.Model[p.ID]});if(i.length===0)return;const r=e.children.reduce(function(p,f){return s[f.ID]!==void 0&&(p=s[f.ID]),p},null);e.children.forEach(function(p){n.morphTargets[p.ID]!==void 0&&o.push(n.morphTargets[p.ID])});const a=i[0],u={};"RotationOrder"in a&&(u.eulerOrder=cn(a.RotationOrder.value)),"InheritType"in a&&(u.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(u.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(u.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(u.scale=a.GeometricScaling.value);const d=ln(u);return this.genGeometry(t,r,o,d)}genGeometry(e,t,n,s){const o=new l.BufferGeometry;e.attrName&&(o.name=e.attrName);const i=this.parseGeoNode(e,t),r=this.genBuffers(i),a=new l.Float32BufferAttribute(r.vertex,3);if(a.applyMatrix4(s),o.setAttribute("position",a),r.colors.length>0&&o.setAttribute("color",new l.Float32BufferAttribute(r.colors,3)),t&&(o.setAttribute("skinIndex",new l.Uint16BufferAttribute(r.weightsIndices,4)),o.setAttribute("skinWeight",new l.Float32BufferAttribute(r.vertexWeights,4)),o.FBX_Deformer=t),r.normal.length>0){const u=new l.Matrix3().getNormalMatrix(s),d=new l.Float32BufferAttribute(r.normal,3);d.applyNormalMatrix(u),o.setAttribute("normal",d)}if(r.uvs.forEach(function(u,d){let p="uv"+(d+1).toString();d===0&&(p="uv"),o.setAttribute(p,new l.Float32BufferAttribute(r.uvs[d],2))}),i.material&&i.material.mappingType!=="AllSame"){let u=r.materialIndex[0],d=0;if(r.materialIndex.forEach(function(p,f){p!==u&&(o.addGroup(d,f-d,u),u=p,d=f)}),o.groups.length>0){const p=o.groups[o.groups.length-1],f=p.start+p.count;f!==r.materialIndex.length&&o.addGroup(f,r.materialIndex.length-f,u)}o.groups.length===0&&o.addGroup(0,r.materialIndex.length,r.materialIndex[0])}return this.addMorphTargets(o,e,n,s),o}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let s=0;for(;e.LayerElementUV[s];)e.LayerElementUV[s].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[s])),s++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(s,o){s.indices.forEach(function(i,r){n.weightTable[i]===void 0&&(n.weightTable[i]=[]),n.weightTable[i].push({id:o,weight:s.weights[r]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,s=0,o=!1,i=[],r=[],a=[],u=[],d=[],p=[];const f=this;return e.vertexIndices.forEach(function(m,y){let _,x=!1;m<0&&(m=m^-1,x=!0);let S=[],O=[];if(i.push(m*3,m*3+1,m*3+2),e.color){const M=ot(y,n,m,e.color);a.push(M[0],M[1],M[2])}if(e.skeleton){if(e.weightTable[m]!==void 0&&e.weightTable[m].forEach(function(M){O.push(M.weight),S.push(M.id)}),O.length>4){o||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),o=!0);const M=[0,0,0,0],g=[0,0,0,0];O.forEach(function(A,b){let w=A,v=S[b];g.forEach(function(C,k,I){if(w>C){I[k]=w,w=C;const U=M[k];M[k]=v,v=U}})}),S=M,O=g}for(;O.length<4;)O.push(0),S.push(0);for(let M=0;M<4;++M)d.push(O[M]),p.push(S[M])}if(e.normal){const M=ot(y,n,m,e.normal);r.push(M[0],M[1],M[2])}e.material&&e.material.mappingType!=="AllSame"&&(_=ot(y,n,m,e.material)[0]),e.uv&&e.uv.forEach(function(M,g){const A=ot(y,n,m,M);u[g]===void 0&&(u[g]=[]),u[g].push(A[0]),u[g].push(A[1])}),s++,x&&(f.genFace(t,e,i,_,r,a,u,d,p,s),n++,s=0,i=[],r=[],a=[],u=[],d=[],p=[])}),t}genFace(e,t,n,s,o,i,r,a,u,d){for(let p=2;p<d;p++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(p-1)*3]]),e.vertex.push(t.vertexPositions[n[(p-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(p-1)*3+2]]),e.vertex.push(t.vertexPositions[n[p*3]]),e.vertex.push(t.vertexPositions[n[p*3+1]]),e.vertex.push(t.vertexPositions[n[p*3+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[(p-1)*4]),e.vertexWeights.push(a[(p-1)*4+1]),e.vertexWeights.push(a[(p-1)*4+2]),e.vertexWeights.push(a[(p-1)*4+3]),e.vertexWeights.push(a[p*4]),e.vertexWeights.push(a[p*4+1]),e.vertexWeights.push(a[p*4+2]),e.vertexWeights.push(a[p*4+3]),e.weightsIndices.push(u[0]),e.weightsIndices.push(u[1]),e.weightsIndices.push(u[2]),e.weightsIndices.push(u[3]),e.weightsIndices.push(u[(p-1)*4]),e.weightsIndices.push(u[(p-1)*4+1]),e.weightsIndices.push(u[(p-1)*4+2]),e.weightsIndices.push(u[(p-1)*4+3]),e.weightsIndices.push(u[p*4]),e.weightsIndices.push(u[p*4+1]),e.weightsIndices.push(u[p*4+2]),e.weightsIndices.push(u[p*4+3])),t.color&&(e.colors.push(i[0]),e.colors.push(i[1]),e.colors.push(i[2]),e.colors.push(i[(p-1)*3]),e.colors.push(i[(p-1)*3+1]),e.colors.push(i[(p-1)*3+2]),e.colors.push(i[p*3]),e.colors.push(i[p*3+1]),e.colors.push(i[p*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(s),e.materialIndex.push(s),e.materialIndex.push(s)),t.normal&&(e.normal.push(o[0]),e.normal.push(o[1]),e.normal.push(o[2]),e.normal.push(o[(p-1)*3]),e.normal.push(o[(p-1)*3+1]),e.normal.push(o[(p-1)*3+2]),e.normal.push(o[p*3]),e.normal.push(o[p*3+1]),e.normal.push(o[p*3+2])),t.uv&&t.uv.forEach(function(f,m){e.uvs[m]===void 0&&(e.uvs[m]=[]),e.uvs[m].push(r[m][0]),e.uvs[m].push(r[m][1]),e.uvs[m].push(r[m][(p-1)*2]),e.uvs[m].push(r[m][(p-1)*2+1]),e.uvs[m].push(r[m][p*2]),e.uvs[m].push(r[m][p*2+1])})}addMorphTargets(e,t,n,s){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const o=this;n.forEach(function(i){i.rawTargets.forEach(function(r){const a=Y.Objects.Geometry[r.geoID];a!==void 0&&o.genMorphGeometry(e,t,a,s,r.name)})})}genMorphGeometry(e,t,n,s,o){const i=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],r=n.Vertices!==void 0?n.Vertices.a:[],a=n.Indexes!==void 0?n.Indexes.a:[],u=e.attributes.position.count*3,d=new Float32Array(u);for(let y=0;y<a.length;y++){const _=a[y]*3;d[_]=r[y*3],d[_+1]=r[y*3+1],d[_+2]=r[y*3+2]}const p={vertexIndices:i,vertexPositions:d},f=this.genBuffers(p),m=new l.Float32BufferAttribute(f.vertex,3);m.name=o||n.attrName,m.applyMatrix4(s),e.morphAttributes.position.push(m)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Normals.a;let o=[];return n==="IndexToDirect"&&("NormalIndex"in e?o=e.NormalIndex.a:"NormalsIndex"in e&&(o=e.NormalsIndex.a)),{dataSize:3,buffer:s,indices:o,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.UV.a;let o=[];return n==="IndexToDirect"&&(o=e.UVIndex.a),{dataSize:2,buffer:s,indices:o,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Colors.a;let o=[];return n==="IndexToDirect"&&(o=e.ColorIndex.a),{dataSize:4,buffer:s,indices:o,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const s=e.Materials.a,o=[];for(let i=0;i<s.length;++i)o.push(i);return{dataSize:1,buffer:s,indices:o,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(sn===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 l.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 l.BufferGeometry;const n=t-1,s=e.KnotVector.a,o=[],i=e.Points.a;for(let p=0,f=i.length;p<f;p+=4)o.push(new l.Vector4().fromArray(i,p));let r,a;if(e.Form==="Closed")o.push(o[0]);else if(e.Form==="Periodic"){r=n,a=s.length-1-r;for(let p=0;p<n;++p)o.push(o[p])}const d=new sn(n,s,o,r,a).getPoints(o.length*12);return new l.BufferGeometry().setFromPoints(d)}}class co{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const s=t[n],o=this.addClip(s);e.push(o)}return e}parseClips(){if(Y.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Y.Objects.AnimationCurveNode,t=new Map;for(const n in e){const s=e[n];if(s.attrName.match(/S|R|T|DeformPercent/)!==null){const o={id:s.id,attr:s.attrName,curves:{}};t.set(o.id,o)}}return t}parseAnimationCurves(e){const t=Y.Objects.AnimationCurve;for(const n in t){const s={id:t[n].id,times:t[n].KeyTime.a.map(mo),values:t[n].KeyValueFloat.a},o=ie.get(s.id);if(o!==void 0){const i=o.parents[0].ID,r=o.parents[0].relationship;r.match(/X/)?e.get(i).curves.x=s:r.match(/Y/)?e.get(i).curves.y=s:r.match(/Z/)?e.get(i).curves.z=s:r.match(/d|DeformPercent/)&&e.has(i)&&(e.get(i).curves.morph=s)}}}parseAnimationLayers(e){const t=Y.Objects.AnimationLayer,n=new Map;for(const s in t){const o=[],i=ie.get(parseInt(s));i!==void 0&&(i.children.forEach(function(a,u){if(e.has(a.ID)){const d=e.get(a.ID);if(d.curves.x!==void 0||d.curves.y!==void 0||d.curves.z!==void 0){if(o[u]===void 0){const p=ie.get(a.ID).parents.filter(function(f){return f.relationship!==void 0})[0].ID;if(p!==void 0){const f=Y.Objects.Model[p.toString()];if(f===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",a);return}const m={modelName:f.attrName?l.PropertyBinding.sanitizeNodeName(f.attrName):"",ID:f.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ue.traverse(function(y){y.ID===f.id&&(m.transform=y.matrix,y.userData.transformData&&(m.eulerOrder=y.userData.transformData.eulerOrder))}),m.transform||(m.transform=new l.Matrix4),"PreRotation"in f&&(m.preRotation=f.PreRotation.value),"PostRotation"in f&&(m.postRotation=f.PostRotation.value),o[u]=m}}o[u]&&(o[u][d.attr]=d)}else if(d.curves.morph!==void 0){if(o[u]===void 0){const p=ie.get(a.ID).parents.filter(function(S){return S.relationship!==void 0})[0].ID,f=ie.get(p).parents[0].ID,m=ie.get(f).parents[0].ID,y=ie.get(m).parents[0].ID,_=Y.Objects.Model[y],x={modelName:_.attrName?l.PropertyBinding.sanitizeNodeName(_.attrName):"",morphName:Y.Objects.Deformer[p].attrName};o[u]=x}o[u][d.attr]=d}}}),n.set(parseInt(s),o))}return n}parseAnimStacks(e){const t=Y.Objects.AnimationStack,n={};for(const s in t){const o=ie.get(parseInt(s)).children;o.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const i=e.get(o[0].ID);n[s]={name:t[s].attrName,layer:i}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(s){t=t.concat(n.generateTracks(s))}),new l.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new l.Vector3,s=new l.Quaternion,o=new l.Vector3;if(e.transform&&e.transform.decompose(n,s,o),n=n.toArray(),s=new l.Euler().setFromQuaternion(s,e.eulerOrder).toArray(),o=o.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");i!==void 0&&t.push(i)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const i=this.generateRotationTrack(e.modelName,e.R.curves,s,e.preRotation,e.postRotation,e.eulerOrder);i!==void 0&&t.push(i)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.S.curves,o,"scale");i!==void 0&&t.push(i)}if(e.DeformPercent!==void 0){const i=this.generateMorphTrack(e);i!==void 0&&t.push(i)}return t}generateVectorTrack(e,t,n,s){const o=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(o,t,n);return new l.VectorKeyframeTrack(e+"."+s,o,i)}generateRotationTrack(e,t,n,s,o,i){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(l.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(l.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(l.MathUtils.degToRad));const r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,n);s!==void 0&&(s=s.map(l.MathUtils.degToRad),s.push(i),s=new l.Euler().fromArray(s),s=new l.Quaternion().setFromEuler(s)),o!==void 0&&(o=o.map(l.MathUtils.degToRad),o.push(i),o=new l.Euler().fromArray(o),o=new l.Quaternion().setFromEuler(o).invert());const u=new l.Quaternion,d=new l.Euler,p=[];for(let f=0;f<a.length;f+=3)d.set(a[f],a[f+1],a[f+2],i),u.setFromEuler(d),s!==void 0&&u.premultiply(s),o!==void 0&&u.multiply(o),u.toArray(p,f/3*4);return new l.QuaternionKeyframeTrack(e+".quaternion",r,p)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(o){return o/100}),s=ue.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new l.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+s+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,s){return n-s}),t.length>1){let n=1,s=t[0];for(let o=1;o<t.length;o++){const i=t[o];i!==s&&(t[n]=i,s=i,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const s=n,o=[];let i=-1,r=-1,a=-1;return e.forEach(function(u){if(t.x&&(i=t.x.times.indexOf(u)),t.y&&(r=t.y.times.indexOf(u)),t.z&&(a=t.z.times.indexOf(u)),i!==-1){const d=t.x.values[i];o.push(d),s[0]=d}else o.push(s[0]);if(r!==-1){const d=t.y.values[r];o.push(d),s[1]=d}else o.push(s[1]);if(a!==-1){const d=t.z.values[a];o.push(d),s[2]=d}else o.push(s[2])}),o}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],s=e.values[t]-n,o=Math.abs(s);if(o>=180){const i=o/180,r=s/i;let a=n+r;const u=e.times[t-1],p=(e.times[t]-u)/i;let f=u+p;const m=[],y=[];for(;f<e.times[t];)m.push(f),f+=p,y.push(a),a+=r;e.times=un(e.times,t,m),e.values=un(e.values,t,y)}}}}class ho{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 rn,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(s,o){const i=s.match(/^[\s\t]*;/),r=s.match(/^[\s\t]*$/);if(i||r)return;const a=s.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),u=s.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),d=s.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(s,a):u?t.parseNodeProperty(s,u,n[++o]):d?t.popStack():s.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(s)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),s=t[2].split(",").map(function(a){return a.trim().replace(/^"/,"").replace(/"$/,"")}),o={name:n},i=this.parseNodeAttr(s),r=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,o):n in r?(n==="PoseNode"?r.PoseNode.push(o):r[n].id!==void 0&&(r[n]={},r[n][r[n].id]=r[n]),i.id!==""&&(r[n][i.id]=o)):typeof i.id=="number"?(r[n]={},r[n][i.id]=o):n!=="Properties70"&&(n==="PoseNode"?r[n]=[o]:r[n]=o),typeof i.id=="number"&&(o.id=i.id),i.name!==""&&(o.attrName=i.name),i.type!==""&&(o.attrType=i.type),this.pushStack(o)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",s="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),s=e[2]),{id:t,name:n,type:s}}parseNodeProperty(e,t,n){let s=t[1].replace(/^"/,"").replace(/"$/,"").trim(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();s==="Content"&&o===","&&(o=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if(i.name==="Properties70"){this.parseNodeSpecialProperty(e,s,o);return}if(s==="C"){const a=o.split(",").slice(1),u=parseInt(a[0]),d=parseInt(a[1]);let p=o.split(",").slice(3);p=p.map(function(f){return f.trim().replace(/^"/,"")}),s="connections",o=[u,d],_o(o,p),i[s]===void 0&&(i[s]=[])}s==="Node"&&(i.id=o),s in i&&Array.isArray(i[s])?i[s].push(o):s!=="a"?i[s]=o:i.a=o,this.setCurrentProp(i,s),s==="a"&&o.slice(-1)!==","&&(i.a=Mt(o))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Mt(t.a))}parseNodeSpecialProperty(e,t,n){const s=n.split('",').map(function(d){return d.trim().replace(/^\"/,"").replace(/\s/,"_")}),o=s[0],i=s[1],r=s[2],a=s[3];let u=s[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":u=parseFloat(u);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":u=Mt(u);break}this.getPrevNode()[o]={type:i,type2:r,flag:a,value:u},this.setCurrentProp(this.getPrevNode(),o)}}class uo{parse(e){const t=new on(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const s=new rn;for(;!this.endOfContent(t);){const o=this.parseNode(t,n);o!==null&&s.add(o.name,o)}return s}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},s=t>=7500?e.getUint64():e.getUint32(),o=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),r=e.getString(i);if(s===0)return null;const a=[];for(let f=0;f<o;f++)a.push(this.parseProperty(e));const u=a.length>0?a[0]:"",d=a.length>1?a[1]:"",p=a.length>2?a[2]:"";for(n.singleProperty=o===1&&e.getOffset()===s;s>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(r,n,f)}return n.propertyList=a,typeof u=="number"&&(n.id=u),d!==""&&(n.attrName=d),p!==""&&(n.attrType=p),r!==""&&(n.name=r),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const s=n.propertyList[0];Array.isArray(s)?(t[n.name]=n,n.a=s):t[n.name]=s}else if(e==="Connections"&&n.name==="C"){const s=[];n.propertyList.forEach(function(o,i){i!==0&&s.push(o)}),t.connections===void 0&&(t.connections=[]),t.connections.push(s)}else if(n.name==="Properties70")Object.keys(n).forEach(function(o){t[o]=n[o]});else if(e==="Properties70"&&n.name==="P"){let s=n.propertyList[0],o=n.propertyList[1];const i=n.propertyList[2],r=n.propertyList[3];let a;s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),o.indexOf("Lcl ")===0&&(o=o.replace("Lcl ","Lcl_")),o==="Color"||o==="ColorRGB"||o==="Vector"||o==="Vector3D"||o.indexOf("Lcl_")===0?a=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:a=n.propertyList[4],t[s]={type:o,type2:i,flag:r,value:a}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const s=e.getUint32(),o=e.getUint32(),i=e.getUint32();if(o===0)switch(t){case"b":case"c":return e.getBooleanArray(s);case"d":return e.getFloat64Array(s);case"f":return e.getFloat32Array(s);case"i":return e.getInt32Array(s);case"l":return e.getInt64Array(s)}const r=ns(new Uint8Array(e.getArrayBuffer(i))),a=new on(r.buffer);switch(t){case"b":case"c":return a.getBooleanArray(s);case"d":return a.getFloat64Array(s);case"f":return a.getFloat32Array(s);case"i":return a.getInt32Array(s);case"l":return a.getInt64Array(s)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class on{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let s=0;s<e;s++)t[s]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),l.LoaderUtils.decodeText(new Uint8Array(t))}}class rn{add(e,t){this[e]=t}}function po(c){const e="Kaydara FBX Binary \0";return c.byteLength>=e.length&&e===hn(c,0,e.length)}function fo(c){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(s){const o=c[s-1];return c=c.slice(t+s),t++,o}for(let s=0;s<e.length;++s)if(n(1)===e[s])return!1;return!0}function an(c){const e=/FBXVersion: (\d+)/,t=c.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function mo(c){return c/46186158e3}const go=[];function ot(c,e,t,n){let s;switch(n.mappingType){case"ByPolygonVertex":s=c;break;case"ByPolygon":s=e;break;case"ByVertice":s=t;break;case"AllSame":s=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(s=n.indices[s]);const o=s*n.dataSize,i=o+n.dataSize;return yo(go,n.buffer,o,i)}const xt=new l.Euler,Ge=new l.Vector3;function ln(c){const e=new l.Matrix4,t=new l.Matrix4,n=new l.Matrix4,s=new l.Matrix4,o=new l.Matrix4,i=new l.Matrix4,r=new l.Matrix4,a=new l.Matrix4,u=new l.Matrix4,d=new l.Matrix4,p=new l.Matrix4,f=new l.Matrix4,m=c.inheritType?c.inheritType:0;if(c.translation&&e.setPosition(Ge.fromArray(c.translation)),c.preRotation){const k=c.preRotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),t.makeRotationFromEuler(xt.fromArray(k))}if(c.rotation){const k=c.rotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),n.makeRotationFromEuler(xt.fromArray(k))}if(c.postRotation){const k=c.postRotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),s.makeRotationFromEuler(xt.fromArray(k)),s.invert()}c.scale&&o.scale(Ge.fromArray(c.scale)),c.scalingOffset&&r.setPosition(Ge.fromArray(c.scalingOffset)),c.scalingPivot&&i.setPosition(Ge.fromArray(c.scalingPivot)),c.rotationOffset&&a.setPosition(Ge.fromArray(c.rotationOffset)),c.rotationPivot&&u.setPosition(Ge.fromArray(c.rotationPivot)),c.parentMatrixWorld&&(p.copy(c.parentMatrix),d.copy(c.parentMatrixWorld));const y=t.clone().multiply(n).multiply(s),_=new l.Matrix4;_.extractRotation(d);const x=new l.Matrix4;x.copyPosition(d);const S=x.clone().invert().multiply(d),O=_.clone().invert().multiply(S),M=o,g=new l.Matrix4;if(m===0)g.copy(_).multiply(y).multiply(O).multiply(M);else if(m===1)g.copy(_).multiply(O).multiply(y).multiply(M);else{const I=new l.Matrix4().scale(new l.Vector3().setFromMatrixScale(p)).clone().invert(),U=O.clone().multiply(I);g.copy(_).multiply(y).multiply(U).multiply(M)}const A=u.clone().invert(),b=i.clone().invert();let w=e.clone().multiply(a).multiply(u).multiply(t).multiply(n).multiply(s).multiply(A).multiply(r).multiply(i).multiply(o).multiply(b);const v=new l.Matrix4().copyPosition(w),C=d.clone().multiply(v);return f.copyPosition(C),w=f.clone().multiply(g),w.premultiply(d.invert()),w}function cn(c){c=c||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return c===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[c]}function Mt(c){return c.split(",").map(function(t){return parseFloat(t)})}function hn(c,e,t){return e===void 0&&(e=0),t===void 0&&(t=c.byteLength),l.LoaderUtils.decodeText(new Uint8Array(c,e,t))}function _o(c,e){for(let t=0,n=c.length,s=e.length;t<s;t++,n++)c[n]=e[t]}function yo(c,e,t,n){for(let s=t,o=0;s<n;s++,o++)c[o]=e[s];return c}function un(c,e,t){return c.slice(0,e).concat(t).concat(c.slice(e))}var wo=Object.defineProperty,vo=(c,e,t)=>e in c?wo(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,bt=(c,e,t)=>(vo(c,typeof e!="symbol"?e+"":e,t),t);class Ao extends l.Loader{constructor(e){super(e)}load(e,t,n,s){const o=new l.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,i=>{if(typeof i!="string")throw new Error("unsupported data type");const r=JSON.parse(i),a=this.parse(r);t&&t(a)},n,s)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new Tt(e)}}class Tt{constructor(e){bt(this,"data"),this.data=e}generateShapes(e,t=100,n){const s=[],o={letterSpacing:0,lineHeight:1,...n},i=xo(e,t,this.data,o);for(let r=0,a=i.length;r<a;r++)Array.prototype.push.apply(s,i[r].toShapes(!1));return s}}bt(Tt,"isFont"),bt(Tt,"type");function xo(c,e,t,n){const s=Array.from(c),o=e/t.resolution,i=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*o,r=[];let a=0,u=0;for(let d=0;d<s.length;d++){const p=s[d];if(p===`
74
- `)a=0,u-=i*n.lineHeight;else{const f=Mo(p,o,a,u,t);f&&(a+=f.offsetX+n.letterSpacing,r.push(f.path))}}return r}function Mo(c,e,t,n,s){const o=s.glyphs[c]||s.glyphs["?"];if(!o){console.error('THREE.Font: character "'+c+'" does not exists in font family '+s.familyName+".");return}const i=new l.ShapePath;let r,a,u,d,p,f,m,y;if(o.o){const _=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let x=0,S=_.length;x<S;)switch(_[x++]){case"m":r=parseInt(_[x++])*e+t,a=parseInt(_[x++])*e+n,i.moveTo(r,a);break;case"l":r=parseInt(_[x++])*e+t,a=parseInt(_[x++])*e+n,i.lineTo(r,a);break;case"q":u=parseInt(_[x++])*e+t,d=parseInt(_[x++])*e+n,p=parseInt(_[x++])*e+t,f=parseInt(_[x++])*e+n,i.quadraticCurveTo(p,f,u,d);break;case"b":u=parseInt(_[x++])*e+t,d=parseInt(_[x++])*e+n,p=parseInt(_[x++])*e+t,f=parseInt(_[x++])*e+n,m=parseInt(_[x++])*e+t,y=parseInt(_[x++])*e+n,i.bezierCurveTo(p,f,m,y,u,d);break}}return{offsetX:o.ha*e,path:i}}class bo extends l.DataTextureLoader{constructor(e){super(e),this.type=l.HalfFloatType}parse(e){const r=function(M,g){switch(M){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},p=`
75
- `,f=function(M,g,A){g=g||1024;let w=M.pos,v=-1,C=0,k="",I=String.fromCharCode.apply(null,new Uint16Array(M.subarray(w,w+128)));for(;0>(v=I.indexOf(p))&&C<g&&w<M.byteLength;)k+=I,C+=I.length,w+=128,I+=String.fromCharCode.apply(null,new Uint16Array(M.subarray(w,w+128)));return-1<v?(A!==!1&&(M.pos+=C+v+1),k+I.slice(0,v)):!1},m=function(M){const g=/^#\?(\S+)/,A=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,w=/^\s*FORMAT=(\S+)\s*$/,v=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,C={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let k,I;if(M.pos>=M.byteLength||!(k=f(M)))return r(1,"no header found");if(!(I=k.match(g)))return r(3,"bad initial token");for(C.valid|=1,C.programtype=I[1],C.string+=k+`
76
- `;k=f(M),k!==!1;){if(C.string+=k+`
77
- `,k.charAt(0)==="#"){C.comments+=k+`
78
- `;continue}if((I=k.match(A))&&(C.gamma=parseFloat(I[1])),(I=k.match(b))&&(C.exposure=parseFloat(I[1])),(I=k.match(w))&&(C.valid|=2,C.format=I[1]),(I=k.match(v))&&(C.valid|=4,C.height=parseInt(I[1],10),C.width=parseInt(I[2],10)),C.valid&2&&C.valid&4)break}return C.valid&2?C.valid&4?C:r(3,"missing image size specifier"):r(3,"missing format specifier")},y=function(M,g,A){const b=g;if(b<8||b>32767||M[0]!==2||M[1]!==2||M[2]&128)return new Uint8Array(M);if(b!==(M[2]<<8|M[3]))return r(3,"wrong scanline width");const w=new Uint8Array(4*g*A);if(!w.length)return r(4,"unable to allocate buffer space");let v=0,C=0;const k=4*b,I=new Uint8Array(4),U=new Uint8Array(k);let j=A;for(;j>0&&C<M.byteLength;){if(C+4>M.byteLength)return r(1);if(I[0]=M[C++],I[1]=M[C++],I[2]=M[C++],I[3]=M[C++],I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=b)return r(3,"bad rgbe scanline format");let H=0,G;for(;H<k&&C<M.byteLength;){G=M[C++];const X=G>128;if(X&&(G-=128),G===0||H+G>k)return r(3,"bad scanline data");if(X){const ae=M[C++];for(let re=0;re<G;re++)U[H++]=ae}else U.set(M.subarray(C,C+G),H),H+=G,C+=G}const ne=b;for(let X=0;X<ne;X++){let ae=0;w[v]=U[X+ae],ae+=b,w[v+1]=U[X+ae],ae+=b,w[v+2]=U[X+ae],ae+=b,w[v+3]=U[X+ae],v+=4}j--}return w},_=function(M,g,A,b){const w=M[g+3],v=Math.pow(2,w-128)/255;A[b+0]=M[g+0]*v,A[b+1]=M[g+1]*v,A[b+2]=M[g+2]*v,A[b+3]=1},x=function(M,g,A,b){const w=M[g+3],v=Math.pow(2,w-128)/255;A[b+0]=l.DataUtils.toHalfFloat(Math.min(M[g+0]*v,65504)),A[b+1]=l.DataUtils.toHalfFloat(Math.min(M[g+1]*v,65504)),A[b+2]=l.DataUtils.toHalfFloat(Math.min(M[g+2]*v,65504)),A[b+3]=l.DataUtils.toHalfFloat(1)},S=new Uint8Array(e);S.pos=0;const O=m(S);if(O!==-1){const M=O.width,g=O.height,A=y(S.subarray(S.pos),M,g);if(A!==-1){let b,w,v;switch(this.type){case l.FloatType:v=A.length/4;const C=new Float32Array(v*4);for(let I=0;I<v;I++)_(A,I*4,C,I*4);b=C,w=l.FloatType;break;case l.HalfFloatType:v=A.length/4;const k=new Uint16Array(v*4);for(let I=0;I<v;I++)x(A,I*4,k,I*4);b=k,w=l.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:M,height:g,data:b,header:O.string,gamma:O.gamma,exposure:O.exposure,type:w}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,s){function o(i,r){switch(i.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in i?i.colorSpace="srgb-linear":i.encoding=3e3,i.minFilter=l.LinearFilter,i.magFilter=l.LinearFilter,i.generateMipmaps=!1,i.flipY=!0;break}t&&t(i,r)}return super.load(e,o,n,s)}}const St=new WeakMap;class To extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const o=new l.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,i=>{const r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(i,r).then(t).catch(s)},n,s)}decodeDracoFile(e,t,n,s){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,o).then(t)}decodeGeometry(e,t){for(const a in t.attributeTypes){const u=t.attributeTypes[a];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[a]=u.name)}const n=JSON.stringify(t);if(St.has(e)){const a=St.get(e);if(a.key===n)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 s;const o=this.workerNextTaskID++,i=e.byteLength,r=this._getWorker(o,i).then(a=>(s=a,new Promise((u,d)=>{s._callbacks[o]={resolve:u,reject:d},s.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return r.catch(()=>!0).then(()=>{s&&o&&this._releaseTask(s,o)}),St.set(e,{key:n,promise:r}),r}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],o=s.name,i=s.array,r=s.itemSize;t.setAttribute(o,new l.BufferAttribute(i,r))}return t}_loadLibrary(e,t){const n=new l.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,o)=>{n.load(e,s,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=So.toString(),i=["/* draco decoder */",s,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
79
- `);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(o){const i=o.data;switch(i.type){case"decode":s._callbacks[i.id].resolve(i);break;case"error":s._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,o){return s._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function So(){let c,e;onmessage=function(i){const r=i.data;switch(r.type){case"init":c=r.decoderConfig,e=new Promise(function(d){c.onModuleLoaded=function(p){d({draco:p})},DracoDecoderModule(c)});break;case"decode":const a=r.buffer,u=r.taskConfig;e.then(d=>{const p=d.draco,f=new p.Decoder,m=new p.DecoderBuffer;m.Init(new Int8Array(a),a.byteLength);try{const y=t(p,f,m,u),_=y.attributes.map(x=>x.array.buffer);y.index&&_.push(y.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:y},_)}catch(y){console.error(y),self.postMessage({type:"error",id:r.id,error:y.message})}finally{p.destroy(m),p.destroy(f)}});break}};function t(i,r,a,u){const d=u.attributeIDs,p=u.attributeTypes;let f,m;const y=r.GetEncodedGeometryType(a);if(y===i.TRIANGULAR_MESH)f=new i.Mesh,m=r.DecodeBufferToMesh(a,f);else if(y===i.POINT_CLOUD)f=new i.PointCloud,m=r.DecodeBufferToPointCloud(a,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!m.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+m.error_msg());const _={index:null,attributes:[]};for(const x in d){const S=self[p[x]];let O,M;if(u.useUniqueIDs)M=d[x],O=r.GetAttributeByUniqueId(f,M);else{if(M=r.GetAttributeId(f,i[d[x]]),M===-1)continue;O=r.GetAttribute(f,M)}_.attributes.push(s(i,r,f,x,S,O))}return y===i.TRIANGULAR_MESH&&(_.index=n(i,r,f)),i.destroy(f),_}function n(i,r,a){const d=a.num_faces()*3,p=d*4,f=i._malloc(p);r.GetTrianglesUInt32Array(a,p,f);const m=new Uint32Array(i.HEAPF32.buffer,f,d).slice();return i._free(f),{array:m,itemSize:1}}function s(i,r,a,u,d,p){const f=p.num_components(),y=a.num_points()*f,_=y*d.BYTES_PER_ELEMENT,x=o(i,d),S=i._malloc(_);r.GetAttributeDataArrayForAllPoints(a,p,x,_,S);const O=new d(i.HEAPF32.buffer,S,y).slice();return i._free(S),{name:u,array:O,itemSize:f}}function o(i,r){switch(r){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}const Lo=["args","center"],Oo=h.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(c,{expose:e}){let t,n;const s=c,{center:o,font:i,text:r,needUpdates:a,size:u,height:d,curveSegments:p,bevelEnabled:f,bevelThickness:m,bevelSize:y,bevelOffset:_,bevelSegments:x}=h.toRefs(s),{extend:S}=q.useTresContext();S({TextGeometry:tn});const O=new Ao,M=h.useSlots(),g=h.computed(()=>{var v;return r!=null&&r.value?r.value:M.default?(v=M.default()[0].children)==null?void 0:v.trim():a.value?"":"TresJS"}),A=h.shallowRef();e({value:A});const b=([t,n]=h.withAsyncContext(()=>new Promise((v,C)=>{try{typeof i.value=="string"?O.load(i.value,k=>{v(k)}):v(i.value)}catch(k){C(console.error("cientos",k))}})),t=await t,n(),t),w=h.computed(()=>({font:b,size:h.toValue(u),height:h.toValue(d),curveSegments:h.toValue(p),bevelEnabled:h.toValue(f),bevelThickness:h.toValue(m),bevelSize:h.toValue(y),bevelOffset:h.toValue(_),bevelSegments:h.toValue(x)}));return h.watchEffect(()=>{A.value&&a.value&&(A.value.geometry.dispose(),A.value.geometry=new tn(g.value,w.value),o.value&&A.value.geometry.center())}),(v,C)=>h.unref(i)?(h.openBlock(),h.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:A},[g.value?(h.openBlock(),h.createElementBlock("TresTextGeometry",{key:0,args:[g.value,w.value],center:h.unref(o)},null,8,Lo)):h.createCommentVNode("",!0),h.renderSlot(v.$slots,"default")],512)):h.createCommentVNode("",!0)}});function Po(c,e){const t=h.ref(e),n=new l.AnimationMixer(t.value),s=h.shallowReactive({});c.forEach(i=>{const r=n.clipAction(i,t.value);s[i.name]=r});const{onLoop:o}=q.useRenderLoop();return o(({delta:i})=>{n.update(i)}),{actions:s,mixer:n}}const Lt={sunset:"venice/venice_sunset_4k.hdr"};async function pn({files:c=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],blur:e=0,background:t=!1,path:n="/",preset:s=void 0}){const{scene:o}=q.useTresContext();if(s){if(!(s in Lt))throw new Error("Preset must be one of: "+Object.keys(Lt).join(", "));c=Lt[s],n="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/"}const i=Array.isArray(c),r=i?l.CubeTextureLoader:bo,a=await q.useLoader(r,i?[c]:c,d=>{n&&d.setPath(n)}),u=i?a[0]:a;return u&&(u.mapping=i?l.CubeReflectionMapping:l.EquirectangularReflectionMapping,u.colorSpace=l.SRGBColorSpace),o.value&&(o.value.environment=u,t&&(o.value.background=u),e&&(o.value.backgroundBlurriness=e|0)),u}const Co=h.defineComponent({name:"Environment",props:["background","blur","files","encoding","path","preset"],async setup(c,{expose:e}){let t=null;return e({getTexture:()=>t}),t=await pn(c),()=>{}}}),Do=["position","a-scale"],Io=["size","size-attenuation","transparent","alpha-test","alpha-map"],ko=h.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(c,{expose:e}){const t=c,n=h.ref(),s=h.ref(),{radius:o,depth:i,count:r,size:a,sizeAttenuation:u,transparent:d,alphaMap:p,alphaTest:f}=h.toRefs(t),m=()=>{let _=o.value+i.value;const x=h.computed(()=>i.value/r.value),S=[],O=Array.from({length:r.value},()=>(.5+.5*Math.random())*4),M=g=>new l.Vector3().setFromSpherical(new l.Spherical(g,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let g=0;g<r.value;g++)_-=x.value*Math.random(),S.push(...M(_));n.value=new Float32Array(S),s.value=new Float32Array(O)};h.watchEffect(()=>{m()});const y=h.shallowRef();return e({value:y}),(_,x)=>(h.openBlock(),h.createElementBlock("TresPoints",{ref_key:"starsRef",ref:y},[h.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[s.value,1]},null,8,Do),h.createElementVNode("TresPointsMaterial",{size:h.unref(a),"size-attenuation":h.unref(u),transparent:h.unref(d),"alpha-test":h.unref(f),"alpha-map":h.unref(p)},null,8,Io)],512))}}),Fo=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Uo=["position","velocity"],Bo=h.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(c){const e=c,{size:t,area:n,color:s,alphaMap:o,map:i,opacity:r,alphaTest:a,depthWrite:u,transparent:d,sizeAttenuation:p,count:f,speed:m,randomness:y}=h.toRefs(e),_=h.shallowRef();let x=[],S=[];const O=()=>{x=new Float32Array(f.value*3);for(let A=0;A<f.value;A++){const b=A*3;x[b]=(Math.random()-.5)*n.value[0],x[b+1]=(Math.random()-.5)*n.value[1],x[b+2]=(Math.random()-.5)*n.value[2]}},M=()=>{S=new Float32Array(f.value*2);for(let A=0;A<f.value*2;A+=2)S[A]=(Math.random()-.5)/5*m.value*y.value,S[A+1]=Math.random()/5*m.value+.01};M(),O(),h.watchEffect(()=>{M(),O()});const{onLoop:g}=q.useRenderLoop();return g(()=>{var A,b;if((A=_.value)!=null&&A.attributes.position.array&&((b=_.value)!=null&&b.attributes.position.count)){const w=_.value.attributes.position.array;for(let v=0;v<_.value.attributes.position.count;v++){const C=S[v*2],k=S[v*2+1];w[v*3]+=C,w[v*3+1]-=k,(w[v*3]<=-n.value[0]/2||w[v*3]>=n.value[0]/2)&&(w[v*3]=w[v*3]*-1),(w[v*3+1]<=-n.value[1]/2||w[v*3+1]>=n.value[1]/2)&&(w[v*3+1]=w[v*3+1]*-1)}_.value.attributes.position.needsUpdate=!0}}),(A,b)=>(h.openBlock(),h.createElementBlock("TresPoints",null,[h.createElementVNode("TresPointsMaterial",{size:h.unref(t),color:h.unref(s),"alpha-map":h.unref(o),map:h.unref(i),opacity:h.unref(r),"alpha-test":h.unref(a),"depth-write":h.unref(u),transparent:h.unref(d),"size-attenuation":h.unref(p)},null,8,Fo),h.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:_,position:[h.unref(x),3],velocity:[h.unref(S)]},null,8,Uo)]))}}),Vo=["position"],No=["position"],zo=["scale"],Ro=["map","depth-test","color-space","color","opacity"],Eo=h.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(c,{expose:e}){let t,n;const s=c,{width:o,depth:i,segments:r,texture:a,color:u,depthTest:d,opacity:p,speed:f}=h.toRefs(s),m=h.shallowRef(),y=h.shallowRef();e({value:m});const _=[...new Array(r)].map((b,w)=>({x:o.value/2-Math.random()*o.value,y:o.value/2-Math.random()*o.value,scale:.4+Math.sin((w+1)/r.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*f.value})),x=(b,w)=>b/6*w*p.value,{map:S}=([t,n]=h.withAsyncContext(()=>q.useTexture({map:a.value})),t=await t,n(),t),{renderer:O,camera:M}=q.useTresContext(),g=h.computed(()=>{var b;return(b=O.value)==null?void 0:b.outputColorSpace}),{onLoop:A}=q.useRenderLoop();return A(()=>{var b,w;m.value&&M.value&&y.value&&((b=y.value)==null||b.children.forEach((v,C)=>{v.rotation.z+=_[C].rotation}),m.value.lookAt((w=M.value)==null?void 0:w.position))}),(b,w)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps({ref_key:"smokeRef",ref:m},b.$attrs),[h.createElementVNode("TresGroup",{ref_key:"groupRef",ref:y,position:[0,0,h.unref(r)/2*h.unref(i)]},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(h.unref(_),({scale:v,x:C,y:k,density:I},U)=>(h.openBlock(),h.createElementBlock("TresMesh",{key:`${U}`,position:[C,k,-U*h.unref(i)]},[h.createElementVNode("TresPlaneGeometry",{scale:[v,v,v],rotation:[0,0,0]},null,8,zo),h.createElementVNode("TresMeshStandardMaterial",{map:h.unref(S),"depth-test":h.unref(d),"color-space":g.value,color:h.unref(u),"depth-write":!1,transparent:"",opacity:x(v,I)},null,8,Ro)],8,No))),128))],8,Vo)],16))}}),Go=h.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(c,{expose:e}){const t=c,n=h.shallowRef();e({value:n});const{onLoop:s}=q.useRenderLoop(),o=h.ref(Math.random()*1e4);return s(({elapsed:i})=>{var u,d;if(!n.value)return;const r=o.value+i;n.value.rotation.x=Math.cos(r/4*t.speed)/8*t.rotationFactor,n.value.rotation.y=Math.sin(r/4*t.speed)/8*t.rotationFactor,n.value.rotation.z=Math.sin(r/4*t.speed)/20*t.rotationFactor;let a=Math.sin(r/4*t.speed)/10;a=l.MathUtils.mapLinear(a,-.1,.1,((u=t.range)==null?void 0:u[0])??-.1,((d=t.range)==null?void 0:d[1])??.1),n.value.position.y=a*t.floatFactor}),(i,r)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps(i.$attrs,{ref_key:"groupRef",ref:n}),[h.renderSlot(i.$slots,"default")],16))}}),jo=["geometry"],Yo=["map","opacity","depth-write"],Xo=["args"],Zo=["rotation","args"],Qo=h.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(c,{expose:e}){const t=c,n=h.shallowRef(),s=h.shallowRef();e(n);let o,i,r,a,u;const{renderer:d,scene:p}=q.useTresContext(),f=h.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),m=h.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));h.watchEffect(()=>{o&&o.dispose(),i&&i.dispose(),r&&r.dispose(),a&&a.geometry.dispose(),o=new l.WebGLRenderTarget(t.resolution,t.resolution),i=new l.WebGLRenderTarget(t.resolution,t.resolution),i.texture.generateMipmaps=o.texture.generateMipmaps=!1,s.value=new l.OrthographicCamera(-f.value/2,f.value/2,m.value/2,-m.value/2,0,t.far),r=new l.PlaneGeometry(f.value,m.value).rotateX(Math.PI/2),a=new l.Mesh(r),a.visible=!1}),h.watchEffect(()=>{t.color&&(u&&u.dispose(),u=new l.MeshDepthMaterial,u.depthTest=u.depthWrite=!1,u.onBeforeCompile=A=>{A.uniforms={...A.uniforms,ucolor:{value:t.color?new l.Color(t.color):new l.Color}},A.fragmentShader=A.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
73
+ `};function nn(c,e,t){const n=t.length-c-1;if(e>=t[n])return n-1;if(e<=t[c])return c;let s=c,o=n,i=Math.floor((s+o)/2);for(;e<t[i]||e>=t[i+1];)e<t[i]?o=i:s=i,i=Math.floor((s+o)/2);return i}function Js(c,e,t,n){const s=[],o=[],i=[];s[0]=1;for(let r=1;r<=t;++r){o[r]=e-n[c+1-r],i[r]=n[c+r]-e;let a=0;for(let u=0;u<r;++u){const d=i[u+1],p=o[r-u],f=s[u]/(d+p);s[u]=a+d*f,a=p*f}s[r]=a}return s}function Hs(c,e,t,n){const s=nn(c,n,e),o=Js(s,n,c,e),i=new l.Vector4(0,0,0,0);for(let r=0;r<=c;++r){const a=t[s-c+r],u=o[r],d=a.w*u;i.x+=a.x*d,i.y+=a.y*d,i.z+=a.z*d,i.w+=a.w*u}return i}function $s(c,e,t,n,s){const o=[];for(let p=0;p<=t;++p)o[p]=0;const i=[];for(let p=0;p<=n;++p)i[p]=o.slice(0);const r=[];for(let p=0;p<=t;++p)r[p]=o.slice(0);r[0][0]=1;const a=o.slice(0),u=o.slice(0);for(let p=1;p<=t;++p){a[p]=e-s[c+1-p],u[p]=s[c+p]-e;let f=0;for(let m=0;m<p;++m){const v=u[m+1],_=a[p-m];r[p][m]=v+_;const A=r[m][p-1]/r[p][m];r[m][p]=f+v*A,f=_*A}r[p][p]=f}for(let p=0;p<=t;++p)i[0][p]=r[p][t];for(let p=0;p<=t;++p){let f=0,m=1;const v=[];for(let _=0;_<=t;++_)v[_]=o.slice(0);v[0][0]=1;for(let _=1;_<=n;++_){let A=0;const M=p-_,O=t-_;p>=_&&(v[m][0]=v[f][0]/r[O+1][M],A=v[m][0]*r[M][O]);const b=M>=-1?1:-M,g=p-1<=O?_-1:t-p;for(let x=b;x<=g;++x)v[m][x]=(v[f][x]-v[f][x-1])/r[O+1][M+x],A+=v[m][x]*r[M+x][O];p<=O&&(v[m][_]=-v[f][_-1]/r[O+1][p],A+=v[m][_]*r[p][O]),i[_][p]=A;const T=f;f=m,m=T}}let d=t;for(let p=1;p<=n;++p){for(let f=0;f<=t;++f)i[p][f]*=d;d*=t-p}return i}function eo(c,e,t,n,s){const o=s<c?s:c,i=[],r=nn(c,n,e),a=$s(r,n,c,o,e),u=[];for(let d=0;d<t.length;++d){const p=t[d].clone(),f=p.w;p.x*=f,p.y*=f,p.z*=f,u[d]=p}for(let d=0;d<=o;++d){const p=u[r-c].clone().multiplyScalar(a[d][0]);for(let f=1;f<=c;++f)p.add(u[r-c+f].clone().multiplyScalar(a[d][f]));i[d]=p}for(let d=o+1;d<=s+1;++d)i[d]=new l.Vector4(0,0,0);return i}function to(c,e){let t=1;for(let s=2;s<=c;++s)t*=s;let n=1;for(let s=2;s<=e;++s)n*=s;for(let s=2;s<=c-e;++s)n*=s;return t/n}function no(c){const e=c.length,t=[],n=[];for(let o=0;o<e;++o){const i=c[o];t[o]=new l.Vector3(i.x,i.y,i.z),n[o]=i.w}const s=[];for(let o=0;o<e;++o){const i=t[o].clone();for(let r=1;r<=o;++r)i.sub(s[o-r].clone().multiplyScalar(to(o,r)*n[r]));s[o]=i.divideScalar(n[0])}return s}function so(c,e,t,n,s){const o=eo(c,e,t,n,s);return no(o)}class sn extends l.Curve{constructor(e,t,n,s,o){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=s||0,this.endKnot=o||this.knots.length-1;for(let i=0;i<n.length;++i){const r=n[i];this.controlPoints[i]=new l.Vector4(r.x,r.y,r.z,r.w)}}getPoint(e,t){const n=t||new l.Vector3,s=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),o=Hs(this.degree,this.knots,this.controlPoints,s);return o.w!=1&&o.divideScalar(o.w),n.set(o.x,o.y,o.z)}getTangent(e,t){const n=t||new l.Vector3,s=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),o=so(this.degree,this.knots,this.controlPoints,s,1);return n.copy(o[1]).normalize(),n}}let Y,oe,ue;class oo extends l.Loader{constructor(e){super(e)}load(e,t,n,s){const o=this,i=o.path===""?l.LoaderUtils.extractUrlBase(e):o.path,r=new l.FileLoader(this.manager);r.setPath(o.path),r.setResponseType("arraybuffer"),r.setRequestHeader(o.requestHeader),r.setWithCredentials(o.withCredentials),r.load(e,function(a){try{t(o.parse(a,i))}catch(u){s?s(u):console.error(u),o.manager.itemError(e)}},n,s)}parse(e,t){if(ho(e))Y=new co().parse(e);else{const s=hn(e);if(!uo(s))throw new Error("THREE.FBXLoader: Unknown format.");if(an(s)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+an(s));Y=new lo().parse(s)}const n=new l.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new io(n,this.manager).parse(Y)}}class io{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){oe=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),s=this.parseDeformers(),o=new ro().parse(s);return this.parseScene(s,o,n),ue}parseConnections(){const e=new Map;return"Connections"in Y&&Y.Connections.connections.forEach(function(n){const s=n[0],o=n[1],i=n[2];e.has(s)||e.set(s,{parents:[],children:[]});const r={ID:o,relationship:i};e.get(s).parents.push(r),e.has(o)||e.set(o,{parents:[],children:[]});const a={ID:s,relationship:i};e.get(o).children.push(a)}),e}parseImages(){const e={},t={};if("Video"in Y.Objects){const n=Y.Objects.Video;for(const s in n){const o=n[s],i=parseInt(s);if(e[i]=o.RelativeFilename||o.Filename,"Content"in o){const r=o.Content instanceof ArrayBuffer&&o.Content.byteLength>0,a=typeof o.Content=="string"&&o.Content!=="";if(r||a){const u=this.parseImage(n[s]);t[o.RelativeFilename||o.Filename]=u}}}}for(const n in e){const s=e[n];t[s]!==void 0?e[n]=t[s]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,s=n.slice(n.lastIndexOf(".")+1).toLowerCase();let o;switch(s){case"bmp":o="image/bmp";break;case"jpg":case"jpeg":o="image/jpeg";break;case"png":o="image/png";break;case"tif":o="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),o="image/tga";break;default:console.warn('FBXLoader: Image type "'+s+'" is not supported.');return}if(typeof t=="string")return"data:"+o+";base64,"+t;{const i=new Uint8Array(t);return window.URL.createObjectURL(new Blob([i],{type:o}))}}parseTextures(e){const t=new Map;if("Texture"in Y.Objects){const n=Y.Objects.Texture;for(const s in n){const o=this.parseTexture(n[s],e);t.set(parseInt(s),o)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const s=e.WrapModeU,o=e.WrapModeV,i=s!==void 0?s.value:0,r=o!==void 0?o.value:0;if(n.wrapS=i===0?l.RepeatWrapping:l.ClampToEdgeWrapping,n.wrapT=r===0?l.RepeatWrapping:l.ClampToEdgeWrapping,"Scaling"in e){const a=e.Scaling.value;n.repeat.x=a[0],n.repeat.y=a[1]}return n}loadTexture(e,t){let n;const s=this.textureLoader.path,o=oe.get(e.id).children;o!==void 0&&o.length>0&&t[o[0].ID]!==void 0&&(n=t[o[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let i;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),i=new l.Texture):(a.setPath(this.textureLoader.path),i=a.load(n))}else r==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),i=new l.Texture):i=this.textureLoader.load(n);return this.textureLoader.setPath(s),i}parseMaterials(e){const t=new Map;if("Material"in Y.Objects){const n=Y.Objects.Material;for(const s in n){const o=this.parseMaterial(n[s],e);o!==null&&t.set(parseInt(s),o)}}return t}parseMaterial(e,t){const n=e.id,s=e.attrName;let o=e.ShadingModel;if(typeof o=="object"&&(o=o.value),!oe.has(n))return null;const i=this.parseParameters(e,t,n);let r;switch(o.toLowerCase()){case"phong":r=new l.MeshPhongMaterial;break;case"lambert":r=new l.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),r=new l.MeshPhongMaterial;break}return r.setValues(i),r.name=s,r}parseParameters(e,t,n){const s={};e.BumpFactor&&(s.bumpScale=e.BumpFactor.value),e.Diffuse?s.color=new l.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(s.color=new l.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(s.displacementScale=e.DisplacementFactor.value),e.Emissive?s.emissive=new l.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(s.emissive=new l.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(s.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(s.opacity=parseFloat(e.Opacity.value)),s.opacity<1&&(s.transparent=!0),e.ReflectionFactor&&(s.reflectivity=e.ReflectionFactor.value),e.Shininess&&(s.shininess=e.Shininess.value),e.Specular?s.specular=new l.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(s.specular=new l.Color().fromArray(e.SpecularColor.value));const o=this;return oe.get(n).children.forEach(function(i){const r=i.relationship;switch(r){case"Bump":s.bumpMap=o.getTexture(t,i.ID);break;case"Maya|TEX_ao_map":s.aoMap=o.getTexture(t,i.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":s.map=o.getTexture(t,i.ID),s.map!==void 0&&("colorSpace"in s.map?s.map.colorSpace="srgb":s.map.encoding=3001);break;case"DisplacementColor":s.displacementMap=o.getTexture(t,i.ID);break;case"EmissiveColor":s.emissiveMap=o.getTexture(t,i.ID),s.emissiveMap!==void 0&&("colorSpace"in s.emissiveMap?s.emissiveMap.colorSpace="srgb":s.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":s.normalMap=o.getTexture(t,i.ID);break;case"ReflectionColor":s.envMap=o.getTexture(t,i.ID),s.envMap!==void 0&&(s.envMap.mapping=l.EquirectangularReflectionMapping,"colorSpace"in s.envMap?s.envMap.colorSpace="srgb":s.envMap.encoding=3001);break;case"SpecularColor":s.specularMap=o.getTexture(t,i.ID),s.specularMap!==void 0&&("colorSpace"in s.specularMap?s.specularMap.colorSpace="srgb":s.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":s.alphaMap=o.getTexture(t,i.ID),s.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r);break}}),s}getTexture(e,t){return"LayeredTexture"in Y.Objects&&t in Y.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=oe.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Y.Objects){const n=Y.Objects.Deformer;for(const s in n){const o=n[s],i=oe.get(parseInt(s));if(o.attrType==="Skin"){const r=this.parseSkeleton(i,n);r.ID=s,i.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),r.geometryID=i.parents[0].ID,e[s]=r}else if(o.attrType==="BlendShape"){const r={id:s};r.rawTargets=this.parseMorphTargets(i,n),r.id=s,i.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[s]=r}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(s){const o=t[s.ID];if(o.attrType!=="Cluster")return;const i={ID:s.ID,indices:[],weights:[],transformLink:new l.Matrix4().fromArray(o.TransformLink.a)};"Indexes"in o&&(i.indices=o.Indexes.a,i.weights=o.Weights.a),n.push(i)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let s=0;s<e.children.length;s++){const o=e.children[s],i=t[o.ID],r={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if(i.attrType!=="BlendShapeChannel")return;r.geoID=oe.get(parseInt(o.ID)).children.filter(function(a){return a.relationship===void 0})[0].ID,n.push(r)}return n}parseScene(e,t,n){ue=new l.Group;const s=this.parseModels(e.skeletons,t,n),o=Y.Objects.Model,i=this;s.forEach(function(a){const u=o[a.ID];i.setLookAtProperties(a,u),oe.get(a.ID).parents.forEach(function(p){const f=s.get(p.ID);f!==void 0&&f.add(a)}),a.parent===null&&ue.add(a)}),this.bindSkeleton(e.skeletons,t,s),this.createAmbientLight(),ue.traverse(function(a){if(a.userData.transformData){a.parent&&(a.userData.transformData.parentMatrix=a.parent.matrix,a.userData.transformData.parentMatrixWorld=a.parent.matrixWorld);const u=ln(a.userData.transformData);a.applyMatrix4(u),a.updateWorldMatrix()}});const r=new ao().parse();ue.children.length===1&&ue.children[0].isGroup&&(ue.children[0].animations=r,ue=ue.children[0]),ue.animations=r}parseModels(e,t,n){const s=new Map,o=Y.Objects.Model;for(const i in o){const r=parseInt(i),a=o[i],u=oe.get(r);let d=this.buildSkeleton(u,e,r,a.attrName);if(!d){switch(a.attrType){case"Camera":d=this.createCamera(u);break;case"Light":d=this.createLight(u);break;case"Mesh":d=this.createMesh(u,t,n);break;case"NurbsCurve":d=this.createCurve(u,t);break;case"LimbNode":case"Root":d=new l.Bone;break;case"Null":default:d=new l.Group;break}d.name=a.attrName?l.PropertyBinding.sanitizeNodeName(a.attrName):"",d.ID=r}this.getTransformData(d,a),s.set(r,d)}return s}buildSkeleton(e,t,n,s){let o=null;return e.parents.forEach(function(i){for(const r in t){const a=t[r];a.rawBones.forEach(function(u,d){if(u.ID===i.ID){const p=o;o=new l.Bone,o.matrixWorld.copy(u.transformLink),o.name=s?l.PropertyBinding.sanitizeNodeName(s):"",o.ID=n,a.bones[d]=o,p!==null&&o.add(p)}})}}),o}createCamera(e){let t,n;if(e.children.forEach(function(s){const o=Y.Objects.NodeAttribute[s.ID];o!==void 0&&(n=o)}),n===void 0)t=new l.Object3D;else{let s=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(s=1);let o=1;n.NearPlane!==void 0&&(o=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let r=window.innerWidth,a=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(r=n.AspectWidth.value,a=n.AspectHeight.value);const u=r/a;let d=45;n.FieldOfView!==void 0&&(d=n.FieldOfView.value);const p=n.FocalLength?n.FocalLength.value:null;switch(s){case 0:t=new l.PerspectiveCamera(d,u,o,i),p!==null&&t.setFocalLength(p);break;case 1:t=new l.OrthographicCamera(-r/2,r/2,a/2,-a/2,o,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+s+"."),t=new l.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(s){const o=Y.Objects.NodeAttribute[s.ID];o!==void 0&&(n=o)}),n===void 0)t=new l.Object3D;else{let s;n.LightType===void 0?s=0:s=n.LightType.value;let o=16777215;n.Color!==void 0&&(o=new l.Color().fromArray(n.Color.value));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let r=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?r=0:r=n.FarAttenuationEnd.value);const a=1;switch(s){case 0:t=new l.PointLight(o,i,r,a);break;case 1:t=new l.DirectionalLight(o,i);break;case 2:let u=Math.PI/3;n.InnerAngle!==void 0&&(u=l.MathUtils.degToRad(n.InnerAngle.value));let d=0;n.OuterAngle!==void 0&&(d=l.MathUtils.degToRad(n.OuterAngle.value),d=Math.max(d,1)),t=new l.SpotLight(o,i,r,u,d,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new l.PointLight(o,i);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let s,o=null,i=null;const r=[];return e.children.forEach(function(a){t.has(a.ID)&&(o=t.get(a.ID)),n.has(a.ID)&&r.push(n.get(a.ID))}),r.length>1?i=r:r.length>0?i=r[0]:(i=new l.MeshPhongMaterial({color:13421772}),r.push(i)),"color"in o.attributes&&r.forEach(function(a){a.vertexColors=!0}),o.FBX_Deformer?(s=new l.SkinnedMesh(o,i),s.normalizeSkinWeights()):s=new l.Mesh(o,i),s}createCurve(e,t){const n=e.children.reduce(function(o,i){return t.has(i.ID)&&(o=t.get(i.ID)),o},null),s=new l.LineBasicMaterial({color:3342591,linewidth:1});return new l.Line(n,s)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=cn(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&oe.get(e.ID).children.forEach(function(s){if(s.relationship==="LookAtProperty"){const o=Y.Objects.Model[s.ID];if("Lcl_Translation"in o){const i=o.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),ue.add(e.target)):e.lookAt(new l.Vector3().fromArray(i))}}})}bindSkeleton(e,t,n){const s=this.parsePoseNodes();for(const o in e){const i=e[o];oe.get(parseInt(i.ID)).parents.forEach(function(a){if(t.has(a.ID)){const u=a.ID;oe.get(u).parents.forEach(function(p){n.has(p.ID)&&n.get(p.ID).bind(new l.Skeleton(i.bones),s[p.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in Y.Objects){const t=Y.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const s=t[n].PoseNode;Array.isArray(s)?s.forEach(function(o){e[o.Node]=new l.Matrix4().fromArray(o.Matrix.a)}):e[s.Node]=new l.Matrix4().fromArray(s.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Y&&"AmbientColor"in Y.GlobalSettings){const e=Y.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],s=e[2];if(t!==0||n!==0||s!==0){const o=new l.Color(t,n,s);ue.add(new l.AmbientLight(o,1))}}}}class ro{parse(e){const t=new Map;if("Geometry"in Y.Objects){const n=Y.Objects.Geometry;for(const s in n){const o=oe.get(parseInt(s)),i=this.parseGeometry(o,n[s],e);t.set(parseInt(s),i)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const s=n.skeletons,o=[],i=e.parents.map(function(p){return Y.Objects.Model[p.ID]});if(i.length===0)return;const r=e.children.reduce(function(p,f){return s[f.ID]!==void 0&&(p=s[f.ID]),p},null);e.children.forEach(function(p){n.morphTargets[p.ID]!==void 0&&o.push(n.morphTargets[p.ID])});const a=i[0],u={};"RotationOrder"in a&&(u.eulerOrder=cn(a.RotationOrder.value)),"InheritType"in a&&(u.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(u.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(u.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(u.scale=a.GeometricScaling.value);const d=ln(u);return this.genGeometry(t,r,o,d)}genGeometry(e,t,n,s){const o=new l.BufferGeometry;e.attrName&&(o.name=e.attrName);const i=this.parseGeoNode(e,t),r=this.genBuffers(i),a=new l.Float32BufferAttribute(r.vertex,3);if(a.applyMatrix4(s),o.setAttribute("position",a),r.colors.length>0&&o.setAttribute("color",new l.Float32BufferAttribute(r.colors,3)),t&&(o.setAttribute("skinIndex",new l.Uint16BufferAttribute(r.weightsIndices,4)),o.setAttribute("skinWeight",new l.Float32BufferAttribute(r.vertexWeights,4)),o.FBX_Deformer=t),r.normal.length>0){const u=new l.Matrix3().getNormalMatrix(s),d=new l.Float32BufferAttribute(r.normal,3);d.applyNormalMatrix(u),o.setAttribute("normal",d)}if(r.uvs.forEach(function(u,d){let p="uv"+(d+1).toString();d===0&&(p="uv"),o.setAttribute(p,new l.Float32BufferAttribute(r.uvs[d],2))}),i.material&&i.material.mappingType!=="AllSame"){let u=r.materialIndex[0],d=0;if(r.materialIndex.forEach(function(p,f){p!==u&&(o.addGroup(d,f-d,u),u=p,d=f)}),o.groups.length>0){const p=o.groups[o.groups.length-1],f=p.start+p.count;f!==r.materialIndex.length&&o.addGroup(f,r.materialIndex.length-f,u)}o.groups.length===0&&o.addGroup(0,r.materialIndex.length,r.materialIndex[0])}return this.addMorphTargets(o,e,n,s),o}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let s=0;for(;e.LayerElementUV[s];)e.LayerElementUV[s].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[s])),s++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(s,o){s.indices.forEach(function(i,r){n.weightTable[i]===void 0&&(n.weightTable[i]=[]),n.weightTable[i].push({id:o,weight:s.weights[r]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,s=0,o=!1,i=[],r=[],a=[],u=[],d=[],p=[];const f=this;return e.vertexIndices.forEach(function(m,v){let _,A=!1;m<0&&(m=m^-1,A=!0);let M=[],O=[];if(i.push(m*3,m*3+1,m*3+2),e.color){const b=ot(v,n,m,e.color);a.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[m]!==void 0&&e.weightTable[m].forEach(function(b){O.push(b.weight),M.push(b.id)}),O.length>4){o||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),o=!0);const b=[0,0,0,0],g=[0,0,0,0];O.forEach(function(T,x){let y=T,w=M[x];g.forEach(function(D,k,I){if(y>D){I[k]=y,y=D;const U=b[k];b[k]=w,w=U}})}),M=b,O=g}for(;O.length<4;)O.push(0),M.push(0);for(let b=0;b<4;++b)d.push(O[b]),p.push(M[b])}if(e.normal){const b=ot(v,n,m,e.normal);r.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(_=ot(v,n,m,e.material)[0]),e.uv&&e.uv.forEach(function(b,g){const T=ot(v,n,m,b);u[g]===void 0&&(u[g]=[]),u[g].push(T[0]),u[g].push(T[1])}),s++,A&&(f.genFace(t,e,i,_,r,a,u,d,p,s),n++,s=0,i=[],r=[],a=[],u=[],d=[],p=[])}),t}genFace(e,t,n,s,o,i,r,a,u,d){for(let p=2;p<d;p++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(p-1)*3]]),e.vertex.push(t.vertexPositions[n[(p-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(p-1)*3+2]]),e.vertex.push(t.vertexPositions[n[p*3]]),e.vertex.push(t.vertexPositions[n[p*3+1]]),e.vertex.push(t.vertexPositions[n[p*3+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[(p-1)*4]),e.vertexWeights.push(a[(p-1)*4+1]),e.vertexWeights.push(a[(p-1)*4+2]),e.vertexWeights.push(a[(p-1)*4+3]),e.vertexWeights.push(a[p*4]),e.vertexWeights.push(a[p*4+1]),e.vertexWeights.push(a[p*4+2]),e.vertexWeights.push(a[p*4+3]),e.weightsIndices.push(u[0]),e.weightsIndices.push(u[1]),e.weightsIndices.push(u[2]),e.weightsIndices.push(u[3]),e.weightsIndices.push(u[(p-1)*4]),e.weightsIndices.push(u[(p-1)*4+1]),e.weightsIndices.push(u[(p-1)*4+2]),e.weightsIndices.push(u[(p-1)*4+3]),e.weightsIndices.push(u[p*4]),e.weightsIndices.push(u[p*4+1]),e.weightsIndices.push(u[p*4+2]),e.weightsIndices.push(u[p*4+3])),t.color&&(e.colors.push(i[0]),e.colors.push(i[1]),e.colors.push(i[2]),e.colors.push(i[(p-1)*3]),e.colors.push(i[(p-1)*3+1]),e.colors.push(i[(p-1)*3+2]),e.colors.push(i[p*3]),e.colors.push(i[p*3+1]),e.colors.push(i[p*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(s),e.materialIndex.push(s),e.materialIndex.push(s)),t.normal&&(e.normal.push(o[0]),e.normal.push(o[1]),e.normal.push(o[2]),e.normal.push(o[(p-1)*3]),e.normal.push(o[(p-1)*3+1]),e.normal.push(o[(p-1)*3+2]),e.normal.push(o[p*3]),e.normal.push(o[p*3+1]),e.normal.push(o[p*3+2])),t.uv&&t.uv.forEach(function(f,m){e.uvs[m]===void 0&&(e.uvs[m]=[]),e.uvs[m].push(r[m][0]),e.uvs[m].push(r[m][1]),e.uvs[m].push(r[m][(p-1)*2]),e.uvs[m].push(r[m][(p-1)*2+1]),e.uvs[m].push(r[m][p*2]),e.uvs[m].push(r[m][p*2+1])})}addMorphTargets(e,t,n,s){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const o=this;n.forEach(function(i){i.rawTargets.forEach(function(r){const a=Y.Objects.Geometry[r.geoID];a!==void 0&&o.genMorphGeometry(e,t,a,s,r.name)})})}genMorphGeometry(e,t,n,s,o){const i=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],r=n.Vertices!==void 0?n.Vertices.a:[],a=n.Indexes!==void 0?n.Indexes.a:[],u=e.attributes.position.count*3,d=new Float32Array(u);for(let v=0;v<a.length;v++){const _=a[v]*3;d[_]=r[v*3],d[_+1]=r[v*3+1],d[_+2]=r[v*3+2]}const p={vertexIndices:i,vertexPositions:d},f=this.genBuffers(p),m=new l.Float32BufferAttribute(f.vertex,3);m.name=o||n.attrName,m.applyMatrix4(s),e.morphAttributes.position.push(m)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Normals.a;let o=[];return n==="IndexToDirect"&&("NormalIndex"in e?o=e.NormalIndex.a:"NormalsIndex"in e&&(o=e.NormalsIndex.a)),{dataSize:3,buffer:s,indices:o,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.UV.a;let o=[];return n==="IndexToDirect"&&(o=e.UVIndex.a),{dataSize:2,buffer:s,indices:o,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Colors.a;let o=[];return n==="IndexToDirect"&&(o=e.ColorIndex.a),{dataSize:4,buffer:s,indices:o,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const s=e.Materials.a,o=[];for(let i=0;i<s.length;++i)o.push(i);return{dataSize:1,buffer:s,indices:o,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(sn===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 l.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 l.BufferGeometry;const n=t-1,s=e.KnotVector.a,o=[],i=e.Points.a;for(let p=0,f=i.length;p<f;p+=4)o.push(new l.Vector4().fromArray(i,p));let r,a;if(e.Form==="Closed")o.push(o[0]);else if(e.Form==="Periodic"){r=n,a=s.length-1-r;for(let p=0;p<n;++p)o.push(o[p])}const d=new sn(n,s,o,r,a).getPoints(o.length*12);return new l.BufferGeometry().setFromPoints(d)}}class ao{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const s=t[n],o=this.addClip(s);e.push(o)}return e}parseClips(){if(Y.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Y.Objects.AnimationCurveNode,t=new Map;for(const n in e){const s=e[n];if(s.attrName.match(/S|R|T|DeformPercent/)!==null){const o={id:s.id,attr:s.attrName,curves:{}};t.set(o.id,o)}}return t}parseAnimationCurves(e){const t=Y.Objects.AnimationCurve;for(const n in t){const s={id:t[n].id,times:t[n].KeyTime.a.map(po),values:t[n].KeyValueFloat.a},o=oe.get(s.id);if(o!==void 0){const i=o.parents[0].ID,r=o.parents[0].relationship;r.match(/X/)?e.get(i).curves.x=s:r.match(/Y/)?e.get(i).curves.y=s:r.match(/Z/)?e.get(i).curves.z=s:r.match(/d|DeformPercent/)&&e.has(i)&&(e.get(i).curves.morph=s)}}}parseAnimationLayers(e){const t=Y.Objects.AnimationLayer,n=new Map;for(const s in t){const o=[],i=oe.get(parseInt(s));i!==void 0&&(i.children.forEach(function(a,u){if(e.has(a.ID)){const d=e.get(a.ID);if(d.curves.x!==void 0||d.curves.y!==void 0||d.curves.z!==void 0){if(o[u]===void 0){const p=oe.get(a.ID).parents.filter(function(f){return f.relationship!==void 0})[0].ID;if(p!==void 0){const f=Y.Objects.Model[p.toString()];if(f===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",a);return}const m={modelName:f.attrName?l.PropertyBinding.sanitizeNodeName(f.attrName):"",ID:f.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ue.traverse(function(v){v.ID===f.id&&(m.transform=v.matrix,v.userData.transformData&&(m.eulerOrder=v.userData.transformData.eulerOrder))}),m.transform||(m.transform=new l.Matrix4),"PreRotation"in f&&(m.preRotation=f.PreRotation.value),"PostRotation"in f&&(m.postRotation=f.PostRotation.value),o[u]=m}}o[u]&&(o[u][d.attr]=d)}else if(d.curves.morph!==void 0){if(o[u]===void 0){const p=oe.get(a.ID).parents.filter(function(M){return M.relationship!==void 0})[0].ID,f=oe.get(p).parents[0].ID,m=oe.get(f).parents[0].ID,v=oe.get(m).parents[0].ID,_=Y.Objects.Model[v],A={modelName:_.attrName?l.PropertyBinding.sanitizeNodeName(_.attrName):"",morphName:Y.Objects.Deformer[p].attrName};o[u]=A}o[u][d.attr]=d}}}),n.set(parseInt(s),o))}return n}parseAnimStacks(e){const t=Y.Objects.AnimationStack,n={};for(const s in t){const o=oe.get(parseInt(s)).children;o.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const i=e.get(o[0].ID);n[s]={name:t[s].attrName,layer:i}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(s){t=t.concat(n.generateTracks(s))}),new l.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new l.Vector3,s=new l.Quaternion,o=new l.Vector3;if(e.transform&&e.transform.decompose(n,s,o),n=n.toArray(),s=new l.Euler().setFromQuaternion(s,e.eulerOrder).toArray(),o=o.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");i!==void 0&&t.push(i)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const i=this.generateRotationTrack(e.modelName,e.R.curves,s,e.preRotation,e.postRotation,e.eulerOrder);i!==void 0&&t.push(i)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.S.curves,o,"scale");i!==void 0&&t.push(i)}if(e.DeformPercent!==void 0){const i=this.generateMorphTrack(e);i!==void 0&&t.push(i)}return t}generateVectorTrack(e,t,n,s){const o=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(o,t,n);return new l.VectorKeyframeTrack(e+"."+s,o,i)}generateRotationTrack(e,t,n,s,o,i){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(l.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(l.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(l.MathUtils.degToRad));const r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,n);s!==void 0&&(s=s.map(l.MathUtils.degToRad),s.push(i),s=new l.Euler().fromArray(s),s=new l.Quaternion().setFromEuler(s)),o!==void 0&&(o=o.map(l.MathUtils.degToRad),o.push(i),o=new l.Euler().fromArray(o),o=new l.Quaternion().setFromEuler(o).invert());const u=new l.Quaternion,d=new l.Euler,p=[];for(let f=0;f<a.length;f+=3)d.set(a[f],a[f+1],a[f+2],i),u.setFromEuler(d),s!==void 0&&u.premultiply(s),o!==void 0&&u.multiply(o),u.toArray(p,f/3*4);return new l.QuaternionKeyframeTrack(e+".quaternion",r,p)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(o){return o/100}),s=ue.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new l.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+s+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,s){return n-s}),t.length>1){let n=1,s=t[0];for(let o=1;o<t.length;o++){const i=t[o];i!==s&&(t[n]=i,s=i,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const s=n,o=[];let i=-1,r=-1,a=-1;return e.forEach(function(u){if(t.x&&(i=t.x.times.indexOf(u)),t.y&&(r=t.y.times.indexOf(u)),t.z&&(a=t.z.times.indexOf(u)),i!==-1){const d=t.x.values[i];o.push(d),s[0]=d}else o.push(s[0]);if(r!==-1){const d=t.y.values[r];o.push(d),s[1]=d}else o.push(s[1]);if(a!==-1){const d=t.z.values[a];o.push(d),s[2]=d}else o.push(s[2])}),o}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],s=e.values[t]-n,o=Math.abs(s);if(o>=180){const i=o/180,r=s/i;let a=n+r;const u=e.times[t-1],p=(e.times[t]-u)/i;let f=u+p;const m=[],v=[];for(;f<e.times[t];)m.push(f),f+=p,v.push(a),a+=r;e.times=un(e.times,t,m),e.values=un(e.values,t,v)}}}}class lo{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 rn,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(s,o){const i=s.match(/^[\s\t]*;/),r=s.match(/^[\s\t]*$/);if(i||r)return;const a=s.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),u=s.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),d=s.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(s,a):u?t.parseNodeProperty(s,u,n[++o]):d?t.popStack():s.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(s)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),s=t[2].split(",").map(function(a){return a.trim().replace(/^"/,"").replace(/"$/,"")}),o={name:n},i=this.parseNodeAttr(s),r=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,o):n in r?(n==="PoseNode"?r.PoseNode.push(o):r[n].id!==void 0&&(r[n]={},r[n][r[n].id]=r[n]),i.id!==""&&(r[n][i.id]=o)):typeof i.id=="number"?(r[n]={},r[n][i.id]=o):n!=="Properties70"&&(n==="PoseNode"?r[n]=[o]:r[n]=o),typeof i.id=="number"&&(o.id=i.id),i.name!==""&&(o.attrName=i.name),i.type!==""&&(o.attrType=i.type),this.pushStack(o)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",s="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),s=e[2]),{id:t,name:n,type:s}}parseNodeProperty(e,t,n){let s=t[1].replace(/^"/,"").replace(/"$/,"").trim(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();s==="Content"&&o===","&&(o=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if(i.name==="Properties70"){this.parseNodeSpecialProperty(e,s,o);return}if(s==="C"){const a=o.split(",").slice(1),u=parseInt(a[0]),d=parseInt(a[1]);let p=o.split(",").slice(3);p=p.map(function(f){return f.trim().replace(/^"/,"")}),s="connections",o=[u,d],mo(o,p),i[s]===void 0&&(i[s]=[])}s==="Node"&&(i.id=o),s in i&&Array.isArray(i[s])?i[s].push(o):s!=="a"?i[s]=o:i.a=o,this.setCurrentProp(i,s),s==="a"&&o.slice(-1)!==","&&(i.a=Mt(o))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Mt(t.a))}parseNodeSpecialProperty(e,t,n){const s=n.split('",').map(function(d){return d.trim().replace(/^\"/,"").replace(/\s/,"_")}),o=s[0],i=s[1],r=s[2],a=s[3];let u=s[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":u=parseFloat(u);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":u=Mt(u);break}this.getPrevNode()[o]={type:i,type2:r,flag:a,value:u},this.setCurrentProp(this.getPrevNode(),o)}}class co{parse(e){const t=new on(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const s=new rn;for(;!this.endOfContent(t);){const o=this.parseNode(t,n);o!==null&&s.add(o.name,o)}return s}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},s=t>=7500?e.getUint64():e.getUint32(),o=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),r=e.getString(i);if(s===0)return null;const a=[];for(let f=0;f<o;f++)a.push(this.parseProperty(e));const u=a.length>0?a[0]:"",d=a.length>1?a[1]:"",p=a.length>2?a[2]:"";for(n.singleProperty=o===1&&e.getOffset()===s;s>e.getOffset();){const f=this.parseNode(e,t);f!==null&&this.parseSubNode(r,n,f)}return n.propertyList=a,typeof u=="number"&&(n.id=u),d!==""&&(n.attrName=d),p!==""&&(n.attrType=p),r!==""&&(n.name=r),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const s=n.propertyList[0];Array.isArray(s)?(t[n.name]=n,n.a=s):t[n.name]=s}else if(e==="Connections"&&n.name==="C"){const s=[];n.propertyList.forEach(function(o,i){i!==0&&s.push(o)}),t.connections===void 0&&(t.connections=[]),t.connections.push(s)}else if(n.name==="Properties70")Object.keys(n).forEach(function(o){t[o]=n[o]});else if(e==="Properties70"&&n.name==="P"){let s=n.propertyList[0],o=n.propertyList[1];const i=n.propertyList[2],r=n.propertyList[3];let a;s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),o.indexOf("Lcl ")===0&&(o=o.replace("Lcl ","Lcl_")),o==="Color"||o==="ColorRGB"||o==="Vector"||o==="Vector3D"||o.indexOf("Lcl_")===0?a=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:a=n.propertyList[4],t[s]={type:o,type2:i,flag:r,value:a}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const s=e.getUint32(),o=e.getUint32(),i=e.getUint32();if(o===0)switch(t){case"b":case"c":return e.getBooleanArray(s);case"d":return e.getFloat64Array(s);case"f":return e.getFloat32Array(s);case"i":return e.getInt32Array(s);case"l":return e.getInt64Array(s)}const r=es(new Uint8Array(e.getArrayBuffer(i))),a=new on(r.buffer);switch(t){case"b":case"c":return a.getBooleanArray(s);case"d":return a.getFloat64Array(s);case"f":return a.getFloat32Array(s);case"i":return a.getInt32Array(s);case"l":return a.getInt64Array(s)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class on{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let s=0;s<e;s++)t[s]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),l.LoaderUtils.decodeText(new Uint8Array(t))}}class rn{add(e,t){this[e]=t}}function ho(c){const e="Kaydara FBX Binary \0";return c.byteLength>=e.length&&e===hn(c,0,e.length)}function uo(c){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(s){const o=c[s-1];return c=c.slice(t+s),t++,o}for(let s=0;s<e.length;++s)if(n(1)===e[s])return!1;return!0}function an(c){const e=/FBXVersion: (\d+)/,t=c.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function po(c){return c/46186158e3}const fo=[];function ot(c,e,t,n){let s;switch(n.mappingType){case"ByPolygonVertex":s=c;break;case"ByPolygon":s=e;break;case"ByVertice":s=t;break;case"AllSame":s=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(s=n.indices[s]);const o=s*n.dataSize,i=o+n.dataSize;return go(fo,n.buffer,o,i)}const xt=new l.Euler,je=new l.Vector3;function ln(c){const e=new l.Matrix4,t=new l.Matrix4,n=new l.Matrix4,s=new l.Matrix4,o=new l.Matrix4,i=new l.Matrix4,r=new l.Matrix4,a=new l.Matrix4,u=new l.Matrix4,d=new l.Matrix4,p=new l.Matrix4,f=new l.Matrix4,m=c.inheritType?c.inheritType:0;if(c.translation&&e.setPosition(je.fromArray(c.translation)),c.preRotation){const k=c.preRotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),t.makeRotationFromEuler(xt.fromArray(k))}if(c.rotation){const k=c.rotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),n.makeRotationFromEuler(xt.fromArray(k))}if(c.postRotation){const k=c.postRotation.map(l.MathUtils.degToRad);k.push(c.eulerOrder),s.makeRotationFromEuler(xt.fromArray(k)),s.invert()}c.scale&&o.scale(je.fromArray(c.scale)),c.scalingOffset&&r.setPosition(je.fromArray(c.scalingOffset)),c.scalingPivot&&i.setPosition(je.fromArray(c.scalingPivot)),c.rotationOffset&&a.setPosition(je.fromArray(c.rotationOffset)),c.rotationPivot&&u.setPosition(je.fromArray(c.rotationPivot)),c.parentMatrixWorld&&(p.copy(c.parentMatrix),d.copy(c.parentMatrixWorld));const v=t.clone().multiply(n).multiply(s),_=new l.Matrix4;_.extractRotation(d);const A=new l.Matrix4;A.copyPosition(d);const M=A.clone().invert().multiply(d),O=_.clone().invert().multiply(M),b=o,g=new l.Matrix4;if(m===0)g.copy(_).multiply(v).multiply(O).multiply(b);else if(m===1)g.copy(_).multiply(O).multiply(v).multiply(b);else{const I=new l.Matrix4().scale(new l.Vector3().setFromMatrixScale(p)).clone().invert(),U=O.clone().multiply(I);g.copy(_).multiply(v).multiply(U).multiply(b)}const T=u.clone().invert(),x=i.clone().invert();let y=e.clone().multiply(a).multiply(u).multiply(t).multiply(n).multiply(s).multiply(T).multiply(r).multiply(i).multiply(o).multiply(x);const w=new l.Matrix4().copyPosition(y),D=d.clone().multiply(w);return f.copyPosition(D),y=f.clone().multiply(g),y.premultiply(d.invert()),y}function cn(c){c=c||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return c===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[c]}function Mt(c){return c.split(",").map(function(t){return parseFloat(t)})}function hn(c,e,t){return e===void 0&&(e=0),t===void 0&&(t=c.byteLength),l.LoaderUtils.decodeText(new Uint8Array(c,e,t))}function mo(c,e){for(let t=0,n=c.length,s=e.length;t<s;t++,n++)c[n]=e[t]}function go(c,e,t,n){for(let s=t,o=0;s<n;s++,o++)c[o]=e[s];return c}function un(c,e,t){return c.slice(0,e).concat(t).concat(c.slice(e))}var _o=Object.defineProperty,yo=(c,e,t)=>e in c?_o(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,bt=(c,e,t)=>(yo(c,typeof e!="symbol"?e+"":e,t),t);class wo extends l.Loader{constructor(e){super(e)}load(e,t,n,s){const o=new l.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,i=>{if(typeof i!="string")throw new Error("unsupported data type");const r=JSON.parse(i),a=this.parse(r);t&&t(a)},n,s)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new Tt(e)}}class Tt{constructor(e){bt(this,"data"),this.data=e}generateShapes(e,t=100,n){const s=[],o={letterSpacing:0,lineHeight:1,...n},i=vo(e,t,this.data,o);for(let r=0,a=i.length;r<a;r++)Array.prototype.push.apply(s,i[r].toShapes(!1));return s}}bt(Tt,"isFont"),bt(Tt,"type");function vo(c,e,t,n){const s=Array.from(c),o=e/t.resolution,i=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*o,r=[];let a=0,u=0;for(let d=0;d<s.length;d++){const p=s[d];if(p===`
74
+ `)a=0,u-=i*n.lineHeight;else{const f=Ao(p,o,a,u,t);f&&(a+=f.offsetX+n.letterSpacing,r.push(f.path))}}return r}function Ao(c,e,t,n,s){const o=s.glyphs[c]||s.glyphs["?"];if(!o){console.error('THREE.Font: character "'+c+'" does not exists in font family '+s.familyName+".");return}const i=new l.ShapePath;let r,a,u,d,p,f,m,v;if(o.o){const _=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let A=0,M=_.length;A<M;)switch(_[A++]){case"m":r=parseInt(_[A++])*e+t,a=parseInt(_[A++])*e+n,i.moveTo(r,a);break;case"l":r=parseInt(_[A++])*e+t,a=parseInt(_[A++])*e+n,i.lineTo(r,a);break;case"q":u=parseInt(_[A++])*e+t,d=parseInt(_[A++])*e+n,p=parseInt(_[A++])*e+t,f=parseInt(_[A++])*e+n,i.quadraticCurveTo(p,f,u,d);break;case"b":u=parseInt(_[A++])*e+t,d=parseInt(_[A++])*e+n,p=parseInt(_[A++])*e+t,f=parseInt(_[A++])*e+n,m=parseInt(_[A++])*e+t,v=parseInt(_[A++])*e+n,i.bezierCurveTo(p,f,m,v,u,d);break}}return{offsetX:o.ha*e,path:i}}class xo extends l.DataTextureLoader{constructor(e){super(e),this.type=l.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},p=`
75
+ `,f=function(b,g,T){g=g||1024;let y=b.pos,w=-1,D=0,k="",I=String.fromCharCode.apply(null,new Uint16Array(b.subarray(y,y+128)));for(;0>(w=I.indexOf(p))&&D<g&&y<b.byteLength;)k+=I,D+=I.length,y+=128,I+=String.fromCharCode.apply(null,new Uint16Array(b.subarray(y,y+128)));return-1<w?(T!==!1&&(b.pos+=D+w+1),k+I.slice(0,w)):!1},m=function(b){const g=/^#\?(\S+)/,T=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,x=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,y=/^\s*FORMAT=(\S+)\s*$/,w=/^\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=f(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=f(b),k!==!1;){if(D.string+=k+`
77
+ `,k.charAt(0)==="#"){D.comments+=k+`
78
+ `;continue}if((I=k.match(T))&&(D.gamma=parseFloat(I[1])),(I=k.match(x))&&(D.exposure=parseFloat(I[1])),(I=k.match(y))&&(D.valid|=2,D.format=I[1]),(I=k.match(w))&&(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")},v=function(b,g,T){const x=g;if(x<8||x>32767||b[0]!==2||b[1]!==2||b[2]&128)return new Uint8Array(b);if(x!==(b[2]<<8|b[3]))return r(3,"wrong scanline width");const y=new Uint8Array(4*g*T);if(!y.length)return r(4,"unable to allocate buffer space");let w=0,D=0;const k=4*x,I=new Uint8Array(4),U=new Uint8Array(k);let R=T;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])!=x)return r(3,"bad rgbe scanline format");let H=0,E;for(;H<k&&D<b.byteLength;){E=b[D++];const X=E>128;if(X&&(E-=128),E===0||H+E>k)return r(3,"bad scanline data");if(X){const ae=b[D++];for(let ie=0;ie<E;ie++)U[H++]=ae}else U.set(b.subarray(D,D+E),H),H+=E,D+=E}const ne=x;for(let X=0;X<ne;X++){let ae=0;y[w]=U[X+ae],ae+=x,y[w+1]=U[X+ae],ae+=x,y[w+2]=U[X+ae],ae+=x,y[w+3]=U[X+ae],w+=4}R--}return y},_=function(b,g,T,x){const y=b[g+3],w=Math.pow(2,y-128)/255;T[x+0]=b[g+0]*w,T[x+1]=b[g+1]*w,T[x+2]=b[g+2]*w,T[x+3]=1},A=function(b,g,T,x){const y=b[g+3],w=Math.pow(2,y-128)/255;T[x+0]=l.DataUtils.toHalfFloat(Math.min(b[g+0]*w,65504)),T[x+1]=l.DataUtils.toHalfFloat(Math.min(b[g+1]*w,65504)),T[x+2]=l.DataUtils.toHalfFloat(Math.min(b[g+2]*w,65504)),T[x+3]=l.DataUtils.toHalfFloat(1)},M=new Uint8Array(e);M.pos=0;const O=m(M);if(O!==-1){const b=O.width,g=O.height,T=v(M.subarray(M.pos),b,g);if(T!==-1){let x,y,w;switch(this.type){case l.FloatType:w=T.length/4;const D=new Float32Array(w*4);for(let I=0;I<w;I++)_(T,I*4,D,I*4);x=D,y=l.FloatType;break;case l.HalfFloatType:w=T.length/4;const k=new Uint16Array(w*4);for(let I=0;I<w;I++)A(T,I*4,k,I*4);x=k,y=l.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:b,height:g,data:x,header:O.string,gamma:O.gamma,exposure:O.exposure,type:y}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,s){function o(i,r){switch(i.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in i?i.colorSpace="srgb-linear":i.encoding=3e3,i.minFilter=l.LinearFilter,i.magFilter=l.LinearFilter,i.generateMipmaps=!1,i.flipY=!0;break}t&&t(i,r)}return super.load(e,o,n,s)}}const St=new WeakMap;class Mo extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const o=new l.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,i=>{const r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(i,r).then(t).catch(s)},n,s)}decodeDracoFile(e,t,n,s){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,o).then(t)}decodeGeometry(e,t){for(const a in t.attributeTypes){const u=t.attributeTypes[a];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[a]=u.name)}const n=JSON.stringify(t);if(St.has(e)){const a=St.get(e);if(a.key===n)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 s;const o=this.workerNextTaskID++,i=e.byteLength,r=this._getWorker(o,i).then(a=>(s=a,new Promise((u,d)=>{s._callbacks[o]={resolve:u,reject:d},s.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return r.catch(()=>!0).then(()=>{s&&o&&this._releaseTask(s,o)}),St.set(e,{key:n,promise:r}),r}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],o=s.name,i=s.array,r=s.itemSize;t.setAttribute(o,new l.BufferAttribute(i,r))}return t}_loadLibrary(e,t){const n=new l.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,o)=>{n.load(e,s,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=bo.toString(),i=["/* draco decoder */",s,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
79
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(o){const i=o.data;switch(i.type){case"decode":s._callbacks[i.id].resolve(i);break;case"error":s._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,o){return s._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function bo(){let c,e;onmessage=function(i){const r=i.data;switch(r.type){case"init":c=r.decoderConfig,e=new Promise(function(d){c.onModuleLoaded=function(p){d({draco:p})},DracoDecoderModule(c)});break;case"decode":const a=r.buffer,u=r.taskConfig;e.then(d=>{const p=d.draco,f=new p.Decoder,m=new p.DecoderBuffer;m.Init(new Int8Array(a),a.byteLength);try{const v=t(p,f,m,u),_=v.attributes.map(A=>A.array.buffer);v.index&&_.push(v.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:v},_)}catch(v){console.error(v),self.postMessage({type:"error",id:r.id,error:v.message})}finally{p.destroy(m),p.destroy(f)}});break}};function t(i,r,a,u){const d=u.attributeIDs,p=u.attributeTypes;let f,m;const v=r.GetEncodedGeometryType(a);if(v===i.TRIANGULAR_MESH)f=new i.Mesh,m=r.DecodeBufferToMesh(a,f);else if(v===i.POINT_CLOUD)f=new i.PointCloud,m=r.DecodeBufferToPointCloud(a,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!m.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+m.error_msg());const _={index:null,attributes:[]};for(const A in d){const M=self[p[A]];let O,b;if(u.useUniqueIDs)b=d[A],O=r.GetAttributeByUniqueId(f,b);else{if(b=r.GetAttributeId(f,i[d[A]]),b===-1)continue;O=r.GetAttribute(f,b)}_.attributes.push(s(i,r,f,A,M,O))}return v===i.TRIANGULAR_MESH&&(_.index=n(i,r,f)),i.destroy(f),_}function n(i,r,a){const d=a.num_faces()*3,p=d*4,f=i._malloc(p);r.GetTrianglesUInt32Array(a,p,f);const m=new Uint32Array(i.HEAPF32.buffer,f,d).slice();return i._free(f),{array:m,itemSize:1}}function s(i,r,a,u,d,p){const f=p.num_components(),v=a.num_points()*f,_=v*d.BYTES_PER_ELEMENT,A=o(i,d),M=i._malloc(_);r.GetAttributeDataArrayForAllPoints(a,p,A,_,M);const O=new d(i.HEAPF32.buffer,M,v).slice();return i._free(M),{name:u,array:O,itemSize:f}}function o(i,r){switch(r){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}const To=["args","center"],So=h.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(c,{expose:e}){let t,n;const s=c,{center:o,font:i,text:r,needUpdates:a,size:u,height:d,curveSegments:p,bevelEnabled:f,bevelThickness:m,bevelSize:v,bevelOffset:_,bevelSegments:A}=h.toRefs(s),{extend:M}=q.useTresContext();M({TextGeometry:tn});const O=new wo,b=h.useSlots(),g=h.computed(()=>{var w;return r!=null&&r.value?r.value:b.default?(w=b.default()[0].children)==null?void 0:w.trim():a.value?"":"TresJS"}),T=h.shallowRef();e({value:T});const x=([t,n]=h.withAsyncContext(()=>new Promise((w,D)=>{try{typeof i.value=="string"?O.load(i.value,k=>{w(k)}):w(i.value)}catch(k){D(console.error("cientos",k))}})),t=await t,n(),t),y=h.computed(()=>({font:x,size:h.toValue(u),height:h.toValue(d),curveSegments:h.toValue(p),bevelEnabled:h.toValue(f),bevelThickness:h.toValue(m),bevelSize:h.toValue(v),bevelOffset:h.toValue(_),bevelSegments:h.toValue(A)}));return h.watchEffect(()=>{T.value&&a.value&&(T.value.geometry.dispose(),T.value.geometry=new tn(g.value,y.value),o.value&&T.value.geometry.center())}),(w,D)=>h.unref(i)?(h.openBlock(),h.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:T},[g.value?(h.openBlock(),h.createElementBlock("TresTextGeometry",{key:0,args:[g.value,y.value],center:h.unref(o)},null,8,To)):h.createCommentVNode("",!0),h.renderSlot(w.$slots,"default")],512)):h.createCommentVNode("",!0)}});function Lo(c,e){const t=h.ref(e),n=new l.AnimationMixer(t.value),s=h.shallowReactive({});c.forEach(i=>{const r=n.clipAction(i,t.value);s[i.name]=r});const{onLoop:o}=q.useRenderLoop();return o(({delta:i})=>{n.update(i)}),{actions:s,mixer:n}}const Lt={sunset:"venice/venice_sunset_4k.hdr"};async function pn({files:c=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],blur:e=0,background:t=!1,path:n="/",preset:s=void 0}){const{scene:o}=q.useTresContext();if(s){if(!(s in Lt))throw new Error("Preset must be one of: "+Object.keys(Lt).join(", "));c=Lt[s],n="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/"}const i=Array.isArray(c),r=i?l.CubeTextureLoader:xo,a=await q.useLoader(r,i?[c]:c,d=>{n&&d.setPath(n)}),u=i?a[0]:a;return u&&(u.mapping=i?l.CubeReflectionMapping:l.EquirectangularReflectionMapping,u.colorSpace=l.SRGBColorSpace),o.value&&(o.value.environment=u,t&&(o.value.background=u),e&&(o.value.backgroundBlurriness=e|0)),u}const Oo=h.defineComponent({name:"Environment",props:["background","blur","files","encoding","path","preset"],async setup(c,{expose:e}){let t=null;return e({getTexture:()=>t}),t=await pn(c),()=>{}}}),Po=["position","a-scale"],Co=["size","size-attenuation","transparent","alpha-test","alpha-map"],Do=h.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(c,{expose:e}){const t=c,n=h.ref(),s=h.ref(),{radius:o,depth:i,count:r,size:a,sizeAttenuation:u,transparent:d,alphaMap:p,alphaTest:f}=h.toRefs(t),m=()=>{let _=o.value+i.value;const A=h.computed(()=>i.value/r.value),M=[],O=Array.from({length:r.value},()=>(.5+.5*Math.random())*4),b=g=>new l.Vector3().setFromSpherical(new l.Spherical(g,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let g=0;g<r.value;g++)_-=A.value*Math.random(),M.push(...b(_));n.value=new Float32Array(M),s.value=new Float32Array(O)};h.watchEffect(()=>{m()});const v=h.shallowRef();return e({value:v}),(_,A)=>(h.openBlock(),h.createElementBlock("TresPoints",{ref_key:"starsRef",ref:v},[h.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[s.value,1]},null,8,Po),h.createElementVNode("TresPointsMaterial",{size:h.unref(a),"size-attenuation":h.unref(u),transparent:h.unref(d),"alpha-test":h.unref(f),"alpha-map":h.unref(p)},null,8,Co)],512))}}),Io=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],ko=["position","velocity"],Fo=h.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(c){const e=c,{size:t,area:n,color:s,alphaMap:o,map:i,opacity:r,alphaTest:a,depthWrite:u,transparent:d,sizeAttenuation:p,count:f,speed:m,randomness:v}=h.toRefs(e),_=h.shallowRef();let A=[],M=[];const O=()=>{A=new Float32Array(f.value*3);for(let T=0;T<f.value;T++){const x=T*3;A[x]=(Math.random()-.5)*n.value[0],A[x+1]=(Math.random()-.5)*n.value[1],A[x+2]=(Math.random()-.5)*n.value[2]}},b=()=>{M=new Float32Array(f.value*2);for(let T=0;T<f.value*2;T+=2)M[T]=(Math.random()-.5)/5*m.value*v.value,M[T+1]=Math.random()/5*m.value+.01};b(),O(),h.watchEffect(()=>{b(),O()});const{onLoop:g}=q.useRenderLoop();return g(()=>{var T,x;if((T=_.value)!=null&&T.attributes.position.array&&((x=_.value)!=null&&x.attributes.position.count)){const y=_.value.attributes.position.array;for(let w=0;w<_.value.attributes.position.count;w++){const D=M[w*2],k=M[w*2+1];y[w*3]+=D,y[w*3+1]-=k,(y[w*3]<=-n.value[0]/2||y[w*3]>=n.value[0]/2)&&(y[w*3]=y[w*3]*-1),(y[w*3+1]<=-n.value[1]/2||y[w*3+1]>=n.value[1]/2)&&(y[w*3+1]=y[w*3+1]*-1)}_.value.attributes.position.needsUpdate=!0}}),(T,x)=>(h.openBlock(),h.createElementBlock("TresPoints",null,[h.createElementVNode("TresPointsMaterial",{size:h.unref(t),color:h.unref(s),"alpha-map":h.unref(o),map:h.unref(i),opacity:h.unref(r),"alpha-test":h.unref(a),"depth-write":h.unref(u),transparent:h.unref(d),"size-attenuation":h.unref(p)},null,8,Io),h.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:_,position:[h.unref(A),3],velocity:[h.unref(M)]},null,8,ko)]))}}),Uo=["position"],Bo=["position"],Vo=["scale"],No=["map","depth-test","color-space","color","opacity"],zo=h.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(c,{expose:e}){let t,n;const s=c,{width:o,depth:i,segments:r,texture:a,color:u,depthTest:d,opacity:p,speed:f}=h.toRefs(s),m=h.shallowRef(),v=h.shallowRef();e({value:m});const _=[...new Array(r)].map((x,y)=>({x:o.value/2-Math.random()*o.value,y:o.value/2-Math.random()*o.value,scale:.4+Math.sin((y+1)/r.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*f.value})),A=(x,y)=>x/6*y*p.value,{map:M}=([t,n]=h.withAsyncContext(()=>q.useTexture({map:a.value})),t=await t,n(),t),{renderer:O,camera:b}=q.useTresContext(),g=h.computed(()=>{var x;return(x=O.value)==null?void 0:x.outputColorSpace}),{onLoop:T}=q.useRenderLoop();return T(()=>{var x,y;m.value&&b.value&&v.value&&((x=v.value)==null||x.children.forEach((w,D)=>{w.rotation.z+=_[D].rotation}),m.value.lookAt((y=b.value)==null?void 0:y.position))}),(x,y)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps({ref_key:"smokeRef",ref:m},x.$attrs),[h.createElementVNode("TresGroup",{ref_key:"groupRef",ref:v,position:[0,0,h.unref(r)/2*h.unref(i)]},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(h.unref(_),({scale:w,x:D,y:k,density:I},U)=>(h.openBlock(),h.createElementBlock("TresMesh",{key:`${U}`,position:[D,k,-U*h.unref(i)]},[h.createElementVNode("TresPlaneGeometry",{scale:[w,w,w],rotation:[0,0,0]},null,8,Vo),h.createElementVNode("TresMeshStandardMaterial",{map:h.unref(M),"depth-test":h.unref(d),"color-space":g.value,color:h.unref(u),"depth-write":!1,transparent:"",opacity:A(w,I)},null,8,No)],8,Bo))),128))],8,Uo)],16))}}),Ro=h.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(c,{expose:e}){const t=c,n=h.shallowRef();e({value:n});const{onLoop:s}=q.useRenderLoop(),o=h.ref(Math.random()*1e4);return s(({elapsed:i})=>{var u,d;if(!n.value)return;const r=o.value+i;n.value.rotation.x=Math.cos(r/4*t.speed)/8*t.rotationFactor,n.value.rotation.y=Math.sin(r/4*t.speed)/8*t.rotationFactor,n.value.rotation.z=Math.sin(r/4*t.speed)/20*t.rotationFactor;let a=Math.sin(r/4*t.speed)/10;a=l.MathUtils.mapLinear(a,-.1,.1,((u=t.range)==null?void 0:u[0])??-.1,((d=t.range)==null?void 0:d[1])??.1),n.value.position.y=a*t.floatFactor}),(i,r)=>(h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps(i.$attrs,{ref_key:"groupRef",ref:n}),[h.renderSlot(i.$slots,"default")],16))}}),Eo=["geometry"],Go=["map","opacity","depth-write"],jo=["args"],Yo=["rotation","args"],Xo=h.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(c,{expose:e}){const t=c,n=h.shallowRef(),s=h.shallowRef();e(n);let o,i,r,a,u;const{renderer:d,scene:p}=q.useTresContext(),f=h.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),m=h.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));h.watchEffect(()=>{o&&o.dispose(),i&&i.dispose(),r&&r.dispose(),a&&a.geometry.dispose(),o=new l.WebGLRenderTarget(t.resolution,t.resolution),i=new l.WebGLRenderTarget(t.resolution,t.resolution),i.texture.generateMipmaps=o.texture.generateMipmaps=!1,s.value=new l.OrthographicCamera(-f.value/2,f.value/2,m.value/2,-m.value/2,0,t.far),r=new l.PlaneGeometry(f.value,m.value).rotateX(Math.PI/2),a=new l.Mesh(r),a.visible=!1}),h.watchEffect(()=>{t.color&&(u&&u.dispose(),u=new l.MeshDepthMaterial,u.depthTest=u.depthWrite=!1,u.onBeforeCompile=T=>{T.uniforms={...T.uniforms,ucolor:{value:t.color?new l.Color(t.color):new l.Color}},T.fragmentShader=T.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
80
80
  void main() {
81
- `),A.fragmentShader=A.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const y=new l.ShaderMaterial(Js),_=new l.ShaderMaterial(Hs);_.depthTest=y.depthTest=!1;function x(A){!d.value||!s.value||(a.visible=!0,a.material=y,y.uniforms.tDiffuse.value=o.texture,y.uniforms.h.value=A/256,d.value.setRenderTarget(i),d.value.render(a,s.value),a.material=_,_.uniforms.tDiffuse.value=i.texture,_.uniforms.v.value=A/256,d.value.setRenderTarget(o),d.value.render(a,s.value),a.visible=!1)}const{onLoop:S}=q.useRenderLoop();let O=0,M,g;return S(()=>{!s.value||p.value===void 0||d.value===void 0||(t.frames===1/0||O<t.frames)&&(O++,M=p.value.background,g=p.value.overrideMaterial,n.value.visible=!1,p.value.background=null,p.value.overrideMaterial=u,d.value.setRenderTarget(o),d.value.render(p.value,s.value),x(t.blur),t.smooth&&x(t.blur*.4),d.value.setRenderTarget(null),n.value.visible=!0,p.value.background=M,p.value.overrideMaterial=g)}),(A,b)=>{const w=h.resolveComponent("primitive");return h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps({ref_key:"groupRef",ref:n},A.$attrs),[h.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:h.unref(r)},[h.createElementVNode("TresMeshBasicMaterial",{map:h.unref(o).texture,opacity:A.opacity,"depth-write":A.depthWrite,transparent:!0},null,8,Yo)],8,jo),h.createVNode(w,{object:h.unref(a)},null,8,["object"]),s.value&&A.helper?(h.openBlock(),h.createElementBlock("TresCameraHelper",{key:0,args:[s.value]},null,8,Xo)):h.createCommentVNode("",!0),h.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:s,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-f.value/2,f.value/2,m.value/2,-m.value/2,0,A.far]},null,8,Zo)],16)}}});function dn(c){return h.getCurrentScope()?(h.onScopeDispose(c),!0):!1}function we(c){return typeof c=="function"?c():h.unref(c)}const Ko=typeof window<"u",Ie=()=>{};function fn(c,e){function t(...n){return new Promise((s,o)=>{Promise.resolve(c(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})).then(s).catch(o)})}return t}function Wo(c,e={}){let t,n,s=Ie;const o=r=>{clearTimeout(r),s(),s=Ie};return r=>{const a=we(c),u=we(e.maxWait);return t&&o(t),a<=0||u!==void 0&&u<=0?(n&&(o(n),n=null),Promise.resolve(r())):new Promise((d,p)=>{s=e.rejectOnCancel?p:d,u&&!n&&(n=setTimeout(()=>{t&&o(t),n=null,d(r())},u)),t=setTimeout(()=>{n&&o(n),n=null,d(r())},a)})}}function qo(c,e=!0,t=!0,n=!1){let s=0,o,i=!0,r=Ie,a;const u=()=>{o&&(clearTimeout(o),o=void 0,r(),r=Ie)};return p=>{const f=we(c),m=Date.now()-s,y=()=>a=p();return u(),f<=0?(s=Date.now(),y()):(m>f&&(t||!i)?(s=Date.now(),y()):e&&(a=new Promise((_,x)=>{r=n?x:_,o=setTimeout(()=>{s=Date.now(),i=!0,_(y()),u()},Math.max(0,f-m))})),!t&&!o&&(o=setTimeout(()=>i=!0,f)),i=!1,a)}}function Jo(...c){if(c.length!==1)return h.toRef(...c);const e=c[0];return typeof e=="function"?h.readonly(h.customRef(()=>({get:e,set:Ie}))):h.ref(e)}function Ho(c,e=200,t={}){return fn(Wo(e,t),c)}function $o(c,e=200,t=!1,n=!0,s=!1){return fn(qo(e,t,n,s),c)}function ei(c,e=!0){h.getCurrentInstance()?h.onMounted(c):e?c():h.nextTick(c)}function ti(c){var e;const t=we(c);return(e=t==null?void 0:t.$el)!=null?e:t}const je=Ko?window:void 0;function oe(...c){let e,t,n,s;if(typeof c[0]=="string"||Array.isArray(c[0])?([t,n,s]=c,e=je):[e,t,n,s]=c,!e)return Ie;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const o=[],i=()=>{o.forEach(d=>d()),o.length=0},r=(d,p,f,m)=>(d.addEventListener(p,f,m),()=>d.removeEventListener(p,f,m)),a=h.watch(()=>[ti(e),we(s)],([d,p])=>{i(),d&&o.push(...t.flatMap(f=>n.map(m=>r(d,f,m,p))))},{immediate:!0,flush:"post"}),u=()=>{a(),i()};return dn(u),u}function ni(c){return typeof c=="function"?c:typeof c=="string"?e=>e.key===c:Array.isArray(c)?e=>c.includes(e.key):()=>!0}function Be(...c){let e,t,n={};c.length===3?(e=c[0],t=c[1],n=c[2]):c.length===2?typeof c[1]=="object"?(e=!0,t=c[0],n=c[1]):(e=c[0],t=c[1]):(e=!0,t=c[0]);const{target:s=je,eventName:o="keydown",passive:i=!1,dedupe:r=!1}=n,a=ni(e);return oe(s,o,d=>{d.repeat&&we(r)||a(d)&&t(d)},i)}function si(){const c=h.ref(!1);return h.getCurrentInstance()&&h.onMounted(()=>{c.value=!0}),c}function oi(c){const e=si();return h.computed(()=>(e.value,!!c()))}function ii(c,e={}){const{window:t=je}=e,n=oi(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let s;const o=h.ref(!1),i=()=>{s&&("removeEventListener"in s?s.removeEventListener("change",r):s.removeListener(r))},r=()=>{n.value&&(i(),s=t.matchMedia(Jo(c).value),o.value=!!(s!=null&&s.matches),s&&("addEventListener"in s?s.addEventListener("change",r):s.addListener(r)))};return h.watchEffect(r),dn(()=>i()),o}const mn=1;function ri(c,e={}){const{throttle:t=0,idle:n=200,onStop:s=Ie,onScroll:o=Ie,offset:i={left:0,right:0,top:0,bottom:0},eventListenerOptions:r={capture:!1,passive:!0},behavior:a="auto"}=e,u=h.ref(0),d=h.ref(0),p=h.computed({get(){return u.value},set(A){m(A,void 0)}}),f=h.computed({get(){return d.value},set(A){m(void 0,A)}});function m(A,b){var w,v,C;const k=we(c);k&&((C=k instanceof Document?document.body:k)==null||C.scrollTo({top:(w=we(b))!=null?w:f.value,left:(v=we(A))!=null?v:p.value,behavior:we(a)}))}const y=h.ref(!1),_=h.reactive({left:!0,right:!1,top:!0,bottom:!1}),x=h.reactive({left:!1,right:!1,top:!1,bottom:!1}),S=A=>{y.value&&(y.value=!1,x.left=!1,x.right=!1,x.top=!1,x.bottom=!1,s(A))},O=Ho(S,t+n),M=A=>{const b=A===window?A.document.documentElement:A===document?A.documentElement:A,{display:w,flexDirection:v}=getComputedStyle(b),C=b.scrollLeft;x.left=C<u.value,x.right=C>u.value;const k=Math.abs(C)<=0+(i.left||0),I=Math.abs(C)+b.clientWidth>=b.scrollWidth-(i.right||0)-mn;w==="flex"&&v==="row-reverse"?(_.left=I,_.right=k):(_.left=k,_.right=I),u.value=C;let U=b.scrollTop;A===document&&!U&&(U=document.body.scrollTop),x.top=U<d.value,x.bottom=U>d.value;const j=Math.abs(U)<=0+(i.top||0),H=Math.abs(U)+b.clientHeight>=b.scrollHeight-(i.bottom||0)-mn;w==="flex"&&v==="column-reverse"?(_.top=H,_.bottom=j):(_.top=j,_.bottom=H),d.value=U},g=A=>{const b=A.target===document?A.target.documentElement:A.target;M(b),y.value=!0,O(A),o(A)};return oe(c,"scroll",t?$o(g,t,!0,!1):g,r),oe(c,"scrollend",S,r),{x:p,y:f,isScrolling:y,arrivedState:_,directions:x,measure(){const A=we(c);A&&M(A)}}}const ai={page:c=>[c.pageX,c.pageY],client:c=>[c.clientX,c.clientY],screen:c=>[c.screenX,c.screenY],movement:c=>c instanceof Touch?null:[c.movementX,c.movementY]};function li(c={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:s={x:0,y:0},window:o=je,target:i=o,eventFilter:r}=c,a=h.ref(s.x),u=h.ref(s.y),d=h.ref(null),p=typeof e=="function"?e:ai[e],f=S=>{const O=p(S);O&&([a.value,u.value]=O,d.value="mouse")},m=S=>{if(S.touches.length>0){const O=p(S.touches[0]);O&&([a.value,u.value]=O,d.value="touch")}},y=()=>{a.value=s.x,u.value=s.y},_=r?S=>r(()=>f(S),{}):S=>f(S),x=r?S=>r(()=>m(S),{}):S=>m(S);return i&&(oe(i,"mousemove",_,{passive:!0}),oe(i,"dragover",_,{passive:!0}),t&&e!=="movement"&&(oe(i,"touchstart",x,{passive:!0}),oe(i,"touchmove",x,{passive:!0}),n&&oe(i,"touchend",y,{passive:!0}))),{x:a,y:u,sourceType:d}}function ci({window:c=je}={}){if(!c)return{x:h.ref(0),y:h.ref(0)};const e=h.ref(c.scrollX),t=h.ref(c.scrollY);return oe(c,"scroll",()=>{e.value=c.scrollX,t.value=c.scrollY},{capture:!1,passive:!0}),{x:e,y:t}}function gn(c={}){const{window:e=je,initialWidth:t=1/0,initialHeight:n=1/0,listenOrientation:s=!0,includeScrollbar:o=!0}=c,i=h.ref(t),r=h.ref(n),a=()=>{e&&(o?(i.value=e.innerWidth,r.value=e.innerHeight):(i.value=e.document.documentElement.clientWidth,r.value=e.document.documentElement.clientHeight))};if(a(),ei(a),oe("resize",a,{passive:!0}),s){const u=ii("(orientation: portrait)");h.watch(u,()=>a())}return{width:i,height:r}}const hi=h.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(c){const e=c,{camera:t}=q.useTresContext(),{disabled:n,factor:s,ease:o}=h.toRefs(e),{x:i,y:r}=li(),{width:a,height:u}=gn(),d=h.ref(),p=h.computed(()=>(i.value/a.value-.5)*s.value),f=h.computed(()=>-(r.value/u.value-.5)*s.value),{onLoop:m}=q.useRenderLoop();return m(({delta:y})=>{n.value||!d.value||(d.value.position.x+=(p.value-d.value.position.x)*o.value*y,d.value.position.y+=(f.value-d.value.position.y)*o.value*y)}),h.watch(()=>d.value,y=>{y==null||y.add(t.value)}),(y,_)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:d},null,512))}});let it=null;function ui(c,e){return t=>{e&&e(t),c.draco&&(it||(it=new To),it.setDecoderPath(c.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(it))}}async function _n(c,e={draco:!1},t){return await q.useLoader(ys,c,ui(e,t))}const pi=h.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"}},async setup(c,{expose:e}){let t,n;const s=c,o=h.ref();e({value:o});const{scene:i}=([t,n]=h.withAsyncContext(()=>_n(s.path,{draco:s.draco,decoderPath:s.decoderPath})),t=await t,n(),t);return(r,a)=>{const u=h.resolveComponent("primitive");return h.openBlock(),h.createBlock(u,h.mergeProps({ref_key:"modelRef",ref:o,object:h.unref(i)},r.$attrs),null,16,["object"])}}});async function yn(c){return await q.useLoader(ro,c)}const di=h.defineComponent({__name:"component",props:{path:{}},async setup(c,{expose:e}){let t,n;const s=c,o=h.ref();e({value:o});const i=([t,n]=h.withAsyncContext(()=>yn(s.path)),t=await t,n(),t);return(r,a)=>{const u=h.resolveComponent("primitive");return h.openBlock(),h.createBlock(u,h.mergeProps({ref_key:"modelRef",ref:o,object:h.unref(i)},r.$attrs),null,16,["object"])}}}),wn="[TresJS - Cientos ▲ ■ ♥] ";function fi(){function c(n,s){console.error(`${wn} ${n}`,s||"")}function e(n){console.warn(`${wn} ${n}`)}function t(n,s){}return{logError:c,logWarning:e,logMessage:t}}let Ot=0;function mi(){const c=h.ref(!1),e=h.ref(0),t=h.ref([]),{logError:n}=fi();return new Promise(s=>{l.DefaultLoadingManager.onStart=()=>{c.value=!1},l.DefaultLoadingManager.onLoad=()=>{c.value=!0},l.DefaultLoadingManager.onProgress=(o,i,r)=>{i===r&&(Ot=r,c.value=!0,t.value.push(o)),e.value=Math.round((i-Ot)/(r-Ot)*100||100,2)},l.DefaultLoadingManager.onError=o=>{n("Error loading assets",new Error(o)),c.value=!0},s({items:t,hasFinishLoading:c,progress:e})})}const gi=["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"],_i=h.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!1},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(c,{emit:e}){const t=c,{makeDefault:n,autoRotate:s,autoRotateSpeed:o,enableDamping:i,dampingFactor:r,enablePan:a,keyPanSpeed:u,maxAzimuthAngle:d,minAzimuthAngle:p,maxPolarAngle:f,minPolarAngle:m,minDistance:y,maxDistance:_,minZoom:x,maxZoom:S,enableZoom:O,zoomSpeed:M,enableRotate:g,touches:A,rotateSpeed:b,target:w}=h.toRefs(t),{camera:v,renderer:C,extend:k,controls:I}=q.useTresContext(),U=h.ref(null);k({OrbitControls:Kt}),h.watch(U,G=>{j(),G&&n.value?I.value=G:I.value=null});function j(){oe(U.value,"change",()=>e("change",U.value)),oe(U.value,"start",()=>e("start",U.value)),oe(U.value,"end",()=>e("end",U.value))}const{onLoop:H}=q.useRenderLoop();return H(()=>{U.value&&(i.value||s.value)&&U.value.update()}),h.onUnmounted(()=>{U.value&&U.value.dispose()}),(G,ne)=>{var X;return h.unref(v)&&h.unref(C)?(h.openBlock(),h.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:U,target:h.unref(w),"auto-rotate":h.unref(s),"auto-rotate-speed":h.unref(o),"enable-damping":h.unref(i),"damping-factor":h.unref(r),"enable-pan":h.unref(a),"key-pan-speed":h.unref(u),keys:G.keys,"max-azimuth-angle":h.unref(d),"min-azimuth-angle":h.unref(p),"max-polar-angle":h.unref(f),"min-polar-angle":h.unref(m),"min-distance":h.unref(y),"max-distance":h.unref(_),"min-zoom":h.unref(x),"max-zoom":h.unref(S),touches:h.unref(A),"enable-zoom":h.unref(O),"zoom-speed":h.unref(M),"enable-rotate":h.unref(g),"rotate-speed":h.unref(b),args:[h.unref(v)||G.camera,((X=h.unref(C))==null?void 0:X.domElement)||G.domElement]},null,8,gi)):h.createCommentVNode("",!0)}}}),yi=5,wi=6,vi=.3,Ai=h.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(c){var k;const e=c,{forward:t,back:n,left:s,right:o,jump:i,gravity:r,moveSpeed:a,headBobbing:u,is2D:d}=h.toRefs(e),{camera:p,controls:f}=q.useTresContext(),m=h.ref(0),y=h.ref(0),_=h.ref(!1),x=h.ref(!1),S=h.ref(0),O=h.shallowRef(),M=d.value?"y":"z";let g=((k=p.value.position)==null?void 0:k.y)||0;Be(t.value,()=>{_.value=!0,y.value=a.value},{eventName:"keydown"}),Be(n.value,()=>{_.value=!0,y.value=-a.value},{eventName:"keydown"}),Be([...t.value,...n.value],()=>{_.value=!1,y.value=0},{eventName:"keyup"}),Be(s.value,()=>{_.value=!0,m.value=-a.value},{eventName:"keydown"}),Be(o.value,()=>{_.value=!0,m.value=a.value},{eventName:"keydown"}),Be([...s.value,...o.value],()=>{_.value=!1,m.value=0},{eventName:"keyup"}),Be(i.value,()=>{x.value||(S.value=Date.now()),x.value=!0});const A=I=>_.value?Math.sin(I*yi)*vi+g:g,b=()=>(Date.now()-S.value)/1e3*3,w=I=>g+wi*I-.5*r.value*Math.pow(I,2),v=()=>{if(x.value){const I=w(b());return I<=g&&(x.value=!1),I}return 0},{onLoop:C}=q.useRenderLoop();return C(({elapsed:I})=>{var U;f.value instanceof gt&&((U=f.value)!=null&&U.isLocked)?(f.value.moveForward(y.value),f.value.moveRight(m.value),p.value.position&&(p.value.position.y=u.value?A(I):g,p.value.position.y+=v())):O.value.children.length>0&&!(f.value instanceof gt)&&(O.value.position.x+=m.value,O.value.position[M]+=d.value?y.value:-y.value)}),(I,U)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:O},[h.renderSlot(I.$slots,"default")],512))}}),xi=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Mi=h.defineComponent({__name:"TransformControls",props:{object:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(c,{emit:e}){const t=c,{object:n,mode:s,enabled:o,axis:i,translationSnap:r,rotationSnap:a,scaleSnap:u,space:d,size:p,showX:f,showY:m,showZ:y}=h.toRefs(t),_=h.shallowRef(),{controls:x,camera:S,renderer:O,extend:M}=q.useTresContext();M({TransformControls:as});const g=b=>{x.value&&(x.value.enabled=!b.value),e("dragging",b.value)};function A(){oe(_.value,"change",()=>e("change")),oe(_.value,"dragging-changed",g),oe(_.value,"mouseDown",()=>e("mouseDown")),oe(_.value,"mouseUp",()=>e("mouseUp")),oe(_.value,"objectChange",()=>e("objectChange"))}return h.watchEffect(()=>{_.value&&A()}),h.onUnmounted(()=>{_.value&&_.value.dispose()}),(b,w)=>h.unref(S)&&h.unref(O)?(h.openBlock(),h.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:_,object:h.unref(n),args:[h.unref(S),h.unref(O).domElement],mode:h.unref(s),enabled:h.unref(o),axis:h.unref(i),"translation-snap":h.unref(r),"rotation-snap":h.unref(a),"scale-snap":h.unref(u),space:h.unref(d),size:h.unref(p),"show-x":h.unref(f),"show-y":h.unref(m),"show-z":h.unref(y),visible:!0},null,8,xi)):h.createCommentVNode("",!0)}}),bi=["args"],Ti=h.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock"],setup(c,{expose:e,emit:t}){const n=c,{camera:s,renderer:o,extend:i,controls:r}=q.useTresContext(),a=h.ref(null);let u;i({PointerLockControls:gt});const d=p=>{t("isLock",p)};return h.watch(a,p=>{p&&n.makeDefault?r.value=p:r.value=null;const f=document.getElementById(n.selector||"");u=f||o.value.domElement,oe(u,"click",()=>{var m,y,_;(m=r.value)==null||m.lock(),(y=r.value)==null||y.addEventListener("lock",()=>d(!0)),(_=r.value)==null||_.addEventListener("unlock",()=>d(!1))})}),h.onUnmounted(()=>{var p,f;(p=r.value)==null||p.removeEventListener("lock",()=>d(!0)),(f=r.value)==null||f.removeEventListener("unlock",()=>d(!1)),a.value&&a.value.dispose()}),e({value:r}),(p,f)=>{var m;return h.unref(s)&&h.unref(o)?(h.openBlock(),h.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:a,args:[h.unref(s)||p.camera,((m=h.unref(o))==null?void 0:m.domElement)||p.domElement]},null,8,bi)):h.createCommentVNode("",!0)}}}),Si=["args"],Li=h.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(c){const e=c,{camera:t,renderer:n,extend:s,controls:o}=q.useTresContext(),i=h.ref(null);return s({MapControls:_s}),h.watch(o,r=>{r&&e.makeDefault?o.value=r:o.value=null}),h.onUnmounted(()=>{i.value&&i.value.dispose()}),(r,a)=>{var u;return h.unref(t)&&h.unref(n)?(h.openBlock(),h.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:i,args:[h.unref(t)||r.camera,((u=h.unref(n))==null?void 0:u.domElement)||r.domElement]},null,8,Si)):h.createCommentVNode("",!0)}}}),Oi=h.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(c,{emit:e}){const t=c,{logWarning:n}=q.useLogger();t.smoothScroll<0&&n("SmoothControl must be greater than zero"),t.pages<0&&n("Pages must be greater than zero");const{camera:s,controls:o,renderer:i}=q.useTresContext(),r=h.shallowRef(),a=document.createElement("div"),{y:u}=ci(),{x:d,y:p,isScrolling:f}=ri(a),{height:m,width:y}=gn();let _=0;const x=h.ref(!1),S=h.ref(0),O=h.ref(0),M=h.ref(0),g=t.horizontal?"x":"y",A=h.watch(s,w=>{if(x.value){A();return}_=t.horizontal?(w==null?void 0:w.position.x)||0:(w==null?void 0:w.position.y)||0,x.value=!0},{immediate:!0});h.watch(f,w=>{o.value&&(o.value.enabled=!w)},{immediate:!0}),h.watch(u,w=>{!f.value&&!t.htmlScroll||(O.value=parseFloat((w/m.value/(M.value/m.value-1)).toFixed(2)),S.value=-1*O.value,e("update:modelValue",O.value))}),h.watch(p,w=>{O.value=parseFloat((w/m.value/(M.value/m.value)).toFixed(2)),S.value=-1*O.value,e("update:modelValue",O.value)}),h.watch(d,w=>{O.value=parseFloat((w/y.value/(M.value/y.value-1)).toFixed(2)),S.value=+O.value,e("update:modelValue",O.value)}),h.watch(i,w=>{var C,k;const v=w==null?void 0:w.domElement;if(t.htmlScroll&&(w!=null&&w.domElement))v!=null&&v.style.width&&(v!=null&&v.style.position)&&(v!=null&&v.style.top)&&(v!=null&&v.style.left)&&(v.style.width="100%",v.style.position="fixed",v.style.zIndex=" -99999",v.style.top="0",v.style.left="0"),M.value=document.body.scrollHeight;else{const I=document.createElement("div"),U=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),U.style.height=t.horizontal?"100%":`${m.value*t.pages}px`,U.style.width=t.horizontal?`${y.value*t.pages}px`:"100vw",U.style.pointerEvents="none",v.style.position="fixed",v.style.zIndex="0",v!=null&&v.style.width&&(v.style.width="100%"),a.appendChild(U),w.domElement.parentNode.style.position="relative",(k=(C=w==null?void 0:w.domElement)==null?void 0:C.parentNode)==null||k.appendChild(a),M.value=t.horizontal?y.value*t.pages:m.value*t.pages}},{immediate:!0});const{onLoop:b}=q.useRenderLoop();return b(()=>{var w;if((w=s.value)!=null&&w.position){const v=(S.value*t.distance-s.value.position[g]+_)*t.smoothScroll;s.value.position[g]+=v,r.value.children.length>0&&(r.value.position[g]+=v)}}),(w,v)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:r},[h.renderSlot(w.$slots,"default")],512))}});/*!
81
+ `),T.fragmentShader=T.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const v=new l.ShaderMaterial(Ws),_=new l.ShaderMaterial(qs);_.depthTest=v.depthTest=!1;function A(T){!d.value||!s.value||(a.visible=!0,a.material=v,v.uniforms.tDiffuse.value=o.texture,v.uniforms.h.value=T/256,d.value.setRenderTarget(i),d.value.render(a,s.value),a.material=_,_.uniforms.tDiffuse.value=i.texture,_.uniforms.v.value=T/256,d.value.setRenderTarget(o),d.value.render(a,s.value),a.visible=!1)}const{onLoop:M}=q.useRenderLoop();let O=0,b,g;return M(()=>{!s.value||p.value===void 0||d.value===void 0||(t.frames===1/0||O<t.frames)&&(O++,b=p.value.background,g=p.value.overrideMaterial,n.value.visible=!1,p.value.background=null,p.value.overrideMaterial=u,d.value.setRenderTarget(o),d.value.render(p.value,s.value),A(t.blur),t.smooth&&A(t.blur*.4),d.value.setRenderTarget(null),n.value.visible=!0,p.value.background=b,p.value.overrideMaterial=g)}),(T,x)=>{const y=h.resolveComponent("primitive");return h.openBlock(),h.createElementBlock("TresGroup",h.mergeProps({ref_key:"groupRef",ref:n},T.$attrs),[h.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:h.unref(r)},[h.createElementVNode("TresMeshBasicMaterial",{map:h.unref(o).texture,opacity:T.opacity,"depth-write":T.depthWrite,transparent:!0},null,8,Go)],8,Eo),h.createVNode(y,{object:h.unref(a)},null,8,["object"]),s.value&&T.helper?(h.openBlock(),h.createElementBlock("TresCameraHelper",{key:0,args:[s.value]},null,8,jo)):h.createCommentVNode("",!0),h.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:s,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-f.value/2,f.value/2,m.value/2,-m.value/2,0,T.far]},null,8,Yo)],16)}}});function dn(c){return h.getCurrentScope()?(h.onScopeDispose(c),!0):!1}function ge(c){return typeof c=="function"?c():h.unref(c)}const Zo=typeof window<"u",Ue=()=>{};function fn(c,e){function t(...n){return new Promise((s,o)=>{Promise.resolve(c(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})).then(s).catch(o)})}return t}function Qo(c,e={}){let t,n,s=Ue;const o=r=>{clearTimeout(r),s(),s=Ue};return r=>{const a=ge(c),u=ge(e.maxWait);return t&&o(t),a<=0||u!==void 0&&u<=0?(n&&(o(n),n=null),Promise.resolve(r())):new Promise((d,p)=>{s=e.rejectOnCancel?p:d,u&&!n&&(n=setTimeout(()=>{t&&o(t),n=null,d(r())},u)),t=setTimeout(()=>{n&&o(n),n=null,d(r())},a)})}}function Ko(c,e=!0,t=!0,n=!1){let s=0,o,i=!0,r=Ue,a;const u=()=>{o&&(clearTimeout(o),o=void 0,r(),r=Ue)};return p=>{const f=ge(c),m=Date.now()-s,v=()=>a=p();return u(),f<=0?(s=Date.now(),v()):(m>f&&(t||!i)?(s=Date.now(),v()):e&&(a=new Promise((_,A)=>{r=n?A:_,o=setTimeout(()=>{s=Date.now(),i=!0,_(v()),u()},Math.max(0,f-m))})),!t&&!o&&(o=setTimeout(()=>i=!0,f)),i=!1,a)}}function Wo(c,e=200,t={}){return fn(Qo(e,t),c)}function qo(c,e=200,t=!1,n=!0,s=!1){return fn(Ko(e,t,n,s),c)}function Jo(c,e=!0){h.getCurrentInstance()?h.onMounted(c):e?c():h.nextTick(c)}function Ho(c){var e;const t=ge(c);return(e=t==null?void 0:t.$el)!=null?e:t}const Be=Zo?window:void 0;function re(...c){let e,t,n,s;if(typeof c[0]=="string"||Array.isArray(c[0])?([t,n,s]=c,e=Be):[e,t,n,s]=c,!e)return Ue;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const o=[],i=()=>{o.forEach(d=>d()),o.length=0},r=(d,p,f,m)=>(d.addEventListener(p,f,m),()=>d.removeEventListener(p,f,m)),a=h.watch(()=>[Ho(e),ge(s)],([d,p])=>{i(),d&&o.push(...t.flatMap(f=>n.map(m=>r(d,f,m,p))))},{immediate:!0,flush:"post"}),u=()=>{a(),i()};return dn(u),u}function $o(c){return typeof c=="function"?c:typeof c=="string"?e=>e.key===c:Array.isArray(c)?e=>c.includes(e.key):()=>!0}function Ve(...c){let e,t,n={};c.length===3?(e=c[0],t=c[1],n=c[2]):c.length===2?typeof c[1]=="object"?(e=!0,t=c[0],n=c[1]):(e=c[0],t=c[1]):(e=!0,t=c[0]);const{target:s=Be,eventName:o="keydown",passive:i=!1,dedupe:r=!1}=n,a=$o(e);return re(s,o,d=>{d.repeat&&ge(r)||a(d)&&t(d)},i)}function ei(){const c=h.ref(!1);return h.getCurrentInstance()&&h.onMounted(()=>{c.value=!0}),c}function ti(c){const e=ei();return h.computed(()=>(e.value,!!c()))}function ni(c,e={}){const{window:t=Be}=e,n=ti(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let s;const o=h.ref(!1),i=u=>{o.value=u.matches},r=()=>{s&&("removeEventListener"in s?s.removeEventListener("change",i):s.removeListener(i))},a=h.watchEffect(()=>{n.value&&(r(),s=t.matchMedia(ge(c)),"addEventListener"in s?s.addEventListener("change",i):s.addListener(i),o.value=s.matches)});return dn(()=>{a(),r(),s=void 0}),o}const mn=1;function si(c,e={}){const{throttle:t=0,idle:n=200,onStop:s=Ue,onScroll:o=Ue,offset:i={left:0,right:0,top:0,bottom:0},eventListenerOptions:r={capture:!1,passive:!0},behavior:a="auto",window:u=Be}=e,d=h.ref(0),p=h.ref(0),f=h.computed({get(){return d.value},set(x){v(x,void 0)}}),m=h.computed({get(){return p.value},set(x){v(void 0,x)}});function v(x,y){var w,D,k;if(!u)return;const I=ge(c);I&&((k=I instanceof Document?u.document.body:I)==null||k.scrollTo({top:(w=ge(y))!=null?w:m.value,left:(D=ge(x))!=null?D:f.value,behavior:ge(a)}))}const _=h.ref(!1),A=h.reactive({left:!0,right:!1,top:!0,bottom:!1}),M=h.reactive({left:!1,right:!1,top:!1,bottom:!1}),O=x=>{_.value&&(_.value=!1,M.left=!1,M.right=!1,M.top=!1,M.bottom=!1,s(x))},b=Wo(O,t+n),g=x=>{if(!u)return;const y=x===u?x.document.documentElement:x===u.document?x.documentElement:x,{display:w,flexDirection:D}=getComputedStyle(y),k=y.scrollLeft;M.left=k<d.value,M.right=k>d.value;const I=Math.abs(k)<=0+(i.left||0),U=Math.abs(k)+y.clientWidth>=y.scrollWidth-(i.right||0)-mn;w==="flex"&&D==="row-reverse"?(A.left=U,A.right=I):(A.left=I,A.right=U),d.value=k;let R=y.scrollTop;x===u.document&&!R&&(R=u.document.body.scrollTop),M.top=R<p.value,M.bottom=R>p.value;const H=Math.abs(R)<=0+(i.top||0),E=Math.abs(R)+y.clientHeight>=y.scrollHeight-(i.bottom||0)-mn;w==="flex"&&D==="column-reverse"?(A.top=E,A.bottom=H):(A.top=H,A.bottom=E),p.value=R},T=x=>{if(!u)return;const y=x.target===u.document?x.target.documentElement:x.target;g(y),_.value=!0,b(x),o(x)};return re(c,"scroll",t?qo(T,t,!0,!1):T,r),re(c,"scrollend",O,r),{x:f,y:m,isScrolling:_,arrivedState:A,directions:M,measure(){const x=ge(c);u&&x&&g(x)}}}const oi={page:c=>[c.pageX,c.pageY],client:c=>[c.clientX,c.clientY],screen:c=>[c.screenX,c.screenY],movement:c=>c instanceof Touch?null:[c.movementX,c.movementY]};function ii(c={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:s={x:0,y:0},window:o=Be,target:i=o,eventFilter:r}=c,a=h.ref(s.x),u=h.ref(s.y),d=h.ref(null),p=typeof e=="function"?e:oi[e],f=M=>{const O=p(M);O&&([a.value,u.value]=O,d.value="mouse")},m=M=>{if(M.touches.length>0){const O=p(M.touches[0]);O&&([a.value,u.value]=O,d.value="touch")}},v=()=>{a.value=s.x,u.value=s.y},_=r?M=>r(()=>f(M),{}):M=>f(M),A=r?M=>r(()=>m(M),{}):M=>m(M);if(i){const M={passive:!0};re(i,["mousemove","dragover"],_,M),t&&e!=="movement"&&(re(i,["touchstart","touchmove"],A,M),n&&re(i,"touchend",v,M))}return{x:a,y:u,sourceType:d}}function ri({window:c=Be}={}){if(!c)return{x:h.ref(0),y:h.ref(0)};const e=h.ref(c.scrollX),t=h.ref(c.scrollY);return re(c,"scroll",()=>{e.value=c.scrollX,t.value=c.scrollY},{capture:!1,passive:!0}),{x:e,y:t}}function gn(c={}){const{window:e=Be,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:n=Number.POSITIVE_INFINITY,listenOrientation:s=!0,includeScrollbar:o=!0}=c,i=h.ref(t),r=h.ref(n),a=()=>{e&&(o?(i.value=e.innerWidth,r.value=e.innerHeight):(i.value=e.document.documentElement.clientWidth,r.value=e.document.documentElement.clientHeight))};if(a(),Jo(a),re("resize",a,{passive:!0}),s){const u=ni("(orientation: portrait)");h.watch(u,()=>a())}return{width:i,height:r}}const ai=h.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(c){const e=c,{camera:t}=q.useTresContext(),{disabled:n,factor:s,ease:o}=h.toRefs(e),{x:i,y:r}=ii(),{width:a,height:u}=gn(),d=h.ref(),p=h.computed(()=>(i.value/a.value-.5)*s.value),f=h.computed(()=>-(r.value/u.value-.5)*s.value),{onLoop:m}=q.useRenderLoop();return m(({delta:v})=>{n.value||!d.value||(d.value.position.x+=(p.value-d.value.position.x)*o.value*v,d.value.position.y+=(f.value-d.value.position.y)*o.value*v)}),h.watch(()=>d.value,v=>{v==null||v.add(t.value)}),(v,_)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:d},null,512))}});let it=null;function li(c,e){return t=>{e&&e(t),c.draco&&(it||(it=new Mo),it.setDecoderPath(c.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(it))}}async function _n(c,e={draco:!1},t){return await q.useLoader(gs,c,li(e,t))}const ci=h.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"}},async setup(c,{expose:e}){let t,n;const s=c,o=h.ref();e({value:o});const{scene:i}=([t,n]=h.withAsyncContext(()=>_n(s.path,{draco:s.draco,decoderPath:s.decoderPath})),t=await t,n(),t);return(r,a)=>{const u=h.resolveComponent("primitive");return h.openBlock(),h.createBlock(u,h.mergeProps({ref_key:"modelRef",ref:o,object:h.unref(i)},r.$attrs),null,16,["object"])}}});async function yn(c){return await q.useLoader(oo,c)}const hi=h.defineComponent({__name:"component",props:{path:{}},async setup(c,{expose:e}){let t,n;const s=c,o=h.ref();e({value:o});const i=([t,n]=h.withAsyncContext(()=>yn(s.path)),t=await t,n(),t);return(r,a)=>{const u=h.resolveComponent("primitive");return h.openBlock(),h.createBlock(u,h.mergeProps({ref_key:"modelRef",ref:o,object:h.unref(i)},r.$attrs),null,16,["object"])}}}),wn="[TresJS - Cientos ▲ ■ ♥] ";function vn(){function c(n,s){console.error(`${wn} ${n}`,s||"")}function e(n){console.warn(`${wn} ${n}`)}function t(n,s){}return{logError:c,logWarning:e,logMessage:t}}let Ot=0;function ui(){const c=h.ref(!1),e=h.ref(0),t=h.ref([]),{logError:n}=vn();return new Promise(s=>{l.DefaultLoadingManager.onStart=()=>{c.value=!1},l.DefaultLoadingManager.onLoad=()=>{c.value=!0},l.DefaultLoadingManager.onProgress=(o,i,r)=>{i===r&&(Ot=r,c.value=!0,t.value.push(o)),e.value=Math.round((i-Ot)/(r-Ot)*100||100,2)},l.DefaultLoadingManager.onError=o=>{n("Error loading assets",new Error(o)),c.value=!0},s({items:t,hasFinishLoading:c,progress:e})})}async function pi(c,e){const{logError:t}=vn();if(!c)return t("Error no path provided");const{unsuspend:n,start:s,crossOrigin:o,muted:i,loop:r,...a}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function u(){return new Promise((d,p)=>{const f=Object.assign(document.createElement("video"),{src:typeof c=="string"&&c||void 0,crossOrigin:o,loop:r,muted:i,autoplay:!0,...a}),m=new l.VideoTexture(f);return f.addEventListener(n,()=>d(m)),f.addEventListener("error",()=>p()),m})}try{const d=await u();return s&&d.image&&d.image.play(),d}catch{t("Error loading resource")}}const di=["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"],fi=h.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!1},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(c,{emit:e}){const t=c,{makeDefault:n,autoRotate:s,autoRotateSpeed:o,enableDamping:i,dampingFactor:r,enablePan:a,keyPanSpeed:u,maxAzimuthAngle:d,minAzimuthAngle:p,maxPolarAngle:f,minPolarAngle:m,minDistance:v,maxDistance:_,minZoom:A,maxZoom:M,enableZoom:O,zoomSpeed:b,enableRotate:g,touches:T,rotateSpeed:x,target:y}=h.toRefs(t),{camera:w,renderer:D,extend:k,controls:I}=q.useTresContext(),U=h.ref(null);k({OrbitControls:Kt}),h.watch(U,E=>{R(),E&&n.value?I.value=E:I.value=null});function R(){re(U.value,"change",()=>e("change",U.value)),re(U.value,"start",()=>e("start",U.value)),re(U.value,"end",()=>e("end",U.value))}const{onLoop:H}=q.useRenderLoop();return H(()=>{U.value&&(i.value||s.value)&&U.value.update()}),h.onUnmounted(()=>{U.value&&U.value.dispose()}),(E,ne)=>{var X;return h.unref(w)&&h.unref(D)?(h.openBlock(),h.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:U,target:h.unref(y),"auto-rotate":h.unref(s),"auto-rotate-speed":h.unref(o),"enable-damping":h.unref(i),"damping-factor":h.unref(r),"enable-pan":h.unref(a),"key-pan-speed":h.unref(u),keys:E.keys,"max-azimuth-angle":h.unref(d),"min-azimuth-angle":h.unref(p),"max-polar-angle":h.unref(f),"min-polar-angle":h.unref(m),"min-distance":h.unref(v),"max-distance":h.unref(_),"min-zoom":h.unref(A),"max-zoom":h.unref(M),touches:h.unref(T),"enable-zoom":h.unref(O),"zoom-speed":h.unref(b),"enable-rotate":h.unref(g),"rotate-speed":h.unref(x),args:[h.unref(w)||E.camera,((X=h.unref(D))==null?void 0:X.domElement)||E.domElement]},null,8,di)):h.createCommentVNode("",!0)}}}),mi=5,gi=6,_i=.3,yi=h.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(c){var k;const e=c,{forward:t,back:n,left:s,right:o,jump:i,gravity:r,moveSpeed:a,headBobbing:u,is2D:d}=h.toRefs(e),{camera:p,controls:f}=q.useTresContext(),m=h.ref(0),v=h.ref(0),_=h.ref(!1),A=h.ref(!1),M=h.ref(0),O=h.shallowRef(),b=d.value?"y":"z";let g=((k=p.value.position)==null?void 0:k.y)||0;Ve(t.value,()=>{_.value=!0,v.value=a.value},{eventName:"keydown"}),Ve(n.value,()=>{_.value=!0,v.value=-a.value},{eventName:"keydown"}),Ve([...t.value,...n.value],()=>{_.value=!1,v.value=0},{eventName:"keyup"}),Ve(s.value,()=>{_.value=!0,m.value=-a.value},{eventName:"keydown"}),Ve(o.value,()=>{_.value=!0,m.value=a.value},{eventName:"keydown"}),Ve([...s.value,...o.value],()=>{_.value=!1,m.value=0},{eventName:"keyup"}),Ve(i.value,()=>{A.value||(M.value=Date.now()),A.value=!0});const T=I=>_.value?Math.sin(I*mi)*_i+g:g,x=()=>(Date.now()-M.value)/1e3*3,y=I=>g+gi*I-.5*r.value*Math.pow(I,2),w=()=>{if(A.value){const I=y(x());return I<=g&&(A.value=!1),I}return 0},{onLoop:D}=q.useRenderLoop();return D(({elapsed:I})=>{var U;f.value instanceof gt&&((U=f.value)!=null&&U.isLocked)?(f.value.moveForward(v.value),f.value.moveRight(m.value),p.value.position&&(p.value.position.y=u.value?T(I):g,p.value.position.y+=w())):O.value.children.length>0&&!(f.value instanceof gt)&&(O.value.position.x+=m.value,O.value.position[b]+=d.value?v.value:-v.value)}),(I,U)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:O},[h.renderSlot(I.$slots,"default")],512))}}),wi=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],vi=h.defineComponent({__name:"TransformControls",props:{object:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(c,{emit:e}){const t=c,{object:n,mode:s,enabled:o,axis:i,translationSnap:r,rotationSnap:a,scaleSnap:u,space:d,size:p,showX:f,showY:m,showZ:v}=h.toRefs(t),_=h.shallowRef(),{controls:A,camera:M,renderer:O,extend:b}=q.useTresContext();b({TransformControls:is});const g=x=>{A.value&&(A.value.enabled=!x.value),e("dragging",x.value)};function T(){re(_.value,"change",()=>e("change")),re(_.value,"dragging-changed",g),re(_.value,"mouseDown",()=>e("mouseDown")),re(_.value,"mouseUp",()=>e("mouseUp")),re(_.value,"objectChange",()=>e("objectChange"))}return h.watchEffect(()=>{_.value&&T()}),h.onUnmounted(()=>{_.value&&_.value.dispose()}),(x,y)=>h.unref(M)&&h.unref(O)?(h.openBlock(),h.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:_,object:h.unref(n),args:[h.unref(M),h.unref(O).domElement],mode:h.unref(s),enabled:h.unref(o),axis:h.unref(i),"translation-snap":h.unref(r),"rotation-snap":h.unref(a),"scale-snap":h.unref(u),space:h.unref(d),size:h.unref(p),"show-x":h.unref(f),"show-y":h.unref(m),"show-z":h.unref(v),visible:!0},null,8,wi)):h.createCommentVNode("",!0)}}),Ai=["args"],xi=h.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock"],setup(c,{expose:e,emit:t}){const n=c,{camera:s,renderer:o,extend:i,controls:r}=q.useTresContext(),a=h.ref(null);let u;i({PointerLockControls:gt});const d=p=>{t("isLock",p)};return h.watch(a,p=>{p&&n.makeDefault?r.value=p:r.value=null;const f=document.getElementById(n.selector||"");u=f||o.value.domElement,re(u,"click",()=>{var m,v,_;(m=r.value)==null||m.lock(),(v=r.value)==null||v.addEventListener("lock",()=>d(!0)),(_=r.value)==null||_.addEventListener("unlock",()=>d(!1))})}),h.onUnmounted(()=>{var p,f;(p=r.value)==null||p.removeEventListener("lock",()=>d(!0)),(f=r.value)==null||f.removeEventListener("unlock",()=>d(!1)),a.value&&a.value.dispose()}),e({value:r}),(p,f)=>{var m;return h.unref(s)&&h.unref(o)?(h.openBlock(),h.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:a,args:[h.unref(s)||p.camera,((m=h.unref(o))==null?void 0:m.domElement)||p.domElement]},null,8,Ai)):h.createCommentVNode("",!0)}}}),Mi=["args"],bi=h.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(c){const e=c,{camera:t,renderer:n,extend:s,controls:o}=q.useTresContext(),i=h.ref(null);return s({MapControls:ms}),h.watch(o,r=>{r&&e.makeDefault?o.value=r:o.value=null}),h.onUnmounted(()=>{i.value&&i.value.dispose()}),(r,a)=>{var u;return h.unref(t)&&h.unref(n)?(h.openBlock(),h.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:i,args:[h.unref(t)||r.camera,((u=h.unref(n))==null?void 0:u.domElement)||r.domElement]},null,8,Mi)):h.createCommentVNode("",!0)}}}),Ti=h.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(c,{emit:e}){const t=c,{logWarning:n}=q.useLogger();t.smoothScroll<0&&n("SmoothControl must be greater than zero"),t.pages<0&&n("Pages must be greater than zero");const{camera:s,controls:o,renderer:i}=q.useTresContext(),r=h.shallowRef(),a=document.createElement("div"),{y:u}=ri(),{x:d,y:p,isScrolling:f}=si(a),{height:m,width:v}=gn();let _=0;const A=h.ref(!1),M=h.ref(0),O=h.ref(0),b=h.ref(0),g=t.horizontal?"x":"y",T=h.watch(s,y=>{if(A.value){T();return}_=t.horizontal?(y==null?void 0:y.position.x)||0:(y==null?void 0:y.position.y)||0,A.value=!0},{immediate:!0});h.watch(f,y=>{o.value&&(o.value.enabled=!y)},{immediate:!0}),h.watch(u,y=>{!f.value&&!t.htmlScroll||(O.value=parseFloat((y/m.value/(b.value/m.value-1)).toFixed(2)),M.value=-1*O.value,e("update:modelValue",O.value))}),h.watch(p,y=>{O.value=parseFloat((y/m.value/(b.value/m.value)).toFixed(2)),M.value=-1*O.value,e("update:modelValue",O.value)}),h.watch(d,y=>{O.value=parseFloat((y/v.value/(b.value/v.value-1)).toFixed(2)),M.value=+O.value,e("update:modelValue",O.value)}),h.watch(i,y=>{var D,k;const w=y==null?void 0:y.domElement;if(t.htmlScroll&&(y!=null&&y.domElement))w!=null&&w.style.width&&(w!=null&&w.style.position)&&(w!=null&&w.style.top)&&(w!=null&&w.style.left)&&(w.style.width="100%",w.style.position="fixed",w.style.zIndex=" -99999",w.style.top="0",w.style.left="0"),b.value=document.body.scrollHeight;else{const I=document.createElement("div"),U=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),U.style.height=t.horizontal?"100%":`${m.value*t.pages}px`,U.style.width=t.horizontal?`${v.value*t.pages}px`:"100vw",U.style.pointerEvents="none",w.style.position="fixed",w.style.zIndex="0",w!=null&&w.style.width&&(w.style.width="100%"),a.appendChild(U),y.domElement.parentNode.style.position="relative",(k=(D=y==null?void 0:y.domElement)==null?void 0:D.parentNode)==null||k.appendChild(a),b.value=t.horizontal?v.value*t.pages:m.value*t.pages}},{immediate:!0});const{onLoop:x}=q.useRenderLoop();return x(()=>{var y;if((y=s.value)!=null&&y.position){const w=(M.value*t.distance-s.value.position[g]+_)*t.smoothScroll;s.value.position[g]+=w,r.value.children.length>0&&(r.value.position[g]+=w)}}),(y,w)=>(h.openBlock(),h.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:r},[h.renderSlot(y.$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 N={LEFT:1,RIGHT:2,MIDDLE:4},D=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}),Ye={NONE:0,IN:1,OUT:-1};function Ve(c){return c.isPerspectiveCamera}function ke(c){return c.isOrthographicCamera}const Xe=Math.PI*2,vn=Math.PI/2,An=1e-5,Je=Math.PI/180;function xe(c,e,t){return Math.max(e,Math.min(t,c))}function te(c,e=An){return Math.abs(c)<e}function J(c,e,t=An){return te(c-e,t)}function xn(c,e){return Math.round(c/e)*e}function He(c){return isFinite(c)?c:c<0?-Number.MAX_VALUE:Number.MAX_VALUE}function $e(c){return Math.abs(c)<Number.MAX_VALUE?c:c*(1/0)}function rt(c,e,t,n,s=1/0,o){n=Math.max(1e-4,n);const i=2/n,r=i*o,a=1/(1+r+.48*r*r+.235*r*r*r);let u=c-e;const d=e,p=s*n;u=xe(u,-p,p),e=c-u;const f=(t.value+i*u)*o;t.value=(t.value-i*f)*a;let m=e+(u+f)*a;return d-c>0==m>d&&(m=d,t.value=(m-d)/o),m}function Mn(c,e,t,n,s=1/0,o,i){n=Math.max(1e-4,n);const r=2/n,a=r*o,u=1/(1+a+.48*a*a+.235*a*a*a);let d=e.x,p=e.y,f=e.z,m=c.x-d,y=c.y-p,_=c.z-f;const x=d,S=p,O=f,M=s*n,g=M*M,A=m*m+y*y+_*_;if(A>g){const G=Math.sqrt(A);m=m/G*M,y=y/G*M,_=_/G*M}d=c.x-m,p=c.y-y,f=c.z-_;const b=(t.x+r*m)*o,w=(t.y+r*y)*o,v=(t.z+r*_)*o;t.x=(t.x-r*b)*u,t.y=(t.y-r*w)*u,t.z=(t.z-r*v)*u,i.x=d+(m+b)*u,i.y=p+(y+w)*u,i.z=f+(_+v)*u;const C=x-c.x,k=S-c.y,I=O-c.z,U=i.x-x,j=i.y-S,H=i.z-O;return C*U+k*j+I*H>0&&(i.x=x,i.y=S,i.z=O,t.x=(i.x-x)/o,t.y=(i.y-S)/o,t.z=(i.z-O)/o),i}function Pt(c,e){e.set(0,0),c.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=c.length,e.y/=c.length}function Ct(c,e){return ke(c)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Pi{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners[e];if(s!==void 0){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let o=0,i=s.length;o<i;o++)s[o].call(this,e)}}}const Ci="2.7.0",at=1/8,bn=typeof window<"u",Di=bn&&/Mac/.test(navigator.platform),Ii=!(bn&&"PointerEvent"in window);let V,Tn,lt,Dt,pe,R,W,Ze,et,Me,be,Ne,Sn,Ln,ge,tt,Qe,On,It,Pn,kt,Ft,ct;class nt extends Pi{static install(e){V=e.THREE,Tn=Object.freeze(new V.Vector3(0,0,0)),lt=Object.freeze(new V.Vector3(0,1,0)),Dt=Object.freeze(new V.Vector3(0,0,1)),pe=new V.Vector2,R=new V.Vector3,W=new V.Vector3,Ze=new V.Vector3,et=new V.Vector3,Me=new V.Vector3,be=new V.Vector3,Ne=new V.Vector3,Sn=new V.Vector3,Ln=new V.Vector3,ge=new V.Spherical,tt=new V.Spherical,Qe=new V.Box3,On=new V.Box3,It=new V.Sphere,Pn=new V.Quaternion,kt=new V.Quaternion,Ft=new V.Matrix4,ct=new V.Raycaster}static get ACTION(){return D}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=D.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=Ye.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new V.Vector3,this._focalOffsetVelocity=new V.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,A,b)=>{let w,v;if(Ve(this._camera)){const C=R.copy(this._camera.position).sub(this._target),k=this._camera.getEffectiveFOV()*Je,I=C.length()*Math.tan(k*.5);w=this.truckSpeed*g*I/this._elementRect.height,v=this.truckSpeed*A*I/this._elementRect.height}else if(ke(this._camera)){const C=this._camera;w=g*(C.right-C.left)/C.zoom/this._elementRect.width,v=A*(C.top-C.bottom)/C.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+w,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(w,0,!0),this.forward(-v,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+w,this._focalOffsetEnd.y+v,this._focalOffsetEnd.z,!0):this.truck(w,v,!0)},this._rotateInternal=(g,A)=>{const b=Xe*this.azimuthRotateSpeed*g/this._elementRect.height,w=Xe*this.polarRotateSpeed*A/this._elementRect.height;this.rotate(b,w,!0)},this._dollyInternal=(g,A,b)=>{const w=Math.pow(.95,-g*this.dollySpeed),v=this._sphericalEnd.radius,C=this._sphericalEnd.radius*w,k=V.MathUtils.clamp(C,this.minDistance,this.maxDistance),I=k-C;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(C,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(I,!0),this._dollyToNoClamp(k,!0)):this._dollyToNoClamp(k,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?C:k)-v,this._dollyControlCoord.set(A,b)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,A,b)=>{const w=Math.pow(.95,g*this.dollySpeed),v=this._zoom,C=this._zoom*w;this.zoomTo(C,!0),this.dollyToCursor&&(this._changedZoom+=C-v,this._dollyControlCoord.set(A,b))},typeof V>"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 V.Quaternion().setFromUnitVectors(this._camera.up,lt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=D.NONE,this._target=new V.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new V.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new V.Spherical().setFromVector3(R.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 V.Vector3,new V.Vector3,new V.Vector3,new V.Vector3],this._updateNearPlaneCorners(),this._boundary=new V.Box3(new V.Vector3(-1/0,-1/0,-1/0),new V.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 V.Vector2,this.mouseButtons={left:D.ROTATE,middle:D.DOLLY,right:D.TRUCK,wheel:Ve(this._camera)?D.DOLLY:ke(this._camera)?D.ZOOM:D.NONE},this.touches={one:D.TOUCH_ROTATE,two:Ve(this._camera)?D.TOUCH_DOLLY_TRUCK:ke(this._camera)?D.TOUCH_ZOOM_TRUCK:D.NONE,three:D.TOUCH_TRUCK};const n=new V.Vector2,s=new V.Vector2,o=new V.Vector2,i=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 w=this._domElement.getBoundingClientRect(),v=g.clientX/w.width,C=g.clientY/w.height;if(v<this._interactiveArea.left||v>this._interactiveArea.right||C<this._interactiveArea.top||C>this._interactiveArea.bottom)return}const A=g.pointerType!=="mouse"?null:(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.MIDDLE?N.MIDDLE:(g.buttons&N.RIGHT)===N.RIGHT?N.RIGHT:null;if(A!==null){const w=this._findPointerByMouseButton(A);w&&this._disposePointer(w)}if((g.buttons&N.LEFT)===N.LEFT&&this._lockedPointer)return;const b={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:A};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),this._isDragging=!0,_(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 w=this._domElement.getBoundingClientRect(),v=g.clientX/w.width,C=g.clientY/w.height;if(v<this._interactiveArea.left||v>this._interactiveArea.right||C<this._interactiveArea.top||C>this._interactiveArea.bottom)return}const A=(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.MIDDLE?N.MIDDLE:(g.buttons&N.RIGHT)===N.RIGHT?N.RIGHT:null;if(A!==null){const w=this._findPointerByMouseButton(A);w&&this._disposePointer(w)}const b={pointerId:1,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.LEFT?N.MIDDLE:(g.buttons&N.RIGHT)===N.LEFT?N.RIGHT:null};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",p),this._domElement.ownerDocument.addEventListener("mousemove",u),this._domElement.ownerDocument.addEventListener("mouseup",p),this._isDragging=!0,_(g)},a=g=>{g.cancelable&&g.preventDefault();const A=g.pointerId,b=this._lockedPointer||this._findPointerById(A);if(b){if(b.clientX=g.clientX,b.clientY=g.clientY,b.deltaX=g.movementX,b.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&N.LEFT)===N.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right);x()}},u=g=>{const A=this._lockedPointer||this._findPointerById(1);A&&(A.clientX=g.clientX,A.clientY=g.clientY,A.deltaX=g.movementX,A.deltaY=g.movementY,this._state=0,(this._lockedPointer||(g.buttons&N.LEFT)===N.LEFT)&&(this._state=this._state|this.mouseButtons.left),(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right),x())},d=g=>{const A=this._findPointerById(g.pointerId);if(!(A&&A===this._lockedPointer)){if(A&&this._disposePointer(A),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=D.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=D.NONE;S()}},p=()=>{const g=this._findPointerById(1);g&&g===this._lockedPointer||(g&&this._disposePointer(g),this._state=D.NONE,S())};let f=-1;const m=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===D.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),k=g.clientX/C.width,I=g.clientY/C.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===D.ROTATE||this.mouseButtons.wheel===D.TRUCK){const C=performance.now();f-C<1e3&&this._getClientRect(this._elementRect),f=C}const A=Di?-1:-3,b=g.deltaMode===1?g.deltaY/A:g.deltaY/(A*10),w=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,v=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case D.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case D.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case D.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case D.DOLLY:{this._dollyInternal(-b,w,v),this._isUserControllingDolly=!0;break}case D.ZOOM:{this._zoomInternal(-b,w,v),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},y=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===nt.ACTION.NONE){const A=g instanceof PointerEvent?g.pointerId:(g instanceof MouseEvent,0),b=this._findPointerById(A);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",p);return}g.preventDefault()}},_=g=>{if(!this._enabled)return;if(Pt(this._activePointers,pe),this._getClientRect(this._elementRect),n.copy(pe),s.copy(pe),this._activePointers.length>=2){const b=pe.x-this._activePointers[1].clientX,w=pe.y-this._activePointers[1].clientY,v=Math.sqrt(b*b+w*w);o.set(0,v);const C=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,k=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;s.set(C,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&N.LEFT)===N.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&D.ROTATE)===D.ROTATE||(this._state&D.TOUCH_ROTATE)===D.TOUCH_ROTATE||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE||(this._state&D.TOUCH_ZOOM_ROTATE)===D.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&D.TRUCK)===D.TRUCK||(this._state&D.TOUCH_TRUCK)===D.TOUCH_TRUCK||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_ZOOM_TRUCK)===D.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&D.DOLLY)===D.DOLLY||(this._state&D.TOUCH_DOLLY)===D.TOUCH_DOLLY||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&D.ZOOM)===D.ZOOM||(this._state&D.TOUCH_ZOOM)===D.TOUCH_ZOOM||(this._state&D.TOUCH_ZOOM_TRUCK)===D.TOUCH_ZOOM_TRUCK||(this._state&D.TOUCH_ZOOM_OFFSET)===D.TOUCH_ZOOM_OFFSET||(this._state&D.TOUCH_ZOOM_ROTATE)===D.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&D.OFFSET)===D.OFFSET||(this._state&D.TOUCH_OFFSET)===D.TOUCH_OFFSET||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET||(this._state&D.TOUCH_ZOOM_OFFSET)===D.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},x=()=>{if(!this._enabled)return;Pt(this._activePointers,pe);const A=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=A?-A.deltaX:s.x-pe.x,w=A?-A.deltaY:s.y-pe.y;if(s.copy(pe),((this._state&D.ROTATE)===D.ROTATE||(this._state&D.TOUCH_ROTATE)===D.TOUCH_ROTATE||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE||(this._state&D.TOUCH_ZOOM_ROTATE)===D.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,w),this._isUserControllingRotate=!0),(this._state&D.DOLLY)===D.DOLLY||(this._state&D.ZOOM)===D.ZOOM){const v=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,C=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,k=this.dollyDragInverted?-1:1;(this._state&D.DOLLY)===D.DOLLY?(this._dollyInternal(k*w*at,v,C),this._isUserControllingDolly=!0):(this._zoomInternal(k*w*at,v,C),this._isUserControllingZoom=!0)}if((this._state&D.TOUCH_DOLLY)===D.TOUCH_DOLLY||(this._state&D.TOUCH_ZOOM)===D.TOUCH_ZOOM||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_ZOOM_TRUCK)===D.TOUCH_ZOOM_TRUCK||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET||(this._state&D.TOUCH_ZOOM_OFFSET)===D.TOUCH_ZOOM_OFFSET||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE||(this._state&D.TOUCH_ZOOM_ROTATE)===D.TOUCH_ZOOM_ROTATE){const v=pe.x-this._activePointers[1].clientX,C=pe.y-this._activePointers[1].clientY,k=Math.sqrt(v*v+C*C),I=o.y-k;o.set(0,k);const U=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,j=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&D.TOUCH_DOLLY)===D.TOUCH_DOLLY||(this._state&D.TOUCH_DOLLY_ROTATE)===D.TOUCH_DOLLY_ROTATE||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET?(this._dollyInternal(I*at,U,j),this._isUserControllingDolly=!0):(this._zoomInternal(I*at,U,j),this._isUserControllingZoom=!0)}((this._state&D.TRUCK)===D.TRUCK||(this._state&D.TOUCH_TRUCK)===D.TOUCH_TRUCK||(this._state&D.TOUCH_DOLLY_TRUCK)===D.TOUCH_DOLLY_TRUCK||(this._state&D.TOUCH_ZOOM_TRUCK)===D.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,w,!1),this._isUserControllingTruck=!0),((this._state&D.OFFSET)===D.OFFSET||(this._state&D.TOUCH_OFFSET)===D.TOUCH_OFFSET||(this._state&D.TOUCH_DOLLY_OFFSET)===D.TOUCH_DOLLY_OFFSET||(this._state&D.TOUCH_ZOOM_OFFSET)===D.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,w,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},S=()=>{Pt(this._activePointers,pe),s.copy(pe),(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",u),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",p),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",O),this._domElement.ownerDocument.addEventListener("pointerlockerror",M),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),_())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",O),this._domElement.ownerDocument.removeEventListener("pointerlockerror",M))};const O=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},M=()=>{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",i),Ii&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",d),this._domElement.addEventListener("wheel",m,{passive:!1}),this._domElement.addEventListener("contextmenu",y)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",i),this._domElement.removeEventListener("mousedown",r),this._domElement.removeEventListener("pointercancel",d),this._domElement.removeEventListener("wheel",m,{passive:!1}),this._domElement.removeEventListener("contextmenu",y),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",p),this._domElement.ownerDocument.removeEventListener("pointerlockchange",O),this._domElement.ownerDocument.removeEventListener("pointerlockerror",M))},this.cancel=()=>{this._state!==D.NONE&&(this._state=D.NONE,this._activePointers.length=0,S())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=xe(e.width,0,1),this._interactiveArea.height=xe(e.height,0,1),this._interactiveArea.x=xe(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=xe(e.x,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const s=xe(e,this.minAzimuthAngle,this.maxAzimuthAngle),o=xe(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=o,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const i=!n||J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(i)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0,this._dollyToNoClamp(xe(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const i=this._collisionTest(),r=J(i,this._spherical.radius);if(!(n>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,i)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const o=!t||J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(o)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(et).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!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(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=xe(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||J(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),Me.setFromMatrixColumn(this._camera.matrix,0),be.setFromMatrixColumn(this._camera.matrix,1),Me.multiplyScalar(e),be.multiplyScalar(-t);const s=R.copy(Me).add(be),o=W.copy(this._targetEnd).add(s);return this.moveTo(o.x,o.y,o.z,n)}forward(e,t=!1){R.setFromMatrixColumn(this._camera.matrix,0),R.crossVectors(this._camera.up,R),R.multiplyScalar(e);const n=W.copy(this._targetEnd).add(R);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return R.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+R.x,this._targetEnd.y+R.y,this._targetEnd.z+R.z,t)}moveTo(e,t,n,s=!1){this._isUserControllingTruck=!1;const o=R.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,o,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const i=!s||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(i)}lookInDirectionOf(e,t,n,s=!1){const r=R.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,s)}fitToBox(e,t,{cover:n=!1,paddingLeft:s=0,paddingRight:o=0,paddingBottom:i=0,paddingTop:r=0}={}){const a=[],u=e.isBox3?Qe.copy(e):Qe.setFromObject(e);u.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const d=xn(this._sphericalEnd.theta,vn),p=xn(this._sphericalEnd.phi,vn);a.push(this.rotateTo(d,p,t));const f=R.setFromSpherical(this._sphericalEnd).normalize(),m=Pn.setFromUnitVectors(f,Dt),y=J(Math.abs(f.y),1);y&&m.multiply(kt.setFromAxisAngle(lt,d)),m.multiply(this._yAxisUpSpaceInverse);const _=On.makeEmpty();W.copy(u.min).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setX(u.max.x).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setY(u.max.y).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setZ(u.min.z).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setZ(u.max.z).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setY(u.min.y).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setX(u.min.x).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).applyQuaternion(m),_.expandByPoint(W),_.min.x-=s,_.min.y-=i,_.max.x+=o,_.max.y+=r,m.setFromUnitVectors(Dt,f),y&&m.premultiply(kt.invert()),m.premultiply(this._yAxisUpSpace);const x=_.getSize(R),S=_.getCenter(W).applyQuaternion(m);if(Ve(this._camera)){const O=this.getDistanceToFitBox(x.x,x.y,x.z,n);a.push(this.moveTo(S.x,S.y,S.z,t)),a.push(this.dollyTo(O,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(ke(this._camera)){const O=this._camera,M=O.right-O.left,g=O.top-O.bottom,A=n?Math.max(M/x.x,g/x.y):Math.min(M/x.x,g/x.y);a.push(this.moveTo(S.x,S.y,S.z,t)),a.push(this.zoomTo(A,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const n=[],o=e instanceof V.Sphere?It.copy(e):nt.createBoundingSphere(e,It);if(n.push(this.moveTo(o.center.x,o.center.y,o.center.z,t)),Ve(this._camera)){const i=this.getDistanceToFitSphere(o.radius);n.push(this.dollyTo(i,t))}else if(ke(this._camera)){const i=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*o.radius,u=Math.min(i/a,r/a);n.push(this.zoomTo(u,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,s,o,i,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0;const a=W.set(s,o,i),u=R.set(e,t,n);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(u.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const d=!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(d)}lerpLookAt(e,t,n,s,o,i,r,a,u,d,p,f,m,y=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0;const _=R.set(s,o,i),x=W.set(e,t,n);ge.setFromVector3(x.sub(_).applyQuaternion(this._yAxisUpSpace));const S=Ze.set(d,p,f),O=W.set(r,a,u);tt.setFromVector3(O.sub(S).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(_.lerp(S,m));const M=tt.theta-ge.theta,g=tt.phi-ge.phi,A=tt.radius-ge.radius;this._sphericalEnd.set(ge.radius+A*m,ge.phi+g*m,ge.theta+M*m),this.normalizeRotations(),this._needsUpdate=!0,y||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const b=!y||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(b)}setPosition(e,t,n,s=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,t,n,s=!1){const o=this.getPosition(R),i=this.setLookAt(o.x,o.y,o.z,e,t,n,s);return this._sphericalEnd.phi=xe(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),i}setFocalOffset(e,t,n,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const o=!s||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(o)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Me.setFromMatrixColumn(this._camera.matrixWorldInverse,0),be.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Ne.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=R.set(e,t,n),o=s.distanceTo(this._camera.position),i=s.sub(this._camera.position);Me.multiplyScalar(i.x),be.multiplyScalar(i.y),Ne.multiplyScalar(i.z),R.copy(Me).add(be).add(Ne),R.z=R.z+o,this.dollyTo(o,!1),this.setFocalOffset(-R.x,R.y,-R.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,s){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new V.Vector4,typeof e=="number"?this._viewport.set(e,t,n,s):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,s=!1){if(Ct(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=e/t,i=this._camera.getEffectiveFOV()*Je,r=this._camera.aspect;return((s?o>r:o<r)?t:e/r)*.5/Math.tan(i*.5)+n*.5}getDistanceToFitSphere(e){if(Ct(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Je,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,s=1<this._camera.aspect?t:n;return e/Math.sin(s*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof V.Spherical?e:new V.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Xe,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Xe),this._spherical.theta+=Xe*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Xe)}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 n=this.getPosition(R);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,lt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=R.subVectors(this._target,this._camera.position).normalize(),t=W.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e),this._camera.updateMatrixWorld();const n=this.getPosition(R);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,o=Sn.subVectors(this._targetEnd,this._target),i=Ln.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 p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=rt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,p,1/0,e),this._needsUpdate=!0}if(te(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=rt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,p,1/0,e),this._needsUpdate=!0}if(te(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const p=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=rt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,p,this.maxSpeed,e),this._needsUpdate=!0}if(te(o.x)&&te(o.y)&&te(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const p=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Mn(this._target,this._targetEnd,this._targetVelocity,p,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(te(i.x)&&te(i.y)&&te(i.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const p=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Mn(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,p,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(te(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const p=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=rt(this._zoom,this._zoomEnd,this._zoomVelocity,p,1/0,e)}if(this.dollyToCursor){if(Ve(this._camera)&&this._changedDolly!==0){const p=this._spherical.radius-this._lastDistance,f=this._camera,m=this._getCameraDirection(et),y=R.copy(m).cross(f.up).normalize();y.lengthSq()===0&&(y.x=1);const _=W.crossVectors(y,m),x=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Je*.5),O=(this._sphericalEnd.radius-p-this._sphericalEnd.radius)/this._sphericalEnd.radius,M=Ze.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*x*f.aspect)).add(_.multiplyScalar(this._dollyControlCoord.y*x)),g=R.copy(this._targetEnd).lerp(M,O),A=this._lastDollyDirection===Ye.IN&&this._spherical.radius<=this.minDistance,b=this._lastDollyDirection===Ye.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(A||b)){this._sphericalEnd.radius-=p,this._spherical.radius-=p;const v=W.copy(m).multiplyScalar(-p);g.add(v)}this._boundary.clampPoint(g,g);const w=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(w),this._changedDolly-=p,te(this._changedDolly)&&(this._changedDolly=0)}else if(ke(this._camera)&&this._changedZoom!==0){const p=this._zoom-this._lastZoom,f=this._camera,m=R.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),y=W.set(0,0,-1).applyQuaternion(f.quaternion),_=Ze.copy(m).add(y.multiplyScalar(-m.dot(f.up))),S=-(this._zoom-p-this._zoom)/this._zoom,O=this._getCameraDirection(et),M=this._targetEnd.dot(O),g=R.copy(this._targetEnd).lerp(_,S),A=g.dot(O),b=O.multiplyScalar(A-M);g.sub(b),this._boundary.clampPoint(g,g);const w=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(w),this._changedZoom-=p,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(),Me.setFromMatrixColumn(this._camera.matrix,0),be.setFromMatrixColumn(this._camera.matrix,1),Ne.setFromMatrixColumn(this._camera.matrix,2),Me.multiplyScalar(this._focalOffset.x),be.multiplyScalar(-this._focalOffset.y),Ne.multiplyScalar(this._focalOffset.z),R.copy(Me).add(be).add(Ne),this._camera.position.add(R)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),R.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const d=this._needsUpdate;return d&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):d?(this.dispatchEvent({type:"update"}),te(t,this.restThreshold)&&te(n,this.restThreshold)&&te(s,this.restThreshold)&&te(o.x,this.restThreshold)&&te(o.y,this.restThreshold)&&te(o.z,this.restThreshold)&&te(i.x,this.restThreshold)&&te(i.y,this.restThreshold)&&te(i.z,this.restThreshold)&&te(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!d&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=d,this._needsUpdate=!1,d}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:He(this.maxDistance),minZoom:this.minZoom,maxZoom:He(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:He(this.maxPolarAngle),minAzimuthAngle:He(this.minAzimuthAngle),maxAzimuthAngle:He(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:R.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=$e(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=$e(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=$e(n.maxPolarAngle),this.minAzimuthAngle=$e(n.minAzimuthAngle),this.maxAzimuthAngle=$e(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),ge.setFromVector3(R.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ge.theta,ge.phi,t),this.dollyTo(ge.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",Ci),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,n){const s=t.lengthSq();if(s===0)return e;const o=W.copy(t).add(e),r=this._boundary.clampPoint(o,Ze).sub(o),a=r.lengthSq();if(a===0)return e.add(t);if(a===s)return e;if(n===0)return e.add(t).add(r);{const u=1+n*a/t.dot(r);return e.add(W.copy(t).multiplyScalar(u)).add(r.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Ve(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Je,s=Math.tan(n*.5)*t,o=s*e.aspect;this._nearPlaneCorners[0].set(-o,-s,0),this._nearPlaneCorners[1].set(o,-s,0),this._nearPlaneCorners[2].set(o,s,0),this._nearPlaneCorners[3].set(-o,s,0)}else if(ke(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,s=e.right*t,o=e.top*t,i=e.bottom*t;this._nearPlaneCorners[0].set(n,o,0),this._nearPlaneCorners[1].set(s,o,0),this._nearPlaneCorners[2].set(s,i,0),this._nearPlaneCorners[3].set(n,i,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Ct(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(et);Ft.lookAt(Tn,n,this._camera.up);for(let s=0;s<4;s++){const o=W.copy(this._nearPlaneCorners[s]);o.applyMatrix4(Ft);const i=Ze.addVectors(this._target,o);ct.set(i,n),ct.far=this._spherical.radius+1;const r=ct.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<e&&(e=r[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new V.Sphere){const n=t,s=n.center;Qe.makeEmpty(),e.traverseVisible(i=>{i.isMesh&&Qe.expandByObject(i)}),Qe.getCenter(s);let o=0;return e.traverseVisible(i=>{if(!i.isMesh)return;const r=i,a=r.geometry.clone();a.applyMatrix4(r.matrixWorld);const d=a.attributes.position;for(let p=0,f=d.count;p<f;p++)R.fromBufferAttribute(d,p),o=Math.max(o,s.distanceToSquared(R))}),n.radius=Math.sqrt(o),n}}const ki=["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"],Fi=h.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},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(c,{expose:e,emit:t}){const n=c,{makeDefault:s,minPolarAngle:o,maxPolarAngle:i,minAzimuthAngle:r,maxAzimuthAngle:a,minDistance:u,maxDistance:d,infinityDolly:p,minZoom:f,maxZoom:m,smoothTime:y,draggingSmoothTime:_,maxSpeed:x,azimuthRotateSpeed:S,polarRotateSpeed:O,dollySpeed:M,dollyDragInverted:g,truckSpeed:A,dollyToCursor:b,dragToOffset:w,verticalDragToForward:v,boundaryFriction:C,restThreshold:k,colliderMeshes:I}=h.toRefs(n),U={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};nt.install({THREE:U});const{camera:j,renderer:H,extend:G,controls:ne}=q.useTresContext(),X=h.ref(null);G({CameraControls:nt}),h.watchEffect(()=>{ae(),X.value&&s.value?ne.value=X.value:ne.value=null});function ae(){oe(X.value,"update",()=>t("change",X.value)),oe(X.value,"controlend",()=>t("end",X.value)),oe(X.value,"controlstart",()=>t("start",X.value))}const{onLoop:re}=q.useRenderLoop();return re(({delta:$})=>{var Q,K;(Q=X.value)!=null&&Q.enabled&&((K=X.value)==null||K.update($))}),h.onUnmounted(()=>{X.value&&X.value.disconnect()}),e({value:X}),($,Q)=>{var K;return h.unref(j)&&h.unref(H)?(h.openBlock(),h.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:X,"min-polar-angle":h.unref(o),"max-polar-angle":h.unref(i),"min-azimuth-angle":h.unref(r),"max-azimuth-angle":h.unref(a),"min-distance":h.unref(u),"max-distance":h.unref(d),"infinity-dolly":h.unref(p),"min-zoom":h.unref(f),"max-zoom":h.unref(m),"smooth-time":h.unref(y),"dragging-smooth-time":h.unref(_),"max-speed":h.unref(x),"azimuth-rotate-speed":h.unref(S),"polar-rotate-speed":h.unref(O),"dolly-speed":h.unref(M),"dolly-drag-inverted":h.unref(g),"truck-speed":h.unref(A),"dolly-to-cursor":h.unref(b),"drag-to-offset":h.unref(w),"vertical-drag-to-forward":h.unref(v),"boundary-friction":h.unref(C),"rest-threshold":h.unref(k),"collider-meshes":h.unref(I),args:[h.unref(j)||$.camera,((K=h.unref(H))==null?void 0:K.domElement)||$.domElement]},null,8,ki)):h.createCommentVNode("",!0)}}});class Ui extends l.MeshStandardMaterial{constructor(t={}){super(t);Nt(this,"_time");Nt(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 N={LEFT:1,RIGHT:2,MIDDLE:4},C=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}),Ye={NONE:0,IN:1,OUT:-1};function Ne(c){return c.isPerspectiveCamera}function Ie(c){return c.isOrthographicCamera}const Xe=Math.PI*2,An=Math.PI/2,xn=1e-5,Je=Math.PI/180;function ve(c,e,t){return Math.max(e,Math.min(t,c))}function te(c,e=xn){return Math.abs(c)<e}function J(c,e,t=xn){return te(c-e,t)}function Mn(c,e){return Math.round(c/e)*e}function He(c){return isFinite(c)?c:c<0?-Number.MAX_VALUE:Number.MAX_VALUE}function $e(c){return Math.abs(c)<Number.MAX_VALUE?c:c*(1/0)}function rt(c,e,t,n,s=1/0,o){n=Math.max(1e-4,n);const i=2/n,r=i*o,a=1/(1+r+.48*r*r+.235*r*r*r);let u=c-e;const d=e,p=s*n;u=ve(u,-p,p),e=c-u;const f=(t.value+i*u)*o;t.value=(t.value-i*f)*a;let m=e+(u+f)*a;return d-c>0==m>d&&(m=d,t.value=(m-d)/o),m}function bn(c,e,t,n,s=1/0,o,i){n=Math.max(1e-4,n);const r=2/n,a=r*o,u=1/(1+a+.48*a*a+.235*a*a*a);let d=e.x,p=e.y,f=e.z,m=c.x-d,v=c.y-p,_=c.z-f;const A=d,M=p,O=f,b=s*n,g=b*b,T=m*m+v*v+_*_;if(T>g){const E=Math.sqrt(T);m=m/E*b,v=v/E*b,_=_/E*b}d=c.x-m,p=c.y-v,f=c.z-_;const x=(t.x+r*m)*o,y=(t.y+r*v)*o,w=(t.z+r*_)*o;t.x=(t.x-r*x)*u,t.y=(t.y-r*y)*u,t.z=(t.z-r*w)*u,i.x=d+(m+x)*u,i.y=p+(v+y)*u,i.z=f+(_+w)*u;const D=A-c.x,k=M-c.y,I=O-c.z,U=i.x-A,R=i.y-M,H=i.z-O;return D*U+k*R+I*H>0&&(i.x=A,i.y=M,i.z=O,t.x=(i.x-A)/o,t.y=(i.y-M)/o,t.z=(i.z-O)/o),i}function Pt(c,e){e.set(0,0),c.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=c.length,e.y/=c.length}function Ct(c,e){return Ie(c)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Si{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners[e];if(s!==void 0){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let o=0,i=s.length;o<i;o++)s[o].call(this,e)}}}const Li="2.7.1",at=1/8,Tn=typeof window<"u",Oi=Tn&&/Mac/.test(navigator.platform),Pi=!(Tn&&"PointerEvent"in window);let V,Sn,lt,Dt,pe,G,W,Ze,et,xe,Me,ze,Ln,On,_e,tt,Qe,Pn,It,Cn,kt,Ft,ct;class nt extends Si{static install(e){V=e.THREE,Sn=Object.freeze(new V.Vector3(0,0,0)),lt=Object.freeze(new V.Vector3(0,1,0)),Dt=Object.freeze(new V.Vector3(0,0,1)),pe=new V.Vector2,G=new V.Vector3,W=new V.Vector3,Ze=new V.Vector3,et=new V.Vector3,xe=new V.Vector3,Me=new V.Vector3,ze=new V.Vector3,Ln=new V.Vector3,On=new V.Vector3,_e=new V.Spherical,tt=new V.Spherical,Qe=new V.Box3,Pn=new V.Box3,It=new V.Sphere,Cn=new V.Quaternion,kt=new V.Quaternion,Ft=new V.Matrix4,ct=new V.Raycaster}static get ACTION(){return C}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=C.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=Ye.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new V.Vector3,this._focalOffsetVelocity=new V.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,T,x)=>{let y,w;if(Ne(this._camera)){const D=G.copy(this._camera.position).sub(this._target),k=this._camera.getEffectiveFOV()*Je,I=D.length()*Math.tan(k*.5);y=this.truckSpeed*g*I/this._elementRect.height,w=this.truckSpeed*T*I/this._elementRect.height}else if(Ie(this._camera)){const D=this._camera;y=g*(D.right-D.left)/D.zoom/this._elementRect.width,w=T*(D.top-D.bottom)/D.zoom/this._elementRect.height}else return;this.verticalDragToForward?(x?this.setFocalOffset(this._focalOffsetEnd.x+y,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(y,0,!0),this.forward(-w,!0)):x?this.setFocalOffset(this._focalOffsetEnd.x+y,this._focalOffsetEnd.y+w,this._focalOffsetEnd.z,!0):this.truck(y,w,!0)},this._rotateInternal=(g,T)=>{const x=Xe*this.azimuthRotateSpeed*g/this._elementRect.height,y=Xe*this.polarRotateSpeed*T/this._elementRect.height;this.rotate(x,y,!0)},this._dollyInternal=(g,T,x)=>{const y=Math.pow(.95,-g*this.dollySpeed),w=this._sphericalEnd.radius,D=this._sphericalEnd.radius*y,k=ve(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)-w,this._dollyControlCoord.set(T,x)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,T,x)=>{const y=Math.pow(.95,g*this.dollySpeed),w=this._zoom,D=this._zoom*y;this.zoomTo(D,!0),this.dollyToCursor&&(this._changedZoom+=D-w,this._dollyControlCoord.set(T,x))},typeof V>"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 V.Quaternion().setFromUnitVectors(this._camera.up,lt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=C.NONE,this._target=new V.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new V.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new V.Spherical().setFromVector3(G.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 V.Vector3,new V.Vector3,new V.Vector3,new V.Vector3],this._updateNearPlaneCorners(),this._boundary=new V.Box3(new V.Vector3(-1/0,-1/0,-1/0),new V.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 V.Vector2,this.mouseButtons={left:C.ROTATE,middle:C.DOLLY,right:C.TRUCK,wheel:Ne(this._camera)?C.DOLLY:Ie(this._camera)?C.ZOOM:C.NONE},this.touches={one:C.TOUCH_ROTATE,two:Ne(this._camera)?C.TOUCH_DOLLY_TRUCK:Ie(this._camera)?C.TOUCH_ZOOM_TRUCK:C.NONE,three:C.TOUCH_TRUCK};const n=new V.Vector2,s=new V.Vector2,o=new V.Vector2,i=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 y=this._domElement.getBoundingClientRect(),w=g.clientX/y.width,D=g.clientY/y.height;if(w<this._interactiveArea.left||w>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const T=g.pointerType!=="mouse"?null:(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.MIDDLE?N.MIDDLE:(g.buttons&N.RIGHT)===N.RIGHT?N.RIGHT:null;if(T!==null){const y=this._findPointerByMouseButton(T);y&&this._disposePointer(y)}if((g.buttons&N.LEFT)===N.LEFT&&this._lockedPointer)return;const x={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:T};this._activePointers.push(x),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),this._isDragging=!0,_(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 y=this._domElement.getBoundingClientRect(),w=g.clientX/y.width,D=g.clientY/y.height;if(w<this._interactiveArea.left||w>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const T=(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.MIDDLE?N.MIDDLE:(g.buttons&N.RIGHT)===N.RIGHT?N.RIGHT:null;if(T!==null){const y=this._findPointerByMouseButton(T);y&&this._disposePointer(y)}const x={pointerId:1,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:(g.buttons&N.LEFT)===N.LEFT?N.LEFT:(g.buttons&N.MIDDLE)===N.LEFT?N.MIDDLE:(g.buttons&N.RIGHT)===N.LEFT?N.RIGHT:null};this._activePointers.push(x),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",p),this._domElement.ownerDocument.addEventListener("mousemove",u),this._domElement.ownerDocument.addEventListener("mouseup",p),this._isDragging=!0,_(g)},a=g=>{g.cancelable&&g.preventDefault();const T=g.pointerId,x=this._lockedPointer||this._findPointerById(T);if(x){if(x.clientX=g.clientX,x.clientY=g.clientY,x.deltaX=g.movementX,x.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&N.LEFT)===N.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right);A()}},u=g=>{const T=this._lockedPointer||this._findPointerById(1);T&&(T.clientX=g.clientX,T.clientY=g.clientY,T.deltaX=g.movementX,T.deltaY=g.movementY,this._state=0,(this._lockedPointer||(g.buttons&N.LEFT)===N.LEFT)&&(this._state=this._state|this.mouseButtons.left),(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right),A())},d=g=>{const T=this._findPointerById(g.pointerId);if(!(T&&T===this._lockedPointer)){if(T&&this._disposePointer(T),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=C.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=C.NONE;M()}},p=()=>{const g=this._findPointerById(1);g&&g===this._lockedPointer||(g&&this._disposePointer(g),this._state=C.NONE,M())};let f=-1;const m=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===C.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===C.ROTATE||this.mouseButtons.wheel===C.TRUCK){const D=performance.now();f-D<1e3&&this._getClientRect(this._elementRect),f=D}const T=Oi?-1:-3,x=g.deltaMode===1?g.deltaY/T:g.deltaY/(T*10),y=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,w=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case C.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case C.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case C.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case C.DOLLY:{this._dollyInternal(-x,y,w),this._isUserControllingDolly=!0;break}case C.ZOOM:{this._zoomInternal(-x,y,w),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},v=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===nt.ACTION.NONE){const T=g instanceof PointerEvent?g.pointerId:(g instanceof MouseEvent,0),x=this._findPointerById(T);x&&this._disposePointer(x),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",p);return}g.preventDefault()}},_=g=>{if(!this._enabled)return;if(Pt(this._activePointers,pe),this._getClientRect(this._elementRect),n.copy(pe),s.copy(pe),this._activePointers.length>=2){const x=pe.x-this._activePointers[1].clientX,y=pe.y-this._activePointers[1].clientY,w=Math.sqrt(x*x+y*y);o.set(0,w);const D=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,k=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;s.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&N.LEFT)===N.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&N.MIDDLE)===N.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&N.RIGHT)===N.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&C.ROTATE)===C.ROTATE||(this._state&C.TOUCH_ROTATE)===C.TOUCH_ROTATE||(this._state&C.TOUCH_DOLLY_ROTATE)===C.TOUCH_DOLLY_ROTATE||(this._state&C.TOUCH_ZOOM_ROTATE)===C.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&C.TRUCK)===C.TRUCK||(this._state&C.TOUCH_TRUCK)===C.TOUCH_TRUCK||(this._state&C.TOUCH_DOLLY_TRUCK)===C.TOUCH_DOLLY_TRUCK||(this._state&C.TOUCH_ZOOM_TRUCK)===C.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&C.DOLLY)===C.DOLLY||(this._state&C.TOUCH_DOLLY)===C.TOUCH_DOLLY||(this._state&C.TOUCH_DOLLY_TRUCK)===C.TOUCH_DOLLY_TRUCK||(this._state&C.TOUCH_DOLLY_OFFSET)===C.TOUCH_DOLLY_OFFSET||(this._state&C.TOUCH_DOLLY_ROTATE)===C.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&C.ZOOM)===C.ZOOM||(this._state&C.TOUCH_ZOOM)===C.TOUCH_ZOOM||(this._state&C.TOUCH_ZOOM_TRUCK)===C.TOUCH_ZOOM_TRUCK||(this._state&C.TOUCH_ZOOM_OFFSET)===C.TOUCH_ZOOM_OFFSET||(this._state&C.TOUCH_ZOOM_ROTATE)===C.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&C.OFFSET)===C.OFFSET||(this._state&C.TOUCH_OFFSET)===C.TOUCH_OFFSET||(this._state&C.TOUCH_DOLLY_OFFSET)===C.TOUCH_DOLLY_OFFSET||(this._state&C.TOUCH_ZOOM_OFFSET)===C.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},A=()=>{if(!this._enabled)return;Pt(this._activePointers,pe);const T=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,x=T?-T.deltaX:s.x-pe.x,y=T?-T.deltaY:s.y-pe.y;if(s.copy(pe),((this._state&C.ROTATE)===C.ROTATE||(this._state&C.TOUCH_ROTATE)===C.TOUCH_ROTATE||(this._state&C.TOUCH_DOLLY_ROTATE)===C.TOUCH_DOLLY_ROTATE||(this._state&C.TOUCH_ZOOM_ROTATE)===C.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(x,y),this._isUserControllingRotate=!0),(this._state&C.DOLLY)===C.DOLLY||(this._state&C.ZOOM)===C.ZOOM){const w=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,D=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,k=this.dollyDragInverted?-1:1;(this._state&C.DOLLY)===C.DOLLY?(this._dollyInternal(k*y*at,w,D),this._isUserControllingDolly=!0):(this._zoomInternal(k*y*at,w,D),this._isUserControllingZoom=!0)}if((this._state&C.TOUCH_DOLLY)===C.TOUCH_DOLLY||(this._state&C.TOUCH_ZOOM)===C.TOUCH_ZOOM||(this._state&C.TOUCH_DOLLY_TRUCK)===C.TOUCH_DOLLY_TRUCK||(this._state&C.TOUCH_ZOOM_TRUCK)===C.TOUCH_ZOOM_TRUCK||(this._state&C.TOUCH_DOLLY_OFFSET)===C.TOUCH_DOLLY_OFFSET||(this._state&C.TOUCH_ZOOM_OFFSET)===C.TOUCH_ZOOM_OFFSET||(this._state&C.TOUCH_DOLLY_ROTATE)===C.TOUCH_DOLLY_ROTATE||(this._state&C.TOUCH_ZOOM_ROTATE)===C.TOUCH_ZOOM_ROTATE){const w=pe.x-this._activePointers[1].clientX,D=pe.y-this._activePointers[1].clientY,k=Math.sqrt(w*w+D*D),I=o.y-k;o.set(0,k);const U=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,R=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&C.TOUCH_DOLLY)===C.TOUCH_DOLLY||(this._state&C.TOUCH_DOLLY_ROTATE)===C.TOUCH_DOLLY_ROTATE||(this._state&C.TOUCH_DOLLY_TRUCK)===C.TOUCH_DOLLY_TRUCK||(this._state&C.TOUCH_DOLLY_OFFSET)===C.TOUCH_DOLLY_OFFSET?(this._dollyInternal(I*at,U,R),this._isUserControllingDolly=!0):(this._zoomInternal(I*at,U,R),this._isUserControllingZoom=!0)}((this._state&C.TRUCK)===C.TRUCK||(this._state&C.TOUCH_TRUCK)===C.TOUCH_TRUCK||(this._state&C.TOUCH_DOLLY_TRUCK)===C.TOUCH_DOLLY_TRUCK||(this._state&C.TOUCH_ZOOM_TRUCK)===C.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(x,y,!1),this._isUserControllingTruck=!0),((this._state&C.OFFSET)===C.OFFSET||(this._state&C.TOUCH_OFFSET)===C.TOUCH_OFFSET||(this._state&C.TOUCH_DOLLY_OFFSET)===C.TOUCH_DOLLY_OFFSET||(this._state&C.TOUCH_ZOOM_OFFSET)===C.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(x,y,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},M=()=>{Pt(this._activePointers,pe),s.copy(pe),(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",u),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",p),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",O),this._domElement.ownerDocument.addEventListener("pointerlockerror",b),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",d),_())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",O),this._domElement.ownerDocument.removeEventListener("pointerlockerror",b))};const O=()=>{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",i),Pi&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",d),this._domElement.addEventListener("wheel",m,{passive:!1}),this._domElement.addEventListener("contextmenu",v)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",i),this._domElement.removeEventListener("mousedown",r),this._domElement.removeEventListener("pointercancel",d),this._domElement.removeEventListener("wheel",m,{passive:!1}),this._domElement.removeEventListener("contextmenu",v),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("pointerup",d),this._domElement.ownerDocument.removeEventListener("mouseup",p),this._domElement.ownerDocument.removeEventListener("pointerlockchange",O),this._domElement.ownerDocument.removeEventListener("pointerlockerror",b))},this.cancel=()=>{this._state!==C.NONE&&(this._state=C.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=ve(e.width,0,1),this._interactiveArea.height=ve(e.height,0,1),this._interactiveArea.x=ve(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=ve(e.x,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const s=ve(e,this.minAzimuthAngle,this.maxAzimuthAngle),o=ve(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=o,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const i=!n||J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(i)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0,this._dollyToNoClamp(ve(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const i=this._collisionTest(),r=J(i,this._spherical.radius);if(!(n>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,i)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const o=!t||J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(o)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(et).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!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(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=ve(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||J(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),xe.setFromMatrixColumn(this._camera.matrix,0),Me.setFromMatrixColumn(this._camera.matrix,1),xe.multiplyScalar(e),Me.multiplyScalar(-t);const s=G.copy(xe).add(Me),o=W.copy(this._targetEnd).add(s);return this.moveTo(o.x,o.y,o.z,n)}forward(e,t=!1){G.setFromMatrixColumn(this._camera.matrix,0),G.crossVectors(this._camera.up,G),G.multiplyScalar(e);const n=W.copy(this._targetEnd).add(G);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return G.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+G.x,this._targetEnd.y+G.y,this._targetEnd.z+G.z,t)}moveTo(e,t,n,s=!1){this._isUserControllingTruck=!1;const o=G.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,o,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const i=!s||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(i)}lookInDirectionOf(e,t,n,s=!1){const r=G.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,s)}fitToBox(e,t,{cover:n=!1,paddingLeft:s=0,paddingRight:o=0,paddingBottom:i=0,paddingTop:r=0}={}){const a=[],u=e.isBox3?Qe.copy(e):Qe.setFromObject(e);u.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const d=Mn(this._sphericalEnd.theta,An),p=Mn(this._sphericalEnd.phi,An);a.push(this.rotateTo(d,p,t));const f=G.setFromSpherical(this._sphericalEnd).normalize(),m=Cn.setFromUnitVectors(f,Dt),v=J(Math.abs(f.y),1);v&&m.multiply(kt.setFromAxisAngle(lt,d)),m.multiply(this._yAxisUpSpaceInverse);const _=Pn.makeEmpty();W.copy(u.min).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setX(u.max.x).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setY(u.max.y).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setZ(u.min.z).applyQuaternion(m),_.expandByPoint(W),W.copy(u.min).setZ(u.max.z).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setY(u.min.y).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).setX(u.min.x).applyQuaternion(m),_.expandByPoint(W),W.copy(u.max).applyQuaternion(m),_.expandByPoint(W),_.min.x-=s,_.min.y-=i,_.max.x+=o,_.max.y+=r,m.setFromUnitVectors(Dt,f),v&&m.premultiply(kt.invert()),m.premultiply(this._yAxisUpSpace);const A=_.getSize(G),M=_.getCenter(W).applyQuaternion(m);if(Ne(this._camera)){const O=this.getDistanceToFitBox(A.x,A.y,A.z,n);a.push(this.moveTo(M.x,M.y,M.z,t)),a.push(this.dollyTo(O,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(Ie(this._camera)){const O=this._camera,b=O.right-O.left,g=O.top-O.bottom,T=n?Math.max(b/A.x,g/A.y):Math.min(b/A.x,g/A.y);a.push(this.moveTo(M.x,M.y,M.z,t)),a.push(this.zoomTo(T,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const n=[],o=e instanceof V.Sphere?It.copy(e):nt.createBoundingSphere(e,It);if(n.push(this.moveTo(o.center.x,o.center.y,o.center.z,t)),Ne(this._camera)){const i=this.getDistanceToFitSphere(o.radius);n.push(this.dollyTo(i,t))}else if(Ie(this._camera)){const i=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*o.radius,u=Math.min(i/a,r/a);n.push(this.zoomTo(u,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,s,o,i,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0;const a=W.set(s,o,i),u=G.set(e,t,n);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(u.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const d=!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(d)}lerpLookAt(e,t,n,s,o,i,r,a,u,d,p,f,m,v=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ye.NONE,this._changedDolly=0;const _=G.set(s,o,i),A=W.set(e,t,n);_e.setFromVector3(A.sub(_).applyQuaternion(this._yAxisUpSpace));const M=Ze.set(d,p,f),O=W.set(r,a,u);tt.setFromVector3(O.sub(M).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(_.lerp(M,m));const b=tt.theta-_e.theta,g=tt.phi-_e.phi,T=tt.radius-_e.radius;this._sphericalEnd.set(_e.radius+T*m,_e.phi+g*m,_e.theta+b*m),this.normalizeRotations(),this._needsUpdate=!0,v||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const x=!v||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(x)}setPosition(e,t,n,s=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,t,n,s=!1){const o=this.getPosition(G),i=this.setLookAt(o.x,o.y,o.z,e,t,n,s);return this._sphericalEnd.phi=ve(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),i}setFocalOffset(e,t,n,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const o=!s||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(o)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),xe.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Me.setFromMatrixColumn(this._camera.matrixWorldInverse,1),ze.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=G.set(e,t,n),o=s.distanceTo(this._camera.position),i=s.sub(this._camera.position);xe.multiplyScalar(i.x),Me.multiplyScalar(i.y),ze.multiplyScalar(i.z),G.copy(xe).add(Me).add(ze),G.z=G.z+o,this.dollyTo(o,!1),this.setFocalOffset(-G.x,G.y,-G.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,s){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new V.Vector4,typeof e=="number"?this._viewport.set(e,t,n,s):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,s=!1){if(Ct(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const o=e/t,i=this._camera.getEffectiveFOV()*Je,r=this._camera.aspect;return((s?o>r:o<r)?t:e/r)*.5/Math.tan(i*.5)+n*.5}getDistanceToFitSphere(e){if(Ct(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Je,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,s=1<this._camera.aspect?t:n;return e/Math.sin(s*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof V.Spherical?e:new V.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new V.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Xe,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Xe),this._spherical.theta+=Xe*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Xe)}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 n=this.getPosition(G);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,lt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=G.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 n=this.getPosition(G);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,o=Ln.subVectors(this._targetEnd,this._target),i=On.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 p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=rt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,p,1/0,e),this._needsUpdate=!0}if(te(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const p=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=rt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,p,1/0,e),this._needsUpdate=!0}if(te(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const p=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=rt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,p,this.maxSpeed,e),this._needsUpdate=!0}if(te(o.x)&&te(o.y)&&te(o.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const p=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;bn(this._target,this._targetEnd,this._targetVelocity,p,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(te(i.x)&&te(i.y)&&te(i.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const p=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;bn(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,p,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(te(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const p=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=rt(this._zoom,this._zoomEnd,this._zoomVelocity,p,1/0,e)}if(this.dollyToCursor){if(Ne(this._camera)&&this._changedDolly!==0){const p=this._spherical.radius-this._lastDistance,f=this._camera,m=this._getCameraDirection(et),v=G.copy(m).cross(f.up).normalize();v.lengthSq()===0&&(v.x=1);const _=W.crossVectors(v,m),A=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Je*.5),O=(this._sphericalEnd.radius-p-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=Ze.copy(this._targetEnd).add(v.multiplyScalar(this._dollyControlCoord.x*A*f.aspect)).add(_.multiplyScalar(this._dollyControlCoord.y*A)),g=G.copy(this._targetEnd).lerp(b,O),T=this._lastDollyDirection===Ye.IN&&this._spherical.radius<=this.minDistance,x=this._lastDollyDirection===Ye.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(T||x)){this._sphericalEnd.radius-=p,this._spherical.radius-=p;const w=W.copy(m).multiplyScalar(-p);g.add(w)}this._boundary.clampPoint(g,g);const y=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(y),this._changedDolly-=p,te(this._changedDolly)&&(this._changedDolly=0)}else if(Ie(this._camera)&&this._changedZoom!==0){const p=this._zoom-this._lastZoom,f=this._camera,m=G.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),v=W.set(0,0,-1).applyQuaternion(f.quaternion),_=Ze.copy(m).add(v.multiplyScalar(-m.dot(f.up))),M=-(this._zoom-p-this._zoom)/this._zoom,O=this._getCameraDirection(et),b=this._targetEnd.dot(O),g=G.copy(this._targetEnd).lerp(_,M),T=g.dot(O),x=O.multiplyScalar(T-b);g.sub(x),this._boundary.clampPoint(g,g);const y=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(y),this._changedZoom-=p,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(),xe.setFromMatrixColumn(this._camera.matrix,0),Me.setFromMatrixColumn(this._camera.matrix,1),ze.setFromMatrixColumn(this._camera.matrix,2),xe.multiplyScalar(this._focalOffset.x),Me.multiplyScalar(-this._focalOffset.y),ze.multiplyScalar(this._focalOffset.z),G.copy(xe).add(Me).add(ze),this._camera.position.add(G)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),G.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const d=this._needsUpdate;return d&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):d?(this.dispatchEvent({type:"update"}),te(t,this.restThreshold)&&te(n,this.restThreshold)&&te(s,this.restThreshold)&&te(o.x,this.restThreshold)&&te(o.y,this.restThreshold)&&te(o.z,this.restThreshold)&&te(i.x,this.restThreshold)&&te(i.y,this.restThreshold)&&te(i.z,this.restThreshold)&&te(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!d&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=d,this._needsUpdate=!1,d}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:He(this.maxDistance),minZoom:this.minZoom,maxZoom:He(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:He(this.maxPolarAngle),minAzimuthAngle:He(this.minAzimuthAngle),maxAzimuthAngle:He(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:G.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=$e(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=$e(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=$e(n.maxPolarAngle),this.minAzimuthAngle=$e(n.minAzimuthAngle),this.maxAzimuthAngle=$e(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),_e.setFromVector3(G.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(_e.theta,_e.phi,t),this.dollyTo(_e.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",Li),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,n){const s=t.lengthSq();if(s===0)return e;const o=W.copy(t).add(e),r=this._boundary.clampPoint(o,Ze).sub(o),a=r.lengthSq();if(a===0)return e.add(t);if(a===s)return e;if(n===0)return e.add(t).add(r);{const u=1+n*a/t.dot(r);return e.add(W.copy(t).multiplyScalar(u)).add(r.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Ne(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Je,s=Math.tan(n*.5)*t,o=s*e.aspect;this._nearPlaneCorners[0].set(-o,-s,0),this._nearPlaneCorners[1].set(o,-s,0),this._nearPlaneCorners[2].set(o,s,0),this._nearPlaneCorners[3].set(-o,s,0)}else if(Ie(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,s=e.right*t,o=e.top*t,i=e.bottom*t;this._nearPlaneCorners[0].set(n,o,0),this._nearPlaneCorners[1].set(s,o,0),this._nearPlaneCorners[2].set(s,i,0),this._nearPlaneCorners[3].set(n,i,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Ct(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(et);Ft.lookAt(Sn,n,this._camera.up);for(let s=0;s<4;s++){const o=W.copy(this._nearPlaneCorners[s]);o.applyMatrix4(Ft);const i=Ze.addVectors(this._target,o);ct.set(i,n),ct.far=this._spherical.radius+1;const r=ct.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<e&&(e=r[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new V.Sphere){const n=t,s=n.center;Qe.makeEmpty(),e.traverseVisible(i=>{i.isMesh&&Qe.expandByObject(i)}),Qe.getCenter(s);let o=0;return e.traverseVisible(i=>{if(!i.isMesh)return;const r=i,a=r.geometry.clone();a.applyMatrix4(r.matrixWorld);const d=a.attributes.position;for(let p=0,f=d.count;p<f;p++)G.fromBufferAttribute(d,p),o=Math.max(o,s.distanceToSquared(G))}),n.radius=Math.sqrt(o),n}}const Ci=["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"],Di=h.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},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(c,{expose:e,emit:t}){const n=c,{makeDefault:s,minPolarAngle:o,maxPolarAngle:i,minAzimuthAngle:r,maxAzimuthAngle:a,minDistance:u,maxDistance:d,infinityDolly:p,minZoom:f,maxZoom:m,smoothTime:v,draggingSmoothTime:_,maxSpeed:A,azimuthRotateSpeed:M,polarRotateSpeed:O,dollySpeed:b,dollyDragInverted:g,truckSpeed:T,dollyToCursor:x,dragToOffset:y,verticalDragToForward:w,boundaryFriction:D,restThreshold:k,colliderMeshes:I}=h.toRefs(n),U={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};nt.install({THREE:U});const{camera:R,renderer:H,extend:E,controls:ne}=q.useTresContext(),X=h.ref(null);E({CameraControls:nt}),h.watchEffect(()=>{ae(),X.value&&s.value?ne.value=X.value:ne.value=null});function ae(){re(X.value,"update",()=>t("change",X.value)),re(X.value,"controlend",()=>t("end",X.value)),re(X.value,"controlstart",()=>t("start",X.value))}const{onLoop:ie}=q.useRenderLoop();return ie(({delta:$})=>{var Q,K;(Q=X.value)!=null&&Q.enabled&&((K=X.value)==null||K.update($))}),h.onUnmounted(()=>{X.value&&X.value.disconnect()}),e({value:X}),($,Q)=>{var K;return h.unref(R)&&h.unref(H)?(h.openBlock(),h.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:X,"min-polar-angle":h.unref(o),"max-polar-angle":h.unref(i),"min-azimuth-angle":h.unref(r),"max-azimuth-angle":h.unref(a),"min-distance":h.unref(u),"max-distance":h.unref(d),"infinity-dolly":h.unref(p),"min-zoom":h.unref(f),"max-zoom":h.unref(m),"smooth-time":h.unref(v),"dragging-smooth-time":h.unref(_),"max-speed":h.unref(A),"azimuth-rotate-speed":h.unref(M),"polar-rotate-speed":h.unref(O),"dolly-speed":h.unref(b),"dolly-drag-inverted":h.unref(g),"truck-speed":h.unref(T),"dolly-to-cursor":h.unref(x),"drag-to-offset":h.unref(y),"vertical-drag-to-forward":h.unref(w),"boundary-friction":h.unref(D),"rest-threshold":h.unref(k),"collider-meshes":h.unref(I),args:[h.unref(R)||$.camera,((K=h.unref(H))==null?void 0:K.domElement)||$.domElement]},null,8,Ci)):h.createCommentVNode("",!0)}}});class Ii extends l.MeshStandardMaterial{constructor(t={}){super(t);Nt(this,"_time");Nt(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 Bi=["factor"],Vi=h.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(c){const e=c,t=h.shallowRef(),{extend:n}=q.useTresContext();n({MeshWobbleMaterial:Ui});const{onLoop:s}=q.useRenderLoop();return s(({elapsed:o})=>{t.value&&(t.value.time=o*(e==null?void 0:e.speed))}),(o,i)=>(h.openBlock(),h.createElementBlock("TresMeshWobbleMaterial",h.mergeProps({ref_key:"materialRef",ref:t,factor:o.factor},o.$attrs),null,16,Bi))}}),Ni=["args"],zi=["color"],Ri=h.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"boxRef",ref:o},i.$attrs),[h.createElementVNode("TresBoxGeometry",{args:h.unref(n)},null,8,Ni),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,zi)])],16))}}),Ei=["args"],Gi=["color"],ji=h.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"circleRef",ref:o},i.$attrs),[h.createElementVNode("TresCircleGeometry",{args:h.unref(n)},null,8,Ei),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Gi)])],16))}}),Yi=["args"],Xi=["color"],Zi=h.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"coneRef",ref:o},i.$attrs),[h.createElementVNode("TresConeGeometry",{args:h.unref(n)},null,8,Yi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Xi)])],16))}}),Qi=["args"],Ki=["color"],Wi=h.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"dodecahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresDodecahedronGeometry",{args:h.unref(n)},null,8,Qi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Ki)])],16))}}),qi=["args"],Ji=["color"],Hi=h.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"icosahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresIcosahedronGeometry",{args:h.unref(n)},null,8,qi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Ji)])],16))}}),$i=["args"],er=["color"],tr=h.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"octahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresOctahedronGeometry",{args:h.unref(n)},null,8,$i),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,er)])],16))}}),nr=["rotation"],sr=["args"],or=["color"],ir=h.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"planeRef",ref:o,rotation:[-Math.PI/2,0,0]},i.$attrs),[h.createElementVNode("TresPlaneGeometry",{args:h.unref(n)},null,8,sr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,or)])],16,nr))}}),rr=["args"],ar=["color"],lr=h.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"ringRef",ref:o},i.$attrs),[h.createElementVNode("TresRingGeometry",{args:h.unref(n)},null,8,rr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,ar)])],16))}}),cr=["args"],hr=["color"],ur=h.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"sphereRef",ref:o},i.$attrs),[h.createElementVNode("TresSphereGeometry",{args:h.unref(n)},null,8,cr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,hr)])],16))}}),pr=["rotation"],dr=["args"],fr=["color"],mr=h.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"tetrahedronRef",ref:o,rotation:[-Math.PI/2,0,0]},i.$attrs),[h.createElementVNode("TresTetrahedronGeometry",{args:h.unref(n)},null,8,dr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,fr)])],16,pr))}}),gr=["args"],_r=["color"],yr=h.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"torusRef",ref:o},i.$attrs),[h.createElementVNode("TresTorusGeometry",{args:h.unref(n)},null,8,gr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,_r)])],16))}}),wr=["args"],vr=["color"],Ar=h.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"torusKnotRef",ref:o},i.$attrs),[h.createElementVNode("TresTorusKnotGeometry",{args:h.unref(n)},null,8,wr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,vr)])],16))}}),xr=["args"],Mr=["color"],br=h.defineComponent({__name:"Tube",props:{args:{default:()=>[new l.QuadraticBezierCurve3(new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"tubeRef",ref:o},i.$attrs),[h.createElementVNode("TresTubeGeometry",{args:h.unref(n)},null,8,xr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Mr)])],16))}}),Tr=["receive-shadow","rotation"],Sr=["args"],Lr=h.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Or=h.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(c){const e=c,t=r=>r===0?0:Math.pow(2,10*r-10),{floor:n,segments:s,receiveShadow:o}=h.toRefs(e),i=h.ref(null);return h.watch(()=>[s.value,n.value,i.value],([r,a,u])=>{if(!u||r===null)return;let d=0;const p=r/r/2,f=u.attributes.position;for(let m=0;m<r+1;m++)for(let y=0;y<r+1;y++)f.setXYZ(d++,m/r-p+(m===0?-a:0),y/r-p,t(m/r));f.needsUpdate=!0,u.computeVertexNormals()}),(r,a)=>(h.openBlock(),h.createElementBlock("TresGroup",h.normalizeProps(h.guardReactiveProps(r.$attrs)),[h.createElementVNode("TresMesh",{"receive-shadow":h.unref(o),rotation:[-Math.PI/2,0,Math.PI/2]},[h.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:i,args:[1,1,h.unref(s),h.unref(s)]},null,8,Sr),h.renderSlot(r.$slots,"default",{},()=>[Lr])],8,Tr)],16))}});let ve,ht;const Pr=(c="body")=>{ve||(ve=new En.Pane({container:document.querySelector(c)}),ve.element.style.position="absolute",ve.element.style.top="1rem",ve.element.style.right="1rem",ve.element.style.zIndex="9999",ve.registerPlugin(Yn),ht=ve.addBlade({view:"fpsgraph",label:"fpsgraph"}));function e(){ve&&ve.dispose()}return h.onMounted(()=>{const{onBeforeLoop:t,onAfterLoop:n,resume:s}=q.useRenderLoop();s(),t(()=>ht.begin()),n(()=>ht.end())}),h.onUnmounted(()=>{e()}),{pane:ve,fpsGraph:ht,disposeTweakPane:e}};B.Backdrop=Or,B.Box=Ri,B.CameraControls=Fi,B.Circle=ji,B.Cone=Zi,B.ContactShadows=Qo,B.Dodecahedron=Wi,B.Environment=Co,B.FBXModel=di,B.GLTFModel=pi,B.Icosahedron=Hi,B.KeyboardControls=Ai,B.Levioso=Go,B.MapControls=Li,B.MeshWobbleMaterial=Vi,B.MouseParallax=hi,B.Octahedron=tr,B.OrbitControls=_i,B.Plane=ir,B.PointerLockControls=Ti,B.Precipitation=Bo,B.Ring=lr,B.ScrollControls=Oi,B.Smoke=Eo,B.Sphere=ur,B.Stars=ko,B.Tetrahedron=mr,B.Text3D=Oo,B.Torus=yr,B.TorusKnot=Ar,B.TransformControls=Mi,B.Tube=br,B.useAnimations=Po,B.useEnvironment=pn,B.useFBX=yn,B.useGLTF=_n,B.useProgress=mi,B.useTweakPane=Pr,Object.defineProperty(B,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 ki=["factor"],Fi=h.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(c){const e=c,t=h.shallowRef(),{extend:n}=q.useTresContext();n({MeshWobbleMaterial:Ii});const{onLoop:s}=q.useRenderLoop();return s(({elapsed:o})=>{t.value&&(t.value.time=o*(e==null?void 0:e.speed))}),(o,i)=>(h.openBlock(),h.createElementBlock("TresMeshWobbleMaterial",h.mergeProps({ref_key:"materialRef",ref:t,factor:o.factor},o.$attrs),null,16,ki))}}),Ui=["args"],Bi=["color"],Vi=h.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"boxRef",ref:o},i.$attrs),[h.createElementVNode("TresBoxGeometry",{args:h.unref(n)},null,8,Ui),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Bi)])],16))}}),Ni=["args"],zi=["color"],Ri=h.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"circleRef",ref:o},i.$attrs),[h.createElementVNode("TresCircleGeometry",{args:h.unref(n)},null,8,Ni),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,zi)])],16))}}),Ei=["args"],Gi=["color"],ji=h.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"coneRef",ref:o},i.$attrs),[h.createElementVNode("TresConeGeometry",{args:h.unref(n)},null,8,Ei),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Gi)])],16))}}),Yi=["args"],Xi=["color"],Zi=h.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"dodecahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresDodecahedronGeometry",{args:h.unref(n)},null,8,Yi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Xi)])],16))}}),Qi=["args"],Ki=["color"],Wi=h.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"icosahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresIcosahedronGeometry",{args:h.unref(n)},null,8,Qi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Ki)])],16))}}),qi=["args"],Ji=["color"],Hi=h.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"octahedronRef",ref:o},i.$attrs),[h.createElementVNode("TresOctahedronGeometry",{args:h.unref(n)},null,8,qi),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,Ji)])],16))}}),$i=["rotation"],er=["args"],tr=["color"],nr=h.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"planeRef",ref:o,rotation:[-Math.PI/2,0,0]},i.$attrs),[h.createElementVNode("TresPlaneGeometry",{args:h.unref(n)},null,8,er),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,tr)])],16,$i))}}),sr=["args"],or=["color"],ir=h.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"ringRef",ref:o},i.$attrs),[h.createElementVNode("TresRingGeometry",{args:h.unref(n)},null,8,sr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,or)])],16))}}),rr=["args"],ar=["color"],lr=h.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"sphereRef",ref:o},i.$attrs),[h.createElementVNode("TresSphereGeometry",{args:h.unref(n)},null,8,rr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,ar)])],16))}}),cr=["rotation"],hr=["args"],ur=["color"],pr=h.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"tetrahedronRef",ref:o,rotation:[-Math.PI/2,0,0]},i.$attrs),[h.createElementVNode("TresTetrahedronGeometry",{args:h.unref(n)},null,8,hr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,ur)])],16,cr))}}),dr=["args"],fr=["color"],mr=h.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"torusRef",ref:o},i.$attrs),[h.createElementVNode("TresTorusGeometry",{args:h.unref(n)},null,8,dr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,fr)])],16))}}),gr=["args"],_r=["color"],yr=h.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"torusKnotRef",ref:o},i.$attrs),[h.createElementVNode("TresTorusKnotGeometry",{args:h.unref(n)},null,8,gr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,_r)])],16))}}),wr=["args"],vr=["color"],Ar=h.defineComponent({__name:"Tube",props:{args:{default:()=>[new l.QuadraticBezierCurve3(new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(c,{expose:e}){const t=c,{args:n,color:s}=h.toRefs(t),o=h.shallowRef();return e({value:o}),(i,r)=>(h.openBlock(),h.createElementBlock("TresMesh",h.mergeProps({ref_key:"tubeRef",ref:o},i.$attrs),[h.createElementVNode("TresTubeGeometry",{args:h.unref(n)},null,8,wr),h.renderSlot(i.$slots,"default",{},()=>[h.createElementVNode("TresMeshBasicMaterial",{color:h.unref(s)},null,8,vr)])],16))}}),xr=["receive-shadow","rotation"],Mr=["args"],br=h.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Tr=h.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(c){const e=c,t=r=>r===0?0:Math.pow(2,10*r-10),{floor:n,segments:s,receiveShadow:o}=h.toRefs(e),i=h.ref(null);return h.watch(()=>[s.value,n.value,i.value],([r,a,u])=>{if(!u||r===null)return;let d=0;const p=r/r/2,f=u.attributes.position;for(let m=0;m<r+1;m++)for(let v=0;v<r+1;v++)f.setXYZ(d++,m/r-p+(m===0?-a:0),v/r-p,t(m/r));f.needsUpdate=!0,u.computeVertexNormals()}),(r,a)=>(h.openBlock(),h.createElementBlock("TresGroup",h.normalizeProps(h.guardReactiveProps(r.$attrs)),[h.createElementVNode("TresMesh",{"receive-shadow":h.unref(o),rotation:[-Math.PI/2,0,Math.PI/2]},[h.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:i,args:[1,1,h.unref(s),h.unref(s)]},null,8,Mr),h.renderSlot(r.$slots,"default",{},()=>[br])],8,xr)],16))}});let be,ht;const Sr=(c="body")=>{be||(be=new Gn.Pane({container:document.querySelector(c)}),be.element.style.position="absolute",be.element.style.top="1rem",be.element.style.right="1rem",be.element.style.zIndex="9999",ht=be.addBlade({view:"fpsgraph",label:"fpsgraph"}));function e(){be&&be.dispose()}return h.onMounted(()=>{const{onBeforeLoop:t,onAfterLoop:n,resume:s}=q.useRenderLoop();s(),t(()=>ht.begin()),n(()=>ht.end())}),h.onUnmounted(()=>{e()}),{pane:be,fpsGraph:ht,disposeTweakPane:e}};B.Backdrop=Tr,B.Box=Vi,B.CameraControls=Di,B.Circle=Ri,B.Cone=ji,B.ContactShadows=Xo,B.Dodecahedron=Zi,B.Environment=Oo,B.FBXModel=hi,B.GLTFModel=ci,B.Icosahedron=Wi,B.KeyboardControls=yi,B.Levioso=Ro,B.MapControls=bi,B.MeshWobbleMaterial=Fi,B.MouseParallax=ai,B.Octahedron=Hi,B.OrbitControls=fi,B.Plane=nr,B.PointerLockControls=xi,B.Precipitation=Fo,B.Ring=ir,B.ScrollControls=Ti,B.Smoke=zo,B.Sphere=lr,B.Stars=Do,B.Tetrahedron=pr,B.Text3D=So,B.Torus=mr,B.TorusKnot=yr,B.TransformControls=vi,B.Tube=Ar,B.useAnimations=Lo,B.useEnvironment=pn,B.useFBX=yn,B.useGLTF=_n,B.useProgress=ui,B.useTweakPane=Sr,B.useVideoTexture=pi,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});