a3js 0.0.8 → 0.0.10
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 +4 -4
- package/dist/a3js.es.js +139 -114
- package/package.json +1 -1
package/dist/a3js.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("three");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("three");function nt(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 _=nt(d);class De{_x;_y;_z;get x(){return this._x}get y(){return this._y}get z(){return this._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 Pe{_x;_y;_z;_w;get x(){return this._x}get y(){return this._y}get z(){return this._z}get w(){return this._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 De(0,0,0);_rot=new Pe(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 _.BoxGeometry,t=new _.MeshStandardMaterial({color:65280});return new _.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 _.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 Oe 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 Oe{camera;headLight;constructor(e){super(e),this.camera=e,this.headLight=new _.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 _.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 Fe extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;constructor(e){super(),e||(e={}),e.camera||(e.camera=new _.PerspectiveCamera(75,300/150,.1,1e3)),this.camera3js=e.camera;const t=new ye(e.camera);this.base=new Te(t),this.scene=this.base.scene,this.camera=this.base.camera;const s={antialias:e.antialias?e.antialias:!1,alpha:e.transparent?e.transparent:!1};this.renderer=new _.WebGLRenderer(s),"opaque"in e&&this.renderer.setClearAlpha(0),this.clock=new _.Clock,this.style="display: block; background: rgba(0,0,0,0);",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",Fe);function at(o){return o.isPerspectiveCamera===!0}const ct=`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 100px;
|
|
4
4
|
left: 100px;
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
padding: 8px;
|
|
13
13
|
cursor: move;
|
|
14
14
|
user-select: none; /* 文字選択を防ぐ */
|
|
15
|
-
`;class
|
|
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
|
|
15
|
+
`;class Ge extends HTMLElement{ro;base;renderer;scene;camera;camera3js;clock;isDragging=!1;offsetX=0;offsetY=0;constructor(e,t){super(),this.camera3js=new _.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 _.WebGLRenderer,this.clock=new _.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",Ge);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 Ue(o){return typeof o=="string"}var v=Uint8Array,V=Uint16Array,pt=Int32Array,He=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]),Be=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]),je=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}},Ke=je(He,2),ze=Ke.b,gt=Ke.r;ze[28]=258,gt[258]=28;var Tt=je(Be,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 Q=(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}),Z=new v(288);for(var b=0;b<144;++b)Z[b]=8;for(var b=144;b<256;++b)Z[b]=9;for(var b=256;b<280;++b)Z[b]=7;for(var b=280;b<288;++b)Z[b]=8;var Ve=new v(32);for(var b=0;b<32;++b)Ve[b]=5;var xt=Q(Z,9,1),wt=Q(Ve,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)},Rt=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(Le){var Se=t.length;if(Le>Se){var Me=new v(Math.max(Se*2,Le));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=wt,g=9,m=5;else if(A==2){var L=P(o,u,31)+257,S=P(o,u+10,15)+4,I=L+P(o,u+5,31)+1;u+=14;for(var C=new v(I),N=new v(19),M=0;M<S;++M)N[mt[M]]=P(o,u+M*3,7);u+=S*3;for(var we=re(N),$e=(1<<we)-1,Qe=Q(N,we,1),M=0;M<I;){var Re=Qe[P(o,u,$e)];u+=Re&15;var x=Re>>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,L),U=C.subarray(L);g=re(Ae),m=re(U),p=Q(Ae,g,1),T=Q(U,m,1)}else D(1);else{var x=Rt(u)+4,w=o[x-4]|o[x-3]<<8,E=x+w;if(E>n){c&&D(0);break}a&&l(f+w),t.set(o.subarray(x,E),f),e.b=f+=w,e.p=u=E*8,e.f=h;continue}if(u>y){c&&D(0);break}}a&&l(f+131072);for(var Ze=(1<<g)-1,et=(1<<m)-1,te=u;;te=u){var K=p[ie(o,u)&Ze],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=He[M];be=P(o,u,(1<<Y)-1)+ze[M],u+=Y}var ne=T[ie(o,u)&et],se=ne>>4;ne||D(3),u+=ne&15;var U=yt[se];if(se>3){var Y=Be[se];U+=ie(o,u)&(1<<Y)-1,u+=Y}if(u>y){c&&D(0);break}a&&l(f+131072);var _e=f+be;if(f<U){var Ee=i-U,tt=Math.min(U,_e);for(Ee+f<0&&D(3);f<tt;++f)t[f]=s[Ee+f]}for(;f<_e;++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)},_t=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 Et(o,e){return bt(o,{i:2},e&&e.out,e&&e.dictionary)}var fe=typeof TextDecoder<"u"&&new TextDecoder,Lt=0;try{fe.decode(_t,{stream:!0}),Lt=1}catch{}var St=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 Xe(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=St(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=Xe(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]=Et(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 _.FileLoader;t.setResponseType("arraybuffer");const s=await t.loadAsync(o),n=It(new Uint8Array(s)),i=Xe(new Uint8Array(n[e].buffer));pe=new ut(JSON.parse(i))}class kt extends q{initObject(e){let t;if(Ue(e)?t=e:t="ERROR",pe==null){const s=new _.BoxGeometry,n=new _.MeshStandardMaterial({color:16711680});return new _.Mesh(s,n)}else{const s={font:pe,size:1,depth:.5,curveSegments:12},n=new ft(t,s);n.center();const i=new _.MeshStandardMaterial({color:65280});return new _.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 Qt(t)}),this.register(function(t){return new Zt(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))===We){try{r[R.KHR_BINARY_GLTF]=new en(e)}catch(u){n&&n(u);return}i=JSON.parse(r[R.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 R.KHR_MATERIALS_UNLIT:r[u]=new Ft;break;case R.KHR_DRACO_MESH_COMPRESSION:r[u]=new tn(i,this.dracoLoader);break;case R.KHR_TEXTURE_TRANSFORM:r[u]=new nn;break;case R.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 R={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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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=R.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 Qt{constructor(e){this.name=R.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 Zt{constructor(e){this.name=R.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 w=0;w<f;w++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,w),c.ROTATION&&y.fromBufferAttribute(c.ROTATION,w),c.SCALE&&A.fromBufferAttribute(c.SCALE,w),x.setMatrixAt(w,g.compose(m,y,A));for(const w in c)if(w==="_COLOR_0"){const E=c[w];x.instanceColor=new d.InstancedBufferAttribute(E.array,E.itemSize,E.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&T.geometry.setAttribute(w,c[w]);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 We="glTF",J=12,ve={JSON:1313821514,BIN:5130562};class en{constructor(e){this.name=R.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!==We)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=R.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=R.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=R.KHR_MESH_QUANTIZATION}}class qe 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 w=0;w!==a;w++){const E=r[g+w+a],L=r[g+w+c]*h,S=r[T+w+a],I=r[T+w]*h;i[w]=A*E+x*L+m*S+y*I}return i}}const rn=new d.Quaternion;class on extends qe{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[R.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[R.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,w=n.sparse.values.byteOffset||0,E=new A(r[1],x,n.sparse.count*y),L=new l(r[2],w,n.sparse.count*c);a!==null&&(m=new d.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let S=0,I=E.length;S<I;S++){const C=E[S];if(m.setX(C,L[S*c]),c>=2&&m.setY(C,L[S*c+1]),c>=3&&m.setZ(C,L[S*c+2]),c>=4&&m.setW(C,L[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[R.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[R.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=i.associations.get(r);r=i.extensions[R.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[R.KHR_MATERIALS_UNLIT]){const u=n[R.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[R.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[R.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,w=f.length;x<w;x++){const E=f[x],L=p[x],S=T[x],I=g[x],C=m[x];if(E===void 0)continue;E.updateMatrix&&E.updateMatrix();const N=s._createAnimationTracks(E,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:qe;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 w=n(r,a,f,m,y,A);m==="color"&&(w.vertexColorSpace=l.vertexColorSpace),g.attributes.push(w)}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,w=r._malloc(A);a.GetAttributeDataArrayForAllPoints(c,u,T,A,w);const E=new h(r.HEAPF32.buffer,w,A/h.BYTES_PER_ELEMENT);let L;if(g===m)L=E.slice();else{L=new h(x/h.BYTES_PER_ELEMENT);let S=0;for(let I=0,C=E.length;I<C;I++){for(let N=0;N<p;N++)L[S+N]=E[I*p+N];S+=y}}return r._free(w),{name:l,count:f,itemSize:p,array:L,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 Ye=new Dt,Je=new gn;Je.setDecoderPath("/examples/jsm/libs/draco/");Ye.setDRACOLoader(Je);class xn extends q{ready;model=null;constructor(e){super(),this.ready=this.asyncInit(e),this.needsUpdate=!0}initObject(){return new _.Object3D}async asyncInit(e){if(Ue(e)){const t=await Ye.loadAsync(e),s=new _.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 _.BoxGeometry,s=new _.MeshStandardMaterial({color:16711680}),n=new _.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 wn extends q{constructor(e){super(e)}initObject(e){return e}}function Rn(o){return 2*o}exports.A3Camera=Oe;exports.A3Canvas=Fe;exports.A3Object=q;exports.A3Scene=X;exports.A3Test=st;exports.A3Text3D=kt;exports.A3ViewBase=Te;exports.A3Window=Ge;exports.A3glTF=xn;exports.GeneralCamera=ye;exports.Quat=Pe;exports.ThreeJS=wn;exports.Vec3=De;exports.initFont=Nt;exports.times2=Rn;
|
package/dist/a3js.es.js
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { ShapePath as Mt, ExtrudeGeometry as vt, TrianglesDrawMode as It, TriangleFanDrawMode as
|
|
1
|
+
import * as E from "three";
|
|
2
|
+
import { ShapePath as Mt, ExtrudeGeometry as vt, TrianglesDrawMode as It, TriangleFanDrawMode as _e, TriangleStripDrawMode as $e, Loader as Ze, LoaderUtils as ee, FileLoader as ce, MeshPhysicalMaterial as U, Vector2 as Qe, Color as z, LinearSRGBColorSpace as H, SRGBColorSpace as K, SpotLight as Ct, PointLight as Nt, DirectionalLight as kt, Matrix4 as le, Vector3 as q, Quaternion as et, InstancedMesh as Dt, InstancedBufferAttribute as Pt, Object3D as tt, TextureLoader as Ot, ImageBitmapLoader as Ft, BufferAttribute as te, InterleavedBuffer as nt, InterleavedBufferAttribute as st, LinearMipmapLinearFilter as rt, NearestMipmapLinearFilter as Ht, LinearMipmapNearestFilter as Ut, NearestMipmapNearestFilter as Gt, LinearFilter as Ee, NearestFilter as it, RepeatWrapping as Ae, MirroredRepeatWrapping as jt, ClampToEdgeWrapping as Bt, PointsMaterial as Kt, Material as fe, LineBasicMaterial as zt, MeshStandardMaterial as ot, DoubleSide as Vt, MeshBasicMaterial as Q, PropertyBinding as Xt, BufferGeometry as at, SkinnedMesh as Wt, Mesh as qt, LineSegments as Yt, Line as Jt, LineLoop as $t, Points as Zt, Group as pe, PerspectiveCamera as Qt, MathUtils as en, OrthographicCamera as tn, Skeleton as nn, AnimationClip as sn, Bone as rn, InterpolateDiscrete as on, InterpolateLinear as ct, Texture as Be, VectorKeyframeTrack as Ke, NumberKeyframeTrack as ze, QuaternionKeyframeTrack as Ve, ColorManagement as be, FrontSide as an, Interpolant as cn, Box3 as ln, Sphere as un } from "three";
|
|
3
3
|
class hn {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
_x;
|
|
5
|
+
_y;
|
|
6
|
+
_z;
|
|
7
|
+
get x() {
|
|
8
|
+
return this._x;
|
|
9
|
+
}
|
|
10
|
+
get y() {
|
|
11
|
+
return this._y;
|
|
12
|
+
}
|
|
13
|
+
get z() {
|
|
14
|
+
return this._z;
|
|
15
|
+
}
|
|
7
16
|
constructor(e, t, s) {
|
|
8
|
-
this.
|
|
17
|
+
this._x = e, this._y = t, this._z = s;
|
|
9
18
|
}
|
|
10
19
|
set(e, t, s) {
|
|
11
|
-
this.
|
|
20
|
+
this._x = e, this._y = t, this._z = s;
|
|
12
21
|
}
|
|
13
22
|
add(e) {
|
|
14
|
-
return this.
|
|
23
|
+
return this._x += e.x, this._y += e.y, this._z += e.z, this;
|
|
15
24
|
}
|
|
16
25
|
}
|
|
17
26
|
class dn {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
_x;
|
|
28
|
+
_y;
|
|
29
|
+
_z;
|
|
30
|
+
_w;
|
|
31
|
+
get x() {
|
|
32
|
+
return this._x;
|
|
33
|
+
}
|
|
34
|
+
get y() {
|
|
35
|
+
return this._y;
|
|
36
|
+
}
|
|
37
|
+
get z() {
|
|
38
|
+
return this._z;
|
|
39
|
+
}
|
|
40
|
+
get w() {
|
|
41
|
+
return this._w;
|
|
42
|
+
}
|
|
22
43
|
constructor(e, t, s, n) {
|
|
23
|
-
this.
|
|
44
|
+
this._x = e, this._y = t, this._z = s, this._w = n;
|
|
24
45
|
}
|
|
25
46
|
set(e, t, s, n) {
|
|
26
|
-
this.
|
|
47
|
+
this._x = e, this._y = t, this._z = s, this._w = n;
|
|
27
48
|
}
|
|
28
49
|
}
|
|
29
50
|
class ie {
|
|
@@ -60,14 +81,14 @@ class vs extends ie {
|
|
|
60
81
|
super(), this.needsUpdate = !0, e && (this.needsPhysics = e.physics);
|
|
61
82
|
}
|
|
62
83
|
initObject() {
|
|
63
|
-
const e = new
|
|
64
|
-
return new
|
|
84
|
+
const e = new E.BoxGeometry(), t = new E.MeshStandardMaterial({ color: 65280 });
|
|
85
|
+
return new E.Mesh(e, t);
|
|
65
86
|
}
|
|
66
87
|
update(e) {
|
|
67
88
|
this.physics ? super.update(e) : (this.object.rotation.x += e, this.object.rotation.y += e, this.object.rotation.z += e);
|
|
68
89
|
}
|
|
69
90
|
}
|
|
70
|
-
let
|
|
91
|
+
let Le;
|
|
71
92
|
class ne {
|
|
72
93
|
static RAPIER;
|
|
73
94
|
isInitialized = !1;
|
|
@@ -80,7 +101,7 @@ class ne {
|
|
|
80
101
|
async createWorld(e) {
|
|
81
102
|
if (!ne.RAPIER) {
|
|
82
103
|
const s = await import("./rapier-B3oL1ap-.js");
|
|
83
|
-
await s.init(), ne.RAPIER = s,
|
|
104
|
+
await s.init(), ne.RAPIER = s, Le = s, this.isInitialized = !0;
|
|
84
105
|
}
|
|
85
106
|
const t = new ne.RAPIER.World(e.gravity);
|
|
86
107
|
return new fn(t, e.timestep);
|
|
@@ -109,7 +130,7 @@ class pn {
|
|
|
109
130
|
colliderDesc;
|
|
110
131
|
collider = null;
|
|
111
132
|
constructor(e) {
|
|
112
|
-
this.object = e, this.bodyDesc =
|
|
133
|
+
this.object = e, this.bodyDesc = Le.RigidBodyDesc.dynamic(), this.bodyDesc.setTranslation(e.loc.x, e.loc.y, e.loc.z), this.colliderDesc = Le.ColliderDesc.cuboid(1, 1, 1), this.colliderDesc.setRestitution(0.3).setFriction(0.6);
|
|
113
134
|
}
|
|
114
135
|
synchronize(e) {
|
|
115
136
|
if (this.body) {
|
|
@@ -133,7 +154,7 @@ class se {
|
|
|
133
154
|
physicsWorld = null;
|
|
134
155
|
physicsDt = 1 / 60;
|
|
135
156
|
constructor() {
|
|
136
|
-
this.scene = new
|
|
157
|
+
this.scene = new E.Scene(), this.objects = [], se.physics || (se.physics = new ne());
|
|
137
158
|
}
|
|
138
159
|
add(e) {
|
|
139
160
|
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);
|
|
@@ -172,10 +193,10 @@ class ut extends mn {
|
|
|
172
193
|
camera;
|
|
173
194
|
headLight;
|
|
174
195
|
constructor(e) {
|
|
175
|
-
super(e), this.camera = e, this.headLight = new
|
|
196
|
+
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);
|
|
176
197
|
}
|
|
177
198
|
initObject() {
|
|
178
|
-
return new
|
|
199
|
+
return new E.Object3D();
|
|
179
200
|
}
|
|
180
201
|
getHeadLight() {
|
|
181
202
|
return this.headLight;
|
|
@@ -199,9 +220,14 @@ class Tn extends HTMLElement {
|
|
|
199
220
|
camera3js;
|
|
200
221
|
clock;
|
|
201
222
|
constructor(e) {
|
|
202
|
-
super(), e || (e = new
|
|
203
|
-
const t = new ut(e);
|
|
204
|
-
this.base = new lt(t), this.scene = this.base.scene, this.camera = this.base.camera
|
|
223
|
+
super(), e || (e = {}), e.camera || (e.camera = new E.PerspectiveCamera(75, 300 / 150, 0.1, 1e3)), this.camera3js = e.camera;
|
|
224
|
+
const t = new ut(e.camera);
|
|
225
|
+
this.base = new lt(t), this.scene = this.base.scene, this.camera = this.base.camera;
|
|
226
|
+
const s = {
|
|
227
|
+
antialias: e.antialias ? e.antialias : !1,
|
|
228
|
+
alpha: e.transparent ? e.transparent : !1
|
|
229
|
+
};
|
|
230
|
+
this.renderer = new E.WebGLRenderer(s), "opaque" in e && this.renderer.setClearAlpha(0), this.clock = new E.Clock(), this.style = "display: block; background: rgba(0,0,0,0);", this.renderer.domElement.style = "display: block; width: 100%; height: 100%; margin: 0; padding: 0;", this.appendChild(this.renderer.domElement), this.animationFrameId = requestAnimationFrame(this.renderingLoop);
|
|
205
231
|
}
|
|
206
232
|
connectedCallback() {
|
|
207
233
|
this.ro = new ResizeObserver(() => {
|
|
@@ -253,9 +279,9 @@ class Rn extends HTMLElement {
|
|
|
253
279
|
offsetX = 0;
|
|
254
280
|
offsetY = 0;
|
|
255
281
|
constructor(e, t) {
|
|
256
|
-
super(), this.camera3js = new
|
|
282
|
+
super(), this.camera3js = new E.PerspectiveCamera(75, e / t, 0.1, 1e3);
|
|
257
283
|
const s = new ut(this.camera3js);
|
|
258
|
-
this.base = new lt(s), this.scene = this.base.scene, this.camera = this.base.camera, this.renderer = new
|
|
284
|
+
this.base = new lt(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 = xn, document.body ? document.body.appendChild(this) : document.addEventListener("DOMContentLoaded", () => {
|
|
259
285
|
document.body.append(this);
|
|
260
286
|
}, { once: !0 });
|
|
261
287
|
const n = document.createElement("div");
|
|
@@ -290,7 +316,7 @@ class Rn extends HTMLElement {
|
|
|
290
316
|
};
|
|
291
317
|
}
|
|
292
318
|
customElements.define("a3-window", Rn);
|
|
293
|
-
class
|
|
319
|
+
class _n {
|
|
294
320
|
/**
|
|
295
321
|
* Constructs a new font.
|
|
296
322
|
*
|
|
@@ -309,13 +335,13 @@ class En {
|
|
|
309
335
|
* @return {Array<Shape>} An array of shapes representing the text.
|
|
310
336
|
*/
|
|
311
337
|
generateShapes(e, t = 100, s = "ltr") {
|
|
312
|
-
const n = [], i =
|
|
338
|
+
const n = [], i = En(e, t, this.data, s);
|
|
313
339
|
for (let r = 0, a = i.length; r < a; r++)
|
|
314
340
|
n.push(...i[r].toShapes());
|
|
315
341
|
return n;
|
|
316
342
|
}
|
|
317
343
|
}
|
|
318
|
-
function
|
|
344
|
+
function En(o, e, t, s) {
|
|
319
345
|
const n = Array.from(o), i = e / t.resolution, r = (t.boundingBox.yMax - t.boundingBox.yMin + t.underlineThickness) * i, a = [];
|
|
320
346
|
let c = 0, l = 0;
|
|
321
347
|
(s == "rtl" || s == "tb") && n.reverse();
|
|
@@ -325,13 +351,13 @@ function An(o, e, t, s) {
|
|
|
325
351
|
`)
|
|
326
352
|
c = 0, l -= r;
|
|
327
353
|
else {
|
|
328
|
-
const d =
|
|
354
|
+
const d = An(u, i, c, l, t);
|
|
329
355
|
s == "tb" ? (c = 0, l += t.ascender * i) : c += d.offsetX, a.push(d.path);
|
|
330
356
|
}
|
|
331
357
|
}
|
|
332
358
|
return a;
|
|
333
359
|
}
|
|
334
|
-
function
|
|
360
|
+
function An(o, e, t, s, n) {
|
|
335
361
|
const i = n.glyphs[o] || n.glyphs["?"];
|
|
336
362
|
if (!i) {
|
|
337
363
|
console.error('THREE.Font: character "' + o + '" does not exists in font family ' + n.familyName + ".");
|
|
@@ -359,7 +385,7 @@ function bn(o, e, t, s, n) {
|
|
|
359
385
|
}
|
|
360
386
|
return { offsetX: i.ha * e, path: r };
|
|
361
387
|
}
|
|
362
|
-
class
|
|
388
|
+
class bn extends vt {
|
|
363
389
|
/**
|
|
364
390
|
* Constructs a new text geometry.
|
|
365
391
|
*
|
|
@@ -380,7 +406,7 @@ class Ln extends vt {
|
|
|
380
406
|
function ht(o) {
|
|
381
407
|
return typeof o == "string";
|
|
382
408
|
}
|
|
383
|
-
var v = Uint8Array, Y = Uint16Array,
|
|
409
|
+
var v = Uint8Array, Y = Uint16Array, Ln = Int32Array, dt = new v([
|
|
384
410
|
0,
|
|
385
411
|
0,
|
|
386
412
|
0,
|
|
@@ -452,16 +478,16 @@ var v = Uint8Array, Y = Uint16Array, _n = Int32Array, dt = new v([
|
|
|
452
478
|
]), Sn = new v([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), pt = function(o, e) {
|
|
453
479
|
for (var t = new Y(31), s = 0; s < 31; ++s)
|
|
454
480
|
t[s] = e += 1 << o[s - 1];
|
|
455
|
-
for (var n = new
|
|
481
|
+
for (var n = new Ln(t[30]), s = 1; s < 30; ++s)
|
|
456
482
|
for (var i = t[s]; i < t[s + 1]; ++i)
|
|
457
483
|
n[i] = i - t[s] << 5 | s;
|
|
458
484
|
return { b: t, r: n };
|
|
459
485
|
}, mt = pt(dt, 2), gt = mt.b, Mn = mt.r;
|
|
460
486
|
gt[28] = 258, Mn[258] = 28;
|
|
461
487
|
var vn = pt(ft, 0), In = vn.b, Se = new Y(32768);
|
|
462
|
-
for (var
|
|
463
|
-
var j = (
|
|
464
|
-
j = (j & 52428) >> 2 | (j & 13107) << 2, j = (j & 61680) >> 4 | (j & 3855) << 4, Se[
|
|
488
|
+
for (var _ = 0; _ < 32768; ++_) {
|
|
489
|
+
var j = (_ & 43690) >> 1 | (_ & 21845) << 1;
|
|
490
|
+
j = (j & 52428) >> 2 | (j & 13107) << 2, j = (j & 61680) >> 4 | (j & 3855) << 4, Se[_] = ((j & 65280) >> 8 | (j & 255) << 8) >> 1;
|
|
465
491
|
}
|
|
466
492
|
var re = (function(o, e, t) {
|
|
467
493
|
for (var s = o.length, n = 0, i = new Y(e); n < s; ++n)
|
|
@@ -482,17 +508,17 @@ var re = (function(o, e, t) {
|
|
|
482
508
|
o[n] && (a[n] = Se[r[o[n] - 1]++] >> 15 - o[n]);
|
|
483
509
|
return a;
|
|
484
510
|
}), oe = new v(288);
|
|
485
|
-
for (var
|
|
486
|
-
oe[
|
|
487
|
-
for (var
|
|
488
|
-
oe[
|
|
489
|
-
for (var
|
|
490
|
-
oe[
|
|
491
|
-
for (var
|
|
492
|
-
oe[
|
|
511
|
+
for (var _ = 0; _ < 144; ++_)
|
|
512
|
+
oe[_] = 8;
|
|
513
|
+
for (var _ = 144; _ < 256; ++_)
|
|
514
|
+
oe[_] = 9;
|
|
515
|
+
for (var _ = 256; _ < 280; ++_)
|
|
516
|
+
oe[_] = 7;
|
|
517
|
+
for (var _ = 280; _ < 288; ++_)
|
|
518
|
+
oe[_] = 8;
|
|
493
519
|
var Tt = new v(32);
|
|
494
|
-
for (var
|
|
495
|
-
Tt[
|
|
520
|
+
for (var _ = 0; _ < 32; ++_)
|
|
521
|
+
Tt[_] = 5;
|
|
496
522
|
var Cn = /* @__PURE__ */ re(oe, 9, 1), Nn = /* @__PURE__ */ re(Tt, 5, 1), me = function(o) {
|
|
497
523
|
for (var e = o[0], t = 1; t < o.length; ++t)
|
|
498
524
|
o[t] > e && (e = o[t]);
|
|
@@ -549,13 +575,13 @@ var Cn = /* @__PURE__ */ re(oe, 9, 1), Nn = /* @__PURE__ */ re(Tt, 5, 1), me = f
|
|
|
549
575
|
if (R == 1)
|
|
550
576
|
f = Cn, g = Nn, m = 9, p = 5;
|
|
551
577
|
else if (R == 2) {
|
|
552
|
-
var
|
|
578
|
+
var b = D(o, u, 31) + 257, L = D(o, u + 10, 15) + 4, I = b + D(o, u + 5, 31) + 1;
|
|
553
579
|
u += 14;
|
|
554
|
-
for (var M = new v(I), C = new v(19), S = 0; S <
|
|
580
|
+
for (var M = new v(I), C = new v(19), S = 0; S < L; ++S)
|
|
555
581
|
C[Sn[S]] = D(o, u + S * 3, 7);
|
|
556
|
-
u +=
|
|
557
|
-
for (var ke = me(C),
|
|
558
|
-
var De =
|
|
582
|
+
u += L * 3;
|
|
583
|
+
for (var ke = me(C), Et = (1 << ke) - 1, At = re(C, ke, 1), S = 0; S < I; ) {
|
|
584
|
+
var De = At[D(o, u, Et)];
|
|
559
585
|
u += De & 15;
|
|
560
586
|
var y = De >> 4;
|
|
561
587
|
if (y < 16)
|
|
@@ -566,17 +592,17 @@ var Cn = /* @__PURE__ */ re(oe, 9, 1), Nn = /* @__PURE__ */ re(Tt, 5, 1), me = f
|
|
|
566
592
|
M[S++] = X;
|
|
567
593
|
}
|
|
568
594
|
}
|
|
569
|
-
var Pe = M.subarray(0,
|
|
595
|
+
var Pe = M.subarray(0, b), G = M.subarray(b);
|
|
570
596
|
m = me(Pe), p = me(G), f = re(Pe, m, 1), g = re(G, p, 1);
|
|
571
597
|
} else
|
|
572
598
|
k(1);
|
|
573
599
|
else {
|
|
574
|
-
var y = kn(u) + 4, x = o[y - 4] | o[y - 3] << 8,
|
|
575
|
-
if (
|
|
600
|
+
var y = kn(u) + 4, x = o[y - 4] | o[y - 3] << 8, A = y + x;
|
|
601
|
+
if (A > n) {
|
|
576
602
|
c && k(0);
|
|
577
603
|
break;
|
|
578
604
|
}
|
|
579
|
-
a && l(d + x), t.set(o.subarray(y,
|
|
605
|
+
a && l(d + x), t.set(o.subarray(y, A), d), e.b = d += x, e.p = u = A * 8, e.f = h;
|
|
580
606
|
continue;
|
|
581
607
|
}
|
|
582
608
|
if (u > T) {
|
|
@@ -585,8 +611,8 @@ var Cn = /* @__PURE__ */ re(oe, 9, 1), Nn = /* @__PURE__ */ re(Tt, 5, 1), me = f
|
|
|
585
611
|
}
|
|
586
612
|
}
|
|
587
613
|
a && l(d + 131072);
|
|
588
|
-
for (var
|
|
589
|
-
var X = f[ge(o, u) &
|
|
614
|
+
for (var bt = (1 << m) - 1, Lt = (1 << p) - 1, ue = u; ; ue = u) {
|
|
615
|
+
var X = f[ge(o, u) & bt], W = X >> 4;
|
|
590
616
|
if (u += X & 15, u > T) {
|
|
591
617
|
c && k(0);
|
|
592
618
|
break;
|
|
@@ -602,7 +628,7 @@ var Cn = /* @__PURE__ */ re(oe, 9, 1), Nn = /* @__PURE__ */ re(Tt, 5, 1), me = f
|
|
|
602
628
|
var S = W - 257, $ = dt[S];
|
|
603
629
|
Oe = D(o, u, (1 << $) - 1) + gt[S], u += $;
|
|
604
630
|
}
|
|
605
|
-
var he = g[ge(o, u) &
|
|
631
|
+
var he = g[ge(o, u) & Lt], de = he >> 4;
|
|
606
632
|
he || k(3), u += he & 15;
|
|
607
633
|
var G = In[de];
|
|
608
634
|
if (de > 3) {
|
|
@@ -691,29 +717,29 @@ function Kn(o, e) {
|
|
|
691
717
|
}
|
|
692
718
|
let ve = null;
|
|
693
719
|
async function Is(o) {
|
|
694
|
-
const e = o.substring(0, o.length - 4), t = new
|
|
720
|
+
const e = o.substring(0, o.length - 4), t = new E.FileLoader();
|
|
695
721
|
t.setResponseType("arraybuffer");
|
|
696
722
|
const s = await t.loadAsync(o), n = Kn(new Uint8Array(s)), i = yt(new Uint8Array(n[e].buffer));
|
|
697
|
-
ve = new
|
|
723
|
+
ve = new _n(JSON.parse(i));
|
|
698
724
|
}
|
|
699
725
|
class Cs extends ie {
|
|
700
726
|
initObject(e) {
|
|
701
727
|
let t;
|
|
702
728
|
if (ht(e) ? t = e : t = "ERROR", ve == null) {
|
|
703
|
-
const s = new
|
|
704
|
-
return new
|
|
729
|
+
const s = new E.BoxGeometry(), n = new E.MeshStandardMaterial({ color: 16711680 });
|
|
730
|
+
return new E.Mesh(s, n);
|
|
705
731
|
} else {
|
|
706
|
-
const s = { font: ve, size: 1, depth: 0.5, curveSegments: 12 }, n = new
|
|
732
|
+
const s = { font: ve, size: 1, depth: 0.5, curveSegments: 12 }, n = new bn(t, s);
|
|
707
733
|
n.center();
|
|
708
|
-
const i = new
|
|
709
|
-
return new
|
|
734
|
+
const i = new E.MeshStandardMaterial({ color: 65280 });
|
|
735
|
+
return new E.Mesh(n, i);
|
|
710
736
|
}
|
|
711
737
|
}
|
|
712
738
|
}
|
|
713
739
|
function Xe(o, e) {
|
|
714
740
|
if (e === It)
|
|
715
741
|
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), o;
|
|
716
|
-
if (e ===
|
|
742
|
+
if (e === _e || e === $e) {
|
|
717
743
|
let t = o.getIndex();
|
|
718
744
|
if (t === null) {
|
|
719
745
|
const r = [], a = o.getAttribute("position");
|
|
@@ -725,7 +751,7 @@ function Xe(o, e) {
|
|
|
725
751
|
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), o;
|
|
726
752
|
}
|
|
727
753
|
const s = t.count - 2, n = [];
|
|
728
|
-
if (e ===
|
|
754
|
+
if (e === _e)
|
|
729
755
|
for (let r = 1; r <= s; r++)
|
|
730
756
|
n.push(t.getX(0)), n.push(t.getX(r)), n.push(t.getX(r + 1));
|
|
731
757
|
else
|
|
@@ -893,7 +919,7 @@ class zn extends Ze {
|
|
|
893
919
|
n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
894
920
|
return;
|
|
895
921
|
}
|
|
896
|
-
const l = new
|
|
922
|
+
const l = new Es(i, {
|
|
897
923
|
path: t || this.resourcePath || "",
|
|
898
924
|
crossOrigin: this.crossOrigin,
|
|
899
925
|
requestHeader: this.requestHeader,
|
|
@@ -1337,8 +1363,8 @@ class ls {
|
|
|
1337
1363
|
c.TRANSLATION && p.fromBufferAttribute(c.TRANSLATION, x), c.ROTATION && T.fromBufferAttribute(c.ROTATION, x), c.SCALE && R.fromBufferAttribute(c.SCALE, x), y.setMatrixAt(x, m.compose(p, T, R));
|
|
1338
1364
|
for (const x in c)
|
|
1339
1365
|
if (x === "_COLOR_0") {
|
|
1340
|
-
const
|
|
1341
|
-
y.instanceColor = new Pt(
|
|
1366
|
+
const A = c[x];
|
|
1367
|
+
y.instanceColor = new Pt(A.array, A.itemSize, A.normalized);
|
|
1342
1368
|
} else x !== "TRANSLATION" && x !== "ROTATION" && x !== "SCALE" && g.geometry.setAttribute(x, c[x]);
|
|
1343
1369
|
tt.prototype.copy.call(y, g), this.parser.assignFinalMaterial(y), f.push(y);
|
|
1344
1370
|
}
|
|
@@ -1436,8 +1462,8 @@ class wt extends cn {
|
|
|
1436
1462
|
interpolate_(e, t, s, n) {
|
|
1437
1463
|
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, f = d * u, g = e * l, m = g - l, p = -2 * f + 3 * d, T = f - d, R = 1 - p, y = T - d + u;
|
|
1438
1464
|
for (let x = 0; x !== a; x++) {
|
|
1439
|
-
const
|
|
1440
|
-
i[x] = R *
|
|
1465
|
+
const A = r[m + x + a], b = r[m + x + c] * h, L = r[g + x + a], I = r[g + x] * h;
|
|
1466
|
+
i[x] = R * A + y * b + p * L + T * I;
|
|
1441
1467
|
}
|
|
1442
1468
|
return i;
|
|
1443
1469
|
}
|
|
@@ -1466,7 +1492,7 @@ const N = {
|
|
|
1466
1492
|
5126: Float32Array
|
|
1467
1493
|
}, qe = {
|
|
1468
1494
|
9728: it,
|
|
1469
|
-
9729:
|
|
1495
|
+
9729: Ee,
|
|
1470
1496
|
9984: Gt,
|
|
1471
1497
|
9985: Ut,
|
|
1472
1498
|
9986: Ht,
|
|
@@ -1474,7 +1500,7 @@ const N = {
|
|
|
1474
1500
|
}, Ye = {
|
|
1475
1501
|
33071: Bt,
|
|
1476
1502
|
33648: jt,
|
|
1477
|
-
10497:
|
|
1503
|
+
10497: Ae
|
|
1478
1504
|
}, ye = {
|
|
1479
1505
|
SCALAR: 1,
|
|
1480
1506
|
VEC2: 2,
|
|
@@ -1606,8 +1632,8 @@ function Ce(o) {
|
|
|
1606
1632
|
function Rs(o) {
|
|
1607
1633
|
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";
|
|
1608
1634
|
}
|
|
1609
|
-
const
|
|
1610
|
-
class
|
|
1635
|
+
const _s = new le();
|
|
1636
|
+
class Es {
|
|
1611
1637
|
constructor(e = {}, t = {}) {
|
|
1612
1638
|
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new Vn(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
|
|
1613
1639
|
let s = !1, n = -1, i = !1, r = -1;
|
|
@@ -1871,11 +1897,11 @@ class As {
|
|
|
1871
1897
|
} else
|
|
1872
1898
|
a === null ? m = new l(n.count * c) : m = new l(a, d, n.count * c), p = new te(m, c, g);
|
|
1873
1899
|
if (n.sparse !== void 0) {
|
|
1874
|
-
const T = ye.SCALAR, R = J[n.sparse.indices.componentType], y = n.sparse.indices.byteOffset || 0, x = n.sparse.values.byteOffset || 0,
|
|
1900
|
+
const T = ye.SCALAR, R = J[n.sparse.indices.componentType], y = n.sparse.indices.byteOffset || 0, x = n.sparse.values.byteOffset || 0, A = new R(r[1], y, n.sparse.count * T), b = new l(r[2], x, n.sparse.count * c);
|
|
1875
1901
|
a !== null && (p = new te(p.array.slice(), p.itemSize, p.normalized)), p.normalized = !1;
|
|
1876
|
-
for (let
|
|
1877
|
-
const M =
|
|
1878
|
-
if (p.setX(M, L
|
|
1902
|
+
for (let L = 0, I = A.length; L < I; L++) {
|
|
1903
|
+
const M = A[L];
|
|
1904
|
+
if (p.setX(M, b[L * c]), c >= 2 && p.setY(M, b[L * c + 1]), c >= 3 && p.setZ(M, b[L * c + 2]), c >= 4 && p.setW(M, b[L * c + 3]), c >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1879
1905
|
}
|
|
1880
1906
|
p.normalized = g;
|
|
1881
1907
|
}
|
|
@@ -1905,7 +1931,7 @@ class As {
|
|
|
1905
1931
|
const l = this.loadImageSource(t, s).then(function(h) {
|
|
1906
1932
|
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);
|
|
1907
1933
|
const d = (i.samplers || {})[r.sampler] || {};
|
|
1908
|
-
return h.magFilter = qe[d.magFilter] ||
|
|
1934
|
+
return h.magFilter = qe[d.magFilter] || Ee, h.minFilter = qe[d.minFilter] || rt, h.wrapS = Ye[d.wrapS] || Ae, h.wrapT = Ye[d.wrapT] || Ae, h.generateMipmaps = !h.isCompressedTexture && h.minFilter !== it && h.minFilter !== Ee, n.associations.set(h, { textures: e }), h;
|
|
1909
1935
|
}).catch(function() {
|
|
1910
1936
|
return null;
|
|
1911
1937
|
});
|
|
@@ -2098,7 +2124,7 @@ class As {
|
|
|
2098
2124
|
let T;
|
|
2099
2125
|
const R = l[f];
|
|
2100
2126
|
if (p.mode === N.TRIANGLES || p.mode === N.TRIANGLE_STRIP || p.mode === N.TRIANGLE_FAN || p.mode === void 0)
|
|
2101
|
-
T = i.isSkinnedMesh === !0 ? new Wt(m, R) : new qt(m, R), T.isSkinnedMesh === !0 && T.normalizeSkinWeights(), p.mode === N.TRIANGLE_STRIP ? T.geometry = Xe(T.geometry, $e) : p.mode === N.TRIANGLE_FAN && (T.geometry = Xe(T.geometry,
|
|
2127
|
+
T = i.isSkinnedMesh === !0 ? new Wt(m, R) : new qt(m, R), T.isSkinnedMesh === !0 && T.normalizeSkinWeights(), p.mode === N.TRIANGLE_STRIP ? T.geometry = Xe(T.geometry, $e) : p.mode === N.TRIANGLE_FAN && (T.geometry = Xe(T.geometry, _e));
|
|
2102
2128
|
else if (p.mode === N.LINES)
|
|
2103
2129
|
T = new Yt(m, R);
|
|
2104
2130
|
else if (p.mode === N.LINE_STRIP)
|
|
@@ -2188,10 +2214,10 @@ class As {
|
|
|
2188
2214
|
]).then(function(u) {
|
|
2189
2215
|
const d = u[0], f = u[1], g = u[2], m = u[3], p = u[4], T = [];
|
|
2190
2216
|
for (let y = 0, x = d.length; y < x; y++) {
|
|
2191
|
-
const
|
|
2192
|
-
if (
|
|
2193
|
-
|
|
2194
|
-
const C = s._createAnimationTracks(b, L,
|
|
2217
|
+
const A = d[y], b = f[y], L = g[y], I = m[y], M = p[y];
|
|
2218
|
+
if (A === void 0) continue;
|
|
2219
|
+
A.updateMatrix && A.updateMatrix();
|
|
2220
|
+
const C = s._createAnimationTracks(A, b, L, I, M);
|
|
2195
2221
|
if (C)
|
|
2196
2222
|
for (let S = 0; S < C.length; S++)
|
|
2197
2223
|
T.push(C[S]);
|
|
@@ -2230,7 +2256,7 @@ class As {
|
|
|
2230
2256
|
]).then(function(l) {
|
|
2231
2257
|
const h = l[0], u = l[1], d = l[2];
|
|
2232
2258
|
d !== null && h.traverse(function(f) {
|
|
2233
|
-
f.isSkinnedMesh && f.bind(d,
|
|
2259
|
+
f.isSkinnedMesh && f.bind(d, _s);
|
|
2234
2260
|
});
|
|
2235
2261
|
for (let f = 0, g = u.length; f < g; f++)
|
|
2236
2262
|
h.add(u[f]);
|
|
@@ -2349,7 +2375,7 @@ class As {
|
|
|
2349
2375
|
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
2350
2376
|
}
|
|
2351
2377
|
}
|
|
2352
|
-
function
|
|
2378
|
+
function As(o, e, t) {
|
|
2353
2379
|
const s = e.attributes, n = new ln();
|
|
2354
2380
|
if (s.POSITION !== void 0) {
|
|
2355
2381
|
const a = t.json.accessors[s.POSITION], c = a.min, l = a.max;
|
|
@@ -2407,12 +2433,12 @@ function Je(o, e, t) {
|
|
|
2407
2433
|
});
|
|
2408
2434
|
n.push(r);
|
|
2409
2435
|
}
|
|
2410
|
-
return
|
|
2436
|
+
return be.workingColorSpace !== H && "COLOR_0" in s && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${be.workingColorSpace}" not supported.`), O(o, e), As(o, e, t), Promise.all(n).then(function() {
|
|
2411
2437
|
return e.targets !== void 0 ? ys(o, e.targets, t) : o;
|
|
2412
2438
|
});
|
|
2413
2439
|
}
|
|
2414
2440
|
const Re = /* @__PURE__ */ new WeakMap();
|
|
2415
|
-
class
|
|
2441
|
+
class bs extends Ze {
|
|
2416
2442
|
/**
|
|
2417
2443
|
* Constructs a new Draco loader.
|
|
2418
2444
|
*
|
|
@@ -2538,7 +2564,7 @@ class Ls extends Ze {
|
|
|
2538
2564
|
if (t !== K) return;
|
|
2539
2565
|
const s = new z();
|
|
2540
2566
|
for (let n = 0, i = e.count; n < i; n++)
|
|
2541
|
-
s.fromBufferAttribute(e, n),
|
|
2567
|
+
s.fromBufferAttribute(e, n), be.colorSpaceToWorking(s, K), e.setXYZ(n, s.r, s.g, s.b);
|
|
2542
2568
|
}
|
|
2543
2569
|
_loadLibrary(e, t) {
|
|
2544
2570
|
const s = new ce(this.manager);
|
|
@@ -2555,7 +2581,7 @@ class Ls extends Ze {
|
|
|
2555
2581
|
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) => {
|
|
2556
2582
|
const n = s[0];
|
|
2557
2583
|
e || (this.decoderConfig.wasmBinary = s[1]);
|
|
2558
|
-
const i =
|
|
2584
|
+
const i = Ls.toString(), r = [
|
|
2559
2585
|
"/* draco decoder */",
|
|
2560
2586
|
n,
|
|
2561
2587
|
"",
|
|
@@ -2603,7 +2629,7 @@ class Ls extends Ze {
|
|
|
2603
2629
|
return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this;
|
|
2604
2630
|
}
|
|
2605
2631
|
}
|
|
2606
|
-
function
|
|
2632
|
+
function Ls() {
|
|
2607
2633
|
let o, e;
|
|
2608
2634
|
onmessage = function(r) {
|
|
2609
2635
|
const a = r.data;
|
|
@@ -2667,24 +2693,24 @@ function _s() {
|
|
|
2667
2693
|
function n(r, a, c, l, h, u) {
|
|
2668
2694
|
const d = c.num_points(), f = u.num_components(), g = i(r, h), m = f * h.BYTES_PER_ELEMENT, p = Math.ceil(m / 4) * 4, T = p / h.BYTES_PER_ELEMENT, R = d * m, y = d * p, x = r._malloc(R);
|
|
2669
2695
|
a.GetAttributeDataArrayForAllPoints(c, u, g, R, x);
|
|
2670
|
-
const
|
|
2671
|
-
let
|
|
2696
|
+
const A = new h(r.HEAPF32.buffer, x, R / h.BYTES_PER_ELEMENT);
|
|
2697
|
+
let b;
|
|
2672
2698
|
if (m === p)
|
|
2673
|
-
|
|
2699
|
+
b = A.slice();
|
|
2674
2700
|
else {
|
|
2675
|
-
|
|
2676
|
-
let
|
|
2677
|
-
for (let I = 0, M =
|
|
2701
|
+
b = new h(y / h.BYTES_PER_ELEMENT);
|
|
2702
|
+
let L = 0;
|
|
2703
|
+
for (let I = 0, M = A.length; I < M; I++) {
|
|
2678
2704
|
for (let C = 0; C < f; C++)
|
|
2679
|
-
L
|
|
2680
|
-
|
|
2705
|
+
b[L + C] = A[I * f + C];
|
|
2706
|
+
L += T;
|
|
2681
2707
|
}
|
|
2682
2708
|
}
|
|
2683
2709
|
return r._free(x), {
|
|
2684
2710
|
name: l,
|
|
2685
2711
|
count: d,
|
|
2686
2712
|
itemSize: f,
|
|
2687
|
-
array:
|
|
2713
|
+
array: b,
|
|
2688
2714
|
stride: T
|
|
2689
2715
|
};
|
|
2690
2716
|
}
|
|
@@ -2710,24 +2736,21 @@ function _s() {
|
|
|
2710
2736
|
function Ss(o) {
|
|
2711
2737
|
return "morphTargetDictionary" in o && o.morphTargetDictionary !== void 0 && "morphTargetInfluences" in o && Array.isArray(o.morphTargetInfluences);
|
|
2712
2738
|
}
|
|
2713
|
-
const Rt = new zn(),
|
|
2714
|
-
|
|
2715
|
-
Rt.setDRACOLoader(
|
|
2739
|
+
const Rt = new zn(), _t = new bs();
|
|
2740
|
+
_t.setDecoderPath("/examples/jsm/libs/draco/");
|
|
2741
|
+
Rt.setDRACOLoader(_t);
|
|
2716
2742
|
class Ns extends ie {
|
|
2717
2743
|
ready;
|
|
2718
2744
|
model = null;
|
|
2719
2745
|
constructor(e) {
|
|
2720
|
-
super(), this.ready = this.asyncInit(e);
|
|
2746
|
+
super(), this.ready = this.asyncInit(e), this.needsUpdate = !0;
|
|
2721
2747
|
}
|
|
2722
2748
|
initObject() {
|
|
2723
|
-
return new
|
|
2724
|
-
}
|
|
2725
|
-
initNeedsUpdate() {
|
|
2726
|
-
return !0;
|
|
2749
|
+
return new E.Object3D();
|
|
2727
2750
|
}
|
|
2728
2751
|
async asyncInit(e) {
|
|
2729
2752
|
if (ht(e)) {
|
|
2730
|
-
const t = await Rt.loadAsync(e), s = new
|
|
2753
|
+
const t = await Rt.loadAsync(e), s = new E.AnimationMixer(t.scene), n = {};
|
|
2731
2754
|
console.log(`File: ${e}`), console.log(" actions:");
|
|
2732
2755
|
for (let r = 0; r < t.animations.length; r++) {
|
|
2733
2756
|
const a = t.animations[r], c = s.clipAction(a);
|
|
@@ -2750,7 +2773,7 @@ class Ns extends ie {
|
|
|
2750
2773
|
morphs: i
|
|
2751
2774
|
}, this.object.add(this.model.gltf.scene);
|
|
2752
2775
|
} else {
|
|
2753
|
-
const t = new
|
|
2776
|
+
const t = new E.BoxGeometry(), s = new E.MeshStandardMaterial({ color: 16711680 }), n = new E.Mesh(t, s);
|
|
2754
2777
|
this.object.add(n);
|
|
2755
2778
|
}
|
|
2756
2779
|
return this;
|
|
@@ -2794,7 +2817,9 @@ export {
|
|
|
2794
2817
|
Rn as A3Window,
|
|
2795
2818
|
Ns as A3glTF,
|
|
2796
2819
|
ut as GeneralCamera,
|
|
2820
|
+
dn as Quat,
|
|
2797
2821
|
ks as ThreeJS,
|
|
2822
|
+
hn as Vec3,
|
|
2798
2823
|
Is as initFont,
|
|
2799
2824
|
Ds as times2
|
|
2800
2825
|
};
|