Skip to content

transpiler wrong name for 'for' , compile to 'while' but should be Loop #30908

@Makio64

Description

@Makio64

Description

It transpile for as While but it seems While was replaced by Loop, in my opinion it's good to have while & a For loop, as i dont immediatly understand it when i see the generic terms Loop but it might be only me, anyway the transpiler have a little problem here.

Reproduction steps

https://threejs.org/examples/webgpu_tsl_transpiler.html

Code

float test(){
	int i=0;
  	for(float i=0.; i<1.; i+=1.){
 		i++;
	}
	return i;
}

->

// Three.js Transpiler r175

import { int, float, While, Fn } from 'three/tsl';

export const test = /*#__PURE__*/ Fn( () => {

	const i = int( int( 0 ) ).toVar();

	{

		const i = float( 0. ).toVar();

		While( i.lessThan( 1. ), () => {

			i.increment();

			i.addAssign( 1. );

		} )

	}

	return i;

} ).setLayout( {
	name: 'test',
	type: 'float',
	inputs: []
} );

Live example

X

Screenshots

X

Version

r175

Device

No response

Browser

No response

OS

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TSLThree.js Shading Language

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions