Browse Source

Material: Check if material has the property. Warn otherwise.

Mr.doob 10 years ago
parent
commit
718f496705
1 changed files with 15 additions and 12 deletions
  1. 15 12
      src/materials/Material.js

+ 15 - 12
src/materials/Material.js

@@ -81,28 +81,31 @@ THREE.Material.prototype = {
 
 			}
 
-			if ( key in this ) {
+			var currentValue = this[ key ];
 
-				var currentValue = this[ key ];
+			if ( currentValue === undefined ) {
 
-				if ( currentValue instanceof THREE.Color ) {
+				console.warn( "THREE." + this.type + ": '" + key + "' is not a property of this material." );
+				continue;
+
+			}
 
-					currentValue.set( newValue );
+			if ( currentValue instanceof THREE.Color ) {
 
-				} else if ( currentValue instanceof THREE.Vector3 && newValue instanceof THREE.Vector3 ) {
+				currentValue.set( newValue );
 
-					currentValue.copy( newValue );
+			} else if ( currentValue instanceof THREE.Vector3 && newValue instanceof THREE.Vector3 ) {
 
-				} else if ( key === 'overdraw' ) {
+				currentValue.copy( newValue );
 
-					// ensure overdraw is backwards-compatible with legacy boolean type
-					this[ key ] = Number( newValue );
+			} else if ( key === 'overdraw' ) {
 
-				} else {
+				// ensure overdraw is backwards-compatible with legacy boolean type
+				this[ key ] = Number( newValue );
 
-					this[ key ] = newValue;
+			} else {
 
-				}
+				this[ key ] = newValue;
 
 			}