@tresjs/cientos 3.2.0-next.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/materials/index.d.ts +2 -1
- package/dist/core/materials/meshGlassMaterial/index.vue.d.ts +4 -0
- package/dist/core/materials/meshGlassMaterial/material.d.ts +30 -0
- package/dist/core/misc/useTweakPane/index.d.ts +1 -1
- package/dist/trescientos.js +3092 -2210
- package/dist/trescientos.umd.cjs +12 -12
- package/package.json +10 -11
package/dist/trescientos.umd.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/cientos
|
|
3
|
-
* version: v3.2.
|
|
3
|
+
* version: v3.2.1
|
|
4
4
|
* (c) 2023
|
|
5
5
|
* description: Collection of useful helpers and fully functional, ready-made abstractions for Tres
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
(function(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:`
|
|
8
|
+
(function(U,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue"),require("three"),require("@tresjs/core"),require("tweakpane")):typeof define=="function"&&define.amd?define(["exports","vue","three","@tresjs/core","tweakpane"],u):(U=typeof globalThis<"u"?globalThis:U||self,u(U.trescientos={},U.Vue,U.Three,U.TresjsCore,U.tweakpane))})(this,function(U,u,c,q,nn){"use strict";var la=Object.defineProperty;var ca=(U,u,c)=>u in U?la(U,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):U[u]=c;var re=(U,u,c)=>(ca(U,typeof u!="symbol"?u+"":u,c),c);function ts(l,e){if(e===c.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===c.TriangleFanDrawMode||e===c.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],r=l.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)o.push(a);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=t.count-2,n=[];if(t)if(e===c.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}var ge=Uint8Array,Ie=Uint16Array,xt=Uint32Array,ss=new ge([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ns=new ge([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),on=new ge([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),is=function(l,e){for(var t=new Ie(31),s=0;s<31;++s)t[s]=e+=1<<l[s-1];for(var n=new xt(t[30]),s=1;s<30;++s)for(var i=t[s];i<t[s+1];++i)n[i]=i-t[s]<<5|s;return[t,n]},os=is(ss,2),rs=os[0],rn=os[1];rs[28]=258,rn[258]=28;for(var an=is(ns,0),ln=an[0],vt=new Ie(32768),ne=0;ne<32768;++ne){var ke=(ne&43690)>>>1|(ne&21845)<<1;ke=(ke&52428)>>>2|(ke&13107)<<2,ke=(ke&61680)>>>4|(ke&3855)<<4,vt[ne]=((ke&65280)>>>8|(ke&255)<<8)>>>1}for(var tt=function(l,e,t){for(var s=l.length,n=0,i=new Ie(e);n<s;++n)++i[l[n]-1];var o=new Ie(e);for(n=0;n<e;++n)o[n]=o[n-1]+i[n-1]<<1;var r;if(t){r=new Ie(1<<e);var a=15-e;for(n=0;n<s;++n)if(l[n])for(var h=n<<4|l[n],p=e-l[n],d=o[l[n]-1]++<<p,m=d|(1<<p)-1;d<=m;++d)r[vt[d]>>>a]=h}else for(r=new Ie(s),n=0;n<s;++n)l[n]&&(r[n]=vt[o[l[n]-1]++]>>>15-l[n]);return r},st=new ge(288),ne=0;ne<144;++ne)st[ne]=8;for(var ne=144;ne<256;++ne)st[ne]=9;for(var ne=256;ne<280;++ne)st[ne]=7;for(var ne=280;ne<288;++ne)st[ne]=8;for(var as=new ge(32),ne=0;ne<32;++ne)as[ne]=5;var cn=tt(st,9,1),hn=tt(as,5,1),At=function(l){for(var e=l[0],t=1;t<l.length;++t)l[t]>e&&(e=l[t]);return e},ve=function(l,e,t){var s=e/8|0;return(l[s]|l[s+1]<<8)>>(e&7)&t},Mt=function(l,e){var t=e/8|0;return(l[t]|l[t+1]<<8|l[t+2]<<16)>>(e&7)},un=function(l){return(l/8|0)+(l&7&&1)},pn=function(l,e,t){(e==null||e<0)&&(e=0),(t==null||t>l.length)&&(t=l.length);var s=new(l instanceof Ie?Ie:l instanceof xt?xt:ge)(t-e);return s.set(l.subarray(e,t)),s},dn=function(l,e,t){var s=l.length;if(!s||t&&!t.l&&s<5)return e||new ge(0);var n=!e||t,i=!t||t.i;t||(t={}),e||(e=new ge(s*3));var o=function(xe){var Se=e.length;if(xe>Se){var Ne=new ge(Math.max(Se*2,xe));Ne.set(e),e=Ne}},r=t.f||0,a=t.p||0,h=t.b||0,p=t.l,d=t.d,m=t.m,f=t.n,w=s*8;do{if(!p){t.f=r=ve(l,a,1);var y=ve(l,a+1,3);if(a+=3,y)if(y==1)p=cn,d=hn,m=9,f=5;else if(y==2){var b=ve(l,a,31)+257,g=ve(l,a+10,15)+4,S=b+ve(l,a+5,31)+1;a+=14;for(var A=new ge(S),_=new ge(19),x=0;x<g;++x)_[on[x]]=ve(l,a+x*3,7);a+=g*3;for(var D=At(_),k=(1<<D)-1,I=tt(_,D,1),x=0;x<S;){var B=I[ve(l,a,k)];a+=B&15;var v=B>>>4;if(v<16)A[x++]=v;else{var R=0,H=0;for(v==16?(H=3+ve(l,a,3),a+=2,R=A[x-1]):v==17?(H=3+ve(l,a,7),a+=3):v==18&&(H=11+ve(l,a,127),a+=7);H--;)A[x++]=R}}var G=A.subarray(0,b),se=A.subarray(b);m=At(G),f=At(se),p=tt(G,m,1),d=tt(se,f,1)}else throw"invalid block type";else{var v=un(a)+4,M=l[v-4]|l[v-3]<<8,L=v+M;if(L>s){if(i)throw"unexpected EOF";break}n&&o(h+M),e.set(l.subarray(v,L),h),t.b=h+=M,t.p=a=L*8;continue}if(a>w){if(i)throw"unexpected EOF";break}}n&&o(h+131072);for(var X=(1<<m)-1,le=(1<<f)-1,oe=a;;oe=a){var R=p[Mt(l,a)&X],$=R>>>4;if(a+=R&15,a>w){if(i)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if($<256)e[h++]=$;else if($==256){oe=a,p=null;break}else{var Q=$-254;if($>264){var x=$-257,K=ss[x];Q=ve(l,a,(1<<K)-1)+rs[x],a+=K}var he=d[Mt(l,a)&le],C=he>>>4;if(!he)throw"invalid distance";a+=he&15;var se=ln[C];if(C>3){var K=ns[C];se+=Mt(l,a)&(1<<K)-1,a+=K}if(a>w){if(i)throw"unexpected EOF";break}n&&o(h+131072);for(var fe=h+Q;h<fe;h+=4)e[h]=e[h-se],e[h+1]=e[h+1-se],e[h+2]=e[h+2-se],e[h+3]=e[h+3-se];h=fe}}t.l=p,t.p=oe,t.b=h,p&&(r=1,t.m=m,t.d=d,t.n=f)}while(!r);return h==e.length?e:pn(e,0,h)},mn=new ge(0),fn=function(l){if((l[0]&15)!=8||l[0]>>>4>7||(l[0]<<8|l[1])%31)throw"invalid zlib data";if(l[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function gn(l,e){return dn((fn(l),l.subarray(2,-4)),e)}var yn=typeof TextDecoder<"u"&&new TextDecoder,_n=0;try{yn.decode(mn,{stream:!0}),_n=1}catch{}var wn=Object.defineProperty,xn=(l,e,t)=>e in l?wn(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,O=(l,e,t)=>(xn(l,typeof e!="symbol"?e+"":e,t),t);class vn extends c.Object3D{constructor(e,t){super(),O(this,"isTransformControls",!0),O(this,"visible",!1),O(this,"domElement"),O(this,"raycaster",new c.Raycaster),O(this,"gizmo"),O(this,"plane"),O(this,"tempVector",new c.Vector3),O(this,"tempVector2",new c.Vector3),O(this,"tempQuaternion",new c.Quaternion),O(this,"unit",{X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)}),O(this,"pointStart",new c.Vector3),O(this,"pointEnd",new c.Vector3),O(this,"offset",new c.Vector3),O(this,"rotationAxis",new c.Vector3),O(this,"startNorm",new c.Vector3),O(this,"endNorm",new c.Vector3),O(this,"rotationAngle",0),O(this,"cameraPosition",new c.Vector3),O(this,"cameraQuaternion",new c.Quaternion),O(this,"cameraScale",new c.Vector3),O(this,"parentPosition",new c.Vector3),O(this,"parentQuaternion",new c.Quaternion),O(this,"parentQuaternionInv",new c.Quaternion),O(this,"parentScale",new c.Vector3),O(this,"worldPositionStart",new c.Vector3),O(this,"worldQuaternionStart",new c.Quaternion),O(this,"worldScaleStart",new c.Vector3),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"worldQuaternionInv",new c.Quaternion),O(this,"worldScale",new c.Vector3),O(this,"eye",new c.Vector3),O(this,"positionStart",new c.Vector3),O(this,"quaternionStart",new c.Quaternion),O(this,"scaleStart",new c.Vector3),O(this,"camera"),O(this,"object"),O(this,"enabled",!0),O(this,"axis",null),O(this,"mode","translate"),O(this,"translationSnap",null),O(this,"rotationSnap",null),O(this,"scaleSnap",null),O(this,"space","world"),O(this,"size",1),O(this,"dragging",!1),O(this,"showX",!0),O(this,"showY",!0),O(this,"showZ",!0),O(this,"changeEvent",{type:"change"}),O(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),O(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),O(this,"objectChangeEvent",{type:"objectChange"}),O(this,"intersectObjectWithRay",(n,i,o)=>{const r=i.intersectObject(n,!0);for(let a=0;a<r.length;a++)if(r[a].object.visible||o)return r[a];return!1}),O(this,"attach",n=>(this.object=n,this.visible=!0,this)),O(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),O(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),O(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),O(this,"pointerHover",n=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(n,this.camera);const i=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);i?this.axis=i.object.name:this.axis=null}),O(this,"pointerDown",n=>{if(!(this.object===void 0||this.dragging===!0||n.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(n,this.camera);const i=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(i){let o=this.space;if(this.mode==="scale"?o="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(o="world"),o==="local"&&this.mode==="rotate"){const r=this.rotationSnap;this.axis==="X"&&r&&(this.object.rotation.x=Math.round(this.object.rotation.x/r)*r),this.axis==="Y"&&r&&(this.object.rotation.y=Math.round(this.object.rotation.y/r)*r),this.axis==="Z"&&r&&(this.object.rotation.z=Math.round(this.object.rotation.z/r)*r)}this.object.updateMatrixWorld(),this.object.parent&&this.object.parent.updateMatrixWorld(),this.positionStart.copy(this.object.position),this.quaternionStart.copy(this.object.quaternion),this.scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.worldScaleStart),this.pointStart.copy(i.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),O(this,"pointerMove",n=>{const i=this.axis,o=this.mode,r=this.object;let a=this.space;if(o==="scale"?a="local":(i==="E"||i==="XYZE"||i==="XYZ")&&(a="world"),r===void 0||i===null||this.dragging===!1||n.button!==-1)return;this.raycaster.setFromCamera(n,this.camera);const h=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(h){if(this.pointEnd.copy(h.point).sub(this.worldPositionStart),o==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&i!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),i.indexOf("X")===-1&&(this.offset.x=0),i.indexOf("Y")===-1&&(this.offset.y=0),i.indexOf("Z")===-1&&(this.offset.z=0),a==="local"&&i!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),r.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(a==="local"&&(r.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this.quaternionStart)),a==="world"&&(r.parent&&r.position.add(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld)),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld))));else if(o==="scale"){if(i.search("XYZ")!==-1){let p=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(p*=-1),this.tempVector2.set(p,p,p)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),i.search("X")===-1&&(this.tempVector2.x=1),i.search("Y")===-1&&(this.tempVector2.y=1),i.search("Z")===-1&&(this.tempVector2.z=1);r.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(i.search("X")!==-1&&(this.object.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(o==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const p=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));i==="E"?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.startNorm.copy(this.pointStart).normalize(),this.endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this.endNorm.cross(this.startNorm).dot(this.eye)<0?1:-1):i==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*p):(i==="X"||i==="Y"||i==="Z")&&(this.rotationAxis.copy(this.unit[i]),this.tempVector.copy(this.unit[i]),a==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*p),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&i!=="E"&&i!=="XYZE"?(r.quaternion.copy(this.quaternionStart),r.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),r.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),O(this,"pointerUp",n=>{n.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),O(this,"getPointer",n=>{var i,o;if(this.domElement&&((i=this.domElement.ownerDocument)!=null&&i.pointerLockElement))return{x:0,y:0,button:n.button};{const r=n.changedTouches?n.changedTouches[0]:n,a=(o=this.domElement)==null?void 0:o.getBoundingClientRect();return{x:(r.clientX-a.left)/a.width*2-1,y:-(r.clientY-a.top)/a.height*2+1,button:n.button}}}),O(this,"onPointerHover",n=>{if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(n));break}}),O(this,"onPointerDown",n=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(n)),this.pointerDown(this.getPointer(n)))}),O(this,"onPointerMove",n=>{this.enabled&&this.pointerMove(this.getPointer(n))}),O(this,"onPointerUp",n=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(n)))}),O(this,"getMode",()=>this.mode),O(this,"setMode",n=>{this.mode=n}),O(this,"setTranslationSnap",n=>{this.translationSnap=n}),O(this,"setRotationSnap",n=>{this.rotationSnap=n}),O(this,"setScaleSnap",n=>{this.scaleSnap=n}),O(this,"setSize",n=>{this.size=n}),O(this,"setSpace",n=>{this.space=n}),O(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),O(this,"connect",n=>{n===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=n,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),O(this,"dispose",()=>{var n,i,o,r,a,h;(n=this.domElement)==null||n.removeEventListener("pointerdown",this.onPointerDown),(i=this.domElement)==null||i.removeEventListener("pointermove",this.onPointerHover),(r=(o=this.domElement)==null?void 0:o.ownerDocument)==null||r.removeEventListener("pointermove",this.onPointerMove),(h=(a=this.domElement)==null?void 0:a.ownerDocument)==null||h.removeEventListener("pointerup",this.onPointerUp),this.traverse(p=>{const d=p;d.geometry&&d.geometry.dispose(),d.material&&d.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new An,this.add(this.gizmo),this.plane=new Mn,this.add(this.plane);const s=(n,i)=>{let o=i;Object.defineProperty(this,n,{get:function(){return o!==void 0?o:i},set:function(r){o!==r&&(o=r,this.plane[n]=r,this.gizmo[n]=r,this.dispatchEvent({type:n+"-changed",value:r}),this.dispatchEvent(this.changeEvent))}}),this[n]=i,this.plane[n]=i,this.gizmo[n]=i};s("camera",this.camera),s("object",this.object),s("enabled",this.enabled),s("axis",this.axis),s("mode",this.mode),s("translationSnap",this.translationSnap),s("rotationSnap",this.rotationSnap),s("scaleSnap",this.scaleSnap),s("space",this.space),s("size",this.size),s("dragging",this.dragging),s("showX",this.showX),s("showY",this.showY),s("showZ",this.showZ),s("worldPosition",this.worldPosition),s("worldPositionStart",this.worldPositionStart),s("worldQuaternion",this.worldQuaternion),s("worldQuaternionStart",this.worldQuaternionStart),s("cameraPosition",this.cameraPosition),s("cameraQuaternion",this.cameraQuaternion),s("pointStart",this.pointStart),s("pointEnd",this.pointEnd),s("rotationAxis",this.rotationAxis),s("rotationAngle",this.rotationAngle),s("eye",this.eye),t!==void 0&&this.connect(t)}}class An extends c.Object3D{constructor(){super(),O(this,"isTransformControlsGizmo",!0),O(this,"type","TransformControlsGizmo"),O(this,"tempVector",new c.Vector3(0,0,0)),O(this,"tempEuler",new c.Euler),O(this,"alignVector",new c.Vector3(0,1,0)),O(this,"zeroVector",new c.Vector3(0,0,0)),O(this,"lookAtMatrix",new c.Matrix4),O(this,"tempQuaternion",new c.Quaternion),O(this,"tempQuaternion2",new c.Quaternion),O(this,"identityQuaternion",new c.Quaternion),O(this,"unitX",new c.Vector3(1,0,0)),O(this,"unitY",new c.Vector3(0,1,0)),O(this,"unitZ",new c.Vector3(0,0,1)),O(this,"gizmo"),O(this,"picker"),O(this,"helper"),O(this,"rotationAxis",new c.Vector3),O(this,"cameraPosition",new c.Vector3),O(this,"worldPositionStart",new c.Vector3),O(this,"worldQuaternionStart",new c.Quaternion),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"eye",new c.Vector3),O(this,"camera",null),O(this,"enabled",!0),O(this,"axis",null),O(this,"mode","translate"),O(this,"space","world"),O(this,"size",1),O(this,"dragging",!1),O(this,"showX",!0),O(this,"showY",!0),O(this,"showZ",!0),O(this,"updateMatrixWorld",()=>{let $=this.space;this.mode==="scale"&&($="local");const Q=$==="local"?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let K=[];K=K.concat(this.picker[this.mode].children),K=K.concat(this.gizmo[this.mode].children),K=K.concat(this.helper[this.mode].children);for(let he=0;he<K.length;he++){const C=K[he];C.visible=!0,C.rotation.set(0,0,0),C.position.copy(this.worldPosition);let fe;if(this.camera.isOrthographicCamera?fe=(this.camera.top-this.camera.bottom)/this.camera.zoom:fe=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),C.scale.set(1,1,1).multiplyScalar(fe*this.size/7),C.tag==="helper"){C.visible=!1,C.name==="AXIS"?(C.position.copy(this.worldPositionStart),C.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),C.quaternion.copy(Q).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.9&&(C.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),C.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),C.quaternion.multiply(this.tempQuaternion),C.visible=this.dragging),this.axis==="E"&&(C.visible=!1)):C.name==="START"?(C.position.copy(this.worldPositionStart),C.visible=this.dragging):C.name==="END"?(C.position.copy(this.worldPosition),C.visible=this.dragging):C.name==="DELTA"?(C.position.copy(this.worldPositionStart),C.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),C.scale.copy(this.tempVector),C.visible=this.dragging):(C.quaternion.copy(Q),this.dragging?C.position.copy(this.worldPositionStart):C.position.copy(this.worldPosition),this.axis&&(C.visible=this.axis.search(C.name)!==-1));continue}C.quaternion.copy(Q),this.mode==="translate"||this.mode==="scale"?((C.name==="X"||C.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),(C.name==="Y"||C.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),(C.name==="Z"||C.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))>.99&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye))<.2&&(C.scale.set(1e-10,1e-10,1e-10),C.visible=!1),C.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.x*=-1:C.tag==="bwd"&&(C.visible=!1)),C.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.y*=-1:C.tag==="bwd"&&(C.visible=!1)),C.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(Q).dot(this.eye)<0?C.tag==="fwd"?C.visible=!1:C.scale.z*=-1:C.tag==="bwd"&&(C.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(Q),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(Q).invert()),C.name.search("E")!==-1&&C.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),C.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion)),C.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion)),C.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),C.quaternion.copy(this.tempQuaternion))),C.visible=C.visible&&(C.name.indexOf("X")===-1||this.showX),C.visible=C.visible&&(C.name.indexOf("Y")===-1||this.showY),C.visible=C.visible&&(C.name.indexOf("Z")===-1||this.showZ),C.visible=C.visible&&(C.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),C.material.tempOpacity=C.material.tempOpacity||C.material.opacity,C.material.tempColor=C.material.tempColor||C.material.color.clone(),C.material.color.copy(C.material.tempColor),C.material.opacity=C.material.tempOpacity,this.enabled?this.axis&&(C.name===this.axis?(C.material.opacity=1,C.material.color.lerp(new c.Color(1,1,1),.5)):this.axis.split("").some(function(xe){return C.name===xe})?(C.material.opacity=1,C.material.color.lerp(new c.Color(1,1,1),.5)):(C.material.opacity*=.25,C.material.color.lerp(new c.Color(1,1,1),.5))):(C.material.opacity*=.5,C.material.color.lerp(new c.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new c.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:c.DoubleSide,fog:!1,toneMapped:!1}),t=new c.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),s=e.clone();s.opacity=.15;const n=e.clone();n.opacity=.33;const i=e.clone();i.color.set(16711680);const o=e.clone();o.color.set(65280);const r=e.clone();r.color.set(255);const a=e.clone();a.opacity=.25;const h=a.clone();h.color.set(16776960);const p=a.clone();p.color.set(65535);const d=a.clone();d.color.set(16711935),e.clone().color.set(16776960);const f=t.clone();f.color.set(16711680);const w=t.clone();w.color.set(65280);const y=t.clone();y.color.set(255);const v=t.clone();v.color.set(65535);const M=t.clone();M.color.set(16711935);const L=t.clone();L.color.set(16776960);const b=t.clone();b.color.set(7895160);const g=L.clone();g.opacity=.25;const S=new c.CylinderGeometry(0,.05,.2,12,1,!1),A=new c.BoxGeometry(.125,.125,.125),_=new c.BufferGeometry;_.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3));const x=($,Q)=>{const K=new c.BufferGeometry,he=[];for(let C=0;C<=64*Q;++C)he.push(0,Math.cos(C/32*Math.PI)*$,Math.sin(C/32*Math.PI)*$);return K.setAttribute("position",new c.Float32BufferAttribute(he,3)),K},D=()=>{const $=new c.BufferGeometry;return $.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),$},k={X:[[new c.Mesh(S,i),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new c.Mesh(S,i),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new c.Line(_,f)]],Y:[[new c.Mesh(S,o),[0,1,0],null,null,"fwd"],[new c.Mesh(S,o),[0,1,0],[Math.PI,0,0],null,"bwd"],[new c.Line(_,w),null,[0,0,Math.PI/2]]],Z:[[new c.Mesh(S,r),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new c.Mesh(S,r),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new c.Line(_,y),null,[0,-Math.PI/2,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.1,0),a.clone()),[0,0,0],[0,0,0]]],XY:[[new c.Mesh(new c.PlaneGeometry(.295,.295),h.clone()),[.15,.15,0]],[new c.Line(_,L),[.18,.3,0],null,[.125,1,1]],[new c.Line(_,L),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),p.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new c.Line(_,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(_,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new c.Line(_,M),[.18,0,.3],null,[.125,1,1]],[new c.Line(_,M),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),s),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),s),[0,.6,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),s),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.2,0),s)]],XY:[[new c.Mesh(new c.PlaneGeometry(.4,.4),s),[.2,.2,0]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),s),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),s),[.2,0,.2],[-Math.PI/2,0,0]]]},B={START:[[new c.Mesh(new c.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],END:[[new c.Mesh(new c.OctahedronGeometry(.01,2),n),null,null,null,"helper"]],DELTA:[[new c.Line(D(),n),null,null,null,"helper"]],X:[[new c.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={X:[[new c.Line(x(1,.5),f)],[new c.Mesh(new c.OctahedronGeometry(.04,0),i),[0,0,.99],null,[1,3,1]]],Y:[[new c.Line(x(1,.5),w),null,[0,0,-Math.PI/2]],[new c.Mesh(new c.OctahedronGeometry(.04,0),o),[0,0,.99],null,[3,1,1]]],Z:[[new c.Line(x(1,.5),y),null,[0,Math.PI/2,0]],[new c.Mesh(new c.OctahedronGeometry(.04,0),r),[.99,0,0],null,[1,3,1]]],E:[[new c.Line(x(1.25,1),g),null,[0,Math.PI/2,0]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),g),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new c.Line(x(1,1),b),null,[0,Math.PI/2,0]]]},H={AXIS:[[new c.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},G={X:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new c.Mesh(new c.TorusGeometry(1.25,.1,2,24),s)]],XYZE:[[new c.Mesh(new c.SphereGeometry(.7,10,8),s)]]},se={X:[[new c.Mesh(A,i),[.8,0,0],[0,0,-Math.PI/2]],[new c.Line(_,f),null,null,[.8,1,1]]],Y:[[new c.Mesh(A,o),[0,.8,0]],[new c.Line(_,w),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new c.Mesh(A,r),[0,0,.8],[Math.PI/2,0,0]],[new c.Line(_,y),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new c.Mesh(A,h),[.85,.85,0],null,[2,2,.2]],[new c.Line(_,L),[.855,.98,0],null,[.125,1,1]],[new c.Line(_,L),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(A,p),[0,.85,.85],null,[.2,2,2]],[new c.Line(_,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(_,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(A,d),[.85,0,.85],null,[2,.2,2]],[new c.Line(_,M),[.855,0,.98],null,[.125,1,1]],[new c.Line(_,M),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),a.clone()),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),a.clone()),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),a.clone()),[0,0,1.1]]]},X={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),s),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),s),[0,.5,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),s),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new c.Mesh(A,s),[.85,.85,0],null,[3,3,.2]]],YZ:[[new c.Mesh(A,s),[0,.85,.85],null,[.2,3,3]]],XZ:[[new c.Mesh(A,s),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),s),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),s),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),s),[0,0,1.1]]]},le={X:[[new c.Line(_,n.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(_,n.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(_,n.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},oe=$=>{const Q=new c.Object3D;for(let K in $)for(let he=$[K].length;he--;){const C=$[K][he][0].clone(),fe=$[K][he][1],xe=$[K][he][2],Se=$[K][he][3],Ne=$[K][he][4];C.name=K,C.tag=Ne,fe&&C.position.set(fe[0],fe[1],fe[2]),xe&&C.rotation.set(xe[0],xe[1],xe[2]),Se&&C.scale.set(Se[0],Se[1],Se[2]),C.updateMatrix();const ut=C.geometry.clone();ut.applyMatrix4(C.matrix),C.geometry=ut,C.renderOrder=1/0,C.position.set(0,0,0),C.rotation.set(0,0,0),C.scale.set(1,1,1),Q.add(C)}return Q};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=oe(k)),this.add(this.gizmo.rotate=oe(R)),this.add(this.gizmo.scale=oe(se)),this.add(this.picker.translate=oe(I)),this.add(this.picker.rotate=oe(G)),this.add(this.picker.scale=oe(X)),this.add(this.helper.translate=oe(B)),this.add(this.helper.rotate=oe(H)),this.add(this.helper.scale=oe(le)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class Mn extends c.Mesh{constructor(){super(new c.PlaneGeometry(1e5,1e5,2,2),new c.MeshBasicMaterial({visible:!1,wireframe:!0,side:c.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),O(this,"isTransformControlsPlane",!0),O(this,"type","TransformControlsPlane"),O(this,"unitX",new c.Vector3(1,0,0)),O(this,"unitY",new c.Vector3(0,1,0)),O(this,"unitZ",new c.Vector3(0,0,1)),O(this,"tempVector",new c.Vector3),O(this,"dirVector",new c.Vector3),O(this,"alignVector",new c.Vector3),O(this,"tempMatrix",new c.Matrix4),O(this,"identityQuaternion",new c.Quaternion),O(this,"cameraQuaternion",new c.Quaternion),O(this,"worldPosition",new c.Vector3),O(this,"worldQuaternion",new c.Quaternion),O(this,"eye",new c.Vector3),O(this,"axis",null),O(this,"mode","translate"),O(this,"space","world"),O(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var bn=Object.defineProperty,Sn=(l,e,t)=>e in l?bn(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,ce=(l,e,t)=>(Sn(l,typeof e!="symbol"?e+"":e,t),t);const Qe=new c.Euler(0,0,0,"YXZ"),Ke=new c.Vector3,Tn={type:"change"},Ln={type:"lock"},Cn={type:"unlock"},ls=Math.PI/2;class bt extends c.EventDispatcher{constructor(e,t){super(),ce(this,"camera"),ce(this,"domElement"),ce(this,"isLocked"),ce(this,"minPolarAngle"),ce(this,"maxPolarAngle"),ce(this,"pointerSpeed"),ce(this,"onMouseMove",s=>{if(!this.domElement||this.isLocked===!1)return;const n=s.movementX||s.mozMovementX||s.webkitMovementX||0,i=s.movementY||s.mozMovementY||s.webkitMovementY||0;Qe.setFromQuaternion(this.camera.quaternion),Qe.y-=n*.002*this.pointerSpeed,Qe.x-=i*.002*this.pointerSpeed,Qe.x=Math.max(ls-this.maxPolarAngle,Math.min(ls-this.minPolarAngle,Qe.x)),this.camera.quaternion.setFromEuler(Qe),this.dispatchEvent(Tn)}),ce(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(Ln),this.isLocked=!0):(this.dispatchEvent(Cn),this.isLocked=!1))}),ce(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),ce(this,"connect",s=>{this.domElement=s||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),ce(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),ce(this,"dispose",()=>{this.disconnect()}),ce(this,"getObject",()=>this.camera),ce(this,"direction",new c.Vector3(0,0,-1)),ce(this,"getDirection",s=>s.copy(this.direction).applyQuaternion(this.camera.quaternion)),ce(this,"moveForward",s=>{Ke.setFromMatrixColumn(this.camera.matrix,0),Ke.crossVectors(this.camera.up,Ke),this.camera.position.addScaledVector(Ke,s)}),ce(this,"moveRight",s=>{Ke.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(Ke,s)}),ce(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),ce(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var On=Object.defineProperty,Pn=(l,e,t)=>e in l?On(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,E=(l,e,t)=>(Pn(l,typeof e!="symbol"?e+"":e,t),t);const cs=(l,e)=>(l%e+e)%e;class hs extends c.EventDispatcher{constructor(e,t){super(),E(this,"object"),E(this,"domElement"),E(this,"enabled",!0),E(this,"target",new c.Vector3),E(this,"minDistance",0),E(this,"maxDistance",1/0),E(this,"minZoom",0),E(this,"maxZoom",1/0),E(this,"minPolarAngle",0),E(this,"maxPolarAngle",Math.PI),E(this,"minAzimuthAngle",-1/0),E(this,"maxAzimuthAngle",1/0),E(this,"enableDamping",!1),E(this,"dampingFactor",.05),E(this,"enableZoom",!0),E(this,"zoomSpeed",1),E(this,"enableRotate",!0),E(this,"rotateSpeed",1),E(this,"enablePan",!0),E(this,"panSpeed",1),E(this,"screenSpacePanning",!0),E(this,"keyPanSpeed",7),E(this,"autoRotate",!1),E(this,"autoRotateSpeed",2),E(this,"reverseOrbit",!1),E(this,"reverseHorizontalOrbit",!1),E(this,"reverseVerticalOrbit",!1),E(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),E(this,"mouseButtons",{LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN}),E(this,"touches",{ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN}),E(this,"target0"),E(this,"position0"),E(this,"zoom0"),E(this,"_domElementKeyEvents",null),E(this,"getPolarAngle"),E(this,"getAzimuthalAngle"),E(this,"setPolarAngle"),E(this,"setAzimuthalAngle"),E(this,"getDistance"),E(this,"listenToKeyEvents"),E(this,"stopListenToKeyEvents"),E(this,"saveState"),E(this,"reset"),E(this,"update"),E(this,"connect"),E(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=T=>{let F=cs(T,2*Math.PI),z=p.phi;z<0&&(z+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-z);2*Math.PI-ee<ee&&(F<z?F+=2*Math.PI:z+=2*Math.PI),d.phi=F-z,s.update()},this.setAzimuthalAngle=T=>{let F=cs(T,2*Math.PI),z=p.theta;z<0&&(z+=2*Math.PI),F<0&&(F+=2*Math.PI);let ee=Math.abs(F-z);2*Math.PI-ee<ee&&(F<z?F+=2*Math.PI:z+=2*Math.PI),d.theta=F-z,s.update()},this.getDistance=()=>s.object.position.distanceTo(s.target),this.listenToKeyEvents=T=>{T.addEventListener("keydown",$t),this._domElementKeyEvents=T},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",$t),this._domElementKeyEvents=null},this.saveState=()=>{s.target0.copy(s.target),s.position0.copy(s.object.position),s.zoom0=s.object.zoom},this.reset=()=>{s.target.copy(s.target0),s.object.position.copy(s.position0),s.object.zoom=s.zoom0,s.object.updateProjectionMatrix(),s.dispatchEvent(n),s.update(),a=r.NONE},this.update=(()=>{const T=new c.Vector3,F=new c.Vector3(0,1,0),z=new c.Quaternion().setFromUnitVectors(e.up,F),ee=z.clone().invert(),pe=new c.Vector3,Ze=new c.Quaternion,Ve=2*Math.PI;return function(){const sn=s.object.position;z.setFromUnitVectors(e.up,F),ee.copy(z).invert(),T.copy(sn).sub(s.target),T.applyQuaternion(z),p.setFromVector3(T),s.autoRotate&&a===r.NONE&&B(k()),s.enableDamping?(p.theta+=d.theta*s.dampingFactor,p.phi+=d.phi*s.dampingFactor):(p.theta+=d.theta,p.phi+=d.phi);let Pe=s.minAzimuthAngle,De=s.maxAzimuthAngle;return isFinite(Pe)&&isFinite(De)&&(Pe<-Math.PI?Pe+=Ve:Pe>Math.PI&&(Pe-=Ve),De<-Math.PI?De+=Ve:De>Math.PI&&(De-=Ve),Pe<=De?p.theta=Math.max(Pe,Math.min(De,p.theta)):p.theta=p.theta>(Pe+De)/2?Math.max(Pe,p.theta):Math.min(De,p.theta)),p.phi=Math.max(s.minPolarAngle,Math.min(s.maxPolarAngle,p.phi)),p.makeSafe(),p.radius*=m,p.radius=Math.max(s.minDistance,Math.min(s.maxDistance,p.radius)),s.enableDamping===!0?s.target.addScaledVector(f,s.dampingFactor):s.target.add(f),T.setFromSpherical(p),T.applyQuaternion(ee),sn.copy(s.target).add(T),s.object.lookAt(s.target),s.enableDamping===!0?(d.theta*=1-s.dampingFactor,d.phi*=1-s.dampingFactor,f.multiplyScalar(1-s.dampingFactor)):(d.set(0,0,0),f.set(0,0,0)),m=1,w||pe.distanceToSquared(s.object.position)>h||8*(1-Ze.dot(s.object.quaternion))>h?(s.dispatchEvent(n),pe.copy(s.object.position),Ze.copy(s.object.quaternion),w=!1,!0):!1}})(),this.connect=T=>{T===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),s.domElement=T,s.domElement.style.touchAction="none",s.domElement.addEventListener("contextmenu",$s),s.domElement.addEventListener("pointerdown",qs),s.domElement.addEventListener("pointercancel",Js),s.domElement.addEventListener("wheel",Hs)},this.dispose=()=>{var T,F,z,ee,pe,Ze;(T=s.domElement)==null||T.removeEventListener("contextmenu",$s),(F=s.domElement)==null||F.removeEventListener("pointerdown",qs),(z=s.domElement)==null||z.removeEventListener("pointercancel",Js),(ee=s.domElement)==null||ee.removeEventListener("wheel",Hs),(pe=s.domElement)==null||pe.ownerDocument.removeEventListener("pointermove",Jt),(Ze=s.domElement)==null||Ze.ownerDocument.removeEventListener("pointerup",Ht),s._domElementKeyEvents!==null&&s._domElementKeyEvents.removeEventListener("keydown",$t)};const s=this,n={type:"change"},i={type:"start"},o={type:"end"},r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=r.NONE;const h=1e-6,p=new c.Spherical,d=new c.Spherical;let m=1;const f=new c.Vector3;let w=!1;const y=new c.Vector2,v=new c.Vector2,M=new c.Vector2,L=new c.Vector2,b=new c.Vector2,g=new c.Vector2,S=new c.Vector2,A=new c.Vector2,_=new c.Vector2,x=[],D={};function k(){return 2*Math.PI/60/60*s.autoRotateSpeed}function I(){return Math.pow(.95,s.zoomSpeed)}function B(T){s.reverseOrbit||s.reverseHorizontalOrbit?d.theta+=T:d.theta-=T}function R(T){s.reverseOrbit||s.reverseVerticalOrbit?d.phi+=T:d.phi-=T}const H=(()=>{const T=new c.Vector3;return function(z,ee){T.setFromMatrixColumn(ee,0),T.multiplyScalar(-z),f.add(T)}})(),G=(()=>{const T=new c.Vector3;return function(z,ee){s.screenSpacePanning===!0?T.setFromMatrixColumn(ee,1):(T.setFromMatrixColumn(ee,0),T.crossVectors(s.object.up,T)),T.multiplyScalar(z),f.add(T)}})(),se=(()=>{const T=new c.Vector3;return function(z,ee){const pe=s.domElement;if(pe&&s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera){const Ze=s.object.position;T.copy(Ze).sub(s.target);let Ve=T.length();Ve*=Math.tan(s.object.fov/2*Math.PI/180),H(2*z*Ve/pe.clientHeight,s.object.matrix),G(2*ee*Ve/pe.clientHeight,s.object.matrix)}else pe&&s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(H(z*(s.object.right-s.object.left)/s.object.zoom/pe.clientWidth,s.object.matrix),G(ee*(s.object.top-s.object.bottom)/s.object.zoom/pe.clientHeight,s.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),s.enablePan=!1)}})();function X(T){s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera?m/=T:s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(s.object.zoom=Math.max(s.minZoom,Math.min(s.maxZoom,s.object.zoom*T)),s.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),s.enableZoom=!1)}function le(T){s.object instanceof c.PerspectiveCamera&&s.object.isPerspectiveCamera?m*=T:s.object instanceof c.OrthographicCamera&&s.object.isOrthographicCamera?(s.object.zoom=Math.max(s.minZoom,Math.min(s.maxZoom,s.object.zoom/T)),s.object.updateProjectionMatrix(),w=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),s.enableZoom=!1)}function oe(T){y.set(T.clientX,T.clientY)}function $(T){S.set(T.clientX,T.clientY)}function Q(T){L.set(T.clientX,T.clientY)}function K(T){v.set(T.clientX,T.clientY),M.subVectors(v,y).multiplyScalar(s.rotateSpeed);const F=s.domElement;F&&(B(2*Math.PI*M.x/F.clientHeight),R(2*Math.PI*M.y/F.clientHeight)),y.copy(v),s.update()}function he(T){A.set(T.clientX,T.clientY),_.subVectors(A,S),_.y>0?X(I()):_.y<0&&le(I()),S.copy(A),s.update()}function C(T){b.set(T.clientX,T.clientY),g.subVectors(b,L).multiplyScalar(s.panSpeed),se(g.x,g.y),L.copy(b),s.update()}function fe(T){T.deltaY<0?le(I()):T.deltaY>0&&X(I()),s.update()}function xe(T){let F=!1;switch(T.code){case s.keys.UP:se(0,s.keyPanSpeed),F=!0;break;case s.keys.BOTTOM:se(0,-s.keyPanSpeed),F=!0;break;case s.keys.LEFT:se(s.keyPanSpeed,0),F=!0;break;case s.keys.RIGHT:se(-s.keyPanSpeed,0),F=!0;break}F&&(T.preventDefault(),s.update())}function Se(){if(x.length==1)y.set(x[0].pageX,x[0].pageY);else{const T=.5*(x[0].pageX+x[1].pageX),F=.5*(x[0].pageY+x[1].pageY);y.set(T,F)}}function Ne(){if(x.length==1)L.set(x[0].pageX,x[0].pageY);else{const T=.5*(x[0].pageX+x[1].pageX),F=.5*(x[0].pageY+x[1].pageY);L.set(T,F)}}function ut(){const T=x[0].pageX-x[1].pageX,F=x[0].pageY-x[1].pageY,z=Math.sqrt(T*T+F*F);S.set(0,z)}function $r(){s.enableZoom&&ut(),s.enablePan&&Ne()}function ea(){s.enableZoom&&ut(),s.enableRotate&&Se()}function Qs(T){if(x.length==1)v.set(T.pageX,T.pageY);else{const z=es(T),ee=.5*(T.pageX+z.x),pe=.5*(T.pageY+z.y);v.set(ee,pe)}M.subVectors(v,y).multiplyScalar(s.rotateSpeed);const F=s.domElement;F&&(B(2*Math.PI*M.x/F.clientHeight),R(2*Math.PI*M.y/F.clientHeight)),y.copy(v)}function Ks(T){if(x.length==1)b.set(T.pageX,T.pageY);else{const F=es(T),z=.5*(T.pageX+F.x),ee=.5*(T.pageY+F.y);b.set(z,ee)}g.subVectors(b,L).multiplyScalar(s.panSpeed),se(g.x,g.y),L.copy(b)}function Ws(T){const F=es(T),z=T.pageX-F.x,ee=T.pageY-F.y,pe=Math.sqrt(z*z+ee*ee);A.set(0,pe),_.set(0,Math.pow(A.y/S.y,s.zoomSpeed)),X(_.y),S.copy(A)}function ta(T){s.enableZoom&&Ws(T),s.enablePan&&Ks(T)}function sa(T){s.enableZoom&&Ws(T),s.enableRotate&&Qs(T)}function qs(T){var F,z;s.enabled!==!1&&(x.length===0&&((F=s.domElement)==null||F.ownerDocument.addEventListener("pointermove",Jt),(z=s.domElement)==null||z.ownerDocument.addEventListener("pointerup",Ht)),aa(T),T.pointerType==="touch"?oa(T):na(T))}function Jt(T){s.enabled!==!1&&(T.pointerType==="touch"?ra(T):ia(T))}function Ht(T){var F,z,ee;en(T),x.length===0&&((F=s.domElement)==null||F.releasePointerCapture(T.pointerId),(z=s.domElement)==null||z.ownerDocument.removeEventListener("pointermove",Jt),(ee=s.domElement)==null||ee.ownerDocument.removeEventListener("pointerup",Ht)),s.dispatchEvent(o),a=r.NONE}function Js(T){en(T)}function na(T){let F;switch(T.button){case 0:F=s.mouseButtons.LEFT;break;case 1:F=s.mouseButtons.MIDDLE;break;case 2:F=s.mouseButtons.RIGHT;break;default:F=-1}switch(F){case c.MOUSE.DOLLY:if(s.enableZoom===!1)return;$(T),a=r.DOLLY;break;case c.MOUSE.ROTATE:if(T.ctrlKey||T.metaKey||T.shiftKey){if(s.enablePan===!1)return;Q(T),a=r.PAN}else{if(s.enableRotate===!1)return;oe(T),a=r.ROTATE}break;case c.MOUSE.PAN:if(T.ctrlKey||T.metaKey||T.shiftKey){if(s.enableRotate===!1)return;oe(T),a=r.ROTATE}else{if(s.enablePan===!1)return;Q(T),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&s.dispatchEvent(i)}function ia(T){if(s.enabled!==!1)switch(a){case r.ROTATE:if(s.enableRotate===!1)return;K(T);break;case r.DOLLY:if(s.enableZoom===!1)return;he(T);break;case r.PAN:if(s.enablePan===!1)return;C(T);break}}function Hs(T){s.enabled===!1||s.enableZoom===!1||a!==r.NONE&&a!==r.ROTATE||(T.preventDefault(),s.dispatchEvent(i),fe(T),s.dispatchEvent(o))}function $t(T){s.enabled===!1||s.enablePan===!1||xe(T)}function oa(T){switch(tn(T),x.length){case 1:switch(s.touches.ONE){case c.TOUCH.ROTATE:if(s.enableRotate===!1)return;Se(),a=r.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(s.enablePan===!1)return;Ne(),a=r.TOUCH_PAN;break;default:a=r.NONE}break;case 2:switch(s.touches.TWO){case c.TOUCH.DOLLY_PAN:if(s.enableZoom===!1&&s.enablePan===!1)return;$r(),a=r.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(s.enableZoom===!1&&s.enableRotate===!1)return;ea(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&s.dispatchEvent(i)}function ra(T){switch(tn(T),a){case r.TOUCH_ROTATE:if(s.enableRotate===!1)return;Qs(T),s.update();break;case r.TOUCH_PAN:if(s.enablePan===!1)return;Ks(T),s.update();break;case r.TOUCH_DOLLY_PAN:if(s.enableZoom===!1&&s.enablePan===!1)return;ta(T),s.update();break;case r.TOUCH_DOLLY_ROTATE:if(s.enableZoom===!1&&s.enableRotate===!1)return;sa(T),s.update();break;default:a=r.NONE}}function $s(T){s.enabled!==!1&&T.preventDefault()}function aa(T){x.push(T)}function en(T){delete D[T.pointerId];for(let F=0;F<x.length;F++)if(x[F].pointerId==T.pointerId){x.splice(F,1);return}}function tn(T){let F=D[T.pointerId];F===void 0&&(F=new c.Vector2,D[T.pointerId]=F),F.set(T.pageX,T.pageY)}function es(T){const F=T.pointerId===x[0].pointerId?x[1]:x[0];return D[F.pointerId]}t!==void 0&&this.connect(t),this.update()}}class Dn extends hs{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=c.MOUSE.PAN,this.mouseButtons.RIGHT=c.MOUSE.ROTATE,this.touches.ONE=c.TOUCH.PAN,this.touches.TWO=c.TOUCH.DOLLY_ROTATE}}class In extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Nn(t)}),this.register(function(t){return new Xn(t)}),this.register(function(t){return new Zn(t)}),this.register(function(t){return new Qn(t)}),this.register(function(t){return new En(t)}),this.register(function(t){return new zn(t)}),this.register(function(t){return new Rn(t)}),this.register(function(t){return new Gn(t)}),this.register(function(t){return new Un(t)}),this.register(function(t){return new Yn(t)}),this.register(function(t){return new Vn(t)}),this.register(function(t){return new jn(t)}),this.register(function(t){return new Fn(t)}),this.register(function(t){return new Kn(t)}),this.register(function(t){return new Wn(t)})}load(e,t,s,n){const i=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=c.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const r=function(h){n?n(h):console.error(h),i.manager.itemError(e),i.manager.itemEnd(e)},a=new c.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(h){try{i.parse(h,o,function(p){t(p),i.manager.itemEnd(e)},r)}catch(p){r(p)}},s,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let i;const o={},r={};if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===us){try{o[Z.KHR_BINARY_GLTF]=new qn(e)}catch(p){n&&n(p);return}i=JSON.parse(o[Z.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.LoaderUtils.decodeText(new Uint8Array(e)));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const a=new ci(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const p=this.pluginCallbacks[h](a);r[p.name]=p,o[p.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const p=i.extensionsUsed[h],d=i.extensionsRequired||[];switch(p){case Z.KHR_MATERIALS_UNLIT:o[p]=new Bn;break;case Z.KHR_DRACO_MESH_COMPRESSION:o[p]=new Jn(i,this.dracoLoader);break;case Z.KHR_TEXTURE_TRANSFORM:o[p]=new Hn;break;case Z.KHR_MESH_QUANTIZATION:o[p]=new $n;break;default:d.indexOf(p)>=0&&r[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}a.setExtensions(o),a.setPlugins(r),a.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function kn(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const Z={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Fn{constructor(e){this.parser=e,this.name=Z.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let h;const p=new c.Color(16777215);a.color!==void 0&&p.fromArray(a.color);const d=a.range!==void 0?a.range:0;switch(a.type){case"directional":h=new c.DirectionalLight(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new c.PointLight(p),h.distance=d;break;case"spot":h=new c.SpotLight(p),h.distance=d,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,h.angle=a.spot.outerConeAngle,h.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return h.position.set(0,0,0),h.decay=2,Be(h,a),a.intensity!==void 0&&(h.intensity=a.intensity),h.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(h),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return s._getNodeRef(t.cache,r,a)})}}class Bn{constructor(){this.name=Z.KHR_MATERIALS_UNLIT}getMaterialType(){return c.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new c.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.fromArray(o),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,3001))}return Promise.all(n)}}class Un{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class Nn{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const r=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new c.Vector2(r,r)}return Promise.all(i)}}class Vn{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class En{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];return o.sheenColorFactor!==void 0&&t.sheenColor.fromArray(o.sheenColorFactor),o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,3001)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class zn{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Rn{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const r=o.attenuationColor||[1,1,1];return t.attenuationColor=new c.Color(r[0],r[1],r[2]),Promise.all(i)}}class Gn{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Yn{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const r=o.specularColorFactor||[1,1,1];return t.specularColor=new c.Color(r[0],r[1],r[2]),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,3001)),Promise.all(i)}}class jn{constructor(e){this.parser=e,this.name=Z.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Xn{constructor(e){this.parser=e,this.name=Z.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class Zn{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=n.images[o.source];let a=s.textureLoader;if(r.uri){const h=s.options.manager.getHandler(r.uri);h!==null&&(a=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,o.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Qn{constructor(e){this.parser=e,this.name=Z.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=n.images[o.source];let a=s.textureLoader;if(r.uri){const h=s.options.manager.getHandler(r.uri);h!==null&&(a=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,o.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Kn{constructor(e){this.name=Z.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(r){const a=n.byteOffset||0,h=n.byteLength||0,p=n.count,d=n.byteStride,m=new Uint8Array(r,a,h);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(p,d,m,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(p*d);return o.decodeGltfBuffer(new Uint8Array(f),p,d,m,n.mode,n.filter),f})})}else return null}}class Wn{constructor(e){this.name=Z.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const h of n.primitives)if(h.mode!==ye.TRIANGLES&&h.mode!==ye.TRIANGLE_STRIP&&h.mode!==ye.TRIANGLE_FAN&&h.mode!==void 0)return null;const o=s.extensions[this.name].attributes,r=[],a={};for(const h in o)r.push(this.parser.getDependency("accessor",o[h]).then(p=>(a[h]=p,a[h])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(h=>{const p=h.pop(),d=p.isGroup?p.children:[p],m=h[0].count,f=[];for(const w of d){const y=new c.Matrix4,v=new c.Vector3,M=new c.Quaternion,L=new c.Vector3(1,1,1),b=new c.InstancedMesh(w.geometry,w.material,m);for(let g=0;g<m;g++)a.TRANSLATION&&v.fromBufferAttribute(a.TRANSLATION,g),a.ROTATION&&M.fromBufferAttribute(a.ROTATION,g),a.SCALE&&L.fromBufferAttribute(a.SCALE,g),b.setMatrixAt(g,y.compose(v,M,L));for(const g in a)g!=="TRANSLATION"&&g!=="ROTATION"&&g!=="SCALE"&&w.geometry.setAttribute(g,a[g]);c.Object3D.prototype.copy.call(b,w),this.parser.assignFinalMaterial(b),f.push(b)}return p.isGroup?(p.clear(),p.add(...f),p):f[0]}))}}const us="glTF",nt=12,ps={JSON:1313821514,BIN:5130562};class qn{constructor(e){this.name=Z.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,nt);if(this.header={magic:c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==us)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-nt,n=new DataView(e,nt);let i=0;for(;i<s;){const o=n.getUint32(i,!0);i+=4;const r=n.getUint32(i,!0);if(i+=4,r===ps.JSON){const a=new Uint8Array(e,nt+i,o);this.content=c.LoaderUtils.decodeText(a)}else if(r===ps.BIN){const a=nt+i;this.body=e.slice(a,a+o)}i+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Jn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Z.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,r={},a={},h={};for(const p in o){const d=Tt[p]||p.toLowerCase();r[d]=o[p]}for(const p in e.attributes){const d=Tt[p]||p.toLowerCase();if(o[p]!==void 0){const m=s.accessors[e.attributes[p]],f=We[m.componentType];h[d]=f.name,a[d]=m.normalized===!0}}return t.getDependency("bufferView",i).then(function(p){return new Promise(function(d){n.decodeDracoFile(p,function(m){for(const f in m.attributes){const w=m.attributes[f],y=a[f];y!==void 0&&(w.normalized=y)}d(m)},r,h)})})}}class Hn{constructor(){this.name=Z.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class $n{constructor(){this.name=Z.KHR_MESH_QUANTIZATION}}class ds extends c.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,r=this.valueSize,a=r*2,h=r*3,p=n-t,d=(s-t)/p,m=d*d,f=m*d,w=e*h,y=w-h,v=-2*f+3*m,M=f-m,L=1-v,b=M-m+d;for(let g=0;g!==r;g++){const S=o[y+g+r],A=o[y+g+a]*p,_=o[w+g+r],x=o[w+g]*p;i[g]=L*S+b*A+v*_+M*x}return i}}const ei=new c.Quaternion;class ti extends ds{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return ei.fromArray(i).normalize().toArray(i),i}}const ye={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},We={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ms={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},fs={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},St={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Tt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...c.REVISION.replace(/\D+/g,"")>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Fe={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},si={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},Lt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ni(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),l.DefaultMaterial}function Ee(l,e,t){for(const s in t.extensions)l[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function Be(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ii(l,e,t){let s=!1,n=!1,i=!1;for(let h=0,p=e.length;h<p;h++){const d=e[h];if(d.POSITION!==void 0&&(s=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const o=[],r=[],a=[];for(let h=0,p=e.length;h<p;h++){const d=e[h];if(s){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):l.attributes.position;o.push(m)}if(n){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):l.attributes.normal;r.push(m)}if(i){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):l.attributes.color;a.push(m)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a)]).then(function(h){const p=h[0],d=h[1],m=h[2];return s&&(l.morphAttributes.position=p),n&&(l.morphAttributes.normal=d),i&&(l.morphAttributes.color=m),l.morphTargetsRelative=!0,l})}function oi(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)l.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ri(l){let e;const t=l.extensions&&l.extensions[Z.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ct(t.attributes):e=l.indices+":"+Ct(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+Ct(l.targets[s]);return e}function Ct(l){let e="";const t=Object.keys(l).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+l[t[s]]+";";return e}function Ot(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function ai(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const li=new c.Matrix4;class ci{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new kn,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=!1,i=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,i=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||n&&i<98?this.textureLoader=new c.TextureLoader(this.options.manager):this.textureLoader=new c.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const r={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};Ee(i,r,n),Be(r,n),Promise.all(s._invokeAll(function(a){return a.afterRoot&&a.afterRoot(r)})).then(function(){e(r)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let r=0,a=o.length;r<a;r++)e[o[r]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,r)=>{const a=this.associations.get(o);a!=null&&this.associations.set(r,a);for(const[h,p]of o.children.entries())i(p,r.children[h])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Z.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(c.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=St[n.type],r=We[n.componentType],a=n.normalized===!0,h=new r(n.count*o);return Promise.resolve(new c.BufferAttribute(h,o,a))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const r=o[0],a=St[n.type],h=We[n.componentType],p=h.BYTES_PER_ELEMENT,d=p*a,m=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,w=n.normalized===!0;let y,v;if(f&&f!==d){const M=Math.floor(m/f),L="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+M+":"+n.count;let b=t.cache.get(L);b||(y=new h(r,M*f,n.count*f/p),b=new c.InterleavedBuffer(y,f/p),t.cache.add(L,b)),v=new c.InterleavedBufferAttribute(b,a,m%f/p,w)}else r===null?y=new h(n.count*a):y=new h(r,m,n.count*a),v=new c.BufferAttribute(y,a,w);if(n.sparse!==void 0){const M=St.SCALAR,L=We[n.sparse.indices.componentType],b=n.sparse.indices.byteOffset||0,g=n.sparse.values.byteOffset||0,S=new L(o[1],b,n.sparse.count*M),A=new h(o[2],g,n.sparse.count*a);r!==null&&(v=new c.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let _=0,x=S.length;_<x;_++){const D=S[_];if(v.setX(D,A[_*a]),a>=2&&v.setY(D,A[_*a+1]),a>=3&&v.setZ(D,A[_*a+2]),a>=4&&v.setW(D,A[_*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let r=this.textureLoader;if(o.uri){const a=s.manager.getHandler(o.uri);a!==null&&(r=a)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],r=i.images[t],a=(r.uri||r.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const h=this.loadImageSource(t,s).then(function(p){p.flipY=!1,p.name=o.name||r.name||"",p.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(p.name=r.uri);const m=(i.samplers||{})[o.sampler]||{};return p.magFilter=ms[m.magFilter]||c.LinearFilter,p.minFilter=ms[m.minFilter]||c.LinearMipmapLinearFilter,p.wrapS=fs[m.wrapS]||c.RepeatWrapping,p.wrapT=fs[m.wrapT]||c.RepeatWrapping,n.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[a]=h,h}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=n.images[e],r=self.URL||self.webkitURL;let a=o.uri||"",h=!1;if(o.bufferView!==void 0)a=s.getDependency("bufferView",o.bufferView).then(function(d){h=!0;const m=new Blob([d],{type:o.mimeType});return a=r.createObjectURL(m),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(a).then(function(d){return new Promise(function(m,f){let w=m;t.isImageBitmapLoader===!0&&(w=function(y){const v=new c.Texture(y);v.needsUpdate=!0,m(v)}),t.load(c.LoaderUtils.resolveURL(d,i.path),w,void 0,f)})}).then(function(d){return h===!0&&r.revokeObjectURL(a),d.userData.mimeType=o.mimeType||ai(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),d});return this.sourceCache[e]=p,p}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[Z.KHR_TEXTURE_TRANSFORM]){const r=s.extensions!==void 0?s.extensions[Z.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=i.associations.get(o);o=i.extensions[Z.KHR_TEXTURE_TRANSFORM].extendTexture(o,r),i.associations.set(o,a)}}return n!==void 0&&("colorSpace"in o?o.colorSpace=n===3001?"srgb":"srgb-linear":o.encoding=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+s.uuid;let a=this.cache.get(r);a||(a=new c.PointsMaterial,c.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,a.sizeAttenuation=!1,this.cache.add(r,a)),s=a}else if(e.isLine){const r="LineBasicMaterial:"+s.uuid;let a=this.cache.get(r);a||(a=new c.LineBasicMaterial,c.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,this.cache.add(r,a)),s=a}if(n||i||o){let r="ClonedMaterial:"+s.uuid+":";n&&(r+="derivative-tangents:"),i&&(r+="vertex-colors:"),o&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=s.clone(),i&&(a.vertexColors=!0),o&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(s))),s=a}e.material=s}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const r={},a=i.extensions||{},h=[];if(a[Z.KHR_MATERIALS_UNLIT]){const d=n[Z.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),h.push(d.extendParams(r,i,t))}else{const d=i.pbrMetallicRoughness||{};if(r.color=new c.Color(1,1,1),r.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;r.color.fromArray(m),r.opacity=m[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(r,"map",d.baseColorTexture,3001)),r.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,r.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(r,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(r,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,r)})))}i.doubleSided===!0&&(r.side=c.DoubleSide);const p=i.alphaMode||Lt.OPAQUE;if(p===Lt.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,p===Lt.MASK&&(r.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==c.MeshBasicMaterial&&(h.push(t.assignTexture(r,"normalMap",i.normalTexture)),r.normalScale=new c.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;r.normalScale.set(d,d)}return i.occlusionTexture!==void 0&&o!==c.MeshBasicMaterial&&(h.push(t.assignTexture(r,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==c.MeshBasicMaterial&&(r.emissive=new c.Color().fromArray(i.emissiveFactor)),i.emissiveTexture!==void 0&&o!==c.MeshBasicMaterial&&h.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture,3001)),Promise.all(h).then(function(){const d=new o(r);return i.name&&(d.name=i.name),Be(d,i),t.associations.set(d,{materials:e}),i.extensions&&Ee(n,d,i),d})}createUniqueName(e){const t=c.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(r){return s[Z.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return gs(a,r,t)})}const o=[];for(let r=0,a=e.length;r<a;r++){const h=e[r],p=ri(h),d=n[p];if(d)o.push(d.promise);else{let m;h.extensions&&h.extensions[Z.KHR_DRACO_MESH_COMPRESSION]?m=i(h):m=gs(new c.BufferGeometry,h,t),n[p]={primitive:h,promise:m},o.push(m)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,r=[];for(let a=0,h=o.length;a<h;a++){const p=o[a].material===void 0?ni(this.cache):this.getDependency("material",o[a].material);r.push(p)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(a){const h=a.slice(0,a.length-1),p=a[a.length-1],d=[];for(let f=0,w=p.length;f<w;f++){const y=p[f],v=o[f];let M;const L=h[f];if(v.mode===ye.TRIANGLES||v.mode===ye.TRIANGLE_STRIP||v.mode===ye.TRIANGLE_FAN||v.mode===void 0)M=i.isSkinnedMesh===!0?new c.SkinnedMesh(y,L):new c.Mesh(y,L),M.isSkinnedMesh===!0&&M.normalizeSkinWeights(),v.mode===ye.TRIANGLE_STRIP?M.geometry=ts(M.geometry,c.TriangleStripDrawMode):v.mode===ye.TRIANGLE_FAN&&(M.geometry=ts(M.geometry,c.TriangleFanDrawMode));else if(v.mode===ye.LINES)M=new c.LineSegments(y,L);else if(v.mode===ye.LINE_STRIP)M=new c.Line(y,L);else if(v.mode===ye.LINE_LOOP)M=new c.LineLoop(y,L);else if(v.mode===ye.POINTS)M=new c.Points(y,L);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(M.geometry.morphAttributes).length>0&&oi(M,i),M.name=t.createUniqueName(i.name||"mesh_"+e),Be(M,i),v.extensions&&Ee(n,M,v),t.assignFinalMaterial(M),d.push(M)}for(let f=0,w=d.length;f<w;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return i.extensions&&Ee(n,d[0],i),d[0];const m=new c.Group;i.extensions&&Ee(n,m,i),t.associations.set(m,{meshes:e});for(let f=0,w=d.length;f<w;f++)m.add(d[f]);return m})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new c.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),Be(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,r=[],a=[];for(let h=0,p=o.length;h<p;h++){const d=o[h];if(d){r.push(d);const m=new c.Matrix4;i!==null&&m.fromArray(i.array,h*16),a.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new c.Skeleton(r,a)})}loadAnimation(e){const s=this.json.animations[e],n=s.name?s.name:"animation_"+e,i=[],o=[],r=[],a=[],h=[];for(let p=0,d=s.channels.length;p<d;p++){const m=s.channels[p],f=s.samplers[m.sampler],w=m.target,y=w.node,v=s.parameters!==void 0?s.parameters[f.input]:f.input,M=s.parameters!==void 0?s.parameters[f.output]:f.output;w.node!==void 0&&(i.push(this.getDependency("node",y)),o.push(this.getDependency("accessor",v)),r.push(this.getDependency("accessor",M)),a.push(f),h.push(w))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(r),Promise.all(a),Promise.all(h)]).then(function(p){const d=p[0],m=p[1],f=p[2],w=p[3],y=p[4],v=[];for(let M=0,L=d.length;M<L;M++){const b=d[M],g=m[M],S=f[M],A=w[M],_=y[M];if(b===void 0)continue;b.updateMatrix();let x;switch(Fe[_.path]){case Fe.weights:x=c.NumberKeyframeTrack;break;case Fe.rotation:x=c.QuaternionKeyframeTrack;break;case Fe.position:case Fe.scale:default:x=c.VectorKeyframeTrack;break}const D=b.name?b.name:b.uuid,k=A.interpolation!==void 0?si[A.interpolation]:c.InterpolateLinear,I=[];Fe[_.path]===Fe.weights?b.traverse(function(R){R.morphTargetInfluences&&I.push(R.name?R.name:R.uuid)}):I.push(D);let B=S.array;if(S.normalized){const R=Ot(B.constructor),H=new Float32Array(B.length);for(let G=0,se=B.length;G<se;G++)H[G]=B[G]*R;B=H}for(let R=0,H=I.length;R<H;R++){const G=new x(I[R]+"."+Fe[_.path],g.array,B,k);A.interpolation==="CUBICSPLINE"&&(G.createInterpolant=function(X){const le=this instanceof c.QuaternionKeyframeTrack?ti:ds;return new le(this.times,this.values,this.getValueSize()/3,X)},G.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),v.push(G)}}return new c.AnimationClip(n,void 0,v)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(r){if(r.isMesh)for(let a=0,h=n.weights.length;a<h;a++)r.morphTargetInfluences[a]=n.weights[a]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],r=n.children||[];for(let h=0,p=r.length;h<p;h++)o.push(s.getDependency("node",r[h]));const a=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),a]).then(function(h){const p=h[0],d=h[1],m=h[2];m!==null&&p.traverse(function(f){f.isSkinnedMesh&&f.bind(m,li)});for(let f=0,w=d.length;f<w;f++)p.add(d[f]);return p})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",r=[],a=n._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return a&&r.push(a),i.camera!==void 0&&r.push(n.getDependency("camera",i.camera).then(function(h){return n._getNodeRef(n.cameraCache,i.camera,h)})),n._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){r.push(h)}),this.nodeCache[e]=Promise.all(r).then(function(h){let p;if(i.isBone===!0?p=new c.Bone:h.length>1?p=new c.Group:h.length===1?p=h[0]:p=new c.Object3D,p!==h[0])for(let d=0,m=h.length;d<m;d++)p.add(h[d]);if(i.name&&(p.userData.name=i.name,p.name=o),Be(p,i),i.extensions&&Ee(s,p,i),i.matrix!==void 0){const d=new c.Matrix4;d.fromArray(i.matrix),p.applyMatrix4(d)}else i.translation!==void 0&&p.position.fromArray(i.translation),i.rotation!==void 0&&p.quaternion.fromArray(i.rotation),i.scale!==void 0&&p.scale.fromArray(i.scale);return n.associations.has(p)||n.associations.set(p,{}),n.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new c.Group;s.name&&(i.name=n.createUniqueName(s.name)),Be(i,s),s.extensions&&Ee(t,i,s);const o=s.nodes||[],r=[];for(let a=0,h=o.length;a<h;a++)r.push(n.getDependency("node",o[a]));return Promise.all(r).then(function(a){for(let p=0,d=a.length;p<d;p++)i.add(a[p]);const h=p=>{const d=new Map;for(const[m,f]of n.associations)(m instanceof c.Material||m instanceof c.Texture)&&d.set(m,f);return p.traverse(m=>{const f=n.associations.get(m);f!=null&&d.set(m,f)}),d};return n.associations=h(i),i})}}function hi(l,e,t){const s=e.attributes,n=new c.Box3;if(s.POSITION!==void 0){const r=t.json.accessors[s.POSITION],a=r.min,h=r.max;if(a!==void 0&&h!==void 0){if(n.set(new c.Vector3(a[0],a[1],a[2]),new c.Vector3(h[0],h[1],h[2])),r.normalized){const p=Ot(We[r.componentType]);n.min.multiplyScalar(p),n.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new c.Vector3,a=new c.Vector3;for(let h=0,p=i.length;h<p;h++){const d=i[h];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],f=m.min,w=m.max;if(f!==void 0&&w!==void 0){if(a.setX(Math.max(Math.abs(f[0]),Math.abs(w[0]))),a.setY(Math.max(Math.abs(f[1]),Math.abs(w[1]))),a.setZ(Math.max(Math.abs(f[2]),Math.abs(w[2]))),m.normalized){const y=Ot(We[m.componentType]);a.multiplyScalar(y)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(r)}l.boundingBox=n;const o=new c.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=o}function gs(l,e,t){const s=e.attributes,n=[];function i(o,r){return t.getDependency("accessor",o).then(function(a){l.setAttribute(r,a)})}for(const o in s){const r=Tt[o]||o.toLowerCase();r in l.attributes||n.push(i(s[o],r))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(r){l.setIndex(r)});n.push(o)}return Be(l,e),hi(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ii(l,e.targets,t):l})}class ys extends c.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:s=!1,bevelSize:n=8,bevelThickness:i=10,font:o,height:r=50,size:a=100,lineHeight:h=1,letterSpacing:p=0,...d}=t;if(o===void 0)super();else{const m=o.generateShapes(e,a,{lineHeight:h,letterSpacing:p});super(m,{...d,bevelEnabled:s,bevelSize:n,bevelThickness:i,depth:r})}this.type="TextGeometry"}}const ui={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
9
9
|
varying vec2 vUv;
|
|
10
10
|
|
|
11
11
|
void main() {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
gl_FragColor = sum;
|
|
38
38
|
|
|
39
39
|
}
|
|
40
|
-
`},
|
|
40
|
+
`},pi={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 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,
|
|
75
|
-
`,
|
|
76
|
-
`;k=
|
|
73
|
+
`};function _s(l,e,t){const s=t.length-l-1;if(e>=t[s])return s-1;if(e<=t[l])return l;let n=l,i=s,o=Math.floor((n+i)/2);for(;e<t[o]||e>=t[o+1];)e<t[o]?i=o:n=o,o=Math.floor((n+i)/2);return o}function di(l,e,t,s){const n=[],i=[],o=[];n[0]=1;for(let r=1;r<=t;++r){i[r]=e-s[l+1-r],o[r]=s[l+r]-e;let a=0;for(let h=0;h<r;++h){const p=o[h+1],d=i[r-h],m=n[h]/(p+d);n[h]=a+p*m,a=d*m}n[r]=a}return n}function mi(l,e,t,s){const n=_s(l,s,e),i=di(n,s,l,e),o=new c.Vector4(0,0,0,0);for(let r=0;r<=l;++r){const a=t[n-l+r],h=i[r],p=a.w*h;o.x+=a.x*p,o.y+=a.y*p,o.z+=a.z*p,o.w+=a.w*h}return o}function fi(l,e,t,s,n){const i=[];for(let d=0;d<=t;++d)i[d]=0;const o=[];for(let d=0;d<=s;++d)o[d]=i.slice(0);const r=[];for(let d=0;d<=t;++d)r[d]=i.slice(0);r[0][0]=1;const a=i.slice(0),h=i.slice(0);for(let d=1;d<=t;++d){a[d]=e-n[l+1-d],h[d]=n[l+d]-e;let m=0;for(let f=0;f<d;++f){const w=h[f+1],y=a[d-f];r[d][f]=w+y;const v=r[f][d-1]/r[d][f];r[f][d]=m+w*v,m=y*v}r[d][d]=m}for(let d=0;d<=t;++d)o[0][d]=r[d][t];for(let d=0;d<=t;++d){let m=0,f=1;const w=[];for(let y=0;y<=t;++y)w[y]=i.slice(0);w[0][0]=1;for(let y=1;y<=s;++y){let v=0;const M=d-y,L=t-y;d>=y&&(w[f][0]=w[m][0]/r[L+1][M],v=w[f][0]*r[M][L]);const b=M>=-1?1:-M,g=d-1<=L?y-1:t-d;for(let A=b;A<=g;++A)w[f][A]=(w[m][A]-w[m][A-1])/r[L+1][M+A],v+=w[f][A]*r[M+A][L];d<=L&&(w[f][y]=-w[m][y-1]/r[L+1][d],v+=w[f][y]*r[d][L]),o[y][d]=v;const S=m;m=f,f=S}}let p=t;for(let d=1;d<=s;++d){for(let m=0;m<=t;++m)o[d][m]*=p;p*=t-d}return o}function gi(l,e,t,s,n){const i=n<l?n:l,o=[],r=_s(l,s,e),a=fi(r,s,l,i,e),h=[];for(let p=0;p<t.length;++p){const d=t[p].clone(),m=d.w;d.x*=m,d.y*=m,d.z*=m,h[p]=d}for(let p=0;p<=i;++p){const d=h[r-l].clone().multiplyScalar(a[p][0]);for(let m=1;m<=l;++m)d.add(h[r-l+m].clone().multiplyScalar(a[p][m]));o[p]=d}for(let p=i+1;p<=n+1;++p)o[p]=new c.Vector4(0,0,0);return o}function yi(l,e){let t=1;for(let n=2;n<=l;++n)t*=n;let s=1;for(let n=2;n<=e;++n)s*=n;for(let n=2;n<=l-e;++n)s*=n;return t/s}function _i(l){const e=l.length,t=[],s=[];for(let i=0;i<e;++i){const o=l[i];t[i]=new c.Vector3(o.x,o.y,o.z),s[i]=o.w}const n=[];for(let i=0;i<e;++i){const o=t[i].clone();for(let r=1;r<=i;++r)o.sub(n[i-r].clone().multiplyScalar(yi(i,r)*s[r]));n[i]=o.divideScalar(s[0])}return n}function wi(l,e,t,s,n){const i=gi(l,e,t,s,n);return _i(i)}class ws extends c.Curve{constructor(e,t,s,n,i){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=n||0,this.endKnot=i||this.knots.length-1;for(let o=0;o<s.length;++o){const r=s[o];this.controlPoints[o]=new c.Vector4(r.x,r.y,r.z,r.w)}}getPoint(e,t){const s=t||new c.Vector3,n=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=mi(this.degree,this.knots,this.controlPoints,n);return i.w!=1&&i.divideScalar(i.w),s.set(i.x,i.y,i.z)}getTangent(e,t){const s=t||new c.Vector3,n=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=wi(this.degree,this.knots,this.controlPoints,n,1);return s.copy(i[1]).normalize(),s}}let j,ie,de;class xi extends c.Loader{constructor(e){super(e)}load(e,t,s,n){const i=this,o=i.path===""?c.LoaderUtils.extractUrlBase(e):i.path,r=new c.FileLoader(this.manager);r.setPath(i.path),r.setResponseType("arraybuffer"),r.setRequestHeader(i.requestHeader),r.setWithCredentials(i.withCredentials),r.load(e,function(a){try{t(i.parse(a,o))}catch(h){n?n(h):console.error(h),i.manager.itemError(e)}},s,n)}parse(e,t){if(Ti(e))j=new Si().parse(e);else{const n=Ss(e);if(!Li(n))throw new Error("THREE.FBXLoader: Unknown format.");if(As(n)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+As(n));j=new bi().parse(n)}const s=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new vi(s,this.manager).parse(j)}}class vi{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){ie=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),s=this.parseMaterials(t),n=this.parseDeformers(),i=new Ai().parse(n);return this.parseScene(n,i,s),de}parseConnections(){const e=new Map;return"Connections"in j&&j.Connections.connections.forEach(function(s){const n=s[0],i=s[1],o=s[2];e.has(n)||e.set(n,{parents:[],children:[]});const r={ID:i,relationship:o};e.get(n).parents.push(r),e.has(i)||e.set(i,{parents:[],children:[]});const a={ID:n,relationship:o};e.get(i).children.push(a)}),e}parseImages(){const e={},t={};if("Video"in j.Objects){const s=j.Objects.Video;for(const n in s){const i=s[n],o=parseInt(n);if(e[o]=i.RelativeFilename||i.Filename,"Content"in i){const r=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,a=typeof i.Content=="string"&&i.Content!=="";if(r||a){const h=this.parseImage(s[n]);t[i.RelativeFilename||i.Filename]=h}}}}for(const s in e){const n=e[s];t[n]!==void 0?e[s]=t[n]:e[s]=e[s].split("\\").pop()}return e}parseImage(e){const t=e.Content,s=e.RelativeFilename||e.Filename,n=s.slice(s.lastIndexOf(".")+1).toLowerCase();let i;switch(n){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",s),i="image/tga";break;default:console.warn('FBXLoader: Image type "'+n+'" is not supported.');return}if(typeof t=="string")return"data:"+i+";base64,"+t;{const o=new Uint8Array(t);return window.URL.createObjectURL(new Blob([o],{type:i}))}}parseTextures(e){const t=new Map;if("Texture"in j.Objects){const s=j.Objects.Texture;for(const n in s){const i=this.parseTexture(s[n],e);t.set(parseInt(n),i)}}return t}parseTexture(e,t){const s=this.loadTexture(e,t);s.ID=e.id,s.name=e.attrName;const n=e.WrapModeU,i=e.WrapModeV,o=n!==void 0?n.value:0,r=i!==void 0?i.value:0;if(s.wrapS=o===0?c.RepeatWrapping:c.ClampToEdgeWrapping,s.wrapT=r===0?c.RepeatWrapping:c.ClampToEdgeWrapping,"Scaling"in e){const a=e.Scaling.value;s.repeat.x=a[0],s.repeat.y=a[1]}return s}loadTexture(e,t){let s;const n=this.textureLoader.path,i=ie.get(e.id).children;i!==void 0&&i.length>0&&t[i[0].ID]!==void 0&&(s=t[i[0].ID],(s.indexOf("blob:")===0||s.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let o;const r=e.FileName.slice(-3).toLowerCase();if(r==="tga"){const a=this.manager.getHandler(".tga");a===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),o=new c.Texture):(a.setPath(this.textureLoader.path),o=a.load(s))}else r==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),o=new c.Texture):o=this.textureLoader.load(s);return this.textureLoader.setPath(n),o}parseMaterials(e){const t=new Map;if("Material"in j.Objects){const s=j.Objects.Material;for(const n in s){const i=this.parseMaterial(s[n],e);i!==null&&t.set(parseInt(n),i)}}return t}parseMaterial(e,t){const s=e.id,n=e.attrName;let i=e.ShadingModel;if(typeof i=="object"&&(i=i.value),!ie.has(s))return null;const o=this.parseParameters(e,t,s);let r;switch(i.toLowerCase()){case"phong":r=new c.MeshPhongMaterial;break;case"lambert":r=new c.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),r=new c.MeshPhongMaterial;break}return r.setValues(o),r.name=n,r}parseParameters(e,t,s){const n={};e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=new c.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(n.color=new c.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=new c.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(n.emissive=new c.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(n.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(n.opacity=parseFloat(e.Opacity.value)),n.opacity<1&&(n.transparent=!0),e.ReflectionFactor&&(n.reflectivity=e.ReflectionFactor.value),e.Shininess&&(n.shininess=e.Shininess.value),e.Specular?n.specular=new c.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(n.specular=new c.Color().fromArray(e.SpecularColor.value));const i=this;return ie.get(s).children.forEach(function(o){const r=o.relationship;switch(r){case"Bump":n.bumpMap=i.getTexture(t,o.ID);break;case"Maya|TEX_ao_map":n.aoMap=i.getTexture(t,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=i.getTexture(t,o.ID),n.map!==void 0&&("colorSpace"in n.map?n.map.colorSpace="srgb":n.map.encoding=3001);break;case"DisplacementColor":n.displacementMap=i.getTexture(t,o.ID);break;case"EmissiveColor":n.emissiveMap=i.getTexture(t,o.ID),n.emissiveMap!==void 0&&("colorSpace"in n.emissiveMap?n.emissiveMap.colorSpace="srgb":n.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=i.getTexture(t,o.ID);break;case"ReflectionColor":n.envMap=i.getTexture(t,o.ID),n.envMap!==void 0&&(n.envMap.mapping=c.EquirectangularReflectionMapping,"colorSpace"in n.envMap?n.envMap.colorSpace="srgb":n.envMap.encoding=3001);break;case"SpecularColor":n.specularMap=i.getTexture(t,o.ID),n.specularMap!==void 0&&("colorSpace"in n.specularMap?n.specularMap.colorSpace="srgb":n.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=i.getTexture(t,o.ID),n.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",r);break}}),n}getTexture(e,t){return"LayeredTexture"in j.Objects&&t in j.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=ie.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in j.Objects){const s=j.Objects.Deformer;for(const n in s){const i=s[n],o=ie.get(parseInt(n));if(i.attrType==="Skin"){const r=this.parseSkeleton(o,s);r.ID=n,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),r.geometryID=o.parents[0].ID,e[n]=r}else if(i.attrType==="BlendShape"){const r={id:n};r.rawTargets=this.parseMorphTargets(o,s),r.id=n,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[n]=r}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const s=[];return e.children.forEach(function(n){const i=t[n.ID];if(i.attrType!=="Cluster")return;const o={ID:n.ID,indices:[],weights:[],transformLink:new c.Matrix4().fromArray(i.TransformLink.a)};"Indexes"in i&&(o.indices=i.Indexes.a,o.weights=i.Weights.a),s.push(o)}),{rawBones:s,bones:[]}}parseMorphTargets(e,t){const s=[];for(let n=0;n<e.children.length;n++){const i=e.children[n],o=t[i.ID],r={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if(o.attrType!=="BlendShapeChannel")return;r.geoID=ie.get(parseInt(i.ID)).children.filter(function(a){return a.relationship===void 0})[0].ID,s.push(r)}return s}parseScene(e,t,s){de=new c.Group;const n=this.parseModels(e.skeletons,t,s),i=j.Objects.Model,o=this;n.forEach(function(a){const h=i[a.ID];o.setLookAtProperties(a,h),ie.get(a.ID).parents.forEach(function(d){const m=n.get(d.ID);m!==void 0&&m.add(a)}),a.parent===null&&de.add(a)}),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),de.traverse(function(a){if(a.userData.transformData){a.parent&&(a.userData.transformData.parentMatrix=a.parent.matrix,a.userData.transformData.parentMatrixWorld=a.parent.matrixWorld);const h=Ms(a.userData.transformData);a.applyMatrix4(h),a.updateWorldMatrix()}});const r=new Mi().parse();de.children.length===1&&de.children[0].isGroup&&(de.children[0].animations=r,de=de.children[0]),de.animations=r}parseModels(e,t,s){const n=new Map,i=j.Objects.Model;for(const o in i){const r=parseInt(o),a=i[o],h=ie.get(r);let p=this.buildSkeleton(h,e,r,a.attrName);if(!p){switch(a.attrType){case"Camera":p=this.createCamera(h);break;case"Light":p=this.createLight(h);break;case"Mesh":p=this.createMesh(h,t,s);break;case"NurbsCurve":p=this.createCurve(h,t);break;case"LimbNode":case"Root":p=new c.Bone;break;case"Null":default:p=new c.Group;break}p.name=a.attrName?c.PropertyBinding.sanitizeNodeName(a.attrName):"",p.ID=r}this.getTransformData(p,a),n.set(r,p)}return n}buildSkeleton(e,t,s,n){let i=null;return e.parents.forEach(function(o){for(const r in t){const a=t[r];a.rawBones.forEach(function(h,p){if(h.ID===o.ID){const d=i;i=new c.Bone,i.matrixWorld.copy(h.transformLink),i.name=n?c.PropertyBinding.sanitizeNodeName(n):"",i.ID=s,a.bones[p]=i,d!==null&&i.add(d)}})}}),i}createCamera(e){let t,s;if(e.children.forEach(function(n){const i=j.Objects.NodeAttribute[n.ID];i!==void 0&&(s=i)}),s===void 0)t=new c.Object3D;else{let n=0;s.CameraProjectionType!==void 0&&s.CameraProjectionType.value===1&&(n=1);let i=1;s.NearPlane!==void 0&&(i=s.NearPlane.value/1e3);let o=1e3;s.FarPlane!==void 0&&(o=s.FarPlane.value/1e3);let r=window.innerWidth,a=window.innerHeight;s.AspectWidth!==void 0&&s.AspectHeight!==void 0&&(r=s.AspectWidth.value,a=s.AspectHeight.value);const h=r/a;let p=45;s.FieldOfView!==void 0&&(p=s.FieldOfView.value);const d=s.FocalLength?s.FocalLength.value:null;switch(n){case 0:t=new c.PerspectiveCamera(p,h,i,o),d!==null&&t.setFocalLength(d);break;case 1:t=new c.OrthographicCamera(-r/2,r/2,a/2,-a/2,i,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+n+"."),t=new c.Object3D;break}}return t}createLight(e){let t,s;if(e.children.forEach(function(n){const i=j.Objects.NodeAttribute[n.ID];i!==void 0&&(s=i)}),s===void 0)t=new c.Object3D;else{let n;s.LightType===void 0?n=0:n=s.LightType.value;let i=16777215;s.Color!==void 0&&(i=new c.Color().fromArray(s.Color.value));let o=s.Intensity===void 0?1:s.Intensity.value/100;s.CastLightOnObject!==void 0&&s.CastLightOnObject.value===0&&(o=0);let r=0;s.FarAttenuationEnd!==void 0&&(s.EnableFarAttenuation!==void 0&&s.EnableFarAttenuation.value===0?r=0:r=s.FarAttenuationEnd.value);const a=1;switch(n){case 0:t=new c.PointLight(i,o,r,a);break;case 1:t=new c.DirectionalLight(i,o);break;case 2:let h=Math.PI/3;s.InnerAngle!==void 0&&(h=c.MathUtils.degToRad(s.InnerAngle.value));let p=0;s.OuterAngle!==void 0&&(p=c.MathUtils.degToRad(s.OuterAngle.value),p=Math.max(p,1)),t=new c.SpotLight(i,o,r,h,p,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+s.LightType.value+", defaulting to a PointLight."),t=new c.PointLight(i,o);break}s.CastShadows!==void 0&&s.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,s){let n,i=null,o=null;const r=[];return e.children.forEach(function(a){t.has(a.ID)&&(i=t.get(a.ID)),s.has(a.ID)&&r.push(s.get(a.ID))}),r.length>1?o=r:r.length>0?o=r[0]:(o=new c.MeshPhongMaterial({color:13421772}),r.push(o)),"color"in i.attributes&&r.forEach(function(a){a.vertexColors=!0}),i.FBX_Deformer?(n=new c.SkinnedMesh(i,o),n.normalizeSkinWeights()):n=new c.Mesh(i,o),n}createCurve(e,t){const s=e.children.reduce(function(i,o){return t.has(o.ID)&&(i=t.get(o.ID)),i},null),n=new c.LineBasicMaterial({color:3342591,linewidth:1});return new c.Line(s,n)}getTransformData(e,t){const s={};"InheritType"in t&&(s.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?s.eulerOrder=bs(t.RotationOrder.value):s.eulerOrder="ZYX","Lcl_Translation"in t&&(s.translation=t.Lcl_Translation.value),"PreRotation"in t&&(s.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(s.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(s.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(s.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(s.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(s.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(s.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(s.rotationPivot=t.RotationPivot.value),e.userData.transformData=s}setLookAtProperties(e,t){"LookAtProperty"in t&&ie.get(e.ID).children.forEach(function(n){if(n.relationship==="LookAtProperty"){const i=j.Objects.Model[n.ID];if("Lcl_Translation"in i){const o=i.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(o),de.add(e.target)):e.lookAt(new c.Vector3().fromArray(o))}}})}bindSkeleton(e,t,s){const n=this.parsePoseNodes();for(const i in e){const o=e[i];ie.get(parseInt(o.ID)).parents.forEach(function(a){if(t.has(a.ID)){const h=a.ID;ie.get(h).parents.forEach(function(d){s.has(d.ID)&&s.get(d.ID).bind(new c.Skeleton(o.bones),n[d.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in j.Objects){const t=j.Objects.Pose;for(const s in t)if(t[s].attrType==="BindPose"&&t[s].NbPoseNodes>0){const n=t[s].PoseNode;Array.isArray(n)?n.forEach(function(i){e[i.Node]=new c.Matrix4().fromArray(i.Matrix.a)}):e[n.Node]=new c.Matrix4().fromArray(n.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in j&&"AmbientColor"in j.GlobalSettings){const e=j.GlobalSettings.AmbientColor.value,t=e[0],s=e[1],n=e[2];if(t!==0||s!==0||n!==0){const i=new c.Color(t,s,n);de.add(new c.AmbientLight(i,1))}}}}class Ai{parse(e){const t=new Map;if("Geometry"in j.Objects){const s=j.Objects.Geometry;for(const n in s){const i=ie.get(parseInt(n)),o=this.parseGeometry(i,s[n],e);t.set(parseInt(n),o)}}return t}parseGeometry(e,t,s){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,s);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,s){const n=s.skeletons,i=[],o=e.parents.map(function(d){return j.Objects.Model[d.ID]});if(o.length===0)return;const r=e.children.reduce(function(d,m){return n[m.ID]!==void 0&&(d=n[m.ID]),d},null);e.children.forEach(function(d){s.morphTargets[d.ID]!==void 0&&i.push(s.morphTargets[d.ID])});const a=o[0],h={};"RotationOrder"in a&&(h.eulerOrder=bs(a.RotationOrder.value)),"InheritType"in a&&(h.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(h.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(h.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(h.scale=a.GeometricScaling.value);const p=Ms(h);return this.genGeometry(t,r,i,p)}genGeometry(e,t,s,n){const i=new c.BufferGeometry;e.attrName&&(i.name=e.attrName);const o=this.parseGeoNode(e,t),r=this.genBuffers(o),a=new c.Float32BufferAttribute(r.vertex,3);if(a.applyMatrix4(n),i.setAttribute("position",a),r.colors.length>0&&i.setAttribute("color",new c.Float32BufferAttribute(r.colors,3)),t&&(i.setAttribute("skinIndex",new c.Uint16BufferAttribute(r.weightsIndices,4)),i.setAttribute("skinWeight",new c.Float32BufferAttribute(r.vertexWeights,4)),i.FBX_Deformer=t),r.normal.length>0){const h=new c.Matrix3().getNormalMatrix(n),p=new c.Float32BufferAttribute(r.normal,3);p.applyNormalMatrix(h),i.setAttribute("normal",p)}if(r.uvs.forEach(function(h,p){let d="uv"+(p+1).toString();p===0&&(d="uv"),i.setAttribute(d,new c.Float32BufferAttribute(r.uvs[p],2))}),o.material&&o.material.mappingType!=="AllSame"){let h=r.materialIndex[0],p=0;if(r.materialIndex.forEach(function(d,m){d!==h&&(i.addGroup(p,m-p,h),h=d,p=m)}),i.groups.length>0){const d=i.groups[i.groups.length-1],m=d.start+d.count;m!==r.materialIndex.length&&i.addGroup(m,r.materialIndex.length-m,h)}i.groups.length===0&&i.addGroup(0,r.materialIndex.length,r.materialIndex[0])}return this.addMorphTargets(i,e,s,n),i}parseGeoNode(e,t){const s={};if(s.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],s.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(s.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(s.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(s.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){s.uv=[];let n=0;for(;e.LayerElementUV[n];)e.LayerElementUV[n].UV&&s.uv.push(this.parseUVs(e.LayerElementUV[n])),n++}return s.weightTable={},t!==null&&(s.skeleton=t,t.rawBones.forEach(function(n,i){n.indices.forEach(function(o,r){s.weightTable[o]===void 0&&(s.weightTable[o]=[]),s.weightTable[o].push({id:i,weight:n.weights[r]})})})),s}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let s=0,n=0,i=!1,o=[],r=[],a=[],h=[],p=[],d=[];const m=this;return e.vertexIndices.forEach(function(f,w){let y,v=!1;f<0&&(f=f^-1,v=!0);let M=[],L=[];if(o.push(f*3,f*3+1,f*3+2),e.color){const b=pt(w,s,f,e.color);a.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(b){L.push(b.weight),M.push(b.id)}),L.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const b=[0,0,0,0],g=[0,0,0,0];L.forEach(function(S,A){let _=S,x=M[A];g.forEach(function(D,k,I){if(_>D){I[k]=_,_=D;const B=b[k];b[k]=x,x=B}})}),M=b,L=g}for(;L.length<4;)L.push(0),M.push(0);for(let b=0;b<4;++b)p.push(L[b]),d.push(M[b])}if(e.normal){const b=pt(w,s,f,e.normal);r.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(y=pt(w,s,f,e.material)[0]),e.uv&&e.uv.forEach(function(b,g){const S=pt(w,s,f,b);h[g]===void 0&&(h[g]=[]),h[g].push(S[0]),h[g].push(S[1])}),n++,v&&(m.genFace(t,e,o,y,r,a,h,p,d,n),s++,n=0,o=[],r=[],a=[],h=[],p=[],d=[])}),t}genFace(e,t,s,n,i,o,r,a,h,p){for(let d=2;d<p;d++)e.vertex.push(t.vertexPositions[s[0]]),e.vertex.push(t.vertexPositions[s[1]]),e.vertex.push(t.vertexPositions[s[2]]),e.vertex.push(t.vertexPositions[s[(d-1)*3]]),e.vertex.push(t.vertexPositions[s[(d-1)*3+1]]),e.vertex.push(t.vertexPositions[s[(d-1)*3+2]]),e.vertex.push(t.vertexPositions[s[d*3]]),e.vertex.push(t.vertexPositions[s[d*3+1]]),e.vertex.push(t.vertexPositions[s[d*3+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[(d-1)*4]),e.vertexWeights.push(a[(d-1)*4+1]),e.vertexWeights.push(a[(d-1)*4+2]),e.vertexWeights.push(a[(d-1)*4+3]),e.vertexWeights.push(a[d*4]),e.vertexWeights.push(a[d*4+1]),e.vertexWeights.push(a[d*4+2]),e.vertexWeights.push(a[d*4+3]),e.weightsIndices.push(h[0]),e.weightsIndices.push(h[1]),e.weightsIndices.push(h[2]),e.weightsIndices.push(h[3]),e.weightsIndices.push(h[(d-1)*4]),e.weightsIndices.push(h[(d-1)*4+1]),e.weightsIndices.push(h[(d-1)*4+2]),e.weightsIndices.push(h[(d-1)*4+3]),e.weightsIndices.push(h[d*4]),e.weightsIndices.push(h[d*4+1]),e.weightsIndices.push(h[d*4+2]),e.weightsIndices.push(h[d*4+3])),t.color&&(e.colors.push(o[0]),e.colors.push(o[1]),e.colors.push(o[2]),e.colors.push(o[(d-1)*3]),e.colors.push(o[(d-1)*3+1]),e.colors.push(o[(d-1)*3+2]),e.colors.push(o[d*3]),e.colors.push(o[d*3+1]),e.colors.push(o[d*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(n),e.materialIndex.push(n),e.materialIndex.push(n)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[(d-1)*3]),e.normal.push(i[(d-1)*3+1]),e.normal.push(i[(d-1)*3+2]),e.normal.push(i[d*3]),e.normal.push(i[d*3+1]),e.normal.push(i[d*3+2])),t.uv&&t.uv.forEach(function(m,f){e.uvs[f]===void 0&&(e.uvs[f]=[]),e.uvs[f].push(r[f][0]),e.uvs[f].push(r[f][1]),e.uvs[f].push(r[f][(d-1)*2]),e.uvs[f].push(r[f][(d-1)*2+1]),e.uvs[f].push(r[f][d*2]),e.uvs[f].push(r[f][d*2+1])})}addMorphTargets(e,t,s,n){if(s.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const i=this;s.forEach(function(o){o.rawTargets.forEach(function(r){const a=j.Objects.Geometry[r.geoID];a!==void 0&&i.genMorphGeometry(e,t,a,n,r.name)})})}genMorphGeometry(e,t,s,n,i){const o=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],r=s.Vertices!==void 0?s.Vertices.a:[],a=s.Indexes!==void 0?s.Indexes.a:[],h=e.attributes.position.count*3,p=new Float32Array(h);for(let w=0;w<a.length;w++){const y=a[w]*3;p[y]=r[w*3],p[y+1]=r[w*3+1],p[y+2]=r[w*3+2]}const d={vertexIndices:o,vertexPositions:p},m=this.genBuffers(d),f=new c.Float32BufferAttribute(m.vertex,3);f.name=i||s.attrName,f.applyMatrix4(n),e.morphAttributes.position.push(f)}parseNormals(e){const t=e.MappingInformationType,s=e.ReferenceInformationType,n=e.Normals.a;let i=[];return s==="IndexToDirect"&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:n,indices:i,mappingType:t,referenceType:s}}parseUVs(e){const t=e.MappingInformationType,s=e.ReferenceInformationType,n=e.UV.a;let i=[];return s==="IndexToDirect"&&(i=e.UVIndex.a),{dataSize:2,buffer:n,indices:i,mappingType:t,referenceType:s}}parseVertexColors(e){const t=e.MappingInformationType,s=e.ReferenceInformationType,n=e.Colors.a;let i=[];return s==="IndexToDirect"&&(i=e.ColorIndex.a),{dataSize:4,buffer:n,indices:i,mappingType:t,referenceType:s}}parseMaterialIndices(e){const t=e.MappingInformationType,s=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:s};const n=e.Materials.a,i=[];for(let o=0;o<n.length;++o)i.push(o);return{dataSize:1,buffer:n,indices:i,mappingType:t,referenceType:s}}parseNurbsGeometry(e){if(ws===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new c.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new c.BufferGeometry;const s=t-1,n=e.KnotVector.a,i=[],o=e.Points.a;for(let d=0,m=o.length;d<m;d+=4)i.push(new c.Vector4().fromArray(o,d));let r,a;if(e.Form==="Closed")i.push(i[0]);else if(e.Form==="Periodic"){r=s,a=n.length-1-r;for(let d=0;d<s;++d)i.push(i[d])}const p=new ws(s,n,i,r,a).getPoints(i.length*12);return new c.BufferGeometry().setFromPoints(p)}}class Mi{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const s in t){const n=t[s],i=this.addClip(n);e.push(i)}return e}parseClips(){if(j.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=j.Objects.AnimationCurveNode,t=new Map;for(const s in e){const n=e[s];if(n.attrName.match(/S|R|T|DeformPercent/)!==null){const i={id:n.id,attr:n.attrName,curves:{}};t.set(i.id,i)}}return t}parseAnimationCurves(e){const t=j.Objects.AnimationCurve;for(const s in t){const n={id:t[s].id,times:t[s].KeyTime.a.map(Ci),values:t[s].KeyValueFloat.a},i=ie.get(n.id);if(i!==void 0){const o=i.parents[0].ID,r=i.parents[0].relationship;r.match(/X/)?e.get(o).curves.x=n:r.match(/Y/)?e.get(o).curves.y=n:r.match(/Z/)?e.get(o).curves.z=n:r.match(/d|DeformPercent/)&&e.has(o)&&(e.get(o).curves.morph=n)}}}parseAnimationLayers(e){const t=j.Objects.AnimationLayer,s=new Map;for(const n in t){const i=[],o=ie.get(parseInt(n));o!==void 0&&(o.children.forEach(function(a,h){if(e.has(a.ID)){const p=e.get(a.ID);if(p.curves.x!==void 0||p.curves.y!==void 0||p.curves.z!==void 0){if(i[h]===void 0){const d=ie.get(a.ID).parents.filter(function(m){return m.relationship!==void 0})[0].ID;if(d!==void 0){const m=j.Objects.Model[d.toString()];if(m===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",a);return}const f={modelName:m.attrName?c.PropertyBinding.sanitizeNodeName(m.attrName):"",ID:m.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};de.traverse(function(w){w.ID===m.id&&(f.transform=w.matrix,w.userData.transformData&&(f.eulerOrder=w.userData.transformData.eulerOrder))}),f.transform||(f.transform=new c.Matrix4),"PreRotation"in m&&(f.preRotation=m.PreRotation.value),"PostRotation"in m&&(f.postRotation=m.PostRotation.value),i[h]=f}}i[h]&&(i[h][p.attr]=p)}else if(p.curves.morph!==void 0){if(i[h]===void 0){const d=ie.get(a.ID).parents.filter(function(M){return M.relationship!==void 0})[0].ID,m=ie.get(d).parents[0].ID,f=ie.get(m).parents[0].ID,w=ie.get(f).parents[0].ID,y=j.Objects.Model[w],v={modelName:y.attrName?c.PropertyBinding.sanitizeNodeName(y.attrName):"",morphName:j.Objects.Deformer[d].attrName};i[h]=v}i[h][p.attr]=p}}}),s.set(parseInt(n),i))}return s}parseAnimStacks(e){const t=j.Objects.AnimationStack,s={};for(const n in t){const i=ie.get(parseInt(n)).children;i.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const o=e.get(i[0].ID);s[n]={name:t[n].attrName,layer:o}}return s}addClip(e){let t=[];const s=this;return e.layer.forEach(function(n){t=t.concat(s.generateTracks(n))}),new c.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let s=new c.Vector3,n=new c.Quaternion,i=new c.Vector3;if(e.transform&&e.transform.decompose(s,n,i),s=s.toArray(),n=new c.Euler().setFromQuaternion(n,e.eulerOrder).toArray(),i=i.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.T.curves,s,"position");o!==void 0&&t.push(o)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const o=this.generateRotationTrack(e.modelName,e.R.curves,n,e.preRotation,e.postRotation,e.eulerOrder);o!==void 0&&t.push(o)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const o=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");o!==void 0&&t.push(o)}if(e.DeformPercent!==void 0){const o=this.generateMorphTrack(e);o!==void 0&&t.push(o)}return t}generateVectorTrack(e,t,s,n){const i=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(i,t,s);return new c.VectorKeyframeTrack(e+"."+n,i,o)}generateRotationTrack(e,t,s,n,i,o){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(c.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(c.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(c.MathUtils.degToRad));const r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,s);n!==void 0&&(n=n.map(c.MathUtils.degToRad),n.push(o),n=new c.Euler().fromArray(n),n=new c.Quaternion().setFromEuler(n)),i!==void 0&&(i=i.map(c.MathUtils.degToRad),i.push(o),i=new c.Euler().fromArray(i),i=new c.Quaternion().setFromEuler(i).invert());const h=new c.Quaternion,p=new c.Euler,d=[];for(let m=0;m<a.length;m+=3)p.set(a[m],a[m+1],a[m+2],o),h.setFromEuler(p),n!==void 0&&h.premultiply(n),i!==void 0&&h.multiply(i),h.toArray(d,m/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",r,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,s=t.values.map(function(i){return i/100}),n=de.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new c.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+n+"]",t.times,s)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(s,n){return s-n}),t.length>1){let s=1,n=t[0];for(let i=1;i<t.length;i++){const o=t[i];o!==n&&(t[s]=o,n=o,s++)}t=t.slice(0,s)}return t}getKeyframeTrackValues(e,t,s){const n=s,i=[];let o=-1,r=-1,a=-1;return e.forEach(function(h){if(t.x&&(o=t.x.times.indexOf(h)),t.y&&(r=t.y.times.indexOf(h)),t.z&&(a=t.z.times.indexOf(h)),o!==-1){const p=t.x.values[o];i.push(p),n[0]=p}else i.push(n[0]);if(r!==-1){const p=t.y.values[r];i.push(p),n[1]=p}else i.push(n[1]);if(a!==-1){const p=t.z.values[a];i.push(p),n[2]=p}else i.push(n[2])}),i}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const s=e.values[t-1],n=e.values[t]-s,i=Math.abs(n);if(i>=180){const o=i/180,r=n/o;let a=s+r;const h=e.times[t-1],d=(e.times[t]-h)/o;let m=h+d;const f=[],w=[];for(;m<e.times[t];)f.push(m),m+=d,w.push(a),a+=r;e.times=Ts(e.times,t,f),e.values=Ts(e.values,t,w)}}}}class bi{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new vs,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,s=e.split(/[\r\n]+/);return s.forEach(function(n,i){const o=n.match(/^[\s\t]*;/),r=n.match(/^[\s\t]*$/);if(o||r)return;const a=n.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),h=n.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),p=n.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(n,a):h?t.parseNodeProperty(n,h,s[++i]):p?t.popStack():n.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(n)}),this.allNodes}parseNodeBegin(e,t){const s=t[1].trim().replace(/^"/,"").replace(/"$/,""),n=t[2].split(",").map(function(a){return a.trim().replace(/^"/,"").replace(/"$/,"")}),i={name:s},o=this.parseNodeAttr(n),r=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(s,i):s in r?(s==="PoseNode"?r.PoseNode.push(i):r[s].id!==void 0&&(r[s]={},r[s][r[s].id]=r[s]),o.id!==""&&(r[s][o.id]=i)):typeof o.id=="number"?(r[s]={},r[s][o.id]=i):s!=="Properties70"&&(s==="PoseNode"?r[s]=[i]:r[s]=i),typeof o.id=="number"&&(i.id=o.id),o.name!==""&&(i.attrName=o.name),o.type!==""&&(i.attrType=o.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let s="",n="";return e.length>1&&(s=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:s,type:n}}parseNodeProperty(e,t,s){let n=t[1].replace(/^"/,"").replace(/"$/,"").trim(),i=t[2].replace(/^"/,"").replace(/"$/,"").trim();n==="Content"&&i===","&&(i=s.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(e,n,i);return}if(n==="C"){const a=i.split(",").slice(1),h=parseInt(a[0]),p=parseInt(a[1]);let d=i.split(",").slice(3);d=d.map(function(m){return m.trim().replace(/^"/,"")}),n="connections",i=[h,p],Pi(i,d),o[n]===void 0&&(o[n]=[])}n==="Node"&&(o.id=i),n in o&&Array.isArray(o[n])?o[n].push(i):n!=="a"?o[n]=i:o.a=i,this.setCurrentProp(o,n),n==="a"&&i.slice(-1)!==","&&(o.a=Dt(i))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Dt(t.a))}parseNodeSpecialProperty(e,t,s){const n=s.split('",').map(function(p){return p.trim().replace(/^\"/,"").replace(/\s/,"_")}),i=n[0],o=n[1],r=n[2],a=n[3];let h=n[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":h=parseFloat(h);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":h=Dt(h);break}this.getPrevNode()[i]={type:o,type2:r,flag:a,value:h},this.setCurrentProp(this.getPrevNode(),i)}}class Si{parse(e){const t=new xs(e);t.skip(23);const s=t.getUint32();if(s<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+s);const n=new vs;for(;!this.endOfContent(t);){const i=this.parseNode(t,s);i!==null&&n.add(i.name,i)}return n}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const s={},n=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const o=e.getUint8(),r=e.getString(o);if(n===0)return null;const a=[];for(let m=0;m<i;m++)a.push(this.parseProperty(e));const h=a.length>0?a[0]:"",p=a.length>1?a[1]:"",d=a.length>2?a[2]:"";for(s.singleProperty=i===1&&e.getOffset()===n;n>e.getOffset();){const m=this.parseNode(e,t);m!==null&&this.parseSubNode(r,s,m)}return s.propertyList=a,typeof h=="number"&&(s.id=h),p!==""&&(s.attrName=p),d!==""&&(s.attrType=d),r!==""&&(s.name=r),s}parseSubNode(e,t,s){if(s.singleProperty===!0){const n=s.propertyList[0];Array.isArray(n)?(t[s.name]=s,s.a=n):t[s.name]=n}else if(e==="Connections"&&s.name==="C"){const n=[];s.propertyList.forEach(function(i,o){o!==0&&n.push(i)}),t.connections===void 0&&(t.connections=[]),t.connections.push(n)}else if(s.name==="Properties70")Object.keys(s).forEach(function(i){t[i]=s[i]});else if(e==="Properties70"&&s.name==="P"){let n=s.propertyList[0],i=s.propertyList[1];const o=s.propertyList[2],r=s.propertyList[3];let a;n.indexOf("Lcl ")===0&&(n=n.replace("Lcl ","Lcl_")),i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),i==="Color"||i==="ColorRGB"||i==="Vector"||i==="Vector3D"||i.indexOf("Lcl_")===0?a=[s.propertyList[4],s.propertyList[5],s.propertyList[6]]:a=s.propertyList[4],t[n]={type:i,type2:o,flag:r,value:a}}else t[s.name]===void 0?typeof s.id=="number"?(t[s.name]={},t[s.name][s.id]=s):t[s.name]=s:s.name==="PoseNode"?(Array.isArray(t[s.name])||(t[s.name]=[t[s.name]]),t[s.name].push(s)):t[s.name][s.id]===void 0&&(t[s.name][s.id]=s)}parseProperty(e){const t=e.getString(1);let s;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return s=e.getUint32(),e.getArrayBuffer(s);case"S":return s=e.getUint32(),e.getString(s);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const n=e.getUint32(),i=e.getUint32(),o=e.getUint32();if(i===0)switch(t){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}const r=gn(new Uint8Array(e.getArrayBuffer(o))),a=new xs(r.buffer);switch(t){case"b":case"c":return a.getBooleanArray(n);case"d":return a.getFloat64Array(n);case"f":return a.getFloat32Array(n);case"i":return a.getInt32Array(n);case"l":return a.getInt64Array(n)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class xs{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let s=0;s<e;s++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let s=0;s<e;s++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let s=0;s<e;s++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let s=0;s<e;s++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let s=0;s<e;s++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let n=0;n<e;n++)t[n]=this.getUint8();const s=t.indexOf(0);return s>=0&&(t=t.slice(0,s)),c.LoaderUtils.decodeText(new Uint8Array(t))}}class vs{add(e,t){this[e]=t}}function Ti(l){const e="Kaydara FBX Binary \0";return l.byteLength>=e.length&&e===Ss(l,0,e.length)}function Li(l){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function s(n){const i=l[n-1];return l=l.slice(t+n),t++,i}for(let n=0;n<e.length;++n)if(s(1)===e[n])return!1;return!0}function As(l){const e=/FBXVersion: (\d+)/,t=l.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Ci(l){return l/46186158e3}const Oi=[];function pt(l,e,t,s){let n;switch(s.mappingType){case"ByPolygonVertex":n=l;break;case"ByPolygon":n=e;break;case"ByVertice":n=t;break;case"AllSame":n=s.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+s.mappingType)}s.referenceType==="IndexToDirect"&&(n=s.indices[n]);const i=n*s.dataSize,o=i+s.dataSize;return Di(Oi,s.buffer,i,o)}const Pt=new c.Euler,qe=new c.Vector3;function Ms(l){const e=new c.Matrix4,t=new c.Matrix4,s=new c.Matrix4,n=new c.Matrix4,i=new c.Matrix4,o=new c.Matrix4,r=new c.Matrix4,a=new c.Matrix4,h=new c.Matrix4,p=new c.Matrix4,d=new c.Matrix4,m=new c.Matrix4,f=l.inheritType?l.inheritType:0;if(l.translation&&e.setPosition(qe.fromArray(l.translation)),l.preRotation){const k=l.preRotation.map(c.MathUtils.degToRad);k.push(l.eulerOrder),t.makeRotationFromEuler(Pt.fromArray(k))}if(l.rotation){const k=l.rotation.map(c.MathUtils.degToRad);k.push(l.eulerOrder),s.makeRotationFromEuler(Pt.fromArray(k))}if(l.postRotation){const k=l.postRotation.map(c.MathUtils.degToRad);k.push(l.eulerOrder),n.makeRotationFromEuler(Pt.fromArray(k)),n.invert()}l.scale&&i.scale(qe.fromArray(l.scale)),l.scalingOffset&&r.setPosition(qe.fromArray(l.scalingOffset)),l.scalingPivot&&o.setPosition(qe.fromArray(l.scalingPivot)),l.rotationOffset&&a.setPosition(qe.fromArray(l.rotationOffset)),l.rotationPivot&&h.setPosition(qe.fromArray(l.rotationPivot)),l.parentMatrixWorld&&(d.copy(l.parentMatrix),p.copy(l.parentMatrixWorld));const w=t.clone().multiply(s).multiply(n),y=new c.Matrix4;y.extractRotation(p);const v=new c.Matrix4;v.copyPosition(p);const M=v.clone().invert().multiply(p),L=y.clone().invert().multiply(M),b=i,g=new c.Matrix4;if(f===0)g.copy(y).multiply(w).multiply(L).multiply(b);else if(f===1)g.copy(y).multiply(L).multiply(w).multiply(b);else{const I=new c.Matrix4().scale(new c.Vector3().setFromMatrixScale(d)).clone().invert(),B=L.clone().multiply(I);g.copy(y).multiply(w).multiply(B).multiply(b)}const S=h.clone().invert(),A=o.clone().invert();let _=e.clone().multiply(a).multiply(h).multiply(t).multiply(s).multiply(n).multiply(S).multiply(r).multiply(o).multiply(i).multiply(A);const x=new c.Matrix4().copyPosition(_),D=p.clone().multiply(x);return m.copyPosition(D),_=m.clone().multiply(g),_.premultiply(p.invert()),_}function bs(l){l=l||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return l===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[l]}function Dt(l){return l.split(",").map(function(t){return parseFloat(t)})}function Ss(l,e,t){return e===void 0&&(e=0),t===void 0&&(t=l.byteLength),c.LoaderUtils.decodeText(new Uint8Array(l,e,t))}function Pi(l,e){for(let t=0,s=l.length,n=e.length;t<n;t++,s++)l[s]=e[t]}function Di(l,e,t,s){for(let n=t,i=0;n<s;n++,i++)l[i]=e[n];return l}function Ts(l,e,t){return l.slice(0,e).concat(t).concat(l.slice(e))}var Ii=Object.defineProperty,ki=(l,e,t)=>e in l?Ii(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,It=(l,e,t)=>(ki(l,typeof e!="symbol"?e+"":e,t),t);class Fi extends c.Loader{constructor(e){super(e)}load(e,t,s,n){const i=new c.FileLoader(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,o=>{if(typeof o!="string")throw new Error("unsupported data type");const r=JSON.parse(o),a=this.parse(r);t&&t(a)},s,n)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new kt(e)}}class kt{constructor(e){It(this,"data"),this.data=e}generateShapes(e,t=100,s){const n=[],i={letterSpacing:0,lineHeight:1,...s},o=Bi(e,t,this.data,i);for(let r=0,a=o.length;r<a;r++)Array.prototype.push.apply(n,o[r].toShapes(!1));return n}}It(kt,"isFont"),It(kt,"type");function Bi(l,e,t,s){const n=Array.from(l),i=e/t.resolution,o=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,r=[];let a=0,h=0;for(let p=0;p<n.length;p++){const d=n[p];if(d===`
|
|
74
|
+
`)a=0,h-=o*s.lineHeight;else{const m=Ui(d,i,a,h,t);m&&(a+=m.offsetX+s.letterSpacing,r.push(m.path))}}return r}function Ui(l,e,t,s,n){const i=n.glyphs[l]||n.glyphs["?"];if(!i){console.error('THREE.Font: character "'+l+'" does not exists in font family '+n.familyName+".");return}const o=new c.ShapePath;let r,a,h,p,d,m,f,w;if(i.o){const y=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let v=0,M=y.length;v<M;)switch(y[v++]){case"m":r=parseInt(y[v++])*e+t,a=parseInt(y[v++])*e+s,o.moveTo(r,a);break;case"l":r=parseInt(y[v++])*e+t,a=parseInt(y[v++])*e+s,o.lineTo(r,a);break;case"q":h=parseInt(y[v++])*e+t,p=parseInt(y[v++])*e+s,d=parseInt(y[v++])*e+t,m=parseInt(y[v++])*e+s,o.quadraticCurveTo(d,m,h,p);break;case"b":h=parseInt(y[v++])*e+t,p=parseInt(y[v++])*e+s,d=parseInt(y[v++])*e+t,m=parseInt(y[v++])*e+s,f=parseInt(y[v++])*e+t,w=parseInt(y[v++])*e+s,o.bezierCurveTo(d,m,f,w,h,p);break}}return{offsetX:i.ha*e,path:o}}class Ni extends c.DataTextureLoader{constructor(e){super(e),this.type=c.HalfFloatType}parse(e){const r=function(b,g){switch(b){case 1:console.error("THREE.RGBELoader Read Error: "+(g||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(g||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(g||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(g||""))}return-1},d=`
|
|
75
|
+
`,m=function(b,g,S){g=g||1024;let _=b.pos,x=-1,D=0,k="",I=String.fromCharCode.apply(null,new Uint16Array(b.subarray(_,_+128)));for(;0>(x=I.indexOf(d))&&D<g&&_<b.byteLength;)k+=I,D+=I.length,_+=128,I+=String.fromCharCode.apply(null,new Uint16Array(b.subarray(_,_+128)));return-1<x?(S!==!1&&(b.pos+=D+x+1),k+I.slice(0,x)):!1},f=function(b){const g=/^#\?(\S+)/,S=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,A=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,x=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,D={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let k,I;if(b.pos>=b.byteLength||!(k=m(b)))return r(1,"no header found");if(!(I=k.match(g)))return r(3,"bad initial token");for(D.valid|=1,D.programtype=I[1],D.string+=k+`
|
|
76
|
+
`;k=m(b),k!==!1;){if(D.string+=k+`
|
|
77
77
|
`,k.charAt(0)==="#"){D.comments+=k+`
|
|
78
|
-
`;continue}if((I=k.match(
|
|
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;
|
|
78
|
+
`;continue}if((I=k.match(S))&&(D.gamma=parseFloat(I[1])),(I=k.match(A))&&(D.exposure=parseFloat(I[1])),(I=k.match(_))&&(D.valid|=2,D.format=I[1]),(I=k.match(x))&&(D.valid|=4,D.height=parseInt(I[1],10),D.width=parseInt(I[2],10)),D.valid&2&&D.valid&4)break}return D.valid&2?D.valid&4?D:r(3,"missing image size specifier"):r(3,"missing format specifier")},w=function(b,g,S){const A=g;if(A<8||A>32767||b[0]!==2||b[1]!==2||b[2]&128)return new Uint8Array(b);if(A!==(b[2]<<8|b[3]))return r(3,"wrong scanline width");const _=new Uint8Array(4*g*S);if(!_.length)return r(4,"unable to allocate buffer space");let x=0,D=0;const k=4*A,I=new Uint8Array(4),B=new Uint8Array(k);let R=S;for(;R>0&&D<b.byteLength;){if(D+4>b.byteLength)return r(1);if(I[0]=b[D++],I[1]=b[D++],I[2]=b[D++],I[3]=b[D++],I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=A)return r(3,"bad rgbe scanline format");let H=0,G;for(;H<k&&D<b.byteLength;){G=b[D++];const X=G>128;if(X&&(G-=128),G===0||H+G>k)return r(3,"bad scanline data");if(X){const le=b[D++];for(let oe=0;oe<G;oe++)B[H++]=le}else B.set(b.subarray(D,D+G),H),H+=G,D+=G}const se=A;for(let X=0;X<se;X++){let le=0;_[x]=B[X+le],le+=A,_[x+1]=B[X+le],le+=A,_[x+2]=B[X+le],le+=A,_[x+3]=B[X+le],x+=4}R--}return _},y=function(b,g,S,A){const _=b[g+3],x=Math.pow(2,_-128)/255;S[A+0]=b[g+0]*x,S[A+1]=b[g+1]*x,S[A+2]=b[g+2]*x,S[A+3]=1},v=function(b,g,S,A){const _=b[g+3],x=Math.pow(2,_-128)/255;S[A+0]=c.DataUtils.toHalfFloat(Math.min(b[g+0]*x,65504)),S[A+1]=c.DataUtils.toHalfFloat(Math.min(b[g+1]*x,65504)),S[A+2]=c.DataUtils.toHalfFloat(Math.min(b[g+2]*x,65504)),S[A+3]=c.DataUtils.toHalfFloat(1)},M=new Uint8Array(e);M.pos=0;const L=f(M);if(L!==-1){const b=L.width,g=L.height,S=w(M.subarray(M.pos),b,g);if(S!==-1){let A,_,x;switch(this.type){case c.FloatType:x=S.length/4;const D=new Float32Array(x*4);for(let I=0;I<x;I++)y(S,I*4,D,I*4);A=D,_=c.FloatType;break;case c.HalfFloatType:x=S.length/4;const k=new Uint16Array(x*4);for(let I=0;I<x;I++)v(S,I*4,k,I*4);A=k,_=c.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:b,height:g,data:A,header:L.string,gamma:L.gamma,exposure:L.exposure,type:_}}}return null}setDataType(e){return this.type=e,this}load(e,t,s,n){function i(o,r){switch(o.type){case c.FloatType:case c.HalfFloatType:"colorSpace"in o?o.colorSpace="srgb-linear":o.encoding=3e3,o.minFilter=c.LinearFilter,o.magFilter=c.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,r)}return super.load(e,i,s,n)}}const Ft=new WeakMap;class Vi extends c.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,s,n){const i=new c.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,o=>{const r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,r).then(t).catch(n)},s,n)}decodeDracoFile(e,t,s,n){const i={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(const a in t.attributeTypes){const h=t.attributeTypes[a];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[a]=h.name)}const s=JSON.stringify(t);if(Ft.has(e)){const a=Ft.get(e);if(a.key===s)return a.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const i=this.workerNextTaskID++,o=e.byteLength,r=this._getWorker(i,o).then(a=>(n=a,new Promise((h,p)=>{n._callbacks[i]={resolve:h,reject:p},n.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return r.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),Ft.set(e,{key:s,promise:r}),r}_createGeometry(e){const t=new c.BufferGeometry;e.index&&t.setIndex(new c.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s],i=n.name,o=n.array,r=n.itemSize;t.setAttribute(i,new c.BufferAttribute(o,r))}return t}_loadLibrary(e,t){const s=new c.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((n,i)=>{s.load(e,n,void 0,i)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(s=>{const n=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const i=Ei.toString(),o=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
|
|
79
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(i){const o=i.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,i){return n._taskLoad>i._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function Ei(){let l,e;onmessage=function(o){const r=o.data;switch(r.type){case"init":l=r.decoderConfig,e=new Promise(function(p){l.onModuleLoaded=function(d){p({draco:d})},DracoDecoderModule(l)});break;case"decode":const a=r.buffer,h=r.taskConfig;e.then(p=>{const d=p.draco,m=new d.Decoder,f=new d.DecoderBuffer;f.Init(new Int8Array(a),a.byteLength);try{const w=t(d,m,f,h),y=w.attributes.map(v=>v.array.buffer);w.index&&y.push(w.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:w},y)}catch(w){console.error(w),self.postMessage({type:"error",id:r.id,error:w.message})}finally{d.destroy(f),d.destroy(m)}});break}};function t(o,r,a,h){const p=h.attributeIDs,d=h.attributeTypes;let m,f;const w=r.GetEncodedGeometryType(a);if(w===o.TRIANGULAR_MESH)m=new o.Mesh,f=r.DecodeBufferToMesh(a,m);else if(w===o.POINT_CLOUD)m=new o.PointCloud,f=r.DecodeBufferToPointCloud(a,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const y={index:null,attributes:[]};for(const v in p){const M=self[d[v]];let L,b;if(h.useUniqueIDs)b=p[v],L=r.GetAttributeByUniqueId(m,b);else{if(b=r.GetAttributeId(m,o[p[v]]),b===-1)continue;L=r.GetAttribute(m,b)}y.attributes.push(n(o,r,m,v,M,L))}return w===o.TRIANGULAR_MESH&&(y.index=s(o,r,m)),o.destroy(m),y}function s(o,r,a){const p=a.num_faces()*3,d=p*4,m=o._malloc(d);r.GetTrianglesUInt32Array(a,d,m);const f=new Uint32Array(o.HEAPF32.buffer,m,p).slice();return o._free(m),{array:f,itemSize:1}}function n(o,r,a,h,p,d){const m=d.num_components(),w=a.num_points()*m,y=w*p.BYTES_PER_ELEMENT,v=i(o,p),M=o._malloc(y);r.GetAttributeDataArrayForAllPoints(a,d,v,y,M);const L=new p(o.HEAPF32.buffer,M,w).slice();return o._free(M),{name:h,array:L,itemSize:m}}function i(o,r){switch(r){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}const zi=["args","center"],Ri=u.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(l,{expose:e}){let t,s;const n=l,{center:i,font:o,text:r,needUpdates:a,size:h,height:p,curveSegments:d,bevelEnabled:m,bevelThickness:f,bevelSize:w,bevelOffset:y,bevelSegments:v}=u.toRefs(n),{extend:M}=q.useTresContext();M({TextGeometry:ys});const L=new Fi,b=u.useSlots(),g=u.computed(()=>{var x;return r!=null&&r.value?r.value:b.default?(x=b.default()[0].children)==null?void 0:x.trim():a.value?"":"TresJS"}),S=u.shallowRef();e({value:S});const A=([t,s]=u.withAsyncContext(()=>new Promise((x,D)=>{try{typeof o.value=="string"?L.load(o.value,k=>{x(k)}):x(o.value)}catch(k){D(console.error("cientos",k))}})),t=await t,s(),t),_=u.computed(()=>({font:A,size:u.toValue(h),height:u.toValue(p),curveSegments:u.toValue(d),bevelEnabled:u.toValue(m),bevelThickness:u.toValue(f),bevelSize:u.toValue(w),bevelOffset:u.toValue(y),bevelSegments:u.toValue(v)}));return u.watchEffect(()=>{S.value&&a.value&&(S.value.geometry.dispose(),S.value.geometry=new ys(g.value,_.value),i.value&&S.value.geometry.center())}),(x,D)=>u.unref(o)?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:S},[g.value?(u.openBlock(),u.createElementBlock("TresTextGeometry",{key:0,args:[g.value,_.value],center:u.unref(i)},null,8,zi)):u.createCommentVNode("",!0),u.renderSlot(x.$slots,"default")],512)):u.createCommentVNode("",!0)}});function Gi(l,e){const t=u.ref(e),s=new c.AnimationMixer(t.value),n=u.shallowReactive({});l.forEach(o=>{const r=s.clipAction(o,t.value);n[o.name]=r});const{onLoop:i}=q.useRenderLoop();return i(({delta:o})=>{s.update(o)}),{actions:n,mixer:s}}const Bt={sunset:"venice/venice_sunset_4k.hdr"};async function Ls({files:l=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],blur:e=0,background:t=!1,path:s="/",preset:n=void 0}){const{scene:i}=q.useTresContext();if(n){if(!(n in Bt))throw new Error("Preset must be one of: "+Object.keys(Bt).join(", "));l=Bt[n],s="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/"}const o=Array.isArray(l),r=o?c.CubeTextureLoader:Ni,a=await q.useLoader(r,o?[l]:l,p=>{s&&p.setPath(s)}),h=o?a[0]:a;return h&&(h.mapping=o?c.CubeReflectionMapping:c.EquirectangularReflectionMapping,h.colorSpace=c.SRGBColorSpace),i.value&&(i.value.environment=h,t&&(i.value.background=h),e&&(i.value.backgroundBlurriness=e|0)),h}const Yi=u.defineComponent({name:"Environment",props:["background","blur","files","encoding","path","preset"],async setup(l,{expose:e}){let t=null;return e({getTexture:()=>t}),t=await Ls(l),()=>{}}}),ji=["position","a-scale"],Xi=["size","size-attenuation","transparent","alpha-test","alpha-map"],Zi=u.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(l,{expose:e}){const t=l,s=u.ref(),n=u.ref(),{radius:i,depth:o,count:r,size:a,sizeAttenuation:h,transparent:p,alphaMap:d,alphaTest:m}=u.toRefs(t),f=()=>{let y=i.value+o.value;const v=u.computed(()=>o.value/r.value),M=[],L=Array.from({length:r.value},()=>(.5+.5*Math.random())*4),b=g=>new c.Vector3().setFromSpherical(new c.Spherical(g,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let g=0;g<r.value;g++)y-=v.value*Math.random(),M.push(...b(y));s.value=new Float32Array(M),n.value=new Float32Array(L)};u.watchEffect(()=>{f()});const w=u.shallowRef();return e({value:w}),(y,v)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"starsRef",ref:w},[u.createElementVNode("TresBufferGeometry",{position:[s.value,3],"a-scale":[n.value,1]},null,8,ji),u.createElementVNode("TresPointsMaterial",{size:u.unref(a),"size-attenuation":u.unref(h),transparent:u.unref(p),"alpha-test":u.unref(m),"alpha-map":u.unref(d)},null,8,Xi)],512))}}),Qi=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Ki=["position","velocity"],Wi=u.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(l){const e=l,{size:t,area:s,color:n,alphaMap:i,map:o,opacity:r,alphaTest:a,depthWrite:h,transparent:p,sizeAttenuation:d,count:m,speed:f,randomness:w}=u.toRefs(e),y=u.shallowRef();let v=[],M=[];const L=()=>{v=new Float32Array(m.value*3);for(let S=0;S<m.value;S++){const A=S*3;v[A]=(Math.random()-.5)*s.value[0],v[A+1]=(Math.random()-.5)*s.value[1],v[A+2]=(Math.random()-.5)*s.value[2]}},b=()=>{M=new Float32Array(m.value*2);for(let S=0;S<m.value*2;S+=2)M[S]=(Math.random()-.5)/5*f.value*w.value,M[S+1]=Math.random()/5*f.value+.01};b(),L(),u.watchEffect(()=>{b(),L()});const{onLoop:g}=q.useRenderLoop();return g(()=>{var S,A;if((S=y.value)!=null&&S.attributes.position.array&&((A=y.value)!=null&&A.attributes.position.count)){const _=y.value.attributes.position.array;for(let x=0;x<y.value.attributes.position.count;x++){const D=M[x*2],k=M[x*2+1];_[x*3]+=D,_[x*3+1]-=k,(_[x*3]<=-s.value[0]/2||_[x*3]>=s.value[0]/2)&&(_[x*3]=_[x*3]*-1),(_[x*3+1]<=-s.value[1]/2||_[x*3+1]>=s.value[1]/2)&&(_[x*3+1]=_[x*3+1]*-1)}y.value.attributes.position.needsUpdate=!0}}),(S,A)=>(u.openBlock(),u.createElementBlock("TresPoints",null,[u.createElementVNode("TresPointsMaterial",{size:u.unref(t),color:u.unref(n),"alpha-map":u.unref(i),map:u.unref(o),opacity:u.unref(r),"alpha-test":u.unref(a),"depth-write":u.unref(h),transparent:u.unref(p),"size-attenuation":u.unref(d)},null,8,Qi),u.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:y,position:[u.unref(v),3],velocity:[u.unref(M)]},null,8,Ki)]))}}),qi=["position"],Ji=["position"],Hi=["scale"],$i=["map","depth-test","color-space","color","opacity"],eo=u.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(l,{expose:e}){let t,s;const n=l,{width:i,depth:o,segments:r,texture:a,color:h,depthTest:p,opacity:d,speed:m}=u.toRefs(n),f=u.shallowRef(),w=u.shallowRef();e({value:f});const y=[...new Array(r)].map((A,_)=>({x:i.value/2-Math.random()*i.value,y:i.value/2-Math.random()*i.value,scale:.4+Math.sin((_+1)/r.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*m.value})),v=(A,_)=>A/6*_*d.value,{map:M}=([t,s]=u.withAsyncContext(()=>q.useTexture({map:a.value})),t=await t,s(),t),{renderer:L,camera:b}=q.useTresContext(),g=u.computed(()=>{var A;return(A=L.value)==null?void 0:A.outputColorSpace}),{onLoop:S}=q.useRenderLoop();return S(()=>{var A,_;f.value&&b.value&&w.value&&((A=w.value)==null||A.children.forEach((x,D)=>{x.rotation.z+=y[D].rotation}),f.value.lookAt((_=b.value)==null?void 0:_.position))}),(A,_)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"smokeRef",ref:f},A.$attrs),[u.createElementVNode("TresGroup",{ref_key:"groupRef",ref:w,position:[0,0,u.unref(r)/2*u.unref(o)]},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(u.unref(y),({scale:x,x:D,y:k,density:I},B)=>(u.openBlock(),u.createElementBlock("TresMesh",{key:`${B}`,position:[D,k,-B*u.unref(o)]},[u.createElementVNode("TresPlaneGeometry",{scale:[x,x,x],rotation:[0,0,0]},null,8,Hi),u.createElementVNode("TresMeshStandardMaterial",{map:u.unref(M),"depth-test":u.unref(p),"color-space":g.value,color:u.unref(h),"depth-write":!1,transparent:"",opacity:v(x,I)},null,8,$i)],8,Ji))),128))],8,qi)],16))}}),to=u.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(l,{expose:e}){const t=l,s=u.shallowRef();e({value:s});const{onLoop:n}=q.useRenderLoop(),i=u.ref(Math.random()*1e4);return n(({elapsed:o})=>{var h,p;if(!s.value)return;const r=i.value+o;s.value.rotation.x=Math.cos(r/4*t.speed)/8*t.rotationFactor,s.value.rotation.y=Math.sin(r/4*t.speed)/8*t.rotationFactor,s.value.rotation.z=Math.sin(r/4*t.speed)/20*t.rotationFactor;let a=Math.sin(r/4*t.speed)/10;a=c.MathUtils.mapLinear(a,-.1,.1,((h=t.range)==null?void 0:h[0])??-.1,((p=t.range)==null?void 0:p[1])??.1),s.value.position.y=a*t.floatFactor}),(o,r)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps(o.$attrs,{ref_key:"groupRef",ref:s}),[u.renderSlot(o.$slots,"default")],16))}}),so=["geometry"],no=["map","opacity","depth-write"],io=["args"],oo=["rotation","args"],ro=u.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(l,{expose:e}){const t=l,s=u.shallowRef(),n=u.shallowRef();e(s);let i,o,r,a,h;const{renderer:p,scene:d}=q.useTresContext(),m=u.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),f=u.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));u.watchEffect(()=>{i&&i.dispose(),o&&o.dispose(),r&&r.dispose(),a&&a.geometry.dispose(),i=new c.WebGLRenderTarget(t.resolution,t.resolution),o=new c.WebGLRenderTarget(t.resolution,t.resolution),o.texture.generateMipmaps=i.texture.generateMipmaps=!1,n.value=new c.OrthographicCamera(-m.value/2,m.value/2,f.value/2,-f.value/2,0,t.far),r=new c.PlaneGeometry(m.value,f.value).rotateX(Math.PI/2),a=new c.Mesh(r),a.visible=!1}),u.watchEffect(()=>{t.color&&(h&&h.dispose(),h=new c.MeshDepthMaterial,h.depthTest=h.depthWrite=!1,h.onBeforeCompile=S=>{S.uniforms={...S.uniforms,ucolor:{value:t.color?new c.Color(t.color):new c.Color}},S.fragmentShader=S.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
|
|
80
80
|
void main() {
|
|
81
|
-
`),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))}});/*!
|
|
81
|
+
`),S.fragmentShader=S.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const w=new c.ShaderMaterial(ui),y=new c.ShaderMaterial(pi);y.depthTest=w.depthTest=!1;function v(S){!p.value||!n.value||(a.visible=!0,a.material=w,w.uniforms.tDiffuse.value=i.texture,w.uniforms.h.value=S/256,p.value.setRenderTarget(o),p.value.render(a,n.value),a.material=y,y.uniforms.tDiffuse.value=o.texture,y.uniforms.v.value=S/256,p.value.setRenderTarget(i),p.value.render(a,n.value),a.visible=!1)}const{onLoop:M}=q.useRenderLoop();let L=0,b,g;return M(()=>{!n.value||d.value===void 0||p.value===void 0||(t.frames===1/0||L<t.frames)&&(L++,b=d.value.background,g=d.value.overrideMaterial,s.value.visible=!1,d.value.background=null,d.value.overrideMaterial=h,p.value.setRenderTarget(i),p.value.render(d.value,n.value),v(t.blur),t.smooth&&v(t.blur*.4),p.value.setRenderTarget(null),s.value.visible=!0,d.value.background=b,d.value.overrideMaterial=g)}),(S,A)=>{const _=u.resolveComponent("primitive");return u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"groupRef",ref:s},S.$attrs),[u.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:u.unref(r)},[u.createElementVNode("TresMeshBasicMaterial",{map:u.unref(i).texture,opacity:S.opacity,"depth-write":S.depthWrite,transparent:!0},null,8,no)],8,so),u.createVNode(_,{object:u.unref(a)},null,8,["object"]),n.value&&S.helper?(u.openBlock(),u.createElementBlock("TresCameraHelper",{key:0,args:[n.value]},null,8,io)):u.createCommentVNode("",!0),u.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:n,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-m.value/2,m.value/2,f.value/2,-f.value/2,0,S.far]},null,8,oo)],16)}}});function Cs(l){return u.getCurrentScope()?(u.onScopeDispose(l),!0):!1}function _e(l){return typeof l=="function"?l():u.unref(l)}const ao=typeof window<"u",ze=()=>{};function Os(l,e){function t(...s){return new Promise((n,i)=>{Promise.resolve(l(()=>e.apply(this,s),{fn:e,thisArg:this,args:s})).then(n).catch(i)})}return t}function lo(l,e={}){let t,s,n=ze;const i=r=>{clearTimeout(r),n(),n=ze};return r=>{const a=_e(l),h=_e(e.maxWait);return t&&i(t),a<=0||h!==void 0&&h<=0?(s&&(i(s),s=null),Promise.resolve(r())):new Promise((p,d)=>{n=e.rejectOnCancel?d:p,h&&!s&&(s=setTimeout(()=>{t&&i(t),s=null,p(r())},h)),t=setTimeout(()=>{s&&i(s),s=null,p(r())},a)})}}function co(l,e=!0,t=!0,s=!1){let n=0,i,o=!0,r=ze,a;const h=()=>{i&&(clearTimeout(i),i=void 0,r(),r=ze)};return d=>{const m=_e(l),f=Date.now()-n,w=()=>a=d();return h(),m<=0?(n=Date.now(),w()):(f>m&&(t||!o)?(n=Date.now(),w()):e&&(a=new Promise((y,v)=>{r=s?v:y,i=setTimeout(()=>{n=Date.now(),o=!0,y(w()),h()},Math.max(0,m-f))})),!t&&!i&&(i=setTimeout(()=>o=!0,m)),o=!1,a)}}function ho(l,e=200,t={}){return Os(lo(e,t),l)}function uo(l,e=200,t=!1,s=!0,n=!1){return Os(co(e,t,s,n),l)}function po(l,e=!0){u.getCurrentInstance()?u.onMounted(l):e?l():u.nextTick(l)}function mo(l){var e;const t=_e(l);return(e=t==null?void 0:t.$el)!=null?e:t}const Re=ao?window:void 0;function ae(...l){let e,t,s,n;if(typeof l[0]=="string"||Array.isArray(l[0])?([t,s,n]=l,e=Re):[e,t,s,n]=l,!e)return ze;Array.isArray(t)||(t=[t]),Array.isArray(s)||(s=[s]);const i=[],o=()=>{i.forEach(p=>p()),i.length=0},r=(p,d,m,f)=>(p.addEventListener(d,m,f),()=>p.removeEventListener(d,m,f)),a=u.watch(()=>[mo(e),_e(n)],([p,d])=>{o(),p&&i.push(...t.flatMap(m=>s.map(f=>r(p,m,f,d))))},{immediate:!0,flush:"post"}),h=()=>{a(),o()};return Cs(h),h}function fo(l){return typeof l=="function"?l:typeof l=="string"?e=>e.key===l:Array.isArray(l)?e=>l.includes(e.key):()=>!0}function Ge(...l){let e,t,s={};l.length===3?(e=l[0],t=l[1],s=l[2]):l.length===2?typeof l[1]=="object"?(e=!0,t=l[0],s=l[1]):(e=l[0],t=l[1]):(e=!0,t=l[0]);const{target:n=Re,eventName:i="keydown",passive:o=!1,dedupe:r=!1}=s,a=fo(e);return ae(n,i,p=>{p.repeat&&_e(r)||a(p)&&t(p)},o)}function go(){const l=u.ref(!1);return u.getCurrentInstance()&&u.onMounted(()=>{l.value=!0}),l}function yo(l){const e=go();return u.computed(()=>(e.value,!!l()))}function _o(l,e={}){const{window:t=Re}=e,s=yo(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let n;const i=u.ref(!1),o=h=>{i.value=h.matches},r=()=>{n&&("removeEventListener"in n?n.removeEventListener("change",o):n.removeListener(o))},a=u.watchEffect(()=>{s.value&&(r(),n=t.matchMedia(_e(l)),"addEventListener"in n?n.addEventListener("change",o):n.addListener(o),i.value=n.matches)});return Cs(()=>{a(),r(),n=void 0}),i}const Ps=1;function wo(l,e={}){const{throttle:t=0,idle:s=200,onStop:n=ze,onScroll:i=ze,offset:o={left:0,right:0,top:0,bottom:0},eventListenerOptions:r={capture:!1,passive:!0},behavior:a="auto",window:h=Re}=e,p=u.ref(0),d=u.ref(0),m=u.computed({get(){return p.value},set(A){w(A,void 0)}}),f=u.computed({get(){return d.value},set(A){w(void 0,A)}});function w(A,_){var x,D,k;if(!h)return;const I=_e(l);I&&((k=I instanceof Document?h.document.body:I)==null||k.scrollTo({top:(x=_e(_))!=null?x:f.value,left:(D=_e(A))!=null?D:m.value,behavior:_e(a)}))}const y=u.ref(!1),v=u.reactive({left:!0,right:!1,top:!0,bottom:!1}),M=u.reactive({left:!1,right:!1,top:!1,bottom:!1}),L=A=>{y.value&&(y.value=!1,M.left=!1,M.right=!1,M.top=!1,M.bottom=!1,n(A))},b=ho(L,t+s),g=A=>{if(!h)return;const _=A===h?A.document.documentElement:A===h.document?A.documentElement:A,{display:x,flexDirection:D}=getComputedStyle(_),k=_.scrollLeft;M.left=k<p.value,M.right=k>p.value;const I=Math.abs(k)<=0+(o.left||0),B=Math.abs(k)+_.clientWidth>=_.scrollWidth-(o.right||0)-Ps;x==="flex"&&D==="row-reverse"?(v.left=B,v.right=I):(v.left=I,v.right=B),p.value=k;let R=_.scrollTop;A===h.document&&!R&&(R=h.document.body.scrollTop),M.top=R<d.value,M.bottom=R>d.value;const H=Math.abs(R)<=0+(o.top||0),G=Math.abs(R)+_.clientHeight>=_.scrollHeight-(o.bottom||0)-Ps;x==="flex"&&D==="column-reverse"?(v.top=G,v.bottom=H):(v.top=H,v.bottom=G),d.value=R},S=A=>{if(!h)return;const _=A.target===h.document?A.target.documentElement:A.target;g(_),y.value=!0,b(A),i(A)};return ae(l,"scroll",t?uo(S,t,!0,!1):S,r),ae(l,"scrollend",L,r),{x:m,y:f,isScrolling:y,arrivedState:v,directions:M,measure(){const A=_e(l);h&&A&&g(A)}}}const xo={page:l=>[l.pageX,l.pageY],client:l=>[l.clientX,l.clientY],screen:l=>[l.screenX,l.screenY],movement:l=>l instanceof Touch?null:[l.movementX,l.movementY]};function vo(l={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:s=!1,initialValue:n={x:0,y:0},window:i=Re,target:o=i,eventFilter:r}=l,a=u.ref(n.x),h=u.ref(n.y),p=u.ref(null),d=typeof e=="function"?e:xo[e],m=M=>{const L=d(M);L&&([a.value,h.value]=L,p.value="mouse")},f=M=>{if(M.touches.length>0){const L=d(M.touches[0]);L&&([a.value,h.value]=L,p.value="touch")}},w=()=>{a.value=n.x,h.value=n.y},y=r?M=>r(()=>m(M),{}):M=>m(M),v=r?M=>r(()=>f(M),{}):M=>f(M);if(o){const M={passive:!0};ae(o,["mousemove","dragover"],y,M),t&&e!=="movement"&&(ae(o,["touchstart","touchmove"],v,M),s&&ae(o,"touchend",w,M))}return{x:a,y:h,sourceType:p}}function Ao({window:l=Re}={}){if(!l)return{x:u.ref(0),y:u.ref(0)};const e=u.ref(l.scrollX),t=u.ref(l.scrollY);return ae(l,"scroll",()=>{e.value=l.scrollX,t.value=l.scrollY},{capture:!1,passive:!0}),{x:e,y:t}}function Ds(l={}){const{window:e=Re,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:s=Number.POSITIVE_INFINITY,listenOrientation:n=!0,includeScrollbar:i=!0}=l,o=u.ref(t),r=u.ref(s),a=()=>{e&&(i?(o.value=e.innerWidth,r.value=e.innerHeight):(o.value=e.document.documentElement.clientWidth,r.value=e.document.documentElement.clientHeight))};if(a(),po(a),ae("resize",a,{passive:!0}),n){const h=_o("(orientation: portrait)");u.watch(h,()=>a())}return{width:o,height:r}}const Mo=u.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(l){const e=l,{camera:t}=q.useTresContext(),{disabled:s,factor:n,ease:i}=u.toRefs(e),{x:o,y:r}=vo(),{width:a,height:h}=Ds(),p=u.ref(),d=u.computed(()=>(o.value/a.value-.5)*n.value),m=u.computed(()=>-(r.value/h.value-.5)*n.value),{onLoop:f}=q.useRenderLoop();return f(({delta:w})=>{s.value||!p.value||(p.value.position.x+=(d.value-p.value.position.x)*i.value*w,p.value.position.y+=(m.value-p.value.position.y)*i.value*w)}),u.watch(()=>p.value,w=>{w==null||w.add(t.value)}),(w,y)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:p},null,512))}});let dt=null;function bo(l,e){return t=>{e&&e(t),l.draco&&(dt||(dt=new Vi),dt.setDecoderPath(l.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(dt))}}async function Is(l,e={draco:!1},t){return await q.useLoader(In,l,bo(e,t))}const So=u.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"}},async setup(l,{expose:e}){let t,s;const n=l,i=u.ref();e({value:i});const{scene:o}=([t,s]=u.withAsyncContext(()=>Is(n.path,{draco:n.draco,decoderPath:n.decoderPath})),t=await t,s(),t);return(r,a)=>{const h=u.resolveComponent("primitive");return u.openBlock(),u.createBlock(h,u.mergeProps({ref_key:"modelRef",ref:i,object:u.unref(o)},r.$attrs),null,16,["object"])}}});async function ks(l){return await q.useLoader(xi,l)}const To=u.defineComponent({__name:"component",props:{path:{}},async setup(l,{expose:e}){let t,s;const n=l,i=u.ref();e({value:i});const o=([t,s]=u.withAsyncContext(()=>ks(n.path)),t=await t,s(),t);return(r,a)=>{const h=u.resolveComponent("primitive");return u.openBlock(),u.createBlock(h,u.mergeProps({ref_key:"modelRef",ref:i,object:u.unref(o)},r.$attrs),null,16,["object"])}}}),Fs="[TresJS - Cientos ▲ ■ ♥] ";function Ut(){function l(s,n){console.error(`${Fs} ${s}`,n||"")}function e(s){console.warn(`${Fs} ${s}`)}function t(s,n){}return{logError:l,logWarning:e,logMessage:t}}let Nt=0;function Lo(){const l=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:s}=Ut();return new Promise(n=>{c.DefaultLoadingManager.onStart=()=>{l.value=!1},c.DefaultLoadingManager.onLoad=()=>{l.value=!0},c.DefaultLoadingManager.onProgress=(i,o,r)=>{o===r&&(Nt=r,l.value=!0,t.value.push(i)),e.value=Math.round((o-Nt)/(r-Nt)*100||100,2)},c.DefaultLoadingManager.onError=i=>{s("Error loading assets",new Error(i)),l.value=!0},n({items:t,hasFinishLoading:l,progress:e})})}async function Co(l,e){const{logError:t}=Ut();if(!l)return t("Error no path provided");const{unsuspend:s,start:n,crossOrigin:i,muted:o,loop:r,...a}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function h(){return new Promise((p,d)=>{const m=Object.assign(document.createElement("video"),{src:typeof l=="string"&&l||void 0,crossOrigin:i,loop:r,muted:o,autoplay:!0,...a}),f=new c.VideoTexture(m);return m.addEventListener(s,()=>p(f)),m.addEventListener("error",()=>d()),f})}try{const p=await h();return n&&p.image&&p.image.play(),p}catch{t("Error loading resource")}}const Oo=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","args"],Po=u.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!1},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(l,{emit:e}){const t=l,{makeDefault:s,autoRotate:n,autoRotateSpeed:i,enableDamping:o,dampingFactor:r,enablePan:a,keyPanSpeed:h,maxAzimuthAngle:p,minAzimuthAngle:d,maxPolarAngle:m,minPolarAngle:f,minDistance:w,maxDistance:y,minZoom:v,maxZoom:M,enableZoom:L,zoomSpeed:b,enableRotate:g,touches:S,rotateSpeed:A,target:_}=u.toRefs(t),{camera:x,renderer:D,extend:k,controls:I}=q.useTresContext(),B=u.ref(null);k({OrbitControls:hs}),u.watch(B,G=>{R(),G&&s.value?I.value=G:I.value=null});function R(){ae(B.value,"change",()=>e("change",B.value)),ae(B.value,"start",()=>e("start",B.value)),ae(B.value,"end",()=>e("end",B.value))}const{onLoop:H}=q.useRenderLoop();return H(()=>{B.value&&(o.value||n.value)&&B.value.update()}),u.onUnmounted(()=>{B.value&&B.value.dispose()}),(G,se)=>{var X;return u.unref(x)&&u.unref(D)?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:B,target:u.unref(_),"auto-rotate":u.unref(n),"auto-rotate-speed":u.unref(i),"enable-damping":u.unref(o),"damping-factor":u.unref(r),"enable-pan":u.unref(a),"key-pan-speed":u.unref(h),keys:G.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(d),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(f),"min-distance":u.unref(w),"max-distance":u.unref(y),"min-zoom":u.unref(v),"max-zoom":u.unref(M),touches:u.unref(S),"enable-zoom":u.unref(L),"zoom-speed":u.unref(b),"enable-rotate":u.unref(g),"rotate-speed":u.unref(A),args:[u.unref(x)||G.camera,((X=u.unref(D))==null?void 0:X.domElement)||G.domElement]},null,8,Oo)):u.createCommentVNode("",!0)}}}),Do=5,Io=6,ko=.3,Fo=u.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(l){var k;const e=l,{forward:t,back:s,left:n,right:i,jump:o,gravity:r,moveSpeed:a,headBobbing:h,is2D:p}=u.toRefs(e),{camera:d,controls:m}=q.useTresContext(),f=u.ref(0),w=u.ref(0),y=u.ref(!1),v=u.ref(!1),M=u.ref(0),L=u.shallowRef(),b=p.value?"y":"z";let g=((k=d.value.position)==null?void 0:k.y)||0;Ge(t.value,()=>{y.value=!0,w.value=a.value},{eventName:"keydown"}),Ge(s.value,()=>{y.value=!0,w.value=-a.value},{eventName:"keydown"}),Ge([...t.value,...s.value],()=>{y.value=!1,w.value=0},{eventName:"keyup"}),Ge(n.value,()=>{y.value=!0,f.value=-a.value},{eventName:"keydown"}),Ge(i.value,()=>{y.value=!0,f.value=a.value},{eventName:"keydown"}),Ge([...n.value,...i.value],()=>{y.value=!1,f.value=0},{eventName:"keyup"}),Ge(o.value,()=>{v.value||(M.value=Date.now()),v.value=!0});const S=I=>y.value?Math.sin(I*Do)*ko+g:g,A=()=>(Date.now()-M.value)/1e3*3,_=I=>g+Io*I-.5*r.value*Math.pow(I,2),x=()=>{if(v.value){const I=_(A());return I<=g&&(v.value=!1),I}return 0},{onLoop:D}=q.useRenderLoop();return D(({elapsed:I})=>{var B;m.value instanceof bt&&((B=m.value)!=null&&B.isLocked)?(m.value.moveForward(w.value),m.value.moveRight(f.value),d.value.position&&(d.value.position.y=h.value?S(I):g,d.value.position.y+=x())):L.value.children.length>0&&!(m.value instanceof bt)&&(L.value.position.x+=f.value,L.value.position[b]+=p.value?w.value:-w.value)}),(I,B)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:L},[u.renderSlot(I.$slots,"default")],512))}}),Bo=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Uo=u.defineComponent({__name:"TransformControls",props:{object:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(l,{emit:e}){const t=l,{object:s,mode:n,enabled:i,axis:o,translationSnap:r,rotationSnap:a,scaleSnap:h,space:p,size:d,showX:m,showY:f,showZ:w}=u.toRefs(t),y=u.shallowRef(),{controls:v,camera:M,renderer:L,extend:b}=q.useTresContext();b({TransformControls:vn});const g=A=>{v.value&&(v.value.enabled=!A.value),e("dragging",A.value)};function S(){ae(y.value,"change",()=>e("change")),ae(y.value,"dragging-changed",g),ae(y.value,"mouseDown",()=>e("mouseDown")),ae(y.value,"mouseUp",()=>e("mouseUp")),ae(y.value,"objectChange",()=>e("objectChange"))}return u.watchEffect(()=>{y.value&&S()}),u.onUnmounted(()=>{y.value&&y.value.dispose()}),(A,_)=>u.unref(M)&&u.unref(L)?(u.openBlock(),u.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:y,object:u.unref(s),args:[u.unref(M),u.unref(L).domElement],mode:u.unref(n),enabled:u.unref(i),axis:u.unref(o),"translation-snap":u.unref(r),"rotation-snap":u.unref(a),"scale-snap":u.unref(h),space:u.unref(p),size:u.unref(d),"show-x":u.unref(m),"show-y":u.unref(f),"show-z":u.unref(w),visible:!0},null,8,Bo)):u.createCommentVNode("",!0)}}),No=["args"],Vo=u.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock"],setup(l,{expose:e,emit:t}){const s=l,{camera:n,renderer:i,extend:o,controls:r}=q.useTresContext(),a=u.ref(null);let h;o({PointerLockControls:bt});const p=d=>{t("isLock",d)};return u.watch(a,d=>{d&&s.makeDefault?r.value=d:r.value=null;const m=document.getElementById(s.selector||"");h=m||i.value.domElement,ae(h,"click",()=>{var f,w,y;(f=r.value)==null||f.lock(),(w=r.value)==null||w.addEventListener("lock",()=>p(!0)),(y=r.value)==null||y.addEventListener("unlock",()=>p(!1))})}),u.onUnmounted(()=>{var d,m;(d=r.value)==null||d.removeEventListener("lock",()=>p(!0)),(m=r.value)==null||m.removeEventListener("unlock",()=>p(!1)),a.value&&a.value.dispose()}),e({value:r}),(d,m)=>{var f;return u.unref(n)&&u.unref(i)?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:a,args:[u.unref(n)||d.camera,((f=u.unref(i))==null?void 0:f.domElement)||d.domElement]},null,8,No)):u.createCommentVNode("",!0)}}}),Eo=["args"],zo=u.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(l){const e=l,{camera:t,renderer:s,extend:n,controls:i}=q.useTresContext(),o=u.ref(null);return n({MapControls:Dn}),u.watch(i,r=>{r&&e.makeDefault?i.value=r:i.value=null}),u.onUnmounted(()=>{o.value&&o.value.dispose()}),(r,a)=>{var h;return u.unref(t)&&u.unref(s)?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:o,args:[u.unref(t)||r.camera,((h=u.unref(s))==null?void 0:h.domElement)||r.domElement]},null,8,Eo)):u.createCommentVNode("",!0)}}}),Ro=u.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(l,{emit:e}){const t=l,{logWarning:s}=q.useLogger();t.smoothScroll<0&&s("SmoothControl must be greater than zero"),t.pages<0&&s("Pages must be greater than zero");const{camera:n,controls:i,renderer:o}=q.useTresContext(),r=u.shallowRef(),a=document.createElement("div"),{y:h}=Ao(),{x:p,y:d,isScrolling:m}=wo(a),{height:f,width:w}=Ds();let y=0;const v=u.ref(!1),M=u.ref(0),L=u.ref(0),b=u.ref(0),g=t.horizontal?"x":"y",S=u.watch(n,_=>{if(v.value){S();return}y=t.horizontal?(_==null?void 0:_.position.x)||0:(_==null?void 0:_.position.y)||0,v.value=!0},{immediate:!0});u.watch(m,_=>{i.value&&(i.value.enabled=!_)},{immediate:!0}),u.watch(h,_=>{!m.value&&!t.htmlScroll||(L.value=_/f.value/(b.value/f.value-1),M.value=-1*L.value,e("update:modelValue",L.value))}),u.watch(d,_=>{L.value=_/f.value/(b.value/f.value),M.value=-1*L.value,e("update:modelValue",L.value)}),u.watch(p,_=>{L.value=_/w.value/(b.value/w.value-1),M.value=+L.value,e("update:modelValue",L.value)}),u.watch(o,_=>{var D,k;const x=_==null?void 0:_.domElement;if(t.htmlScroll&&(_!=null&&_.domElement))x!=null&&x.style.width&&(x!=null&&x.style.position)&&(x!=null&&x.style.top)&&(x!=null&&x.style.left)&&(x.style.width="100%",x.style.position="fixed",x.style.zIndex=" -99999",x.style.top="0",x.style.left="0"),b.value=document.body.scrollHeight;else{const I=document.createElement("div"),B=document.createElement("div");a.style[t.horizontal?"overflowX":"overflowY"]="auto",a.style[t.horizontal?"overflowY":"overflowX"]="hidden",a.style.position="absolute",a.style.width="100%",a.style.height=" 100%",a.style.top="0",a.style.left="0",a.classList.add("scrollContainer"),I.style.position="sticky",I.style.top="0px",I.style.left="0px",I.style.width="100%",I.style.height="100%",I.style.overflow="hidden",a.appendChild(I),B.style.height=t.horizontal?"100%":`${f.value*t.pages}px`,B.style.width=t.horizontal?`${w.value*t.pages}px`:"100vw",B.style.pointerEvents="none",x.style.position="fixed",x.style.zIndex="0",x!=null&&x.style.width&&(x.style.width="100%"),a.appendChild(B),_.domElement.parentNode.style.position="relative",(k=(D=_==null?void 0:_.domElement)==null?void 0:D.parentNode)==null||k.appendChild(a),b.value=t.horizontal?w.value*t.pages:f.value*t.pages}},{immediate:!0});const{onLoop:A}=q.useRenderLoop();return A(()=>{var _;if((_=n.value)!=null&&_.position){const x=(M.value*t.distance-n.value.position[g]+y)*t.smoothScroll;n.value.position[g]+=x,r.value.children.length>0&&(r.value.position[g]+=x)}}),(_,x)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:r},[u.renderSlot(_.$slots,"default")],512))}});/*!
|
|
82
82
|
* camera-controls
|
|
83
83
|
* https://github.com/yomotsu/camera-controls
|
|
84
84
|
* (c) 2017 @yomotsu
|
|
85
85
|
* Released under the MIT License.
|
|
86
|
-
*/const 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=`
|
|
86
|
+
*/const V={LEFT:1,RIGHT:2,MIDDLE:4},P=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Je={NONE:0,IN:1,OUT:-1};function Ye(l){return l.isPerspectiveCamera}function Ue(l){return l.isOrthographicCamera}const He=Math.PI*2,Bs=Math.PI/2,Us=1e-5,it=Math.PI/180;function Ae(l,e,t){return Math.max(e,Math.min(t,l))}function te(l,e=Us){return Math.abs(l)<e}function J(l,e,t=Us){return te(l-e,t)}function Ns(l,e){return Math.round(l/e)*e}function ot(l){return isFinite(l)?l:l<0?-Number.MAX_VALUE:Number.MAX_VALUE}function rt(l){return Math.abs(l)<Number.MAX_VALUE?l:l*(1/0)}function mt(l,e,t,s,n=1/0,i){s=Math.max(1e-4,s);const o=2/s,r=o*i,a=1/(1+r+.48*r*r+.235*r*r*r);let h=l-e;const p=e,d=n*s;h=Ae(h,-d,d),e=l-h;const m=(t.value+o*h)*i;t.value=(t.value-o*m)*a;let f=e+(h+m)*a;return p-l>0==f>p&&(f=p,t.value=(f-p)/i),f}function Vs(l,e,t,s,n=1/0,i,o){s=Math.max(1e-4,s);const r=2/s,a=r*i,h=1/(1+a+.48*a*a+.235*a*a*a);let p=e.x,d=e.y,m=e.z,f=l.x-p,w=l.y-d,y=l.z-m;const v=p,M=d,L=m,b=n*s,g=b*b,S=f*f+w*w+y*y;if(S>g){const G=Math.sqrt(S);f=f/G*b,w=w/G*b,y=y/G*b}p=l.x-f,d=l.y-w,m=l.z-y;const A=(t.x+r*f)*i,_=(t.y+r*w)*i,x=(t.z+r*y)*i;t.x=(t.x-r*A)*h,t.y=(t.y-r*_)*h,t.z=(t.z-r*x)*h,o.x=p+(f+A)*h,o.y=d+(w+_)*h,o.z=m+(y+x)*h;const D=v-l.x,k=M-l.y,I=L-l.z,B=o.x-v,R=o.y-M,H=o.z-L;return D*B+k*R+I*H>0&&(o.x=v,o.y=M,o.z=L,t.x=(o.x-v)/i,t.y=(o.y-M)/i,t.z=(o.z-L)/i),o}function Vt(l,e){e.set(0,0),l.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=l.length,e.y/=l.length}function Et(l,e){return Ue(l)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Go{constructor(){this._listeners={}}addEventListener(e,t){const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners[e];if(n!==void 0){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const s=this._listeners[e.type];if(s!==void 0){e.target=this;const n=s.slice(0);for(let i=0,o=n.length;i<o;i++)n[i].call(this,e)}}}const Yo="2.7.1",ft=1/8,Es=typeof window<"u",jo=Es&&/Mac/.test(navigator.platform),Xo=!(Es&&"PointerEvent"in window);let N,zs,gt,zt,me,Y,W,$e,at,Te,Le,je,Rs,Gs,we,lt,et,Ys,Rt,js,Gt,Yt,yt;class ct extends Go{static install(e){N=e.THREE,zs=Object.freeze(new N.Vector3(0,0,0)),gt=Object.freeze(new N.Vector3(0,1,0)),zt=Object.freeze(new N.Vector3(0,0,1)),me=new N.Vector2,Y=new N.Vector3,W=new N.Vector3,$e=new N.Vector3,at=new N.Vector3,Te=new N.Vector3,Le=new N.Vector3,je=new N.Vector3,Rs=new N.Vector3,Gs=new N.Vector3,we=new N.Spherical,lt=new N.Spherical,et=new N.Box3,Ys=new N.Box3,Rt=new N.Sphere,js=new N.Quaternion,Gt=new N.Quaternion,Yt=new N.Matrix4,yt=new N.Raycaster}static get ACTION(){return P}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=P.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Je.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new N.Vector3,this._focalOffsetVelocity=new N.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,S,A)=>{let _,x;if(Ye(this._camera)){const D=Y.copy(this._camera.position).sub(this._target),k=this._camera.getEffectiveFOV()*it,I=D.length()*Math.tan(k*.5);_=this.truckSpeed*g*I/this._elementRect.height,x=this.truckSpeed*S*I/this._elementRect.height}else if(Ue(this._camera)){const D=this._camera;_=g*(D.right-D.left)/D.zoom/this._elementRect.width,x=S*(D.top-D.bottom)/D.zoom/this._elementRect.height}else return;this.verticalDragToForward?(A?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(_,0,!0),this.forward(-x,!0)):A?this.setFocalOffset(this._focalOffsetEnd.x+_,this._focalOffsetEnd.y+x,this._focalOffsetEnd.z,!0):this.truck(_,x,!0)},this._rotateInternal=(g,S)=>{const A=He*this.azimuthRotateSpeed*g/this._elementRect.height,_=He*this.polarRotateSpeed*S/this._elementRect.height;this.rotate(A,_,!0)},this._dollyInternal=(g,S,A)=>{const _=Math.pow(.95,-g*this.dollySpeed),x=this._sphericalEnd.radius,D=this._sphericalEnd.radius*_,k=Ae(D,this.minDistance,this.maxDistance),I=k-D;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(D,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(I,!0),this._dollyToNoClamp(k,!0)):this._dollyToNoClamp(k,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?D:k)-x,this._dollyControlCoord.set(S,A)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,S,A)=>{const _=Math.pow(.95,g*this.dollySpeed),x=this._zoom,D=this._zoom*_;this.zoomTo(D,!0),this.dollyToCursor&&(this._changedZoom+=D-x,this._dollyControlCoord.set(S,A))},typeof N>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new N.Quaternion().setFromUnitVectors(this._camera.up,gt),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=P.NONE,this._target=new N.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new N.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new N.Spherical().setFromVector3(Y.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new N.Vector3,new N.Vector3,new N.Vector3,new N.Vector3],this._updateNearPlaneCorners(),this._boundary=new N.Box3(new N.Vector3(-1/0,-1/0,-1/0),new N.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new N.Vector2,this.mouseButtons={left:P.ROTATE,middle:P.DOLLY,right:P.TRUCK,wheel:Ye(this._camera)?P.DOLLY:Ue(this._camera)?P.ZOOM:P.NONE},this.touches={one:P.TOUCH_ROTATE,two:Ye(this._camera)?P.TOUCH_DOLLY_TRUCK:Ue(this._camera)?P.TOUCH_ZOOM_TRUCK:P.NONE,three:P.TOUCH_TRUCK};const s=new N.Vector2,n=new N.Vector2,i=new N.Vector2,o=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const _=this._domElement.getBoundingClientRect(),x=g.clientX/_.width,D=g.clientY/_.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const S=g.pointerType!=="mouse"?null:(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(g.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(S!==null){const _=this._findPointerByMouseButton(S);_&&this._disposePointer(_)}if((g.buttons&V.LEFT)===V.LEFT&&this._lockedPointer)return;const A={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:S};this._activePointers.push(A),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",p),this._isDragging=!0,y(g)},r=g=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const _=this._domElement.getBoundingClientRect(),x=g.clientX/_.width,D=g.clientY/_.height;if(x<this._interactiveArea.left||x>this._interactiveArea.right||D<this._interactiveArea.top||D>this._interactiveArea.bottom)return}const S=(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.MIDDLE?V.MIDDLE:(g.buttons&V.RIGHT)===V.RIGHT?V.RIGHT:null;if(S!==null){const _=this._findPointerByMouseButton(S);_&&this._disposePointer(_)}const A={pointerId:1,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:(g.buttons&V.LEFT)===V.LEFT?V.LEFT:(g.buttons&V.MIDDLE)===V.LEFT?V.MIDDLE:(g.buttons&V.RIGHT)===V.LEFT?V.RIGHT:null};this._activePointers.push(A),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.addEventListener("mousemove",h),this._domElement.ownerDocument.addEventListener("mouseup",d),this._isDragging=!0,y(g)},a=g=>{g.cancelable&&g.preventDefault();const S=g.pointerId,A=this._lockedPointer||this._findPointerById(S);if(A){if(A.clientX=g.clientX,A.clientY=g.clientY,A.deltaX=g.movementX,A.deltaY=g.movementY,this._state=0,g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(g.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);v()}},h=g=>{const S=this._lockedPointer||this._findPointerById(1);S&&(S.clientX=g.clientX,S.clientY=g.clientY,S.deltaX=g.movementX,S.deltaY=g.movementY,this._state=0,(this._lockedPointer||(g.buttons&V.LEFT)===V.LEFT)&&(this._state=this._state|this.mouseButtons.left),(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right),v())},p=g=>{const S=this._findPointerById(g.pointerId);if(!(S&&S===this._lockedPointer)){if(S&&this._disposePointer(S),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=P.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=P.NONE;M()}},d=()=>{const g=this._findPointerById(1);g&&g===this._lockedPointer||(g&&this._disposePointer(g),this._state=P.NONE,M())};let m=-1;const f=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===P.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const D=this._domElement.getBoundingClientRect(),k=g.clientX/D.width,I=g.clientY/D.height;if(k<this._interactiveArea.left||k>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===P.ROTATE||this.mouseButtons.wheel===P.TRUCK){const D=performance.now();m-D<1e3&&this._getClientRect(this._elementRect),m=D}const S=jo?-1:-3,A=g.deltaMode===1?g.deltaY/S:g.deltaY/(S*10),_=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case P.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case P.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case P.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case P.DOLLY:{this._dollyInternal(-A,_,x),this._isUserControllingDolly=!0;break}case P.ZOOM:{this._zoomInternal(-A,_,x),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},w=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===ct.ACTION.NONE){const S=g instanceof PointerEvent?g.pointerId:(g instanceof MouseEvent,0),A=this._findPointerById(S);A&&this._disposePointer(A),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("mouseup",d);return}g.preventDefault()}},y=g=>{if(!this._enabled)return;if(Vt(this._activePointers,me),this._getClientRect(this._elementRect),s.copy(me),n.copy(me),this._activePointers.length>=2){const A=me.x-this._activePointers[1].clientX,_=me.y-this._activePointers[1].clientY,x=Math.sqrt(A*A+_*_);i.set(0,x);const D=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,k=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;n.set(D,k)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(g.buttons&V.LEFT)===V.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&V.MIDDLE)===V.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&V.RIGHT)===V.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&P.ROTATE)===P.ROTATE||(this._state&P.TOUCH_ROTATE)===P.TOUCH_ROTATE||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&P.TRUCK)===P.TRUCK||(this._state&P.TOUCH_TRUCK)===P.TOUCH_TRUCK||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&P.DOLLY)===P.DOLLY||(this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&P.ZOOM)===P.ZOOM||(this._state&P.TOUCH_ZOOM)===P.TOUCH_ZOOM||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&P.OFFSET)===P.OFFSET||(this._state&P.TOUCH_OFFSET)===P.TOUCH_OFFSET||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},v=()=>{if(!this._enabled)return;Vt(this._activePointers,me);const S=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,A=S?-S.deltaX:n.x-me.x,_=S?-S.deltaY:n.y-me.y;if(n.copy(me),((this._state&P.ROTATE)===P.ROTATE||(this._state&P.TOUCH_ROTATE)===P.TOUCH_ROTATE||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(A,_),this._isUserControllingRotate=!0),(this._state&P.DOLLY)===P.DOLLY||(this._state&P.ZOOM)===P.ZOOM){const x=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,D=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0,k=this.dollyDragInverted?-1:1;(this._state&P.DOLLY)===P.DOLLY?(this._dollyInternal(k*_*ft,x,D),this._isUserControllingDolly=!0):(this._zoomInternal(k*_*ft,x,D),this._isUserControllingZoom=!0)}if((this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_ZOOM)===P.TOUCH_ZOOM||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_ZOOM_ROTATE)===P.TOUCH_ZOOM_ROTATE){const x=me.x-this._activePointers[1].clientX,D=me.y-this._activePointers[1].clientY,k=Math.sqrt(x*x+D*D),I=i.y-k;i.set(0,k);const B=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,R=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&P.TOUCH_DOLLY)===P.TOUCH_DOLLY||(this._state&P.TOUCH_DOLLY_ROTATE)===P.TOUCH_DOLLY_ROTATE||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET?(this._dollyInternal(I*ft,B,R),this._isUserControllingDolly=!0):(this._zoomInternal(I*ft,B,R),this._isUserControllingZoom=!0)}((this._state&P.TRUCK)===P.TRUCK||(this._state&P.TOUCH_TRUCK)===P.TOUCH_TRUCK||(this._state&P.TOUCH_DOLLY_TRUCK)===P.TOUCH_DOLLY_TRUCK||(this._state&P.TOUCH_ZOOM_TRUCK)===P.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(A,_,!1),this._isUserControllingTruck=!0),((this._state&P.OFFSET)===P.OFFSET||(this._state&P.TOUCH_OFFSET)===P.TOUCH_OFFSET||(this._state&P.TOUCH_DOLLY_OFFSET)===P.TOUCH_DOLLY_OFFSET||(this._state&P.TOUCH_ZOOM_OFFSET)===P.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(A,_,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},M=()=>{Vt(this._activePointers,me),n.copy(me),(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.ownerDocument.removeEventListener("mouseup",d),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",L),this._domElement.ownerDocument.addEventListener("pointerlockerror",b),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",p),y())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",L),this._domElement.ownerDocument.removeEventListener("pointerlockerror",b))};const L=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},b=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),Xo&&this._domElement.addEventListener("mousedown",r),this._domElement.addEventListener("pointercancel",p),this._domElement.addEventListener("wheel",f,{passive:!1}),this._domElement.addEventListener("contextmenu",w)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("mousedown",r),this._domElement.removeEventListener("pointercancel",p),this._domElement.removeEventListener("wheel",f,{passive:!1}),this._domElement.removeEventListener("contextmenu",w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",h),this._domElement.ownerDocument.removeEventListener("pointerup",p),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.removeEventListener("pointerlockchange",L),this._domElement.ownerDocument.removeEventListener("pointerlockerror",b))},this.cancel=()=>{this._state!==P.NONE&&(this._state=P.NONE,this._activePointers.length=0,M())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Ae(e.width,0,1),this._interactiveArea.height=Ae(e.height,0,1),this._interactiveArea.x=Ae(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ae(e.x,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,s=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,s)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,s=!1){this._isUserControllingRotate=!1;const n=Ae(e,this.minAzimuthAngle,this.maxAzimuthAngle),i=Ae(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=i,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,s||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!s||J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Je.NONE,this._changedDolly=0,this._dollyToNoClamp(Ae(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const s=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),r=J(o,this._spherical.radius);if(!(s>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const i=!t||J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(i)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(at).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const s=!t||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Ae(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const s=!t||J(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(s)}pan(e,t,s=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,s)}truck(e,t,s=!1){this._camera.updateMatrix(),Te.setFromMatrixColumn(this._camera.matrix,0),Le.setFromMatrixColumn(this._camera.matrix,1),Te.multiplyScalar(e),Le.multiplyScalar(-t);const n=Y.copy(Te).add(Le),i=W.copy(this._targetEnd).add(n);return this.moveTo(i.x,i.y,i.z,s)}forward(e,t=!1){Y.setFromMatrixColumn(this._camera.matrix,0),Y.crossVectors(this._camera.up,Y),Y.multiplyScalar(e);const s=W.copy(this._targetEnd).add(Y);return this.moveTo(s.x,s.y,s.z,t)}elevate(e,t=!1){return Y.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+Y.x,this._targetEnd.y+Y.y,this._targetEnd.z+Y.z,t)}moveTo(e,t,s,n=!1){this._isUserControllingTruck=!1;const i=Y.set(e,t,s).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,i,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);const o=!n||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,s,n=!1){const r=Y.set(e,t,s).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,n)}fitToBox(e,t,{cover:s=!1,paddingLeft:n=0,paddingRight:i=0,paddingBottom:o=0,paddingTop:r=0}={}){const a=[],h=e.isBox3?et.copy(e):et.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=Ns(this._sphericalEnd.theta,Bs),d=Ns(this._sphericalEnd.phi,Bs);a.push(this.rotateTo(p,d,t));const m=Y.setFromSpherical(this._sphericalEnd).normalize(),f=js.setFromUnitVectors(m,zt),w=J(Math.abs(m.y),1);w&&f.multiply(Gt.setFromAxisAngle(gt,p)),f.multiply(this._yAxisUpSpaceInverse);const y=Ys.makeEmpty();W.copy(h.min).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setX(h.max.x).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setY(h.max.y).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setZ(h.min.z).applyQuaternion(f),y.expandByPoint(W),W.copy(h.min).setZ(h.max.z).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setY(h.min.y).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).setX(h.min.x).applyQuaternion(f),y.expandByPoint(W),W.copy(h.max).applyQuaternion(f),y.expandByPoint(W),y.min.x-=n,y.min.y-=o,y.max.x+=i,y.max.y+=r,f.setFromUnitVectors(zt,m),w&&f.premultiply(Gt.invert()),f.premultiply(this._yAxisUpSpace);const v=y.getSize(Y),M=y.getCenter(W).applyQuaternion(f);if(Ye(this._camera)){const L=this.getDistanceToFitBox(v.x,v.y,v.z,s);a.push(this.moveTo(M.x,M.y,M.z,t)),a.push(this.dollyTo(L,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(Ue(this._camera)){const L=this._camera,b=L.right-L.left,g=L.top-L.bottom,S=s?Math.max(b/v.x,g/v.y):Math.min(b/v.x,g/v.y);a.push(this.moveTo(M.x,M.y,M.z,t)),a.push(this.zoomTo(S,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const s=[],i=e instanceof N.Sphere?Rt.copy(e):ct.createBoundingSphere(e,Rt);if(s.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),Ye(this._camera)){const o=this.getDistanceToFitSphere(i.radius);s.push(this.dollyTo(o,t))}else if(Ue(this._camera)){const o=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*i.radius,h=Math.min(o/a,r/a);s.push(this.zoomTo(h,t))}return s.push(this.setFocalOffset(0,0,0,t)),Promise.all(s)}setLookAt(e,t,s,n,i,o,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Je.NONE,this._changedDolly=0;const a=W.set(n,i,o),h=Y.set(e,t,s);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(h.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!r||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold)&&J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,s,n,i,o,r,a,h,p,d,m,f,w=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Je.NONE,this._changedDolly=0;const y=Y.set(n,i,o),v=W.set(e,t,s);we.setFromVector3(v.sub(y).applyQuaternion(this._yAxisUpSpace));const M=$e.set(p,d,m),L=W.set(r,a,h);lt.setFromVector3(L.sub(M).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(M,f));const b=lt.theta-we.theta,g=lt.phi-we.phi,S=lt.radius-we.radius;this._sphericalEnd.set(we.radius+S*f,we.phi+g*f,we.theta+b*f),this.normalizeRotations(),this._needsUpdate=!0,w||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const A=!w||J(this._target.x,this._targetEnd.x,this.restThreshold)&&J(this._target.y,this._targetEnd.y,this.restThreshold)&&J(this._target.z,this._targetEnd.z,this.restThreshold)&&J(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&J(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&J(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(A)}setPosition(e,t,s,n=!1){return this.setLookAt(e,t,s,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,n)}setTarget(e,t,s,n=!1){const i=this.getPosition(Y),o=this.setLookAt(i.x,i.y,i.z,e,t,s,n);return this._sphericalEnd.phi=Ae(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,s,n=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,s),this._needsUpdate=!0,n||this._focalOffset.copy(this._focalOffsetEnd);const i=!n||J(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&J(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&J(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}setOrbitPoint(e,t,s){this._camera.updateMatrixWorld(),Te.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Le.setFromMatrixColumn(this._camera.matrixWorldInverse,1),je.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const n=Y.set(e,t,s),i=n.distanceTo(this._camera.position),o=n.sub(this._camera.position);Te.multiplyScalar(o.x),Le.multiplyScalar(o.y),je.multiplyScalar(o.z),Y.copy(Te).add(Le).add(je),Y.z=Y.z+i,this.dollyTo(i,!1),this.setFocalOffset(-Y.x,Y.y,-Y.z,!1),this.moveTo(e,t,s,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,s,n){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new N.Vector4,typeof e=="number"?this._viewport.set(e,t,s,n):this._viewport.copy(e)}getDistanceToFitBox(e,t,s,n=!1){if(Et(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const i=e/t,o=this._camera.getEffectiveFOV()*it,r=this._camera.aspect;return((n?i>r:i<r)?t:e/r)*.5/Math.tan(o*.5)+s*.5}getDistanceToFitSphere(e){if(Et(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*it,s=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,n=1<this._camera.aspect?t:s;return e/Math.sin(n*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new N.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new N.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof N.Spherical?e:new N.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new N.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%He,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=He),this._spherical.theta+=He*Math.round((this._sphericalEnd.theta-this._spherical.theta)/He)}reset(e=!1){if(!J(this._camera.up.x,this._cameraUp0.x)||!J(this._camera.up.y,this._cameraUp0.y)||!J(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const s=this.getPosition(Y);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,gt),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=Y.subVectors(this._target,this._camera.position).normalize(),t=W.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const s=this.getPosition(Y);this.updateCameraUp(),this.setPosition(s.x,s.y,s.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,s=this._sphericalEnd.phi-this._spherical.phi,n=this._sphericalEnd.radius-this._spherical.radius,i=Rs.subVectors(this._targetEnd,this._target),o=Gs.subVectors(this._focalOffsetEnd,this._focalOffset),r=this._zoomEnd-this._zoom;if(te(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=mt(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,d,1/0,e),this._needsUpdate=!0}if(te(s))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=mt(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,d,1/0,e),this._needsUpdate=!0}if(te(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const d=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=mt(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,d,this.maxSpeed,e),this._needsUpdate=!0}if(te(i.x)&&te(i.y)&&te(i.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const d=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Vs(this._target,this._targetEnd,this._targetVelocity,d,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(te(o.x)&&te(o.y)&&te(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const d=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Vs(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,d,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(te(r))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const d=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=mt(this._zoom,this._zoomEnd,this._zoomVelocity,d,1/0,e)}if(this.dollyToCursor){if(Ye(this._camera)&&this._changedDolly!==0){const d=this._spherical.radius-this._lastDistance,m=this._camera,f=this._getCameraDirection(at),w=Y.copy(f).cross(m.up).normalize();w.lengthSq()===0&&(w.x=1);const y=W.crossVectors(w,f),v=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*it*.5),L=(this._sphericalEnd.radius-d-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=$e.copy(this._targetEnd).add(w.multiplyScalar(this._dollyControlCoord.x*v*m.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*v)),g=Y.copy(this._targetEnd).lerp(b,L),S=this._lastDollyDirection===Je.IN&&this._spherical.radius<=this.minDistance,A=this._lastDollyDirection===Je.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(S||A)){this._sphericalEnd.radius-=d,this._spherical.radius-=d;const x=W.copy(f).multiplyScalar(-d);g.add(x)}this._boundary.clampPoint(g,g);const _=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(_),this._changedDolly-=d,te(this._changedDolly)&&(this._changedDolly=0)}else if(Ue(this._camera)&&this._changedZoom!==0){const d=this._zoom-this._lastZoom,m=this._camera,f=Y.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),w=W.set(0,0,-1).applyQuaternion(m.quaternion),y=$e.copy(f).add(w.multiplyScalar(-f.dot(m.up))),M=-(this._zoom-d-this._zoom)/this._zoom,L=this._getCameraDirection(at),b=this._targetEnd.dot(L),g=Y.copy(this._targetEnd).lerp(y,M),S=g.dot(L),A=L.multiplyScalar(S-b);g.sub(A),this._boundary.clampPoint(g,g);const _=W.subVectors(g,this._targetEnd);this._targetEnd.copy(g),this._target.add(_),this._changedZoom-=d,te(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0);const a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!te(this._focalOffset.x)||!te(this._focalOffset.y)||!te(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Te.setFromMatrixColumn(this._camera.matrix,0),Le.setFromMatrixColumn(this._camera.matrix,1),je.setFromMatrixColumn(this._camera.matrix,2),Te.multiplyScalar(this._focalOffset.x),Le.multiplyScalar(-this._focalOffset.y),je.multiplyScalar(this._focalOffset.z),Y.copy(Te).add(Le).add(je),this._camera.position.add(Y)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Y.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),te(t,this.restThreshold)&&te(s,this.restThreshold)&&te(n,this.restThreshold)&&te(i.x,this.restThreshold)&&te(i.y,this.restThreshold)&&te(i.z,this.restThreshold)&&te(o.x,this.restThreshold)&&te(o.y,this.restThreshold)&&te(o.z,this.restThreshold)&&te(r,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ot(this.maxDistance),minZoom:this.minZoom,maxZoom:ot(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ot(this.maxPolarAngle),minAzimuthAngle:ot(this.minAzimuthAngle),maxAzimuthAngle:ot(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:Y.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const s=JSON.parse(e);this.enabled=s.enabled,this.minDistance=s.minDistance,this.maxDistance=rt(s.maxDistance),this.minZoom=s.minZoom,this.maxZoom=rt(s.maxZoom),this.minPolarAngle=s.minPolarAngle,this.maxPolarAngle=rt(s.maxPolarAngle),this.minAzimuthAngle=rt(s.minAzimuthAngle),this.maxAzimuthAngle=rt(s.maxAzimuthAngle),this.smoothTime=s.smoothTime,this.draggingSmoothTime=s.draggingSmoothTime,this.dollySpeed=s.dollySpeed,this.truckSpeed=s.truckSpeed,this.dollyToCursor=s.dollyToCursor,this.verticalDragToForward=s.verticalDragToForward,this._target0.fromArray(s.target0),this._position0.fromArray(s.position0),this._zoom0=s.zoom0,this._focalOffset0.fromArray(s.focalOffset0),this.moveTo(s.target[0],s.target[1],s.target[2],t),we.setFromVector3(Y.fromArray(s.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(we.theta,we.phi,t),this.dollyTo(we.radius,t),this.zoomTo(s.zoom,t),this.setFocalOffset(s.focalOffset[0],s.focalOffset[1],s.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",Yo),this._addAllEventListeners(e)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,s){const n=t.lengthSq();if(n===0)return e;const i=W.copy(t).add(e),r=this._boundary.clampPoint(i,$e).sub(i),a=r.lengthSq();if(a===0)return e.add(t);if(a===n)return e;if(s===0)return e.add(t).add(r);{const h=1+s*a/t.dot(r);return e.add(W.copy(t).multiplyScalar(h)).add(r.multiplyScalar(1-s))}}_updateNearPlaneCorners(){if(Ye(this._camera)){const e=this._camera,t=e.near,s=e.getEffectiveFOV()*it,n=Math.tan(s*.5)*t,i=n*e.aspect;this._nearPlaneCorners[0].set(-i,-n,0),this._nearPlaneCorners[1].set(i,-n,0),this._nearPlaneCorners[2].set(i,n,0),this._nearPlaneCorners[3].set(-i,n,0)}else if(Ue(this._camera)){const e=this._camera,t=1/e.zoom,s=e.left*t,n=e.right*t,i=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(s,i,0),this._nearPlaneCorners[1].set(n,i,0),this._nearPlaneCorners[2].set(n,o,0),this._nearPlaneCorners[3].set(s,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Et(this._camera,"_collisionTest"))return e;const s=this._getTargetDirection(at);Yt.lookAt(zs,s,this._camera.up);for(let n=0;n<4;n++){const i=W.copy(this._nearPlaneCorners[n]);i.applyMatrix4(Yt);const o=$e.addVectors(this._target,i);yt.set(o,s),yt.far=this._spherical.radius+1;const r=yt.intersectObjects(this.colliderMeshes);r.length!==0&&r[0].distance<e&&(e=r[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const s=()=>{this.removeEventListener("rest",s),t()};this.addEventListener("rest",s)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new N.Sphere){const s=t,n=s.center;et.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&et.expandByObject(o)}),et.getCenter(n);let i=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const r=o,a=r.geometry.clone();a.applyMatrix4(r.matrixWorld);const p=a.attributes.position;for(let d=0,m=p.count;d<m;d++)Y.fromBufferAttribute(p,d),i=Math.max(i,n.distanceToSquared(Y))}),s.radius=Math.sqrt(i),s}}const Zo=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args"],Qo=u.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},minDistance:{default:Number.EPSILON},maxDistance:{default:1/0},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:1/0},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:1/0},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{},touches:{}},emits:["change","start","end"],setup(l,{expose:e,emit:t}){const s=l,{makeDefault:n,minPolarAngle:i,maxPolarAngle:o,minAzimuthAngle:r,maxAzimuthAngle:a,minDistance:h,maxDistance:p,infinityDolly:d,minZoom:m,maxZoom:f,smoothTime:w,draggingSmoothTime:y,maxSpeed:v,azimuthRotateSpeed:M,polarRotateSpeed:L,dollySpeed:b,dollyDragInverted:g,truckSpeed:S,dollyToCursor:A,dragToOffset:_,verticalDragToForward:x,boundaryFriction:D,restThreshold:k,colliderMeshes:I}=u.toRefs(s),B={Box3:c.Box3,MathUtils:{clamp:c.MathUtils.clamp},Matrix4:c.Matrix4,Quaternion:c.Quaternion,Raycaster:c.Raycaster,Sphere:c.Sphere,Spherical:c.Spherical,Vector2:c.Vector2,Vector3:c.Vector3,Vector4:c.Vector4};ct.install({THREE:B});const{camera:R,renderer:H,extend:G,controls:se}=q.useTresContext(),X=u.ref(null);G({CameraControls:ct}),u.watchEffect(()=>{le(),X.value&&n.value?se.value=X.value:se.value=null});function le(){ae(X.value,"update",()=>t("change",X.value)),ae(X.value,"controlend",()=>t("end",X.value)),ae(X.value,"controlstart",()=>t("start",X.value))}const{onLoop:oe}=q.useRenderLoop();return oe(({delta:$})=>{var Q,K;(Q=X.value)!=null&&Q.enabled&&((K=X.value)==null||K.update($))}),u.onUnmounted(()=>{X.value&&X.value.disconnect()}),e({value:X}),($,Q)=>{var K;return u.unref(R)&&u.unref(H)?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:X,"min-polar-angle":u.unref(i),"max-polar-angle":u.unref(o),"min-azimuth-angle":u.unref(r),"max-azimuth-angle":u.unref(a),"min-distance":u.unref(h),"max-distance":u.unref(p),"infinity-dolly":u.unref(d),"min-zoom":u.unref(m),"max-zoom":u.unref(f),"smooth-time":u.unref(w),"dragging-smooth-time":u.unref(y),"max-speed":u.unref(v),"azimuth-rotate-speed":u.unref(M),"polar-rotate-speed":u.unref(L),"dolly-speed":u.unref(b),"dolly-drag-inverted":u.unref(g),"truck-speed":u.unref(S),"dolly-to-cursor":u.unref(A),"drag-to-offset":u.unref(_),"vertical-drag-to-forward":u.unref(x),"boundary-friction":u.unref(D),"rest-threshold":u.unref(k),"collider-meshes":u.unref(I),args:[u.unref(R)||$.camera,((K=u.unref(H))==null?void 0:K.domElement)||$.domElement]},null,8,Zo)):u.createCommentVNode("",!0)}}});class Ko extends c.MeshStandardMaterial{constructor(t={}){super(t);re(this,"_time");re(this,"_factor");this.setValues(t),this._time={value:0},this._factor={value:1}}onBeforeCompile(t){t.uniforms||(t.uniforms={}),t.uniforms.time=this._time,t.uniforms.factor=this._factor,t.vertexShader=`
|
|
87
87
|
uniform float time;
|
|
88
88
|
uniform float factor;
|
|
89
89
|
${t.vertexShader}
|
|
@@ -92,4 +92,4 @@
|
|
|
92
92
|
float s = sin( theta );
|
|
93
93
|
mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );
|
|
94
94
|
vec3 transformed = vec3( position ) * m;
|
|
95
|
-
vNormal = vNormal * m;`)}get time(){return this._time.value}set time(t){this._time.value=t}get factor(){return this._factor.value}set factor(t){this._factor.value=t}}const 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"})});
|
|
95
|
+
vNormal = vNormal * m;`)}get time(){return this._time.value}set time(t){this._time.value=t}get factor(){return this._factor.value}set factor(t){this._factor.value=t}}const Wo=["factor"],qo=u.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(l){const e=l,t=u.shallowRef(),{extend:s}=q.useTresContext();s({MeshWobbleMaterial:Ko});const{onLoop:n}=q.useRenderLoop();return n(({elapsed:i})=>{t.value&&(t.value.time=i*(e==null?void 0:e.speed))}),(i,o)=>(u.openBlock(),u.createElementBlock("TresMeshWobbleMaterial",u.mergeProps({ref_key:"materialRef",ref:t,factor:i.factor},i.$attrs),null,16,Wo))}});function Xe(l,e,t){return Math.max(e,Math.min(t,l))}function Jo(l,e){return(l%e+e)%e}function jt(l,e,t){return(1-t)*l+t*e}class Xt{constructor(e=0,t=0){Xt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(Xe(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const s=Math.cos(t),n=Math.sin(t),i=this.x-e.x,o=this.y-e.y;return this.x=i*s-o*n+e.x,this.y=i*n+o*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}const Ce="srgb",Zt="srgb-linear",Xs="display-p3";class ht{constructor(e,t,s,n,i,o,r,a,h){ht.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,s,n,i,o,r,a,h)}set(e,t,s,n,i,o,r,a,h){const p=this.elements;return p[0]=e,p[1]=n,p[2]=r,p[3]=t,p[4]=i,p[5]=a,p[6]=s,p[7]=o,p[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,n=t.elements,i=this.elements,o=s[0],r=s[3],a=s[6],h=s[1],p=s[4],d=s[7],m=s[2],f=s[5],w=s[8],y=n[0],v=n[3],M=n[6],L=n[1],b=n[4],g=n[7],S=n[2],A=n[5],_=n[8];return i[0]=o*y+r*L+a*S,i[3]=o*v+r*b+a*A,i[6]=o*M+r*g+a*_,i[1]=h*y+p*L+d*S,i[4]=h*v+p*b+d*A,i[7]=h*M+p*g+d*_,i[2]=m*y+f*L+w*S,i[5]=m*v+f*b+w*A,i[8]=m*M+f*g+w*_,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],n=e[2],i=e[3],o=e[4],r=e[5],a=e[6],h=e[7],p=e[8];return t*o*p-t*r*h-s*i*p+s*r*a+n*i*h-n*o*a}invert(){const e=this.elements,t=e[0],s=e[1],n=e[2],i=e[3],o=e[4],r=e[5],a=e[6],h=e[7],p=e[8],d=p*o-r*h,m=r*a-p*i,f=h*i-o*a,w=t*d+s*m+n*f;if(w===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/w;return e[0]=d*y,e[1]=(n*h-p*s)*y,e[2]=(r*s-n*o)*y,e[3]=m*y,e[4]=(p*t-n*a)*y,e[5]=(n*i-r*t)*y,e[6]=f*y,e[7]=(s*a-h*t)*y,e[8]=(o*t-s*i)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,s,n,i,o,r){const a=Math.cos(i),h=Math.sin(i);return this.set(s*a,s*h,-s*(a*o+h*r)+o+e,-n*h,n*a,-n*(-h*o+a*r)+r+t,0,0,1),this}scale(e,t){return this.premultiply(Qt.makeScale(e,t)),this}rotate(e){return this.premultiply(Qt.makeRotation(-e)),this}translate(e,t){return this.premultiply(Qt.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let n=0;n<9;n++)if(t[n]!==s[n])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Qt=new ht;function Kt(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}function Wt(l){return l<.0031308?l*12.92:1.055*Math.pow(l,.41666)-.055}const Ho=new ht().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),$o=new ht().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function er(l){return l.convertSRGBToLinear().applyMatrix3($o)}function tr(l){return l.applyMatrix3(Ho).convertLinearToSRGB()}const sr={[Zt]:l=>l,[Ce]:l=>l.convertSRGBToLinear(),[Xs]:er},nr={[Zt]:l=>l,[Ce]:l=>l.convertLinearToSRGB(),[Xs]:tr},Me={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(l){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!l},get workingColorSpace(){return Zt},set workingColorSpace(l){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(l,e,t){if(this.enabled===!1||e===t||!e||!t)return l;const s=sr[e],n=nr[t];if(s===void 0||n===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);return n(s(l))},fromWorkingColorSpace:function(l,e){return this.convert(l,this.workingColorSpace,e)},toWorkingColorSpace:function(l,e){return this.convert(l,e,this.workingColorSpace)}},Zs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},be={h:0,s:0,l:0},_t={h:0,s:0,l:0};function qt(l,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?l+(e-l)*6*t:t<1/2?e:t<2/3?l+(e-l)*6*(2/3-t):l}class wt{constructor(e,t,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,s)}set(e,t,s){if(t===void 0&&s===void 0){const n=e;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(e,t,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ce){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Me.toWorkingColorSpace(this,t),this}setRGB(e,t,s,n=Me.workingColorSpace){return this.r=e,this.g=t,this.b=s,Me.toWorkingColorSpace(this,n),this}setHSL(e,t,s,n=Me.workingColorSpace){if(e=Jo(e,1),t=Xe(t,0,1),s=Xe(s,0,1),t===0)this.r=this.g=this.b=s;else{const i=s<=.5?s*(1+t):s+t-s*t,o=2*s-i;this.r=qt(o,i,e+1/3),this.g=qt(o,i,e),this.b=qt(o,i,e-1/3)}return Me.toWorkingColorSpace(this,n),this}setStyle(e,t=Ce){function s(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const o=n[1],r=n[2];switch(o){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return s(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return s(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return s(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const i=n[1],o=i.length;if(o===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ce){const s=Zs[e.toLowerCase()];return s!==void 0?this.setHex(s,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Kt(e.r),this.g=Kt(e.g),this.b=Kt(e.b),this}copyLinearToSRGB(e){return this.r=Wt(e.r),this.g=Wt(e.g),this.b=Wt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ce){return Me.fromWorkingColorSpace(ue.copy(this),e),Math.round(Xe(ue.r*255,0,255))*65536+Math.round(Xe(ue.g*255,0,255))*256+Math.round(Xe(ue.b*255,0,255))}getHexString(e=Ce){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Me.workingColorSpace){Me.fromWorkingColorSpace(ue.copy(this),t);const s=ue.r,n=ue.g,i=ue.b,o=Math.max(s,n,i),r=Math.min(s,n,i);let a,h;const p=(r+o)/2;if(r===o)a=0,h=0;else{const d=o-r;switch(h=p<=.5?d/(o+r):d/(2-o-r),o){case s:a=(n-i)/d+(n<i?6:0);break;case n:a=(i-s)/d+2;break;case i:a=(s-n)/d+4;break}a/=6}return e.h=a,e.s=h,e.l=p,e}getRGB(e,t=Me.workingColorSpace){return Me.fromWorkingColorSpace(ue.copy(this),t),e.r=ue.r,e.g=ue.g,e.b=ue.b,e}getStyle(e=Ce){Me.fromWorkingColorSpace(ue.copy(this),e);const t=ue.r,s=ue.g,n=ue.b;return e!==Ce?`color(${e} ${t.toFixed(3)} ${s.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(s*255)},${Math.round(n*255)})`}offsetHSL(e,t,s){return this.getHSL(be),be.h+=e,be.s+=t,be.l+=s,this.setHSL(be.h,be.s,be.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,s){return this.r=e.r+(t.r-e.r)*s,this.g=e.g+(t.g-e.g)*s,this.b=e.b+(t.b-e.b)*s,this}lerpHSL(e,t){this.getHSL(be),e.getHSL(_t);const s=jt(be.h,_t.h,t),n=jt(be.s,_t.s,t),i=jt(be.l,_t.l,t);return this.setHSL(s,n,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,s=this.g,n=this.b,i=e.elements;return this.r=i[0]*t+i[3]*s+i[6]*n,this.g=i[1]*t+i[4]*s+i[7]*n,this.b=i[2]*t+i[5]*s+i[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const ue=new wt;wt.NAMES=Zs;class ir extends c.MeshStandardMaterial{constructor(t={}){super();re(this,"isMeshPhysicalMaterial");re(this,"clearcoatMap");re(this,"clearcoatRoughness");re(this,"clearcoatRoughnessMap");re(this,"clearcoatNormalScale");re(this,"clearcoatNormalMap");re(this,"ior");re(this,"transmissionMap");re(this,"thickness");re(this,"thicknessMap");re(this,"attenuationDistance");re(this,"attenuationColor");re(this,"specularIntensity");re(this,"specularIntensityMap");re(this,"specularColor");re(this,"specularColorMap");re(this,"_clearcoat");re(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Xt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Xe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(s){this.ior=(1+.4*s)/(1-.4*s)}}),this.roughness=0,this.transmissionMap=null,this.thickness=.5,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new wt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new wt(1,1,1),this.specularColorMap=null,this._clearcoat=.5,this._transmission=1,this.setValues(t)}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}const or=ir,rr=u.defineComponent({__name:"index",setup(l,{expose:e}){const t=u.shallowRef(),{extend:s}=q.useTresContext();return s({MeshGlassMaterial:or}),e({MeshGlassMaterialClass:t}),(n,i)=>(u.openBlock(),u.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}}),ar=["args"],lr=["color"],cr=u.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"boxRef",ref:i},o.$attrs),[u.createElementVNode("TresBoxGeometry",{args:u.unref(s)},null,8,ar),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,lr)])],16))}}),hr=["args"],ur=["color"],pr=u.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"circleRef",ref:i},o.$attrs),[u.createElementVNode("TresCircleGeometry",{args:u.unref(s)},null,8,hr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,ur)])],16))}}),dr=["args"],mr=["color"],fr=u.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"coneRef",ref:i},o.$attrs),[u.createElementVNode("TresConeGeometry",{args:u.unref(s)},null,8,dr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,mr)])],16))}}),gr=["args"],yr=["color"],_r=u.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"dodecahedronRef",ref:i},o.$attrs),[u.createElementVNode("TresDodecahedronGeometry",{args:u.unref(s)},null,8,gr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,yr)])],16))}}),wr=["args"],xr=["color"],vr=u.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"icosahedronRef",ref:i},o.$attrs),[u.createElementVNode("TresIcosahedronGeometry",{args:u.unref(s)},null,8,wr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,xr)])],16))}}),Ar=["args"],Mr=["color"],br=u.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"octahedronRef",ref:i},o.$attrs),[u.createElementVNode("TresOctahedronGeometry",{args:u.unref(s)},null,8,Ar),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Mr)])],16))}}),Sr=["rotation"],Tr=["args"],Lr=["color"],Cr=u.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"planeRef",ref:i,rotation:[-Math.PI/2,0,0]},o.$attrs),[u.createElementVNode("TresPlaneGeometry",{args:u.unref(s)},null,8,Tr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Lr)])],16,Sr))}}),Or=["args"],Pr=["color"],Dr=u.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"ringRef",ref:i},o.$attrs),[u.createElementVNode("TresRingGeometry",{args:u.unref(s)},null,8,Or),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Pr)])],16))}}),Ir=["args"],kr=["color"],Fr=u.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"sphereRef",ref:i},o.$attrs),[u.createElementVNode("TresSphereGeometry",{args:u.unref(s)},null,8,Ir),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,kr)])],16))}}),Br=["rotation"],Ur=["args"],Nr=["color"],Vr=u.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tetrahedronRef",ref:i,rotation:[-Math.PI/2,0,0]},o.$attrs),[u.createElementVNode("TresTetrahedronGeometry",{args:u.unref(s)},null,8,Ur),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Nr)])],16,Br))}}),Er=["args"],zr=["color"],Rr=u.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusRef",ref:i},o.$attrs),[u.createElementVNode("TresTorusGeometry",{args:u.unref(s)},null,8,Er),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,zr)])],16))}}),Gr=["args"],Yr=["color"],jr=u.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusKnotRef",ref:i},o.$attrs),[u.createElementVNode("TresTorusKnotGeometry",{args:u.unref(s)},null,8,Gr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Yr)])],16))}}),Xr=["args"],Zr=["color"],Qr=u.defineComponent({__name:"Tube",props:{args:{default:()=>[new c.QuadraticBezierCurve3(new c.Vector3(-1,0,0),new c.Vector3(0,1,0),new c.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(l,{expose:e}){const t=l,{args:s,color:n}=u.toRefs(t),i=u.shallowRef();return e({value:i}),(o,r)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tubeRef",ref:i},o.$attrs),[u.createElementVNode("TresTubeGeometry",{args:u.unref(s)},null,8,Xr),u.renderSlot(o.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(n)},null,8,Zr)])],16))}}),Kr=["receive-shadow","rotation"],Wr=["args"],qr=u.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Jr=u.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(l){const e=l,t=r=>r===0?0:Math.pow(2,10*r-10),{floor:s,segments:n,receiveShadow:i}=u.toRefs(e),o=u.ref(null);return u.watch(()=>[n.value,s.value,o.value],([r,a,h])=>{if(!h||r===null)return;let p=0;const d=r/r/2,m=h.attributes.position;for(let f=0;f<r+1;f++)for(let w=0;w<r+1;w++)m.setXYZ(p++,f/r-d+(f===0?-a:0),w/r-d,t(f/r));m.needsUpdate=!0,h.computeVertexNormals()}),(r,a)=>(u.openBlock(),u.createElementBlock("TresGroup",u.normalizeProps(u.guardReactiveProps(r.$attrs)),[u.createElementVNode("TresMesh",{"receive-shadow":u.unref(i),rotation:[-Math.PI/2,0,Math.PI/2]},[u.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:o,args:[1,1,u.unref(n),u.unref(n)]},null,8,Wr),u.renderSlot(r.$slots,"default",{},()=>[qr])],8,Kr)],16))}});let Oe;const Hr=(l="body")=>{Oe||(Oe=new nn.Pane({container:document.querySelector(l)}),Oe.element.style.position="absolute",Oe.element.style.top="1rem",Oe.element.style.right="1rem",Oe.element.style.zIndex="9999");const{logWarning:e}=Ut();e("useTweakPane is going to be deprecated soon and will no longer be part of this package, please start migrating to @tresjs/leches package https://github.com/Tresjs/leches or v-tweakpane https://github.com/vinayakkulkarni/v-tweakpane instead.");function t(){Oe&&Oe.dispose()}return u.onMounted(()=>{const{resume:s}=q.useRenderLoop();s()}),u.onUnmounted(()=>{t()}),{pane:Oe,disposeTweakPane:t}};U.Backdrop=Jr,U.Box=cr,U.CameraControls=Qo,U.Circle=pr,U.Cone=fr,U.ContactShadows=ro,U.Dodecahedron=_r,U.Environment=Yi,U.FBXModel=To,U.GLTFModel=So,U.Icosahedron=vr,U.KeyboardControls=Fo,U.Levioso=to,U.MapControls=zo,U.MeshGlassMaterial=rr,U.MeshWobbleMaterial=qo,U.MouseParallax=Mo,U.Octahedron=br,U.OrbitControls=Po,U.Plane=Cr,U.PointerLockControls=Vo,U.Precipitation=Wi,U.Ring=Dr,U.ScrollControls=Ro,U.Smoke=eo,U.Sphere=Fr,U.Stars=Zi,U.Tetrahedron=Vr,U.Text3D=Ri,U.Torus=Rr,U.TorusKnot=jr,U.TransformControls=Uo,U.Tube=Qr,U.useAnimations=Gi,U.useEnvironment=Ls,U.useFBX=ks,U.useGLTF=Is,U.useProgress=Lo,U.useTweakPane=Hr,U.useVideoTexture=Co,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
|