Skip to content

WebGLRenderer: Support FrustumArray. - #34275

Merged
Mugen87 merged 2 commits into
mrdoob:devfrom
Mugen87:dev1
Sep 9, 2026
Merged

Mugen87 merged 2 commits into
mrdoob:devfrom
Mugen87:dev1

Conversation

@Mugen87

@Mugen87 Mugen87 commented Aug 17, 2026 •

Copy link
Copy Markdown
Collaborator

Fixed #31672.
Fixed #16766.
Closes #31677

Description

The PR ensures WebGLRenderer supports FrustumArray. In this way, view frustum culling in XR happens like in WebGPURenderer per sub camera.

Now that we cull per camera, we can remove setProjectionFromUnion(). To keep ray casting in context of phone AR intact, the XR camera copies the projection matrix from the first sub camera by default.

Raycasting often uses setFromCamera() and that requires a correct projection matrix in the user camera. In VR, raycasting is normally done with the controllers and that involves no projection matrix. A Raycaster that should detect intersections along the look direction of the XR camera (gaze-style interaction) will now use the transformation and projection of the left eye only.

This must be noted in the migration guide.

/ping @cabanier

@Mugen87 Mugen87 added this to the r187 milestone Aug 17, 2026
@Mugen87
Mugen87 marked this pull request as draft August 17, 2026 10:52
@github-actions

Copy link
Copy Markdown

πŸ“¦ Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 372.19
87.91
371.55
87.71
-637 B
-200 B
WebGPU 698.62
192.75
697.85
192.49
-771 B
-261 B
WebGPU Nodes 696.61
192.44
695.84
192.18
-771 B
-262 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 515.61
124.86
516.14
124.89
+534 B
+24 B
WebGPU 772.8
207.59
772.02
207.33
-773 B
-265 B
WebGPU Nodes 721.76
194.9
720.99
194.64
-773 B
-260 B

@cabanier

Copy link
Copy Markdown
Contributor

This is a great cleanup! Do you want me to test it?

@Mugen87

Mugen87 commented Aug 17, 2026 •

Copy link
Copy Markdown
Collaborator Author

Yes, that would be good! Thank you!

My main concern is that the XR camera now carries different transformation and projection matrices (the one from the first sub camera) since these matrices are not derived from setProjectionFromUnion() anymore. But given that setProjectionFromUnion() has its own set of issues, the new approach seems more consistent.

The thing is: If somebody used the XR camera to setup an instance of Raycaster, the results with this PR will be slightly different. I'm not fully sure how much this matters but I think it shouldn't make much of a difference.

@cabanier

Copy link
Copy Markdown
Contributor

Yes, that would be good! Thank you!

I tried the examples of WebGL and WebGPU WebXR on my Quest 3 and they rendered correctly.

@harryhjsh

Copy link
Copy Markdown
Contributor

Quickly noting that #21002 shows some potential usage of the combined frustum (as noted in #31672).

My opinion is that literally raycasting from the combined frustum is probably just as unsatisfying as raycasting from the left camera would be. We could document a better solution in the migration guide if we could come up with one; a (totally untested) suggestion would be that exposing more of the XRViewerPose from frame.getViewerPose could make the 'forward' direction of the viewer themselves derivable (without relying on raycasting from an XRView at all).

@Mugen87
Mugen87 marked this pull request as ready for review September 9, 2026 07:11
@Mugen87
Mugen87 merged commit 7e21d6d into mrdoob:dev Sep 9, 2026
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.

WebXR: Frustum culling inconsistency between renderers setProjectionFromUnion makes incorrect assumptions

3 participants