miijs
Version:
The most complete and easy to use Mii library available.
1 lines • 126 kB
JavaScript
import"./chunk-AR532XI3.js";import{Ab as o,P as bn,ua as je}from"./chunk-QXQ57AU5.js";import{$b as se,A as xt,Aa as Et,Ae as un,Bd as At,Be as fn,Cg as Tn,D as _t,Dd as g,E as ko,Ed as ie,F as Go,Fd as q,Fg as En,G as zo,Gf as mn,Hd as _e,Id as yt,Jb as Yo,Jd as on,Kb as wt,Md as nn,Nf as It,Pa as Ne,Pd as Rt,Pf as Ae,Qd as Mt,Rb as $o,Rd as Te,Rf as ye,Sa as Xo,Sb as He,Sd as z,Sf as ze,Tb as xe,Tg as wn,Ua as qo,Wf as dn,Xf as Dt,Yd as St,_d as ae,a as pt,ac as G,bg as pn,ce,eg as hn,fd as Zo,fg as gn,gd as Be,ge as Ee,gg as Ve,hd as Q,he as we,hg as xn,id as R,ie as be,kd as Ue,kf as Lt,l as Oe,m as Uo,me as N,n as re,na as Pe,nd as bt,ne as le,ng as ue,o as ht,oa as Vo,od as Jo,oe as Ft,pa as J,pd as Qo,pe as Ge,qa as Tt,qd as en,qe as vt,ra as jo,re as rn,rg as _n,t as gt,ta as Wo,va as K,vd as ke,vf as Ct,wa as Ko,wd as tn,we as sn,wf as H,xe as an,ya as ge,yd as I,ye as cn,ze as ln}from"./chunk-R7OXYAFO.js";import{a as or}from"./chunk-HMW42XQT.js";import{a as Bo,i as Ot,j as We,n as Ke}from"./chunk-AD7HDZ5R.js";import{b as dt,c as De,i as ne}from"./chunk-C7XDOTG6.js";import{c as er,d as tr,f as F,g as y}from"./chunk-VMLSR5BU.js";y();y();y();function Pt(a,e){if(e===$o)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),a;if(e===xe||e===He){let t=a.getIndex();if(t===null){let i=[],c=a.getAttribute("position");if(c!==void 0){for(let l=0;l<c.count;l++)i.push(l);a.setIndex(i),t=a.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),a}let n=t.count-2,r=[];if(e===xe)for(let i=1;i<=n;i++)r.push(t.getX(0)),r.push(t.getX(i)),r.push(t.getX(i+1));else for(let i=0;i<n;i++)i%2===0?(r.push(t.getX(i)),r.push(t.getX(i+1)),r.push(t.getX(i+2))):(r.push(t.getX(i+2)),r.push(t.getX(i+1)),r.push(t.getX(i)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let s=a.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),a}y();var Me=class extends dn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new zt(t)}),this.register(function(t){return new Vt(t)}),this.register(function(t){return new Jt(t)}),this.register(function(t){return new Qt(t)}),this.register(function(t){return new eo(t)}),this.register(function(t){return new Wt(t)}),this.register(function(t){return new Kt(t)}),this.register(function(t){return new Xt(t)}),this.register(function(t){return new qt(t)}),this.register(function(t){return new Gt(t)}),this.register(function(t){return new Yt(t)}),this.register(function(t){return new jt(t)}),this.register(function(t){return new Zt(t)}),this.register(function(t){return new $t(t)}),this.register(function(t){return new Ut(t)}),this.register(function(t){return new to(t)}),this.register(function(t){return new oo(t)})}load(e,t,n,r){let s=this,i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){let u=ue.extractUrlBase(e);i=ue.resolveURL(u,this.path)}else i=ue.extractUrlBase(e);this.manager.itemStart(e);let c=function(u){r?r(u):console.error(u),s.manager.itemError(e),s.manager.itemEnd(e)},l=new Dt(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(u){try{s.parse(u,i,function(f){t(f),s.manager.itemEnd(e)},c)}catch(f){c(f)}},n,c)}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,n,r){let s,i={},c={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Sn){try{i[E.KHR_BINARY_GLTF]=new no(e)}catch(m){r&&r(m);return}s=JSON.parse(i[E.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let u=new uo(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){let m=this.pluginCallbacks[f](u);m.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[m.name]=m,i[m.name]=!0}if(s.extensionsUsed)for(let f=0;f<s.extensionsUsed.length;++f){let m=s.extensionsUsed[f],d=s.extensionsRequired||[];switch(m){case E.KHR_MATERIALS_UNLIT:i[m]=new kt;break;case E.KHR_DRACO_MESH_COMPRESSION:i[m]=new ro(s,this.dracoLoader);break;case E.KHR_TEXTURE_TRANSFORM:i[m]=new so;break;case E.KHR_MESH_QUANTIZATION:i[m]=new io;break;default:d.indexOf(m)>=0&&c[m]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+m+'".')}}u.setExtensions(i),u.setPlugins(c),u.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}};function rr(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}var E={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"},Ut=class{constructor(e){this.parser=e,this.name=E.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,r=t.cache.get(n);if(r)return r;let s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],u,f=new g(16777215);l.color!==void 0&&f.setRGB(l.color[0],l.color[1],l.color[2],G);let m=l.range!==void 0?l.range:0;switch(l.type){case"directional":u=new xn(f),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new gn(f),u.distance=m;break;case"spot":u=new hn(f),u.distance=m,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,u.angle=l.spot.outerConeAngle,u.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return u.position.set(0,0,0),V(u,l),l.intensity!==void 0&&(u.intensity=l.intensity),u.name=t.createUniqueName(l.name||"light_"+e),r=Promise.resolve(u),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,s=n.json.nodes[e],c=(s.extensions&&s.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(l){return n._getNodeRef(t.cache,c,l)})}},kt=class{constructor(){this.name=E.KHR_MATERIALS_UNLIT}getMaterialType(){return q}extendParams(e,t,n){let r=[];e.color=new g(1,1,1),e.opacity=1;let s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){let i=s.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],G),e.opacity=i[3]}s.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",s.baseColorTexture,se))}return Promise.all(r)}},Gt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}},zt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],i=r.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){let c=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Be(c,c)}return Promise.all(s)}},Vt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_DISPERSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}},jt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],i=r.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}},Wt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_SHEEN}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[];t.sheenColor=new g(0,0,0),t.sheenRoughness=0,t.sheen=1;let i=r.extensions[this.name];if(i.sheenColorFactor!==void 0){let c=i.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],G)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,se)),i.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}},Kt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],i=r.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}},Xt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_VOLUME}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],i=r.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;let c=i.attenuationColor||[1,1,1];return t.attenuationColor=new g().setRGB(c[0],c[1],c[2],G),Promise.all(s)}},qt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_IOR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},Yt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_SPECULAR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],i=r.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));let c=i.specularColorFactor||[1,1,1];return t.specularColor=new g().setRGB(c[0],c[1],c[2],G),i.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,se)),Promise.all(s)}},$t=class{constructor(e){this.parser=e,this.name=E.EXT_MATERIALS_BUMP}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],i=r.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}},Zt=class{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:H}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],i=r.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}},Jt=class{constructor(e){this.parser=e,this.name=E.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let s=r.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,i)}},Qt=class{constructor(e){this.parser=e,this.name=E.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let i=s.extensions[t],c=r.images[i.source],l=n.textureLoader;if(c.uri){let u=n.options.manager.getHandler(c.uri);u!==null&&(l=u)}return n.loadTextureImage(e,i.source,l)}},eo=class{constructor(e){this.parser=e,this.name=E.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let i=s.extensions[t],c=r.images[i.source],l=n.textureLoader;if(c.uri){let u=n.options.manager.getHandler(c.uri);u!==null&&(l=u)}return n.loadTextureImage(e,i.source,l)}},to=class{constructor(e){this.name=E.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let r=n.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(c){let l=r.byteOffset||0,u=r.byteLength||0,f=r.count,m=r.byteStride,d=new Uint8Array(c,l,u);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(f,m,d,r.mode,r.filter).then(function(p){return p.buffer}):i.ready.then(function(){let p=new ArrayBuffer(f*m);return i.decodeGltfBuffer(new Uint8Array(p),f,m,d,r.mode,r.filter),p})})}else return null}},oo=class{constructor(e){this.name=E.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let u of r.primitives)if(u.mode!==D.TRIANGLES&&u.mode!==D.TRIANGLE_STRIP&&u.mode!==D.TRIANGLE_FAN&&u.mode!==void 0)return null;let i=n.extensions[this.name].attributes,c=[],l={};for(let u in i)c.push(this.parser.getDependency("accessor",i[u]).then(f=>(l[u]=f,l[u])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(u=>{let f=u.pop(),m=f.isGroup?f.children:[f],d=u[0].count,p=[];for(let h of m){let T=new I,x=new R,_=new Q,b=new R(1,1,1),w=new rn(h.geometry,h.material,d);for(let A=0;A<d;A++)l.TRANSLATION&&x.fromBufferAttribute(l.TRANSLATION,A),l.ROTATION&&_.fromBufferAttribute(l.ROTATION,A),l.SCALE&&b.fromBufferAttribute(l.SCALE,A),w.setMatrixAt(A,T.compose(x,_,b));for(let A in l)if(A==="_COLOR_0"){let v=l[A];w.instanceColor=new vt(v.array,v.itemSize,v.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&h.geometry.setAttribute(A,l[A]);At.prototype.copy.call(w,h),this.parser.assignFinalMaterial(w),p.push(w)}return f.isGroup?(f.clear(),f.add(...p),f):p[0]}))}},Sn="glTF",Re=12,An={JSON:1313821514,BIN:5130562},no=class{constructor(e){this.name=E.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Re),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Sn)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let r=this.header.length-Re,s=new DataView(e,Re),i=0;for(;i<r;){let c=s.getUint32(i,!0);i+=4;let l=s.getUint32(i,!0);if(i+=4,l===An.JSON){let u=new Uint8Array(e,Re+i,c);this.content=n.decode(u)}else if(l===An.BIN){let u=Re+i;this.body=e.slice(u,u+c)}i+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},ro=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=E.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,c={},l={},u={};for(let f in i){let m=co[f]||f.toLowerCase();c[m]=i[f]}for(let f in e.attributes){let m=co[f]||f.toLowerCase();if(i[f]!==void 0){let d=n.accessors[e.attributes[f]],p=fe[d.componentType];u[m]=p.name,l[m]=d.normalized===!0}}return t.getDependency("bufferView",s).then(function(f){return new Promise(function(m,d){r.decodeDracoFile(f,function(p){for(let h in p.attributes){let T=p.attributes[h],x=l[h];x!==void 0&&(T.normalized=x)}m(p)},c,u,G,d)})})}},so=class{constructor(){this.name=E.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}},io=class{constructor(){this.name=E.KHR_MESH_QUANTIZATION}},Xe=class extends mn{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let i=0;i!==r;i++)t[i]=n[s+i];return t}interpolate_(e,t,n,r){let s=this.resultBuffer,i=this.sampleValues,c=this.valueSize,l=c*2,u=c*3,f=r-t,m=(n-t)/f,d=m*m,p=d*m,h=e*u,T=h-u,x=-2*p+3*d,_=p-d,b=1-x,w=_-d+m;for(let A=0;A!==c;A++){let v=i[T+A+c],k=i[T+A+l]*f,P=i[h+A+c],he=i[h+A]*f;s[A]=b*v+w*k+x*P+_*he}return s}},sr=new Q,ao=class extends Xe{interpolate_(e,t,n,r){let s=super.interpolate_(e,t,n,r);return sr.fromArray(s).normalize().toArray(s),s}},D={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},fe={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yn={9728:Tt,9729:K,9984:jo,9985:Ko,9986:Wo,9987:ge},Rn={33071:Vo,33648:J,10497:Pe},Nt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},co={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"},Y={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ir={CUBICSPLINE:void 0,LINEAR:wt,STEP:Yo},Ht={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ar(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new Ct({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Oe})),a.DefaultMaterial}function ee(a,e,t){for(let n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function V(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function cr(a,e,t){let n=!1,r=!1,s=!1;for(let u=0,f=e.length;u<f;u++){let m=e[u];if(m.POSITION!==void 0&&(n=!0),m.NORMAL!==void 0&&(r=!0),m.COLOR_0!==void 0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(a);let i=[],c=[],l=[];for(let u=0,f=e.length;u<f;u++){let m=e[u];if(n){let d=m.POSITION!==void 0?t.getDependency("accessor",m.POSITION):a.attributes.position;i.push(d)}if(r){let d=m.NORMAL!==void 0?t.getDependency("accessor",m.NORMAL):a.attributes.normal;c.push(d)}if(s){let d=m.COLOR_0!==void 0?t.getDependency("accessor",m.COLOR_0):a.attributes.color;l.push(d)}}return Promise.all([Promise.all(i),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],m=u[1],d=u[2];return n&&(a.morphAttributes.position=f),r&&(a.morphAttributes.normal=m),s&&(a.morphAttributes.color=d),a.morphTargetsRelative=!0,a})}function lr(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)a.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(a.morphTargetInfluences.length===t.length){a.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)a.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ur(a){let e,t=a.extensions&&a.extensions[E.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Bt(t.attributes):e=a.indices+":"+Bt(a.attributes)+":"+a.mode,a.targets!==void 0)for(let n=0,r=a.targets.length;n<r;n++)e+=":"+Bt(a.targets[n]);return e}function Bt(a){let e="",t=Object.keys(a).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+a[t[n]]+";";return e}function lo(a){switch(a){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 fr(a){return a.search(/\.jpe?g($|\?)/i)>0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":a.search(/\.ktx2($|\?)/i)>0||a.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var mr=new I,uo=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new rr,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,s=!1,i=-1;if(typeof navigator<"u"){let c=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(c)===!0;let l=c.match(/Version\/(\d+)/);r=n&&l?parseInt(l[1],10):-1,s=c.indexOf("Firefox")>-1,i=s?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&r<17||s&&i<98?this.textureLoader=new pn(this.options.manager):this.textureLoader=new _n(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Dt(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){let n=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){let c={scene:i[0][r.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:r.asset,parser:n,userData:{}};return ee(s,c,r),V(c,r),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(c)})).then(function(){for(let l of c.scenes)l.updateMatrixWorld();e(c)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){let i=t[r].joints;for(let c=0,l=i.length;c<l;c++)e[i[c]].isBone=!0}for(let r=0,s=e.length;r<s;r++){let i=e[r];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),s=(i,c)=>{let l=this.associations.get(i);l!=null&&this.associations.set(c,l);for(let[u,f]of i.children.entries())s(f,c.children[u])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let s=e(t[r]);s&&n.push(s)}return n}getDependency(e,t){let n=e+":"+t,r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":r=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(s,i){return n.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(s,i){n.load(ue.resolveURL(t.uri,r.path),s,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let r=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+r)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let i=Nt[r.type],c=fe[r.componentType],l=r.normalized===!0,u=new c(r.count*i);return Promise.resolve(new _e(u,i,l))}let s=[];return r.bufferView!==void 0?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),r.sparse!==void 0&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(i){let c=i[0],l=Nt[r.type],u=fe[r.componentType],f=u.BYTES_PER_ELEMENT,m=f*l,d=r.byteOffset||0,p=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,h=r.normalized===!0,T,x;if(p&&p!==m){let _=Math.floor(d/p),b="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+_+":"+r.count,w=t.cache.get(b);w||(T=new u(c,_*p,r.count*p/f),w=new we(T,p/f),t.cache.add(b,w)),x=new be(w,l,d%p/f,h)}else c===null?T=new u(r.count*l):T=new u(c,d,r.count*l),x=new _e(T,l,h);if(r.sparse!==void 0){let _=Nt.SCALAR,b=fe[r.sparse.indices.componentType],w=r.sparse.indices.byteOffset||0,A=r.sparse.values.byteOffset||0,v=new b(i[1],w,r.sparse.count*_),k=new u(i[2],A,r.sparse.count*l);c!==null&&(x=new _e(x.array.slice(),x.itemSize,x.normalized)),x.normalized=!1;for(let P=0,he=v.length;P<he;P++){let oe=v[P];if(x.setX(oe,k[P*l]),l>=2&&x.setY(oe,k[P*l+1]),l>=3&&x.setZ(oe,k[P*l+2]),l>=4&&x.setW(oe,k[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=h}return x})}loadTexture(e){let t=this.json,n=this.options,s=t.textures[e].source,i=t.images[s],c=this.textureLoader;if(i.uri){let l=n.manager.getHandler(i.uri);l!==null&&(c=l)}return this.loadTextureImage(e,s,c)}loadTextureImage(e,t,n){let r=this,s=this.json,i=s.textures[e],c=s.images[t],l=(c.uri||c.bufferView)+":"+i.sampler;if(this.textureCache[l])return this.textureCache[l];let u=this.loadImageSource(t,n).then(function(f){f.flipY=!1,f.name=i.name||c.name||"",f.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(f.name=c.uri);let d=(s.samplers||{})[i.sampler]||{};return f.magFilter=yn[d.magFilter]||K,f.minFilter=yn[d.minFilter]||ge,f.wrapS=Rn[d.wrapS]||Pe,f.wrapT=Rn[d.wrapT]||Pe,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==Tt&&f.minFilter!==K,r.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[l]=u,u}loadImageSource(e,t){let n=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(m=>m.clone());let i=r.images[e],c=self.URL||self.webkitURL,l=i.uri||"",u=!1;if(i.bufferView!==void 0)l=n.getDependency("bufferView",i.bufferView).then(function(m){u=!0;let d=new Blob([m],{type:i.mimeType});return l=c.createObjectURL(d),l});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let f=Promise.resolve(l).then(function(m){return new Promise(function(d,p){let h=d;t.isImageBitmapLoader===!0&&(h=function(T){let x=new bt(T);x.needsUpdate=!0,d(x)}),t.load(ue.resolveURL(m,s.path),h,void 0,p)})}).then(function(m){return u===!0&&c.revokeObjectURL(l),V(m,i),m.userData.mimeType=i.mimeType||fr(i.uri),m}).catch(function(m){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),m});return this.sourceCache[e]=f,f}assignTexture(e,t,n,r){let s=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),s.extensions[E.KHR_TEXTURE_TRANSFORM]){let c=n.extensions!==void 0?n.extensions[E.KHR_TEXTURE_TRANSFORM]:void 0;if(c){let l=s.associations.get(i);i=s.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(i,c),s.associations.set(i,l)}}return r!==void 0&&(i.colorSpace=r),e[t]=i,i})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){let c="PointsMaterial:"+n.uuid,l=this.cache.get(c);l||(l=new un,ie.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(c,l)),n=l}else if(e.isLine){let c="LineBasicMaterial:"+n.uuid,l=this.cache.get(c);l||(l=new sn,ie.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(c,l)),n=l}if(r||s||i){let c="ClonedMaterial:"+n.uuid+":";r&&(c+="derivative-tangents:"),s&&(c+="vertex-colors:"),i&&(c+="flat-shading:");let l=this.cache.get(c);l||(l=n.clone(),s&&(l.vertexColors=!0),i&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(c,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return Ct}loadMaterial(e){let t=this,n=this.json,r=this.extensions,s=n.materials[e],i,c={},l=s.extensions||{},u=[];if(l[E.KHR_MATERIALS_UNLIT]){let m=r[E.KHR_MATERIALS_UNLIT];i=m.getMaterialType(),u.push(m.extendParams(c,s,t))}else{let m=s.pbrMetallicRoughness||{};if(c.color=new g(1,1,1),c.opacity=1,Array.isArray(m.baseColorFactor)){let d=m.baseColorFactor;c.color.setRGB(d[0],d[1],d[2],G),c.opacity=d[3]}m.baseColorTexture!==void 0&&u.push(t.assignTexture(c,"map",m.baseColorTexture,se)),c.metalness=m.metallicFactor!==void 0?m.metallicFactor:1,c.roughness=m.roughnessFactor!==void 0?m.roughnessFactor:1,m.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(c,"metalnessMap",m.metallicRoughnessTexture)),u.push(t.assignTexture(c,"roughnessMap",m.metallicRoughnessTexture))),i=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,c)})))}s.doubleSided===!0&&(c.side=re);let f=s.alphaMode||Ht.OPAQUE;if(f===Ht.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,f===Ht.MASK&&(c.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==q&&(u.push(t.assignTexture(c,"normalMap",s.normalTexture)),c.normalScale=new Be(1,1),s.normalTexture.scale!==void 0)){let m=s.normalTexture.scale;c.normalScale.set(m,m)}if(s.occlusionTexture!==void 0&&i!==q&&(u.push(t.assignTexture(c,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==q){let m=s.emissiveFactor;c.emissive=new g().setRGB(m[0],m[1],m[2],G)}return s.emissiveTexture!==void 0&&i!==q&&u.push(t.assignTexture(c,"emissiveMap",s.emissiveTexture,se)),Promise.all(u).then(function(){let m=new i(c);return s.name&&(m.name=s.name),V(m,s),t.associations.set(m,{materials:e}),s.extensions&&ee(r,m,s),m})}createUniqueName(e){let t=Tn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function s(c){return n[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(l){return Mn(l,c,t)})}let i=[];for(let c=0,l=e.length;c<l;c++){let u=e[c],f=ur(u),m=r[f];if(m)i.push(m.promise);else{let d;u.extensions&&u.extensions[E.KHR_DRACO_MESH_COMPRESSION]?d=s(u):d=Mn(new Te,u,t),r[f]={primitive:u,promise:d},i.push(d)}}return Promise.all(i)}loadMesh(e){let t=this,n=this.json,r=this.extensions,s=n.meshes[e],i=s.primitives,c=[];for(let l=0,u=i.length;l<u;l++){let f=i[l].material===void 0?ar(this.cache):this.getDependency("material",i[l].material);c.push(f)}return c.push(t.loadGeometries(i)),Promise.all(c).then(function(l){let u=l.slice(0,l.length-1),f=l[l.length-1],m=[];for(let p=0,h=f.length;p<h;p++){let T=f[p],x=i[p],_,b=u[p];if(x.mode===D.TRIANGLES||x.mode===D.TRIANGLE_STRIP||x.mode===D.TRIANGLE_FAN||x.mode===void 0)_=s.isSkinnedMesh===!0?new N(T,b):new z(T,b),_.isSkinnedMesh===!0&&_.normalizeSkinWeights(),x.mode===D.TRIANGLE_STRIP?_.geometry=Pt(_.geometry,He):x.mode===D.TRIANGLE_FAN&&(_.geometry=Pt(_.geometry,xe));else if(x.mode===D.LINES)_=new cn(T,b);else if(x.mode===D.LINE_STRIP)_=new an(T,b);else if(x.mode===D.LINE_LOOP)_=new ln(T,b);else if(x.mode===D.POINTS)_=new fn(T,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(_.geometry.morphAttributes).length>0&&lr(_,s),_.name=t.createUniqueName(s.name||"mesh_"+e),V(_,s),x.extensions&&ee(r,_,x),t.assignFinalMaterial(_),m.push(_)}for(let p=0,h=m.length;p<h;p++)t.associations.set(m[p],{meshes:e,primitives:p});if(m.length===1)return s.extensions&&ee(r,m[0],s),m[0];let d=new ce;s.extensions&&ee(r,d,s),t.associations.set(d,{meshes:e});for(let p=0,h=m.length;p<h;p++)d.add(m[p]);return d})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new ae(Zo.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new Ve(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),V(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let r=0,s=t.joints.length;r<s;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){let s=r.pop(),i=r,c=[],l=[];for(let u=0,f=i.length;u<f;u++){let m=i[u];if(m){c.push(m);let d=new I;s!==null&&d.fromArray(s.array,u*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new Ge(c,l)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],s=r.name?r.name:"animation_"+e,i=[],c=[],l=[],u=[],f=[];for(let m=0,d=r.channels.length;m<d;m++){let p=r.channels[m],h=r.samplers[p.sampler],T=p.target,x=T.node,_=r.parameters!==void 0?r.parameters[h.input]:h.input,b=r.parameters!==void 0?r.parameters[h.output]:h.output;T.node!==void 0&&(i.push(this.getDependency("node",x)),c.push(this.getDependency("accessor",_)),l.push(this.getDependency("accessor",b)),u.push(h),f.push(T))}return Promise.all([Promise.all(i),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(f)]).then(function(m){let d=m[0],p=m[1],h=m[2],T=m[3],x=m[4],_=[];for(let w=0,A=d.length;w<A;w++){let v=d[w],k=p[w],P=h[w],he=T[w],oe=x[w];if(v===void 0)continue;v.updateMatrix&&v.updateMatrix();let ft=n._createAnimationTracks(v,k,P,he,oe);if(ft)for(let mt=0;mt<ft.length;mt++)_.push(ft[mt])}let b=new ze(s,void 0,_);return V(b,r),b})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(s){let i=n._getNodeRef(n.meshCache,r.mesh,s);return r.weights!==void 0&&i.traverse(function(c){if(c.isMesh)for(let l=0,u=r.weights.length;l<u;l++)c.morphTargetInfluences[l]=r.weights[l]}),i})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],s=n._loadNodeShallow(e),i=[],c=r.children||[];for(let u=0,f=c.length;u<f;u++)i.push(n.getDependency("node",c[u]));let l=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([s,Promise.all(i),l]).then(function(u){let f=u[0],m=u[1],d=u[2];d!==null&&f.traverse(function(p){p.isSkinnedMesh&&p.bind(d,mr)});for(let p=0,h=m.length;p<h;p++)f.add(m[p]);return f})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],i=s.name?r.createUniqueName(s.name):"",c=[],l=r._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return l&&c.push(l),s.camera!==void 0&&c.push(r.getDependency("camera",s.camera).then(function(u){return r._getNodeRef(r.cameraCache,s.camera,u)})),r._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){c.push(u)}),this.nodeCache[e]=Promise.all(c).then(function(u){let f;if(s.isBone===!0?f=new le:u.length>1?f=new ce:u.length===1?f=u[0]:f=new At,f!==u[0])for(let m=0,d=u.length;m<d;m++)f.add(u[m]);if(s.name&&(f.userData.name=s.name,f.name=i),V(f,s),s.extensions&&ee(n,f,s),s.matrix!==void 0){let m=new I;m.fromArray(s.matrix),f.applyMatrix4(m)}else s.translation!==void 0&&f.position.fromArray(s.translation),s.rotation!==void 0&&f.quaternion.fromArray(s.rotation),s.scale!==void 0&&f.scale.fromArray(s.scale);if(!r.associations.has(f))r.associations.set(f,{});else if(s.mesh!==void 0&&r.meshCache.refs[s.mesh]>1){let m=r.associations.get(f);r.associations.set(f,{...m})}return r.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,s=new ce;n.name&&(s.name=r.createUniqueName(n.name)),V(s,n),n.extensions&&ee(t,s,n);let i=n.nodes||[],c=[];for(let l=0,u=i.length;l<u;l++)c.push(r.getDependency("node",i[l]));return Promise.all(c).then(function(l){for(let f=0,m=l.length;f<m;f++)s.add(l[f]);let u=f=>{let m=new Map;for(let[d,p]of r.associations)(d instanceof ie||d instanceof bt)&&m.set(d,p);return f.traverse(d=>{let p=r.associations.get(d);p!=null&&m.set(d,p)}),m};return r.associations=u(s),s})}_createAnimationTracks(e,t,n,r,s){let i=[],c=e.name?e.name:e.uuid,l=[];Y[s.path]===Y.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(c);let u;switch(Y[s.path]){case Y.weights:u=It;break;case Y.rotation:u=Ae;break;case Y.translation:case Y.scale:u=ye;break;default:n.itemSize===1?u=It:u=ye;break}let f=r.interpolation!==void 0?ir[r.interpolation]:wt,m=this._getArrayFromAccessor(n);for(let d=0,p=l.length;d<p;d++){let h=new u(l[d]+"."+Y[s.path],t.array,m,f);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(h),i.push(h)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=lo(t.constructor),r=new Float32Array(t.length);for(let s=0,i=t.length;s<i;s++)r[s]=t[s]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let r=this instanceof Ae?ao:Xe;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function dr(a,e,t){let n=e.attributes,r=new ke;if(n.POSITION!==void 0){let c=t.json.accessors[n.POSITION],l=c.min,u=c.max;if(l!==void 0&&u!==void 0){if(r.set(new R(l[0],l[1],l[2]),new R(u[0],u[1],u[2])),c.normalized){let f=lo(fe[c.componentType]);r.min.multiplyScalar(f),r.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=e.targets;if(s!==void 0){let c=new R,l=new R;for(let u=0,f=s.length;u<f;u++){let m=s[u];if(m.POSITION!==void 0){let d=t.json.accessors[m.POSITION],p=d.min,h=d.max;if(p!==void 0&&h!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(h[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(h[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(h[2]))),d.normalized){let T=lo(fe[d.componentType]);l.multiplyScalar(T)}c.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(c)}a.boundingBox=r;let i=new tn;r.getCenter(i.center),i.radius=r.min.distanceTo(r.max)/2,a.boundingSphere=i}function Mn(a,e,t){let n=e.attributes,r=[];function s(i,c){return t.getDependency("accessor",i).then(function(l){a.setAttribute(c,l)})}for(let i in n){let c=co[i]||i.toLowerCase();c in a.attributes||r.push(s(n[i],c))}if(e.indices!==void 0&&!a.index){let i=t.getDependency("accessor",e.indices).then(function(c){a.setIndex(c)});r.push(i)}return Ue.workingColorSpace!==G&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ue.workingColorSpace}" not supported.`),V(a,e),dr(a,e,t),Promise.all(r).then(function(){return e.targets!==void 0?cr(a,e.targets,t):a})}var Ye={};er(Ye,{clone:()=>hr,retarget:()=>Fn,retargetClip:()=>pr});y();function fo(a,e){return e.getBoneName!==void 0?e.getBoneName(a):e.names[a.name]}function Fn(a,e,t={}){let n=new Q,r=new R,s=new I,i=new I;t.preserveBoneMatrix=t.preserveBoneMatrix!==void 0?t.preserveBoneMatrix:!0,t.preserveBonePositions=t.preserveBonePositions!==void 0?t.preserveBonePositions:!0,t.useTargetMatrix=t.useTargetMatrix!==void 0?t.useTargetMatrix:!1,t.hip=t.hip!==void 0?t.hip:"hip",t.hipInfluence=t.hipInfluence!==void 0?t.hipInfluence:new R(1,1,1),t.scale=t.scale!==void 0?t.scale:1,t.names=t.names||{};let c=e.isObject3D?e.skeleton.bones:qe(e),l=a.isObject3D?a.skeleton.bones:qe(a),u,f,m,d;if(a.isObject3D?a.skeleton.pose():(t.useTargetMatrix=!0,t.preserveBoneMatrix=!1),t.preserveBonePositions){d=[];for(let p=0;p<l.length;p++)d.push(l[p].position.clone())}if(t.preserveBoneMatrix){a.updateMatrixWorld(),a.matrixWorld.identity();for(let p=0;p<a.children.length;++p)a.children[p].updateMatrixWorld(!0)}for(let p=0;p<l.length;++p)u=l[p],f=fo(u,t),m=vn(f,c),i.copy(u.matrixWorld),m&&(m.updateMatrixWorld(),t.useTargetMatrix?s.copy(m.matrixWorld):(s.copy(a.matrixWorld).invert(),s.multiply(m.matrixWorld)),r.setFromMatrixScale(s),s.scale(r.set(1/r.x,1/r.y,1/r.z)),i.makeRotationFromQuaternion(n.setFromRotationMatrix(s)),a.isObject3D&&t.localOffsets&&t.localOffsets[u.name]&&i.multiply(t.localOffsets[u.name]),i.copyPosition(s)),f===t.hip&&(i.elements[12]*=t.scale*t.hipInfluence.x,i.elements[13]*=t.scale*t.hipInfluence.y,i.elements[14]*=t.scale*t.hipInfluence.z,t.hipPosition!==void 0&&(i.elements[12]+=t.hipPosition.x*t.scale,i.elements[13]+=t.hipPosition.y*t.scale,i.elements[14]+=t.hipPosition.z*t.scale)),u.parent?(u.matrix.copy(u.parent.matrixWorld).invert(),u.matrix.multiply(i)):u.matrix.copy(i),u.matrix.decompose(u.position,u.quaternion,u.scale),u.updateMatrixWorld();if(t.preserveBonePositions)for(let p=0;p<l.length;++p)u=l[p],f=fo(u,t)||u.name,f!==t.hip&&u.position.copy(d[p]);t.preserveBoneMatrix&&a.updateMatrixWorld(!0)}function pr(a,e,t,n={}){n.useFirstFramePosition=n.useFirstFramePosition!==void 0?n.useFirstFramePosition:!1,n.fps=n.fps!==void 0?n.fps:Math.max(...t.tracks.map(_=>_.times.length))/t.duration,n.names=n.names||[],e.isObject3D||(e=gr(e));let r=Math.round(t.duration*(n.fps/1e3)*1e3),s=t.duration/(r-1),i=[],c=new En(e),l=qe(a.skeleton),u=[],f,m,d,p,h;c.clipAction(t).play();let T=0,x=r;n.trim!==void 0?(T=Math.round(n.trim[0]*n.fps),x=Math.min(Math.round(n.trim[1]*n.fps),r)-T,c.update(n.trim[0])):c.update(0),e.updateMatrixWorld();for(let _=0;_<x;++_){let b=_*s;Fn(a,e,n);for(let w=0;w<l.length;++w)m=l[w],h=fo(m,n)||m.name,d=vn(h,e.skeleton),d&&(p=u[w]=u[w]||{bone:m},n.hip===h&&(p.pos||(p.pos={times:new Float32Array(x),values:new Float32Array(x*3)}),n.useFirstFramePosition&&(_===0&&(f=m.position.clone()),m.position.sub(f)),p.pos.times[_]=b,m.position.toArray(p.pos.values,_*3)),p.quat||(p.quat={times:new Float32Array(x),values:new Float32Array(x*4)}),p.quat.times[_]=b,m.quaternion.toArray(p.quat.values,_*4));_===x-2?c.update(s-1e-7):c.update(s),e.updateMatrixWorld()}for(let _=0;_<u.length;++_)p=u[_],p&&(p.pos&&i.push(new ye(".bones["+p.bone.name+"].position",p.pos.times,p.pos.values)),i.push(new Ae(".bones["+p.bone.name+"].quaternion",p.quat.times,p.quat.values)));return c.uncacheAction(t),new ze(t.name,-1,i)}function hr(a){let e=new Map,t=new Map,n=a.clone();return Ln(a,n,function(r,s){e.set(s,r),t.set(r,s)}),n.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,i=e.get(r),c=i.skeleton.bones;s.skeleton=i.skeleton.clone(),s.bindMatrix.copy(i.bindMatrix),s.skeleton.bones=c.map(function(l){return t.get(l)}),s.bind(s.skeleton,s.bindMatrix)}),n}function vn(a,e){for(let t=0,n=qe(e);t<n.length;t++)if(a===n[t].name)return n[t]}function qe(a){return Array.isArray(a)?a:a.bones}function gr(a){let e=new wn(a.bones[0]);return e.skeleton=a,e}function Ln(a,e,t){t(a,e);for(let n=0;n<a.children.length;n++)Ln(a.children[n],e.children[n],t)}y();function mo(a){if(a.prototype._attachments){console.warn("addSkeletonScalingExtensions: Already run, skipping.");return}a.prototype.update=(function(){let e=new I().identity(),t=new I,n=new I,r=new R,s=new Q,i=new R;function c(u,f){if(!u.scalling||!(u.parent instanceof le)||!u.parent.scaleForRootAdjust)return;let m=i.setFromMatrixPosition(f),d=u.parent.scaleForRootAdjust;m.x*=d.y,m.y*=d.y,m.z*=d.x,m.y+=d.x-d.y,f.setPosition(m)}function l(u,f){for(let m of u){t.fromArray(f,m.boneIdx*16),m.localScale&&(t.decompose(i,s,r),t.compose(i,s,m.localScale));let d=m.obj.parent?m.obj.parent.matrixWorld:e;n.copy(d).invert(),m.obj.matrix.multiplyMatrices(n,t),m.obj.updateMatrixWorld(!0)}}return function(){console.assert(this.boneMatrices instanceof Float32Array);let f=this.boneMatrices;for(let m=0;m<this.bones.length;m++){let d=this.bones[m],p=d?d.matrixWorld:e;if(d&&d.scalling){p=t.copy(p).scale(d.scalli