a3js 0.0.7 → 0.0.8

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/a3js.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three");function $e(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const L=$e(f);class Q{object;needsUpdate;constructor(e){this.object=this.initObject(e),this.needsUpdate=this.initNeedsUpdate()}initNeedsUpdate(){return!1}update(e){}setLoc(e,t,s){this.object.position.set(e,t,s)}}class Ie{scene;objects;constructor(){this.scene=new L.Scene,this.objects=[]}add(e){this.scene.add(e.object),this.objects.push(e)}update(e){for(const t of this.objects)t.needsUpdate&&t.update(e)}}class Ne extends Q{}class pe{scene;camera;constructor(e){this.scene=new Ie,this.camera=e,this.scene.scene.add(this.camera.object),this.camera.setLoc(0,0,3)}replaceScene(e){this.scene.scene.remove(this.camera.object),e.scene.add(this.camera.object);const t=this.scene;return this.scene=e,t}updateScene(e){this.scene.update(e)}}class me extends Ne{camera;headLight;constructor(e){super(e),this.camera=e,this.headLight=new L.SpotLight(16777215,1,0,Math.PI/3,0,0),this.headLight.rotation.x=3.14/2,this.object.add(this.camera),this.object.add(this.headLight)}initObject(){return new L.Object3D}getHeadLight(){return this.headLight}setAspect(e){Ze(this.camera)&&(this.camera.aspect=e,this.camera.updateProjectionMatrix())}setHeadLightEnable(e){e?this.headLight.intensity=1:this.headLight.intensity=0}}function Ze(o){return o.isPerspectiveCamera===!0}class ke extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;constructor(e){super(),e||(e=new L.PerspectiveCamera(75,300/150,.1,1e3)),this.camera3js=e;const t=new me(e);this.base=new pe(t),this.scene=this.base.scene,this.camera=this.base.camera,this.renderer=new L.WebGLRenderer,this.clock=new L.Clock,this.style="display: block;",this.renderer.domElement.style="display: block; width: 100%; height: 100%; margin: 0; padding: 0;",this.appendChild(this.renderer.domElement),this.animationFrameId=requestAnimationFrame(this.renderingLoop)}connectedCallback(){this.ro=new ResizeObserver(()=>{const{width:e,height:t}=this.renderer.domElement.getBoundingClientRect();et(this.camera3js)&&(this.camera3js.aspect=e/t),this.renderer.setSize(e,t)}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}replaceScene(e){return this.base.replaceScene(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js)}}customElements.define("a3-canvas",ke);function et(o){return o.isPerspectiveCamera===!0}const tt=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("three");function et(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const E=et(d);class tt{x;y;z;constructor(e,t,s){this.x=e,this.y=t,this.z=s}set(e,t,s){this.x=e,this.y=t,this.z=s}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}}class nt{x;y;z;w;constructor(e,t,s,n){this.x=e,this.y=t,this.z=s,this.w=n}set(e,t,s,n){this.x=e,this.y=t,this.z=s,this.w=n}}class q{_loc=new tt(0,0,0);_rot=new nt(0,0,0,1);object;needsUpdate=!1;needsPhysics=!1;scene=null;physics=null;constructor(e){this.object=this.initObject(e)}update(e){this.physics&&this.physics.synchronize(this)}setLoc(e,t,s){typeof e=="number"?(this._loc.set(e,t,s),this.object.position.set(e,t,s)):(this._loc.set(e.x,e.y,e.z),this.object.position.set(e.x,e.y,e.z))}get loc(){return this._loc}setQuat(e,t,s,n){typeof e=="number"?(this._rot.set(e,t,s,n),this.object.quaternion.set(e,t,s,n)):(this._rot.set(e.x,e.y,e.z,e.w),this.object.quaternion.set(e.x,e.y,e.z,e.w))}get quat(){return this._rot}}class st extends q{constructor(e){super(),this.needsUpdate=!0,e&&(this.needsPhysics=e.physics)}initObject(){const e=new E.BoxGeometry,t=new E.MeshStandardMaterial({color:65280});return new E.Mesh(e,t)}update(e){this.physics?super.update(e):(this.object.rotation.x+=e,this.object.rotation.y+=e,this.object.rotation.z+=e)}}let he;class ${static RAPIER;isInitialized=!1;constructor(){}async createWorld(e){if(!$.RAPIER){const s=await Promise.resolve().then(()=>require("./rapier-DQltNJbN.cjs"));await s.init(),$.RAPIER=s,he=s,this.isInitialized=!0}const t=new $.RAPIER.World(e.gravity);return new rt(t,e.timestep)}}class rt{world;timestep;constructor(e,t){this.world=e,this.timestep=t,this.world.integrationParameters.dt=this.timestep}createPhysicsEntity(e){const t=new it(e);return t.body=this.world.createRigidBody(t.bodyDesc),t.collider=this.world.createCollider(t.colliderDesc,t.body),t}update(e){const t=Math.ceil(e/this.timestep);for(let s=0;s<t;s++)this.world.step()}}class it{object;bodyDesc;body=null;colliderDesc;collider=null;constructor(e){this.object=e,this.bodyDesc=he.RigidBodyDesc.dynamic(),this.bodyDesc.setTranslation(e.loc.x,e.loc.y,e.loc.z),this.colliderDesc=he.ColliderDesc.cuboid(1,1,1),this.colliderDesc.setRestitution(.3).setFriction(.6)}synchronize(e){if(this.body){const t=this.body.translation();e.setLoc(t.x,t.y,t.z);const s=this.body.rotation();e.setQuat(s.x,s.y,s.z,s.w)}}setLoc(e){this.body&&this.body.setTranslation(e,!0)}setQuat(e){this.body&&this.body.setRotation(e,!0)}}class X{scene;objects;static physics;physicsWorld=null;physicsDt=1/60;constructor(){this.scene=new E.Scene,this.objects=[],X.physics||(X.physics=new $)}add(e){this.scene.add(e.object),this.objects.push(e),e.scene=this,e.needsPhysics&&this.physicsWorld&&!e.physics&&(e.physics=this.physicsWorld.createPhysicsEntity(e),e.needsUpdate=!0)}async initPhysics(){const e={gravity:{x:0,y:-9.81,z:0},timestep:this.physicsDt};this.physicsWorld=await X.physics.createWorld(e)}update(e){this.physicsWorld&&this.physicsWorld.update(e);for(const t of this.objects)t.needsUpdate&&t.update(e)}}class De extends q{}class Te{scene;camera;constructor(e){this.scene=new X,this.camera=e,this.scene.scene.add(this.camera.object),this.camera.setLoc(0,0,3)}replaceScene(e){this.scene.scene.remove(this.camera.object),e.scene.add(this.camera.object);const t=this.scene;return this.scene=e,t}updateScene(e){this.scene.update(e)}}class ye extends De{camera;headLight;constructor(e){super(e),this.camera=e,this.headLight=new E.SpotLight(16777215,1,0,Math.PI/3,0,0),this.headLight.rotation.x=3.14/2,this.object.add(this.camera),this.object.add(this.headLight)}initObject(){return new E.Object3D}getHeadLight(){return this.headLight}setAspect(e){ot(this.camera)&&(this.camera.aspect=e,this.camera.updateProjectionMatrix())}setHeadLightEnable(e){e?this.headLight.intensity=1:this.headLight.intensity=0}}function ot(o){return o.isPerspectiveCamera===!0}class Pe extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;constructor(e){super(),e||(e=new E.PerspectiveCamera(75,300/150,.1,1e3)),this.camera3js=e;const t=new ye(e);this.base=new Te(t),this.scene=this.base.scene,this.camera=this.base.camera,this.renderer=new E.WebGLRenderer,this.clock=new E.Clock,this.style="display: block;",this.renderer.domElement.style="display: block; width: 100%; height: 100%; margin: 0; padding: 0;",this.appendChild(this.renderer.domElement),this.animationFrameId=requestAnimationFrame(this.renderingLoop)}connectedCallback(){this.ro=new ResizeObserver(()=>{const{width:e,height:t}=this.renderer.domElement.getBoundingClientRect();at(this.camera3js)&&(this.camera3js.aspect=e/t),this.renderer.setSize(e,t)}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}replaceScene(e){return this.base.replaceScene(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.base.updateScene(e),this.renderer.render(this.scene.scene,this.camera3js)}}customElements.define("a3-canvas",Pe);function at(o){return o.isPerspectiveCamera===!0}const ct=`
2
2
  position: absolute;
3
3
  top: 100px;
4
4
  left: 100px;
@@ -6,12 +6,12 @@
6
6
  border: 1px solid #555;
7
7
  background: white;
8
8
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.3);
9
- `,nt=`
9
+ `,lt=`
10
10
  background: #444;
11
11
  color: white;
12
12
  padding: 8px;
13
13
  cursor: move;
14
14
  user-select: none; /* 文字選択を防ぐ */
