You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
994 B
JavaScript
43 lines
994 B
JavaScript
import ReferenceNode from './ReferenceNode.js';
|
|
import { NodeUpdateType } from '../core/constants.js';
|
|
import { addNodeClass } from '../core/Node.js';
|
|
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
|
|
class MaterialReferenceNode extends ReferenceNode {
|
|
|
|
constructor( property, inputType, material = null ) {
|
|
|
|
super( property, inputType, material );
|
|
|
|
this.material = material;
|
|
|
|
this.updateType = NodeUpdateType.RENDER;
|
|
|
|
}
|
|
|
|
updateReference( frame ) {
|
|
|
|
this.reference = this.material !== null ? this.material : frame.material;
|
|
|
|
return this.reference;
|
|
|
|
}
|
|
|
|
setup( builder ) {
|
|
|
|
const material = this.material !== null ? this.material : builder.material;
|
|
|
|
this.node.value = material[ this.property ];
|
|
|
|
return super.setup( builder );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export default MaterialReferenceNode;
|
|
|
|
export const materialReference = ( name, type, material ) => nodeObject( new MaterialReferenceNode( name, type, material ) );
|
|
|
|
addNodeClass( 'MaterialReferenceNode', MaterialReferenceNode );
|