Open
Description
Description
currently the transpiler seems not understanding the switch :
vec2 get_vertex(int id)
{
switch(id){
case 0: return vec2(1.);
case 1: return vec2(2.);
case 2: return vec2(3.);
case 3: return vec2(4.);
default: return vec2(0.);
}
}
transpile to :
import { int, Fn } from 'three/tsl';
export const get_vertex = /*#__PURE__*/ Fn( ( [ id_immutable ] ) => {
const id = int( id_immutable ).toVar();
switch( id );
} ).setLayout( {
name: 'get_vertex',
type: 'vec2',
inputs: [
{ name: 'id', type: 'int' }
]
} );
Edit : actually i'm not even sure switch
is supported by tsl cause it's not in the doc :
https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language
Live example
https://threejs.org/examples/webgpu_tsl_transpiler.html
Version
r175