Browse Source

Fix '_listeners' warning (#25003)

sunag 2 years ago
parent
commit
5da9a7045d
1 changed files with 9 additions and 7 deletions
  1. 9 7
      examples/jsm/nodes/materials/Materials.js

+ 9 - 7
examples/jsm/nodes/materials/Materials.js

@@ -32,19 +32,21 @@ NodeMaterial.fromMaterial = function ( material ) {
 
 	if ( materialLib[ type ] === undefined ) {
 
-		return material; // is already a node material or cannot be converted
+		if ( material.isNodeMaterial !== true ) {
 
-	}
+			throw new Error( `NodeMaterial: Material "${ material.type }" is not compatible.` );
 
-	const nodeMaterial = new materialLib[ type ]( material );
+		}
 
-	for ( const key in material ) {
+		return material; // is already a node material
 
-		if ( nodeMaterial[ key ] === undefined ) {
+	}
 
-			nodeMaterial[ key ] = material[ key ]; // currently this is needed only for material.alphaTest
+	const nodeMaterial = new materialLib[ type ]();
 
-		}
+	for ( const key in material ) {
+
+		nodeMaterial[ key ] = material[ key ];
 
 	}