123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import Node from './Node.js';
- class InputNode extends Node {
- constructor( inputType ) {
- super( inputType );
- this.inputType = inputType;
- this.constant = false;
- }
- setConst( value ) {
- this.constant = value;
- return this;
- }
- getConst() {
- return this.constant;
- }
- getInputType( /* builder */ ) {
- return this.inputType;
- }
- getInputHash( builder ) {
- return this.getHash( builder );
- }
- generateConst( builder ) {
- return builder.getConst( this.getNodeType( builder ), this.value );
- }
- generate( builder, output ) {
- const type = this.getNodeType( builder );
- if ( this.constant === true ) {
- return builder.format( this.generateConst( builder ), type, output );
- } else {
- const inputHash = this.getInputHash( builder );
- let sharedNode = builder.getNodeFromHash( inputHash );
- if ( sharedNode === undefined ) {
- builder.setHashNode( this, inputHash );
- sharedNode = this;
- }
- const inputType = sharedNode.getInputType( builder );
- const nodeUniform = builder.getUniformFromNode( sharedNode, builder.shaderStage, inputType );
- const propertyName = builder.getPropertyName( nodeUniform );
- return builder.format( propertyName, type, output );
- }
- }
- }
- InputNode.prototype.isInputNode = true;
- export default InputNode;
|