15
- `;class Oe extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;isDragging=!1;offsetX=0;offsetY=0;constructor(e,t){super(),this.camera3js=new L.PerspectiveCamera(75,e/t,.1,1e3);const s=new me(this.camera3js);this.base=new pe(s),this.scene=this.base.scene,this.camera=this.base.camera,this.renderer=new L.WebGLRenderer,this.clock=new L.Clock,this.camera3js.aspect=e/t,this.renderer.setSize(e,t),this.style=tt,document.body?document.body.appendChild(this):document.addEventListener("DOMContentLoaded",()=>{document.body.append(this)},{once:!0});const n=document.createElement("div");n.textContent="A3Window",n.style=nt,this.appendChild(n),n.addEventListener("mousedown",this.mouseDownListener),document.addEventListener("mousemove",this.mouseMoveListener),document.addEventListener("mouseup",this.mouseUpListener),this.renderer.domElement.style=`display: block; width: ${e}px; height: ${t}px; margin: 0; padding: 0;`,this.renderer.domElement.width=e,this.renderer.domElement.width=t,this.appendChild(this.renderer.domElement),this.animationFrameId=requestAnimationFrame(this.renderingLoop)}connectedCallback(){this.ro=new ResizeObserver(()=>{const{width:e,height:t}=this.renderer.domElement.getBoundingClientRect();this.camera3js.aspect=e/t,this.renderer.setSize(e,t)}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}mouseDownListener=e=>{this.isDragging=!0,this.offsetX=e.clientX-this.offsetLeft,this.offsetY=e.clientY-this.offsetTop};mouseMoveListener=e=>{this.isDragging&&(this.style.left=e.clientX-this.offsetX+"px",this.style.top=e.clientY-this.offsetY+"px")};mouseUpListener=()=>{this.isDragging=!1};replaceScene(e){return this.base.replaceScene(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.scene&&(this.scene.update(e),this.renderer.render(this.scene.scene,this.camera3js))}}customElements.define("a3-window",Oe);class st extends Q{initObject(){const e=new L.BoxGeometry,t=new L.MeshStandardMaterial({color:65280});return new L.Mesh(e,t)}initNeedsUpdate(){return!0}update(e){this.object.rotation.x+=e,this.object.rotation.y+=e,this.object.rotation.z+=e}}class rt{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,s="ltr"){const n=[],i=it(e,t,this.data,s);for(let r=0,a=i.length;r<a;r++)n.push(...i[r].toShapes());return n}}function it(o,e,t,s){const n=Array.from(o),i=e/t.resolution,r=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,a=[];let c=0,l=0;(s=="rtl"||s=="tb")&&n.reverse();for(let h=0;h<n.length;h++){const u=n[h];if(u===`
16
- `)c=0,l-=r;else{const d=ot(u,i,c,l,t);s=="tb"?(c=0,l+=t.ascender*i):c+=d.offsetX,a.push(d.path)}}return a}function ot(o,e,t,s,n){const i=n.glyphs[o]||n.glyphs["?"];if(!i){console.error('THREE.Font: character "'+o+'" does not exists in font family '+n.familyName+".");return}const r=new f.ShapePath;let a,c,l,h,u,d,p,T;if(i.o){const g=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let m=0,x=g.length;m<x;)switch(g[m++]){case"m":a=g[m++]*e+t,c=g[m++]*e+s,r.moveTo(a,c);break;case"l":a=g[m++]*e+t,c=g[m++]*e+s,r.lineTo(a,c);break;case"q":l=g[m++]*e+t,h=g[m++]*e+s,u=g[m++]*e+t,d=g[m++]*e+s,r.quadraticCurveTo(u,d,l,h);break;case"b":l=g[m++]*e+t,h=g[m++]*e+s,u=g[m++]*e+t,d=g[m++]*e+s,p=g[m++]*e+t,T=g[m++]*e+s,r.bezierCurveTo(u,d,p,T,l,h);break}}return{offsetX:i.ha*e,path:r}}class at extends f.ExtrudeGeometry{constructor(e,t={}){const s=t.font;if(s===void 0)super();else{const n=s.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(n,t)}this.type="TextGeometry"}}function De(o){return typeof o=="string"}var v=Uint8Array,z=Uint16Array,ct=Int32Array,Pe=new v([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]),Fe=new v([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]),lt=new v([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ge=function(o,e){for(var t=new z(31),s=0;s<31;++s)t[s]=e+=1<<o[s-1];for(var n=new ct(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{b:t,r:n}},Ue=Ge(Pe,2),He=Ue.b,ut=Ue.r;He[28]=258,ut[258]=28;var ht=Ge(Fe,0),ft=ht.b,le=new z(32768);for(var E=0;E<32768;++E){var H=(E&43690)>>1|(E&21845)<<1;H=(H&52428)>>2|(H&13107)<<2,H=(H&61680)>>4|(H&3855)<<4,le[E]=((H&65280)>>8|(H&255)<<8)>>1}var Y=(function(o,e,t){for(var s=o.length,n=0,i=new z(e);n<s;++n)o[n]&&++i[o[n]-1];var r=new z(e);for(n=1;n<e;++n)r[n]=r[n-1]+i[n-1]<<1;var a;if(t){a=new z(1<<e);var c=15-e;for(n=0;n<s;++n)if(o[n])for(var l=n<<4|o[n],h=e-o[n],u=r[o[n]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)a[le[u]>>c]=l}else for(a=new z(s),n=0;n<s;++n)o[n]&&(a[n]=le[r[o[n]-1]++]>>15-o[n]);return a}),J=new v(288);for(var E=0;E<144;++E)J[E]=8;for(var E=144;E<256;++E)J[E]=9;for(var E=256;E<280;++E)J[E]=7;for(var E=280;E<288;++E)J[E]=8;var Be=new v(32);for(var E=0;E<32;++E)Be[E]=5;var dt=Y(J,9,1),pt=Y(Be,5,1),ne=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},D=function(o,e,t){var s=e/8|0;return(o[s]|o[s+1]<<8)>>(e&7)&t},se=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},mt=function(o){return(o+7)/8|0},ge=function(o,e,t){return(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length),new v(o.subarray(e,t))},gt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],O=function(o,e,t){var s=new Error(e||gt[o]);if(s.code=o,Error.captureStackTrace&&Error.captureStackTrace(s,O),!t)throw s;return s},Tt=function(o,e,t,s){var n=o.length,i=s?s.length:0;if(!n||e.f&&!e.l)return t||new v(0);var r=!t,a=r||e.i!=2,c=e.i;r&&(t=new v(n*3));var l=function(Ee){var Le=t.length;if(Ee>Le){var be=new v(Math.max(Le*2,Ee));be.set(t),t=be}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,T=e.d,g=e.m,m=e.n,x=n*8;do{if(!p){h=D(o,u,1);var A=D(o,u+1,3);if(u+=3,A)if(A==1)p=dt,T=pt,g=9,m=5;else if(A==2){var S=D(o,u,31)+257,_=D(o,u+10,15)+4,I=S+D(o,u+5,31)+1;u+=14;for(var C=new v(I),N=new v(19),M=0;M<_;++M)N[lt[M]]=D(o,u+M*3,7);u+=_*3;for(var Te=ne(N),We=(1<<Te)-1,qe=Y(N,Te,1),M=0;M<I;){var xe=qe[D(o,u,We)];u+=xe&15;var y=xe>>4;if(y<16)C[M++]=y;else{var K=0,$=0;for(y==16?($=3+D(o,u,3),u+=2,K=C[M-1]):y==17?($=3+D(o,u,7),u+=3):y==18&&($=11+D(o,u,127),u+=7);$--;)C[M++]=K}}var ye=C.subarray(0,S),U=C.subarray(S);g=ne(ye),m=ne(U),p=Y(ye,g,1),T=Y(U,m,1)}else O(1);else{var y=mt(u)+4,R=o[y-4]|o[y-3]<<8,b=y+R;if(b>n){c&&O(0);break}a&&l(d+R),t.set(o.subarray(y,b),d),e.b=d+=R,e.p=u=b*8,e.f=h;continue}if(u>x){c&&O(0);break}}a&&l(d+131072);for(var Ye=(1<<g)-1,Qe=(1<<m)-1,Z=u;;Z=u){var K=p[se(o,u)&Ye],V=K>>4;if(u+=K&15,u>x){c&&O(0);break}if(K||O(2),V<256)t[d++]=V;else if(V==256){Z=u,p=null;break}else{var Re=V-254;if(V>264){var M=V-257,W=Pe[M];Re=D(o,u,(1<<W)-1)+He[M],u+=W}var ee=T[se(o,u)&Qe],te=ee>>4;ee||O(3),u+=ee&15;var U=ft[te];if(te>3){var W=Fe[te];U+=se(o,u)&(1<<W)-1,u+=W}if(u>x){c&&O(0);break}a&&l(d+131072);var we=d+Re;if(d<U){var Ae=i-U,Je=Math.min(U,we);for(Ae+d<0&&O(3);d<Je;++d)t[d]=s[Ae+d]}for(;d<we;++d)t[d]=t[d-U]}}e.l=p,e.p=Z,e.b=d,e.f=h,p&&(h=1,e.m=g,e.d=T,e.n=m)}while(!h);return d!=t.length&&r?ge(t,0,d):t.subarray(0,d)},xt=new v(0),G=function(o,e){return o[e]|o[e+1]<<8},P=function(o,e){return(o[e]|o[e+1]<<8|o[e+2]<<16|o[e+3]<<24)>>>0},re=function(o,e){return P(o,e)+P(o,e+4)*4294967296};function yt(o,e){return Tt(o,{i:2},e&&e.out,e&&e.dictionary)}var ue=typeof TextDecoder<"u"&&new TextDecoder,Rt=0;try{ue.decode(xt,{stream:!0}),Rt=1}catch{}var wt=function(o){for(var e="",t=0;;){var s=o[t++],n=(s>127)+(s>223)+(s>239);if(t+n>o.length)return{s:e,r:ge(o,t-1)};n?n==3?(s=((s&15)<<18|(o[t++]&63)<<12|(o[t++]&63)<<6|o[t++]&63)-65536,e+=String.fromCharCode(55296|s>>10,56320|s&1023)):n&1?e+=String.fromCharCode((s&31)<<6|o[t++]&63):e+=String.fromCharCode((s&15)<<12|(o[t++]&63)<<6|o[t++]&63):e+=String.fromCharCode(s)}};function je(o,e){if(e){for(var t="",s=0;s<o.length;s+=16384)t+=String.fromCharCode.apply(null,o.subarray(s,s+16384));return t}else{if(ue)return ue.decode(o);var n=wt(o),i=n.s,t=n.r;return t.length&&O(8),i}}var At=function(o,e){return e+30+G(o,e+26)+G(o,e+28)},Et=function(o,e,t){var s=G(o,e+28),n=je(o.subarray(e+46,e+46+s),!(G(o,e+8)&2048)),i=e+46+s,r=P(o,e+20),a=t&&r==4294967295?Lt(o,i):[r,P(o,e+24),P(o,e+42)],c=a[0],l=a[1],h=a[2];return[G(o,e+10),c,l,n,i+G(o,e+30)+G(o,e+32),h]},Lt=function(o,e){for(;G(o,e)!=1;e+=4+G(o,e+2));return[re(o,e+12),re(o,e+4),re(o,e+20)]};function bt(o,e){for(var t={},s=o.length-22;P(o,s)!=101010256;--s)(!s||o.length-s>65558)&&O(13);var n=G(o,s+8);if(!n)return{};var i=P(o,s+16),r=i==4294967295||n==65535;if(r){var a=P(o,s-12);r=P(o,a)==101075792,r&&(n=P(o,a+32),i=P(o,a+48))}for(var c=0;c<n;++c){var l=Et(o,i,r),h=l[0],u=l[1],d=l[2],p=l[3],T=l[4],g=l[5],m=At(o,g);i=T,h?h==8?t[p]=yt(o.subarray(m,m+u),{out:new v(d)}):O(14,"unknown compression type "+h):t[p]=ge(o,m,m+u)}return t}let he=null;async function St(o){const e=o.substring(0,o.length-4),t=new L.FileLoader;t.setResponseType("arraybuffer");const s=await t.loadAsync(o),n=bt(new Uint8Array(s)),i=je(new Uint8Array(n[e].buffer));he=new rt(JSON.parse(i))}class _t extends Q{initObject(e){let t;if(De(e)?t=e:t="ERROR",he==null){const s=new L.BoxGeometry,n=new L.MeshStandardMaterial({color:16711680});return new L.Mesh(s,n)}else{const s={font:he,size:1,depth:.5,curveSegments:12},n=new at(t,s);n.center();const i=new L.MeshStandardMaterial({color:65280});return new L.Mesh(n,i)}}}function Se(o,e){if(e===f.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===f.TriangleFanDrawMode||e===f.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)r.push(c);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const s=t.count-2,n=[];if(e===f.TriangleFanDrawMode)for(let r=1;r<=s;r++)n.push(t.getX(0)),n.push(t.getX(r)),n.push(t.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(t.getX(r)),n.push(t.getX(r+1)),n.push(t.getX(r+2))):(n.push(t.getX(r+2)),n.push(t.getX(r+1)),n.push(t.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=o.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Mt extends f.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new kt(t)}),this.register(function(t){return new Ot(t)}),this.register(function(t){return new Kt(t)}),this.register(function(t){return new Vt(t)}),this.register(function(t){return new zt(t)}),this.register(function(t){return new Pt(t)}),this.register(function(t){return new Ft(t)}),this.register(function(t){return new Gt(t)}),this.register(function(t){return new Ut(t)}),this.register(function(t){return new Nt(t)}),this.register(function(t){return new Ht(t)}),this.register(function(t){return new Dt(t)}),this.register(function(t){return new jt(t)}),this.register(function(t){return new Bt(t)}),this.register(function(t){return new vt(t)}),this.register(function(t){return new Xt(t)}),this.register(function(t){return new Wt(t)})}load(e,t,s,n){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const l=f.LoaderUtils.extractUrlBase(e);r=f.LoaderUtils.resolveURL(l,this.path)}else r=f.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){n?n(l):console.error(l),i.manager.itemError(e),i.manager.itemEnd(e)},c=new f.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{i.parse(l,r,function(h){t(h),i.manager.itemEnd(e)},a)}catch(h){a(h)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}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 r={},a={},c=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ke){try{r[w.KHR_BINARY_GLTF]=new qt(e)}catch(u){n&&n(u);return}i=JSON.parse(r[w.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.decode(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 l=new cn(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,r[u.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const u=i.extensionsUsed[h],d=i.extensionsRequired||[];switch(u){case w.KHR_MATERIALS_UNLIT:r[u]=new It;break;case w.KHR_DRACO_MESH_COMPRESSION:r[u]=new Yt(i,this.dracoLoader);break;case w.KHR_TEXTURE_TRANSFORM:r[u]=new Qt;break;case w.KHR_MESH_QUANTIZATION:r[u]=new Jt;break;default:d.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function Ct(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const w={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class vt{constructor(e){this.parser=e,this.name=w.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,c=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let l;const h=new f.Color(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],f.LinearSRGBColorSpace);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new f.DirectionalLight(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new f.PointLight(h),l.distance=u;break;case"spot":l=new f.SpotLight(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),F(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),n=Promise.resolve(l),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],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return s._getNodeRef(t.cache,a,c)})}}class It{constructor(){this.name=w.KHR_MATERIALS_UNLIT}getMaterialType(){return f.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new f.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],f.LinearSRGBColorSpace),e.opacity=r[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,f.SRGBColorSpace))}return Promise.all(n)}}class Nt{constructor(e){this.parser=e,this.name=w.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 kt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f.Vector2(a,a)}return Promise.all(i)}}class Ot{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Dt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class Pt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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 f.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",r.sheenColorTexture,f.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class Ft{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class Gt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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=[],r=n.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),Promise.all(i)}}class Ut{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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 Ht{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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=[],r=n.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",r.specularColorTexture,f.SRGBColorSpace)),Promise.all(i)}}class Bt{constructor(e){this.parser=e,this.name=w.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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=[],r=n.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(i)}}class jt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:f.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=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class Kt{constructor(e){this.parser=e,this.name=w.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],r=t.options.ktx2Loader;if(!r){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,r)}}class Vt{constructor(e){this.parser=e,this.name=w.EXT_TEXTURE_WEBP}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 r=i.extensions[t],a=n.images[r.source];let c=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(c=l)}return s.loadTextureImage(e,r.source,c)}}class zt{constructor(e){this.parser=e,this.name=w.EXT_TEXTURE_AVIF}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 r=i.extensions[t],a=n.images[r.source];let c=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(c=l)}return s.loadTextureImage(e,r.source,c)}}class Xt{constructor(e){this.name=w.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),r=this.parser.options.meshoptDecoder;if(!r||!r.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(a){const c=n.byteOffset||0,l=n.byteLength||0,h=n.count,u=n.byteStride,d=new Uint8Array(a,c,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(h,u,d,n.mode,n.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(h*u);return r.decodeGltfBuffer(new Uint8Array(p),h,u,d,n.mode,n.filter),p})})}else return null}}class Wt{constructor(e){this.name=w.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 l of n.primitives)if(l.mode!==k.TRIANGLES&&l.mode!==k.TRIANGLE_STRIP&&l.mode!==k.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],c={};for(const l in r)a.push(this.parser.getDependency("accessor",r[l]).then(h=>(c[l]=h,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],d=l[0].count,p=[];for(const T of u){const g=new f.Matrix4,m=new f.Vector3,x=new f.Quaternion,A=new f.Vector3(1,1,1),y=new f.InstancedMesh(T.geometry,T.material,d);for(let R=0;R<d;R++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,R),c.ROTATION&&x.fromBufferAttribute(c.ROTATION,R),c.SCALE&&A.fromBufferAttribute(c.SCALE,R),y.setMatrixAt(R,g.compose(m,x,A));for(const R in c)if(R==="_COLOR_0"){const b=c[R];y.instanceColor=new f.InstancedBufferAttribute(b.array,b.itemSize,b.normalized)}else R!=="TRANSLATION"&&R!=="ROTATION"&&R!=="SCALE"&&T.geometry.setAttribute(R,c[R]);f.Object3D.prototype.copy.call(y,T),this.parser.assignFinalMaterial(y),p.push(y)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const Ke="glTF",q=12,_e={JSON:1313821514,BIN:5130562};class qt{constructor(e){this.name=w.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,q),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ke)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-q,i=new DataView(e,q);let r=0;for(;r<n;){const a=i.getUint32(r,!0);r+=4;const c=i.getUint32(r,!0);if(r+=4,c===_e.JSON){const l=new Uint8Array(e,q+r,a);this.content=s.decode(l)}else if(c===_e.BIN){const l=q+r;this.body=e.slice(l,l+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Yt{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=w.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,r=e.extensions[this.name].attributes,a={},c={},l={};for(const h in r){const u=fe[h]||h.toLowerCase();a[u]=r[h]}for(const h in e.attributes){const u=fe[h]||h.toLowerCase();if(r[h]!==void 0){const d=s.accessors[e.attributes[h]],p=X[d.componentType];l[u]=p.name,c[u]=d.normalized===!0}}return t.getDependency("bufferView",i).then(function(h){return new Promise(function(u,d){n.decodeDracoFile(h,function(p){for(const T in p.attributes){const g=p.attributes[T],m=c[T];m!==void 0&&(g.normalized=m)}u(p)},a,l,f.LinearSRGBColorSpace,d)})})}}class Qt{constructor(){this.name=w.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 Jt{constructor(){this.name=w.KHR_MESH_QUANTIZATION}}class Ve extends f.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 r=0;r!==n;r++)t[r]=s[i+r];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=n-t,u=(s-t)/h,d=u*u,p=d*u,T=e*l,g=T-l,m=-2*p+3*d,x=p-d,A=1-m,y=x-d+u;for(let R=0;R!==a;R++){const b=r[g+R+a],S=r[g+R+c]*h,_=r[T+R+a],I=r[T+R]*h;i[R]=A*b+y*S+m*_+x*I}return i}}const $t=new f.Quaternion;class Zt extends Ve{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return $t.fromArray(i).normalize().toArray(i),i}}const k={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},X={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Me={9728:f.NearestFilter,9729:f.LinearFilter,9984:f.NearestMipmapNearestFilter,9985:f.LinearMipmapNearestFilter,9986:f.NearestMipmapLinearFilter,9987:f.LinearMipmapLinearFilter},Ce={33071:f.ClampToEdgeWrapping,33648:f.MirroredRepeatWrapping,10497:f.RepeatWrapping},ie={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fe={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},B={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},en={CUBICSPLINE:void 0,LINEAR:f.InterpolateLinear,STEP:f.InterpolateDiscrete},oe={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function tn(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new f.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:f.FrontSide})),o.DefaultMaterial}function j(o,e,t){for(const s in t.extensions)o[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function F(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function nn(o,e,t){let s=!1,n=!1,i=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(o);const r=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(s){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):o.attributes.position;r.push(d)}if(n){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):o.attributes.normal;a.push(d)}if(i){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):o.attributes.color;c.push(d)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],d=l[2];return s&&(o.morphAttributes.position=h),n&&(o.morphAttributes.normal=u),i&&(o.morphAttributes.color=d),o.morphTargetsRelative=!0,o})}function sn(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)o.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function rn(o){let e;const t=o.extensions&&o.extensions[w.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ae(t.attributes):e=o.indices+":"+ae(o.attributes)+":"+o.mode,o.targets!==void 0)for(let s=0,n=o.targets.length;s<n;s++)e+=":"+ae(o.targets[s]);return e}function ae(o){let e="";const t=Object.keys(o).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+o[t[s]]+";";return e}function de(o){switch(o){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 on(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const an=new f.Matrix4;class cn{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Ct,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,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);n=s&&c?parseInt(c[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&r<98?this.textureLoader=new f.TextureLoader(this.options.manager):this.textureLoader=new f.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new f.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(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return j(i,a,n),F(a,n),Promise.all(s._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();e(a)})}).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 r=t[n].joints;for(let a=0,c=r.length;a<c;a++)e[r[a]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const r=e[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.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=(r,a)=>{const c=this.associations.get(r);c!=null&&this.associations.set(a,c);for(const[l,h]of r.children.entries())i(h,a.children[l])};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,r){return s.getDependency(e,r)})),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[w.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,r){s.load(f.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){r(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 r=ie[n.type],a=X[n.componentType],c=n.normalized===!0,l=new a(n.count*r);return Promise.resolve(new f.BufferAttribute(l,r,c))}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(r){const a=r[0],c=ie[n.type],l=X[n.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,d=n.byteOffset||0,p=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,T=n.normalized===!0;let g,m;if(p&&p!==u){const x=Math.floor(d/p),A="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+x+":"+n.count;let y=t.cache.get(A);y||(g=new l(a,x*p,n.count*p/h),y=new f.InterleavedBuffer(g,p/h),t.cache.add(A,y)),m=new f.InterleavedBufferAttribute(y,c,d%p/h,T)}else a===null?g=new l(n.count*c):g=new l(a,d,n.count*c),m=new f.BufferAttribute(g,c,T);if(n.sparse!==void 0){const x=ie.SCALAR,A=X[n.sparse.indices.componentType],y=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,b=new A(r[1],y,n.sparse.count*x),S=new l(r[2],R,n.sparse.count*c);a!==null&&(m=new f.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let _=0,I=b.length;_<I;_++){const C=b[_];if(m.setX(C,S[_*c]),c>=2&&m.setY(C,S[_*c+1]),c>=3&&m.setZ(C,S[_*c+2]),c>=4&&m.setW(C,S[_*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=T}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const c=s.manager.getHandler(r.uri);c!==null&&(a=c)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,s){const n=this,i=this.json,r=i.textures[e],a=i.images[t],c=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,s).then(function(h){h.flipY=!1,h.name=r.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const d=(i.samplers||{})[r.sampler]||{};return h.magFilter=Me[d.magFilter]||f.LinearFilter,h.minFilter=Me[d.minFilter]||f.LinearMipmapLinearFilter,h.wrapS=Ce[d.wrapS]||f.RepeatWrapping,h.wrapT=Ce[d.wrapT]||f.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==f.NearestFilter&&h.minFilter!==f.LinearFilter,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const r=n.images[e],a=self.URL||self.webkitURL;let c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=s.getDependency("bufferView",r.bufferView).then(function(u){l=!0;const d=new Blob([u],{type:r.mimeType});return c=a.createObjectURL(d),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(d,p){let T=d;t.isImageBitmapLoader===!0&&(T=function(g){const m=new f.Texture(g);m.needsUpdate=!0,d(m)}),t.load(f.LoaderUtils.resolveURL(u,i.path),T,void 0,p)})}).then(function(u){return l===!0&&a.revokeObjectURL(c),F(u,r),u.userData.mimeType=r.mimeType||on(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[w.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[w.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=i.associations.get(r);r=i.extensions[w.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,c)}}return n!==void 0&&(r.colorSpace=n),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let c=this.cache.get(a);c||(c=new f.PointsMaterial,f.Material.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,c.sizeAttenuation=!1,this.cache.add(a,c)),s=c}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let c=this.cache.get(a);c||(c=new f.LineBasicMaterial,f.Material.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,this.cache.add(a,c)),s=c}if(n||i||r){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=s.clone(),i&&(c.vertexColors=!0),r&&(c.flatShading=!0),n&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(s))),s=c}e.material=s}getMaterialType(){return f.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let r;const a={},c=i.extensions||{},l=[];if(c[w.KHR_MATERIALS_UNLIT]){const u=n[w.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),l.push(u.extendParams(a,i,t))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new f.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],f.LinearSRGBColorSpace),a.opacity=d[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,f.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=f.DoubleSide);const h=i.alphaMode||oe.OPAQUE;if(h===oe.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===oe.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==f.MeshBasicMaterial&&(l.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new f.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&r!==f.MeshBasicMaterial&&(l.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==f.MeshBasicMaterial){const u=i.emissiveFactor;a.emissive=new f.Color().setRGB(u[0],u[1],u[2],f.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&r!==f.MeshBasicMaterial&&l.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,f.SRGBColorSpace)),Promise.all(l).then(function(){const u=new r(a);return i.name&&(u.name=i.name),F(u,i),t.associations.set(u,{materials:e}),i.extensions&&j(n,u,i),u})}createUniqueName(e){const t=f.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(a){return s[w.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return ve(c,a,t)})}const r=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],h=rn(l),u=n[h];if(u)r.push(u.promise);else{let d;l.extensions&&l.extensions[w.KHR_DRACO_MESH_COMPRESSION]?d=i(l):d=ve(new f.BufferGeometry,l,t),n[h]={primitive:l,promise:d},r.push(d)}}return Promise.all(r)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],r=i.primitives,a=[];for(let c=0,l=r.length;c<l;c++){const h=r[c].material===void 0?tn(this.cache):this.getDependency("material",r[c].material);a.push(h)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let p=0,T=h.length;p<T;p++){const g=h[p],m=r[p];let x;const A=l[p];if(m.mode===k.TRIANGLES||m.mode===k.TRIANGLE_STRIP||m.mode===k.TRIANGLE_FAN||m.mode===void 0)x=i.isSkinnedMesh===!0?new f.SkinnedMesh(g,A):new f.Mesh(g,A),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),m.mode===k.TRIANGLE_STRIP?x.geometry=Se(x.geometry,f.TriangleStripDrawMode):m.mode===k.TRIANGLE_FAN&&(x.geometry=Se(x.geometry,f.TriangleFanDrawMode));else if(m.mode===k.LINES)x=new f.LineSegments(g,A);else if(m.mode===k.LINE_STRIP)x=new f.Line(g,A);else if(m.mode===k.LINE_LOOP)x=new f.LineLoop(g,A);else if(m.mode===k.POINTS)x=new f.Points(g,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(x.geometry.morphAttributes).length>0&&sn(x,i),x.name=t.createUniqueName(i.name||"mesh_"+e),F(x,i),m.extensions&&j(n,x,m),t.assignFinalMaterial(x),u.push(x)}for(let p=0,T=u.length;p<T;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return i.extensions&&j(n,u[0],i),u[0];const d=new f.Group;i.extensions&&j(n,d,i),t.associations.set(d,{meshes:e});for(let p=0,T=u.length;p<T;p++)d.add(u[p]);return d})}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 f.PerspectiveCamera(f.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new f.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),F(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(),r=n,a=[],c=[];for(let l=0,h=r.length;l<h;l++){const u=r[l];if(u){a.push(u);const d=new f.Matrix4;i!==null&&d.fromArray(i.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new f.Skeleton(a,c)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,r=[],a=[],c=[],l=[],h=[];for(let u=0,d=n.channels.length;u<d;u++){const p=n.channels[u],T=n.samplers[p.sampler],g=p.target,m=g.node,x=n.parameters!==void 0?n.parameters[T.input]:T.input,A=n.parameters!==void 0?n.parameters[T.output]:T.output;g.node!==void 0&&(r.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",x)),c.push(this.getDependency("accessor",A)),l.push(T),h.push(g))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const d=u[0],p=u[1],T=u[2],g=u[3],m=u[4],x=[];for(let y=0,R=d.length;y<R;y++){const b=d[y],S=p[y],_=T[y],I=g[y],C=m[y];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const N=s._createAnimationTracks(b,S,_,I,C);if(N)for(let M=0;M<N.length;M++)x.push(N[M])}const A=new f.AnimationClip(i,void 0,x);return F(A,n),A})}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 r=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let c=0,l=n.weights.length;c<l;c++)a.morphTargetInfluences[c]=n.weights[c]}),r})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),r=[],a=n.children||[];for(let l=0,h=a.length;l<h;l++)r.push(s.getDependency("node",a[l]));const c=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),c]).then(function(l){const h=l[0],u=l[1],d=l[2];d!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(d,an)});for(let p=0,T=u.length;p<T;p++)h.add(u[p]);return h})}_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],r=i.name?n.createUniqueName(i.name):"",a=[],c=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(i.isBone===!0?h=new f.Bone:l.length>1?h=new f.Group:l.length===1?h=l[0]:h=new f.Object3D,h!==l[0])for(let u=0,d=l.length;u<d;u++)h.add(l[u]);if(i.name&&(h.userData.name=i.name,h.name=r),F(h,i),i.extensions&&j(s,h,i),i.matrix!==void 0){const u=new f.Matrix4;u.fromArray(i.matrix),h.applyMatrix4(u)}else i.translation!==void 0&&h.position.fromArray(i.translation),i.rotation!==void 0&&h.quaternion.fromArray(i.rotation),i.scale!==void 0&&h.scale.fromArray(i.scale);if(!n.associations.has(h))n.associations.set(h,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const u=n.associations.get(h);n.associations.set(h,{...u})}return n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new f.Group;s.name&&(i.name=n.createUniqueName(s.name)),F(i,s),s.extensions&&j(t,i,s);const r=s.nodes||[],a=[];for(let c=0,l=r.length;c<l;c++)a.push(n.getDependency("node",r[c]));return Promise.all(a).then(function(c){for(let h=0,u=c.length;h<u;h++)i.add(c[h]);const l=h=>{const u=new Map;for(const[d,p]of n.associations)(d instanceof f.Material||d instanceof f.Texture)&&u.set(d,p);return h.traverse(d=>{const p=n.associations.get(d);p!=null&&u.set(d,p)}),u};return n.associations=l(i),i})}_createAnimationTracks(e,t,s,n,i){const r=[],a=e.name?e.name:e.uuid,c=[];B[i.path]===B.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(a);let l;switch(B[i.path]){case B.weights:l=f.NumberKeyframeTrack;break;case B.rotation:l=f.QuaternionKeyframeTrack;break;case B.translation:case B.scale:l=f.VectorKeyframeTrack;break;default:s.itemSize===1?l=f.NumberKeyframeTrack:l=f.VectorKeyframeTrack;break}const h=n.interpolation!==void 0?en[n.interpolation]:f.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let d=0,p=c.length;d<p;d++){const T=new l(c[d]+"."+B[i.path],t.array,u,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),r.push(T)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=de(t.constructor),n=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof f.QuaternionKeyframeTrack?Zt:Ve;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ln(o,e,t){const s=e.attributes,n=new f.Box3;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(n.set(new f.Vector3(c[0],c[1],c[2]),new f.Vector3(l[0],l[1],l[2])),a.normalized){const h=de(X[a.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new f.Vector3,c=new f.Vector3;for(let l=0,h=i.length;l<h;l++){const u=i[l];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],p=d.min,T=d.max;if(p!==void 0&&T!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(T[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(T[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(T[2]))),d.normalized){const g=de(X[d.componentType]);c.multiplyScalar(g)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}o.boundingBox=n;const r=new f.Sphere;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,o.boundingSphere=r}function ve(o,e,t){const s=e.attributes,n=[];function i(r,a){return t.getDependency("accessor",r).then(function(c){o.setAttribute(a,c)})}for(const r in s){const a=fe[r]||r.toLowerCase();a in o.attributes||n.push(i(s[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});n.push(r)}return f.ColorManagement.workingColorSpace!==f.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${f.ColorManagement.workingColorSpace}" not supported.`),F(o,e),ln(o,e,t),Promise.all(n).then(function(){return e.targets!==void 0?nn(o,e.targets,t):o})}const ce=new WeakMap;class un extends f.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 f.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,r=>{this.parse(r,t,n)},s,n)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,f.SRGBColorSpace,s).catch(s)}decodeDracoFile(e,t,s,n,i=f.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:i};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const s=JSON.stringify(t);if(ce.has(e)){const c=ce.get(e);if(c.key===s)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const i=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(i,r).then(c=>(n=c,new Promise((l,h)=>{n._callbacks[i]={resolve:l,reject:h},n.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),ce.set(e,{key:s,promise:a}),a}_createGeometry(e){const t=new f.BufferGeometry;e.index&&t.setIndex(new f.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const{name:n,array:i,itemSize:r,stride:a,vertexColorSpace:c}=e.attributes[s];let l;if(r===a)l=new f.BufferAttribute(i,r);else{const h=new f.InterleavedBuffer(i,a);l=new f.InterleavedBufferAttribute(h,r,0)}n==="color"&&(this._assignVertexColorSpace(l,c),l.normalized=!(i instanceof Float32Array)),t.setAttribute(n,l)}return t}_assignVertexColorSpace(e,t){if(t!==f.SRGBColorSpace)return;const s=new f.Color;for(let n=0,i=e.count;n<i;n++)s.fromBufferAttribute(e,n),f.ColorManagement.colorSpaceToWorking(s,f.SRGBColorSpace),e.setXYZ(n,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new f.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=hn.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
17
- `);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),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 r=i.data;switch(r.type){case"decode":n._callbacks[r.id].resolve(r);break;case"error":n._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.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.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function hn(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(h){o.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(o)});break;case"decode":const c=a.buffer,l=a.taskConfig;e.then(h=>{const u=h.draco,d=new u.Decoder;try{const p=t(u,d,new Int8Array(c),l),T=p.attributes.map(g=>g.array.buffer);p.index&&T.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},T)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{u.destroy(d)}});break}};function t(r,a,c,l){const h=l.attributeIDs,u=l.attributeTypes;let d,p;const T=a.GetEncodedGeometryType(c);if(T===r.TRIANGULAR_MESH)d=new r.Mesh,p=a.DecodeArrayToMesh(c,c.byteLength,d);else if(T===r.POINT_CLOUD)d=new r.PointCloud,p=a.DecodeArrayToPointCloud(c,c.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const g={index:null,attributes:[]};for(const m in h){const x=self[u[m]];let A,y;if(l.useUniqueIDs)y=h[m],A=a.GetAttributeByUniqueId(d,y);else{if(y=a.GetAttributeId(d,r[h[m]]),y===-1)continue;A=a.GetAttribute(d,y)}const R=n(r,a,d,m,x,A);m==="color"&&(R.vertexColorSpace=l.vertexColorSpace),g.attributes.push(R)}return T===r.TRIANGULAR_MESH&&(g.index=s(r,a,d)),r.destroy(d),g}function s(r,a,c){const h=c.num_faces()*3,u=h*4,d=r._malloc(u);a.GetTrianglesUInt32Array(c,u,d);const p=new Uint32Array(r.HEAPF32.buffer,d,h).slice();return r._free(d),{array:p,itemSize:1}}function n(r,a,c,l,h,u){const d=c.num_points(),p=u.num_components(),T=i(r,h),g=p*h.BYTES_PER_ELEMENT,m=Math.ceil(g/4)*4,x=m/h.BYTES_PER_ELEMENT,A=d*g,y=d*m,R=r._malloc(A);a.GetAttributeDataArrayForAllPoints(c,u,T,A,R);const b=new h(r.HEAPF32.buffer,R,A/h.BYTES_PER_ELEMENT);let S;if(g===m)S=b.slice();else{S=new h(y/h.BYTES_PER_ELEMENT);let _=0;for(let I=0,C=b.length;I<C;I++){for(let N=0;N<p;N++)S[_+N]=b[I*p+N];_+=x}}return r._free(R),{name:l,count:d,itemSize:p,array:S,stride:x}}function i(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}function fn(o){return"morphTargetDictionary"in o&&o.morphTargetDictionary!==void 0&&"morphTargetInfluences"in o&&Array.isArray(o.morphTargetInfluences)}const ze=new Mt,Xe=new un;Xe.setDecoderPath("/examples/jsm/libs/draco/");ze.setDRACOLoader(Xe);class dn extends Q{ready;model=null;constructor(e){super(),this.ready=this.asyncInit(e)}initObject(){return new L.Object3D}initNeedsUpdate(){return!0}async asyncInit(e){if(De(e)){const t=await ze.loadAsync(e),s=new L.AnimationMixer(t.scene),n={};console.log(`File: ${e}`),console.log(" actions:");for(let r=0;r<t.animations.length;r++){const a=t.animations[r],c=s.clipAction(a);n[a.name]=c,console.log(` ${a.name}`)}console.log(" morphs:");const i={};t.scene.traverse(r=>{if(fn(r)){const{morphTargetDictionary:a,morphTargetInfluences:c}=r;Object.keys(a).forEach(l=>{const h=r.name+"."+l,u=a[l];i[h]={array:c,idx:u},console.log(` ${h}`)})}}),this.model={gltf:t,mixer:s,actions:n,morphs:i},this.object.add(this.model.gltf.scene)}else{const t=new L.BoxGeometry,s=new L.MeshStandardMaterial({color:16711680}),n=new L.Mesh(t,s);this.object.add(n)}return this}change(e){if(this.model){this.model.mixer.stopAllAction();const t=this.model.actions[e];t&&t.play()}}morph(e,t){if(this.model){const{array:s,idx:n}=this.model.morphs[e];s[n]=t}}update(e){this.model&&this.model.mixer.update(e)}}function pn(o){return 2*o}exports.A3Camera=Ne;exports.A3Canvas=ke;exports.A3Object=Q;exports.A3Scene=Ie;exports.A3Test=st;exports.A3Text3D=_t;exports.A3ViewBase=pe;exports.A3Window=Oe;exports.A3glTF=dn;exports.GeneralCamera=me;exports.initFont=St;exports.times2=pn;
15
+ `;class Oe extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;isDragging=!1;offsetX=0;offsetY=0;constructor(e,t){super(),this.camera3js=new E.PerspectiveCamera(75,e/t,.1,1e3);const s=new ye(this.camera3js);this.base=new Te(s),this.scene=this.base.scene,this.camera=this.base.camera,this.renderer=new E.WebGLRenderer,this.clock=new E.Clock,this.camera3js.aspect=e/t,this.renderer.setSize(e,t),this.style=ct,document.body?document.body.appendChild(this):document.addEventListener("DOMContentLoaded",()=>{document.body.append(this)},{once:!0});const n=document.createElement("div");n.textContent="A3Window",n.style=lt,this.appendChild(n),n.addEventListener("mousedown",this.mouseDownListener),document.addEventListener("mousemove",this.mouseMoveListener),document.addEventListener("mouseup",this.mouseUpListener),this.renderer.domElement.style=`display: block; width: ${e}px; height: ${t}px; margin: 0; padding: 0;`,this.renderer.domElement.width=e,this.renderer.domElement.width=t,this.appendChild(this.renderer.domElement),this.animationFrameId=requestAnimationFrame(this.renderingLoop)}connectedCallback(){this.ro=new ResizeObserver(()=>{const{width:e,height:t}=this.renderer.domElement.getBoundingClientRect();this.camera3js.aspect=e/t,this.renderer.setSize(e,t)}),this.ro.observe(this)}disconnectedCallback(){this.ro?.disconnect()}mouseDownListener=e=>{this.isDragging=!0,this.offsetX=e.clientX-this.offsetLeft,this.offsetY=e.clientY-this.offsetTop};mouseMoveListener=e=>{this.isDragging&&(this.style.left=e.clientX-this.offsetX+"px",this.style.top=e.clientY-this.offsetY+"px")};mouseUpListener=()=>{this.isDragging=!1};replaceScene(e){return this.base.replaceScene(e)}animationFrameId=-1;renderingLoop=()=>{this.animationFrameId=requestAnimationFrame(this.renderingLoop);const e=this.clock.getDelta();this.scene&&(this.scene.update(e),this.renderer.render(this.scene.scene,this.camera3js))}}customElements.define("a3-window",Oe);class ut{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,s="ltr"){const n=[],i=ht(e,t,this.data,s);for(let r=0,a=i.length;r<a;r++)n.push(...i[r].toShapes());return n}}function ht(o,e,t,s){const n=Array.from(o),i=e/t.resolution,r=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,a=[];let c=0,l=0;(s=="rtl"||s=="tb")&&n.reverse();for(let h=0;h<n.length;h++){const u=n[h];if(u===`
16
+ `)c=0,l-=r;else{const f=dt(u,i,c,l,t);s=="tb"?(c=0,l+=t.ascender*i):c+=f.offsetX,a.push(f.path)}}return a}function dt(o,e,t,s,n){const i=n.glyphs[o]||n.glyphs["?"];if(!i){console.error('THREE.Font: character "'+o+'" does not exists in font family '+n.familyName+".");return}const r=new d.ShapePath;let a,c,l,h,u,f,p,T;if(i.o){const g=i._cachedOutline||(i._cachedOutline=i.o.split(" "));for(let m=0,y=g.length;m<y;)switch(g[m++]){case"m":a=g[m++]*e+t,c=g[m++]*e+s,r.moveTo(a,c);break;case"l":a=g[m++]*e+t,c=g[m++]*e+s,r.lineTo(a,c);break;case"q":l=g[m++]*e+t,h=g[m++]*e+s,u=g[m++]*e+t,f=g[m++]*e+s,r.quadraticCurveTo(u,f,l,h);break;case"b":l=g[m++]*e+t,h=g[m++]*e+s,u=g[m++]*e+t,f=g[m++]*e+s,p=g[m++]*e+t,T=g[m++]*e+s,r.bezierCurveTo(u,f,p,T,l,h);break}}return{offsetX:i.ha*e,path:r}}class ft extends d.ExtrudeGeometry{constructor(e,t={}){const s=t.font;if(s===void 0)super();else{const n=s.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(n,t)}this.type="TextGeometry"}}function Fe(o){return typeof o=="string"}var v=Uint8Array,V=Uint16Array,pt=Int32Array,Ge=new v([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]),Ue=new v([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]),mt=new v([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),He=function(o,e){for(var t=new V(31),s=0;s<31;++s)t[s]=e+=1<<o[s-1];for(var n=new pt(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{b:t,r:n}},Be=He(Ge,2),je=Be.b,gt=Be.r;je[28]=258,gt[258]=28;var Tt=He(Ue,0),yt=Tt.b,de=new V(32768);for(var b=0;b<32768;++b){var H=(b&43690)>>1|(b&21845)<<1;H=(H&52428)>>2|(H&13107)<<2,H=(H&61680)>>4|(H&3855)<<4,de[b]=((H&65280)>>8|(H&255)<<8)>>1}var Z=(function(o,e,t){for(var s=o.length,n=0,i=new V(e);n<s;++n)o[n]&&++i[o[n]-1];var r=new V(e);for(n=1;n<e;++n)r[n]=r[n-1]+i[n-1]<<1;var a;if(t){a=new V(1<<e);var c=15-e;for(n=0;n<s;++n)if(o[n])for(var l=n<<4|o[n],h=e-o[n],u=r[o[n]-1]++<<h,f=u|(1<<h)-1;u<=f;++u)a[de[u]>>c]=l}else for(a=new V(s),n=0;n<s;++n)o[n]&&(a[n]=de[r[o[n]-1]++]>>15-o[n]);return a}),Q=new v(288);for(var b=0;b<144;++b)Q[b]=8;for(var b=144;b<256;++b)Q[b]=9;for(var b=256;b<280;++b)Q[b]=7;for(var b=280;b<288;++b)Q[b]=8;var Ke=new v(32);for(var b=0;b<32;++b)Ke[b]=5;var xt=Z(Q,9,1),Rt=Z(Ke,5,1),re=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},P=function(o,e,t){var s=e/8|0;return(o[s]|o[s+1]<<8)>>(e&7)&t},ie=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},wt=function(o){return(o+7)/8|0},xe=function(o,e,t){return(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length),new v(o.subarray(e,t))},At=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],D=function(o,e,t){var s=new Error(e||At[o]);if(s.code=o,Error.captureStackTrace&&Error.captureStackTrace(s,D),!t)throw s;return s},bt=function(o,e,t,s){var n=o.length,i=s?s.length:0;if(!n||e.f&&!e.l)return t||new v(0);var r=!t,a=r||e.i!=2,c=e.i;r&&(t=new v(n*3));var l=function(Se){var _e=t.length;if(Se>_e){var Me=new v(Math.max(_e*2,Se));Me.set(t),t=Me}},h=e.f||0,u=e.p||0,f=e.b||0,p=e.l,T=e.d,g=e.m,m=e.n,y=n*8;do{if(!p){h=P(o,u,1);var A=P(o,u+1,3);if(u+=3,A)if(A==1)p=xt,T=Rt,g=9,m=5;else if(A==2){var S=P(o,u,31)+257,_=P(o,u+10,15)+4,I=S+P(o,u+5,31)+1;u+=14;for(var C=new v(I),N=new v(19),M=0;M<_;++M)N[mt[M]]=P(o,u+M*3,7);u+=_*3;for(var Re=re(N),Ye=(1<<Re)-1,Je=Z(N,Re,1),M=0;M<I;){var we=Je[P(o,u,Ye)];u+=we&15;var x=we>>4;if(x<16)C[M++]=x;else{var K=0,ee=0;for(x==16?(ee=3+P(o,u,3),u+=2,K=C[M-1]):x==17?(ee=3+P(o,u,7),u+=3):x==18&&(ee=11+P(o,u,127),u+=7);ee--;)C[M++]=K}}var Ae=C.subarray(0,S),U=C.subarray(S);g=re(Ae),m=re(U),p=Z(Ae,g,1),T=Z(U,m,1)}else D(1);else{var x=wt(u)+4,R=o[x-4]|o[x-3]<<8,L=x+R;if(L>n){c&&D(0);break}a&&l(f+R),t.set(o.subarray(x,L),f),e.b=f+=R,e.p=u=L*8,e.f=h;continue}if(u>y){c&&D(0);break}}a&&l(f+131072);for(var $e=(1<<g)-1,Ze=(1<<m)-1,te=u;;te=u){var K=p[ie(o,u)&$e],z=K>>4;if(u+=K&15,u>y){c&&D(0);break}if(K||D(2),z<256)t[f++]=z;else if(z==256){te=u,p=null;break}else{var be=z-254;if(z>264){var M=z-257,Y=Ge[M];be=P(o,u,(1<<Y)-1)+je[M],u+=Y}var ne=T[ie(o,u)&Ze],se=ne>>4;ne||D(3),u+=ne&15;var U=yt[se];if(se>3){var Y=Ue[se];U+=ie(o,u)&(1<<Y)-1,u+=Y}if(u>y){c&&D(0);break}a&&l(f+131072);var Ee=f+be;if(f<U){var Le=i-U,Qe=Math.min(U,Ee);for(Le+f<0&&D(3);f<Qe;++f)t[f]=s[Le+f]}for(;f<Ee;++f)t[f]=t[f-U]}}e.l=p,e.p=te,e.b=f,e.f=h,p&&(h=1,e.m=g,e.d=T,e.n=m)}while(!h);return f!=t.length&&r?xe(t,0,f):t.subarray(0,f)},Et=new v(0),G=function(o,e){return o[e]|o[e+1]<<8},O=function(o,e){return(o[e]|o[e+1]<<8|o[e+2]<<16|o[e+3]<<24)>>>0},oe=function(o,e){return O(o,e)+O(o,e+4)*4294967296};function Lt(o,e){return bt(o,{i:2},e&&e.out,e&&e.dictionary)}var fe=typeof TextDecoder<"u"&&new TextDecoder,St=0;try{fe.decode(Et,{stream:!0}),St=1}catch{}var _t=function(o){for(var e="",t=0;;){var s=o[t++],n=(s>127)+(s>223)+(s>239);if(t+n>o.length)return{s:e,r:xe(o,t-1)};n?n==3?(s=((s&15)<<18|(o[t++]&63)<<12|(o[t++]&63)<<6|o[t++]&63)-65536,e+=String.fromCharCode(55296|s>>10,56320|s&1023)):n&1?e+=String.fromCharCode((s&31)<<6|o[t++]&63):e+=String.fromCharCode((s&15)<<12|(o[t++]&63)<<6|o[t++]&63):e+=String.fromCharCode(s)}};function ze(o,e){if(e){for(var t="",s=0;s<o.length;s+=16384)t+=String.fromCharCode.apply(null,o.subarray(s,s+16384));return t}else{if(fe)return fe.decode(o);var n=_t(o),i=n.s,t=n.r;return t.length&&D(8),i}}var Mt=function(o,e){return e+30+G(o,e+26)+G(o,e+28)},Ct=function(o,e,t){var s=G(o,e+28),n=ze(o.subarray(e+46,e+46+s),!(G(o,e+8)&2048)),i=e+46+s,r=O(o,e+20),a=t&&r==4294967295?vt(o,i):[r,O(o,e+24),O(o,e+42)],c=a[0],l=a[1],h=a[2];return[G(o,e+10),c,l,n,i+G(o,e+30)+G(o,e+32),h]},vt=function(o,e){for(;G(o,e)!=1;e+=4+G(o,e+2));return[oe(o,e+12),oe(o,e+4),oe(o,e+20)]};function It(o,e){for(var t={},s=o.length-22;O(o,s)!=101010256;--s)(!s||o.length-s>65558)&&D(13);var n=G(o,s+8);if(!n)return{};var i=O(o,s+16),r=i==4294967295||n==65535;if(r){var a=O(o,s-12);r=O(o,a)==101075792,r&&(n=O(o,a+32),i=O(o,a+48))}for(var c=0;c<n;++c){var l=Ct(o,i,r),h=l[0],u=l[1],f=l[2],p=l[3],T=l[4],g=l[5],m=Mt(o,g);i=T,h?h==8?t[p]=Lt(o.subarray(m,m+u),{out:new v(f)}):D(14,"unknown compression type "+h):t[p]=xe(o,m,m+u)}return t}let pe=null;async function Nt(o){const e=o.substring(0,o.length-4),t=new E.FileLoader;t.setResponseType("arraybuffer");const s=await t.loadAsync(o),n=It(new Uint8Array(s)),i=ze(new Uint8Array(n[e].buffer));pe=new ut(JSON.parse(i))}class kt extends q{initObject(e){let t;if(Fe(e)?t=e:t="ERROR",pe==null){const s=new E.BoxGeometry,n=new E.MeshStandardMaterial({color:16711680});return new E.Mesh(s,n)}else{const s={font:pe,size:1,depth:.5,curveSegments:12},n=new ft(t,s);n.center();const i=new E.MeshStandardMaterial({color:65280});return new E.Mesh(n,i)}}}function Ce(o,e){if(e===d.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===d.TriangleFanDrawMode||e===d.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)r.push(c);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const s=t.count-2,n=[];if(e===d.TriangleFanDrawMode)for(let r=1;r<=s;r++)n.push(t.getX(0)),n.push(t.getX(r)),n.push(t.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(t.getX(r)),n.push(t.getX(r+1)),n.push(t.getX(r+2))):(n.push(t.getX(r+2)),n.push(t.getX(r+1)),n.push(t.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=o.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Dt extends d.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ut(t)}),this.register(function(t){return new Ht(t)}),this.register(function(t){return new Yt(t)}),this.register(function(t){return new Jt(t)}),this.register(function(t){return new $t(t)}),this.register(function(t){return new jt(t)}),this.register(function(t){return new Kt(t)}),this.register(function(t){return new zt(t)}),this.register(function(t){return new Vt(t)}),this.register(function(t){return new Gt(t)}),this.register(function(t){return new Xt(t)}),this.register(function(t){return new Bt(t)}),this.register(function(t){return new qt(t)}),this.register(function(t){return new Wt(t)}),this.register(function(t){return new Ot(t)}),this.register(function(t){return new Zt(t)}),this.register(function(t){return new Qt(t)})}load(e,t,s,n){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const l=d.LoaderUtils.extractUrlBase(e);r=d.LoaderUtils.resolveURL(l,this.path)}else r=d.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){n?n(l):console.error(l),i.manager.itemError(e),i.manager.itemEnd(e)},c=new d.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{i.parse(l,r,function(h){t(h),i.manager.itemEnd(e)},a)}catch(h){a(h)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}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 r={},a={},c=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ve){try{r[w.KHR_BINARY_GLTF]=new en(e)}catch(u){n&&n(u);return}i=JSON.parse(r[w.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.decode(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 l=new pn(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,r[u.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const u=i.extensionsUsed[h],f=i.extensionsRequired||[];switch(u){case w.KHR_MATERIALS_UNLIT:r[u]=new Ft;break;case w.KHR_DRACO_MESH_COMPRESSION:r[u]=new tn(i,this.dracoLoader);break;case w.KHR_TEXTURE_TRANSFORM:r[u]=new nn;break;case w.KHR_MESH_QUANTIZATION:r[u]=new sn;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(r),l.setPlugins(a),l.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function Pt(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const w={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Ot{constructor(e){this.parser=e,this.name=w.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,c=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let l;const h=new d.Color(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],d.LinearSRGBColorSpace);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new d.DirectionalLight(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new d.PointLight(h),l.distance=u;break;case"spot":l=new d.SpotLight(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),F(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),n=Promise.resolve(l),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],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return s._getNodeRef(t.cache,a,c)})}}class Ft{constructor(){this.name=w.KHR_MATERIALS_UNLIT}getMaterialType(){return d.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new d.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],d.LinearSRGBColorSpace),e.opacity=r[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,d.SRGBColorSpace))}return Promise.all(n)}}class Gt{constructor(e){this.parser=e,this.name=w.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 Ut{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new d.Vector2(a,a)}return Promise.all(i)}}class Ht{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Bt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class jt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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 d.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",r.sheenColorTexture,d.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class Kt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class zt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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=[],r=n.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),Promise.all(i)}}class Vt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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 Xt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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=[],r=n.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",r.specularColorTexture,d.SRGBColorSpace)),Promise.all(i)}}class Wt{constructor(e){this.parser=e,this.name=w.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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=[],r=n.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(i)}}class qt{constructor(e){this.parser=e,this.name=w.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.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=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class Yt{constructor(e){this.parser=e,this.name=w.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],r=t.options.ktx2Loader;if(!r){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,r)}}class Jt{constructor(e){this.parser=e,this.name=w.EXT_TEXTURE_WEBP}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 r=i.extensions[t],a=n.images[r.source];let c=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(c=l)}return s.loadTextureImage(e,r.source,c)}}class $t{constructor(e){this.parser=e,this.name=w.EXT_TEXTURE_AVIF}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 r=i.extensions[t],a=n.images[r.source];let c=s.textureLoader;if(a.uri){const l=s.options.manager.getHandler(a.uri);l!==null&&(c=l)}return s.loadTextureImage(e,r.source,c)}}class Zt{constructor(e){this.name=w.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),r=this.parser.options.meshoptDecoder;if(!r||!r.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(a){const c=n.byteOffset||0,l=n.byteLength||0,h=n.count,u=n.byteStride,f=new Uint8Array(a,c,l);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(h,u,f,n.mode,n.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(h*u);return r.decodeGltfBuffer(new Uint8Array(p),h,u,f,n.mode,n.filter),p})})}else return null}}class Qt{constructor(e){this.name=w.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 l of n.primitives)if(l.mode!==k.TRIANGLES&&l.mode!==k.TRIANGLE_STRIP&&l.mode!==k.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],c={};for(const l in r)a.push(this.parser.getDependency("accessor",r[l]).then(h=>(c[l]=h,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,p=[];for(const T of u){const g=new d.Matrix4,m=new d.Vector3,y=new d.Quaternion,A=new d.Vector3(1,1,1),x=new d.InstancedMesh(T.geometry,T.material,f);for(let R=0;R<f;R++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,R),c.ROTATION&&y.fromBufferAttribute(c.ROTATION,R),c.SCALE&&A.fromBufferAttribute(c.SCALE,R),x.setMatrixAt(R,g.compose(m,y,A));for(const R in c)if(R==="_COLOR_0"){const L=c[R];x.instanceColor=new d.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else R!=="TRANSLATION"&&R!=="ROTATION"&&R!=="SCALE"&&T.geometry.setAttribute(R,c[R]);d.Object3D.prototype.copy.call(x,T),this.parser.assignFinalMaterial(x),p.push(x)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const Ve="glTF",J=12,ve={JSON:1313821514,BIN:5130562};class en{constructor(e){this.name=w.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,J),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ve)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-J,i=new DataView(e,J);let r=0;for(;r<n;){const a=i.getUint32(r,!0);r+=4;const c=i.getUint32(r,!0);if(r+=4,c===ve.JSON){const l=new Uint8Array(e,J+r,a);this.content=s.decode(l)}else if(c===ve.BIN){const l=J+r;this.body=e.slice(l,l+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=w.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,r=e.extensions[this.name].attributes,a={},c={},l={};for(const h in r){const u=me[h]||h.toLowerCase();a[u]=r[h]}for(const h in e.attributes){const u=me[h]||h.toLowerCase();if(r[h]!==void 0){const f=s.accessors[e.attributes[h]],p=W[f.componentType];l[u]=p.name,c[u]=f.normalized===!0}}return t.getDependency("bufferView",i).then(function(h){return new Promise(function(u,f){n.decodeDracoFile(h,function(p){for(const T in p.attributes){const g=p.attributes[T],m=c[T];m!==void 0&&(g.normalized=m)}u(p)},a,l,d.LinearSRGBColorSpace,f)})})}}class nn{constructor(){this.name=w.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 sn{constructor(){this.name=w.KHR_MESH_QUANTIZATION}}class Xe extends d.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 r=0;r!==n;r++)t[r]=s[i+r];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=n-t,u=(s-t)/h,f=u*u,p=f*u,T=e*l,g=T-l,m=-2*p+3*f,y=p-f,A=1-m,x=y-f+u;for(let R=0;R!==a;R++){const L=r[g+R+a],S=r[g+R+c]*h,_=r[T+R+a],I=r[T+R]*h;i[R]=A*L+x*S+m*_+y*I}return i}}const rn=new d.Quaternion;class on extends Xe{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return rn.fromArray(i).normalize().toArray(i),i}}const k={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},W={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ie={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},Ne={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},ae={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},me={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},B={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},an={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},ce={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function cn(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new d.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:d.FrontSide})),o.DefaultMaterial}function j(o,e,t){for(const s in t.extensions)o[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function F(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ln(o,e,t){let s=!1,n=!1,i=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(o);const r=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(s){const f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):o.attributes.position;r.push(f)}if(n){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):o.attributes.normal;a.push(f)}if(i){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):o.attributes.color;c.push(f)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],f=l[2];return s&&(o.morphAttributes.position=h),n&&(o.morphAttributes.normal=u),i&&(o.morphAttributes.color=f),o.morphTargetsRelative=!0,o})}function un(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)o.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function hn(o){let e;const t=o.extensions&&o.extensions[w.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+le(t.attributes):e=o.indices+":"+le(o.attributes)+":"+o.mode,o.targets!==void 0)for(let s=0,n=o.targets.length;s<n;s++)e+=":"+le(o.targets[s]);return e}function le(o){let e="";const t=Object.keys(o).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+o[t[s]]+";";return e}function ge(o){switch(o){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 dn(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const fn=new d.Matrix4;class pn{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Pt,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,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);n=s&&c?parseInt(c[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&r<98?this.textureLoader=new d.TextureLoader(this.options.manager):this.textureLoader=new d.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.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(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return j(i,a,n),F(a,n),Promise.all(s._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();e(a)})}).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 r=t[n].joints;for(let a=0,c=r.length;a<c;a++)e[r[a]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const r=e[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.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=(r,a)=>{const c=this.associations.get(r);c!=null&&this.associations.set(a,c);for(const[l,h]of r.children.entries())i(h,a.children[l])};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,r){return s.getDependency(e,r)})),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[w.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,r){s.load(d.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){r(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 r=ae[n.type],a=W[n.componentType],c=n.normalized===!0,l=new a(n.count*r);return Promise.resolve(new d.BufferAttribute(l,r,c))}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(r){const a=r[0],c=ae[n.type],l=W[n.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,f=n.byteOffset||0,p=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,T=n.normalized===!0;let g,m;if(p&&p!==u){const y=Math.floor(f/p),A="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+y+":"+n.count;let x=t.cache.get(A);x||(g=new l(a,y*p,n.count*p/h),x=new d.InterleavedBuffer(g,p/h),t.cache.add(A,x)),m=new d.InterleavedBufferAttribute(x,c,f%p/h,T)}else a===null?g=new l(n.count*c):g=new l(a,f,n.count*c),m=new d.BufferAttribute(g,c,T);if(n.sparse!==void 0){const y=ae.SCALAR,A=W[n.sparse.indices.componentType],x=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,L=new A(r[1],x,n.sparse.count*y),S=new l(r[2],R,n.sparse.count*c);a!==null&&(m=new d.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let _=0,I=L.length;_<I;_++){const C=L[_];if(m.setX(C,S[_*c]),c>=2&&m.setY(C,S[_*c+1]),c>=3&&m.setZ(C,S[_*c+2]),c>=4&&m.setW(C,S[_*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=T}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const c=s.manager.getHandler(r.uri);c!==null&&(a=c)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,s){const n=this,i=this.json,r=i.textures[e],a=i.images[t],c=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,s).then(function(h){h.flipY=!1,h.name=r.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(i.samplers||{})[r.sampler]||{};return h.magFilter=Ie[f.magFilter]||d.LinearFilter,h.minFilter=Ie[f.minFilter]||d.LinearMipmapLinearFilter,h.wrapS=Ne[f.wrapS]||d.RepeatWrapping,h.wrapT=Ne[f.wrapT]||d.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==d.NearestFilter&&h.minFilter!==d.LinearFilter,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const r=n.images[e],a=self.URL||self.webkitURL;let c=r.uri||"",l=!1;if(r.bufferView!==void 0)c=s.getDependency("bufferView",r.bufferView).then(function(u){l=!0;const f=new Blob([u],{type:r.mimeType});return c=a.createObjectURL(f),c});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(f,p){let T=f;t.isImageBitmapLoader===!0&&(T=function(g){const m=new d.Texture(g);m.needsUpdate=!0,f(m)}),t.load(d.LoaderUtils.resolveURL(u,i.path),T,void 0,p)})}).then(function(u){return l===!0&&a.revokeObjectURL(c),F(u,r),u.userData.mimeType=r.mimeType||dn(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[w.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[w.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=i.associations.get(r);r=i.extensions[w.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,c)}}return n!==void 0&&(r.colorSpace=n),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let c=this.cache.get(a);c||(c=new d.PointsMaterial,d.Material.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,c.sizeAttenuation=!1,this.cache.add(a,c)),s=c}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let c=this.cache.get(a);c||(c=new d.LineBasicMaterial,d.Material.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,this.cache.add(a,c)),s=c}if(n||i||r){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=s.clone(),i&&(c.vertexColors=!0),r&&(c.flatShading=!0),n&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(s))),s=c}e.material=s}getMaterialType(){return d.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let r;const a={},c=i.extensions||{},l=[];if(c[w.KHR_MATERIALS_UNLIT]){const u=n[w.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),l.push(u.extendParams(a,i,t))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new d.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],d.LinearSRGBColorSpace),a.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,d.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=d.DoubleSide);const h=i.alphaMode||ce.OPAQUE;if(h===ce.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===ce.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==d.MeshBasicMaterial&&(l.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new d.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&r!==d.MeshBasicMaterial&&(l.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==d.MeshBasicMaterial){const u=i.emissiveFactor;a.emissive=new d.Color().setRGB(u[0],u[1],u[2],d.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&r!==d.MeshBasicMaterial&&l.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,d.SRGBColorSpace)),Promise.all(l).then(function(){const u=new r(a);return i.name&&(u.name=i.name),F(u,i),t.associations.set(u,{materials:e}),i.extensions&&j(n,u,i),u})}createUniqueName(e){const t=d.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(a){return s[w.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return ke(c,a,t)})}const r=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],h=hn(l),u=n[h];if(u)r.push(u.promise);else{let f;l.extensions&&l.extensions[w.KHR_DRACO_MESH_COMPRESSION]?f=i(l):f=ke(new d.BufferGeometry,l,t),n[h]={primitive:l,promise:f},r.push(f)}}return Promise.all(r)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],r=i.primitives,a=[];for(let c=0,l=r.length;c<l;c++){const h=r[c].material===void 0?cn(this.cache):this.getDependency("material",r[c].material);a.push(h)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let p=0,T=h.length;p<T;p++){const g=h[p],m=r[p];let y;const A=l[p];if(m.mode===k.TRIANGLES||m.mode===k.TRIANGLE_STRIP||m.mode===k.TRIANGLE_FAN||m.mode===void 0)y=i.isSkinnedMesh===!0?new d.SkinnedMesh(g,A):new d.Mesh(g,A),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),m.mode===k.TRIANGLE_STRIP?y.geometry=Ce(y.geometry,d.TriangleStripDrawMode):m.mode===k.TRIANGLE_FAN&&(y.geometry=Ce(y.geometry,d.TriangleFanDrawMode));else if(m.mode===k.LINES)y=new d.LineSegments(g,A);else if(m.mode===k.LINE_STRIP)y=new d.Line(g,A);else if(m.mode===k.LINE_LOOP)y=new d.LineLoop(g,A);else if(m.mode===k.POINTS)y=new d.Points(g,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(y.geometry.morphAttributes).length>0&&un(y,i),y.name=t.createUniqueName(i.name||"mesh_"+e),F(y,i),m.extensions&&j(n,y,m),t.assignFinalMaterial(y),u.push(y)}for(let p=0,T=u.length;p<T;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return i.extensions&&j(n,u[0],i),u[0];const f=new d.Group;i.extensions&&j(n,f,i),t.associations.set(f,{meshes:e});for(let p=0,T=u.length;p<T;p++)f.add(u[p]);return f})}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 d.PerspectiveCamera(d.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new d.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),F(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(),r=n,a=[],c=[];for(let l=0,h=r.length;l<h;l++){const u=r[l];if(u){a.push(u);const f=new d.Matrix4;i!==null&&f.fromArray(i.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new d.Skeleton(a,c)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,r=[],a=[],c=[],l=[],h=[];for(let u=0,f=n.channels.length;u<f;u++){const p=n.channels[u],T=n.samplers[p.sampler],g=p.target,m=g.node,y=n.parameters!==void 0?n.parameters[T.input]:T.input,A=n.parameters!==void 0?n.parameters[T.output]:T.output;g.node!==void 0&&(r.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",y)),c.push(this.getDependency("accessor",A)),l.push(T),h.push(g))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const f=u[0],p=u[1],T=u[2],g=u[3],m=u[4],y=[];for(let x=0,R=f.length;x<R;x++){const L=f[x],S=p[x],_=T[x],I=g[x],C=m[x];if(L===void 0)continue;L.updateMatrix&&L.updateMatrix();const N=s._createAnimationTracks(L,S,_,I,C);if(N)for(let M=0;M<N.length;M++)y.push(N[M])}const A=new d.AnimationClip(i,void 0,y);return F(A,n),A})}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 r=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let c=0,l=n.weights.length;c<l;c++)a.morphTargetInfluences[c]=n.weights[c]}),r})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),r=[],a=n.children||[];for(let l=0,h=a.length;l<h;l++)r.push(s.getDependency("node",a[l]));const c=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),c]).then(function(l){const h=l[0],u=l[1],f=l[2];f!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(f,fn)});for(let p=0,T=u.length;p<T;p++)h.add(u[p]);return h})}_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],r=i.name?n.createUniqueName(i.name):"",a=[],c=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(i.isBone===!0?h=new d.Bone:l.length>1?h=new d.Group:l.length===1?h=l[0]:h=new d.Object3D,h!==l[0])for(let u=0,f=l.length;u<f;u++)h.add(l[u]);if(i.name&&(h.userData.name=i.name,h.name=r),F(h,i),i.extensions&&j(s,h,i),i.matrix!==void 0){const u=new d.Matrix4;u.fromArray(i.matrix),h.applyMatrix4(u)}else i.translation!==void 0&&h.position.fromArray(i.translation),i.rotation!==void 0&&h.quaternion.fromArray(i.rotation),i.scale!==void 0&&h.scale.fromArray(i.scale);if(!n.associations.has(h))n.associations.set(h,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const u=n.associations.get(h);n.associations.set(h,{...u})}return n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new d.Group;s.name&&(i.name=n.createUniqueName(s.name)),F(i,s),s.extensions&&j(t,i,s);const r=s.nodes||[],a=[];for(let c=0,l=r.length;c<l;c++)a.push(n.getDependency("node",r[c]));return Promise.all(a).then(function(c){for(let h=0,u=c.length;h<u;h++)i.add(c[h]);const l=h=>{const u=new Map;for(const[f,p]of n.associations)(f instanceof d.Material||f instanceof d.Texture)&&u.set(f,p);return h.traverse(f=>{const p=n.associations.get(f);p!=null&&u.set(f,p)}),u};return n.associations=l(i),i})}_createAnimationTracks(e,t,s,n,i){const r=[],a=e.name?e.name:e.uuid,c=[];B[i.path]===B.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(B[i.path]){case B.weights:l=d.NumberKeyframeTrack;break;case B.rotation:l=d.QuaternionKeyframeTrack;break;case B.translation:case B.scale:l=d.VectorKeyframeTrack;break;default:s.itemSize===1?l=d.NumberKeyframeTrack:l=d.VectorKeyframeTrack;break}const h=n.interpolation!==void 0?an[n.interpolation]:d.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let f=0,p=c.length;f<p;f++){const T=new l(c[f]+"."+B[i.path],t.array,u,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),r.push(T)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=ge(t.constructor),n=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof d.QuaternionKeyframeTrack?on:Xe;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function mn(o,e,t){const s=e.attributes,n=new d.Box3;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(n.set(new d.Vector3(c[0],c[1],c[2]),new d.Vector3(l[0],l[1],l[2])),a.normalized){const h=ge(W[a.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new d.Vector3,c=new d.Vector3;for(let l=0,h=i.length;l<h;l++){const u=i[l];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],p=f.min,T=f.max;if(p!==void 0&&T!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(T[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(T[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(T[2]))),f.normalized){const g=ge(W[f.componentType]);c.multiplyScalar(g)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}o.boundingBox=n;const r=new d.Sphere;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,o.boundingSphere=r}function ke(o,e,t){const s=e.attributes,n=[];function i(r,a){return t.getDependency("accessor",r).then(function(c){o.setAttribute(a,c)})}for(const r in s){const a=me[r]||r.toLowerCase();a in o.attributes||n.push(i(s[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});n.push(r)}return d.ColorManagement.workingColorSpace!==d.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${d.ColorManagement.workingColorSpace}" not supported.`),F(o,e),mn(o,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ln(o,e.targets,t):o})}const ue=new WeakMap;class gn extends d.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 d.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,r=>{this.parse(r,t,n)},s,n)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,d.SRGBColorSpace,s).catch(s)}decodeDracoFile(e,t,s,n,i=d.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:i};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const s=JSON.stringify(t);if(ue.has(e)){const c=ue.get(e);if(c.key===s)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const i=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(i,r).then(c=>(n=c,new Promise((l,h)=>{n._callbacks[i]={resolve:l,reject:h},n.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),ue.set(e,{key:s,promise:a}),a}_createGeometry(e){const t=new d.BufferGeometry;e.index&&t.setIndex(new d.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const{name:n,array:i,itemSize:r,stride:a,vertexColorSpace:c}=e.attributes[s];let l;if(r===a)l=new d.BufferAttribute(i,r);else{const h=new d.InterleavedBuffer(i,a);l=new d.InterleavedBufferAttribute(h,r,0)}n==="color"&&(this._assignVertexColorSpace(l,c),l.normalized=!(i instanceof Float32Array)),t.setAttribute(n,l)}return t}_assignVertexColorSpace(e,t){if(t!==d.SRGBColorSpace)return;const s=new d.Color;for(let n=0,i=e.count;n<i;n++)s.fromBufferAttribute(e,n),d.ColorManagement.colorSpaceToWorking(s,d.SRGBColorSpace),e.setXYZ(n,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new d.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=Tn.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
17
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),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 r=i.data;switch(r.type){case"decode":n._callbacks[r.id].resolve(r);break;case"error":n._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.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.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Tn(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(h){o.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(o)});break;case"decode":const c=a.buffer,l=a.taskConfig;e.then(h=>{const u=h.draco,f=new u.Decoder;try{const p=t(u,f,new Int8Array(c),l),T=p.attributes.map(g=>g.array.buffer);p.index&&T.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},T)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{u.destroy(f)}});break}};function t(r,a,c,l){const h=l.attributeIDs,u=l.attributeTypes;let f,p;const T=a.GetEncodedGeometryType(c);if(T===r.TRIANGULAR_MESH)f=new r.Mesh,p=a.DecodeArrayToMesh(c,c.byteLength,f);else if(T===r.POINT_CLOUD)f=new r.PointCloud,p=a.DecodeArrayToPointCloud(c,c.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const g={index:null,attributes:[]};for(const m in h){const y=self[u[m]];let A,x;if(l.useUniqueIDs)x=h[m],A=a.GetAttributeByUniqueId(f,x);else{if(x=a.GetAttributeId(f,r[h[m]]),x===-1)continue;A=a.GetAttribute(f,x)}const R=n(r,a,f,m,y,A);m==="color"&&(R.vertexColorSpace=l.vertexColorSpace),g.attributes.push(R)}return T===r.TRIANGULAR_MESH&&(g.index=s(r,a,f)),r.destroy(f),g}function s(r,a,c){const h=c.num_faces()*3,u=h*4,f=r._malloc(u);a.GetTrianglesUInt32Array(c,u,f);const p=new Uint32Array(r.HEAPF32.buffer,f,h).slice();return r._free(f),{array:p,itemSize:1}}function n(r,a,c,l,h,u){const f=c.num_points(),p=u.num_components(),T=i(r,h),g=p*h.BYTES_PER_ELEMENT,m=Math.ceil(g/4)*4,y=m/h.BYTES_PER_ELEMENT,A=f*g,x=f*m,R=r._malloc(A);a.GetAttributeDataArrayForAllPoints(c,u,T,A,R);const L=new h(r.HEAPF32.buffer,R,A/h.BYTES_PER_ELEMENT);let S;if(g===m)S=L.slice();else{S=new h(x/h.BYTES_PER_ELEMENT);let _=0;for(let I=0,C=L.length;I<C;I++){for(let N=0;N<p;N++)S[_+N]=L[I*p+N];_+=y}}return r._free(R),{name:l,count:f,itemSize:p,array:S,stride:y}}function i(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}function yn(o){return"morphTargetDictionary"in o&&o.morphTargetDictionary!==void 0&&"morphTargetInfluences"in o&&Array.isArray(o.morphTargetInfluences)}const We=new Dt,qe=new gn;qe.setDecoderPath("/examples/jsm/libs/draco/");We.setDRACOLoader(qe);class xn extends q{ready;model=null;constructor(e){super(),this.ready=this.asyncInit(e)}initObject(){return new E.Object3D}initNeedsUpdate(){return!0}async asyncInit(e){if(Fe(e)){const t=await We.loadAsync(e),s=new E.AnimationMixer(t.scene),n={};console.log(`File: ${e}`),console.log(" actions:");for(let r=0;r<t.animations.length;r++){const a=t.animations[r],c=s.clipAction(a);n[a.name]=c,console.log(` ${a.name}`)}console.log(" morphs:");const i={};t.scene.traverse(r=>{if(yn(r)){const{morphTargetDictionary:a,morphTargetInfluences:c}=r;Object.keys(a).forEach(l=>{const h=r.name+"."+l,u=a[l];i[h]={array:c,idx:u},console.log(` ${h}`)})}}),this.model={gltf:t,mixer:s,actions:n,morphs:i},this.object.add(this.model.gltf.scene)}else{const t=new E.BoxGeometry,s=new E.MeshStandardMaterial({color:16711680}),n=new E.Mesh(t,s);this.object.add(n)}return this}change(e){if(this.model){this.model.mixer.stopAllAction();const t=this.model.actions[e];t&&t.play()}}morph(e,t){if(this.model){const{array:s,idx:n}=this.model.morphs[e];s[n]=t}}update(e){this.model&&this.model.mixer.update(e)}}class Rn extends q{constructor(e){super(e)}initObject(e){return e}}function wn(o){return 2*o}exports.A3Camera=De;exports.A3Canvas=Pe;exports.A3Object=q;exports.A3Scene=X;exports.A3Test=st;exports.A3Text3D=kt;exports.A3ViewBase=Te;exports.A3Window=Oe;exports.A3glTF=xn;exports.GeneralCamera=ye;exports.ThreeJS=Rn;exports.initFont=Nt;exports.times2=wn;