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

Nodes: Remove keywords #29129

Merged
merged 1 commit into from
Aug 14, 2024
Merged
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
3 changes: 1 addition & 2 deletions examples/webgpu_materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
material.colorNode = someWGSLFn( { color: texture( uvTexture ) } );
materials.push( material );

// Custom WGSL ( get texture from keywords )
// Custom WGSL

const getWGSLTextureSample = wgslFn( `
fn getWGSLTextureSample( tex: texture_2d<f32>, tex_sampler: sampler, uv:vec2<f32> ) -> vec4<f32> {
Expand All @@ -194,7 +194,6 @@
` );

const textureNode = texture( uvTexture );
//getWGSLTextureSample.keywords = { tex: textureNode, tex_sampler: sampler( textureNode ) };

material = new THREE.MeshBasicNodeMaterial();
material.colorNode = getWGSLTextureSample( { tex: textureNode, tex_sampler: textureNode, uv: uv() } );
Expand Down
1 change: 0 additions & 1 deletion src/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export { default as NodeCache } from './core/NodeCache.js';
export { default as NodeCode } from './core/NodeCode.js';
export { default as NodeFrame } from './core/NodeFrame.js';
export { default as NodeFunctionInput } from './core/NodeFunctionInput.js';
export { default as NodeKeywords } from './core/NodeKeywords.js';
export { default as NodeUniform } from './core/NodeUniform.js';
export { default as NodeVar } from './core/NodeVar.js';
export { default as NodeVarying } from './core/NodeVarying.js';
Expand Down
20 changes: 1 addition & 19 deletions src/nodes/code/FunctionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class FunctionNode extends CodeNode {

super( code, includes, language );

this.keywords = {};

}

getNodeType( builder ) {
Expand Down Expand Up @@ -63,23 +61,7 @@ class FunctionNode extends CodeNode {

const propertyName = builder.getPropertyName( nodeCode );

let code = this.getNodeFunction( builder ).getCode( propertyName );

const keywords = this.keywords;
const keywordsProperties = Object.keys( keywords );

if ( keywordsProperties.length > 0 ) {

for ( const property of keywordsProperties ) {

const propertyRegExp = new RegExp( `\\b${property}\\b`, 'g' );
const nodeProperty = keywords[ property ].build( builder, 'property' );

code = code.replace( propertyRegExp, nodeProperty );

}

}
const code = this.getNodeFunction( builder ).getCode( propertyName );

nodeCode.code = code + '\n';

Expand Down
3 changes: 0 additions & 3 deletions src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import NodeAttribute from './NodeAttribute.js';
import NodeVarying from './NodeVarying.js';
import NodeVar from './NodeVar.js';
import NodeCode from './NodeCode.js';
import NodeKeywords from './NodeKeywords.js';
import NodeCache from './NodeCache.js';
import ParameterNode from './ParameterNode.js';
import FunctionNode from '../code/FunctionNode.js';
Expand Down Expand Up @@ -113,7 +112,6 @@ class NodeBuilder {
this.currentFunctionNode = null;

this.context = {
keywords: new NodeKeywords(),
material: this.material
};

Expand Down Expand Up @@ -402,7 +400,6 @@ class NodeBuilder {

const context = { ...this.context };

delete context.keywords;
delete context.material;

return this.context;
Expand Down
80 changes: 0 additions & 80 deletions src/nodes/core/NodeKeywords.js

This file was deleted.