1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import { Node } from '../core/Node.js';
- class BypassNode extends Node {
- constructor( code, value ) {
- super();
- this.code = code;
- this.value = value;
- }
- getType( builder ) {
- if ( this.value ) {
- return this.value.getType( builder );
- } else if ( builder.isShader( 'fragment' ) ) {
- return 'f';
- }
- return 'void';
- }
- generate( builder, output ) {
- const code = this.code.build( builder, output ) + ';';
- builder.addNodeCode( code );
- if ( builder.isShader( 'vertex' ) ) {
- if ( this.value ) {
- return this.value.build( builder, output );
- }
- } else {
- return this.value ? this.value.build( builder, output ) : builder.format( '0.0', 'f', output );
- }
- }
- copy( source ) {
- super.copy( source );
- this.code = source.code;
- this.value = source.value;
- return this;
- }
- toJSON( meta ) {
- let data = this.getJSONNode( meta );
- if ( ! data ) {
- data = this.createJSONNode( meta );
- data.code = this.code.toJSON( meta ).uuid;
- if ( this.value ) data.value = this.value.toJSON( meta ).uuid;
- }
- return data;
- }
- }
- BypassNode.prototype.nodeType = 'Bypass';
- export { BypassNode };
|