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.

38 lines
655 B

6 months ago
import Node, { addNodeClass } from '../core/Node.js';
import { nodeProxy } from '../shadernode/ShaderNode.js';
class ExpressionNode extends Node {
constructor( snippet = '', nodeType = 'void' ) {
super( nodeType );
this.snippet = snippet;
}
generate( builder, output ) {
const type = this.getNodeType( builder );
const snippet = this.snippet;
if ( type === 'void' ) {
builder.addLineFlowCode( snippet );
} else {
return builder.format( `( ${ snippet } )`, type, output );
}
}
}
export default ExpressionNode;
export const expression = nodeProxy( ExpressionNode );
addNodeClass( 'ExpressionNode', ExpressionNode );