mirror of
https://github.com/jiawanlong/Cesium-Examples.git
synced 2025-07-06 16:31:03 +00:00
40 lines
866 B
JavaScript
40 lines
866 B
JavaScript
import ReferenceNode from './ReferenceNode.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;
|
|
|
|
}
|
|
|
|
construct( builder ) {
|
|
|
|
const material = this.material !== null ? this.material : builder.material;
|
|
|
|
this.node.value = material[ this.property ];
|
|
|
|
return super.construct( builder );
|
|
|
|
}
|
|
|
|
update( frame ) {
|
|
|
|
this.object = this.material !== null ? this.material : frame.material;
|
|
|
|
super.update( frame );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export default MaterialReferenceNode;
|
|
|
|
export const materialReference = ( name, type, material ) => nodeObject( new MaterialReferenceNode( name, type, material ) );
|
|
|
|
addNodeClass( MaterialReferenceNode );
|