소스 검색

Fix '_listeners' warning (#25003)

sunag 2 년 전
부모
커밋
5da9a7045d
1개의 변경된 파일9개의 추가작업 그리고 7개의 파일을 삭제
  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 ];
 
 	}