Skip to content

TSL: Improve vec* checks and warnings #30811

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

Merged
merged 1 commit into from
Mar 27, 2025
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
4 changes: 2 additions & 2 deletions src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2614,13 +2614,13 @@ class NodeBuilder {

if ( fromTypeLength === 16 && toTypeLength === 9 ) {

return `${ this.getType( toType ) }(${ snippet }[0].xyz, ${ snippet }[1].xyz, ${ snippet }[2].xyz)`;
return `${ this.getType( toType ) }( ${ snippet }[ 0 ].xyz, ${ snippet }[ 1 ].xyz, ${ snippet }[ 2 ].xyz )`;

}

if ( fromTypeLength === 9 && toTypeLength === 4 ) {

return `${ this.getType( toType ) }(${ snippet }[0].xy, ${ snippet }[1].xy)`;
return `${ this.getType( toType ) }( ${ snippet }[ 0 ].xy, ${ snippet }[ 1 ].xy )`;

}

Expand Down
4 changes: 2 additions & 2 deletions src/nodes/tsl/TSLCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export function addMethodChaining( name, nodeElement ) {

if ( NodeElements.has( name ) ) {

console.warn( `Redefinition of method chaining ${ name }` );
console.warn( `THREE.TSL: Redefinition of method chaining '${ name }'.` );
return;

}

if ( typeof nodeElement !== 'function' ) throw new Error( `Node element ${ name } is not a function` );
if ( typeof nodeElement !== 'function' ) throw new Error( `THREE.TSL: Node element ${ name } is not a function` );

NodeElements.set( name, nodeElement );

Expand Down
29 changes: 27 additions & 2 deletions src/nodes/utils/JoinNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,42 @@ class JoinNode extends TempNode {
generate( builder, output ) {

const type = this.getNodeType( builder );
const maxLength = builder.getTypeLength( type );

const nodes = this.nodes;

const primitiveType = builder.getComponentType( type );

const snippetValues = [];

let length = 0;

for ( const input of nodes ) {

let inputSnippet = input.build( builder );
if ( length >= maxLength ) {

console.error( 'THREE.TSL: Length of parameters exceeds maximum length of function type.' );
break;

}

let inputType = input.getNodeType( builder );
let inputTypeLength = builder.getTypeLength( inputType );
let inputSnippet;

if ( length + inputTypeLength > maxLength ) {

console.error( 'THREE.TSL: Length of joined data exceeds maximum length of output type.' );

inputTypeLength = maxLength - length;
inputType = builder.getTypeFromLength( inputTypeLength );

}

length += inputTypeLength;
inputSnippet = input.build( builder, inputType );

const inputPrimitiveType = builder.getComponentType( input.getNodeType( builder ) );
const inputPrimitiveType = builder.getComponentType( inputType );

if ( inputPrimitiveType !== primitiveType ) {

Expand Down