Skip to content

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Apr 17, 2025

Fixes #30945

Description

Add expression support for loop( { update: ... } )

// GLSL
for ( int i = 0; i < 10; i += 2 ) { }

// TSL
Loop( { start: 0, end: 10, update: 2 }, () => {} );


// GLSL
for ( int i = 0; i < 10; i += j + 2 ) { }

// TSL
Loop( { start: 0, end: 10, update: ( { i } ) => i.addAssign( j.add( 2 ) ) }, () => {} );

@sunag sunag added this to the r176 milestone Apr 17, 2025
Copy link

github-actions bot commented Apr 17, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.33
78.33
336.33
78.33
+0 B
+0 B
WebGPU 545.17
151.06
545.64
151.26
+467 B
+198 B
WebGPU Nodes 544.52
150.91
544.99
151.1
+467 B
+198 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.48
112.23
465.48
112.23
+0 B
+0 B
WebGPU 618.8
167.34
619.26
167.56
+467 B
+215 B
WebGPU Nodes 573.67
156.68
574.13
156.86
+467 B
+179 B

@sunag sunag marked this pull request as ready for review April 17, 2025 21:13
@sunag sunag merged commit b2e0b0c into mrdoob:dev Apr 18, 2025
12 checks passed
@sunag sunag deleted the dev-loop-update branch April 18, 2025 00:08
@sunag sunag changed the title TSL: Add expression support for loop( { update: ... } ) TSL: Add expression support for Loop( { update: ... } ) Apr 22, 2025
RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
* add expression support for `loop()` update

* Raymarching: update with new approach

* TSLEncoder: update with new approach

* rev

* rev
RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
* add expression support for `loop()` update

* Raymarching: update with new approach

* TSLEncoder: update with new approach

* rev

* rev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tsl transpiler : loop doesn't work with node variable
1 participant