Skip to content

Commit 93dccc1

Browse files
authored
Node: Document more modules. (#30027)
* Node: Document more modules. * Docs: Minor fixes. * Docs: More fixes.
1 parent 0c45156 commit 93dccc1

13 files changed

+499
-4
lines changed

src/nodes/core/LightingModel.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class LightingModel {
1010
* This method is intended for setting up lighting model and context data
1111
* which are later used in the evaluation process.
1212
*
13+
* @abstract
1314
* @param {ContextNode} input - The current node context.
1415
* @param {StackNode} stack - The current stack.
1516
* @param {NodeBuilder} builder - The current node builder.
@@ -20,6 +21,7 @@ class LightingModel {
2021
* This method is intended for executing final tasks like final updates
2122
* to the outgoing light.
2223
*
24+
* @abstract
2325
* @param {ContextNode} input - The current node context.
2426
* @param {StackNode} stack - The current stack.
2527
* @param {NodeBuilder} builder - The current node builder.
@@ -30,6 +32,7 @@ class LightingModel {
3032
* This method is intended for implementing the direct light term and
3133
* executed during the build process of directional, point and spot light nodes.
3234
*
35+
* @abstract
3336
* @param {Object} input - The input data.
3437
* @param {StackNode} stack - The current stack.
3538
* @param {NodeBuilder} builder - The current node builder.
@@ -40,6 +43,7 @@ class LightingModel {
4043
* This method is intended for implementing the direct light term for
4144
* rect area light nodes.
4245
*
46+
* @abstract
4347
* @param {Object} input - The input data.
4448
* @param {StackNode} stack - The current stack.
4549
* @param {NodeBuilder} builder - The current node builder.
@@ -49,6 +53,7 @@ class LightingModel {
4953
/**
5054
* This method is intended for implementing the indirect light term.
5155
*
56+
* @abstract
5257
* @param {ContextNode} input - The current node context.
5358
* @param {StackNode} stack - The current stack.
5459
* @param {NodeBuilder} builder - The current node builder.
@@ -60,6 +65,7 @@ class LightingModel {
6065
* Unlike other methods, this method must be called manually by the lighting
6166
* model in its indirect term.
6267
*
68+
* @abstract
6369
* @param {ContextNode} input - The current node context.
6470
* @param {StackNode} stack - The current stack.
6571
* @param {NodeBuilder} builder - The current node builder.

src/nodes/core/ParameterNode.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { nodeObject } from '../tsl/TSLBase.js';
22
import PropertyNode from './PropertyNode.js';
33

4+
/**
5+
* Special version of {@link PropertyNode} which is used for parameters.
6+
*
7+
* @augments PropertyNode
8+
*/
49
class ParameterNode extends PropertyNode {
510

611
static get type() {
@@ -9,10 +14,23 @@ class ParameterNode extends PropertyNode {
914

1015
}
1116

17+
/**
18+
* Constructs a new parameter node.
19+
*
20+
* @param {String} nodeType - The type of the node.
21+
* @param {String?} [name=null] - The name of the parameter in the shader.
22+
*/
1223
constructor( nodeType, name = null ) {
1324

1425
super( nodeType, name );
1526

27+
/**
28+
* This flag can be used for type testing.
29+
*
30+
* @type {Boolean}
31+
* @readonly
32+
* @default true
33+
*/
1634
this.isParameterNode = true;
1735

1836
}

src/nodes/core/PropertyNode.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
import Node from './Node.js';
22
import { nodeImmutable, nodeObject } from '../tsl/TSLCore.js';
33

4+
/**
5+
* This class represents a shader property. It can be used on
6+
* to explicitely define a property and assign a value to it.
7+
*
8+
* ```js
9+
* const threshold = property( 'float', 'threshold' ).assign( THRESHOLD );
10+
*```
11+
* `PropertyNode` is used by the engine to predefined common material properties
12+
* for TSL code.
13+
*
14+
* @augments Node
15+
*/
416
class PropertyNode extends Node {
517

618
static get type() {
@@ -9,13 +21,41 @@ class PropertyNode extends Node {
921

1022
}
1123

24+
/**
25+
* Constructs a new property node.
26+
*
27+
* @param {String} nodeType - The type of the node.
28+
* @param {String?} [name=null] - The name of the property in the shader.
29+
* @param {Boolean} [varying=false] - Whether this property is a varying or not.
30+
*/
1231
constructor( nodeType, name = null, varying = false ) {
1332

1433
super( nodeType );
1534

35+
/**
36+
* The name of the property in the shader. If no name is defined,
37+
* the node system auto-generates one.
38+
*
39+
* @type {String?}
40+
* @default null
41+
*/
1642
this.name = name;
43+
44+
/**
45+
* Whether this property is a varying or not.
46+
*
47+
* @type {Boolean}
48+
* @default false
49+
*/
1750
this.varying = varying;
1851

52+
/**
53+
* This flag can be used for type testing.
54+
*
55+
* @type {Boolean}
56+
* @readonly
57+
* @default true
58+
*/
1959
this.isPropertyNode = true;
2060

2161
}
@@ -26,6 +66,12 @@ class PropertyNode extends Node {
2666

2767
}
2868

69+
/**
70+
* The method is overwritten so it always returns `true`.
71+
*
72+
* @param {NodeBuilder} builder - The current node builder.
73+
* @return {Boolean} Whether this node is global or not.
74+
*/
2975
isGlobal( /*builder*/ ) {
3076

3177
return true;

src/nodes/core/StackNode.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import Node from './Node.js';
22
import { select } from '../math/ConditionalNode.js';
33
import { ShaderNode, nodeProxy, getCurrentStack, setCurrentStack } from '../tsl/TSLBase.js';
44

5+
/**
6+
* TODO
7+
*
8+
* @augments Node
9+
*/
510
class StackNode extends Node {
611

712
static get type() {
@@ -10,17 +15,54 @@ class StackNode extends Node {
1015

1116
}
1217

18+
/**
19+
* Constructs a new stack node.
20+
*
21+
* @param {StackNode?} [parent=null] - The parent stack node.
22+
*/
1323
constructor( parent = null ) {
1424

1525
super();
1626

27+
/**
28+
* List of nodes.
29+
*
30+
* @type {Array<Node>}
31+
*/
1732
this.nodes = [];
33+
34+
/**
35+
* The output node.
36+
*
37+
* @type {Node?}
38+
* @default null
39+
*/
1840
this.outputNode = null;
1941

42+
/**
43+
* The parent stack node.
44+
*
45+
* @type {StackNode}
46+
* @default null
47+
*/
2048
this.parent = parent;
2149

50+
/**
51+
* The current conditional node.
52+
*
53+
* @private
54+
* @type {ConditionalNode}
55+
* @default null
56+
*/
2257
this._currentCond = null;
2358

59+
/**
60+
* This flag can be used for type testing.
61+
*
62+
* @type {Boolean}
63+
* @readonly
64+
* @default true
65+
*/
2466
this.isStackNode = true;
2567

2668
}
@@ -31,6 +73,12 @@ class StackNode extends Node {
3173

3274
}
3375

76+
/**
77+
* Adds a node to this stack.
78+
*
79+
* @param {Node} node - The node to add.
80+
* @return {StackNode} A reference to this stack node.
81+
*/
3482
add( node ) {
3583

3684
this.nodes.push( node );
@@ -39,6 +87,13 @@ class StackNode extends Node {
3987

4088
}
4189

90+
/**
91+
* Represent an `if` statement in TSL.
92+
*
93+
* @param {Node} boolNode - Represents the condition.
94+
* @param {Function} method - TSL code which is executed if the condition evaluates to `true`.
95+
* @return {StackNode} A reference to this stack node.
96+
*/
4297
If( boolNode, method ) {
4398

4499
const methodNode = new ShaderNode( method );
@@ -48,6 +103,13 @@ class StackNode extends Node {
48103

49104
}
50105

106+
/**
107+
* Represent an `elseif` statement in TSL.
108+
*
109+
* @param {Node} boolNode - Represents the condition.
110+
* @param {Function} method - TSL code which is executed if the condition evaluates to `true`.
111+
* @return {StackNode} A reference to this stack node.
112+
*/
51113
ElseIf( boolNode, method ) {
52114

53115
const methodNode = new ShaderNode( method );
@@ -60,6 +122,12 @@ class StackNode extends Node {
60122

61123
}
62124

125+
/**
126+
* Represent an `else` statement in TSL.
127+
*
128+
* @param {Function} method - TSL code which is executed in the `else` case.
129+
* @return {StackNode} A reference to this stack node.
130+
*/
63131
Else( method ) {
64132

65133
this._currentCond.elseNode = new ShaderNode( method );

src/nodes/core/VaryingNode.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ class VaryingNode extends Node {
6060
/**
6161
* The method is overwritten so it always returns `true`.
6262
*
63+
* @param {NodeBuilder} builder - The current node builder.
6364
* @return {Boolean} Whether this node is global or not.
6465
*/
65-
isGlobal() {
66+
isGlobal( /*builder*/ ) {
6667

6768
return true;
6869

src/nodes/fog/FogExp2Node.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import FogNode from './FogNode.js';
22
import { nodeProxy } from '../tsl/TSLBase.js';
33

4+
/**
5+
* Represents an exponential squared fog. This type of fog gives
6+
* a clear view near the camera and a faster than exponentially
7+
* densening fog farther from the camera.
8+
*
9+
* @augments FogNode
10+
*/
411
class FogExp2Node extends FogNode {
512

613
static get type() {
@@ -9,12 +16,30 @@ class FogExp2Node extends FogNode {
916

1017
}
1118

19+
/**
20+
* Constructs a new exponential squared fog node.
21+
*
22+
* @param {Node} colorNode - Defines the color of the fog.
23+
* @param {Node} densityNode - Defines the fog densitiy.
24+
*/
1225
constructor( colorNode, densityNode ) {
1326

14-
super( colorNode );
27+
super( colorNode, null );
1528

29+
/**
30+
* This flag can be used for type testing.
31+
*
32+
* @type {Boolean}
33+
* @readonly
34+
* @default true
35+
*/
1636
this.isFogExp2Node = true;
1737

38+
/**
39+
* Defines the fog densitiy.
40+
*
41+
* @type {Node}
42+
*/
1843
this.densityNode = densityNode;
1944

2045
}

0 commit comments

Comments
 (0)