Skip to content

TSL: Fix Fn as parameter #31214

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
Jun 1, 2025
Merged

TSL: Fix Fn as parameter #31214

merged 1 commit into from
Jun 1, 2025

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jun 1, 2025

Fixes #31212

Description

Fix Fn as parameter. e.g:

const bar = Fn(([r, g, b]) => {
    return vec3(r, g, b)
})

const foo = Fn(([baz]) => {
    return baz(0.1, 0.2, 0.3)
})

const material = new THREE.NodeMaterial()
material.fragmentNode = foo(bar)

@sunag sunag added this to the r178 milestone Jun 1, 2025
Copy link

github-actions bot commented Jun 1, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 337.4
78.67
337.4
78.67
+0 B
+0 B
WebGPU 553.81
153.47
553.83
153.48
+19 B
+10 B
WebGPU Nodes 553.16
153.32
553.18
153.33
+19 B
+10 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 468.59
113.32
468.59
113.32
+0 B
+0 B
WebGPU 628.77
170.2
628.78
170.21
+19 B
+11 B
WebGPU Nodes 583.62
159.54
583.64
159.55
+19 B
+12 B

@sunag sunag marked this pull request as ready for review June 1, 2025 21:36
@sunag sunag merged commit a1db039 into mrdoob:dev Jun 1, 2025
12 checks passed
@sunag sunag deleted the dev-fix-fn-as-parameter branch June 1, 2025 21:36
@mrdoob
Copy link
Owner

mrdoob commented Jun 2, 2025

Should we release 0.177.1 with this fix?

@sunag
Copy link
Collaborator Author

sunag commented Jun 2, 2025

I'm not sure if it's necessary because it's not very common to use TSL functions as parameters yet. Maybe we could wait in case someone else reports this? Unless we have other pending fixes.

@mrdoob
Copy link
Owner

mrdoob commented Jun 3, 2025

Okay!

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 r177, can no longer pass a callback Fn as a Fn parameter as was possible in r176
2 participants