Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPURenderer: Tree-Shaking 1/2 cleanup #29238

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export { default as ConstNode } from './core/ConstNode.js';
export { default as ContextNode } from './core/ContextNode.js';
export { default as IndexNode } from './core/IndexNode.js';
export { default as LightingModel } from './core/LightingModel.js';
export { default as Node } from './core/Node.js';
export { default as Node, registerNodeClass } from './core/Node.js';
export { default as VarNode } from './core/VarNode.js';
export { default as NodeAttribute } from './core/NodeAttribute.js';
export { default as NodeBuilder } from './core/NodeBuilder.js';
Expand Down
4 changes: 3 additions & 1 deletion src/nodes/accessors/TextureBicubic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { add, mul, div } from '../math/OperatorNode.js';
import { floor, ceil, fract, pow } from '../math/MathNode.js';
import { Fn, float, vec2, vec4, int } from '../tsl/TSLBase.js';
import { Fn, float, vec2, vec4, int, addMethodChaining } from '../tsl/TSLBase.js';

// Mipped Bicubic Texture Filtering by N8
// https://www.shadertoy.com/view/Dl2SDW
Expand Down Expand Up @@ -63,3 +63,5 @@ export const textureBicubic = Fn( ( [ textureNode, lodNode = float( 3 ) ] ) => {
return fract( lodNode ).mix( fSample, cSample );

} );

addMethodChaining( 'bicubic', bicubic );
4 changes: 3 additions & 1 deletion src/nodes/accessors/TextureSizeNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerNodeClass } from '../core/Node.js';
import Node from '../core/Node.js';
import { nodeProxy } from '../tsl/TSLBase.js';
import { addMethodChaining, nodeProxy } from '../tsl/TSLBase.js';

