forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBuiltinNode.js
63 lines (51 loc) · 1.18 KB
/
BuiltinNode.js
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
import Node from '../core/Node.js';
import { nodeProxy } from '../tsl/TSLBase.js';
/**
* The node allows to set values for built-in shader variables. That is
* required for features like hardware-accelerated vertex clipping.
*
* @augments Node
*/
class BuiltinNode extends Node {
/**
* Constructs a new builtin node.
*
* @param {string} name - The name of the built-in shader variable.
*/
constructor( name ) {
super( 'float' );
/**
* The name of the built-in shader variable.
*
* @type {string}
*/
this.name = name;
/**
* This flag can be used for type testing.
*
* @type {boolean}
* @readonly
* @default true
*/
this.isBuiltinNode = true;
}
/**
* Generates the code snippet of the builtin node.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The generated code snippet.
*/
generate( /* builder */ ) {
return this.name;
}
}
export default BuiltinNode;
/**
* TSL function for creating a builtin node.
*
* @tsl
* @function
* @param {string} name - The name of the built-in shader variable.
* @returns {BuiltinNode}
*/
export const builtin = nodeProxy( BuiltinNode ).setParameterLength( 1 );