浏览代码

NodeMaterial: Clean up (#25860)

Levi Pesin 2 年之前
父节点
当前提交
84ddf2bc24
共有 1 个文件被更改,包括 7 次插入7 次删除
  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.` );
 
 		}