Skip to content

TSL: Refine pow2/3/4 implementation and remove the polyfill for pow on Windows #31720

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 3 commits into from
Aug 23, 2025

Conversation

shotamatsuda
Copy link
Contributor

@shotamatsuda shotamatsuda commented Aug 23, 2025

Related issue: #31712

Description

This PR changes the implementation of pow2, pow3, and pow4 to be exact powers of 2, 3, and 4 respectively, regardless of the host implementation of pow.

Additionally, it removes the polyfill for pow on Windows, because it is only valid for odd integer exponents, as explained in the aforementioned issue. This does make the behavior of pow with odd integer exponents unstable on Windows, but it is a reasonable behavior and cannot be avoided unless introducing a precise detection of integer exponents in floating-point numbers.

Copy link

github-actions bot commented Aug 23, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.91
79.1
338.91
79.1
+0 B
+0 B
WebGPU 578.73
159.37
577.78
159.15
-942 B
-215 B
WebGPU Nodes 577.34
159.13
576.39
158.91
-942 B
-215 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 470.7
113.91
470.7
113.91
+0 B
+0 B
WebGPU 649.28
175.4
648.33
175.2
-954 B
-204 B
WebGPU Nodes 603.38
164.55
602.42
164.32
-960 B
-225 B

@sunag sunag added this to the r180 milestone Aug 23, 2025
@sunag
Copy link
Collaborator

sunag commented Aug 23, 2025

/cc @brunosimon

@sunag sunag merged commit 36c9890 into mrdoob:dev Aug 23, 2025
9 checks passed
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.

2 participants