@mapvx/web-components-ssr 1.6.1 → 1.7.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- import{t as r}from"./main.js";import{A as Ct$1,As as vr,B as Dt$1,D as Co,G as Em,Gn as Si,Go as qs,Gt as Kt$1,H as Eg,I as Dn,In as Qt,Is as wo,It as K,Jt as Ln,K as Eo,Ka as kt$1,L as Do,Ls as wr,Ma as ji,Mn as Qn,Mt as Ji,Po as pn,S as C$1,Tr as Wh,Ts as vi,Un as Rt,Us as xo,Vr as Ye,Vs as xl,Wt as Kr,Y as Et,Zi as es,Zs as yn,Zt as Me$1,at as Ft$1,bo as ns,ci as _l,da as gt,di as _r,do as mr,fi as _t,fo as mt,in as Mt$1,is as ss,jo as pi,k as Cr,lc as zu,mr as Ut$1,ms as tt,ns as sl,oa as gl,pn as Nt$1,ps as ts,rc as zh,tc as ze$1,to as lt,tr as Tm,u as Am,ua as gr,un as No,ur as Un,v as Bn,xa as ia,xn as Os,xt as Hr,ys as un}from"./chunk-LltjhLJU.js";function ge(f,t){if(t===0)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),f;if(t===2||t===1){let e=f.getIndex();if(e===null){let i=[],a=f.getAttribute(`position`);if(a!==void 0){for(let o=0;o<a.count;o++)i.push(o);f.setIndex(i),e=f.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),f}let s=e.count-2,n=[];if(t===2)for(let i=1;i<=s;i++)n.push(e.getX(0)),n.push(e.getX(i)),n.push(e.getX(i+1));else for(let i=0;i<s;i++)i%2===0?(n.push(e.getX(i)),n.push(e.getX(i+1)),n.push(e.getX(i+2))):(n.push(e.getX(i+2)),n.push(e.getX(i+1)),n.push(e.getX(i)));n.length/3!==s&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let r=f.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,t),f}function Mt(f){let t=new Map,e=new Map,s=f.clone();return St(f,s,function(n,r){t.set(r,n),e.set(n,r)}),s.traverse(function(n){if(!n.isSkinnedMesh)return;let r=n,i=t.get(n),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(o){return e.get(o)}),r.bind(r.skeleton,r.bindMatrix)}),s}function St(f,t,e){e(f,t);for(let s=0;s<f.children.length;s++)St(f.children[s],t.children[s],e)}var It=class extends un{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new we(e)}),this.register(function(e){return new Ee(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new Me(e)}),this.register(function(e){return new Se(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Ne(e)}),this.register(function(e){return new ye(e)}),this.register(function(e){return new Le(e)}),this.register(function(e){return new _e(e)}),this.register(function(e){return new Ce(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new xe(e)}),this.register(function(e){return new Y(e,g.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new Y(e,g.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new Be(e)})}load(t,e,s,n){let r=this,i;if(this.resourcePath!==``)i=this.resourcePath;else if(this.path!==``){let c=Kr.extractUrlBase(t);i=Kr.resolveURL(c,this.path)}else i=Kr.extractUrlBase(t);this.manager.itemStart(t);let a=function(c){n?n(c):console.error(c),r.manager.itemError(t),r.manager.itemEnd(t)},o=new yn(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{r.parse(c,i,function(u){e(u),r.manager.itemEnd(t)},a)}catch(u){a(u)}},s,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let r,i={},a={},o=new TextDecoder;if(typeof t==`string`)r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(o.decode(new Uint8Array(t,0,4))===vt){try{i[g.KHR_BINARY_GLTF]=new He(t)}catch(l){n&&n(l);return}r=JSON.parse(i[g.KHR_BINARY_GLTF].content)}else r=JSON.parse(o.decode(t));else r=t;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new Ve(r,{path:e||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){let l=this.pluginCallbacks[u](c);l.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),a[l.name]=l,i[l.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){let l=r.extensionsUsed[u],d=r.extensionsRequired||[];switch(l){case g.KHR_MATERIALS_UNLIT:i[l]=new be;break;case g.KHR_DRACO_MESH_COMPRESSION:i[l]=new De(r,this.dracoLoader);break;case g.KHR_TEXTURE_TRANSFORM:i[l]=new Fe;break;case g.KHR_MESH_QUANTIZATION:i[l]=new Ue;break;default:d.indexOf(l)>=0&&a[l]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+l+`".`)}}c.setExtensions(i),c.setPlugins(a),c.parse(s,n)}parseAsync(t,e){let s=this;return new Promise(function(n,r){s.parse(t,e,n,r)})}};function kt(){let f={};return{get:function(t){return f[t]},add:function(t,e){f[t]=e},remove:function(t){delete f[t]},removeAll:function(){f={}}}}function y(f,t,e){let s=f.json.materials[t];return s.extensions&&s.extensions[e]?s.extensions[e]:null}var g={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`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`};var xe=class{constructor(t){this.parser=t,this.name=g.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){let r=e[s];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){let e=this.parser,s=`light:`+t,n=e.cache.get(s);if(n)return n;let r=e.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t],c,u=new Me$1(16777215);o.color!==void 0&&u.setRGB(o.color[0],o.color[1],o.color[2],`srgb-linear`);let l=o.range!==void 0?o.range:0;switch(o.type){case`directional`:c=new xl(u),c.target.position.set(0,0,-1),c.add(c.target);break;case`point`:c=new _l(u),c.distance=l;break;case`spot`:c=new gl(u),c.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error(`THREE.GLTFLoader: Unexpected light type: `+o.type)}return c.position.set(0,0,0),I(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||`light_`+t),n=Promise.resolve(c),e.cache.add(s,n),n}getDependency(t,e){if(t===`light`)return this._loadLight(e)}createNodeAttachment(t){let e=this,s=this.parser,r=s.json.nodes[t],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}};var be=class{constructor(){this.name=g.KHR_MATERIALS_UNLIT}getMaterialType(){return Ln}extendParams(t,e,s){let n=[];t.color=new Me$1(1,1,1),t.opacity=1;let r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let i=r.baseColorFactor;t.color.setRGB(i[0],i[1],i[2],vr),t.opacity=i[3]}r.baseColorTexture!==void 0&&n.push(s.assignTexture(t,`map`,r.baseColorTexture,`srgb`))}return Promise.all(n)}};var ye=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);return s===null||s.emissiveStrength!==void 0&&(e.emissiveIntensity=s.emissiveStrength),Promise.resolve()}};var we=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);if(s===null)return Promise.resolve();let n=[];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(e,`clearcoatMap`,s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(e,`clearcoatRoughnessMap`,s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(e,`clearcoatNormalMap`,s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){let r=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new K(r,r)}return Promise.all(n)}};var Ee=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_DISPERSION}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);return s===null||(e.dispersion=s.dispersion!==void 0?s.dispersion:0),Promise.resolve()}};var _e=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);if(s===null)return Promise.resolve();let n=[];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(e,`iridescenceMap`,s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(e,`iridescenceThicknessMap`,s.iridescenceThicknessTexture)),Promise.all(n)}};var Me=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_SHEEN}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);if(s===null)return Promise.resolve();let n=[];if(e.sheenColor=new Me$1(0,0,0),e.sheenRoughness=0,e.sheen=1,s.sheenColorFactor!==void 0){let r=s.sheenColorFactor;e.sheenColor.setRGB(r[0],r[1],r[2],vr)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(e,`sheenColorMap`,s.sheenColorTexture,`srgb`)),s.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(e,`sheenRoughnessMap`,s.sheenRoughnessTexture)),Promise.all(n)}};var Se=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);if(s===null)return Promise.resolve();let n=[];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(e,`transmissionMap`,s.transmissionTexture)),Promise.all(n)}};var Ie=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_VOLUME}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);if(s===null)return Promise.resolve();let n=[];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(e,`thicknessMap`,s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||Infinity;let r=s.attenuationColor||[1,1,1];return e.attenuationColor=new Me$1().setRGB(r[0],r[1],r[2],vr),Promise.all(n)}};var Ne=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_IOR}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);return s===null||(e.ior=s.ior!==void 0?s.ior:1.5,e.ior===0&&(e.ior=1e3)),Promise.resolve()}};var Le=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_SPECULAR}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);if(s===null)return Promise.resolve();let n=[];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&n.push(this.parser.assignTexture(e,`specularIntensityMap`,s.specularTexture));let r=s.specularColorFactor||[1,1,1];return e.specularColor=new Me$1().setRGB(r[0],r[1],r[2],vr),s.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(e,`specularColorMap`,s.specularColorTexture,`srgb`)),Promise.all(n)}};var Oe=class{constructor(t){this.parser=t,this.name=g.EXT_MATERIALS_BUMP}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);if(s===null)return Promise.resolve();let n=[];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&n.push(this.parser.assignTexture(e,`bumpMap`,s.bumpTexture)),Promise.all(n)}};var Ce=class{constructor(t){this.parser=t,this.name=g.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return y(this.parser,t,this.name)!==null?sl:null}extendMaterialParams(t,e){let s=y(this.parser,t,this.name);if(s===null)return Promise.resolve();let n=[];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(e,`anisotropyMap`,s.anisotropyTexture)),Promise.all(n)}};var ve=class{constructor(t){this.parser=t,this.name=g.KHR_TEXTURE_BASISU}loadTexture(t){let e=this.parser,s=e.json,n=s.textures[t];if(!n.extensions||!n.extensions[this.name])return null;let r=n.extensions[this.name],i=e.options.ktx2Loader;if(!i){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 e.loadTextureImage(t,r.source,i)}};var ke=class{constructor(t){this.parser=t,this.name=g.EXT_TEXTURE_WEBP}loadTexture(t){let e=this.name,s=this.parser,n=s.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;let i=r.extensions[e],a=n.images[i.source],o=s.textureLoader;if(a.uri){let c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(t,i.source,o)}};var Pe=class{constructor(t){this.parser=t,this.name=g.EXT_TEXTURE_AVIF}loadTexture(t){let e=this.name,s=this.parser,n=s.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;let i=r.extensions[e],a=n.images[i.source],o=s.textureLoader;if(a.uri){let c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return s.loadTextureImage(t,i.source,o)}};var Y=class{constructor(t,e){this.name=e,this.parser=t}loadBufferView(t){let e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){let n=s.extensions[this.name],r=this.parser.getDependency(`buffer`,n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(a){let o=n.byteOffset||0,c=n.byteLength||0,u=n.count,l=n.byteStride,d=new Uint8Array(a,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(u,l,d,n.mode,n.filter).then(function(h){return h.buffer}):i.ready.then(function(){let h=new ArrayBuffer(u*l);return i.decodeGltfBuffer(new Uint8Array(h),u,l,d,n.mode,n.filter),h})})}else return null}};var Be=class{constructor(t){this.name=g.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){let e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;let n=e.meshes[s.mesh];for(let c of n.primitives)if(c.mode!==E.TRIANGLES&&c.mode!==E.TRIANGLE_STRIP&&c.mode!==E.TRIANGLE_FAN&&c.mode!==void 0)return null;let i=s.extensions[this.name].attributes,a=[],o={};for(let c in i)a.push(this.parser.getDependency(`accessor`,i[c]).then(u=>(o[c]=u,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{let u=c.pop(),l=u.isGroup?u.children:[u],d=c[0].count,h=[];for(let p of l){let A=new ze$1,m=new C$1,T=new Ut$1,b=new C$1(1,1,1),x=new Co(p.geometry,p.material,d);for(let R=0;R<d;R++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,R),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,R),o.SCALE&&b.fromBufferAttribute(o.SCALE,R),x.setMatrixAt(R,A.compose(m,T,b));for(let R in o)if(R===`_COLOR_0`){let w=o[R];x.instanceColor=new vi(w.array,w.itemSize,w.normalized)}else R!==`TRANSLATION`&&R!==`ROTATION`&&R!==`SCALE`&&p.geometry.setAttribute(R,o[R]);gt.prototype.copy.call(x,p),this.parser.assignFinalMaterial(x),h.push(x)}return u.isGroup?(u.clear(),u.add(...h),u):h[0]}))}};var vt=`glTF`;var z=12;var Nt={JSON:1313821514,BIN:5130562};var He=class{constructor(t){this.name=g.KHR_BINARY_GLTF,this.content=null,this.body=null;let e=new DataView(t,0,z),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==vt)throw new Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw new Error(`THREE.GLTFLoader: Legacy binary file detected.`);let n=this.header.length-z,r=new DataView(t,z),i=0;for(;i<n;){let a=r.getUint32(i,!0);i+=4;let o=r.getUint32(i,!0);if(i+=4,o===Nt.JSON){let c=new Uint8Array(t,z+i,a);this.content=s.decode(c)}else if(o===Nt.BIN){let c=z+i;this.body=t.slice(c,c+a)}i+=a}if(this.content===null)throw new Error(`THREE.GLTFLoader: JSON content not found.`)}};var De=class{constructor(t,e){if(!e)throw new Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=g.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){let s=this.json,n=this.dracoLoader,r=t.extensions[this.name].bufferView,i=t.extensions[this.name].attributes,a={},o={},c={};for(let u in i){let l=Ke[u]||u.toLowerCase();a[l]=i[u]}for(let u in t.attributes){let l=Ke[u]||u.toLowerCase();if(i[u]!==void 0){let d=s.accessors[t.attributes[u]];c[l]=D[d.componentType].name,o[l]=d.normalized===!0}}return e.getDependency(`bufferView`,r).then(function(u){return new Promise(function(l,d){n.decodeDracoFile(u,function(h){for(let p in h.attributes){let A=h.attributes[p],m=o[p];m!==void 0&&(A.normalized=m)}l(h)},a,c,vr,d)})})}};var Fe=class{constructor(){this.name=g.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}};var Ue=class{constructor(){this.name=g.KHR_MESH_QUANTIZATION}};var Z=class extends Si{constructor(t,e,s,n){super(t,e,s,n)}copySampleValue_(t){let e=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let i=0;i!==n;i++)e[i]=s[r+i];return e}interpolate_(t,e,s,n){let r=this.resultBuffer,i=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,u=n-e,l=(s-e)/u,d=l*l,h=d*l,p=t*c,A=p-c,m=-2*h+3*d,T=h-d,b=1-m,x=T-d+l;for(let R=0;R!==a;R++){let w=i[A+R+a],L=i[A+R+o]*u,_=i[p+R+a],F=i[p+R]*u;r[R]=b*w+x*L+m*_+T*F}return r}};var Pt=new Ut$1;var Ge=class extends Z{interpolate_(t,e,s,n){let r=super.interpolate_(t,e,s,n);return Pt.fromArray(r).normalize().toArray(r),r}};var E={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123};var D={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};var Lt={9728:Et,9729:_t,9984:zu,9985:ia,9986:qs,9987:Bn};var Ot={33071:Qt,33648:gr,10497:mr};var Te={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};var Ke={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`};var C={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`};var Bt={CUBICSPLINE:void 0,LINEAR:xo,STEP:_r};var Ae={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function Ht(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new Hr({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),f.DefaultMaterial}function v(f,t,e){for(let s in e.extensions)f[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function I(f,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(f.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function Dt(f,t,e){let s=!1,n=!1,r=!1;for(let c=0,u=t.length;c<u;c++){let l=t[c];if(l.POSITION!==void 0&&(s=!0),l.NORMAL!==void 0&&(n=!0),l.COLOR_0!==void 0&&(r=!0),s&&n&&r)break}if(!s&&!n&&!r)return Promise.resolve(f);let i=[],a=[],o=[];for(let c=0,u=t.length;c<u;c++){let l=t[c];if(s){let d=l.POSITION!==void 0?e.getDependency(`accessor`,l.POSITION):f.attributes.position;i.push(d)}if(n){let d=l.NORMAL!==void 0?e.getDependency(`accessor`,l.NORMAL):f.attributes.normal;a.push(d)}if(r){let d=l.COLOR_0!==void 0?e.getDependency(`accessor`,l.COLOR_0):f.attributes.color;o.push(d)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o)]).then(function(c){let u=c[0],l=c[1],d=c[2];return s&&(f.morphAttributes.position=u),n&&(f.morphAttributes.normal=l),r&&(f.morphAttributes.color=d),f.morphTargetsRelative=!0,f})}function Ft(f,t){if(f.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)f.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){let e=t.extras.targetNames;if(f.morphTargetInfluences.length===e.length){f.morphTargetDictionary={};for(let s=0,n=e.length;s<n;s++)f.morphTargetDictionary[e[s]]=s}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function Ut(f){let t,e=f.extensions&&f.extensions[g.KHR_DRACO_MESH_COMPRESSION];if(e?t=`draco:`+e.bufferView+`:`+e.indices+`:`+Re(e.attributes):t=f.indices+`:`+Re(f.attributes)+`:`+f.mode,f.targets!==void 0)for(let s=0,n=f.targets.length;s<n;s++)t+=`:`+Re(f.targets[s]);return t}function Re(f){let t=``,e=Object.keys(f).sort();for(let s=0,n=e.length;s<n;s++)t+=e[s]+`:`+f[e[s]]+`;`;return t}function ze(f){switch(f){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 Gt(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?`image/jpeg`:f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?`image/webp`:f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var Kt=new ze$1;var Ve=class{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new kt,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,r=!1,i=-1;if(typeof navigator<`u`&&typeof navigator.userAgent<`u`){let a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;let o=a.match(/Version\/(\d+)/);n=s&&o?parseInt(o[1],10):-1,r=a.indexOf(`Firefox`)>-1,i=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||s&&n<17||r&&i<98?this.textureLoader=new zh(this.options.manager):this.textureLoader=new Wh(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new yn(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){let s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies(`scene`),s.getDependencies(`animation`),s.getDependencies(`camera`)])}).then(function(i){let a={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:s,userData:{}};return v(r,a,n),I(a,n),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(let o of a.scenes)o.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){let t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){let i=e[n].joints;for(let a=0,o=i.length;a<o;a++)t[i[a]].isBone=!0}for(let n=0,r=t.length;n<r;n++){let i=t[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(s[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;let n=s.clone(),r=(i,a)=>{let o=this.associations.get(i);o!=null&&this.associations.set(a,o);for(let[c,u]of i.children.entries())r(u,a.children[c])};return r(s,n),n.name+=`_instance_`+t.uses[e]++,n}_invokeOne(t){let e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){let n=t(e[s]);if(n)return n}return null}_invokeAll(t){let e=Object.values(this.plugins);e.unshift(this);let s=[];for(let n=0;n<e.length;n++){let r=t(e[n]);r&&s.push(r)}return s}getDependency(t,e){let s=t+`:`+e,n=this.cache.get(s);if(!n){switch(t){case`scene`:n=this.loadScene(e);break;case`node`:n=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case`mesh`:n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case`accessor`:n=this.loadAccessor(e);break;case`bufferView`:n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case`buffer`:n=this.loadBuffer(e);break;case`material`:n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case`texture`:n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case`skin`:n=this.loadSkin(e);break;case`animation`:n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case`camera`:n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!n)throw new Error(`Unknown type: `+t);break}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){let s=this,n=this.json[t+(t===`mesh`?`es`:`s`)]||[];e=Promise.all(n.map(function(r,i){return s.getDependency(t,i)})),this.cache.add(t,e)}return e}loadBuffer(t){let e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!==`arraybuffer`)throw new Error(`THREE.GLTFLoader: `+e.type+` buffer type is not supported.`);if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[g.KHR_BINARY_GLTF].body);let n=this.options;return new Promise(function(r,i){s.load(Kr.resolveURL(e.uri,n.path),r,void 0,function(){i(new Error(`THREE.GLTFLoader: Failed to load buffer "`+e.uri+`".`))})})}loadBufferView(t){let e=this.json.bufferViews[t];return this.getDependency(`buffer`,e.buffer).then(function(s){let n=e.byteLength||0,r=e.byteOffset||0;return s.slice(r,r+n)})}loadAccessor(t){let e=this,s=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){let i=Te[n.type],a=D[n.componentType],o=n.normalized===!0,c=new a(n.count*i);return Promise.resolve(new lt(c,i,o))}let r=[];return n.bufferView!==void 0?r.push(this.getDependency(`bufferView`,n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency(`bufferView`,n.sparse.indices.bufferView)),r.push(this.getDependency(`bufferView`,n.sparse.values.bufferView))),Promise.all(r).then(function(i){let a=i[0],o=Te[n.type],c=D[n.componentType],u=c.BYTES_PER_ELEMENT,l=u*o,d=n.byteOffset||0,h=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,p=n.normalized===!0,A,m;if(h&&h!==l){let T=Math.floor(d/h),b=`InterleavedBuffer:`+n.bufferView+`:`+n.componentType+`:`+T+`:`+n.count,x=e.cache.get(b);x||(A=new c(a,T*h,n.count*h/u),x=new Os(A,h/u),e.cache.add(b,x)),m=new Ji(x,o,d%h/u,p)}else a===null?A=new c(n.count*o):A=new c(a,d,n.count*o),m=new lt(A,o,p);if(n.sparse!==void 0){let T=Te.SCALAR,b=D[n.sparse.indices.componentType],x=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,w=new b(i[1],x,n.sparse.count*T),L=new c(i[2],R,n.sparse.count*o);a!==null&&(m=new lt(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let _=0,F=w.length;_<F;_++){let k=w[_];if(m.setX(k,L[_*o]),o>=2&&m.setY(k,L[_*o+1]),o>=3&&m.setZ(k,L[_*o+2]),o>=4&&m.setW(k,L[_*o+3]),o>=5)throw new Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}m.normalized=p}return m})}loadTexture(t){let e=this.json,s=this.options,r=e.textures[t].source,i=e.images[r],a=this.textureLoader;if(i.uri){let o=s.manager.getHandler(i.uri);o!==null&&(a=o)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,s){let n=this,r=this.json,i=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+`:`+i.sampler;if(this.textureCache[o])return this.textureCache[o];let c=this.loadImageSource(e,s).then(function(u){u.flipY=!1,u.name=i.name||a.name||``,u.name===``&&typeof a.uri==`string`&&a.uri.startsWith(`data:image/`)===!1&&(u.name=a.uri);let d=(r.samplers||{})[i.sampler]||{};return u.magFilter=Lt[d.magFilter]||1006,u.minFilter=Lt[d.minFilter]||1008,u.wrapS=Ot[d.wrapS]||1e3,u.wrapT=Ot[d.wrapT]||1e3,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==1003&&u.minFilter!==1006,n.associations.set(u,{textures:t}),u}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){let s=this,n=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(l=>l.clone());let i=n.images[t],a=self.URL||self.webkitURL,o=i.uri||``,c=!1;if(i.bufferView!==void 0)o=s.getDependency(`bufferView`,i.bufferView).then(function(l){c=!0;let d=new Blob([l],{type:i.mimeType});return o=a.createObjectURL(d),o});else if(i.uri===void 0)throw new Error(`THREE.GLTFLoader: Image `+t+` is missing URI and bufferView`);let u=Promise.resolve(o).then(function(l){return new Promise(function(d,h){let p=d;e.isImageBitmapLoader===!0&&(p=function(A){let m=new kt$1(A);m.needsUpdate=!0,d(m)}),e.load(Kr.resolveURL(l,r.path),p,void 0,h)})}).then(function(l){return c===!0&&a.revokeObjectURL(o),I(l,i),l.userData.mimeType=i.mimeType||Gt(i.uri),l}).catch(function(l){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,o),l});return this.sourceCache[t]=u,u}assignTexture(t,e,s,n){let r=this;return this.getDependency(`texture`,s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),r.extensions[g.KHR_TEXTURE_TRANSFORM]){let a=s.extensions!==void 0?s.extensions[g.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let o=r.associations.get(i);i=r.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),r.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),t[e]=i,i})}assignFinalMaterial(t){let e=t.geometry,s=t.material,n=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,i=e.attributes.normal===void 0;if(t.isPoints){let a=`PointsMaterial:`+s.uuid,o=this.cache.get(a);o||(o=new Cr,Nt$1.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(t.isLine){let a=`LineBasicMaterial:`+s.uuid,o=this.cache.get(a);o||(o=new Ft$1,Nt$1.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(n||r||i){let a=`ClonedMaterial:`+s.uuid+`:`;n&&(a+=`derivative-tangents:`),r&&(a+=`vertex-colors:`),i&&(a+=`flat-shading:`);let o=this.cache.get(a);o||(o=s.clone(),r&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}t.material=s}getMaterialType(){return Hr}loadMaterial(t){let e=this,s=this.json,n=this.extensions,r=s.materials[t],i,a={},o=r.extensions||{},c=[];if(o[g.KHR_MATERIALS_UNLIT]){let l=n[g.KHR_MATERIALS_UNLIT];i=l.getMaterialType(),c.push(l.extendParams(a,r,e))}else{let l=r.pbrMetallicRoughness||{};if(a.color=new Me$1(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){let d=l.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],vr),a.opacity=d[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,`map`,l.baseColorTexture,`srgb`)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,`metalnessMap`,l.metallicRoughnessTexture)),c.push(e.assignTexture(a,`roughnessMap`,l.metallicRoughnessTexture))),i=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=2);let u=r.alphaMode||Ae.OPAQUE;if(u===Ae.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===Ae.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==Ln&&(c.push(e.assignTexture(a,`normalMap`,r.normalTexture)),a.normalScale=new K(1,1),r.normalTexture.scale!==void 0)){let l=r.normalTexture.scale;a.normalScale.set(l,l)}if(r.occlusionTexture!==void 0&&i!==Ln&&(c.push(e.assignTexture(a,`aoMap`,r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==Ln){let l=r.emissiveFactor;a.emissive=new Me$1().setRGB(l[0],l[1],l[2],vr)}return r.emissiveTexture!==void 0&&i!==Ln&&c.push(e.assignTexture(a,`emissiveMap`,r.emissiveTexture,`srgb`)),Promise.all(c).then(function(){let l=new i(a);return r.name&&(l.name=r.name),I(l,r),e.associations.set(l,{materials:t}),r.extensions&&v(n,l,r),l})}createUniqueName(t){let e=mt.sanitizeNodeName(t||``);return e in this.nodeNamesUsed?e+`_`+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){let e=this,s=this.extensions,n=this.primitiveCache;function r(a){return s[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return Ct(o,a,e)})}let i=[];for(let a=0,o=t.length;a<o;a++){let c=t[a],u=Ut(c),l=n[u];if(l)i.push(l.promise);else{let d;c.extensions&&c.extensions[g.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=Ct(new Ye,c,e),n[u]={primitive:c,promise:d},i.push(d)}}return Promise.all(i)}loadMesh(t){let e=this,s=this.json,n=this.extensions,r=s.meshes[t],i=r.primitives,a=[];for(let o=0,c=i.length;o<c;o++){let u=i[o].material===void 0?Ht(this.cache):this.getDependency(`material`,i[o].material);a.push(u)}return a.push(e.loadGeometries(i)),Promise.all(a).then(function(o){let c=o.slice(0,o.length-1),u=o[o.length-1],l=[];for(let h=0,p=u.length;h<p;h++){let A=u[h],m=i[h],T,b=c[h];if(m.mode===E.TRIANGLES||m.mode===E.TRIANGLE_STRIP||m.mode===E.TRIANGLE_FAN||m.mode===void 0)T=r.isSkinnedMesh===!0?new Eo(A,b):new Mt$1(A,b),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),m.mode===E.TRIANGLE_STRIP?T.geometry=ge(T.geometry,1):m.mode===E.TRIANGLE_FAN&&(T.geometry=ge(T.geometry,2));else if(m.mode===E.LINES)T=new pn(A,b);else if(m.mode===E.LINE_STRIP)T=new Dn(A,b);else if(m.mode===E.LINE_LOOP)T=new Do(A,b);else if(m.mode===E.POINTS)T=new No(A,b);else throw new Error(`THREE.GLTFLoader: Primitive mode unsupported: `+m.mode);Object.keys(T.geometry.morphAttributes).length>0&&Ft(T,r),T.name=e.createUniqueName(r.name||`mesh_`+t),I(T,r),m.extensions&&v(n,T,m),e.assignFinalMaterial(T),l.push(T)}for(let h=0,p=l.length;h<p;h++)e.associations.set(l[h],{meshes:t,primitives:h});if(l.length===1)return r.extensions&&v(n,l[0],r),l[0];let d=new pi;r.extensions&&v(n,d,r),e.associations.set(d,{meshes:t});for(let h=0,p=l.length;h<p;h++)d.add(l[h]);return d})}loadCamera(t){let e,s=this.json.cameras[t],n=s[s.type];if(!n){console.warn(`THREE.GLTFLoader: Missing camera parameters.`);return}return s.type===`perspective`?e=new Ct$1(Eg.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type===`orthographic`&&(e=new ss(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),I(e,s),Promise.resolve(e)}loadSkin(t){let e=this.json.skins[t],s=[];for(let n=0,r=e.joints.length;n<r;n++)s.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency(`accessor`,e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){let r=n.pop(),i=n,a=[],o=[];for(let c=0,u=i.length;c<u;c++){let l=i[c];if(l){a.push(l);let d=new ze$1;r!==null&&d.fromArray(r.array,c*16),o.push(d)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,e.joints[c])}return new wo(a,o)})}loadAnimation(t){let e=this.json,s=this,n=e.animations[t],r=n.name?n.name:`animation_`+t,i=[],a=[],o=[],c=[],u=[];for(let l=0,d=n.channels.length;l<d;l++){let h=n.channels[l],p=n.samplers[h.sampler],A=h.target,m=A.node,T=n.parameters!==void 0?n.parameters[p.input]:p.input,b=n.parameters!==void 0?n.parameters[p.output]:p.output;A.node!==void 0&&(i.push(this.getDependency(`node`,m)),a.push(this.getDependency(`accessor`,T)),o.push(this.getDependency(`accessor`,b)),c.push(p),u.push(A))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(u)]).then(function(l){let d=l[0],h=l[1],p=l[2],A=l[3],m=l[4],T=[];for(let x=0,R=d.length;x<R;x++){let w=d[x],L=h[x],_=p[x],F=A[x],k=m[x];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();let Q=s._createAnimationTracks(w,L,_,F,k);if(Q)for(let J=0;J<Q.length;J++)T.push(Q[J])}let b=new ns(r,void 0,T);return I(b,n),b})}createNodeMesh(t){let e=this.json,s=this,n=e.nodes[t];return n.mesh===void 0?null:s.getDependency(`mesh`,n.mesh).then(function(r){let i=s._getNodeRef(s.meshCache,n.mesh,r);return n.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),i})}loadNode(t){let e=this.json,s=this,n=e.nodes[t],r=s._loadNodeShallow(t),i=[],a=n.children||[];for(let c=0,u=a.length;c<u;c++)i.push(s.getDependency(`node`,a[c]));let o=n.skin===void 0?Promise.resolve(null):s.getDependency(`skin`,n.skin);return Promise.all([r,Promise.all(i),o]).then(function(c){let u=c[0],l=c[1],d=c[2];d!==null&&u.traverse(function(h){h.isSkinnedMesh&&h.bind(d,Kt)});for(let h=0,p=l.length;h<p;h++)u.add(l[h]);if(u.userData.pivot!==void 0&&l.length>0){let h=u.userData.pivot,p=l[0];u.pivot=new C$1().fromArray(h),u.position.x-=h[0],u.position.y-=h[1],u.position.z-=h[2],p.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(t){let e=this.json,s=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];let r$1=e.nodes[t],i=r$1.name?n.createUniqueName(r$1.name):``,a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return o&&a.push(o),r$1.camera!==void 0&&a.push(n.getDependency(`camera`,r$1.camera).then(function(c){return n._getNodeRef(n.cameraCache,r$1.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){a.push(c)}),this.nodeCache[t]=Promise.all(a).then(function(c){let u;if(r$1.isBone===!0?u=new wr:c.length>1?u=new pi:c.length===1?u=c[0]:u=new gt,u!==c[0])for(let l=0,d=c.length;l<d;l++)u.add(c[l]);if(r$1.name&&(u.userData.name=r$1.name,u.name=i),I(u,r$1),r$1.extensions&&v(s,u,r$1),r$1.matrix!==void 0){let l=new ze$1;l.fromArray(r$1.matrix),u.applyMatrix4(l)}else r$1.translation!==void 0&&u.position.fromArray(r$1.translation),r$1.rotation!==void 0&&u.quaternion.fromArray(r$1.rotation),r$1.scale!==void 0&&u.scale.fromArray(r$1.scale);if(!n.associations.has(u))n.associations.set(u,{});else if(r$1.mesh!==void 0&&n.meshCache.refs[r$1.mesh]>1){let l=n.associations.get(u);n.associations.set(u,r({},l))}return n.associations.get(u).nodes=t,u}),this.nodeCache[t]}loadScene(t){let e=this.extensions,s=this.json.scenes[t],n=this,r=new pi;s.name&&(r.name=n.createUniqueName(s.name)),I(r,s),s.extensions&&v(e,r,s);let i=s.nodes||[],a=[];for(let o=0,c=i.length;o<c;o++)a.push(n.getDependency(`node`,i[o]));return Promise.all(a).then(function(o){for(let u=0,l=o.length;u<l;u++){let d=o[u];d.parent!==null?r.add(Mt(d)):r.add(d)}let c=u=>{let l=new Map;for(let[d,h]of n.associations)(d instanceof Nt$1||d instanceof kt$1)&&l.set(d,h);return u.traverse(d=>{let h=n.associations.get(d);h!=null&&l.set(d,h)}),l};return n.associations=c(r),r})}_createAnimationTracks(t,e,s,n,r){let i=[],a=t.name?t.name:t.uuid,o=[];function c(h){h.morphTargetInfluences&&o.push(h.name?h.name:h.uuid)}C[r.path]===C.weights?(c(t),t.isGroup&&t.children.forEach(c)):o.push(a);let u;switch(C[r.path]){case C.weights:u=ji;break;case C.rotation:u=es;break;case C.translation:case C.scale:u=ts;break;default:s.itemSize===1?u=ji:u=ts;break}let l=n.interpolation!==void 0?Bt[n.interpolation]:xo,d=this._getArrayFromAccessor(s);for(let h=0,p=o.length;h<p;h++){let A=new u(o[h]+`.`+C[r.path],e.array,d,l);n.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(A),i.push(A)}return i}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){let s=ze(e.constructor),n=new Float32Array(e.length);for(let r=0,i=e.length;r<i;r++)n[r]=e[r]*s;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){return new(this instanceof es?Ge:Z)(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function zt(f,t,e){let s=t.attributes,n=new Dt$1;if(s.POSITION!==void 0){let a=e.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new C$1(o[0],o[1],o[2]),new C$1(c[0],c[1],c[2])),a.normalized){let u=ze(D[a.componentType]);n.min.multiplyScalar(u),n.max.multiplyScalar(u)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let r=t.targets;if(r!==void 0){let a=new C$1,o=new C$1;for(let c=0,u=r.length;c<u;c++){let l=r[c];if(l.POSITION!==void 0){let d=e.json.accessors[l.POSITION],h=d.min,p=d.max;if(h!==void 0&&p!==void 0){if(o.setX(Math.max(Math.abs(h[0]),Math.abs(p[0]))),o.setY(Math.max(Math.abs(h[1]),Math.abs(p[1]))),o.setZ(Math.max(Math.abs(h[2]),Math.abs(p[2]))),d.normalized){let A=ze(D[d.componentType]);o.multiplyScalar(A)}a.max(o)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}n.expandByVector(a)}f.boundingBox=n;let i=new Rt;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,f.boundingSphere=i}function Ct(f,t,e){let s=t.attributes,n=[];function r(i,a){return e.getDependency(`accessor`,i).then(function(o){f.setAttribute(a,o)})}for(let i in s){let a=Ke[i]||i.toLowerCase();a in f.attributes||n.push(r(s[i],a))}if(t.indices!==void 0&&!f.index){let i=e.getDependency(`accessor`,t.indices).then(function(a){f.setIndex(a)});n.push(i)}return tt.workingColorSpace!==`srgb-linear`&&`COLOR_0`in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${tt.workingColorSpace}" not supported.`),I(f,t),zt(f,t,e),Promise.all(n).then(function(){return t.targets!==void 0?Dt(f,t.targets,e):f})}export{It as GLTFLoader};