UNPKG

polygonjs-engine

Version:

node-based webgl 3D engine https://polygonjs.com

2 lines 40.8 kB
(window.webpackJsonpPOLY=window.webpackJsonpPOLY||[]).push([[7],{222:function(e,t,r){"use strict";r.r(t),r.d(t,"GLTFLoader",(function(){return J}));var s=r(65),n=r(55),a=r(29),i=r(3),o=r(5),u=r(21);function l(e,t,r,s,n,a,i,o,l){u.a.call(this,e,t,r,s,n,a,i,o,l),this.needsUpdate=!0}l.prototype=Object.create(u.a.prototype),l.prototype.constructor=l,l.prototype.isCanvasTexture=!0;var c=r(0),p=r(4),h=r(75),d=r(42),f=r(16),m=r(59),g=r(19);function v(e){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),g.a.call(this,e),this.options={premultiplyAlpha:"none"}}v.prototype=Object.assign(Object.create(g.a.prototype),{constructor:v,isImageBitmapLoader:!0,setOptions:function(e){return this.options=e,this},load:function(e,t,r,s){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=m.a.get(e);if(void 0!==a)return n.manager.itemStart(e),setTimeout((function(){t&&t(a),n.manager.itemEnd(e)}),0),a;const i={};i.credentials="anonymous"===this.crossOrigin?"same-origin":"include",fetch(e,i).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,n.options)})).then((function(r){m.a.add(e,r),t&&t(r),n.manager.itemEnd(e)})).catch((function(t){s&&s(t),n.manager.itemError(e),n.manager.itemEnd(e)})),n.manager.itemStart(e)}});var T=r(56),y=r(50),x=r(38),R=r(34),S=r(23),M=r(132),E=r(28),_=r(110),w=r(9),A=r(7),b=r(10),L=r(13),I=r(20),O=r(111),P=r(45),N=r(82),U=r(12),C=r(32),F=r(22),H=r(76),D=r(37),k=r(44),G=r(113),j=r(108),B=r(114),K=r(73),V=r(31),X=r(77),q=r(112),z=r(2),Y=r(1),W=r(83),J=function(){function e(e){g.a.call(this,e),this.dracoLoader=null,this.ddsLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new Q(e)})),this.register((function(e){return new $(e)})),this.register((function(e){return new ee(e)})),this.register((function(e){return new Z(e)})),this.register((function(e){return new m(e)})),this.register((function(e){return new te(e)}))}function t(){var e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}e.prototype=Object.assign(Object.create(g.a.prototype),{constructor:e,load:function(e,t,r,s){var n,a=this;n=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:_.a.extractUrlBase(e),this.manager.itemStart(e);var i=function(t){s?s(t):console.error(t),a.manager.itemError(e),a.manager.itemEnd(e)},o=new d.a(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(r){try{a.parse(r,n,(function(r){t(r),a.manager.itemEnd(e)}),i)}catch(e){i(e)}}),r,i)},setDRACOLoader:function(e){return this.dracoLoader=e,this},setDDSLoader:function(e){return this.ddsLoader=e,this},setKTX2Loader:function(e){return this.ktx2Loader=e,this},setMeshoptDecoder:function(e){return this.meshoptDecoder=e,this},register:function(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this},unregister:function(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this},parse:function(e,t,s,n){var a,i={},o={};if("string"==typeof e)a=e;else if(_.a.decodeText(new Uint8Array(e,0,4))===re){try{i[r.KHR_BINARY_GLTF]=new ae(e)}catch(e){return void(n&&n(e))}a=i[r.KHR_BINARY_GLTF].content}else a=_.a.decodeText(new Uint8Array(e));var l=JSON.parse(a);if(void 0===l.asset||l.asset.version[0]<2)n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));else{var c=new Ue(l,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(var p=0;p<this.pluginCallbacks.length;p++){var h=this.pluginCallbacks[p](c);o[h.name]=h,i[h.name]=!0}if(l.extensionsUsed)for(p=0;p<l.extensionsUsed.length;++p){var d=l.extensionsUsed[p],f=l.extensionsRequired||[];switch(d){case r.KHR_MATERIALS_UNLIT:i[d]=new J;break;case r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:i[d]=new le;break;case r.KHR_DRACO_MESH_COMPRESSION:i[d]=new ie(l,this.dracoLoader);break;case r.MSFT_TEXTURE_DDS:i[d]=new u(this.ddsLoader);break;case r.KHR_TEXTURE_TRANSFORM:i[d]=new oe;break;case r.KHR_MESH_QUANTIZATION:i[d]=new ce;break;default:f.indexOf(d)>=0&&void 0===o[d]&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(i),c.setPlugins(o),c.parse(s,n)}}});var r={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};function u(e){if(!e)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=r.MSFT_TEXTURE_DDS,this.ddsLoader=e}function m(e){this.parser=e,this.name=r.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}function J(){this.name=r.KHR_MATERIALS_UNLIT}function Q(e){this.parser=e,this.name=r.KHR_MATERIALS_CLEARCOAT}function Z(e){this.parser=e,this.name=r.KHR_MATERIALS_TRANSMISSION}function $(e){this.parser=e,this.name=r.KHR_TEXTURE_BASISU}function ee(e){this.parser=e,this.name=r.EXT_TEXTURE_WEBP,this.isSupported=null}function te(e){this.name=r.EXT_MESHOPT_COMPRESSION,this.parser=e}m.prototype._markDefs=function(){for(var e=this.parser,t=this.parser.json.nodes||[],r=0,s=t.length;r<s;r++){var n=t[r];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}},m.prototype._loadLight=function(e){var t=this.parser,r="light:"+e,s=t.cache.get(r);if(s)return s;var n,a=t.json,i=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e],o=new p.a(16777215);void 0!==i.color&&o.fromArray(i.color);var u=void 0!==i.range?i.range:0;switch(i.type){case"directional":(n=new h.a(o)).target.position.set(0,0,-1),n.add(n.target);break;case"point":(n=new H.a(o)).distance=u;break;case"spot":(n=new X.a(o)).distance=u,i.spot=i.spot||{},i.spot.innerConeAngle=void 0!==i.spot.innerConeAngle?i.spot.innerConeAngle:0,i.spot.outerConeAngle=void 0!==i.spot.outerConeAngle?i.spot.outerConeAngle:Math.PI/4,n.angle=i.spot.outerConeAngle,n.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,n.target.position.set(0,0,-1),n.add(n.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return n.position.set(0,0,0),n.decay=2,void 0!==i.intensity&&(n.intensity=i.intensity),n.name=t.createUniqueName(i.name||"light_"+e),s=Promise.resolve(n),t.cache.add(r,s),s},m.prototype.createNodeAttachment=function(e){var t=this,r=this.parser,s=r.json.nodes[e],n=(s.extensions&&s.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then((function(e){return r._getNodeRef(t.cache,n,e)}))},J.prototype.getMaterialType=function(){return I.a},J.prototype.extendParams=function(e,t,r){var s=[];e.color=new p.a(1,1,1),e.opacity=1;var n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){var a=n.baseColorFactor;e.color.fromArray(a),e.opacity=a[3]}void 0!==n.baseColorTexture&&s.push(r.assignTexture(e,"map",n.baseColorTexture))}return Promise.all(s)},Q.prototype.getMaterialType=function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?O.a:null},Q.prototype.extendMaterialParams=function(e,t){var r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();var n=[],a=s.extensions[this.name];if(void 0!==a.clearcoatFactor&&(t.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&n.push(r.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&n.push(r.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(n.push(r.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){var i=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new z.a(i,i)}return Promise.all(n)},Z.prototype.getMaterialType=function(e){var t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?O.a:null},Z.prototype.extendMaterialParams=function(e,t){var r=this.parser,s=r.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();var n=[],a=s.extensions[this.name];return void 0!==a.transmissionFactor&&(t.transmission=a.transmissionFactor),void 0!==a.transmissionTexture&&n.push(r.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(n)},$.prototype.loadTexture=function(e){var t=this.parser,r=t.json,s=r.textures[e];if(!s.extensions||!s.extensions[this.name])return null;var n=s.extensions[this.name],a=r.images[n.source],i=t.options.ktx2Loader;if(!i){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,a,i)},ee.prototype.loadTexture=function(e){var t=this.name,r=this.parser,s=r.json,n=s.textures[e];if(!n.extensions||!n.extensions[t])return null;var a=n.extensions[t],i=s.images[a.source],o=i.uri?r.options.manager.getHandler(i.uri):r.textureLoader;return this.detectSupport().then((function(n){if(n)return r.loadTextureImage(e,i,o);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)}))},ee.prototype.detectSupport=function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported},te.prototype.loadBufferView=function(e){var t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){var s=r.extensions[this.name],n=this.parser.getDependency("buffer",s.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.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([n,a.ready]).then((function(e){var t=s.byteOffset||0,r=s.byteLength||0,n=s.count,i=s.byteStride,o=new ArrayBuffer(n*i),u=new Uint8Array(e[0],t,r);return a.decodeGltfBuffer(new Uint8Array(o),n,i,u,s.mode,s.filter),o}))}return null};var re="glTF",se=1313821514,ne=5130562;function ae(e){this.name=r.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,12);if(this.header={magic:_.a.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.");for(var s=new DataView(e,12),n=0;n<s.byteLength;){var a=s.getUint32(n,!0);n+=4;var i=s.getUint32(n,!0);if(n+=4,i===se){var o=new Uint8Array(e,12+n,a);this.content=_.a.decodeText(o)}else if(i===ne){var u=12+n;this.body=e.slice(u,u+a)}n+=a}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}function ie(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=r.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}function oe(){this.name=r.KHR_TEXTURE_TRANSFORM}function ue(e){P.a.call(this),this.isGLTFSpecularGlossinessMaterial=!0;var t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),r=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),s=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),n=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),a=["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.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),i={specular:{value:(new p.a).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=i,this.onBeforeCompile=function(e){for(var o in i)e.uniforms[o]=i[o];e.fragmentShader=e.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>",n).replace("#include <lights_physical_fragment>",a)},Object.defineProperties(this,{specular:{get:function(){return i.specular.value},set:function(e){i.specular.value=e}},specularMap:{get:function(){return i.specularMap.value},set:function(e){i.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return i.glossiness.value},set:function(e){i.glossiness.value=e}},glossinessMap:{get:function(){return i.glossinessMap.value},set:function(e){i.glossinessMap.value=e,e?(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)}function le(){return{name:r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return ue},extendParams:function(e,t,r){var s=t.extensions[this.name];e.color=new p.a(1,1,1),e.opacity=1;var n=[];if(Array.isArray(s.diffuseFactor)){var a=s.diffuseFactor;e.color.fromArray(a),e.opacity=a[3]}if(void 0!==s.diffuseTexture&&n.push(r.assignTexture(e,"map",s.diffuseTexture)),e.emissive=new p.a(0,0,0),e.glossiness=void 0!==s.glossinessFactor?s.glossinessFactor:1,e.specular=new p.a(1,1,1),Array.isArray(s.specularFactor)&&e.specular.fromArray(s.specularFactor),void 0!==s.specularGlossinessTexture){var i=s.specularGlossinessTexture;n.push(r.assignTexture(e,"glossinessMap",i)),n.push(r.assignTexture(e,"specularMap",i))}return Promise.all(n)},createMaterial:function(e){var t=new ue(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=c.Uc,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}}function ce(){this.name=r.KHR_MESH_QUANTIZATION}function pe(e,t,r,s){x.a.call(this,e,t,r,s)}ie.prototype.decodePrimitive=function(e,t){var r=this.json,s=this.dracoLoader,n=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,i={},o={},u={};for(var l in a){var c=Me[l]||l.toLowerCase();i[c]=a[l]}for(l in e.attributes){c=Me[l]||l.toLowerCase();if(void 0!==a[l]){var p=r.accessors[e.attributes[l]],h=ye[p.componentType];u[c]=h,o[c]=!0===p.normalized}}return t.getDependency("bufferView",n).then((function(e){return new Promise((function(t){s.decodeDracoFile(e,(function(e){for(var r in e.attributes){var s=e.attributes[r],n=o[r];void 0!==n&&(s.normalized=n)}t(e)}),i,u)}))}))},oe.prototype.extendTexture=function(e,t){return e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),e.needsUpdate=!0,e},ue.prototype=Object.create(P.a.prototype),ue.prototype.constructor=ue,ue.prototype.copy=function(e){return P.a.prototype.copy.call(this,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},pe.prototype=Object.create(x.a.prototype),pe.prototype.constructor=pe,pe.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,r=this.sampleValues,s=this.valueSize,n=e*s*3+s,a=0;a!==s;a++)t[a]=r[n+a];return t},pe.prototype.beforeStart_=pe.prototype.copySampleValue_,pe.prototype.afterEnd_=pe.prototype.copySampleValue_,pe.prototype.interpolate_=function(e,t,r,s){for(var n=this.resultBuffer,a=this.sampleValues,i=this.valueSize,o=2*i,u=3*i,l=s-t,c=(r-t)/l,p=c*c,h=p*c,d=e*u,f=d-u,m=-2*h+3*p,g=h-p,v=1-m,T=g-p+c,y=0;y!==i;y++){var x=a[f+y+i],R=a[f+y+o]*l,S=a[d+y+i],M=a[d+y]*l;n[y]=v*x+T*R+m*S+g*M}return n};var he=0,de=1,fe=2,me=3,ge=4,ve=5,Te=6,ye={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},xe={9728:c.ob,9729:c.V,9984:c.sb,9985:c.Z,9986:c.rb,9987:c.Y},Re={33071:c.n,33648:c.kb,10497:c.wc},Se={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Me={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ee={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},_e={CUBICSPLINE:void 0,LINEAR:c.P,STEP:c.O},we="OPAQUE",Ae="MASK",be="BLEND";function Le(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}function Ie(e,t,r){for(var s in r.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=r.extensions[s])}function Oe(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Pe(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(var r=0,s=t.weights.length;r<s;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){var n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(r=0,s=n.length;r<s;r++)e.morphTargetDictionary[n[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ne(e){for(var t="",r=Object.keys(e).sort(),s=0,n=r.length;s<n;s++)t+=r[s]+":"+e[r[s]]+";";return t}function Ue(e,r){this.json=e||{},this.extensions={},this.plugins={},this.options=r||{},this.cache=new t,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox/.test(navigator.userAgent)?this.textureLoader=new v(this.options.manager):this.textureLoader=new q.a(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new d.a(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}function Ce(e,t,r){var s=t.attributes,n=[];function i(t,s){return r.getDependency("accessor",t).then((function(t){e.setAttribute(s,t)}))}for(var o in s){var u=Me[o]||o.toLowerCase();u in e.attributes||n.push(i(s[o],u))}if(void 0!==t.indices&&!e.index){var l=r.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));n.push(l)}return Oe(e,t),function(e,t,r){var s=t.attributes,n=new a.a;if(void 0!==s.POSITION){var i=(d=r.json.accessors[s.POSITION]).min,o=d.max;if(void 0!==i&&void 0!==o){n.set(new Y.a(i[0],i[1],i[2]),new Y.a(o[0],o[1],o[2]));var u=t.targets;if(void 0!==u){for(var l=new Y.a,c=new Y.a,p=0,h=u.length;p<h;p++){var d,f=u[p];if(void 0!==f.POSITION)i=(d=r.json.accessors[f.POSITION]).min,o=d.max,void 0!==i&&void 0!==o?(c.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),c.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),c.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),l.max(c)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}n.expandByVector(l)}e.boundingBox=n;var m=new V.a;n.getCenter(m.center),m.radius=n.min.distanceTo(n.max)/2,e.boundingSphere=m}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}(e,t,r),Promise.all(n).then((function(){return void 0!==t.targets?function(e,t,r){for(var s=!1,n=!1,a=0,i=t.length;a<i&&(void 0!==(l=t[a]).POSITION&&(s=!0),void 0!==l.NORMAL&&(n=!0),!s||!n);a++);if(!s&&!n)return Promise.resolve(e);var o=[],u=[];for(a=0,i=t.length;a<i;a++){var l=t[a];if(s){var c=void 0!==l.POSITION?r.getDependency("accessor",l.POSITION):e.attributes.position;o.push(c)}n&&(c=void 0!==l.NORMAL?r.getDependency("accessor",l.NORMAL):e.attributes.normal,u.push(c))}return Promise.all([Promise.all(o),Promise.all(u)]).then((function(t){var r=t[0],a=t[1];return s&&(e.morphAttributes.position=r),n&&(e.morphAttributes.normal=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,r):e}))}function Fe(e,t){var r=e.getIndex();if(null===r){var s=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(var a=0;a<n.count;a++)s.push(a);e.setIndex(s),r=e.getIndex()}var i=r.count-2,o=[];if(t===c.Vc)for(a=1;a<=i;a++)o.push(r.getX(0)),o.push(r.getX(a)),o.push(r.getX(a+1));else for(a=0;a<i;a++)a%2==0?(o.push(r.getX(a)),o.push(r.getX(a+1)),o.push(r.getX(a+2))):(o.push(r.getX(a+2)),o.push(r.getX(a+1)),o.push(r.getX(a)));o.length/3!==i&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var u=e.clone();return u.setIndex(o),u}return Ue.prototype.setExtensions=function(e){this.extensions=e},Ue.prototype.setPlugins=function(e){this.plugins=e},Ue.prototype.parse=function(e,t){var r=this,s=this.json,n=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then((function(t){var a={scene:t[0][s.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:s.asset,parser:r,userData:{}};Ie(n,a,s),Oe(a,s),e(a)})).catch(t)},Ue.prototype._markDefs=function(){for(var e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[],s=0,n=t.length;s<n;s++)for(var a=t[s].joints,i=0,o=a.length;i<o;i++)e[a[i]].isBone=!0;for(var u=0,l=e.length;u<l;u++){var c=e[u];void 0!==c.mesh&&(this._addNodeRef(this.meshCache,c.mesh),void 0!==c.skin&&(r[c.mesh].isSkinnedMesh=!0)),void 0!==c.camera&&this._addNodeRef(this.cameraCache,c.camera)}},Ue.prototype._addNodeRef=function(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)},Ue.prototype._getNodeRef=function(e,t,r){if(e.refs[t]<=1)return r;var s=r.clone();return s.name+="_instance_"+e.uses[t]++,s},Ue.prototype._invokeOne=function(e){var t=Object.values(this.plugins);t.push(this);for(var r=0;r<t.length;r++){var s=e(t[r]);if(s)return s}},Ue.prototype._invokeAll=function(e){var t=Object.values(this.plugins);t.unshift(this);for(var r=[],s=0;s<t.length;s++){var n=e(t[s]);n&&r.push(n)}return r},Ue.prototype.getDependency=function(e,t){var r=e+":"+t,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(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":s=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":s=this.loadSkin(t);break;case"animation":s=this.loadAnimation(t);break;case"camera":s=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,s)}return s},Ue.prototype.getDependencies=function(e){var t=this.cache.get(e);if(!t){var r=this,s=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(s.map((function(t,s){return r.getDependency(e,s)}))),this.cache.add(e,t)}return t},Ue.prototype.loadBuffer=function(e){var t=this.json.buffers[e],s=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[r.KHR_BINARY_GLTF].body);var n=this.options;return new Promise((function(e,r){s.load(Le(t.uri,n.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))},Ue.prototype.loadBufferView=function(e){var t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){var r=t.byteLength||0,s=t.byteOffset||0;return e.slice(s,s+r)}))},Ue.prototype.loadAccessor=function(e){var t=this,r=this.json,s=this.json.accessors[e];if(void 0===s.bufferView&&void 0===s.sparse)return Promise.resolve(null);var n=[];return void 0!==s.bufferView?n.push(this.getDependency("bufferView",s.bufferView)):n.push(null),void 0!==s.sparse&&(n.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(n).then((function(e){var n,a,o=e[0],u=Se[s.type],l=ye[s.componentType],c=l.BYTES_PER_ELEMENT,p=c*u,h=s.byteOffset||0,d=void 0!==s.bufferView?r.bufferViews[s.bufferView].byteStride:void 0,f=!0===s.normalized;if(d&&d!==p){var m=Math.floor(h/d),g="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+m+":"+s.count,v=t.cache.get(g);v||(n=new l(o,m*d,s.count*d/c),v=new T.a(n,d/c),t.cache.add(g,v)),a=new y.a(v,u,h%d/c,f)}else n=null===o?new l(s.count*u):new l(o,h,s.count*u),a=new i.a(n,u,f);if(void 0!==s.sparse){var x=Se.SCALAR,R=ye[s.sparse.indices.componentType],S=s.sparse.indices.byteOffset||0,M=s.sparse.values.byteOffset||0,E=new R(e[1],S,s.sparse.count*x),_=new l(e[2],M,s.sparse.count*u);null!==o&&(a=new i.a(a.array.slice(),a.itemSize,a.normalized));for(var w=0,A=E.length;w<A;w++){var b=E[w];if(a.setX(b,_[w*u]),u>=2&&a.setY(b,_[w*u+1]),u>=3&&a.setZ(b,_[w*u+2]),u>=4&&a.setW(b,_[w*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a}))},Ue.prototype.loadTexture=function(e){var t,s,n=this.json,a=this.options,i=n.textures[e],o=i.extensions||{};return(t=o[r.MSFT_TEXTURE_DDS]?n.images[o[r.MSFT_TEXTURE_DDS].source]:n.images[i.source]).uri&&(s=a.manager.getHandler(t.uri)),s||(s=o[r.MSFT_TEXTURE_DDS]?this.extensions[r.MSFT_TEXTURE_DDS].ddsLoader:this.textureLoader),this.loadTextureImage(e,t,s)},Ue.prototype.loadTextureImage=function(e,t,r){var s=this,n=this.json,a=this.options,i=n.textures[e],o=self.URL||self.webkitURL,u=t.uri,p=!1,h=!0;return"image/jpeg"===t.mimeType&&(h=!1),void 0!==t.bufferView&&(u=s.getDependency("bufferView",t.bufferView).then((function(e){if("image/png"===t.mimeType){var r=new DataView(e,25,1).getUint8(0,!1);h=6===r||4===r||3===r}p=!0;var s=new Blob([e],{type:t.mimeType});return u=o.createObjectURL(s)}))),Promise.resolve(u).then((function(e){return new Promise((function(t,s){var n=t;!0===r.isImageBitmapLoader&&(n=function(e){t(new l(e))}),r.load(Le(e,a.path),n,void 0,s)}))})).then((function(t){!0===p&&o.revokeObjectURL(u),t.flipY=!1,i.name&&(t.name=i.name),h||(t.format=c.ic);var r=(n.samplers||{})[i.sampler]||{};return t.magFilter=xe[r.magFilter]||c.V,t.minFilter=xe[r.minFilter]||c.Y,t.wrapS=Re[r.wrapS]||c.wc,t.wrapT=Re[r.wrapT]||c.wc,s.associations.set(t,{type:"textures",index:e}),t}))},Ue.prototype.assignTexture=function(e,t,s){var n=this;return this.getDependency("texture",s.index).then((function(a){if(void 0===s.texCoord||0==s.texCoord||"aoMap"===t&&1==s.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+s.texCoord+" for texture "+t+" not yet supported."),n.extensions[r.KHR_TEXTURE_TRANSFORM]){var i=void 0!==s.extensions?s.extensions[r.KHR_TEXTURE_TRANSFORM]:void 0;if(i){var o=n.associations.get(a);a=n.extensions[r.KHR_TEXTURE_TRANSFORM].extendTexture(a,i),n.associations.set(a,o)}}e[t]=a}))},Ue.prototype.assignFinalMaterial=function(e){var t=e.geometry,r=e.material,s=void 0!==t.attributes.tangent,n=void 0!==t.attributes.color,a=void 0===t.attributes.normal,i=!0===e.isSkinnedMesh,o=Object.keys(t.morphAttributes).length>0,u=o&&void 0!==t.morphAttributes.normal;if(e.isPoints){var l="PointsMaterial:"+r.uuid,c=this.cache.get(l);c||(c=new k.a,w.a.prototype.copy.call(c,r),c.color.copy(r.color),c.map=r.map,c.sizeAttenuation=!1,this.cache.add(l,c)),r=c}else if(e.isLine){l="LineBasicMaterial:"+r.uuid;var p=this.cache.get(l);p||(p=new S.a,w.a.prototype.copy.call(p,r),p.color.copy(r.color),this.cache.add(l,p)),r=p}if(s||n||a||i||o){l="ClonedMaterial:"+r.uuid+":";r.isGLTFSpecularGlossinessMaterial&&(l+="specular-glossiness:"),i&&(l+="skinning:"),s&&(l+="vertex-tangents:"),n&&(l+="vertex-colors:"),a&&(l+="flat-shading:"),o&&(l+="morph-targets:"),u&&(l+="morph-normals:");var h=this.cache.get(l);h||(h=r.clone(),i&&(h.skinning=!0),s&&(h.vertexTangents=!0),n&&(h.vertexColors=!0),a&&(h.flatShading=!0),o&&(h.morphTargets=!0),u&&(h.morphNormals=!0),this.cache.add(l,h),this.associations.set(h,this.associations.get(r))),r=h}r.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),r.normalScale&&!s&&(r.normalScale.y=-r.normalScale.y),r.clearcoatNormalScale&&!s&&(r.clearcoatNormalScale.y=-r.clearcoatNormalScale.y),e.material=r},Ue.prototype.getMaterialType=function(){return P.a},Ue.prototype.loadMaterial=function(e){var t,s=this,n=this.json,a=this.extensions,i=n.materials[e],o={},u=i.extensions||{},l=[];if(u[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var h=a[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=h.getMaterialType(),l.push(h.extendParams(o,i,s))}else if(u[r.KHR_MATERIALS_UNLIT]){var d=a[r.KHR_MATERIALS_UNLIT];t=d.getMaterialType(),l.push(d.extendParams(o,i,s))}else{var f=i.pbrMetallicRoughness||{};if(o.color=new p.a(1,1,1),o.opacity=1,Array.isArray(f.baseColorFactor)){var m=f.baseColorFactor;o.color.fromArray(m),o.opacity=m[3]}void 0!==f.baseColorTexture&&l.push(s.assignTexture(o,"map",f.baseColorTexture)),o.metalness=void 0!==f.metallicFactor?f.metallicFactor:1,o.roughness=void 0!==f.roughnessFactor?f.roughnessFactor:1,void 0!==f.metallicRoughnessTexture&&(l.push(s.assignTexture(o,"metalnessMap",f.metallicRoughnessTexture)),l.push(s.assignTexture(o,"roughnessMap",f.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===i.doubleSided&&(o.side=c.z);var g=i.alphaMode||we;return g===be?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,g===Ae&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&t!==I.a&&(l.push(s.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new z.a(1,1),void 0!==i.normalTexture.scale&&o.normalScale.set(i.normalTexture.scale,i.normalTexture.scale)),void 0!==i.occlusionTexture&&t!==I.a&&(l.push(s.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&t!==I.a&&(o.emissive=(new p.a).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&t!==I.a&&l.push(s.assignTexture(o,"emissiveMap",i.emissiveTexture)),Promise.all(l).then((function(){var n;return n=t===ue?a[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new t(o),i.name&&(n.name=i.name),n.map&&(n.map.encoding=c.ld),n.emissiveMap&&(n.emissiveMap.encoding=c.ld),Oe(n,i),s.associations.set(n,{type:"materials",index:e}),i.extensions&&Ie(a,n,i),n}))},Ue.prototype.createUniqueName=function(e){for(var t=G.a.sanitizeNodeName(e||""),r=t,s=1;this.nodeNamesUsed[r];++s)r=t+"_"+s;return this.nodeNamesUsed[r]=!0,r},Ue.prototype.loadGeometries=function(e){var t=this,s=this.extensions,n=this.primitiveCache;function a(e){return s[r.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(r){return Ce(r,e,t)}))}for(var i,u,l=[],c=0,p=e.length;c<p;c++){var h,d=e[c],f=(u=void 0,(u=(i=d).extensions&&i.extensions[r.KHR_DRACO_MESH_COMPRESSION])?"draco:"+u.bufferView+":"+u.indices+":"+Ne(u.attributes):i.indices+":"+Ne(i.attributes)+":"+i.mode),m=n[f];if(m)l.push(m.promise);else h=d.extensions&&d.extensions[r.KHR_DRACO_MESH_COMPRESSION]?a(d):Ce(new o.a,d,t),n[f]={primitive:d,promise:h},l.push(h)}return Promise.all(l)},Ue.prototype.loadMesh=function(e){for(var t,r=this,s=this.json,n=this.extensions,a=s.meshes[e],i=a.primitives,o=[],u=0,l=i.length;u<l;u++){var p=void 0===i[u].material?(void 0===(t=this.cache).DefaultMaterial&&(t.DefaultMaterial=new P.a({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.H})),t.DefaultMaterial):this.getDependency("material",i[u].material);o.push(p)}return o.push(r.loadGeometries(i)),Promise.all(o).then((function(t){for(var s=t.slice(0,t.length-1),o=t[t.length-1],u=[],l=0,p=o.length;l<p;l++){var h,d=o[l],m=i[l],g=s[l];if(m.mode===ge||m.mode===ve||m.mode===Te||void 0===m.mode)!0!==(h=!0===a.isSkinnedMesh?new K.a(d,g):new L.a(d,g)).isSkinnedMesh||h.geometry.attributes.skinWeight.normalized||h.normalizeSkinWeights(),m.mode===ve?h.geometry=Fe(h.geometry,c.Wc):m.mode===Te&&(h.geometry=Fe(h.geometry,c.Vc));else if(m.mode===de)h=new E.a(d,g);else if(m.mode===me)h=new R.a(d,g);else if(m.mode===fe)h=new M.a(d,g);else{if(m.mode!==he)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);h=new D.a(d,g)}Object.keys(h.geometry.morphAttributes).length>0&&Pe(h,a),h.name=r.createUniqueName(a.name||"mesh_"+e),Oe(h,a),m.extensions&&Ie(n,h,m),r.assignFinalMaterial(h),u.push(h)}if(1===u.length)return u[0];var v=new f.a;for(l=0,p=u.length;l<p;l++)v.add(u[l]);return v}))},Ue.prototype.loadCamera=function(e){var t,r=this.json.cameras[e],s=r[r.type];if(s)return"perspective"===r.type?t=new F.a(A.a.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):"orthographic"===r.type&&(t=new C.a(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),Oe(t,r),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")},Ue.prototype.loadSkin=function(e){var t=this.json.skins[e],r={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(r):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return r.inverseBindMatrices=e,r}))},Ue.prototype.loadAnimation=function(e){for(var t=this.json.animations[e],r=[],n=[],a=[],i=[],o=[],u=0,l=t.channels.length;u<l;u++){var p=t.channels[u],h=t.samplers[p.sampler],d=p.target,f=void 0!==d.node?d.node:d.id,m=void 0!==t.parameters?t.parameters[h.input]:h.input,g=void 0!==t.parameters?t.parameters[h.output]:h.output;r.push(this.getDependency("node",f)),n.push(this.getDependency("accessor",m)),a.push(this.getDependency("accessor",g)),i.push(h),o.push(d)}return Promise.all([Promise.all(r),Promise.all(n),Promise.all(a),Promise.all(i),Promise.all(o)]).then((function(r){for(var n=r[0],a=r[1],i=r[2],o=r[3],u=r[4],l=[],p=0,h=n.length;p<h;p++){var d=n[p],f=a[p],m=i[p],g=o[p],v=u[p];if(void 0!==d){var T;switch(d.updateMatrix(),d.matrixAutoUpdate=!0,Ee[v.path]){case Ee.weights:T=N.a;break;case Ee.rotation:T=j.a;break;case Ee.position:case Ee.scale:default:T=W.a}var y=d.name?d.name:d.uuid,x=void 0!==g.interpolation?_e[g.interpolation]:c.P,R=[];Ee[v.path]===Ee.weights?d.traverse((function(e){!0===e.isMesh&&e.morphTargetInfluences&&R.push(e.name?e.name:e.uuid)})):R.push(y);var S=m.array;if(m.normalized){var M;if(S.constructor===Int8Array)M=1/127;else if(S.constructor===Uint8Array)M=1/255;else if(S.constructor==Int16Array)M=1/32767;else{if(S.constructor!==Uint16Array)throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");M=1/65535}for(var E=new Float32Array(S.length),_=0,w=S.length;_<w;_++)E[_]=S[_]*M;S=E}for(_=0,w=R.length;_<w;_++){var A=new T(R[_]+"."+Ee[v.path],f.array,S,x);"CUBICSPLINE"===g.interpolation&&(A.createInterpolant=function(e){return new pe(this.times,this.values,this.getValueSize()/3,e)},A.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(A)}}}var b=t.name?t.name:"animation_"+e;return new s.a(b,void 0,l)}))},Ue.prototype.loadNode=function(e){var t,r=this.json,s=this.extensions,a=this,i=r.nodes[e],o=i.name?a.createUniqueName(i.name):"";return(t=[],void 0!==i.mesh&&t.push(a.getDependency("mesh",i.mesh).then((function(e){var t=a._getNodeRef(a.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(var t=0,r=i.weights.length;t<r;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))),void 0!==i.camera&&t.push(a.getDependency("camera",i.camera).then((function(e){return a._getNodeRef(a.cameraCache,i.camera,e)}))),a._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)).then((function(t){var r;if((r=!0===i.isBone?new n.a:t.length>1?new f.a:1===t.length?t[0]:new U.a)!==t[0])for(var u=0,l=t.length;u<l;u++)r.add(t[u]);if(i.name&&(r.userData.name=i.name,r.name=o),Oe(r,i),i.extensions&&Ie(s,r,i),void 0!==i.matrix){var c=new b.a;c.fromArray(i.matrix),r.applyMatrix4(c)}else void 0!==i.translation&&r.position.fromArray(i.translation),void 0!==i.rotation&&r.quaternion.fromArray(i.rotation),void 0!==i.scale&&r.scale.fromArray(i.scale);return a.associations.set(r,{type:"nodes",index:e}),r}))},Ue.prototype.loadScene=function(){function e(t,r,s,n){var a=s.nodes[t];return n.getDependency("node",t).then((function(e){return void 0===a.skin?e:n.getDependency("skin",a.skin).then((function(e){for(var r=[],s=0,a=(t=e).joints.length;s<a;s++)r.push(n.getDependency("node",t.joints[s]));return Promise.all(r)})).then((function(r){return e.traverse((function(e){if(e.isMesh){for(var s=[],n=[],a=0,i=r.length;a<i;a++){var o=r[a];if(o){s.push(o);var u=new b.a;void 0!==t.inverseBindMatrices&&u.fromArray(t.inverseBindMatrices.array,16*a),n.push(u)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[a])}e.bind(new B.a(s,n),e.matrixWorld)}})),e}));var t})).then((function(t){r.add(t);var i=[];if(a.children)for(var o=a.children,u=0,l=o.length;u<l;u++){var c=o[u];i.push(e(c,t,s,n))}return Promise.all(i)}))}return function(t){var r=this.json,s=this.extensions,n=this.json.scenes[t],a=new f.a;n.name&&(a.name=this.createUniqueName(n.name)),Oe(a,n),n.extensions&&Ie(s,a,n);for(var i=n.nodes||[],o=[],u=0,l=i.length;u<l;u++)o.push(e(i[u],a,r,this));return Promise.all(o).then((function(){return a}))}}(),e}()}}]); //# sourceMappingURL=7.js.map