File size: 1,393 Bytes
6cd9596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
 * @author sunag / http://www.sunag.com.br/
 */

import { Node } from '../core/Node.js';

function BypassNode( code, value ) {

	Node.call( this );

	this.code = code;
	this.value = value;

}

BypassNode.prototype = Object.create( Node.prototype );
BypassNode.prototype.constructor = BypassNode;
BypassNode.prototype.nodeType = "Bypass";

BypassNode.prototype.getType = function ( builder ) {

	if ( this.value ) {

		return this.value.getType( builder );

	} else if ( builder.isShader( 'fragment' ) ) {

		return 'f';

	}

	return 'void';

};

BypassNode.prototype.generate = function ( builder, output ) {

	var 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 );

	}

};

BypassNode.prototype.copy = function ( source ) {

	Node.prototype.copy.call( this, source );

	this.code = source.code;
	this.value = source.value;

};

BypassNode.prototype.toJSON = function ( meta ) {

	var 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;

};

export { BypassNode };