@gui-chat-plugin/avatar 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4956,7 +4956,7 @@ var Na = class {
4956
4956
  let e = [], a = [];
4957
4957
  for (let r = 0; r !== i[t].morphTargets.length; ++r) {
4958
4958
  let r = i[t];
4959
- e.push(r.time), a.push(r.morphTarget === n ? 1 : 0);
4959
+ e.push(r.time), a.push(+(r.morphTarget === n));
4960
4960
  }
4961
4961
  r.push(new Oa(".morphTargetInfluence[" + n + "]", e, a));
4962
4962
  }
@@ -8799,7 +8799,7 @@ function cl() {
8799
8799
  }
8800
8800
  var ll = 0;
8801
8801
  function ul(e, t) {
8802
- return (t.castShadow ? 2 : 0) - (e.castShadow ? 2 : 0) + (t.map ? 1 : 0) - (e.map ? 1 : 0);
8802
+ return (t.castShadow ? 2 : 0) - (e.castShadow ? 2 : 0) + +!!t.map - !!e.map;
8803
8803
  }
8804
8804
  function dl(e) {
8805
8805
  let t = new sl(), n = cl(), r = {
@@ -12344,16 +12344,16 @@ var ku = (e, t, n) => new Promise((r, i) => {
12344
12344
  return this._binds;
12345
12345
  }
12346
12346
  get overrideBlinkAmount() {
12347
- return this.overrideBlink === "block" ? 0 < this.outputWeight ? 1 : 0 : this.overrideBlink === "blend" ? this.outputWeight : 0;
12347
+ return this.overrideBlink === "block" ? +(0 < this.outputWeight) : this.overrideBlink === "blend" ? this.outputWeight : 0;
12348
12348
  }
12349
12349
  get overrideLookAtAmount() {
12350
- return this.overrideLookAt === "block" ? 0 < this.outputWeight ? 1 : 0 : this.overrideLookAt === "blend" ? this.outputWeight : 0;
12350
+ return this.overrideLookAt === "block" ? +(0 < this.outputWeight) : this.overrideLookAt === "blend" ? this.outputWeight : 0;
12351
12351
  }
12352
12352
  get overrideMouthAmount() {
12353
- return this.overrideMouth === "block" ? 0 < this.outputWeight ? 1 : 0 : this.overrideMouth === "blend" ? this.outputWeight : 0;
12353
+ return this.overrideMouth === "block" ? +(0 < this.outputWeight) : this.overrideMouth === "blend" ? this.outputWeight : 0;
12354
12354
  }
12355
12355
  get outputWeight() {
12356
- return this.isBinary ? this.weight > .5 ? 1 : 0 : this.weight;
12356
+ return this.isBinary ? +(this.weight > .5) : this.weight;
12357
12357
  }
12358
12358
  addBind(e) {
12359
12359
  this._binds.push(e);
@@ -13815,7 +13815,7 @@ var mf = class {
13815
13815
  return this.assignTexture(e, t == null ? void 0 : { index: t }, n);
13816
13816
  });
13817
13817
  }
13818
- }, hf = "// #define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n\n#include <common>\n\n// #include <uv_pars_vertex>\n#ifdef MTOON_USE_UV\n varying vec2 vUv;\n\n // COMPAT: pre-r151 uses a common uvTransform\n #if THREE_VRM_THREE_REVISION < 151\n uniform mat3 uvTransform;\n #endif\n#endif\n\n// #include <uv2_pars_vertex>\n// COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n#if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n attribute vec2 uv2;\n varying vec2 vUv2;\n uniform mat3 uv2Transform;\n #endif\n#endif\n\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\n#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE\n uniform sampler2D outlineWidthMultiplyTexture;\n uniform mat3 outlineWidthMultiplyTextureUvTransform;\n#endif\n\nuniform float outlineWidthFactor;\n\nvoid main() {\n\n // #include <uv_vertex>\n #ifdef MTOON_USE_UV\n // COMPAT: pre-r151 uses a common uvTransform\n #if THREE_VRM_THREE_REVISION >= 151\n vUv = uv;\n #else\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #endif\n\n // #include <uv2_vertex>\n // COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n #if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n #endif\n #endif\n\n #include <color_vertex>\n\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n\n // we need this to compute the outline properly\n objectNormal = normalize( objectNormal );\n\n #include <defaultnormal_vertex>\n\n #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #endif\n\n #include <begin_vertex>\n\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 #ifdef OUTLINE\n float worldNormalLength = length( transformedNormal );\n vec3 outlineOffset = outlineWidthFactor * worldNormalLength * objectNormal;\n\n #ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE\n vec2 outlineWidthMultiplyTextureUv = ( outlineWidthMultiplyTextureUvTransform * vec3( vUv, 1 ) ).xy;\n float outlineTex = texture2D( outlineWidthMultiplyTexture, outlineWidthMultiplyTextureUv ).g;\n outlineOffset *= outlineTex;\n #endif\n\n #ifdef OUTLINE_WIDTH_SCREEN\n outlineOffset *= vViewPosition.z / projectionMatrix[ 1 ].y;\n #endif\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 );\n\n gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic\n #endif\n\n #include <worldpos_vertex>\n // #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n\n}", gf = "// #define PHONG\n\nuniform vec3 litFactor;\n\nuniform float opacity;\n\nuniform vec3 shadeColorFactor;\n#ifdef USE_SHADEMULTIPLYTEXTURE\n uniform sampler2D shadeMultiplyTexture;\n uniform mat3 shadeMultiplyTextureUvTransform;\n#endif\n\nuniform float shadingShiftFactor;\nuniform float shadingToonyFactor;\n\n#ifdef USE_SHADINGSHIFTTEXTURE\n uniform sampler2D shadingShiftTexture;\n uniform mat3 shadingShiftTextureUvTransform;\n uniform float shadingShiftTextureScale;\n#endif\n\nuniform float giEqualizationFactor;\n\nuniform vec3 parametricRimColorFactor;\n#ifdef USE_RIMMULTIPLYTEXTURE\n uniform sampler2D rimMultiplyTexture;\n uniform mat3 rimMultiplyTextureUvTransform;\n#endif\nuniform float rimLightingMixFactor;\nuniform float parametricRimFresnelPowerFactor;\nuniform float parametricRimLiftFactor;\n\n#ifdef USE_MATCAPTEXTURE\n uniform vec3 matcapFactor;\n uniform sampler2D matcapTexture;\n uniform mat3 matcapTextureUvTransform;\n#endif\n\nuniform vec3 emissive;\nuniform float emissiveIntensity;\n\nuniform vec3 outlineColorFactor;\nuniform float outlineLightingMixFactor;\n\n#ifdef USE_UVANIMATIONMASKTEXTURE\n uniform sampler2D uvAnimationMaskTexture;\n uniform mat3 uvAnimationMaskTextureUvTransform;\n#endif\n\nuniform float uvAnimationScrollXOffset;\nuniform float uvAnimationScrollYOffset;\nuniform float uvAnimationRotationPhase;\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n\n// #include <uv_pars_fragment>\n#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n varying vec2 vUv;\n#endif\n\n// #include <uv2_pars_fragment>\n// COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n#if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n #endif\n#endif\n\n#include <map_pars_fragment>\n\n#ifdef USE_MAP\n uniform mat3 mapUvTransform;\n#endif\n\n// #include <alphamap_pars_fragment>\n\n#include <alphatest_pars_fragment>\n\n#include <aomap_pars_fragment>\n// #include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapUvTransform;\n#endif\n\n// #include <envmap_common_pars_fragment>\n// #include <envmap_pars_fragment>\n// #include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n\n// #include <bsdfs>\n// COMPAT: pre-r151 doesn't have BRDF_Lambert in <common>\n#if THREE_VRM_THREE_REVISION < 151\n vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n }\n#endif\n\n#include <lights_pars_begin>\n\n#include <normal_pars_fragment>\n\n// #include <lights_phong_pars_fragment>\nvarying vec3 vViewPosition;\n\nstruct MToonMaterial {\n vec3 diffuseColor;\n vec3 shadeColor;\n float shadingShift;\n};\n\nfloat linearstep( float a, float b, float t ) {\n return clamp( ( t - a ) / ( b - a ), 0.0, 1.0 );\n}\n\n/**\n * Convert NdotL into toon shading factor using shadingShift and shadingToony\n */\nfloat getShading(\n const in float dotNL,\n const in float shadow,\n const in float shadingShift\n) {\n float shading = dotNL;\n shading = shading + shadingShift;\n shading = linearstep( -1.0 + shadingToonyFactor, 1.0 - shadingToonyFactor, shading );\n shading *= shadow;\n return shading;\n}\n\n/**\n * Mix diffuseColor and shadeColor using shading factor and light color\n */\nvec3 getDiffuse(\n const in MToonMaterial material,\n const in float shading,\n in vec3 lightColor\n) {\n #ifdef DEBUG_LITSHADERATE\n return vec3( BRDF_Lambert( shading * lightColor ) );\n #endif\n\n vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) );\n\n // The \"comment out if you want to PBR absolutely\" line\n #ifdef V0_COMPAT_SHADE\n col = min( col, material.diffuseColor );\n #endif\n\n return col;\n}\n\n// COMPAT: pre-r156 uses a struct GeometricContext\n#if THREE_VRM_THREE_REVISION >= 157\n void RE_Direct_MToon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {\n float dotNL = clamp( dot( geometryNormal, directLight.direction ), -1.0, 1.0 );\n vec3 irradiance = directLight.color;\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n\n irradiance *= dotNL;\n\n float shading = getShading( dotNL, shadow, material.shadingShift );\n\n // toon shaded diffuse\n reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );\n }\n\n void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {\n // indirect diffuse will use diffuseColor, no shadeColor involved\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n }\n#else\n void RE_Direct_MToon( const in IncidentLight directLight, const in GeometricContext geometry, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {\n float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 );\n vec3 irradiance = directLight.color;\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n\n irradiance *= dotNL;\n\n float shading = getShading( dotNL, shadow, material.shadingShift );\n\n // toon shaded diffuse\n reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );\n }\n\n void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in GeometricContext geometry, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {\n // indirect diffuse will use diffuseColor, no shadeColor involved\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n }\n#endif\n\n#define RE_Direct RE_Direct_MToon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_MToon\n#define Material_LightProbeLOD( material ) (0)\n\n#include <shadowmap_pars_fragment>\n// #include <bumpmap_pars_fragment>\n\n// #include <normalmap_pars_fragment>\n#ifdef USE_NORMALMAP\n\n uniform sampler2D normalMap;\n uniform mat3 normalMapUvTransform;\n uniform vec2 normalScale;\n\n#endif\n\n// COMPAT: pre-r151\n// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151\n#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )\n\n uniform mat3 normalMatrix;\n\n#endif\n\n// COMPAT: pre-r151\n// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) )\n\n // Per-Pixel Tangent Space Normal Mapping\n // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n // three-vrm specific change: it requires `uv` as an input in order to support uv scrolls\n\n // Temporary compat against shader change @ Three.js r126, r151\n #if THREE_VRM_THREE_REVISION >= 151\n\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n\n vec3 N = surf_norm;\n\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\n return mat3( T * scale, B * scale, N );\n\n }\n\n #else\n\n vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n\n vec3 N = normalize( surf_norm );\n\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n\n // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0\n // TODO: Is this still required? Or shall I make a PR about it?\n if ( length( T ) == 0.0 || length( B ) == 0.0 ) {\n return surf_norm;\n }\n\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\n return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\n }\n\n #endif\n\n#endif\n\n// #include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\n// == post correction ==========================================================\nvoid postCorrection() {\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}\n\n// == main procedure ===========================================================\nvoid main() {\n #include <clipping_planes_fragment>\n\n vec2 uv = vec2(0.5, 0.5);\n\n #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n uv = vUv;\n\n float uvAnimMask = 1.0;\n #ifdef USE_UVANIMATIONMASKTEXTURE\n vec2 uvAnimationMaskTextureUv = ( uvAnimationMaskTextureUvTransform * vec3( uv, 1 ) ).xy;\n uvAnimMask = texture2D( uvAnimationMaskTexture, uvAnimationMaskTextureUv ).b;\n #endif\n\n float uvRotCos = cos( uvAnimationRotationPhase * uvAnimMask );\n float uvRotSin = sin( uvAnimationRotationPhase * uvAnimMask );\n uv = mat2( uvRotCos, -uvRotSin, uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5;\n uv = uv + vec2( uvAnimationScrollXOffset, uvAnimationScrollYOffset ) * uvAnimMask;\n #endif\n\n #ifdef DEBUG_UV\n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n gl_FragColor = vec4( uv, 0.0, 1.0 );\n #endif\n return;\n #endif\n\n vec4 diffuseColor = vec4( litFactor, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive * emissiveIntensity;\n\n #include <logdepthbuf_fragment>\n\n // #include <map_fragment>\n #ifdef USE_MAP\n vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy;\n vec4 sampledDiffuseColor = texture2D( map, mapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n #endif\n diffuseColor *= sampledDiffuseColor;\n #endif\n\n // #include <color_fragment>\n #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )\n diffuseColor.rgb *= vColor;\n #endif\n\n // #include <alphamap_fragment>\n\n #include <alphatest_fragment>\n\n // #include <specularmap_fragment>\n\n // #include <normal_fragment_begin>\n float faceDirection = gl_FrontFacing ? 1.0 : -1.0;\n\n #ifdef FLAT_SHADED\n\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n\n #else\n\n vec3 normal = normalize( vNormal );\n\n #ifdef DOUBLE_SIDED\n\n normal *= faceDirection;\n\n #endif\n\n #endif\n\n #ifdef USE_NORMALMAP\n\n vec2 normalMapUv = ( normalMapUvTransform * vec3( uv, 1 ) ).xy;\n\n #endif\n\n #ifdef USE_NORMALMAP_TANGENTSPACE\n\n #ifdef USE_TANGENT\n\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\n #else\n\n mat3 tbn = getTangentFrame( - vViewPosition, normal, normalMapUv );\n\n #endif\n\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n\n #endif\n\n #endif\n\n #ifdef USE_CLEARCOAT_NORMALMAP\n\n #ifdef USE_TANGENT\n\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\n #else\n\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\n #endif\n\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n\n #endif\n\n #endif\n\n // non perturbed normal for clearcoat among others\n\n vec3 nonPerturbedNormal = normal;\n\n #ifdef OUTLINE\n normal *= -1.0;\n #endif\n\n // #include <normal_fragment_maps>\n\n // COMPAT: pre-r151\n // USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151\n #if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )\n\n normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n #ifdef FLIP_SIDED\n\n normal = - normal;\n\n #endif\n\n #ifdef DOUBLE_SIDED\n\n normal = normal * faceDirection;\n\n #endif\n\n normal = normalize( normalMatrix * normal );\n\n // COMPAT: pre-r151\n // USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151\n #elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP )\n\n vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n\n // COMPAT: pre-r151\n #if THREE_VRM_THREE_REVISION >= 151 || defined( USE_TANGENT )\n\n normal = normalize( tbn * mapN );\n\n #else\n\n normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection );\n\n #endif\n\n #endif\n\n // #include <emissivemap_fragment>\n #ifdef USE_EMISSIVEMAP\n vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy;\n totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb;\n #endif\n\n #ifdef DEBUG_NORMAL\n gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 );\n return;\n #endif\n\n // -- MToon: lighting --------------------------------------------------------\n // accumulation\n // #include <lights_phong_fragment>\n MToonMaterial material;\n\n material.diffuseColor = diffuseColor.rgb;\n\n material.shadeColor = shadeColorFactor;\n #ifdef USE_SHADEMULTIPLYTEXTURE\n vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;\n material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb;\n #endif\n\n #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )\n material.shadeColor.rgb *= vColor;\n #endif\n\n material.shadingShift = shadingShiftFactor;\n #ifdef USE_SHADINGSHIFTTEXTURE\n vec2 shadingShiftTextureUv = ( shadingShiftTextureUvTransform * vec3( uv, 1 ) ).xy;\n material.shadingShift += texture2D( shadingShiftTexture, shadingShiftTextureUv ).r * shadingShiftTextureScale;\n #endif\n\n // #include <lights_fragment_begin>\n\n // MToon Specific changes:\n // Since we want to take shadows into account of shading instead of irradiance,\n // we had to modify the codes that multiplies the results of shadowmap into color of direct lights.\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n vec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 geometryClearcoatNormal;\n\n #ifdef USE_CLEARCOAT\n\n geometryClearcoatNormal = clearcoatNormal;\n\n #endif\n #else\n GeometricContext geometry;\n\n geometry.position = - vViewPosition;\n geometry.normal = normal;\n geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n #ifdef USE_CLEARCOAT\n\n geometry.clearcoatNormal = clearcoatNormal;\n\n #endif\n #endif\n\n IncidentLight directLight;\n\n // since these variables will be used in unrolled loop, we have to define in prior\n float shadow;\n\n #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n pointLight = pointLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #else\n getPointLightInfo( pointLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n // COMPAT: pre-r166\n // r166 introduced shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #else\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n SpotLight spotLight;\n // COMPAT: pre-r144 uses NUM_SPOT_LIGHT_SHADOWS, r144+ uses NUM_SPOT_LIGHT_COORDS\n #if THREE_VRM_THREE_REVISION >= 144\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_COORDS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #elif defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n spotLight = spotLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #else\n getSpotLightInfo( spotLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n // COMPAT: pre-r144 uses NUM_SPOT_LIGHT_SHADOWS and vSpotShadowCoord, r144+ uses NUM_SPOT_LIGHT_COORDS and vSpotLightCoord\n // COMPAT: pre-r166 does not have shadowIntensity, r166+ has shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_COORDS )\n spotLightShadow = spotLightShadows[ i ];\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n #elif THREE_VRM_THREE_REVISION >= 144\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_COORDS )\n spotLightShadow = spotLightShadows[ i ];\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getDirectionalLightInfo( directionalLight, directLight );\n #else\n getDirectionalLightInfo( directionalLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n // COMPAT: pre-r166\n // r166 introduced shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #else\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n // #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n // RectAreaLight rectAreaLight;\n\n // #pragma unroll_loop_start\n // for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n // rectAreaLight = rectAreaLights[ i ];\n // RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n // }\n // #pragma unroll_loop_end\n\n // #endif\n\n #if defined( RE_IndirectDiffuse )\n\n vec3 iblIrradiance = vec3( 0.0 );\n\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n // COMPAT: pre-r156 doesn't have a define USE_LIGHT_PROBES\n #if THREE_VRM_THREE_REVISION >= 157\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #else\n irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n #endif\n\n #if ( NUM_HEMI_LIGHTS > 0 )\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n #else\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #endif\n\n // #if defined( RE_IndirectSpecular )\n\n // vec3 radiance = vec3( 0.0 );\n // vec3 clearcoatRadiance = vec3( 0.0 );\n\n // #endif\n\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n\n // modulation\n #include <aomap_fragment>\n\n vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\n #ifdef DEBUG_LITSHADERATE\n gl_FragColor = vec4( col, diffuseColor.a );\n postCorrection();\n return;\n #endif\n\n // -- MToon: rim lighting -----------------------------------------\n vec3 viewDir = normalize( vViewPosition );\n\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n reflectedLight.directSpecular /= PI;\n #endif\n vec3 rimMix = mix( vec3( 1.0 ), reflectedLight.directSpecular, 1.0 );\n\n vec3 rim = parametricRimColorFactor * pow( saturate( 1.0 - dot( viewDir, normal ) + parametricRimLiftFactor ), parametricRimFresnelPowerFactor );\n\n #ifdef USE_MATCAPTEXTURE\n {\n vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) );\n vec3 y = cross( viewDir, x ); // guaranteed to be normalized\n vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) );\n sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy;\n vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb;\n rim += matcapFactor * matcap;\n }\n #endif\n\n #ifdef USE_RIMMULTIPLYTEXTURE\n vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;\n rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb;\n #endif\n\n col += rimMix * rim;\n\n // -- MToon: Emission --------------------------------------------------------\n col += totalEmissiveRadiance;\n\n // #include <envmap_fragment>\n\n // -- Almost done! -----------------------------------------------------------\n #if defined( OUTLINE )\n col = outlineColorFactor.rgb * mix( vec3( 1.0 ), col, outlineLightingMixFactor );\n #endif\n\n #ifdef OPAQUE\n diffuseColor.a = 1.0;\n #endif\n\n gl_FragColor = vec4( col, diffuseColor.a );\n postCorrection();\n}\n", _f = {
13818
+ }, hf = "// #define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n\n#include <common>\n\n// #include <uv_pars_vertex>\n#ifdef MTOON_USE_UV\n varying vec2 vUv;\n\n // COMPAT: pre-r151 uses a common uvTransform\n #if THREE_VRM_THREE_REVISION < 151\n uniform mat3 uvTransform;\n #endif\n#endif\n\n// #include <uv2_pars_vertex>\n// COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n#if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n attribute vec2 uv2;\n varying vec2 vUv2;\n uniform mat3 uv2Transform;\n #endif\n#endif\n\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\n#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE\n uniform sampler2D outlineWidthMultiplyTexture;\n uniform mat3 outlineWidthMultiplyTextureUvTransform;\n#endif\n\nuniform float outlineWidthFactor;\n\nvoid main() {\n\n // #include <uv_vertex>\n #ifdef MTOON_USE_UV\n // COMPAT: pre-r151 uses a common uvTransform\n #if THREE_VRM_THREE_REVISION >= 151\n vUv = uv;\n #else\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #endif\n\n // #include <uv2_vertex>\n // COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n #if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n #endif\n #endif\n\n #include <color_vertex>\n\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n\n // we need this to compute the outline properly\n objectNormal = normalize( objectNormal );\n\n #include <defaultnormal_vertex>\n\n #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #endif\n\n #include <begin_vertex>\n\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 #ifdef OUTLINE\n float worldNormalLength = length( transformedNormal );\n vec3 outlineOffset = outlineWidthFactor * worldNormalLength * objectNormal;\n\n #ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE\n vec2 outlineWidthMultiplyTextureUv = ( outlineWidthMultiplyTextureUvTransform * vec3( vUv, 1 ) ).xy;\n float outlineTex = texture2D( outlineWidthMultiplyTexture, outlineWidthMultiplyTextureUv ).g;\n outlineOffset *= outlineTex;\n #endif\n\n #ifdef OUTLINE_WIDTH_SCREEN\n outlineOffset *= vViewPosition.z / projectionMatrix[ 1 ].y;\n #endif\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 );\n\n gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic\n #endif\n\n #include <worldpos_vertex>\n // #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n\n}", gf = "// #define PHONG\n\nuniform vec3 litFactor;\n\nuniform float opacity;\n\nuniform vec3 shadeColorFactor;\n#ifdef USE_SHADEMULTIPLYTEXTURE\n uniform sampler2D shadeMultiplyTexture;\n uniform mat3 shadeMultiplyTextureUvTransform;\n#endif\n\nuniform float shadingShiftFactor;\nuniform float shadingToonyFactor;\n\n#ifdef USE_SHADINGSHIFTTEXTURE\n uniform sampler2D shadingShiftTexture;\n uniform mat3 shadingShiftTextureUvTransform;\n uniform float shadingShiftTextureScale;\n#endif\n\nuniform float giEqualizationFactor;\n\nuniform vec3 parametricRimColorFactor;\n#ifdef USE_RIMMULTIPLYTEXTURE\n uniform sampler2D rimMultiplyTexture;\n uniform mat3 rimMultiplyTextureUvTransform;\n#endif\nuniform float rimLightingMixFactor;\nuniform float parametricRimFresnelPowerFactor;\nuniform float parametricRimLiftFactor;\n\n#ifdef USE_MATCAPTEXTURE\n uniform vec3 matcapFactor;\n uniform sampler2D matcapTexture;\n uniform mat3 matcapTextureUvTransform;\n#endif\n\nuniform vec3 emissive;\nuniform float emissiveIntensity;\n\nuniform vec3 outlineColorFactor;\nuniform float outlineLightingMixFactor;\n\n#ifdef USE_UVANIMATIONMASKTEXTURE\n uniform sampler2D uvAnimationMaskTexture;\n uniform mat3 uvAnimationMaskTextureUvTransform;\n#endif\n\nuniform float uvAnimationScrollXOffset;\nuniform float uvAnimationScrollYOffset;\nuniform float uvAnimationRotationPhase;\n\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n\n// #include <uv_pars_fragment>\n#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n varying vec2 vUv;\n#endif\n\n// #include <uv2_pars_fragment>\n// COMAPT: pre-r151 uses uv2 for lightMap and aoMap\n#if THREE_VRM_THREE_REVISION < 151\n #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n #endif\n#endif\n\n#include <map_pars_fragment>\n\n#ifdef USE_MAP\n uniform mat3 mapUvTransform;\n#endif\n\n// #include <alphamap_pars_fragment>\n\n#include <alphatest_pars_fragment>\n\n#include <aomap_pars_fragment>\n// #include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapUvTransform;\n#endif\n\n// #include <envmap_common_pars_fragment>\n// #include <envmap_pars_fragment>\n// #include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n\n// #include <bsdfs>\n// COMPAT: pre-r151 doesn't have BRDF_Lambert in <common>\n#if THREE_VRM_THREE_REVISION < 151\n vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n }\n#endif\n\n#include <lights_pars_begin>\n\n#include <normal_pars_fragment>\n\n// #include <lights_phong_pars_fragment>\nvarying vec3 vViewPosition;\n\nstruct MToonMaterial {\n vec3 diffuseColor;\n vec3 shadeColor;\n float shadingShift;\n};\n\nfloat linearstep( float a, float b, float t ) {\n return clamp( ( t - a ) / ( b - a ), 0.0, 1.0 );\n}\n\n/**\n * Convert NdotL into toon shading factor using shadingShift and shadingToony\n */\nfloat getShading(\n const in float dotNL,\n const in float shadow,\n const in float shadingShift\n) {\n float shading = dotNL;\n shading = shading + shadingShift;\n shading = linearstep( -1.0 + shadingToonyFactor, 1.0 - shadingToonyFactor, shading );\n shading *= shadow;\n return shading;\n}\n\n/**\n * Mix diffuseColor and shadeColor using shading factor and light color\n */\nvec3 getDiffuse(\n const in MToonMaterial material,\n const in float shading,\n in vec3 lightColor\n) {\n #ifdef DEBUG_LITSHADERATE\n return vec3( BRDF_Lambert( shading * lightColor ) );\n #endif\n\n vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) );\n\n // The \"comment out if you want to PBR absolutely\" line\n #ifdef V0_COMPAT_SHADE\n col = min( col, material.diffuseColor );\n #endif\n\n return col;\n}\n\n// COMPAT: pre-r156 uses a struct GeometricContext\n#if THREE_VRM_THREE_REVISION >= 157\n void RE_Direct_MToon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {\n float dotNL = clamp( dot( geometryNormal, directLight.direction ), -1.0, 1.0 );\n vec3 irradiance = directLight.color;\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n\n irradiance *= dotNL;\n\n float shading = getShading( dotNL, shadow, material.shadingShift );\n\n // toon shaded diffuse\n reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );\n }\n\n void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {\n // indirect diffuse will use diffuseColor, no shadeColor involved\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n }\n#else\n void RE_Direct_MToon( const in IncidentLight directLight, const in GeometricContext geometry, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {\n float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 );\n vec3 irradiance = directLight.color;\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n\n irradiance *= dotNL;\n\n float shading = getShading( dotNL, shadow, material.shadingShift );\n\n // toon shaded diffuse\n reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );\n }\n\n void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in GeometricContext geometry, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {\n // indirect diffuse will use diffuseColor, no shadeColor involved\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\n // directSpecular will be used for rim lighting, not an actual specular\n reflectedLight.directSpecular += irradiance;\n }\n#endif\n\n#define RE_Direct RE_Direct_MToon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_MToon\n#define Material_LightProbeLOD( material ) (0)\n\n#include <shadowmap_pars_fragment>\n// #include <bumpmap_pars_fragment>\n\n// #include <normalmap_pars_fragment>\n#ifdef USE_NORMALMAP\n\n uniform sampler2D normalMap;\n uniform mat3 normalMapUvTransform;\n uniform vec2 normalScale;\n\n#endif\n\n// COMPAT: pre-r151\n// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151\n#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )\n\n uniform mat3 normalMatrix;\n\n#endif\n\n// COMPAT: pre-r151\n// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) )\n\n // Per-Pixel Tangent Space Normal Mapping\n // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n // three-vrm specific change: it requires `uv` as an input in order to support uv scrolls\n\n // Temporary compat against shader change @ Three.js r126, r151\n #if THREE_VRM_THREE_REVISION >= 151\n\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n\n vec3 N = surf_norm;\n\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\n return mat3( T * scale, B * scale, N );\n\n }\n\n #else\n\n vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\n vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n\n vec3 N = normalize( surf_norm );\n\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n\n // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0\n // TODO: Is this still required? Or shall I make a PR about it?\n if ( length( T ) == 0.0 || length( B ) == 0.0 ) {\n return surf_norm;\n }\n\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\n return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\n }\n\n #endif\n\n#endif\n\n// #include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\n// == post correction ==========================================================\nvoid postCorrection() {\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}\n\n// == main procedure ===========================================================\nvoid main() {\n #include <clipping_planes_fragment>\n\n vec2 uv = vec2(0.5, 0.5);\n\n #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n uv = vUv;\n\n float uvAnimMask = 1.0;\n #ifdef USE_UVANIMATIONMASKTEXTURE\n vec2 uvAnimationMaskTextureUv = ( uvAnimationMaskTextureUvTransform * vec3( uv, 1 ) ).xy;\n uvAnimMask = texture2D( uvAnimationMaskTexture, uvAnimationMaskTextureUv ).b;\n #endif\n\n float uvRotCos = cos( uvAnimationRotationPhase * uvAnimMask );\n float uvRotSin = sin( uvAnimationRotationPhase * uvAnimMask );\n uv = mat2( uvRotCos, -uvRotSin, uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5;\n uv = uv + vec2( uvAnimationScrollXOffset, uvAnimationScrollYOffset ) * uvAnimMask;\n #endif\n\n #ifdef DEBUG_UV\n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )\n gl_FragColor = vec4( uv, 0.0, 1.0 );\n #endif\n return;\n #endif\n\n vec4 diffuseColor = vec4( litFactor, opacity );\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive * emissiveIntensity;\n\n #include <logdepthbuf_fragment>\n\n // #include <map_fragment>\n #ifdef USE_MAP\n vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy;\n vec4 sampledDiffuseColor = texture2D( map, mapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n #endif\n diffuseColor *= sampledDiffuseColor;\n #endif\n\n // #include <color_fragment>\n #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )\n diffuseColor.rgb *= vColor;\n #endif\n\n // #include <alphamap_fragment>\n\n #include <alphatest_fragment>\n\n // #include <specularmap_fragment>\n\n // #include <normal_fragment_begin>\n float faceDirection = gl_FrontFacing ? 1.0 : -1.0;\n\n #ifdef FLAT_SHADED\n\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n\n #else\n\n vec3 normal = normalize( vNormal );\n\n #ifdef DOUBLE_SIDED\n\n normal *= faceDirection;\n\n #endif\n\n #endif\n\n #ifdef USE_NORMALMAP\n\n vec2 normalMapUv = ( normalMapUvTransform * vec3( uv, 1 ) ).xy;\n\n #endif\n\n #ifdef USE_NORMALMAP_TANGENTSPACE\n\n #ifdef USE_TANGENT\n\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\n #else\n\n mat3 tbn = getTangentFrame( - vViewPosition, normal, normalMapUv );\n\n #endif\n\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n\n #endif\n\n #endif\n\n #ifdef USE_CLEARCOAT_NORMALMAP\n\n #ifdef USE_TANGENT\n\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\n #else\n\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\n #endif\n\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n\n #endif\n\n #endif\n\n // non perturbed normal for clearcoat among others\n\n vec3 nonPerturbedNormal = normal;\n\n #ifdef OUTLINE\n normal *= -1.0;\n #endif\n\n // #include <normal_fragment_maps>\n\n // COMPAT: pre-r151\n // USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151\n #if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )\n\n normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n #ifdef FLIP_SIDED\n\n normal = - normal;\n\n #endif\n\n #ifdef DOUBLE_SIDED\n\n normal = normal * faceDirection;\n\n #endif\n\n normal = normalize( normalMatrix * normal );\n\n // COMPAT: pre-r151\n // USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151\n #elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP )\n\n vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n\n // COMPAT: pre-r151\n #if THREE_VRM_THREE_REVISION >= 151 || defined( USE_TANGENT )\n\n normal = normalize( tbn * mapN );\n\n #else\n\n normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection );\n\n #endif\n\n #endif\n\n // #include <emissivemap_fragment>\n #ifdef USE_EMISSIVEMAP\n vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy;\n totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb;\n #endif\n\n #ifdef DEBUG_NORMAL\n gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 );\n return;\n #endif\n\n // -- MToon: lighting --------------------------------------------------------\n // accumulation\n // #include <lights_phong_fragment>\n MToonMaterial material;\n\n material.diffuseColor = diffuseColor.rgb;\n\n material.shadeColor = shadeColorFactor;\n #ifdef USE_SHADEMULTIPLYTEXTURE\n vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;\n material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb;\n #endif\n\n #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )\n material.shadeColor.rgb *= vColor;\n #endif\n\n material.shadingShift = shadingShiftFactor;\n #ifdef USE_SHADINGSHIFTTEXTURE\n vec2 shadingShiftTextureUv = ( shadingShiftTextureUvTransform * vec3( uv, 1 ) ).xy;\n material.shadingShift += texture2D( shadingShiftTexture, shadingShiftTextureUv ).r * shadingShiftTextureScale;\n #endif\n\n // #include <lights_fragment_begin>\n\n // MToon Specific changes:\n // Since we want to take shadows into account of shading instead of irradiance,\n // we had to modify the codes that multiplies the results of shadowmap into color of direct lights.\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n vec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 geometryClearcoatNormal;\n\n #ifdef USE_CLEARCOAT\n\n geometryClearcoatNormal = clearcoatNormal;\n\n #endif\n #else\n GeometricContext geometry;\n\n geometry.position = - vViewPosition;\n geometry.normal = normal;\n geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n #ifdef USE_CLEARCOAT\n\n geometry.clearcoatNormal = clearcoatNormal;\n\n #endif\n #endif\n\n IncidentLight directLight;\n\n // since these variables will be used in unrolled loop, we have to define in prior\n float shadow;\n\n #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n pointLight = pointLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #else\n getPointLightInfo( pointLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n // COMPAT: pre-r166\n // r166 introduced shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #else\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n SpotLight spotLight;\n // COMPAT: pre-r144 uses NUM_SPOT_LIGHT_SHADOWS, r144+ uses NUM_SPOT_LIGHT_COORDS\n #if THREE_VRM_THREE_REVISION >= 144\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_COORDS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #elif defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n spotLight = spotLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #else\n getSpotLightInfo( spotLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n // COMPAT: pre-r144 uses NUM_SPOT_LIGHT_SHADOWS and vSpotShadowCoord, r144+ uses NUM_SPOT_LIGHT_COORDS and vSpotLightCoord\n // COMPAT: pre-r166 does not have shadowIntensity, r166+ has shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_COORDS )\n spotLightShadow = spotLightShadows[ i ];\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n #elif THREE_VRM_THREE_REVISION >= 144\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_COORDS )\n spotLightShadow = spotLightShadows[ i ];\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n getDirectionalLightInfo( directionalLight, directLight );\n #else\n getDirectionalLightInfo( directionalLight, geometry, directLight );\n #endif\n\n shadow = 1.0;\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n // COMPAT: pre-r166\n // r166 introduced shadowIntensity\n #if THREE_VRM_THREE_REVISION >= 166\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #else\n shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n #endif\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );\n #else\n RE_Direct( directLight, geometry, material, shadow, reflectedLight );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n // #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n // RectAreaLight rectAreaLight;\n\n // #pragma unroll_loop_start\n // for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n // rectAreaLight = rectAreaLights[ i ];\n // RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n // }\n // #pragma unroll_loop_end\n\n // #endif\n\n #if defined( RE_IndirectDiffuse )\n\n vec3 iblIrradiance = vec3( 0.0 );\n\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n // COMPAT: pre-r156 doesn't have a define USE_LIGHT_PROBES\n #if THREE_VRM_THREE_REVISION >= 157\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #else\n irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n #endif\n\n #if ( NUM_HEMI_LIGHTS > 0 )\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n // COMPAT: pre-r156 uses a struct GeometricContext\n #if THREE_VRM_THREE_REVISION >= 157\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n #else\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n #endif\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n #endif\n\n // #if defined( RE_IndirectSpecular )\n\n // vec3 radiance = vec3( 0.0 );\n // vec3 clearcoatRadiance = vec3( 0.0 );\n\n // #endif\n\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n\n // modulation\n #include <aomap_fragment>\n\n vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\n #ifdef DEBUG_LITSHADERATE\n gl_FragColor = vec4( col, diffuseColor.a );\n postCorrection();\n return;\n #endif\n\n // -- MToon: rim lighting -----------------------------------------\n vec3 viewDir = normalize( vViewPosition );\n\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n reflectedLight.directSpecular /= PI;\n #endif\n vec3 rimMix = mix( vec3( 1.0 ), reflectedLight.directSpecular, rimLightingMixFactor );\n\n vec3 rim = parametricRimColorFactor * pow( saturate( 1.0 - dot( viewDir, normal ) + parametricRimLiftFactor ), parametricRimFresnelPowerFactor );\n\n #ifdef USE_MATCAPTEXTURE\n {\n vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) );\n vec3 y = cross( viewDir, x ); // guaranteed to be normalized\n vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) );\n sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy;\n vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb;\n rim += matcapFactor * matcap;\n }\n #endif\n\n #ifdef USE_RIMMULTIPLYTEXTURE\n vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;\n rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb;\n #endif\n\n col += rimMix * rim;\n\n // -- MToon: Emission --------------------------------------------------------\n col += totalEmissiveRadiance;\n\n // #include <envmap_fragment>\n\n // -- Almost done! -----------------------------------------------------------\n #if defined( OUTLINE )\n col = outlineColorFactor.rgb * mix( vec3( 1.0 ), col, outlineLightingMixFactor );\n #endif\n\n #ifdef OPAQUE\n diffuseColor.a = 1.0;\n #endif\n\n gl_FragColor = vec4( col, diffuseColor.a );\n postCorrection();\n}\n", _f = {
13819
13819
  None: "none",
13820
13820
  Normal: "normal",
13821
13821
  LitShadeRate: "litShadeRate",
@@ -14618,7 +14618,7 @@ var np = class {
14618
14618
  return this._rollAxis;
14619
14619
  }
14620
14620
  set rollAxis(e) {
14621
- this._rollAxis = e, this._v3RollAxis.set(e === "X" ? 1 : 0, e === "Y" ? 1 : 0, e === "Z" ? 1 : 0);
14621
+ this._rollAxis = e, this._v3RollAxis.set(+(e === "X"), +(e === "Y"), +(e === "Z"));
14622
14622
  }
14623
14623
  get dependencies() {
14624
14624
  return /* @__PURE__ */ new Set([this.source]);
@@ -15572,7 +15572,120 @@ function _m(e, t) {
15572
15572
  e.bind(l, new q());
15573
15573
  }
15574
15574
  }
15575
- function vm(e) {
15575
+ function vm(e, t) {
15576
+ let n = e.position.count, r = Array(n), i = 0, a = t.array;
15577
+ for (let e = 0; e < a.length; e++) {
15578
+ let t = a[e];
15579
+ r[t] || (r[t] = !0, i++);
15580
+ }
15581
+ return {
15582
+ isVertexUsed: r,
15583
+ vertexCount: n,
15584
+ verticesUsed: i
15585
+ };
15586
+ }
15587
+ function ym(e) {
15588
+ let t = [], n = [], r = 0;
15589
+ for (let i = 0; i < e.length; i++) if (e[i]) {
15590
+ let e = r++;
15591
+ t[i] = e, n[e] = i;
15592
+ }
15593
+ return {
15594
+ originalIndexNewIndexMap: t,
15595
+ newIndexOriginalIndexMap: n
15596
+ };
15597
+ }
15598
+ function bm(e, t) {
15599
+ t.name = e.name, t.morphTargetsRelative = e.morphTargetsRelative, e.groups.forEach((e) => {
15600
+ t.addGroup(e.start, e.count, e.materialIndex);
15601
+ }), t.boundingBox = e.boundingBox?.clone() ?? null, t.boundingSphere = e.boundingSphere?.clone() ?? null, t.setDrawRange(e.drawRange.start, e.drawRange.count), t.userData = e.userData;
15602
+ }
15603
+ function xm(e, t, n) {
15604
+ let r = t.array, i = new r.constructor(r.length);
15605
+ for (let e = 0; e < r.length; e++) i[e] = n[r[e]];
15606
+ e.setIndex(new Y(i, t.itemSize, t.normalized));
15607
+ }
15608
+ function Sm(e, t, n) {
15609
+ let r = e.constructor, i = new r(t.length * n), a = !0;
15610
+ for (let r = 0; r < t.length; r++) {
15611
+ let o = t[r] * n, s = r * n;
15612
+ for (let t = 0; t < n; t++) {
15613
+ let n = e[o + t];
15614
+ i[s + t] = n, a &&= n === 0;
15615
+ }
15616
+ }
15617
+ return [i, a];
15618
+ }
15619
+ function Cm(e) {
15620
+ let t = /* @__PURE__ */ new Map(), n = [];
15621
+ for (let [r, i] of Object.entries(e)) if (i.isInterleavedBufferAttribute) {
15622
+ let e = i, n = e.data, a = t.get(n) ?? [];
15623
+ t.set(n, a), a.push([r, e]);
15624
+ } else {
15625
+ let e = i;
15626
+ n.push([r, e]);
15627
+ }
15628
+ return [t, n];
15629
+ }
15630
+ function wm(e, t, n) {
15631
+ let [r, i] = Cm(t);
15632
+ for (let [t, i] of r) {
15633
+ let r = t.array, { stride: a } = t, [o, s] = Sm(r, n, a), c = new li(o, a);
15634
+ c.setUsage(t.usage);
15635
+ for (let [t, n] of i) {
15636
+ let { itemSize: r, offset: i, normalized: a } = n, o = new di(c, r, i, a);
15637
+ e.setAttribute(t, o);
15638
+ }
15639
+ }
15640
+ for (let [t, r] of i) {
15641
+ let i = r.array, { itemSize: a, normalized: o } = r, [s, c] = Sm(i, n, a);
15642
+ e.setAttribute(t, new Y(s, a, o));
15643
+ }
15644
+ }
15645
+ function Tm(e) {
15646
+ let t = /* @__PURE__ */ new Map(), n = [];
15647
+ for (let [r, i] of Object.entries(e)) {
15648
+ let e = r;
15649
+ for (let r = 0; r < i.length; r++) {
15650
+ let a = i[r];
15651
+ if (a.isInterleavedBufferAttribute) {
15652
+ let n = a, i = n.data, o = t.get(i) ?? [];
15653
+ t.set(i, o), o.push([
15654
+ e,
15655
+ r,
15656
+ n
15657
+ ]);
15658
+ } else {
15659
+ let t = a;
15660
+ n.push([
15661
+ e,
15662
+ r,
15663
+ t
15664
+ ]);
15665
+ }
15666
+ }
15667
+ }
15668
+ return [t, n];
15669
+ }
15670
+ function Em(e, t, n) {
15671
+ let r = !0, [i, a] = Tm(t), o = {};
15672
+ for (let [e, t] of i) {
15673
+ let i = e.array, { stride: a } = e, [s, c] = Sm(i, n, a);
15674
+ r &&= c;
15675
+ let l = new li(s, a);
15676
+ l.setUsage(e.usage);
15677
+ for (let [e, n, r] of t) {
15678
+ let { itemSize: t, offset: i, normalized: a } = r, s = new di(l, t, i, a);
15679
+ o[e] ?? (o[e] = []), o[e][n] = s;
15680
+ }
15681
+ }
15682
+ for (let [e, t, i] of a) {
15683
+ let a = i, s = a.array, { itemSize: c, normalized: l } = a, [u, d] = Sm(s, n, c);
15684
+ r &&= d, o[e] ?? (o[e] = []), o[e][t] = new Y(u, c, l);
15685
+ }
15686
+ e.morphAttributes = r ? {} : o;
15687
+ }
15688
+ function Dm(e) {
15576
15689
  let t = /* @__PURE__ */ new Map();
15577
15690
  e.traverse((e) => {
15578
15691
  if (!e.isMesh) return;
@@ -15583,58 +15696,20 @@ function vm(e) {
15583
15696
  n.geometry = a;
15584
15697
  return;
15585
15698
  }
15586
- let o = Object.values(r.attributes)[0].count, s = Array(o), c = 0, l = i.array;
15587
- for (let e = 0; e < l.length; e++) {
15588
- let t = l[e];
15589
- s[t] || (s[t] = !0, c++);
15590
- }
15591
- if (c === o) return;
15592
- let u = [], d = [], f = 0;
15593
- for (let e = 0; e < s.length; e++) if (s[e]) {
15594
- let t = f++;
15595
- u[e] = t, d[t] = e;
15596
- }
15597
- let p = new Tr();
15598
- p.name = r.name, p.morphTargetsRelative = r.morphTargetsRelative, r.groups.forEach((e) => {
15599
- p.addGroup(e.start, e.count, e.materialIndex);
15600
- }), p.boundingBox = r.boundingBox?.clone() ?? null, p.boundingSphere = r.boundingSphere?.clone() ?? null, p.setDrawRange(r.drawRange.start, r.drawRange.count), p.userData = r.userData, t.set(r, p);
15601
- {
15602
- let e = i.array, t = new e.constructor(e.length);
15603
- for (let n = 0; n < e.length; n++) t[n] = u[e[n]];
15604
- p.setIndex(new Y(t, 1, !1));
15605
- }
15606
- Object.keys(r.attributes).forEach((e) => {
15607
- let t = r.attributes[e];
15608
- if (t.isInterleavedBufferAttribute) throw Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");
15609
- let n = t.array, { itemSize: i, normalized: a } = t, o = new n.constructor(d.length * i);
15610
- d.forEach((e, t) => {
15611
- for (let r = 0; r < i; r++) o[t * i + r] = n[e * i + r];
15612
- }), p.setAttribute(e, new Y(o, i, a));
15613
- });
15614
- let m = !0;
15615
- for (let [e, t] of Object.entries(r.morphAttributes)) {
15616
- let n = e;
15617
- p.morphAttributes[n] = [];
15618
- for (let e = 0; e < t.length; e++) {
15619
- let r = t[e];
15620
- if (r.isInterleavedBufferAttribute) throw Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");
15621
- let i = r.array, { itemSize: a, normalized: o } = r, s = new i.constructor(d.length * a);
15622
- d.forEach((e, t) => {
15623
- for (let n = 0; n < a; n++) s[t * a + n] = i[e * a + n];
15624
- }), m &&= s.every((e) => e === 0), p.morphAttributes[n][e] = new Y(s, a, o);
15625
- }
15626
- }
15627
- m && (p.morphAttributes = {}), n.geometry = p;
15699
+ let { isVertexUsed: o, vertexCount: s, verticesUsed: c } = vm(r.attributes, i);
15700
+ if (c === s) return;
15701
+ let { originalIndexNewIndexMap: l, newIndexOriginalIndexMap: u } = ym(o), d = new Tr();
15702
+ bm(r, d), t.set(r, d), xm(d, i, l), wm(d, r.attributes, u), Em(d, r.morphAttributes, u), n.geometry = d;
15628
15703
  }), Array.from(t.keys()).forEach((e) => {
15629
15704
  e.dispose();
15630
15705
  });
15631
15706
  }
15632
- function ym(e) {
15707
+ function Om(e) {
15633
15708
  e.meta?.metaVersion === "0" && (e.scene.rotation.y = Math.PI);
15634
15709
  }
15635
- var bm = class {
15710
+ var km = class {
15636
15711
  constructor() {}
15637
15712
  };
15638
- bm.combineMorphs = nm, bm.combineSkeletons = am, bm.deepDispose = gm, bm.removeUnnecessaryJoints = _m, bm.removeUnnecessaryVertices = vm, bm.rotateVRM0 = ym;
15713
+ km.combineMorphs = nm, km.combineSkeletons = am, km.deepDispose = gm, km.removeUnnecessaryJoints = _m, km.removeUnnecessaryVertices = Dm, km.rotateVRM0 = Om;
15639
15714
  //#endregion
15640
15715
  export { ao as a, $r as c, kl as i, Ie as l, $p as n, lo as o, jl as r, io as s, Pu as t, ci as u };
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./plugin-DbprBh0b.cjs`),t=require(`./three-vrm.module-FrURzSOB.cjs`);require(`./react.cjs`);let n=require(`vue`);var r={class:`size-full bg-gradient-to-b from-slate-800 to-slate-900 relative`},i={key:0,class:`absolute inset-0 flex items-center justify-center bg-slate-900/80`},a={key:1,class:`absolute inset-0 flex items-center justify-center bg-slate-900/80`},o={class:`text-red-400 text-lg text-center p-4`},s={key:2,class:`absolute top-4 right-4 px-3 py-1 bg-green-600 text-white text-sm rounded-full`},c=(0,n.defineComponent)({__name:`View`,props:{selectedResult:{},sendTextMessage:{type:Function},isAudioPlaying:{type:Boolean}},setup(e){let c=e,l=(0,n.ref)(null),u=(0,n.ref)(!1),d=(0,n.ref)(null),f=null,p=null,m=null,h=null,g=null,_=null,v=0,y=`neutral`,b=`none`,x=0,S=0,C=``,w={neutral:null,happy:t.t.Happy,sad:t.t.Sad,angry:t.t.Angry,surprised:t.t.Surprised};function T(){if(!l.value)return;let e=l.value,n=e.clientWidth,r=e.clientHeight;f=new t.u,p=new t.c(30,n/r,.1,100),p.position.set(0,1.3,1.5),p.lookAt(0,1.2,0),m=new t.i({antialias:!0,alpha:!0}),m.setSize(n,r),m.setPixelRatio(window.devicePixelRatio),m.outputColorSpace=t.l,e.appendChild(m.domElement);let i=new t.a(16777215,.6);f.add(i);let a=new t.s(16777215,.8);a.position.set(1,1,1),f.add(a),g=new t.o,window.addEventListener(`resize`,E),O()}function E(){if(!l.value||!p||!m)return;let e=l.value.clientWidth,t=l.value.clientHeight;p.aspect=e/t,p.updateProjectionMatrix(),m.setSize(e,t)}async function D(e){if(f){u.value=!0,d.value=null,h&&=(f.remove(h.scene),null);try{let n=new t.r;n.register(e=>new t.n(e));let r=(await n.loadAsync(e)).userData.vrm;if(!r)throw Error(`Failed to load VRM data`);f.add(r.scene),h=r,u.value=!1}catch(e){console.error(`Failed to load VRM:`,e),d.value=`Failed to load avatar: ${e instanceof Error?e.message:`Unknown error`}`,u.value=!1}}}function O(){if(_=requestAnimationFrame(O),!g||!m||!f||!p)return;let e=g.getDelta(),n=g.getElapsedTime();if(h){if(h.update(e),c.isAudioPlaying){v+=e*10;let r=(Math.sin(v)+1)*.3;h.expressionManager?.setValue(t.t.Aa,r);let i=h.humanoid?.getNormalizedBoneNode(`head`),a=h.humanoid?.getNormalizedBoneNode(`neck`),o=h.humanoid?.getNormalizedBoneNode(`spine`);i&&(i.rotation.x=Math.sin(n*2)*.08,i.rotation.z=Math.sin(n*1.5)*.05),a&&(a.rotation.y=Math.sin(n*.8)*.05),o&&(o.rotation.z=Math.sin(n*.5)*.03);let s=h.humanoid?.getNormalizedBoneNode(`leftShoulder`),c=h.humanoid?.getNormalizedBoneNode(`rightShoulder`),l=h.humanoid?.getNormalizedBoneNode(`leftUpperArm`),u=h.humanoid?.getNormalizedBoneNode(`rightUpperArm`),d=h.humanoid?.getNormalizedBoneNode(`leftLowerArm`),f=h.humanoid?.getNormalizedBoneNode(`rightLowerArm`);s&&(s.rotation.z=.1),c&&(c.rotation.z=-.1),l&&(l.rotation.z=-.8+Math.sin(n*1.2)*.1,l.rotation.x=.4+Math.sin(n*.9)*.15,l.rotation.y=Math.sin(n*.7)*.1),u&&(u.rotation.z=.8+Math.sin(n*1.3)*.1,u.rotation.x=.4+Math.sin(n*1)*.15,u.rotation.y=Math.sin(n*.8)*.1),d&&(d.rotation.y=-1-Math.sin(n*1.5)*.2,d.rotation.z=Math.sin(n*1.1)*.1),f&&(f.rotation.y=1+Math.sin(n*1.4)*.2,f.rotation.z=Math.sin(n*1.2)*.1)}else{v=0,h.expressionManager?.setValue(t.t.Aa,0);let e=h.humanoid?.getNormalizedBoneNode(`spine`),r=h.humanoid?.getNormalizedBoneNode(`head`);e&&(e.rotation.x=Math.sin(n*.8)*.02),r&&(r.rotation.x=Math.sin(n*.3)*.03,r.rotation.z=Math.sin(n*.2)*.02);let i=h.humanoid?.getNormalizedBoneNode(`leftShoulder`),a=h.humanoid?.getNormalizedBoneNode(`rightShoulder`),o=h.humanoid?.getNormalizedBoneNode(`leftUpperArm`),s=h.humanoid?.getNormalizedBoneNode(`rightUpperArm`),c=h.humanoid?.getNormalizedBoneNode(`leftLowerArm`),l=h.humanoid?.getNormalizedBoneNode(`rightLowerArm`);i&&(i.rotation.z=.1),a&&(a.rotation.z=-.1),o&&(o.rotation.z=-.9,o.rotation.x=.2,o.rotation.y=0),s&&(s.rotation.z=.9,s.rotation.x=.2,s.rotation.y=0),c&&(c.rotation.y=-.8),l&&(l.rotation.y=.8)}n%4<.1?h.expressionManager?.setValue(t.t.Blink,1):h.expressionManager?.setValue(t.t.Blink,0);let r=w[y];if(h.expressionManager?.setValue(t.t.Happy,0),h.expressionManager?.setValue(t.t.Sad,0),h.expressionManager?.setValue(t.t.Angry,0),h.expressionManager?.setValue(t.t.Surprised,0),r&&h.expressionManager?.setValue(r,.8),b!==`none`){let e=n-x,t=1.5;if(e<t){let n=e/t,r=h.humanoid?.getNormalizedBoneNode(`head`),i=h.humanoid?.getNormalizedBoneNode(`rightUpperArm`),a=h.humanoid?.getNormalizedBoneNode(`rightLowerArm`),o=h.humanoid?.getNormalizedBoneNode(`spine`),s=(e=>e<.5?2*e*e:1-(-2*e+2)**2/2)(n<.5?n*2:(1-n)*2);switch(b){case`nod`:r&&(r.rotation.x=Math.sin(n*Math.PI*3)*.2);break;case`shake`:r&&(r.rotation.y=Math.sin(n*Math.PI*4)*.3);break;case`wave`:i&&(i.rotation.z=1.5*s,i.rotation.x=-.3*s),a&&(a.rotation.y=.5+Math.sin(n*Math.PI*6)*.3);break;case`think`:r&&(r.rotation.x=.1*s,r.rotation.z=.1*s),i&&(i.rotation.z=.3*s,i.rotation.x=.8*s),a&&(a.rotation.y=1.5*s);break;case`bow`:o&&(o.rotation.x=.4*s),r&&(r.rotation.x=.2*s);break}}else b=`none`}}m.render(f,p)}function k(){_!==null&&(cancelAnimationFrame(_),_=null),window.removeEventListener(`resize`,E),m&&l.value&&(l.value.removeChild(m.domElement),m.dispose(),m=null),h&&=null,f=null,p=null,g=null}return(0,n.watch)(()=>c.selectedResult,e=>{if(e?.toolName===`receptron_avatar`&&e.data){let t=e.data;if(t.avatarUrl&&t.avatarUrl!==C&&(C=t.avatarUrl,D(t.avatarUrl)),t.emotion&&t.emotion!==y&&(console.log(`[Avatar Debug] Emotion changed to:`,t.emotion),y=t.emotion),t.action&&t.action!==`none`){let e=t.actionTimestamp||0;e>S&&(console.log(`[Avatar Debug] Action triggered:`,t.action),b=t.action,x=g?.getElapsedTime()||0,S=e)}}},{deep:!0}),(0,n.onMounted)(()=>{if(T(),c.selectedResult?.toolName===`receptron_avatar`&&c.selectedResult.data){let e=c.selectedResult.data;e.avatarUrl&&(C=e.avatarUrl,D(e.avatarUrl)),e.emotion&&(y=e.emotion)}}),(0,n.onUnmounted)(()=>{k()}),(t,c)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,r,[(0,n.createElementVNode)(`div`,{ref_key:`containerRef`,ref:l,class:`size-full`},null,512),u.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,i,[...c[0]||=[(0,n.createElementVNode)(`div`,{class:`text-white text-lg`},`Loading Avatar...`,-1)]])):(0,n.createCommentVNode)(``,!0),d.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,a,[(0,n.createElementVNode)(`div`,o,(0,n.toDisplayString)(d.value),1)])):(0,n.createCommentVNode)(``,!0),e.isAudioPlaying?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,s,` Speaking... `)):(0,n.createCommentVNode)(``,!0)]))}}),l={class:`p-3 bg-gradient-to-br from-slate-700 to-slate-800 rounded-md`},u={class:`flex flex-col items-center gap-2`},d={key:0,class:`text-xs px-2 py-0.5 bg-blue-500 text-white rounded-full`},f=(0,n.defineComponent)({__name:`Preview`,props:{result:{}},setup(e){let t=e,r=(0,n.computed)(()=>t.result.data),i=(0,n.computed)(()=>r.value?.emotion||`neutral`);return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,l,[(0,n.createElementVNode)(`div`,u,[t[0]||=(0,n.createElementVNode)(`div`,{class:`size-12 bg-slate-600 rounded-full flex items-center justify-center`},[(0,n.createElementVNode)(`svg`,{class:`size-8 text-slate-300`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[(0,n.createElementVNode)(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`})])],-1),t[1]||=(0,n.createElementVNode)(`div`,{class:`text-sm font-semibold text-white text-center`},` 3D Avatar `,-1),i.value&&i.value!==`neutral`?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,d,(0,n.toDisplayString)(i.value),1)):(0,n.createCommentVNode)(``,!0)])]))}}),p={...e.n,viewComponent:c,previewComponent:f},m={plugin:p};exports.Preview=f,exports.SAMPLES=e.r,exports.TOOL_DEFINITION=e.i,exports.TOOL_NAME=e.a,exports.View=c,exports.default=m,exports.executeAvatar=e.t,exports.plugin=p,exports.pluginCore=e.n;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./plugin-DbprBh0b.cjs`),t=require(`./three-vrm.module-D9yGV_Aw.cjs`);require(`./react.cjs`);let n=require(`vue`);var r={class:`size-full bg-gradient-to-b from-slate-800 to-slate-900 relative`},i={key:0,class:`absolute inset-0 flex items-center justify-center bg-slate-900/80`},a={key:1,class:`absolute inset-0 flex items-center justify-center bg-slate-900/80`},o={class:`text-red-400 text-lg text-center p-4`},s={key:2,class:`absolute top-4 right-4 px-3 py-1 bg-green-600 text-white text-sm rounded-full`},c=(0,n.defineComponent)({__name:`View`,props:{selectedResult:{},sendTextMessage:{type:Function},isAudioPlaying:{type:Boolean}},setup(e){let c=e,l=(0,n.ref)(null),u=(0,n.ref)(!1),d=(0,n.ref)(null),f=null,p=null,m=null,h=null,g=null,_=null,v=0,y=`neutral`,b=`none`,x=0,S=0,C=``,w={neutral:null,happy:t.t.Happy,sad:t.t.Sad,angry:t.t.Angry,surprised:t.t.Surprised};function T(){if(!l.value)return;let e=l.value,n=e.clientWidth,r=e.clientHeight;f=new t.u,p=new t.c(30,n/r,.1,100),p.position.set(0,1.3,1.5),p.lookAt(0,1.2,0),m=new t.i({antialias:!0,alpha:!0}),m.setSize(n,r),m.setPixelRatio(window.devicePixelRatio),m.outputColorSpace=t.l,e.appendChild(m.domElement);let i=new t.a(16777215,.6);f.add(i);let a=new t.s(16777215,.8);a.position.set(1,1,1),f.add(a),g=new t.o,window.addEventListener(`resize`,E),O()}function E(){if(!l.value||!p||!m)return;let e=l.value.clientWidth,t=l.value.clientHeight;p.aspect=e/t,p.updateProjectionMatrix(),m.setSize(e,t)}async function D(e){if(f){u.value=!0,d.value=null,h&&=(f.remove(h.scene),null);try{let n=new t.r;n.register(e=>new t.n(e));let r=(await n.loadAsync(e)).userData.vrm;if(!r)throw Error(`Failed to load VRM data`);f.add(r.scene),h=r,u.value=!1}catch(e){console.error(`Failed to load VRM:`,e),d.value=`Failed to load avatar: ${e instanceof Error?e.message:`Unknown error`}`,u.value=!1}}}function O(){if(_=requestAnimationFrame(O),!g||!m||!f||!p)return;let e=g.getDelta(),n=g.getElapsedTime();if(h){if(h.update(e),c.isAudioPlaying){v+=e*10;let r=(Math.sin(v)+1)*.3;h.expressionManager?.setValue(t.t.Aa,r);let i=h.humanoid?.getNormalizedBoneNode(`head`),a=h.humanoid?.getNormalizedBoneNode(`neck`),o=h.humanoid?.getNormalizedBoneNode(`spine`);i&&(i.rotation.x=Math.sin(n*2)*.08,i.rotation.z=Math.sin(n*1.5)*.05),a&&(a.rotation.y=Math.sin(n*.8)*.05),o&&(o.rotation.z=Math.sin(n*.5)*.03);let s=h.humanoid?.getNormalizedBoneNode(`leftShoulder`),c=h.humanoid?.getNormalizedBoneNode(`rightShoulder`),l=h.humanoid?.getNormalizedBoneNode(`leftUpperArm`),u=h.humanoid?.getNormalizedBoneNode(`rightUpperArm`),d=h.humanoid?.getNormalizedBoneNode(`leftLowerArm`),f=h.humanoid?.getNormalizedBoneNode(`rightLowerArm`);s&&(s.rotation.z=.1),c&&(c.rotation.z=-.1),l&&(l.rotation.z=-.8+Math.sin(n*1.2)*.1,l.rotation.x=.4+Math.sin(n*.9)*.15,l.rotation.y=Math.sin(n*.7)*.1),u&&(u.rotation.z=.8+Math.sin(n*1.3)*.1,u.rotation.x=.4+Math.sin(n*1)*.15,u.rotation.y=Math.sin(n*.8)*.1),d&&(d.rotation.y=-1-Math.sin(n*1.5)*.2,d.rotation.z=Math.sin(n*1.1)*.1),f&&(f.rotation.y=1+Math.sin(n*1.4)*.2,f.rotation.z=Math.sin(n*1.2)*.1)}else{v=0,h.expressionManager?.setValue(t.t.Aa,0);let e=h.humanoid?.getNormalizedBoneNode(`spine`),r=h.humanoid?.getNormalizedBoneNode(`head`);e&&(e.rotation.x=Math.sin(n*.8)*.02),r&&(r.rotation.x=Math.sin(n*.3)*.03,r.rotation.z=Math.sin(n*.2)*.02);let i=h.humanoid?.getNormalizedBoneNode(`leftShoulder`),a=h.humanoid?.getNormalizedBoneNode(`rightShoulder`),o=h.humanoid?.getNormalizedBoneNode(`leftUpperArm`),s=h.humanoid?.getNormalizedBoneNode(`rightUpperArm`),c=h.humanoid?.getNormalizedBoneNode(`leftLowerArm`),l=h.humanoid?.getNormalizedBoneNode(`rightLowerArm`);i&&(i.rotation.z=.1),a&&(a.rotation.z=-.1),o&&(o.rotation.z=-.9,o.rotation.x=.2,o.rotation.y=0),s&&(s.rotation.z=.9,s.rotation.x=.2,s.rotation.y=0),c&&(c.rotation.y=-.8),l&&(l.rotation.y=.8)}n%4<.1?h.expressionManager?.setValue(t.t.Blink,1):h.expressionManager?.setValue(t.t.Blink,0);let r=w[y];if(h.expressionManager?.setValue(t.t.Happy,0),h.expressionManager?.setValue(t.t.Sad,0),h.expressionManager?.setValue(t.t.Angry,0),h.expressionManager?.setValue(t.t.Surprised,0),r&&h.expressionManager?.setValue(r,.8),b!==`none`){let e=n-x,t=1.5;if(e<t){let n=e/t,r=h.humanoid?.getNormalizedBoneNode(`head`),i=h.humanoid?.getNormalizedBoneNode(`rightUpperArm`),a=h.humanoid?.getNormalizedBoneNode(`rightLowerArm`),o=h.humanoid?.getNormalizedBoneNode(`spine`),s=(e=>e<.5?2*e*e:1-(-2*e+2)**2/2)(n<.5?n*2:(1-n)*2);switch(b){case`nod`:r&&(r.rotation.x=Math.sin(n*Math.PI*3)*.2);break;case`shake`:r&&(r.rotation.y=Math.sin(n*Math.PI*4)*.3);break;case`wave`:i&&(i.rotation.z=1.5*s,i.rotation.x=-.3*s),a&&(a.rotation.y=.5+Math.sin(n*Math.PI*6)*.3);break;case`think`:r&&(r.rotation.x=.1*s,r.rotation.z=.1*s),i&&(i.rotation.z=.3*s,i.rotation.x=.8*s),a&&(a.rotation.y=1.5*s);break;case`bow`:o&&(o.rotation.x=.4*s),r&&(r.rotation.x=.2*s);break}}else b=`none`}}m.render(f,p)}function k(){_!==null&&(cancelAnimationFrame(_),_=null),window.removeEventListener(`resize`,E),m&&l.value&&(l.value.removeChild(m.domElement),m.dispose(),m=null),h&&=null,f=null,p=null,g=null}return(0,n.watch)(()=>c.selectedResult,e=>{if(e?.toolName===`receptron_avatar`&&e.data){let t=e.data;if(t.avatarUrl&&t.avatarUrl!==C&&(C=t.avatarUrl,D(t.avatarUrl)),t.emotion&&t.emotion!==y&&(console.log(`[Avatar Debug] Emotion changed to:`,t.emotion),y=t.emotion),t.action&&t.action!==`none`){let e=t.actionTimestamp||0;e>S&&(console.log(`[Avatar Debug] Action triggered:`,t.action),b=t.action,x=g?.getElapsedTime()||0,S=e)}}},{deep:!0}),(0,n.onMounted)(()=>{if(T(),c.selectedResult?.toolName===`receptron_avatar`&&c.selectedResult.data){let e=c.selectedResult.data;e.avatarUrl&&(C=e.avatarUrl,D(e.avatarUrl)),e.emotion&&(y=e.emotion)}}),(0,n.onUnmounted)(()=>{k()}),(t,c)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,r,[(0,n.createElementVNode)(`div`,{ref_key:`containerRef`,ref:l,class:`size-full`},null,512),u.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,i,[...c[0]||=[(0,n.createElementVNode)(`div`,{class:`text-white text-lg`},`Loading Avatar...`,-1)]])):(0,n.createCommentVNode)(``,!0),d.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,a,[(0,n.createElementVNode)(`div`,o,(0,n.toDisplayString)(d.value),1)])):(0,n.createCommentVNode)(``,!0),e.isAudioPlaying?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,s,` Speaking... `)):(0,n.createCommentVNode)(``,!0)]))}}),l={class:`p-3 bg-gradient-to-br from-slate-700 to-slate-800 rounded-md`},u={class:`flex flex-col items-center gap-2`},d={key:0,class:`text-xs px-2 py-0.5 bg-blue-500 text-white rounded-full`},f=(0,n.defineComponent)({__name:`Preview`,props:{result:{}},setup(e){let t=e,r=(0,n.computed)(()=>t.result.data),i=(0,n.computed)(()=>r.value?.emotion||`neutral`);return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,l,[(0,n.createElementVNode)(`div`,u,[t[0]||=(0,n.createElementVNode)(`div`,{class:`size-12 bg-slate-600 rounded-full flex items-center justify-center`},[(0,n.createElementVNode)(`svg`,{class:`size-8 text-slate-300`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[(0,n.createElementVNode)(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`})])],-1),t[1]||=(0,n.createElementVNode)(`div`,{class:`text-sm font-semibold text-white text-center`},` 3D Avatar `,-1),i.value&&i.value!==`neutral`?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,d,(0,n.toDisplayString)(i.value),1)):(0,n.createCommentVNode)(``,!0)])]))}}),p={...e.n,viewComponent:c,previewComponent:f},m={plugin:p};exports.Preview=f,exports.SAMPLES=e.r,exports.TOOL_DEFINITION=e.i,exports.TOOL_NAME=e.a,exports.View=c,exports.default=m,exports.executeAvatar=e.t,exports.plugin=p,exports.pluginCore=e.n;
package/dist/vue.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as e, i as t, n, r, t as i } from "./plugin-Cezk5ZnX.js";
2
- import { a, c as o, i as s, l as c, n as l, o as u, r as d, s as f, t as p, u as m } from "./three-vrm.module-BlO9zbj_.js";
2
+ import { a, c as o, i as s, l as c, n as l, o as u, r as d, s as f, t as p, u as m } from "./three-vrm.module-Dp91hI0o.js";
3
3
  import { computed as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, defineComponent as y, onMounted as b, onUnmounted as x, openBlock as S, ref as C, toDisplayString as w, watch as T } from "vue";
4
4
  //#region src/vue/View.vue?vue&type=script&setup=true&lang.ts
5
5
  var E = { class: "size-full bg-gradient-to-b from-slate-800 to-slate-900 relative" }, D = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gui-chat-plugin/avatar",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "description": "3D Avatar Plugin for GUIChat - VRM avatar with lip-sync",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -72,7 +72,7 @@
72
72
  "react": "^19.0.0",
73
73
  "react-dom": "^19.0.0",
74
74
  "tailwindcss": "^4.2.2",
75
- "typescript": "~5.9.3",
75
+ "typescript": "~6.0.2",
76
76
  "vite": "^8.0.3",
77
77
  "vue": "^3.5.31",
78
78
  "vue-eslint-parser": "^10.4.0",
@@ -93,7 +93,7 @@
93
93
  "license": "MIT",
94
94
  "dependencies": {
95
95
  "@pixiv/three-vrm": "^3.3.3",
96
- "gui-chat-protocol": "^0.0.4",
96
+ "gui-chat-protocol": "^0.1.0",
97
97
  "three": "^0.174.0"
98
98
  }
99
99
  }