Browse Source

NodeMaterial: Clean up (#25860)

Levi Pesin 2 years ago
parent
commit
84ddf2bc24
1 changed files with 7 additions and 7 deletions
  1. 7 7
      examples/jsm/nodes/materials/NodeMaterial.js

+ 7 - 7
examples/jsm/nodes/materials/NodeMaterial.js

@@ -337,19 +337,19 @@ class NodeMaterial extends ShaderMaterial {
 
 	static fromMaterial( material ) {
 
-		const type = material.type.replace( 'Material', 'NodeMaterial' );
+		if ( material.isNodeMaterial === true ) { // is already a node material
 
-		const nodeMaterial = createNodeMaterialFromType( type );
+			return material;
 
-		if ( nodeMaterial === undefined ) {
+		}
 
-			if ( material.isNodeMaterial !== true ) {
+		const type = material.type.replace( 'Material', 'NodeMaterial' );
 
-				throw new Error( `NodeMaterial: Material "${ material.type }" is not compatible.` );
+		const nodeMaterial = createNodeMaterialFromType( type );
 
-			}
+		if ( nodeMaterial === undefined ) {
 
-			return material; // is already a node material
+			throw new Error( `NodeMaterial: Material "${ material.type }" is not compatible.` );
 
 		}