Skip to content

Commit 2ccc5bc

Browse files
authored
Nodes: Rename construct() to setup() (#26840)
* Nodes: Rename `construct()` to `setup()` * deprecated alert
1 parent e2f5911 commit 2ccc5bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+126
-118
lines changed

Diff for: examples/jsm/nodes/accessors/BufferAttributeNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BufferAttributeNode extends InputNode {
4343

4444
}
4545

46-
construct( builder ) {
46+
setup( builder ) {
4747

4848
if ( this.attribute !== null ) return;
4949

Diff for: examples/jsm/nodes/accessors/CubeTextureNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class CubeTextureNode extends TextureNode {
9797

9898
if ( builder.needsColorSpaceToLinear( this.value ) ) {
9999

100-
snippet = colorSpaceToLinear( expression( snippet, nodeType ), this.value.colorSpace ).construct( builder ).build( builder, nodeType );
100+
snippet = colorSpaceToLinear( expression( snippet, nodeType ), this.value.colorSpace ).setup( builder ).build( builder, nodeType );
101101

102102
}
103103

Diff for: examples/jsm/nodes/accessors/ExtendedMaterialNode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ExtendedMaterialNode extends MaterialNode {
2929

3030
}
3131

32-
construct( builder ) {
32+
setup( builder ) {
3333

3434
const material = builder.material;
3535
const scope = this.scope;
@@ -59,7 +59,7 @@ class ExtendedMaterialNode extends MaterialNode {
5959

6060
}
6161

62-
return node || super.construct( builder );
62+
return node || super.setup( builder );
6363

6464
}
6565

Diff for: examples/jsm/nodes/accessors/InstanceNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class InstanceNode extends Node {
1717

1818
}
1919

20-
construct( builder ) {
20+
setup( builder ) {
2121

2222
let instanceMatrixNode = this.instanceMatrixNode;
2323

Diff for: examples/jsm/nodes/accessors/LineMaterialNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { nodeImmutable } from '../shadernode/ShaderNode.js';
44

55
class LineMaterialNode extends MaterialNode {
66

7-
construct( /*builder*/ ) {
7+
setup( /*builder*/ ) {
88

99
return this.getFloat( this.scope );
1010

Diff for: examples/jsm/nodes/accessors/MaterialNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MaterialNode extends Node {
4949

5050
}
5151

52-
construct( builder ) {
52+
setup( builder ) {
5353

5454
const material = builder.context.material;
5555
const scope = this.scope;

Diff for: examples/jsm/nodes/accessors/MaterialReferenceNode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class MaterialReferenceNode extends ReferenceNode {
2323

2424
}
2525

26-
construct( builder ) {
26+
setup( builder ) {
2727

2828
const material = this.material !== null ? this.material : builder.material;
2929

3030
this.node.value = material[ this.property ];
3131

32-
return super.construct( builder );
32+
return super.setup( builder );
3333

3434
}
3535

Diff for: examples/jsm/nodes/accessors/ModelViewProjectionNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ModelViewProjectionNode extends TempNode {
1515

1616
}
1717

18-
construct() {
18+
setup() {
1919

2020
return cameraProjectionMatrix.mul( modelViewMatrix ).mul( this.positionNode );
2121

Diff for: examples/jsm/nodes/accessors/MorphNode.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MorphNode extends Node {
1919

2020
}
2121

22-
constructAttribute( builder, name, assignNode = positionLocal ) {
22+
setupAttribute( builder, name, assignNode = positionLocal ) {
2323

2424
const mesh = this.mesh;
2525
const attributes = mesh.geometry.morphAttributes[ name ];
@@ -39,9 +39,9 @@ class MorphNode extends Node {
3939

4040
}
4141

42-
construct( builder ) {
42+
setup( builder ) {
4343

44-
this.constructAttribute( builder, 'position' );
44+
this.setupAttribute( builder, 'position' );
4545

4646
}
4747

Diff for: examples/jsm/nodes/accessors/ReferenceNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ReferenceNode extends Node {
6363

6464
}
6565

66-
construct( /*builder*/ ) {
66+
setup( /*builder*/ ) {
6767

6868
return this.node;
6969

Diff for: examples/jsm/nodes/accessors/ReflectVectorNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ReflectVectorNode extends Node {
1818

1919
}
2020

21-
construct() {
21+
setup() {
2222

2323
const reflectView = positionViewDirection.negate().reflect( transformedNormalView );
2424

Diff for: examples/jsm/nodes/accessors/SceneNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SceneNode extends Node {
1414

1515
}
1616

17-
construct( builder ) {
17+
setup( builder ) {
1818

1919
const scope = this.scope;
2020
const scene = this.scene !== null ? this.scene : builder.scene;

Diff for: examples/jsm/nodes/accessors/SkinningNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SkinningNode extends Node {
3030

3131
}
3232

33-
construct( builder ) {
33+
setup( builder ) {
3434

3535
const { skinIndexNode, skinWeightNode, bindMatrixNode, bindMatrixInverseNode, boneMatricesNode } = this;
3636

Diff for: examples/jsm/nodes/accessors/TextureBicubicNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TextureBicubicNode extends TempNode {
7777

7878
}
7979

80-
construct() {
80+
setup() {
8181

8282
return textureBicubicMethod( this.textureNode, this.blurNode );
8383

Diff for: examples/jsm/nodes/accessors/TextureNode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class TextureNode extends UniformNode {
7676

7777
}
7878

79-
construct( builder ) {
79+
setup( builder ) {
8080

8181
const properties = builder.getNodeProperties( this );
8282

@@ -187,7 +187,7 @@ class TextureNode extends UniformNode {
187187

188188
if ( builder.needsColorSpaceToLinear( this.value ) ) {
189189

190-
snippet = colorSpaceToLinear( expression( snippet, nodeType ), this.value.colorSpace ).construct( builder ).build( builder, nodeType );
190+
snippet = colorSpaceToLinear( expression( snippet, nodeType ), this.value.colorSpace ).setup( builder ).build( builder, nodeType );
191191

192192
}
193193

Diff for: examples/jsm/nodes/code/ScriptableNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ class ScriptableNode extends Node {
431431

432432
}
433433

434-
construct() {
434+
setup() {
435435

436436
return this.getDefaultOutputNode();
437437

Diff for: examples/jsm/nodes/code/ScriptableValueNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ScriptableValueNode extends Node {
9292

9393
}
9494

95-
construct() {
95+
setup() {
9696

9797
return this.value && this.value.isNode ? this.value : float();
9898

Diff for: examples/jsm/nodes/core/ContextNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ContextNode extends Node {
2020

2121
}
2222

23-
construct( builder ) {
23+
setup( builder ) {
2424

2525
const previousContext = builder.getContext();
2626

Diff for: examples/jsm/nodes/core/Node.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class Node extends EventDispatcher {
134134

135135
}
136136

137-
construct( builder ) {
137+
setup( builder ) {
138138

139139
const nodeProperties = builder.getNodeProperties( this );
140140

@@ -149,6 +149,14 @@ class Node extends EventDispatcher {
149149

150150
}
151151

152+
construct( builder ) { // @deprecated, r157
153+
154+
console.warn( 'THREE.Node: construct() is deprecated. Use setup() instead.' );
155+
156+
return this.setup( builder );
157+
158+
}
159+
152160
analyze( builder ) {
153161

154162
const nodeData = builder.getDataFromNode( this );
@@ -212,26 +220,26 @@ class Node extends EventDispatcher {
212220
builder.addChain( this );
213221

214222
/* Build stages expected results:
215-
- "construct" -> Node
223+
- "setup" -> Node
216224
- "analyze" -> null
217225
- "generate" -> String
218226
*/
219227
let result = null;
220228

221229
const buildStage = builder.getBuildStage();
222230

223-
if ( buildStage === 'construct' ) {
231+
if ( buildStage === 'setup' ) {
224232

225233
const properties = builder.getNodeProperties( this );
226234

227235
if ( properties.initialized !== true || builder.context.tempRead === false ) {
228236

229-
const stackNodesBeforeConstruct = builder.stack.nodes.length;
237+
const stackNodesBeforeSetup = builder.stack.nodes.length;
230238

231239
properties.initialized = true;
232-
properties.outputNode = this.construct( builder );
240+
properties.outputNode = this.setup( builder );
233241

234-
if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeConstruct ) {
242+
if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeSetup ) {
235243

236244
properties.outputNode = builder.stack;
237245

Diff for: examples/jsm/nodes/core/NodeBuilder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ class NodeBuilder {
945945

946946
build() {
947947

948-
// construct() -> stage 1: create possible new nodes and returns an output reference node
948+
// setup() -> stage 1: create possible new nodes and returns an output reference node
949949
// analyze() -> stage 2: analyze nodes to possible optimization and validation
950950
// generate() -> stage 3: generate shader
951951

Diff for: examples/jsm/nodes/core/OutputStructNode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class OutputStructNode extends Node {
1313

1414
}
1515

16-
construct( builder ) {
16+
setup( builder ) {
1717

18-
super.construct( builder );
18+
super.setup( builder );
1919

2020
const members = this.members;
2121
const types = [];

Diff for: examples/jsm/nodes/core/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ export const NodeType = {
2222
};
2323

2424
export const defaultShaderStages = [ 'fragment', 'vertex' ];
25-
export const defaultBuildStages = [ 'construct', 'analyze', 'generate' ];
25+
export const defaultBuildStages = [ 'setup', 'analyze', 'generate' ];
2626
export const shaderStages = [ ...defaultShaderStages, 'compute' ];
2727
export const vectorComponents = [ 'x', 'y', 'z', 'w' ];

Diff for: examples/jsm/nodes/display/BlendModeNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class BlendModeNode extends TempNode {
4848

4949
}
5050

51-
construct() {
51+
setup() {
5252

5353
const { blendMode, baseNode, blendNode } = this;
5454
const params = { base: baseNode, blend: blendNode };

Diff for: examples/jsm/nodes/display/BumpMapNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class BumpMapNode extends TempNode {
5555

5656
}
5757

58-
construct() {
58+
setup() {
5959

6060
const bumpScale = this.scaleNode !== null ? this.scaleNode : 1;
6161
const dHdxy = dHdxy_fwd( { bumpTexture: this.texture, bumpScale } );

Diff for: examples/jsm/nodes/display/ColorAdjustmentNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ColorAdjustmentNode extends TempNode {
4848

4949
}
5050

51-
construct() {
51+
setup() {
5252

5353
const { method, colorNode, adjustmentNode } = this;
5454

Diff for: examples/jsm/nodes/display/ColorSpaceNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ColorSpaceNode extends TempNode {
7070

7171
}
7272

73-
construct() {
73+
setup() {
7474

7575
const { method, node } = this;
7676

Diff for: examples/jsm/nodes/display/NormalMapNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class NormalMapNode extends TempNode {
5252

5353
}
5454

55-
construct( builder ) {
55+
setup( builder ) {
5656

5757
const { normalMapType, scaleNode } = this;
5858

Diff for: examples/jsm/nodes/display/PosterizeNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class PosterizeNode extends TempNode {
1313

1414
}
1515

16-
construct() {
16+
setup() {
1717

1818
const { sourceNode, stepsNode } = this;
1919

Diff for: examples/jsm/nodes/display/ToneMappingNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class ToneMappingNode extends TempNode {
104104

105105
}
106106

107-
construct( builder ) {
107+
setup( builder ) {
108108

109109
const colorNode = this.colorNode || builder.context.color;
110110
const toneMapping = this.toneMapping;

Diff for: examples/jsm/nodes/display/ViewportDepthNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ViewportDepthNode extends Node {
1717

1818
}
1919

20-
construct( /*builder*/ ) {
20+
setup( /*builder*/ ) {
2121

2222
const { scope } = this;
2323

Diff for: examples/jsm/nodes/display/ViewportNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ViewportNode extends Node {
5555

5656
}
5757

58-
construct( builder ) {
58+
setup( builder ) {
5959

6060
const scope = this.scope;
6161

Diff for: examples/jsm/nodes/fog/FogExp2Node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FogExp2Node extends FogNode {
1515

1616
}
1717

18-
construct() {
18+
setup() {
1919

2020
const depthNode = positionView.z.negate();
2121
const densityNode = this.densityNode;

Diff for: examples/jsm/nodes/fog/FogNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FogNode extends Node {
2020

2121
}
2222

23-
construct() {
23+
setup() {
2424

2525
return this.factorNode;
2626

Diff for: examples/jsm/nodes/fog/FogRangeNode.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FogRangeNode extends FogNode {
1717

1818
}
1919

20-
construct() {
20+
setup() {
2121

2222
return smoothstep( this.nearNode, this.farNode, positionView.z.negate() );
2323

0 commit comments

Comments
 (0)