Skip to content

Commit 7527f40

Browse files
authored
TSL: Resolve some name collision (#32032)
* StackNode: Rename `.add()` -> `.addToStack()` * RenderOutputNode: Add `setToneMapping()` and `getToneMapping()` * updates * Update NodeMaterial.js
1 parent a31517a commit 7527f40

File tree

5 files changed

+66
-15
lines changed

5 files changed

+66
-15
lines changed

src/materials/nodes/NodeMaterial.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class NodeMaterial extends Material {
505505

506506
const outgoingLightNode = this.setupLighting( builder );
507507

508-
if ( clippingNode !== null ) builder.stack.add( clippingNode );
508+
if ( clippingNode !== null ) builder.stack.addToStack( clippingNode );
509509

510510
// force unsigned floats - useful for RenderTargets
511511

@@ -599,7 +599,7 @@ class NodeMaterial extends Material {
599599

600600
} else {
601601

602-
builder.stack.add( clipping() );
602+
builder.stack.addToStack( clipping() );
603603

604604
}
605605

@@ -626,7 +626,7 @@ class NodeMaterial extends Material {
626626

627627
if ( candidateCount > 0 && candidateCount <= 8 && builder.isAvailable( 'clipDistance' ) ) {
628628

629-
builder.stack.add( hardwareClipping() );
629+
builder.stack.addToStack( hardwareClipping() );
630630

631631
this.hardwareClipping = true;
632632

src/nodes/core/StackNode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class StackNode extends Node {
9797
* @param {Node} node - The node to add.
9898
* @return {StackNode} A reference to this stack node.
9999
*/
100-
add( node ) {
100+
addToStack( node ) {
101101

102102
if ( node.isNode !== true ) {
103103

@@ -124,7 +124,7 @@ class StackNode extends Node {
124124
const methodNode = new ShaderNode( method );
125125
this._currentCond = select( boolNode, methodNode );
126126

127-
return this.add( this._currentCond );
127+
return this.addToStack( this._currentCond );
128128

129129
}
130130

@@ -226,7 +226,7 @@ class StackNode extends Node {
226226

227227
this._currentCond = condNode;
228228

229-
return this.add( this._currentCond );
229+
return this.addToStack( this._currentCond );
230230

231231
} else {
232232

src/nodes/display/RenderOutputNode.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ class RenderOutputNode extends TempNode {
5656
/**
5757
* The tone mapping type.
5858
*
59+
* @private
5960
* @type {?number}
6061
*/
61-
this.toneMapping = toneMapping;
62+
this._toneMapping = toneMapping;
6263

6364
/**
6465
* The output color space.
@@ -78,13 +79,38 @@ class RenderOutputNode extends TempNode {
7879

7980
}
8081

82+
/**
83+
* Sets the tone mapping type.
84+
*
85+
* @param {number} value - The tone mapping type.
86+
* @return {ToneMappingNode} A reference to this node.
87+
*/
88+
setToneMapping( value ) {
89+
90+
this._toneMapping = value;
91+
92+
return this;
93+
94+
}
95+
96+
/**
97+
* Gets the tone mapping type.
98+
*
99+
* @returns {number} The tone mapping type.
100+
*/
101+
getToneMapping() {
102+
103+
return this._toneMapping;
104+
105+
}
106+
81107
setup( { context } ) {
82108

83109
let outputNode = this.colorNode || context.color;
84110

85111
// tone mapping
86112

87-
const toneMapping = ( this.toneMapping !== null ? this.toneMapping : context.toneMapping ) || NoToneMapping;
113+
const toneMapping = ( this._toneMapping !== null ? this._toneMapping : context.toneMapping ) || NoToneMapping;
88114
const outputColorSpace = ( this.outputColorSpace !== null ? this.outputColorSpace : context.outputColorSpace ) || NoColorSpace;
89115

90116
if ( toneMapping !== NoToneMapping ) {

src/nodes/display/ToneMappingNode.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ class ToneMappingNode extends TempNode {
3333
/**
3434
* The tone mapping type.
3535
*
36+
* @private
3637
* @type {number}
3738
*/
38-
this.toneMapping = toneMapping;
39+
this._toneMapping = toneMapping;
3940

4041
/**
4142
* The tone mapping exposure.
@@ -63,14 +64,39 @@ class ToneMappingNode extends TempNode {
6364
*/
6465
customCacheKey() {
6566

66-
return hash( this.toneMapping );
67+
return hash( this._toneMapping );
68+
69+
}
70+
71+
/**
72+
* Sets the tone mapping type.
73+
*
74+
* @param {number} value - The tone mapping type.
75+
* @return {ToneMappingNode} A reference to this node.
76+
*/
77+
setToneMapping( value ) {
78+
79+
this._toneMapping = value;
80+
81+
return this;
82+
83+
}
84+
85+
/**
86+
* Gets the tone mapping type.
87+
*
88+
* @returns {number} The tone mapping type.
89+
*/
90+
getToneMapping() {
91+
92+
return this._toneMapping;
6793

6894
}
6995

7096
setup( builder ) {
7197

7298
const colorNode = this.colorNode || builder.context.color;
73-
const toneMapping = this.toneMapping;
99+
const toneMapping = this._toneMapping;
74100

75101
if ( toneMapping === NoToneMapping ) return colorNode;
76102

src/nodes/tsl/TSLCore.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function addMethodChaining( name, nodeElement ) {
3737

3838
//if ( name === 'toVarIntent' ) return this;
3939

40-
return this.isStackNode ? this.add( nodeElement( ...params ) ) : nodeElement( this, ...params );
40+
return this.isStackNode ? this.addToStack( nodeElement( ...params ) ) : nodeElement( this, ...params );
4141

4242
};
4343

@@ -76,7 +76,7 @@ Node.prototype.assign = function ( ...params ) {
7676

7777
const nodeElement = NodeElements.get( 'assign' );
7878

79-
return this.add( nodeElement( ...params ) );
79+
return this.addToStack( nodeElement( ...params ) );
8080

8181
}
8282

@@ -1129,7 +1129,7 @@ export const Switch = ( ...params ) => currentStack.Switch( ...params );
11291129
*/
11301130
export function Stack( node ) {
11311131

1132-
if ( currentStack ) currentStack.add( node );
1132+
if ( currentStack ) currentStack.addToStack( node );
11331133

11341134
return node;
11351135

@@ -1221,4 +1221,3 @@ addMethodChaining( 'append', ( node ) => { // @deprecated, r176
12211221
return Stack( node );
12221222

12231223
} );
1224-

0 commit comments

Comments
 (0)