Bläddra i källkod

Updated examples builds.

Mr.doob 3 år sedan
förälder
incheckning
274ab983b3
1 ändrade filer med 17 tillägg och 2 borttagningar
  1. 17 2
      examples/js/loaders/MMDLoader.js

+ 17 - 2
examples/js/loaders/MMDLoader.js

@@ -1863,7 +1863,7 @@
 			} );
 			this.uniforms = THREE.UniformsUtils.clone( THREE.MMDToonShader.uniforms ); // merged from MeshToon/Phong/MatcapMaterial
 
-			const exposePropertyNames = [ 'specular', 'shininess', 'opacity', 'diffuse', 'map', 'matcap', 'gradientMap', 'lightMap', 'lightMapIntensity', 'aoMap', 'aoMapIntensity', 'emissive', 'emissiveMap', 'bumpMap', 'bumpScale', 'normalMap', 'normalScale', 'displacemantBias', 'displacemantMap', 'displacemantScale', 'specularMap', 'alphaMap', 'envMap', 'reflectivity', 'refractionRatio' ];
+			const exposePropertyNames = [ 'specular', 'opacity', 'diffuse', 'map', 'matcap', 'gradientMap', 'lightMap', 'lightMapIntensity', 'aoMap', 'aoMapIntensity', 'emissive', 'emissiveMap', 'bumpMap', 'bumpScale', 'normalMap', 'normalScale', 'displacemantBias', 'displacemantMap', 'displacemantScale', 'specularMap', 'alphaMap', 'envMap', 'reflectivity', 'refractionRatio' ];
 
 			for ( const propertyName of exposePropertyNames ) {
 
@@ -1880,8 +1880,23 @@
 					}
 				} );
 
-			}
+			} // Special path for shininess to handle zero shininess properly
+
+
+			this._shininess = 30;
+			Object.defineProperty( this, 'shininess', {
+				get: function () {
+
+					return this._shininess;
 
+				},
+				set: function ( value ) {
+
+					this._shininess = value;
+					this.uniforms.shininess.value = Math.max( this._shininess, 1e-4 ); // To prevent pow( 0.0, 0.0 )
+
+				}
+			} );
 			Object.defineProperty( this, 'color', Object.getOwnPropertyDescriptor( this, 'diffuse' ) );
 			this.setValues( parameters );