Skip to content
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
10 changes: 9 additions & 1 deletion examples/jsm/transpiler/GLSLDecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const unaryOperators = [
'+', '-', '~', '!', '++', '--'
];

const arithmeticOperators = [
'*', '/', '%', '+', '-', '<<', '>>'
];

const precedenceOperators = [
'*', '/', '%',
'-', '+',
Expand Down Expand Up @@ -328,7 +332,11 @@ class GLSLDecoder {
if ( ! token.isOperator || i === 0 || i === tokens.length - 1 ) return;

// important for negate operator after arithmetic operator: a * -1, a * -( b )
if ( ( inverse && tokens[ i - 1 ].isOperator ) || ( ! inverse && tokens[ i + 1 ].isOperator ) ) return;
if ( ( inverse && arithmeticOperators.includes( tokens[ i - 1 ].str ) ) || ( ! inverse && arithmeticOperators.includes( tokens[ i + 1 ].str ) ) ) {

return;

}

if ( groupIndex === 0 && token.str === operator ) {

Expand Down
21 changes: 4 additions & 17 deletions examples/jsm/transpiler/TSLEncoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class TSLEncoder {
this.global = new Set();
this.overloadings = new Map();
this.iife = false;
this.uniqueNames = false;
this.reference = false;

this._currentVariable = null;
Expand Down Expand Up @@ -726,8 +725,6 @@ ${ this.tab }} )`;

for ( const param of node.params ) {

let str = `{ name: '${ param.name }', type: '${ param.type }'`;

let name = param.name;

if ( param.immutable === false && ( param.qualifier !== 'inout' && param.qualifier !== 'out' ) ) {
Expand All @@ -746,11 +743,9 @@ ${ this.tab }} )`;

}

str += ', qualifier: \'' + param.qualifier + '\'';

}

inputs.push( str + ' }' );
inputs.push( param.name + ': \'' + param.type + '\'' );
params.push( name );

this._currentProperties[ name ] = param;
Expand Down Expand Up @@ -795,23 +790,15 @@ ${ this.tab }} )`;

${ bodyStr }

${ this.tab }} )`;

const layoutInput = inputs.length > 0 ? '\n\t\t' + this.tab + inputs.join( ',\n\t\t' + this.tab ) + '\n\t' + this.tab : '';
${ this.tab }}`;

if ( node.layout !== false && hasPointer === false ) {

const uniqueName = this.uniqueNames ? fnName + '_' + Math.random().toString( 36 ).slice( 2 ) : fnName;

funcStr += `.setLayout( {
${ this.tab }\tname: '${ uniqueName }',
${ this.tab }\ttype: '${ type }',
${ this.tab }\tinputs: [${ layoutInput }]
${ this.tab }} )`;
funcStr += ', { ' + inputs.join( ', ' ) + ', return: \'' + type + '\' }';

}

funcStr += ';\n';
funcStr += ' );\n';

this.imports.add( 'Fn' );

Expand Down