Skip to content

SphereGeometry: Make pole vertices more robust.#33652

Merged
Mugen87 merged 2 commits into
mrdoob:devfrom
Mugen87:dev2
May 27, 2026
Merged

SphereGeometry: Make pole vertices more robust.#33652
Mugen87 merged 2 commits into
mrdoob:devfrom
Mugen87:dev2

Conversation

@Mugen87
Copy link
Copy Markdown
Collaborator

@Mugen87 Mugen87 commented May 26, 2026

Related issue: #11449

Description

While revisiting #11449, I have noticed that even alternative ray casting approaches struggle with SphereGeometry because of how the pole vertices are computed. Math.sin( Math.PI ) produces no exact zero but something like 1.2246467991473532e-16 which means the vertices never lie exactly on the local y-axis. By snapping the south-pole vertices exactly to the y-axis, the broken ray/triangle intersection test from #11449 (see https://jsfiddle.net/zraqkg2f/3/) starts to work with our present algorithm.

Even outside of ray casting, this simple fix makes the vertex data a bit more robust and exact.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 365.43
86.79
365.43
86.79
+0 B
+0 B
WebGPU 661.52
182.6
661.52
182.6
+0 B
+0 B
WebGPU Nodes 659.56
182.3
659.56
182.3
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 498.49
121.58
498.49
121.58
+0 B
+0 B
WebGPU 732.76
197.41
732.76
197.43
-3 B
+19 B
WebGPU Nodes 681.98
184.81
681.98
184.83
-3 B
+20 B

Comment thread src/geometries/SphereGeometry.js Outdated
@Mugen87 Mugen87 added this to the r185 milestone May 27, 2026
@Mugen87 Mugen87 merged commit 373324d into mrdoob:dev May 27, 2026
10 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