Skip to content

Commit

Permalink
TSL: Rename .varying -> .toVarying and .vertexStage -> `.toVert…
Browse files Browse the repository at this point in the history
…exStage` (mrdoob#30356)
  • Loading branch information
sunag authored Jan 18, 2025
1 parent f7be954 commit a3b6b0e
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/nodes/accessors/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { uniformArray } from './UniformArrayNode.js';
*
* @type {UniformNode<uint>}
*/
export const cameraIndex = /*@__PURE__*/ uniform( 'uint' ).setGroup( sharedUniformGroup( 'cameraIndex' ) ).vertexStage();
export const cameraIndex = /*@__PURE__*/ uniform( 0, 'uint' ).setGroup( sharedUniformGroup( 'cameraIndex' ) ).toVarying( 'v_cameraIndex' );

/**
* TSL object that represents the `near` value of the camera used for the current render.
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/accessors/ModelViewProjectionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export const modelViewProjection = /*@__PURE__*/ ( Fn( ( builder ) => {

return builder.context.setupModelViewProjection();

}, 'vec4' ).once() )().varying( 'v_modelViewProjection' );
}, 'vec4' ).once() )().toVarying( 'v_modelViewProjection' );
12 changes: 6 additions & 6 deletions src/nodes/accessors/Position.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ export const positionGeometry = /*@__PURE__*/ attribute( 'position', 'vec3' );
*
* @type {AttributeNode<vec3>}
*/
export const positionLocal = /*@__PURE__*/ positionGeometry.varying( 'positionLocal' );
export const positionLocal = /*@__PURE__*/ positionGeometry.toVarying( 'positionLocal' );

/**
* TSL object that represents the previous vertex position in local space of the current rendered object.
* Used in context of {@link module:VelocityNode~VelocityNode} for rendering motion vectors.
*
* @type {AttributeNode<vec3>}
*/
export const positionPrevious = /*@__PURE__*/ positionGeometry.varying( 'positionPrevious' );
export const positionPrevious = /*@__PURE__*/ positionGeometry.toVarying( 'positionPrevious' );

/**
* TSL object that represents the vertex position in world space of the current rendered object.
*
* @type {VaryingNode<vec3>}
*/
export const positionWorld = /*@__PURE__*/ modelWorldMatrix.mul( positionLocal ).xyz.varying( 'v_positionWorld' ).context( { needsPositionReassign: true } );
export const positionWorld = /*@__PURE__*/ modelWorldMatrix.mul( positionLocal ).xyz.toVarying( 'v_positionWorld' ).context( { needsPositionReassign: true } );

/**
* TSL object that represents the position world direction of the current rendered object.
*
* @type {Node<vec3>}
*/
export const positionWorldDirection = /*@__PURE__*/ positionLocal.transformDirection( modelWorldMatrix ).varying( 'v_positionWorldDirection' ).normalize().toVar( 'positionWorldDirection' ).context( { needsPositionReassign: true } );
export const positionWorldDirection = /*@__PURE__*/ positionLocal.transformDirection( modelWorldMatrix ).toVarying( 'v_positionWorldDirection' ).normalize().toVar( 'positionWorldDirection' ).context( { needsPositionReassign: true } );

/**
* TSL object that represents the vertex position in view space of the current rendered object.
Expand All @@ -49,11 +49,11 @@ export const positionView = /*@__PURE__*/ ( Fn( ( builder ) => {

return builder.context.setupPositionView();

}, 'vec3' ).once() )().varying( 'v_positionView' ).context( { needsPositionReassign: true } );
}, 'vec3' ).once() )().toVarying( 'v_positionView' ).context( { needsPositionReassign: true } );

/**
* TSL object that represents the position view direction of the current rendered object.
*
* @type {VaryingNode<vec3>}
*/
export const positionViewDirection = /*@__PURE__*/ positionView.negate().varying( 'v_positionViewDirection' ).normalize().toVar( 'positionViewDirection' );
export const positionViewDirection = /*@__PURE__*/ positionView.negate().toVarying( 'v_positionViewDirection' ).normalize().toVar( 'positionViewDirection' );
4 changes: 2 additions & 2 deletions src/nodes/accessors/Tangent.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export const tangentLocal = /*@__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLoc
*
* @type {Node<vec3>}
*/
export const tangentView = /*@__PURE__*/ modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.varying( 'v_tangentView' ).normalize().toVar( 'tangentView' );
export const tangentView = /*@__PURE__*/ modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.toVarying( 'v_tangentView' ).normalize().toVar( 'tangentView' );

/**
* TSL object that represents the vertex tangent in world space of the current rendered object.
*
* @type {Node<vec3>}
*/
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).varying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).toVarying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );

/**
* TSL object that represents the transformed vertex tangent in view space of the current rendered object.
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ class NodeBuilder {

}

// deprecated
// Deprecated

/**
* @function
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/core/StackNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class StackNode extends Node {

}

// deprecated
// Deprecated

/**
* @function
Expand Down
22 changes: 19 additions & 3 deletions src/nodes/core/VaryingNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
* existing nodes like the following:
*
* ```js
* const positionLocal = positionGeometry.varying( 'vPositionLocal' );
* const positionLocal = positionGeometry.toVarying( 'vPositionLocal' );
* ```
*
* @augments Node
Expand Down Expand Up @@ -185,5 +185,21 @@ export const varying = /*@__PURE__*/ nodeProxy( VaryingNode );
*/
export const vertexStage = ( node ) => varying( node );

addMethodChaining( 'varying', varying );
addMethodChaining( 'vertexStage', vertexStage );
addMethodChaining( 'toVarying', varying );
addMethodChaining( 'toVertexStage', vertexStage );

// Deprecated

addMethodChaining( 'varying', ( ...params ) => { // @deprecated, r173

console.warn( 'TSL.VaryingNode: .varying() has been renamed to .toVarying().' );
return varying( ...params );

} );

addMethodChaining( 'vertexStage', ( ...params ) => { // @deprecated, r173

console.warn( 'TSL.VaryingNode: .vertexStage() has been renamed to .toVertexStage().' );
return varying( ...params );

} );
2 changes: 1 addition & 1 deletion src/nodes/display/BlendModes.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const blendColor = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
]
} );

// deprecated
// Deprecated

/**
* @function
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/math/ConditionalNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const select = /*@__PURE__*/ nodeProxy( ConditionalNode );

addMethodChaining( 'select', select );

// deprecated
// Deprecated

/**
* @function
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/utils/LoopNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const Continue = () => expression( 'continue' ).append();
*/
export const Break = () => expression( 'break' ).append();

// deprecated
// Deprecated

/**
* @function
Expand Down

0 comments on commit a3b6b0e

Please sign in to comment.