Skip to content

Commit

Permalink
Nodes: Rename construct() to setup() (#26840)
Browse files Browse the repository at this point in the history
* Nodes: Rename `construct()` to `setup()`

* deprecated alert
  • Loading branch information
sunag committed Sep 26, 2023
1 parent e2f5911 commit 2ccc5bc
Show file tree
Hide file tree
Showing 70 changed files with 126 additions and 118 deletions.
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/BufferAttributeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BufferAttributeNode extends InputNode {

}

construct( builder ) {
setup( builder ) {

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

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/CubeTextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class CubeTextureNode extends TextureNode {

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

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

}

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/accessors/ExtendedMaterialNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ExtendedMaterialNode extends MaterialNode {

}

construct( builder ) {
setup( builder ) {

const material = builder.material;
const scope = this.scope;
Expand Down Expand Up @@ -59,7 +59,7 @@ class ExtendedMaterialNode extends MaterialNode {

}

return node || super.construct( builder );
return node || super.setup( builder );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/InstanceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InstanceNode extends Node {

}

construct( builder ) {
setup( builder ) {

let instanceMatrixNode = this.instanceMatrixNode;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/LineMaterialNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { nodeImmutable } from '../shadernode/ShaderNode.js';

class LineMaterialNode extends MaterialNode {

construct( /*builder*/ ) {
setup( /*builder*/ ) {

return this.getFloat( this.scope );

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/MaterialNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MaterialNode extends Node {

}

construct( builder ) {
setup( builder ) {

const material = builder.context.material;
const scope = this.scope;
Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/accessors/MaterialReferenceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class MaterialReferenceNode extends ReferenceNode {

}

construct( builder ) {
setup( builder ) {

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

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

return super.construct( builder );
return super.setup( builder );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/ModelViewProjectionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ModelViewProjectionNode extends TempNode {

}

construct() {
setup() {

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

Expand Down
6 changes: 3 additions & 3 deletions examples/jsm/nodes/accessors/MorphNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MorphNode extends Node {

}

constructAttribute( builder, name, assignNode = positionLocal ) {
setupAttribute( builder, name, assignNode = positionLocal ) {

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

}

construct( builder ) {
setup( builder ) {

this.constructAttribute( builder, 'position' );
this.setupAttribute( builder, 'position' );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/ReferenceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ReferenceNode extends Node {

}

construct( /*builder*/ ) {
setup( /*builder*/ ) {

return this.node;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/ReflectVectorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ReflectVectorNode extends Node {

}

construct() {
setup() {

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

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/SceneNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SceneNode extends Node {

}

construct( builder ) {
setup( builder ) {

const scope = this.scope;
const scene = this.scene !== null ? this.scene : builder.scene;
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/SkinningNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SkinningNode extends Node {

}

construct( builder ) {
setup( builder ) {

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

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/TextureBicubicNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TextureBicubicNode extends TempNode {

}

construct() {
setup() {

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

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class TextureNode extends UniformNode {

}

construct( builder ) {
setup( builder ) {

const properties = builder.getNodeProperties( this );

Expand Down Expand Up @@ -187,7 +187,7 @@ class TextureNode extends UniformNode {

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

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

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/code/ScriptableNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class ScriptableNode extends Node {

}

construct() {
setup() {

return this.getDefaultOutputNode();

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/code/ScriptableValueNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ScriptableValueNode extends Node {

}

construct() {
setup() {

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

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/core/ContextNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ContextNode extends Node {

}

construct( builder ) {
setup( builder ) {

const previousContext = builder.getContext();

Expand Down
20 changes: 14 additions & 6 deletions examples/jsm/nodes/core/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Node extends EventDispatcher {

}

construct( builder ) {
setup( builder ) {

const nodeProperties = builder.getNodeProperties( this );

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

}

construct( builder ) { // @deprecated, r157

console.warn( 'THREE.Node: construct() is deprecated. Use setup() instead.' );

return this.setup( builder );

}

analyze( builder ) {

const nodeData = builder.getDataFromNode( this );
Expand Down Expand Up @@ -212,26 +220,26 @@ class Node extends EventDispatcher {
builder.addChain( this );

/* Build stages expected results:
- "construct" -> Node
- "setup" -> Node
- "analyze" -> null
- "generate" -> String
*/
let result = null;

const buildStage = builder.getBuildStage();

if ( buildStage === 'construct' ) {
if ( buildStage === 'setup' ) {

const properties = builder.getNodeProperties( this );

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

const stackNodesBeforeConstruct = builder.stack.nodes.length;
const stackNodesBeforeSetup = builder.stack.nodes.length;

properties.initialized = true;
properties.outputNode = this.construct( builder );
properties.outputNode = this.setup( builder );

if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeConstruct ) {
if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeSetup ) {

properties.outputNode = builder.stack;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ class NodeBuilder {

build() {

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

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/core/OutputStructNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class OutputStructNode extends Node {

}

construct( builder ) {
setup( builder ) {

super.construct( builder );
super.setup( builder );

const members = this.members;
const types = [];
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export const NodeType = {
};

export const defaultShaderStages = [ 'fragment', 'vertex' ];
export const defaultBuildStages = [ 'construct', 'analyze', 'generate' ];
export const defaultBuildStages = [ 'setup', 'analyze', 'generate' ];
export const shaderStages = [ ...defaultShaderStages, 'compute' ];
export const vectorComponents = [ 'x', 'y', 'z', 'w' ];
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/BlendModeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BlendModeNode extends TempNode {

}

construct() {
setup() {

const { blendMode, baseNode, blendNode } = this;
const params = { base: baseNode, blend: blendNode };
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/BumpMapNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BumpMapNode extends TempNode {

}

construct() {
setup() {

const bumpScale = this.scaleNode !== null ? this.scaleNode : 1;
const dHdxy = dHdxy_fwd( { bumpTexture: this.texture, bumpScale } );
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/ColorAdjustmentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ColorAdjustmentNode extends TempNode {

}

construct() {
setup() {

const { method, colorNode, adjustmentNode } = this;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/ColorSpaceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ColorSpaceNode extends TempNode {

}

construct() {
setup() {

const { method, node } = this;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/NormalMapNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class NormalMapNode extends TempNode {

}

construct( builder ) {
setup( builder ) {

const { normalMapType, scaleNode } = this;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/PosterizeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PosterizeNode extends TempNode {

}

construct() {
setup() {

const { sourceNode, stepsNode } = this;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/ToneMappingNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ToneMappingNode extends TempNode {

}

construct( builder ) {
setup( builder ) {

const colorNode = this.colorNode || builder.context.color;
const toneMapping = this.toneMapping;
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/ViewportDepthNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ViewportDepthNode extends Node {

}

construct( /*builder*/ ) {
setup( /*builder*/ ) {

const { scope } = this;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/display/ViewportNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ViewportNode extends Node {

}

construct( builder ) {
setup( builder ) {

const scope = this.scope;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/fog/FogExp2Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FogExp2Node extends FogNode {

}

construct() {
setup() {

const depthNode = positionView.z.negate();
const densityNode = this.densityNode;
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/fog/FogNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FogNode extends Node {

}

construct() {
setup() {

return this.factorNode;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/fog/FogRangeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FogRangeNode extends FogNode {

}

construct() {
setup() {

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

Expand Down

0 comments on commit 2ccc5bc

Please sign in to comment.