1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import NodeMaterial from './NodeMaterial.js';
- import LineBasicNodeMaterial from './LineBasicNodeMaterial.js';
- import MeshBasicNodeMaterial from './MeshBasicNodeMaterial.js';
- import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js';
- import MeshPhysicalNodeMaterial from './MeshPhysicalNodeMaterial.js';
- import PointsNodeMaterial from './PointsNodeMaterial.js';
- import SpriteNodeMaterial from './SpriteNodeMaterial.js';
- export {
- NodeMaterial,
- LineBasicNodeMaterial,
- MeshBasicNodeMaterial,
- MeshStandardNodeMaterial,
- MeshPhysicalNodeMaterial,
- PointsNodeMaterial,
- SpriteNodeMaterial
- };
- NodeMaterial.fromMaterial = function ( material ) {
- const materialLib = {
- NodeMaterial,
- LineBasicNodeMaterial,
- MeshBasicNodeMaterial,
- MeshStandardNodeMaterial,
- MeshPhysicalNodeMaterial,
- PointsNodeMaterial,
- SpriteNodeMaterial
- };
- const type = material.type.replace( 'Material', 'NodeMaterial' );
- if ( materialLib[ type ] === undefined ) {
- return material; // is already a node material or cannot be converted
- }
- const nodeMaterial = new materialLib[ type ]( material );
- for ( const key in material ) {
- if ( nodeMaterial[ key ] === undefined ) {
- nodeMaterial[ key ] = material[ key ]; // currently this is needed only for material.alphaTest
- }
- }
- return nodeMaterial;
- };
|