|
@@ -32,19 +32,21 @@ NodeMaterial.fromMaterial = function ( material ) {
|
|
|
|
|
|
if ( materialLib[ type ] === undefined ) {
|
|
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 ];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|