TOPVERSE_Official/.output/public/_nuxt/loadGLTF.55174912.js

8 lines
50 KiB
JavaScript

import{aB as ve,y as Ie,a1 as Ne,a2 as pe,a3 as I,a4 as X,ab as R,ak as Ce,ai as Oe,al as Pe,d as G,ac as N,aC as D,h as fe,aD as Fe,a5 as De,aE as ke,aF as Ue,f as z,aG as me,aH as ge,a6 as J,aI as He,aJ as q,b as Ge,aK as te,D as Be,af as je,g as Te,am as Ke,M as Ve,aL as Xe,K as ze,aM as qe,aN as We,G as W,ah as Ye,aj as Qe,ag as Je,aO as Ae,as as $e,ae as ye,O as Ze,a as _e,an as et,aP as Ee,aw as tt,ax as ne,ay as st,az as nt,aQ as ot,aR as rt,aS as it,aT as at,a7 as ct,aU as lt,aV as ut,F as ht,aW as dt,a8 as oe,aX as pt,at as ft,au as re,av as mt,V,aY as gt,B as Tt,S as At,Q as yt}from"./model.vue.8f6f7b03.js";import"./entry.a42f0781.js";class _t extends pe{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new xt(t)}),this.register(function(t){return new Nt(t)}),this.register(function(t){return new Ct(t)}),this.register(function(t){return new St(t)}),this.register(function(t){return new bt(t)}),this.register(function(t){return new wt(t)}),this.register(function(t){return new vt(t)}),this.register(function(t){return new Lt(t)}),this.register(function(t){return new It(t)}),this.register(function(t){return new Rt(t)}),this.register(function(t){return new Ot(t)})}load(e,t,r,s){const o=this;let n;this.resourcePath!==""?n=this.resourcePath:this.path!==""?n=this.path:n=I.extractUrlBase(e),this.manager.itemStart(e);const a=function(c){s?s(c):console.error(c),o.manager.itemError(e),o.manager.itemEnd(e)},i=new X(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{o.parse(c,n,function(u){t(u),o.manager.itemEnd(e)},a)}catch(u){a(u)}},r,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,s){let o;const n={},a={};if(typeof e=="string")o=e;else if(I.decodeText(new Uint8Array(e,0,4))===Re){try{n[A.KHR_BINARY_GLTF]=new Pt(e)}catch(l){s&&s(l);return}o=n[A.KHR_BINARY_GLTF].content}else o=I.decodeText(new Uint8Array(e));const i=JSON.parse(o);if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new qt(i,{path:t||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++){const l=this.pluginCallbacks[u](c);a[l.name]=l,n[l.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const l=i.extensionsUsed[u],d=i.extensionsRequired||[];switch(l){case A.KHR_MATERIALS_UNLIT:n[l]=new Mt;break;case A.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:n[l]=new kt;break;case A.KHR_DRACO_MESH_COMPRESSION:n[l]=new Ft(i,this.dracoLoader);break;case A.KHR_TEXTURE_TRANSFORM:n[l]=new Dt;break;case A.KHR_MESH_QUANTIZATION:n[l]=new Ut;break;default:d.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(n),c.setPlugins(a),c.parse(r,s)}parseAsync(e,t){const r=this;return new Promise(function(s,o){r.parse(e,t,s,o)})}}function Et(){let h={};return{get:function(e){return h[e]},add:function(e,t){h[e]=t},remove:function(e){delete h[e]},removeAll:function(){h={}}}}const A={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class Rt{constructor(e){this.parser=e,this.name=A.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,s=t.length;r<s;r++){const o=t[r];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let s=t.cache.get(r);if(s)return s;const o=t.json,i=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let c;const u=new R(16777215);i.color!==void 0&&u.fromArray(i.color);const l=i.range!==void 0?i.range:0;switch(i.type){case"directional":c=new Pe(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Oe(u),c.distance=l;break;case"spot":c=new Ce(u),c.distance=l,i.spot=i.spot||{},i.spot.innerConeAngle=i.spot.innerConeAngle!==void 0?i.spot.innerConeAngle:0,i.spot.outerConeAngle=i.spot.outerConeAngle!==void 0?i.spot.outerConeAngle:Math.PI/4,c.angle=i.spot.outerConeAngle,c.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return c.position.set(0,0,0),c.decay=2,i.intensity!==void 0&&(c.intensity=i.intensity),c.name=t.createUniqueName(i.name||"light_"+e),s=Promise.resolve(c),t.cache.add(r,s),s}createNodeAttachment(e){const t=this,r=this.parser,o=r.json.nodes[e],a=(o.extensions&&o.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(i){return r._getNodeRef(t.cache,a,i)})}}class Mt{constructor(){this.name=A.KHR_MATERIALS_UNLIT}getMaterialType(){return G}extendParams(e,t,r){const s=[];e.color=new R(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const n=o.baseColorFactor;e.color.fromArray(n),e.opacity=n[3]}o.baseColorTexture!==void 0&&s.push(r.assignTexture(e,"map",o.baseColorTexture,N))}return Promise.all(s)}}class Lt{constructor(e){this.parser=e,this.name=A.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class xt{constructor(e){this.parser=e,this.name=A.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:D}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],n=s.extensions[this.name];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&o.push(r.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&o.push(r.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(o.push(r.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const a=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new fe(a,a)}return Promise.all(o)}}class St{constructor(e){this.parser=e,this.name=A.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:D}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new R(0,0,0),t.sheenRoughness=0,t.sheen=1;const n=s.extensions[this.name];return n.sheenColorFactor!==void 0&&t.sheenColor.fromArray(n.sheenColorFactor),n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&o.push(r.assignTexture(t,"sheenColorMap",n.sheenColorTexture,N)),n.sheenRoughnessTexture!==void 0&&o.push(r.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(o)}}class bt{constructor(e){this.parser=e,this.name=A.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:D}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],n=s.extensions[this.name];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&o.push(r.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(o)}}class wt{constructor(e){this.parser=e,this.name=A.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:D}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],n=s.extensions[this.name];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&o.push(r.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||0;const a=n.attenuationColor||[1,1,1];return t.attenuationColor=new R(a[0],a[1],a[2]),Promise.all(o)}}class vt{constructor(e){this.parser=e,this.name=A.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:D}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=s.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class It{constructor(e){this.parser=e,this.name=A.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:D}extendMaterialParams(e,t){const r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const o=[],n=s.extensions[this.name];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&o.push(r.assignTexture(t,"specularIntensityMap",n.specularTexture));const a=n.specularColorFactor||[1,1,1];return t.specularColor=new R(a[0],a[1],a[2]),n.specularColorTexture!==void 0&&o.push(r.assignTexture(t,"specularColorMap",n.specularColorTexture,N)),Promise.all(o)}}class Nt{constructor(e){this.parser=e,this.name=A.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,s=r.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const o=s.extensions[this.name],n=t.options.ktx2Loader;if(!n){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,n)}}class Ct{constructor(e){this.parser=e,this.name=A.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,s=r.json,o=s.textures[e];if(!o.extensions||!o.extensions[t])return null;const n=o.extensions[t],a=s.images[n.source];let i=r.textureLoader;if(a.uri){const c=r.options.manager.getHandler(a.uri);c!==null&&(i=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,n.source,i);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ot{constructor(e){this.name=A.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const s=r.extensions[this.name],o=this.parser.getDependency("buffer",s.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.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 Promise.all([o,n.ready]).then(function(a){const i=s.byteOffset||0,c=s.byteLength||0,u=s.count,l=s.byteStride,d=new ArrayBuffer(u*l),p=new Uint8Array(a[0],i,c);return n.decodeGltfBuffer(new Uint8Array(d),u,l,p,s.mode,s.filter),d})}else return null}}const Re="glTF",U=12,ie={JSON:1313821514,BIN:5130562};class Pt{constructor(e){this.name=A.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,U);if(this.header={magic:I.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Re)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-U,s=new DataView(e,U);let o=0;for(;o<r;){const n=s.getUint32(o,!0);o+=4;const a=s.getUint32(o,!0);if(o+=4,a===ie.JSON){const i=new Uint8Array(e,U+o,n);this.content=I.decodeText(i)}else if(a===ie.BIN){const i=U+o;this.body=e.slice(i,i+n)}o+=n}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ft{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=A.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,s=this.dracoLoader,o=e.extensions[this.name].bufferView,n=e.extensions[this.name].attributes,a={},i={},c={};for(const u in n){const l=Z[u]||u.toLowerCase();a[l]=n[u]}for(const u in e.attributes){const l=Z[u]||u.toLowerCase();if(n[u]!==void 0){const d=r.accessors[e.attributes[u]],p=B[d.componentType];c[l]=p,i[l]=d.normalized===!0}}return t.getDependency("bufferView",o).then(function(u){return new Promise(function(l){s.decodeDracoFile(u,function(d){for(const p in d.attributes){const m=d.attributes[p],T=i[p];T!==void 0&&(m.normalized=T)}l(d)},a,c)})})}}class Dt{constructor(){this.name=A.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return t.texCoord!==void 0&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class $ extends te{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP"," uniform sampler2D specularMap;","#endif"].join(`
`),r=["#ifdef USE_GLOSSINESSMAP"," uniform sampler2D glossinessMap;","#endif"].join(`
`),s=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP"," vec4 texelSpecular = texture2D( specularMap, vUv );"," // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture"," specularFactor *= texelSpecular.rgb;","#endif"].join(`
`),o=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP"," vec4 texelGlossiness = texture2D( glossinessMap, vUv );"," // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture"," glossinessFactor *= texelGlossiness.a;","#endif"].join(`
`),n=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join(`
`),a={specular:{value:new R().setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(i){for(const c in a)i.uniforms[c]=a[c];i.fragmentShader=i.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",r).replace("#include <roughnessmap_fragment>",s).replace("#include <metalnessmap_fragment>",o).replace("#include <lights_physical_fragment>",n)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(i){a.specular.value=i}},specularMap:{get:function(){return a.specularMap.value},set:function(i){a.specularMap.value=i,i?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(i){a.glossiness.value=i}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(i){a.glossinessMap.value=i,i?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class kt{constructor(){this.name=A.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return $}extendParams(e,t,r){const s=t.extensions[this.name];e.color=new R(1,1,1),e.opacity=1;const o=[];if(Array.isArray(s.diffuseFactor)){const n=s.diffuseFactor;e.color.fromArray(n),e.opacity=n[3]}if(s.diffuseTexture!==void 0&&o.push(r.assignTexture(e,"map",s.diffuseTexture,N)),e.emissive=new R(0,0,0),e.glossiness=s.glossinessFactor!==void 0?s.glossinessFactor:1,e.specular=new R(1,1,1),Array.isArray(s.specularFactor)&&e.specular.fromArray(s.specularFactor),s.specularGlossinessTexture!==void 0){const n=s.specularGlossinessTexture;o.push(r.assignTexture(e,"glossinessMap",n)),o.push(r.assignTexture(e,"specularMap",n,N))}return Promise.all(o)}createMaterial(e){const t=new $(e);return t.fog=!0,t.color=e.color,t.map=e.map===void 0?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=e.aoMap===void 0?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=e.emissiveIntensity===void 0?1:e.emissiveIntensity,t.emissiveMap=e.emissiveMap===void 0?null:e.emissiveMap,t.bumpMap=e.bumpMap===void 0?null:e.bumpMap,t.bumpScale=1,t.normalMap=e.normalMap===void 0?null:e.normalMap,t.normalMapType=Fe,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=e.specularMap===void 0?null:e.specularMap,t.specular=e.specular,t.glossinessMap=e.glossinessMap===void 0?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=e.envMap===void 0?null:e.envMap,t.envMapIntensity=1,t}}class Ut{constructor(){this.name=A.KHR_MESH_QUANTIZATION}}class C extends gt{constructor(e,t,r,s){super(e,t,r,s)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,o=e*s*3+s;for(let n=0;n!==s;n++)t[n]=r[o+n];return t}}C.prototype.beforeStart_=C.prototype.copySampleValue_;C.prototype.afterEnd_=C.prototype.copySampleValue_;C.prototype.interpolate_=function(h,e,t,r){const s=this.resultBuffer,o=this.sampleValues,n=this.valueSize,a=n*2,i=n*3,c=r-e,u=(t-e)/c,l=u*u,d=l*u,p=h*i,m=p-i,T=-2*d+3*l,f=d-l,g=1-T,_=f-l+u;for(let y=0;y!==n;y++){const k=o[m+y+n],w=o[m+y+a]*c,M=o[p+y+n],E=o[p+y]*c;s[y]=g*k+_*w+T*M+f*E}return s};const Ht=new yt;class Gt extends C{interpolate_(e,t,r,s){const o=super.interpolate_(e,t,r,s);return Ht.fromArray(o).normalize().toArray(o),o}}const x={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},B={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ae={9728:ot,9729:me,9984:rt,9985:it,9986:at,9987:ge},ce={33071:ct,33648:lt,10497:J},le={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Z={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},b={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Bt={CUBICSPLINE:void 0,LINEAR:Ae,STEP:ut},Y={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function jt(h){return h.DefaultMaterial===void 0&&(h.DefaultMaterial=new te({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ht})),h.DefaultMaterial}function H(h,e,t){for(const r in t.extensions)h[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function v(h,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(h.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Kt(h,e,t){let r=!1,s=!1,o=!1;for(let c=0,u=e.length;c<u;c++){const l=e[c];if(l.POSITION!==void 0&&(r=!0),l.NORMAL!==void 0&&(s=!0),l.COLOR_0!==void 0&&(o=!0),r&&s&&o)break}if(!r&&!s&&!o)return Promise.resolve(h);const n=[],a=[],i=[];for(let c=0,u=e.length;c<u;c++){const l=e[c];if(r){const d=l.POSITION!==void 0?t.getDependency("accessor",l.POSITION):h.attributes.position;n.push(d)}if(s){const d=l.NORMAL!==void 0?t.getDependency("accessor",l.NORMAL):h.attributes.normal;a.push(d)}if(o){const d=l.COLOR_0!==void 0?t.getDependency("accessor",l.COLOR_0):h.attributes.color;i.push(d)}}return Promise.all([Promise.all(n),Promise.all(a),Promise.all(i)]).then(function(c){const u=c[0],l=c[1],d=c[2];return r&&(h.morphAttributes.position=u),s&&(h.morphAttributes.normal=l),o&&(h.morphAttributes.color=d),h.morphTargetsRelative=!0,h})}function Vt(h,e){if(h.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)h.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(h.morphTargetInfluences.length===t.length){h.morphTargetDictionary={};for(let r=0,s=t.length;r<s;r++)h.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xt(h){const e=h.extensions&&h.extensions[A.KHR_DRACO_MESH_COMPRESSION];let t;return e?t="draco:"+e.bufferView+":"+e.indices+":"+ue(e.attributes):t=h.indices+":"+ue(h.attributes)+":"+h.mode,t}function ue(h){let e="";const t=Object.keys(h).sort();for(let r=0,s=t.length;r<s;r++)e+=t[r]+":"+h[t[r]]+";";return e}function ee(h){switch(h){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 zt(h){return h.search(/\.jpe?g($|\?)/i)>0||h.search(/^data\:image\/jpeg/)===0?"image/jpeg":h.search(/\.webp($|\?)/i)>0||h.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}class qt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Et,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,o=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1;typeof createImageBitmap>"u"||r||s&&o<98?this.textureLoader=new De(this.options.manager):this.textureLoader=new ke(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new X(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,s=this.json,o=this.extensions;this.cache.removeAll(),this._invokeAll(function(n){return n._markDefs&&n._markDefs()}),Promise.all(this._invokeAll(function(n){return n.beforeRoot&&n.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(n){const a={scene:n[0][s.scene||0],scenes:n[0],animations:n[1],cameras:n[2],asset:s.asset,parser:r,userData:{}};H(o,a,s),v(a,s),Promise.all(r._invokeAll(function(i){return i.afterRoot&&i.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let s=0,o=t.length;s<o;s++){const n=t[s].joints;for(let a=0,i=n.length;a<i;a++)e[n[a]].isBone=!0}for(let s=0,o=e.length;s<o;s++){const n=e[s];n.mesh!==void 0&&(this._addNodeRef(this.meshCache,n.mesh),n.skin!==void 0&&(r[n.mesh].isSkinnedMesh=!0)),n.camera!==void 0&&this._addNodeRef(this.cameraCache,n.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,r){if(e.refs[t]<=1)return r;const s=r.clone(),o=(n,a)=>{const i=this.associations.get(n);i!=null&&this.associations.set(a,i);for(const[c,u]of n.children.entries())o(u,a.children[c])};return o(r,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const s=e(t[r]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let s=0;s<t.length;s++){const o=e(t[s]);o&&r.push(o)}return r}getDependency(e,t){const r=e+":"+t;let s=this.cache.get(r);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this.loadNode(t);break;case"mesh":s=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(o,n){return r.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=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[A.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(o,n){r.load(I.resolveURL(t.uri,s.path),o,void 0,function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(r){const s=t.byteLength||0,o=t.byteOffset||0;return r.slice(o,o+s)})}loadAccessor(e){const t=this,r=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0)return Promise.resolve(null);const o=[];return s.bufferView!==void 0?o.push(this.getDependency("bufferView",s.bufferView)):o.push(null),s.sparse!==void 0&&(o.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(o).then(function(n){const a=n[0],i=le[s.type],c=B[s.componentType],u=c.BYTES_PER_ELEMENT,l=u*i,d=s.byteOffset||0,p=s.bufferView!==void 0?r.bufferViews[s.bufferView].byteStride:void 0,m=s.normalized===!0;let T,f;if(p&&p!==l){const g=Math.floor(d/p),_="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+g+":"+s.count;let y=t.cache.get(_);y||(T=new c(a,g*p,s.count*p/u),y=new Ue(T,p/u),t.cache.add(_,y)),f=new dt(y,i,d%p/u,m)}else a===null?T=new c(s.count*i):T=new c(a,d,s.count*i),f=new z(T,i,m);if(s.sparse!==void 0){const g=le.SCALAR,_=B[s.sparse.indices.componentType],y=s.sparse.indices.byteOffset||0,k=s.sparse.values.byteOffset||0,w=new _(n[1],y,s.sparse.count*g),M=new c(n[2],k,s.sparse.count*i);a!==null&&(f=new z(f.array.slice(),f.itemSize,f.normalized));for(let E=0,O=w.length;E<O;E++){const P=w[E];if(f.setX(P,M[E*i]),i>=2&&f.setY(P,M[E*i+1]),i>=3&&f.setZ(P,M[E*i+2]),i>=4&&f.setW(P,M[E*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f})}loadTexture(e){const t=this.json,r=this.options,o=t.textures[e].source,n=t.images[o];let a=this.textureLoader;if(n.uri){const i=r.manager.getHandler(n.uri);i!==null&&(a=i)}return this.loadTextureImage(e,o,a)}loadTextureImage(e,t,r){const s=this,o=this.json,n=o.textures[e],a=o.images[t],i=(a.uri||a.bufferView)+":"+n.sampler;if(this.textureCache[i])return this.textureCache[i];const c=this.loadImageSource(t,r).then(function(u){u.flipY=!1,n.name&&(u.name=n.name);const d=(o.samplers||{})[n.sampler]||{};return u.magFilter=ae[d.magFilter]||me,u.minFilter=ae[d.minFilter]||ge,u.wrapS=ce[d.wrapS]||J,u.wrapT=ce[d.wrapT]||J,s.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[i]=c,c}loadImageSource(e,t){const r=this,s=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(l=>l.clone());const n=s.images[e],a=self.URL||self.webkitURL;let i=n.uri||"",c=!1;if(n.bufferView!==void 0)i=r.getDependency("bufferView",n.bufferView).then(function(l){c=!0;const d=new Blob([l],{type:n.mimeType});return i=a.createObjectURL(d),i});else if(n.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(i).then(function(l){return new Promise(function(d,p){let m=d;t.isImageBitmapLoader===!0&&(m=function(T){const f=new oe(T);f.needsUpdate=!0,d(f)}),t.load(I.resolveURL(l,o.path),m,void 0,p)})}).then(function(l){return c===!0&&a.revokeObjectURL(i),l.userData.mimeType=n.mimeType||zt(n.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),l});return this.sourceCache[e]=u,u}assignTexture(e,t,r,s){const o=this;return this.getDependency("texture",r.index).then(function(n){if(r.texCoord!==void 0&&r.texCoord!=0&&!(t==="aoMap"&&r.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+r.texCoord+" for texture "+t+" not yet supported."),o.extensions[A.KHR_TEXTURE_TRANSFORM]){const a=r.extensions!==void 0?r.extensions[A.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const i=o.associations.get(n);n=o.extensions[A.KHR_TEXTURE_TRANSFORM].extendTexture(n,a),o.associations.set(n,i)}}return s!==void 0&&(n.encoding=s),e[t]=n,n})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const s=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,n=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+r.uuid;let i=this.cache.get(a);i||(i=new He,q.prototype.copy.call(i,r),i.color.copy(r.color),i.map=r.map,i.sizeAttenuation=!1,this.cache.add(a,i)),r=i}else if(e.isLine){const a="LineBasicMaterial:"+r.uuid;let i=this.cache.get(a);i||(i=new Ge,q.prototype.copy.call(i,r),i.color.copy(r.color),this.cache.add(a,i)),r=i}if(s||o||n){let a="ClonedMaterial:"+r.uuid+":";r.isGLTFSpecularGlossinessMaterial&&(a+="specular-glossiness:"),s&&(a+="derivative-tangents:"),o&&(a+="vertex-colors:"),n&&(a+="flat-shading:");let i=this.cache.get(a);i||(i=r.clone(),o&&(i.vertexColors=!0),n&&(i.flatShading=!0),s&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(a,i),this.associations.set(i,this.associations.get(r))),r=i}r.aoMap&&t.attributes.uv2===void 0&&t.attributes.uv!==void 0&&t.setAttribute("uv2",t.attributes.uv),e.material=r}getMaterialType(){return te}loadMaterial(e){const t=this,r=this.json,s=this.extensions,o=r.materials[e];let n;const a={},i=o.extensions||{},c=[];if(i[A.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const l=s[A.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];n=l.getMaterialType(),c.push(l.extendParams(a,o,t))}else if(i[A.KHR_MATERIALS_UNLIT]){const l=s[A.KHR_MATERIALS_UNLIT];n=l.getMaterialType(),c.push(l.extendParams(a,o,t))}else{const l=o.pbrMetallicRoughness||{};if(a.color=new R(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const d=l.baseColorFactor;a.color.fromArray(d),a.opacity=d[3]}l.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",l.baseColorTexture,N)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),n=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}o.doubleSided===!0&&(a.side=Be);const u=o.alphaMode||Y.OPAQUE;if(u===Y.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===Y.MASK&&(a.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&n!==G&&(c.push(t.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new fe(1,1),o.normalTexture.scale!==void 0)){const l=o.normalTexture.scale;a.normalScale.set(l,l)}return o.occlusionTexture!==void 0&&n!==G&&(c.push(t.assignTexture(a,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&n!==G&&(a.emissive=new R().fromArray(o.emissiveFactor)),o.emissiveTexture!==void 0&&n!==G&&c.push(t.assignTexture(a,"emissiveMap",o.emissiveTexture,N)),Promise.all(c).then(function(){let l;return n===$?l=s[A.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):l=new n(a),o.name&&(l.name=o.name),v(l,o),t.associations.set(l,{materials:e}),o.extensions&&H(s,l,o),l})}createUniqueName(e){const t=je.sanitizeNodeName(e||"");let r=t;for(let s=1;this.nodeNamesUsed[r];++s)r=t+"_"+s;return this.nodeNamesUsed[r]=!0,r}loadGeometries(e){const t=this,r=this.extensions,s=this.primitiveCache;function o(a){return r[A.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(i){return he(i,a,t)})}const n=[];for(let a=0,i=e.length;a<i;a++){const c=e[a],u=Xt(c),l=s[u];if(l)n.push(l.promise);else{let d;c.extensions&&c.extensions[A.KHR_DRACO_MESH_COMPRESSION]?d=o(c):d=he(new Te,c,t),s[u]={primitive:c,promise:d},n.push(d)}}return Promise.all(n)}loadMesh(e){const t=this,r=this.json,s=this.extensions,o=r.meshes[e],n=o.primitives,a=[];for(let i=0,c=n.length;i<c;i++){const u=n[i].material===void 0?jt(this.cache):this.getDependency("material",n[i].material);a.push(u)}return a.push(t.loadGeometries(n)),Promise.all(a).then(function(i){const c=i.slice(0,i.length-1),u=i[i.length-1],l=[];for(let p=0,m=u.length;p<m;p++){const T=u[p],f=n[p];let g;const _=c[p];if(f.mode===x.TRIANGLES||f.mode===x.TRIANGLE_STRIP||f.mode===x.TRIANGLE_FAN||f.mode===void 0)g=o.isSkinnedMesh===!0?new Ke(T,_):new Ve(T,_),g.isSkinnedMesh===!0&&!g.geometry.attributes.skinWeight.normalized&&g.normalizeSkinWeights(),f.mode===x.TRIANGLE_STRIP?g.geometry=de(g.geometry,pt):f.mode===x.TRIANGLE_FAN&&(g.geometry=de(g.geometry,Ee));else if(f.mode===x.LINES)g=new Xe(T,_);else if(f.mode===x.LINE_STRIP)g=new ze(T,_);else if(f.mode===x.LINE_LOOP)g=new qe(T,_);else if(f.mode===x.POINTS)g=new We(T,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);Object.keys(g.geometry.morphAttributes).length>0&&Vt(g,o),g.name=t.createUniqueName(o.name||"mesh_"+e),v(g,o),f.extensions&&H(s,g,f),t.assignFinalMaterial(g),l.push(g)}for(let p=0,m=l.length;p<m;p++)t.associations.set(l[p],{meshes:e,primitives:p});if(l.length===1)return l[0];const d=new W;t.associations.set(d,{meshes:e});for(let p=0,m=l.length;p<m;p++)d.add(l[p]);return d})}loadCamera(e){let t;const r=this.json.cameras[e],s=r[r.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new Ye(Qe.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):r.type==="orthographic"&&(t=new Je(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),v(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r={joints:t.joints};return t.inverseBindMatrices===void 0?Promise.resolve(r):this.getDependency("accessor",t.inverseBindMatrices).then(function(s){return r.inverseBindMatrices=s,r})}loadAnimation(e){const r=this.json.animations[e],s=[],o=[],n=[],a=[],i=[];for(let c=0,u=r.channels.length;c<u;c++){const l=r.channels[c],d=r.samplers[l.sampler],p=l.target,m=p.node!==void 0?p.node:p.id,T=r.parameters!==void 0?r.parameters[d.input]:d.input,f=r.parameters!==void 0?r.parameters[d.output]:d.output;s.push(this.getDependency("node",m)),o.push(this.getDependency("accessor",T)),n.push(this.getDependency("accessor",f)),a.push(d),i.push(p)}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(n),Promise.all(a),Promise.all(i)]).then(function(c){const u=c[0],l=c[1],d=c[2],p=c[3],m=c[4],T=[];for(let g=0,_=u.length;g<_;g++){const y=u[g],k=l[g],w=d[g],M=p[g],E=m[g];if(y===void 0)continue;y.updateMatrix(),y.matrixAutoUpdate=!0;let O;switch(b[E.path]){case b.weights:O=mt;break;case b.rotation:O=re;break;case b.position:case b.scale:default:O=ft;break}const P=y.name?y.name:y.uuid,Se=M.interpolation!==void 0?Bt[M.interpolation]:Ae,j=[];b[E.path]===b.weights?y.traverse(function(L){L.morphTargetInfluences&&j.push(L.name?L.name:L.uuid)}):j.push(P);let F=w.array;if(w.normalized){const L=ee(F.constructor),K=new Float32Array(F.length);for(let S=0,se=F.length;S<se;S++)K[S]=F[S]*L;F=K}for(let L=0,K=j.length;L<K;L++){const S=new O(j[L]+"."+b[E.path],k.array,F,Se);M.interpolation==="CUBICSPLINE"&&(S.createInterpolant=function(be){const we=this instanceof re?Gt:C;return new we(this.times,this.values,this.getValueSize()/3,be)},S.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),T.push(S)}}const f=r.name?r.name:"animation_"+e;return new $e(f,void 0,T)})}createNodeMesh(e){const t=this.json,r=this,s=t.nodes[e];return s.mesh===void 0?null:r.getDependency("mesh",s.mesh).then(function(o){const n=r._getNodeRef(r.meshCache,s.mesh,o);return s.weights!==void 0&&n.traverse(function(a){if(a.isMesh)for(let i=0,c=s.weights.length;i<c;i++)a.morphTargetInfluences[i]=s.weights[i]}),n})}loadNode(e){const t=this.json,r=this.extensions,s=this,o=t.nodes[e],n=o.name?s.createUniqueName(o.name):"";return function(){const a=[],i=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return i&&a.push(i),o.camera!==void 0&&a.push(s.getDependency("camera",o.camera).then(function(c){return s._getNodeRef(s.cameraCache,o.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),Promise.all(a)}().then(function(a){let i;if(o.isBone===!0?i=new ye:a.length>1?i=new W:a.length===1?i=a[0]:i=new Ze,i!==a[0])for(let c=0,u=a.length;c<u;c++)i.add(a[c]);if(o.name&&(i.userData.name=o.name,i.name=n),v(i,o),o.extensions&&H(r,i,o),o.matrix!==void 0){const c=new _e;c.fromArray(o.matrix),i.applyMatrix4(c)}else o.translation!==void 0&&i.position.fromArray(o.translation),o.rotation!==void 0&&i.quaternion.fromArray(o.rotation),o.scale!==void 0&&i.scale.fromArray(o.scale);return s.associations.has(i)||s.associations.set(i,{}),s.associations.get(i).nodes=e,i})}loadScene(e){const t=this.json,r=this.extensions,s=this.json.scenes[e],o=this,n=new W;s.name&&(n.name=o.createUniqueName(s.name)),v(n,s),s.extensions&&H(r,n,s);const a=s.nodes||[],i=[];for(let c=0,u=a.length;c<u;c++)i.push(Me(a[c],n,t,o));return Promise.all(i).then(function(){const c=u=>{const l=new Map;for(const[d,p]of o.associations)(d instanceof q||d instanceof oe)&&l.set(d,p);return u.traverse(d=>{const p=o.associations.get(d);p!=null&&l.set(d,p)}),l};return o.associations=c(n),n})}}function Me(h,e,t,r){const s=t.nodes[h];return r.getDependency("node",h).then(function(o){if(s.skin===void 0)return o;let n;return r.getDependency("skin",s.skin).then(function(a){n=a;const i=[];for(let c=0,u=n.joints.length;c<u;c++)i.push(r.getDependency("node",n.joints[c]));return Promise.all(i)}).then(function(a){return o.traverse(function(i){if(!i.isMesh)return;const c=[],u=[];for(let l=0,d=a.length;l<d;l++){const p=a[l];if(p){c.push(p);const m=new _e;n.inverseBindMatrices!==void 0&&m.fromArray(n.inverseBindMatrices.array,l*16),u.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[l])}i.bind(new et(c,u),i.matrixWorld)}),o})}).then(function(o){e.add(o);const n=[];if(s.children){const a=s.children;for(let i=0,c=a.length;i<c;i++){const u=a[i];n.push(Me(u,o,t,r))}}return Promise.all(n)})}function Wt(h,e,t){const r=e.attributes,s=new Tt;if(r.POSITION!==void 0){const a=t.json.accessors[r.POSITION],i=a.min,c=a.max;if(i!==void 0&&c!==void 0){if(s.set(new V(i[0],i[1],i[2]),new V(c[0],c[1],c[2])),a.normalized){const u=ee(B[a.componentType]);s.min.multiplyScalar(u),s.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const a=new V,i=new V;for(let c=0,u=o.length;c<u;c++){const l=o[c];if(l.POSITION!==void 0){const d=t.json.accessors[l.POSITION],p=d.min,m=d.max;if(p!==void 0&&m!==void 0){if(i.setX(Math.max(Math.abs(p[0]),Math.abs(m[0]))),i.setY(Math.max(Math.abs(p[1]),Math.abs(m[1]))),i.setZ(Math.max(Math.abs(p[2]),Math.abs(m[2]))),d.normalized){const T=ee(B[d.componentType]);i.multiplyScalar(T)}a.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}h.boundingBox=s;const n=new At;s.getCenter(n.center),n.radius=s.min.distanceTo(s.max)/2,h.boundingSphere=n}function he(h,e,t){const r=e.attributes,s=[];function o(n,a){return t.getDependency("accessor",n).then(function(i){h.setAttribute(a,i)})}for(const n in r){const a=Z[n]||n.toLowerCase();a in h.attributes||s.push(o(r[n],a))}if(e.indices!==void 0&&!h.index){const n=t.getDependency("accessor",e.indices).then(function(a){h.setIndex(a)});s.push(n)}return v(h,e),Wt(h,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Kt(h,e.targets,t):h})}function de(h,e){let t=h.getIndex();if(t===null){const n=[],a=h.getAttribute("position");if(a!==void 0){for(let i=0;i<a.count;i++)n.push(i);h.setIndex(n),t=h.getIndex()}else return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),h}const r=t.count-2,s=[];if(e===Ee)for(let n=1;n<=r;n++)s.push(t.getX(0)),s.push(t.getX(n)),s.push(t.getX(n+1));else for(let n=0;n<r;n++)n%2===0?(s.push(t.getX(n)),s.push(t.getX(n+1)),s.push(t.getX(n+2))):(s.push(t.getX(n+2)),s.push(t.getX(n+1)),s.push(t.getX(n)));s.length/3!==r&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=h.clone();return o.setIndex(s),o}const Q=new WeakMap;class Yt extends pe{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,r,s){const o=new X(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,n=>{const a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(n,a).then(t).catch(s)},r,s)}decodeDracoFile(e,t,r,s){const o={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!r};this.decodeGeometry(e,o).then(t)}decodeGeometry(e,t){for(const i in t.attributeTypes){const c=t.attributeTypes[i];c.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[i]=c.name)}const r=JSON.stringify(t);if(Q.has(e)){const i=Q.get(e);if(i.key===r)return i.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const o=this.workerNextTaskID++,n=e.byteLength,a=this._getWorker(o,n).then(i=>(s=i,new Promise((c,u)=>{s._callbacks[o]={resolve:c,reject:u},s.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(i=>this._createGeometry(i.geometry));return a.catch(()=>!0).then(()=>{s&&o&&this._releaseTask(s,o)}),Q.set(e,{key:r,promise:a}),a}_createGeometry(e){const t=new Te;e.index&&t.setIndex(new z(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r],o=s.name,n=s.array,a=s.itemSize;t.setAttribute(o,new z(n,a))}return t}_loadLibrary(e,t){const r=new X(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((s,o)=>{r.load(e,s,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(r=>{const s=r[0];e||(this.decoderConfig.wasmBinary=r[1]);const o=Qt.toString(),n=["/* draco decoder */",s,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(o){const n=o.data;switch(n.type){case"decode":s._callbacks[n.id].resolve(n);break;case"error":s._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,o){return s._taskLoad>o._taskLoad?-1:1});const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function Qt(){let h,e;onmessage=function(n){const a=n.data;switch(a.type){case"init":h=a.decoderConfig,e=new Promise(function(u){h.onModuleLoaded=function(l){u({draco:l})},DracoDecoderModule(h)});break;case"decode":const i=a.buffer,c=a.taskConfig;e.then(u=>{const l=u.draco,d=new l.Decoder,p=new l.DecoderBuffer;p.Init(new Int8Array(i),i.byteLength);try{const m=t(l,d,p,c),T=m.attributes.map(f=>f.array.buffer);m.index&&T.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},T)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{l.destroy(p),l.destroy(d)}});break}};function t(n,a,i,c){const u=c.attributeIDs,l=c.attributeTypes;let d,p;const m=a.GetEncodedGeometryType(i);if(m===n.TRIANGULAR_MESH)d=new n.Mesh,p=a.DecodeBufferToMesh(i,d);else if(m===n.POINT_CLOUD)d=new n.PointCloud,p=a.DecodeBufferToPointCloud(i,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const T={index:null,attributes:[]};for(const f in u){const g=self[l[f]];let _,y;if(c.useUniqueIDs)y=u[f],_=a.GetAttributeByUniqueId(d,y);else{if(y=a.GetAttributeId(d,n[u[f]]),y===-1)continue;_=a.GetAttribute(d,y)}T.attributes.push(s(n,a,d,f,g,_))}return m===n.TRIANGULAR_MESH&&(T.index=r(n,a,d)),n.destroy(d),T}function r(n,a,i){const u=i.num_faces()*3,l=u*4,d=n._malloc(l);a.GetTrianglesUInt32Array(i,l,d);const p=new Uint32Array(n.HEAPF32.buffer,d,u).slice();return n._free(d),{array:p,itemSize:1}}function s(n,a,i,c,u,l){const d=l.num_components(),m=i.num_points()*d,T=m*u.BYTES_PER_ELEMENT,f=o(n,u),g=n._malloc(T);a.GetAttributeDataArrayForAllPoints(i,l,f,T,g);const _=new u(n.HEAPF32.buffer,g,m).slice();return n._free(g),{name:c,array:_,itemSize:d}}function o(n,a){switch(a){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}const Jt=new Map,Le=new _t,xe=new Yt;xe.setDecoderPath(ve.wasmPath);Le.setDRACOLoader(xe);var es=async(h,e)=>{const[t,r]=await Ie(Jt,h,()=>new Promise((s,o)=>{tt(),Le.load(h,n=>{ne();let a=!0;for(const i of n.scenes)i.traverse(c=>{var u;a&&c instanceof ye&&(a=!1),!((u=c.material)===null||u===void 0)&&u.map&&(c.material.map.encoding=st)});s([n,a])},nt,()=>{ne(),o()})}));return e?Ne(t.scene,r,t.animations):t.scene};export{es as default};