UNPKG

49.4 kBJavaScriptView Raw
1!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("three")):"function"==typeof define&&define.amd?define(["three"],n):"object"==typeof exports?exports.VRM=n(require("three")):e.VRM=n(e.three)}(window,function(e){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=8)}([function(n,t){n.exports=e},function(e,n){e.exports="// Extend MeshBasicMaterial\n\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifndef FLAT_SHADED\n\n varying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n #include <clipping_planes_fragment>\n\n vec4 diffuseColor = vec4( diffuse, opacity );\n\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n // accumulation (baked indirect lighting only)\n #ifdef USE_LIGHTMAP\n\n reflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\n #else\n\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n\n #endif\n\n // modulation\n #include <aomap_fragment>\n\n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n #include <envmap_fragment>\n\n gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n #include <premultiplied_alpha_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n\n}\n"},function(e,n){e.exports="// Extend MeshBasicMaterial\n\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n #include <skinbase_vertex>\n\n #ifdef USE_ENVMAP\n\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n\n #endif\n\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n #include <envmap_vertex>\n #include <fog_vertex>\n\n}\n"},function(e,n){e.exports="varying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n varying vec3 vNormal;\n\n#endif\n\nstruct BlinnPhongMaterial {\n\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n\n};\n\nvoid RE_Direct_BlinnPhong(const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\n\n float dotNL = saturate(dot(geometry.normal, directLight.direction));\n dotNL = saturate(smoothstep(f_ShadeShift, f_ShadeShift + (1.0 + f_ShadeToony), dotNL));\n vec3 irradiance = mix(v_ShadeColor.rgb, vec3(1.0), dotNL);\n\n irradiance = irradiance * mix(directLight.color, vec3(average(directLight.color)), f_LightColorAttenuation);\n\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n\n irradiance *= PI;\n\n #endif\n\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(directLight, geometry, material.specularColor, material.specularShininess) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\n\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert(material.diffuseColor);\n\n}\n\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n\n#define Material_LightProbeLOD(material) (0)\n"},function(e,n){e.exports="#include <mtoon_uniforms> // MToon uniforms\n\n// Extend MeshPhongMaterial\n#define PHONG\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n// #include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n// #include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\n#include <lights_mtoon_pars_fragment>\n\nvoid main() {\n\n #include <clipping_planes_fragment>\n\n vec4 diffuseColor = vec4(diffuse, opacity);\n ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n vec3 totalEmissiveRadiance = emissive;\n\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n\n // accumulation\n #include <lights_phong_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n\n // modulation\n #include <aomap_fragment>\n\n // vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n vec3 outgoingLight = reflectedLight.directDiffuse + totalEmissiveRadiance;\n\n #include <envmap_fragment>\n\n // outgoingLight = mix(v_ShadeColor.rgb, diffuseColor.rgb, saturate(outgoingLight / diffuseColor.rgb));\n outgoingLight = clamp(outgoingLight, 0.0, 1.0);\n\n // MToon additive matcap\n vec3 viewNormal = normalize(normal);\n vec2 rimUv = vec2(dot(vec3(1.0, 0.0, 0.0), normal), -dot(vec3(0.0, 1.0, 0.0), normal)) * 0.5 + 0.5;\n vec4 rimColor = texture2D(t_SphereAdd, rimUv);\n outgoingLight += rimColor.rgb;\n\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n\n}\n"},function(e,n){e.exports="uniform float f_Cutoff;\nuniform vec4 v_Color;\nuniform vec4 v_ShadeColor;\nuniform sampler2D t_MainTex;\nuniform sampler2D t_ShadeTexture;\nuniform float f_BumpScale;\nuniform sampler2D t_BumpMap;\nuniform float f_ReceiveShadowRate;\nuniform sampler2D t_ReceiveShadowTexture;\nuniform float f_ShadeShift;\nuniform float f_ShadeToony;\nuniform float f_LightColorAttenuation;\nuniform sampler2D t_SphereAdd;\nuniform vec4 v_EmissionColor;\nuniform sampler2D t_EmissionMap;\nuniform sampler2D t_OutlineWidthTexture;\nuniform float f_OutlineWidth;\nuniform float f_OutlineScaledMaxDistance;\nuniform vec4 v_OutlineColor;\nuniform float f_OutlineLightingMix;\n\nuniform int f_DebugMode;\nuniform int f_BlendMode;\nuniform int f_OutlineWidthMode;\nuniform int f_OutlineColorMode;\nuniform int f_CullMode; // Cull [Back | Front | Off]\nuniform int f_OutlineCullMode;\nuniform float f_SrcBlend; // Blend [SrcFactor] [DstFactor]\nuniform float f_DstBlend; // Blend [SrcFactor] [DstFactor]\nuniform int f_ZWrite; // ZWrite [On | Off]\nuniform int f_IsFirstSetup;\n"},function(e,n){e.exports="// Extend MeshPhongMaterial\n#define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n varying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n #include <uv_vertex>\n #include <uv2_vertex>\n #include <color_vertex>\n\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n vNormal = normalize( transformedNormal );\n\n#endif\n\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n\n vViewPosition = - mvPosition.xyz;\n\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n\n}\n"},function(e,n,t){var r=t(0),i=function(){function e(e){this.manager=void 0!==e?e:r.DefaultLoadingManager,this.dracoLoader=null}e.prototype={constructor:e,crossOrigin:"anonymous",load:function(e,n,t,i){var a=this,s=void 0!==this.path?this.path:r.LoaderUtils.extractUrlBase(e),o=new r.FileLoader(a.manager);o.setResponseType("arraybuffer"),o.load(e,function(e){try{a.parse(e,s,n,i)}catch(e){if(void 0===i)throw e;i(e)}},t,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},setDRACOLoader:function(e){return this.dracoLoader=e,this},parse:function(e,d,f,p){var m,h={};if("string"==typeof e)m=e;else if(r.LoaderUtils.decodeText(new Uint8Array(e,0,4))===s){try{h[n.KHR_BINARY_GLTF]=new function(e){this.name=n.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,o);if(this.header={magic:r.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==s)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.");var i=new DataView(e,o),a=0;for(;a<i.byteLength;){var u=i.getUint32(a,!0);a+=4;var c=i.getUint32(a,!0);if(a+=4,c===l.JSON){var d=new Uint8Array(e,o+a,u);this.content=r.LoaderUtils.decodeText(d)}else if(c===l.BIN){var f=o+a;this.body=e.slice(f,f+u)}a+=u}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}(e)}catch(e){return void(p&&p(e))}m=h[n.KHR_BINARY_GLTF].content}else m=r.LoaderUtils.decodeText(new Uint8Array(e));var g=JSON.parse(m);if(void 0===g.asset||g.asset.version[0]<2)p&&p(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead."));else{if(g.extensionsUsed)for(var v=0;v<g.extensionsUsed.length;++v){var _=g.extensionsUsed[v],M=g.extensionsRequired||[];switch(_){case n.KHR_LIGHTS_PUNCTUAL:h[_]=new i(g);break;case n.KHR_MATERIALS_UNLIT:h[_]=new a(g);break;case n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:h[_]=new c;break;case n.KHR_DRACO_MESH_COMPRESSION:h[_]=new u(g,this.dracoLoader);break;case n.MSFT_TEXTURE_DDS:h[n.MSFT_TEXTURE_DDS]=new t;break;default:M.indexOf(_)>=0&&console.warn('THREE.GLTFLoader: Unknown extension "'+_+'".')}}var S=new B(g,h,{path:d||this.path||"",crossOrigin:this.crossOrigin,manager:this.manager});S.parse(function(e,n,t,r,i){var a={scene:e,scenes:n,cameras:t,animations:r,asset:i.asset,parser:S,userData:{}};C(h,a,i),f(a)},p)}}};var n={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};function t(){if(!r.DDSLoader)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing THREE.DDSLoader");this.name=n.MSFT_TEXTURE_DDS,this.ddsLoader=new r.DDSLoader}function i(e){this.name=n.KHR_LIGHTS_PUNCTUAL,this.lights=[];for(var t=(e.extensions&&e.extensions[n.KHR_LIGHTS_PUNCTUAL]||{}).lights||[],i=0;i<t.length;i++){var a,s=t[i],o=new r.Color(16777215);void 0!==s.color&&o.fromArray(s.color);var l=void 0!==s.range?s.range:0;switch(s.type){case"directional":(a=new r.DirectionalLight(o)).target.position.set(0,0,1),a.add(a.target);break;case"point":(a=new r.PointLight(o)).distance=l;break;case"spot":(a=new r.SpotLight(o)).distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,1),a.add(a.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+s.type+'".')}a.decay=2,void 0!==s.intensity&&(a.intensity=s.intensity),a.name=s.name||"light_"+i,this.lights.push(a)}}function a(e){this.name=n.KHR_MATERIALS_UNLIT}a.prototype.getMaterialType=function(e){return r.MeshBasicMaterial},a.prototype.extendParams=function(e,n,t){var i=[];e.color=new r.Color(1,1,1),e.opacity=1;var a=n.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){var s=a.baseColorFactor;e.color.fromArray(s),e.opacity=s[3]}void 0!==a.baseColorTexture&&i.push(t.assignTexture(e,"map",a.baseColorTexture.index))}return Promise.all(i)};var s="glTF",o=12,l={JSON:1313821514,BIN:5130562};function u(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=n.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t}function c(){return{name:n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return r.ShaderMaterial},extendParams:function(e,n,t){var i=n.extensions[this.name],a=r.ShaderLib.standard,s=r.UniformsUtils.clone(a.uniforms),o=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),l=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),u=["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"),c=["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"),d=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb;","material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );","material.specularColor = specularFactor.rgb;"].join("\n"),f=a.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",o).replace("#include <metalnessmap_pars_fragment>",l).replace("#include <roughnessmap_fragment>",u).replace("#include <metalnessmap_fragment>",c).replace("#include <lights_physical_fragment>",d);delete s.roughness,delete s.metalness,delete s.roughnessMap,delete s.metalnessMap,s.specular={value:(new r.Color).setHex(1118481)},s.glossiness={value:.5},s.specularMap={value:null},s.glossinessMap={value:null},e.vertexShader=a.vertexShader,e.fragmentShader=f,e.uniforms=s,e.defines={STANDARD:""},e.color=new r.Color(1,1,1),e.opacity=1;var p=[];if(Array.isArray(i.diffuseFactor)){var m=i.diffuseFactor;e.color.fromArray(m),e.opacity=m[3]}if(void 0!==i.diffuseTexture&&p.push(t.assignTexture(e,"map",i.diffuseTexture.index)),e.emissive=new r.Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new r.Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){var h=i.specularGlossinessTexture.index;p.push(t.assignTexture(e,"glossinessMap",h)),p.push(t.assignTexture(e,"specularMap",h))}return Promise.all(p)},createMaterial:function(e){var n=new r.ShaderMaterial({defines:e.defines,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,uniforms:e.uniforms,fog:!0,lights:!0,opacity:e.opacity,transparent:e.transparent});return n.isGLTFSpecularGlossinessMaterial=!0,n.color=e.color,n.map=void 0===e.map?null:e.map,n.lightMap=null,n.lightMapIntensity=1,n.aoMap=void 0===e.aoMap?null:e.aoMap,n.aoMapIntensity=1,n.emissive=e.emissive,n.emissiveIntensity=1,n.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,n.bumpMap=void 0===e.bumpMap?null:e.bumpMap,n.bumpScale=1,n.normalMap=void 0===e.normalMap?null:e.normalMap,e.normalScale&&(n.normalScale=e.normalScale),n.displacementMap=null,n.displacementScale=1,n.displacementBias=0,n.specularMap=void 0===e.specularMap?null:e.specularMap,n.specular=e.specular,n.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,n.glossiness=e.glossiness,n.alphaMap=null,n.envMap=void 0===e.envMap?null:e.envMap,n.envMapIntensity=1,n.refractionRatio=.98,n.extensions.derivatives=!0,n},cloneMaterial:function(e){var n=e.clone();n.isGLTFSpecularGlossinessMaterial=!0;for(var t=this.specularGlossinessParams,r=0,i=t.length;r<i;r++)n[t[r]]=e[t[r]];return n},refreshUniforms:function(e,n,t,r,i,a){if(!0===i.isGLTFSpecularGlossinessMaterial){var s,o=i.uniforms,l=i.defines;o.opacity.value=i.opacity,o.diffuse.value.copy(i.color),o.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),o.map.value=i.map,o.specularMap.value=i.specularMap,o.alphaMap.value=i.alphaMap,o.lightMap.value=i.lightMap,o.lightMapIntensity.value=i.lightMapIntensity,o.aoMap.value=i.aoMap,o.aoMapIntensity.value=i.aoMapIntensity,i.map?s=i.map:i.specularMap?s=i.specularMap:i.displacementMap?s=i.displacementMap:i.normalMap?s=i.normalMap:i.bumpMap?s=i.bumpMap:i.glossinessMap?s=i.glossinessMap:i.alphaMap?s=i.alphaMap:i.emissiveMap&&(s=i.emissiveMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),o.uvTransform.value.copy(s.matrix)),o.envMap.value=i.envMap,o.envMapIntensity.value=i.envMapIntensity,o.flipEnvMap.value=i.envMap&&i.envMap.isCubeTexture?-1:1,o.refractionRatio.value=i.refractionRatio,o.specular.value.copy(i.specular),o.glossiness.value=i.glossiness,o.glossinessMap.value=i.glossinessMap,o.emissiveMap.value=i.emissiveMap,o.bumpMap.value=i.bumpMap,o.normalMap.value=i.normalMap,o.displacementMap.value=i.displacementMap,o.displacementScale.value=i.displacementScale,o.displacementBias.value=i.displacementBias,null!==o.glossinessMap.value&&void 0===l.USE_GLOSSINESSMAP&&(l.USE_GLOSSINESSMAP="",l.USE_ROUGHNESSMAP=""),null===o.glossinessMap.value&&void 0!==l.USE_GLOSSINESSMAP&&(delete l.USE_GLOSSINESSMAP,delete l.USE_ROUGHNESSMAP)}}}}function d(e,n,t,i){r.Interpolant.call(this,e,n,t,i)}u.prototype.decodePrimitive=function(e,n){var t=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,s={},o={},l={};for(var u in a)u in L&&(s[L[u]]=a[u]);for(u in e.attributes)if(void 0!==L[u]&&void 0!==a[u]){var c=t.accessors[e.attributes[u]],d=M[c.componentType];l[L[u]]=d,o[L[u]]=!0===c.normalized}return n.getDependency("bufferView",i).then(function(e){return new Promise(function(n){r.decodeDracoFile(e,function(e){for(var t in e.attributes){var r=e.attributes[t],i=o[t];void 0!==i&&(r.normalized=i)}n(e)},s,l)})})},d.prototype=Object.create(r.Interpolant.prototype),d.prototype.constructor=d,d.prototype.interpolate_=function(e,n,t,r){for(var i=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=2*s,l=3*s,u=r-n,c=(t-n)/u,d=c*c,f=d*c,p=e*l,m=p-l,h=2*f-3*d+1,g=f-2*d+c,v=-2*f+3*d,_=f-d,M=0;M!==s;M++){var S=a[m+M+s],y=a[m+M+o]*u,x=a[p+M+s],L=a[p+M]*u;i[M]=h*S+g*y+v*x+_*L}return i};var f=0,p=1,m=2,h=3,g=4,v=5,_=6,M=(Number,r.Matrix3,r.Matrix4,r.Vector2,r.Vector3,r.Vector4,r.Texture,{5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array}),S={9728:r.NearestFilter,9729:r.LinearFilter,9984:r.NearestMipMapNearestFilter,9985:r.LinearMipMapNearestFilter,9986:r.NearestMipMapLinearFilter,9987:r.LinearMipMapLinearFilter},y={33071:r.ClampToEdgeWrapping,33648:r.MirroredRepeatWrapping,10497:r.RepeatWrapping},x=(r.BackSide,r.FrontSide,r.NeverDepth,r.LessDepth,r.EqualDepth,r.LessEqualDepth,r.GreaterEqualDepth,r.NotEqualDepth,r.GreaterEqualDepth,r.AlwaysDepth,r.AddEquation,r.SubtractEquation,r.ReverseSubtractEquation,r.ZeroFactor,r.OneFactor,r.SrcColorFactor,r.OneMinusSrcColorFactor,r.SrcAlphaFactor,r.OneMinusSrcAlphaFactor,r.DstAlphaFactor,r.OneMinusDstAlphaFactor,r.DstColorFactor,r.OneMinusDstColorFactor,r.SrcAlphaSaturateFactor,{SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16}),L={POSITION:"position",NORMAL:"normal",TEXCOORD_0:"uv",TEXCOORD0:"uv",TEXCOORD:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",COLOR0:"color",COLOR:"color",WEIGHTS_0:"skinWeight",WEIGHT:"skinWeight",JOINTS_0:"skinIndex",JOINT:"skinIndex"},b={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},T={CUBICSPLINE:r.InterpolateSmooth,LINEAR:r.InterpolateLinear,STEP:r.InterpolateDiscrete},R="OPAQUE",w="MASK",A="BLEND";function E(e,n){return"string"!=typeof e||""===e?"":/^(https?:)?\/\//i.test(e)?e:/^data:.*,.*$/i.test(e)?e:/^blob:.*$/i.test(e)?e:n+e}function C(e,n,t){for(var r in t.extensions)void 0===e[r]&&(n.userData.gltfExtensions=n.userData.gltfExtensions||{},n.userData.gltfExtensions[r]=t.extensions[r])}function P(e,n){void 0!==n.extras&&("object"==typeof n.extras?e.userData=n.extras:console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+n.extras))}function D(e,n){if(e.updateMorphTargets(),void 0!==n.weights)for(var t=0,r=n.weights.length;t<r;t++)e.morphTargetInfluences[t]=n.weights[t];if(n.extras&&Array.isArray(n.extras.targetNames)){var i=n.extras.targetNames;if(e.morphTargetInfluences.length===i.length){e.morphTargetDictionary={};for(t=0,r=i.length;t<r;t++)e.morphTargetDictionary[i[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function O(e,n){return e.indices===n.indices&&F(e.attributes,n.attributes)}function F(e,n){if(Object.keys(e).length!==Object.keys(n).length)return!1;for(var t in e)if(e[t]!==n[t])return!1;return!0}function I(e,n){if(e.length!==n.length)return!1;for(var t=0,r=e.length;t<r;t++)if(e[t]!==n[t])return!1;return!0}function U(e,n){for(var t=0,r=e.length;t<r;t++){var i=e[t];if(O(i.primitive,n))return i.promise}return null}function G(e){if(e.isInterleavedBufferAttribute){for(var n=e.count,t=e.itemSize,i=e.array.slice(0,n*t),a=0;a<n;++a)i[a]=e.getX(a),t>=2&&(i[a+1]=e.getY(a)),t>=3&&(i[a+2]=e.getZ(a)),t>=4&&(i[a+3]=e.getW(a));return new r.BufferAttribute(i,t,e.normalized)}return e.clone()}function B(e,n,t){this.json=e||{},this.extensions=n||{},this.options=t||{},this.cache=new function(){var e={};return{get:function(n){return e[n]},add:function(n,t){e[n]=t},remove:function(n){delete e[n]},removeAll:function(){e={}}}},this.primitiveCache=[],this.multiplePrimitivesCache=[],this.multiPassGeometryCache=[],this.textureLoader=new r.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new r.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer")}function N(e,n,t){var r=n.attributes;for(var i in r){var a=L[i],s=t[r[i]];a&&(a in e.attributes||e.addAttribute(a,s))}void 0===n.indices||e.index||e.setIndex(t[n.indices]),void 0!==n.targets&&function(e,n,t){for(var r=!1,i=!1,a=0,s=n.length;a<s&&(void 0!==(u=n[a]).POSITION&&(r=!0),void 0!==u.NORMAL&&(i=!0),!r||!i);a++);if(r||i){var o=[],l=[];for(a=0,s=n.length;a<s;a++){var u=n[a],c="morphTarget"+a;if(r){if(void 0!==u.POSITION){var d=G(t[u.POSITION]);d.name=c;for(var f=e.attributes.position,p=0,m=d.count;p<m;p++)d.setXYZ(p,d.getX(p)+f.getX(p),d.getY(p)+f.getY(p),d.getZ(p)+f.getZ(p))}else d=e.attributes.position;o.push(d)}if(i){if(void 0!==u.NORMAL){var h;(h=G(t[u.NORMAL])).name=c;var g=e.attributes.normal;for(p=0,m=h.count;p<m;p++)h.setXYZ(p,h.getX(p)+g.getX(p),h.getY(p)+g.getY(p),h.getZ(p)+g.getZ(p))}else h=e.attributes.normal;l.push(h)}}r&&(e.morphAttributes.position=o),i&&(e.morphAttributes.normal=l)}}(e,n.targets,t),P(e,n)}return B.prototype.parse=function(e,n){var t=this.json;this.cache.removeAll(),this.markDefs(),this.getMultiDependencies(["scene","animation","camera"]).then(function(n){var r=n.scenes||[],i=r[t.scene||0],a=n.animations||[],s=n.cameras||[];e(i,r,s,a,t)}).catch(n)},B.prototype.markDefs=function(){for(var e=this.json.nodes||[],n=this.json.skins||[],t=this.json.meshes||[],r={},i={},a=0,s=n.length;a<s;a++)for(var o=n[a].joints,l=0,u=o.length;l<u;l++)e[o[l]].isBone=!0;for(var c=0,d=e.length;c<d;c++){var f=e[c];void 0!==f.mesh&&(void 0===r[f.mesh]&&(r[f.mesh]=i[f.mesh]=0),r[f.mesh]++,void 0!==f.skin&&(t[f.mesh].isSkinnedMesh=!0))}this.json.meshReferences=r,this.json.meshUses=i},B.prototype.getDependency=function(e,n){var t=e+":"+n,r=this.cache.get(t);if(!r){switch(e){case"scene":r=this.loadScene(n);break;case"node":r=this.loadNode(n);break;case"mesh":r=this.loadMesh(n);break;case"accessor":r=this.loadAccessor(n);break;case"bufferView":r=this.loadBufferView(n);break;case"buffer":r=this.loadBuffer(n);break;case"material":r=this.loadMaterial(n);break;case"texture":r=this.loadTexture(n);break;case"skin":r=this.loadSkin(n);break;case"animation":r=this.loadAnimation(n);break;case"camera":r=this.loadCamera(n);break;default:throw new Error("Unknown type: "+e)}this.cache.add(t,r)}return r},B.prototype.getDependencies=function(e){var n=this.cache.get(e);if(!n){var t=this,r=this.json[e+("mesh"===e?"es":"s")]||[];n=Promise.all(r.map(function(n,r){return t.getDependency(e,r)})),this.cache.add(e,n)}return n},B.prototype.getMultiDependencies=function(e){for(var n={},t=[],r=0,i=e.length;r<i;r++){var a=e[r],s=this.getDependencies(a);s=s.then(function(e,t){n[e]=t}.bind(this,a+("mesh"===a?"es":"s"))),t.push(s)}return Promise.all(t).then(function(){return n})},B.prototype.loadBuffer=function(e){var t=this.json.buffers[e],r=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[n.KHR_BINARY_GLTF].body);var i=this.options;return new Promise(function(e,n){r.load(E(t.uri,i.path),e,void 0,function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})},B.prototype.loadBufferView=function(e){var n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(e){var t=n.byteLength||0,r=n.byteOffset||0;return e.slice(r,r+t)})},B.prototype.loadAccessor=function(e){var n=this,t=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return null;var a=[];return void 0!==i.bufferView?a.push(this.getDependency("bufferView",i.bufferView)):a.push(null),void 0!==i.sparse&&(a.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(a).then(function(e){var a,s,o=e[0],l=x[i.type],u=M[i.componentType],c=u.BYTES_PER_ELEMENT,d=c*l,f=i.byteOffset||0,p=t.bufferViews[i.bufferView].byteStride,m=!0===i.normalized;if(p&&p!==d){var h="InterleavedBuffer:"+i.bufferView+":"+i.componentType,g=n.cache.get(h);g||(a=new u(o),g=new r.InterleavedBuffer(a,p/c),n.cache.add(h,g)),s=new r.InterleavedBufferAttribute(g,l,f/c,m)}else a=null===o?new u(i.count*l):new u(o,f,i.count*l),s=new r.BufferAttribute(a,l,m);if(void 0!==i.sparse){var v=x.SCALAR,_=M[i.sparse.indices.componentType],S=i.sparse.indices.byteOffset||0,y=i.sparse.values.byteOffset||0,L=new _(e[1],S,i.sparse.count*v),b=new u(e[2],y,i.sparse.count*l);null!==o&&s.setArray(s.array.slice());for(var T=0,R=L.length;T<R;T++){var w=L[T];if(s.setX(w,b[T*l]),l>=2&&s.setY(w,b[T*l+1]),l>=3&&s.setZ(w,b[T*l+2]),l>=4&&s.setW(w,b[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return s})},B.prototype.loadTexture=function(e){var t,i=this,a=this.json,s=this.options,o=this.textureLoader,l=window.URL||window.webkitURL,u=a.textures[e],c=u.extensions||{},d=(t=c[n.MSFT_TEXTURE_DDS]?a.images[c[n.MSFT_TEXTURE_DDS].source]:a.images[u.source]).uri,f=!1;return void 0!==t.bufferView&&(d=i.getDependency("bufferView",t.bufferView).then(function(e){f=!0;var n=new Blob([e],{type:t.mimeType});return d=l.createObjectURL(n)})),Promise.resolve(d).then(function(e){var t=r.Loader.Handlers.get(e);return t||(t=c[n.MSFT_TEXTURE_DDS]?i.extensions[n.MSFT_TEXTURE_DDS].ddsLoader:o),new Promise(function(n,r){t.load(E(e,s.path),n,void 0,r)})}).then(function(e){!0===f&&l.revokeObjectURL(d),e.flipY=!1,void 0!==u.name&&(e.name=u.name);var n=(a.samplers||{})[u.sampler]||{};return e.magFilter=S[n.magFilter]||r.LinearFilter,e.minFilter=S[n.minFilter]||r.LinearMipMapLinearFilter,e.wrapS=y[n.wrapS]||r.RepeatWrapping,e.wrapT=y[n.wrapT]||r.RepeatWrapping,e})},B.prototype.assignTexture=function(e,n,t){return this.getDependency("texture",t).then(function(t){e[n]=t})},B.prototype.loadMaterial=function(e){this.json;var t,i=this.extensions,a=this.json.materials[e],s={},o=a.extensions||{},l=[];if(o[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var u=i[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=u.getMaterialType(a),l.push(u.extendParams(s,a,this))}else if(o[n.KHR_MATERIALS_UNLIT]){var c=i[n.KHR_MATERIALS_UNLIT];t=c.getMaterialType(a),l.push(c.extendParams(s,a,this))}else{t=r.MeshStandardMaterial;var d=a.pbrMetallicRoughness||{};if(s.color=new r.Color(1,1,1),s.opacity=1,Array.isArray(d.baseColorFactor)){var f=d.baseColorFactor;s.color.fromArray(f),s.opacity=f[3]}if(void 0!==d.baseColorTexture&&l.push(this.assignTexture(s,"map",d.baseColorTexture.index)),s.metalness=void 0!==d.metallicFactor?d.metallicFactor:1,s.roughness=void 0!==d.roughnessFactor?d.roughnessFactor:1,void 0!==d.metallicRoughnessTexture){var p=d.metallicRoughnessTexture.index;l.push(this.assignTexture(s,"metalnessMap",p)),l.push(this.assignTexture(s,"roughnessMap",p))}}!0===a.doubleSided&&(s.side=r.DoubleSide);var m=a.alphaMode||R;return m===A?s.transparent=!0:(s.transparent=!1,m===w&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==r.MeshBasicMaterial&&(l.push(this.assignTexture(s,"normalMap",a.normalTexture.index)),s.normalScale=new r.Vector2(1,1),void 0!==a.normalTexture.scale&&s.normalScale.set(a.normalTexture.scale,a.normalTexture.scale)),void 0!==a.occlusionTexture&&t!==r.MeshBasicMaterial&&(l.push(this.assignTexture(s,"aoMap",a.occlusionTexture.index)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==r.MeshBasicMaterial&&(s.emissive=(new r.Color).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==r.MeshBasicMaterial&&l.push(this.assignTexture(s,"emissiveMap",a.emissiveTexture.index)),Promise.all(l).then(function(){var e;return e=t===r.ShaderMaterial?i[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(s):new t(s),void 0!==a.name&&(e.name=a.name),e.normalScale&&(e.normalScale.y=-e.normalScale.y),e.map&&(e.map.encoding=r.sRGBEncoding),e.emissiveMap&&(e.emissiveMap.encoding=r.sRGBEncoding),e.specularMap&&(e.specularMap.encoding=r.sRGBEncoding),P(e,a),a.extensions&&C(i,e,a),e})},B.prototype.loadGeometries=function(e){var t,i=this,a=this.extensions,s=this.primitiveCache,o=function(e){if(e.length<2)return!1;var n=e[0],t=n.targets||[];if(void 0===n.indices)return!1;for(var r=1,i=e.length;r<i;r++){var a=e[r];if(n.mode!==a.mode)return!1;if(void 0===a.indices)return!1;if(!F(n.attributes,a.attributes))return!1;var s=a.targets||[];if(t.length!==s.length)return!1;for(var o=0,l=t.length;o<l;o++)if(!F(t[o],s[o]))return!1}return!0}(e);return o&&(t=e,e=[e[0]]),this.getDependencies("accessor").then(function(l){for(var u=[],c=0,d=e.length;c<d;c++){var f=e[c],p=U(s,f);if(p)u.push(p);else if(f.extensions&&f.extensions[n.KHR_DRACO_MESH_COMPRESSION]){var m=a[n.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(f,i).then(function(e){return N(e,f,l),e});s.push({primitive:f,promise:m}),u.push(m)}else{var h=new r.BufferGeometry;N(h,f,l);m=Promise.resolve(h);s.push({primitive:f,promise:m}),u.push(m)}}return Promise.all(u).then(function(n){if(o){var a=n[0];if(null!==(_=function(e,n,t){for(var r=0,i=e.length;r<i;r++){var a=e[r];if(n===a.baseGeometry&&I(t,a.primitives))return a.geometry}return null}(v=i.multiPassGeometryCache,a,t)))return[_.geometry];var s=new r.BufferGeometry;for(var u in s.name=a.name,s.userData=a.userData,a.attributes)s.addAttribute(u,a.attributes[u]);for(var u in a.morphAttributes)s.morphAttributes[u]=a.morphAttributes[u];for(var c=[],d=0,f=0,p=t.length;f<p;f++){for(var m=l[t[f].indices],h=0,g=m.count;h<g;h++)c.push(m.array[h]);s.addGroup(d,m.count,f),d+=m.count}return s.setIndex(c),v.push({geometry:s,baseGeometry:a,primitives:t}),[s]}if(n.length>1&&void 0!==r.BufferGeometryUtils){for(f=1,p=e.length;f<p;f++)if(e[0].mode!==e[f].mode)return n;var v,_;if(_=function(e,n){for(var t=0,r=e.length;t<r;t++){var i=e[t];if(I(n,i.baseGeometries))return i.geometry}return null}(v=i.multiplePrimitivesCache,n)){if(null!==_.geometry)return[_.geometry]}else{s=r.BufferGeometryUtils.mergeBufferGeometries(n,!0);if(v.push({geometry:s,baseGeometries:n}),null!==s)return[s]}}return n})})},B.prototype.loadMesh=function(e){var t=this,i=(this.json,this.extensions),a=this.json.meshes[e];return this.getMultiDependencies(["accessor","material"]).then(function(s){for(var o=a.primitives,l=[],u=0,c=o.length;u<c;u++)l[u]=void 0===o[u].material?new r.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:r.FrontSide}):s.materials[o[u].material];return t.loadGeometries(o).then(function(s){for(var u=1===s.length&&s[0].groups.length>0,c=[],d=0,M=s.length;d<M;d++){var S,y=s[d],x=o[d],L=u?l:l[d];if(x.mode===g||x.mode===v||x.mode===_||void 0===x.mode)S=!0===a.isSkinnedMesh?new r.SkinnedMesh(y,L):new r.Mesh(y,L),x.mode===v?S.drawMode=r.TriangleStripDrawMode:x.mode===_&&(S.drawMode=r.TriangleFanDrawMode);else if(x.mode===p)S=new r.LineSegments(y,L);else if(x.mode===h)S=new r.Line(y,L);else if(x.mode===m)S=new r.LineLoop(y,L);else{if(x.mode!==f)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);S=new r.Points(y,L)}Object.keys(S.geometry.morphAttributes).length>0&&D(S,a),S.name=a.name||"mesh_"+e,s.length>1&&(S.name+="_"+d),P(S,a),c.push(S);for(var b=u?S.material:[S.material],T=void 0!==y.attributes.color,R=void 0===y.attributes.normal,w=!0===S.isSkinnedMesh,A=Object.keys(y.morphAttributes).length>0,E=A&&void 0!==y.morphAttributes.normal,C=0,O=b.length;C<O;C++){L=b[C];if(S.isPoints){var F="PointsMaterial:"+L.uuid,I=t.cache.get(F);I||(I=new r.PointsMaterial,r.Material.prototype.copy.call(I,L),I.color.copy(L.color),I.map=L.map,I.lights=!1,t.cache.add(F,I)),L=I}else if(S.isLine){F="LineBasicMaterial:"+L.uuid;var U=t.cache.get(F);U||(U=new r.LineBasicMaterial,r.Material.prototype.copy.call(U,L),U.color.copy(L.color),U.lights=!1,t.cache.add(F,U)),L=U}if(T||R||w||A){F="ClonedMaterial:"+L.uuid+":";L.isGLTFSpecularGlossinessMaterial&&(F+="specular-glossiness:"),w&&(F+="skinning:"),T&&(F+="vertex-colors:"),R&&(F+="flat-shading:"),A&&(F+="morph-targets:"),E&&(F+="morph-normals:");var G=t.cache.get(F);G||(G=L.isGLTFSpecularGlossinessMaterial?i[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].cloneMaterial(L):L.clone(),w&&(G.skinning=!0),T&&(G.vertexColors=r.VertexColors),R&&(G.flatShading=!0),A&&(G.morphTargets=!0),E&&(G.morphNormals=!0),t.cache.add(F,G)),L=G}b[C]=L,L.aoMap&&void 0===y.attributes.uv2&&void 0!==y.attributes.uv&&(console.log("THREE.GLTFLoader: Duplicating UVs to support aoMap."),y.addAttribute("uv2",new r.BufferAttribute(y.attributes.uv.array,2))),L.isGLTFSpecularGlossinessMaterial&&(S.onBeforeRender=i[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].refreshUniforms)}S.material=u?b:b[0]}if(1===c.length)return c[0];var B=new r.Group;for(d=0,M=c.length;d<M;d++)B.add(c[d]);return B})})},B.prototype.loadCamera=function(e){var n,t=this.json.cameras[e],i=t[t.type];if(i)return"perspective"===t.type?n=new r.PerspectiveCamera(r.Math.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===t.type&&(n=new r.OrthographicCamera(i.xmag/-2,i.xmag/2,i.ymag/2,i.ymag/-2,i.znear,i.zfar)),void 0!==t.name&&(n.name=t.name),P(n,t),Promise.resolve(n);console.warn("THREE.GLTFLoader: Missing camera parameters.")},B.prototype.loadSkin=function(e){var n=this.json.skins[e],t={joints:n.joints};return void 0===n.inverseBindMatrices?Promise.resolve(t):this.getDependency("accessor",n.inverseBindMatrices).then(function(e){return t.inverseBindMatrices=e,t})},B.prototype.loadAnimation=function(e){this.json;var n=this.json.animations[e];return this.getMultiDependencies(["accessor","node"]).then(function(t){for(var i=[],a=0,s=n.channels.length;a<s;a++){var o=n.channels[a],l=n.samplers[o.sampler];if(l){var u=o.target,c=void 0!==u.node?u.node:u.id,f=void 0!==n.parameters?n.parameters[l.input]:l.input,p=void 0!==n.parameters?n.parameters[l.output]:l.output,m=t.accessors[f],h=t.accessors[p],g=t.nodes[c];if(g){var v;switch(g.updateMatrix(),g.matrixAutoUpdate=!0,b[u.path]){case b.weights:v=r.NumberKeyframeTrack;break;case b.rotation:v=r.QuaternionKeyframeTrack;break;case b.position:case b.scale:default:v=r.VectorKeyframeTrack}var _=g.name?g.name:g.uuid,M=void 0!==l.interpolation?T[l.interpolation]:r.InterpolateLinear,S=[];b[u.path]===b.weights?g.traverse(function(e){!0===e.isMesh&&e.morphTargetInfluences&&S.push(e.name?e.name:e.uuid)}):S.push(_);for(var y=0,x=S.length;y<x;y++){var L=new v(S[y]+"."+b[u.path],r.AnimationUtils.arraySlice(m.array,0),r.AnimationUtils.arraySlice(h.array,0),M);"CUBICSPLINE"===l.interpolation&&(L.createInterpolant=function(e){return new d(this.times,this.values,this.getValueSize()/3,e)},L.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),i.push(L)}}}}c=void 0!==n.name?n.name:"animation_"+e;return new r.AnimationClip(c,void 0,i)})},B.prototype.loadNode=function(e){this.json;var t=this.extensions,i=this.json.meshReferences,a=this.json.meshUses,s=this.json.nodes[e];return this.getMultiDependencies(["mesh","skin","camera","light"]).then(function(e){var o;if(!0===s.isBone)o=new r.Bone;else if(void 0!==s.mesh){var l=e.meshes[s.mesh];if(i[s.mesh]>1){var u=a[s.mesh]++;(o=l.clone()).name+="_instance_"+u,o.onBeforeRender=l.onBeforeRender;for(var c=0,d=o.children.length;c<d;c++)o.children[c].name+="_instance_"+u,o.children[c].onBeforeRender=l.children[c].onBeforeRender}else o=l}else if(void 0!==s.camera)o=e.cameras[s.camera];else if(s.extensions&&s.extensions[n.KHR_LIGHTS_PUNCTUAL]&&void 0!==s.extensions[n.KHR_LIGHTS_PUNCTUAL].light){o=t[n.KHR_LIGHTS_PUNCTUAL].lights[s.extensions[n.KHR_LIGHTS_PUNCTUAL].light]}else o=new r.Object3D;if(void 0!==s.name&&(o.name=r.PropertyBinding.sanitizeNodeName(s.name)),P(o,s),s.extensions&&C(t,o,s),void 0!==s.matrix){var f=new r.Matrix4;f.fromArray(s.matrix),o.applyMatrix(f)}else void 0!==s.translation&&o.position.fromArray(s.translation),void 0!==s.rotation&&o.quaternion.fromArray(s.rotation),void 0!==s.scale&&o.scale.fromArray(s.scale);return o})},B.prototype.loadScene=function(){function e(n,t,i,a,s){var o=a[n],l=i.nodes[n];if(void 0!==l.skin)for(var u=!0===o.isGroup?o.children:[o],c=0,d=u.length;c<d;c++){for(var f=u[c],p=s[l.skin],m=[],h=[],g=0,v=p.joints.length;g<v;g++){var _=p.joints[g],M=a[_];if(M){m.push(M);var S=new r.Matrix4;void 0!==p.inverseBindMatrices&&S.fromArray(p.inverseBindMatrices.array,16*g),h.push(S)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',_)}f.bind(new r.Skeleton(m,h),f.matrixWorld)}if(t.add(o),l.children){var y=l.children;for(c=0,d=y.length;c<d;c++){e(y[c],o,i,a,s)}}}return function(n){var t=this.json,i=this.extensions,a=this.json.scenes[n];return this.getMultiDependencies(["node","skin"]).then(function(n){var s=new r.Scene;void 0!==a.name&&(s.name=a.name),P(s,a),a.extensions&&C(i,s,a);for(var o=a.nodes||[],l=0,u=o.length;l<u;l++)e(o[l],s,t,n.nodes,n.skins);return s})}}(),e}();e.exports=i},function(e,n,t){"use strict";t.r(n);var r=t(0),i=t(3),a=t.n(i),s=t(4),o=t.n(s),l=t(5),u=t.n(l),c=t(6),d=t.n(c),f=t(1),p=t.n(f),m=t(2),h=t.n(m);Object.assign(r.ShaderChunk,{mtoon_uniforms:u.a,lights_mtoon_pars_fragment:a.a});const g=new Map([["VRM/UnlitTexture",{defines:{},uniforms:Object.assign({},r.ShaderLib.basic.uniforms,{f_Cutoff:{value:0},v_Color:{value:new r.Vector4(1,1,1,1)}}),vertexShader:h.a,fragmentShader:p.a,lights:!1}],["VRM/UnlitCutout",{defines:{},uniforms:Object.assign({},r.ShaderLib.basic.uniforms,{f_Cutoff:{value:0},v_Color:{value:new r.Vector4(1,1,1,1)}}),vertexShader:h.a,fragmentShader:p.a,lights:!1}],["VRM/UnlitTransparent",{defines:{},uniforms:Object.assign({},r.ShaderLib.basic.uniforms,{f_Cutoff:{value:0},v_Color:{value:new r.Vector4(1,1,1,1)}}),vertexShader:h.a,fragmentShader:p.a,lights:!1}],["VRM/UnlitTransparentZWrite",{defines:{},uniforms:Object.assign({},r.ShaderLib.basic.uniforms,{f_Cutoff:{value:0},v_Color:{value:new r.Vector4(1,1,1,1)}}),vertexShader:h.a,fragmentShader:p.a,lights:!1}],["VRM/MToon",{defines:{},uniforms:Object.assign({},r.ShaderLib.phong.uniforms,{f_Cutoff:{value:0},v_Color:{value:new r.Vector4(1,1,1,1)}}),vertexShader:d.a,fragmentShader:o.a,lights:!0}]]),v=new Map([["common",e=>{e.uniforms.f_Cutoff&&(e.defines.ALPHATEST=e.uniforms.f_Cutoff.value.toFixed(6));const n=e.uniforms.v_Color.value;e.uniforms.diffuse={value:new r.Color(n.x,n.y,n.z)},e.uniforms.opacity={value:n.w},e.uniforms.t_MainTex&&(e.map=e.uniforms.t_MainTex.value,e.uniforms.map=e.uniforms.t_MainTex)}],["VRM/UnlitTexture",e=>null],["VRM/UnlitCutout",e=>null],["VRM/UnlitTransparent",e=>null],["VRM/UnlitTransparentZWrite",e=>null],["VRM/MToon",e=>{switch(e.uniforms.shininess={value:0},e.userData.RenderType){case"Opaque":e.defines.ALPHATEST=0;break;case"Cutout":break;case"Transparent":e.defines.ALPHATEST=0,e.transparent=!0;break;case"TransparentCutout":e.transparent=!0}if(e.uniforms.f_BumpScale&&(e.bumpScale=e.uniforms.f_BumpScale.value),e.uniforms.t_BumpMap&&(e.bumpMap=e.uniforms.t_BumpMap.value),e.uniforms.v_EmissionColor&&(e.emissive=e.uniforms.v_EmissionColor.value),e.uniforms.t_EmissionMap&&(e.emissiveMap=e.uniforms.t_EmissionMap.value),e.uniforms.f_CullMode)switch(e.uniforms.f_CullMode.value){case 0:e.side=r.FrontSide;break;case 1:e.side=r.BackSide;break;case 2:e.side=r.DoubleSide}}]]);class _ extends r.ShaderMaterial{constructor(e){super(e),Object.assign(this.uniforms,{v_Color:{value:new r.Vector4(1,0,1,1)}}),this.vertexShader=r.ShaderLib.basic.vertexShader,this.fragmentShader=r.ShaderLib.basic.fragmentShader,v.get("common")(this)}fromMaterialProperty(e){if(this.name=e.name,!g.has(e.shader)||!v.has(e.shader))return;const n=g.get(e.shader),t={},r={};for(const n of Object.keys(e.floatProperties))r["f"+n]={value:e.floatProperties[n]};for(const n of Object.keys(e.keywordMap))t[n]=e.keywordMap[n];for(const n of Object.keys(e.tagMap))this.userData[n]={value:e.tagMap[n]};for(const n of Object.keys(e.textureProperties))r["t"+n]={value:e.textureProperties[n]};for(const n of Object.keys(e.vectorProperties))r["v"+n]={value:e.vectorProperties[n]};Object.assign(this.defines,n.defines),Object.assign(this.defines,t),Object.assign(this.uniforms,n.uniforms),Object.assign(this.uniforms,r),this.vertexShader=n.vertexShader,this.fragmentShader=n.fragmentShader,this.lights=n.lights,v.get("common")(this),v.get(e.shader)(this)}}class M{}class S{}class y{}class x{}class L{}class b{}class T{}var R=function(e,n,t,r){return new(t||(t=Promise))(function(i,a){function s(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?i(e.value):new t(function(n){n(e.value)}).then(s,o)}l((r=r.apply(e,n||[])).next())})};class w{constructor(){this.name="",this.shader="",this.renderQueue=2e3,this.floatProperties={},this.keywordMap={},this.tagMap={},this.textureProperties={},this.vectorProperties={}}fromObject(e,n){return R(this,void 0,void 0,function*(){this.name=e.name,this.shader=e.shader,this.renderQueue=e.renderQueue;for(const n of Object.keys(e.floatProperties))this.floatProperties[n]=Number(e.floatProperties[n]);for(const n of Object.keys(e.keywordMap))this.keywordMap[n]=e.keywordMap[n];for(const n of Object.keys(e.tagMap))this.tagMap[n]=e.tagMap[n];for(const t of Object.keys(e.textureProperties))n?(this.textureProperties[t]=yield n.loadTexture(e.textureProperties[t]),this.textureProperties[t].encoding=r.sRGBEncoding):this.textureProperties[t]=null;for(const n of Object.keys(e.vectorProperties)){const t=e.vectorProperties[n];t.length=4,this.vectorProperties[n]=(new r.Vector4).fromArray(t)}})}}class A{}class E{}class C{}class P{}class D{}var O=function(e,n,t,r){return new(t||(t=Promise))(function(i,a){function s(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?i(e.value):new t(function(n){n(e.value)}).then(s,o)}l((r=r.apply(e,n||[])).next())})};class F{}class I{}class U{constructor(){this.asset=new I,this.scene=new r.Scene,this.parser={},this.userData={},this.materialProperties=[],this.humanoid=new b,this.meta=new A,this.blendShapeMaster=new M,this.firstPerson=new x,this.secondaryAnimation=new E}fromGLTF(e){return O(this,void 0,void 0,function*(){this.asset=e.asset,this.scene=e.scene,this.parser=e.parser,this.userData=e.userData,this.materialProperties=[];for(const n of e.userData.gltfExtensions.VRM.materialProperties){const e=new w;yield e.fromObject(n,this.parser),this.materialProperties.push(e)}return this.humanoid=new b,Object.assign(this.humanoid,e.userData.gltfExtensions.VRM.humanoid),this.meta=new A,Object.assign(this.meta,e.userData.gltfExtensions.VRM.meta),this.blendShapeMaster=new M,Object.assign(this.blendShapeMaster,e.userData.gltfExtensions.VRM.blendShapeMaster),this.firstPerson=new x,Object.assign(this.firstPerson,e.userData.gltfExtensions.VRM.firstPerson),this.secondaryAnimation=new E,Object.assign(this.secondaryAnimation,e.userData.gltfExtensions.VRM.secondaryAnimation),this.scene.traverse(e=>{if(e instanceof r.Mesh)if(Array.isArray(e.material))for(let n=0;n<e.material.length;++n){const t=this.materialProperties.find(t=>t.name===e.material[n].name),r=new _({skinning:!0});r.fromMaterialProperty(t),e.material[n]=r}else{const n=this.materialProperties.find(n=>n.name===e.material.name),t=new _({skinning:!0});t.fromMaterialProperty(n),e.material=t}}),this})}}const G=t(7);class B{constructor(e){this.manager=e||r.DefaultLoadingManager,this.gltfLoader=new G(this.manager)}load(e,n,t,r){this.gltfLoader.load(e,e=>{(new U).fromGLTF(e).then(e=>{n(e)})},t,r)}setCrossOrigin(e){return this.gltfLoader.setCrossOrigin(e),this}setPath(e){return this.gltfLoader.setPath(e),this}setDRACOLoader(e){return this.gltfLoader.setDRACOLoader(e),this}}t.d(n,"GLTF",function(){return F}),t.d(n,"Asset",function(){return I}),t.d(n,"VRM",function(){return U}),t.d(n,"MaterialProperty",function(){return w}),t.d(n,"Humanoid",function(){return b}),t.d(n,"HumanBone",function(){return T}),t.d(n,"Meta",function(){return A}),t.d(n,"BlendShapeMaster",function(){return M}),t.d(n,"BlendShapeGroup",function(){return S}),t.d(n,"BlendShapeBind",function(){return y}),t.d(n,"FirstPerson",function(){return x}),t.d(n,"MeshAnnotation",function(){return L}),t.d(n,"SecondaryAnimation",function(){return E}),t.d(n,"BoneGroup",function(){return C}),t.d(n,"ColliderGroup",function(){return P}),t.d(n,"Collider",function(){return D}),t.d(n,"VRMLoader",function(){return B})}])});
\No newline at end of file