class TextureSizeNode extends Node {

Expand Down Expand Up @@ -31,3 +31,5 @@ export default TextureSizeNode;
registerNodeClass( 'TextureSize', TextureSizeNode );

export const textureSize = nodeProxy( TextureSizeNode );

addMethodChaining( 'textureSize', textureSize );
4 changes: 3 additions & 1 deletion src/nodes/display/BumpMapNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { uv } from '../accessors/UV.js';
import { normalView } from '../accessors/Normal.js';
import { positionView } from '../accessors/Position.js';
import { faceDirection } from './FrontFacingNode.js';
import { Fn, nodeProxy, float, vec2 } from '../tsl/TSLBase.js';
import { Fn, nodeProxy, float, vec2, addMethodChaining } from '../tsl/TSLBase.js';

// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
Expand Down Expand Up @@ -73,3 +73,5 @@ class BumpMapNode extends TempNode {
export default BumpMapNode;

export const bumpMap = nodeProxy( BumpMapNode );

addMethodChaining( 'bumpMap', bumpMap );
4 changes: 3 additions & 1 deletion src/nodes/display/FilmNode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { registerNodeClass } from '../core/Node.js';
import TempNode from '../core/TempNode.js';
import { uv } from '../accessors/UV.js';
import { Fn, nodeProxy, vec4 } from '../tsl/TSLBase.js';
import { addMethodChaining, Fn, nodeProxy, vec4 } from '../tsl/TSLBase.js';
import { mix, fract, clamp, rand } from '../math/MathNode.js';
import { timerLocal } from '../utils/TimerNode.js';

Expand Down Expand Up @@ -51,3 +51,5 @@ export default FilmNode;
registerNodeClass( 'Film', FilmNode );

export const film = nodeProxy( FilmNode );

addMethodChaining( 'film', film );
4 changes: 3 additions & 1 deletion src/nodes/display/NormalMapNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { positionView } from '../accessors/Position.js';
import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';
import { uv } from '../accessors/UV.js';
import { faceDirection } from './FrontFacingNode.js';
import { Fn, nodeProxy, vec3 } from '../tsl/TSLBase.js';
import { addMethodChaining, Fn, nodeProxy, vec3 } from '../tsl/TSLBase.js';

import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from '../../constants.js';

Expand Down Expand Up @@ -102,3 +102,5 @@ export default NormalMapNode;
registerNodeClass( 'NormalMap', NormalMapNode );

export const normalMap = nodeProxy( NormalMapNode );

addMethodChaining( 'normalMap', normalMap );
4 changes: 3 additions & 1 deletion src/nodes/display/PosterizeNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerNodeClass } from '../core/Node.js';
import TempNode from '../core/TempNode.js';
import { nodeProxy } from '../tsl/TSLBase.js';
import { addMethodChaining, nodeProxy } from '../tsl/TSLBase.js';

class PosterizeNode extends TempNode {

Expand Down Expand Up @@ -28,3 +28,5 @@ export default PosterizeNode;
registerNodeClass( 'Posterize', PosterizeNode );

export const posterize = nodeProxy( PosterizeNode );

addMethodChaining( 'posterize', posterize );
4 changes: 3 additions & 1 deletion src/nodes/math/Hash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fn } from '../tsl/TSLBase.js';
import { addMethodChaining, Fn } from '../tsl/TSLBase.js';

export const hash = Fn( ( [ seed ] ) => {

Expand All @@ -11,3 +11,5 @@ export const hash = Fn( ( [ seed ] ) => {
return result.toFloat().mul( 1 / 2 ** 32 ); // Convert to range [0, 1)

} );

addMethodChaining( 'hash', hash );
1 change: 1 addition & 0 deletions src/nodes/utils/Discard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export const Discard = ( conditional ) => ( conditional ? select( conditional, e
export const Return = () => expression( 'return' ).append();

addMethodChaining( 'discard', Discard );
addMethodChaining( 'return', Return );
5 changes: 4 additions & 1 deletion src/nodes/utils/LoopNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Node, { registerNodeClass } from '../core/Node.js';
import { expression } from '../code/ExpressionNode.js';
import { nodeObject, nodeArray } from '../tsl/TSLBase.js';
import { nodeObject, nodeArray, addMethodChaining } from '../tsl/TSLBase.js';

class LoopNode extends Node {

Expand Down Expand Up @@ -197,6 +197,9 @@ export const Loop = ( ...params ) => nodeObject( new LoopNode( nodeArray( params
export const Continue = () => expression( 'continue' ).append();
export const Break = () => expression( 'break' ).append();

addMethodChaining( 'continue', Continue );
addMethodChaining( 'break', Break );

//

export const loop = ( ...params ) => { // @deprecated, r168
Expand Down
7 changes: 6 additions & 1 deletion src/nodes/utils/OscNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Node, { registerNodeClass } from '../core/Node.js';
import { timerLocal } from './TimerNode.js';
import { nodeObject, nodeProxy } from '../tsl/TSLBase.js';
import { addMethodChaining, nodeObject, nodeProxy } from '../tsl/TSLBase.js';

class OscNode extends Node {

Expand Down Expand Up @@ -79,3 +79,8 @@ export const oscSine = nodeProxy( OscNode, OscNode.SINE );
export const oscSquare = nodeProxy( OscNode, OscNode.SQUARE );
export const oscTriangle = nodeProxy( OscNode, OscNode.TRIANGLE );
export const oscSawtooth = nodeProxy( OscNode, OscNode.SAWTOOTH );

addMethodChaining( 'oscSine', oscSine );
addMethodChaining( 'oscSquare', oscSquare );
addMethodChaining( 'oscTriangle', oscTriangle );
addMethodChaining( 'oscSawtooth', oscSawtooth );
4 changes: 3 additions & 1 deletion src/nodes/utils/RotateNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerNodeClass } from '../core/Node.js';
import TempNode from '../core/TempNode.js';
import { nodeProxy, vec4, mat2, mat4 } from '../tsl/TSLBase.js';
import { nodeProxy, vec4, mat2, mat4, addMethodChaining } from '../tsl/TSLBase.js';
import { cos, sin } from '../math/MathNode.js';

class RotateNode extends TempNode {
Expand Down Expand Up @@ -58,3 +58,5 @@ export default RotateNode;
registerNodeClass( 'Rotate', RotateNode );

export const rotate = nodeProxy( RotateNode );

addMethodChaining( 'rotate', rotate );
4 changes: 3 additions & 1 deletion src/nodes/utils/TriplanarTexturesNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { add } from '../math/OperatorNode.js';
import { normalLocal } from '../accessors/Normal.js';
import { positionLocal } from '../accessors/Position.js';
import { texture } from '../accessors/TextureNode.js';
import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
import { nodeProxy, float, vec3, addMethodChaining } from '../tsl/TSLBase.js';

class TriplanarTexturesNode extends Node {

Expand Down Expand Up @@ -58,3 +58,5 @@ registerNodeClass( 'TriplanarTextures', TriplanarTexturesNode );

export const triplanarTextures = nodeProxy( TriplanarTexturesNode );
export const triplanarTexture = ( ...params ) => triplanarTextures( ...params );

addMethodChaining( 'triplanarTexture', triplanarTexture );