You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
854 B
46 lines
854 B
import InputNode from './InputNode.js';
|
|
|
|
class UniformNode extends InputNode {
|
|
|
|
constructor( value, nodeType = null ) {
|
|
|
|
super( value, nodeType );
|
|
|
|
this.isUniformNode = true;
|
|
|
|
}
|
|
|
|
getUniformHash( builder ) {
|
|
|
|
return this.getHash( builder );
|
|
|
|
}
|
|
|
|
generate( builder, output ) {
|
|
|
|
const type = this.getNodeType( builder );
|
|
|
|
const hash = this.getUniformHash( builder );
|
|
|
|
let sharedNode = builder.getNodeFromHash( hash );
|
|
|
|
if ( sharedNode === undefined ) {
|
|
|
|
builder.setHashNode( this, hash );
|
|
|
|
sharedNode = this;
|
|
|
|
}
|
|
|
|
const sharedNodeType = sharedNode.getInputType( builder );
|
|
|
|
const nodeUniform = builder.getUniformFromNode( sharedNode, builder.shaderStage, sharedNodeType );
|
|
const propertyName = builder.getPropertyName( nodeUniform );
|
|
|
|
return builder.format( propertyName, type, output );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export default UniformNode;
|
|
|