-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ensure camera clip planes are correctly applied during XR sessions #8464
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -268,6 +268,10 @@ class Camera { | |||||||||||||||
| this._farClip = newValue; | ||||||||||||||||
| this._projMatDirty = true; | ||||||||||||||||
| } | ||||||||||||||||
| if (this._xr?.active) { | ||||||||||||||||
| this._xrProperties.farClip = newValue; | ||||||||||||||||
| this._xr._setClipPlanes(this._xrProperties.nearClip, newValue); | ||||||||||||||||
|
||||||||||||||||
| this._xr._setClipPlanes(this._xrProperties.nearClip, newValue); | |
| const xr = this._xr; | |
| if (typeof xr.setClipPlanes === 'function') { | |
| xr.setClipPlanes(this._xrProperties.nearClip, newValue); | |
| } else if (typeof xr._setClipPlanes === 'function') { | |
| xr._setClipPlanes(this._xrProperties.nearClip, newValue); | |
| } |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When XR is active, this setter can change the effective near clip (via _xrProperties.nearClip) even if _nearClip already equals newValue (e.g., _xrProperties.nearClip derived from the XR view). In that case _projMatDirty is not set, so projectionMatrix can remain stale even though the getters now return different values. Consider setting _projMatDirty = true whenever _xrProperties.nearClip changes while XR is active (or include _xrProperties.nearClip in the equality check).
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same concern here as in farClip: calling the private XrManager method _setClipPlanes from Camera creates cross-module coupling. Prefer a public method on XrManager (or an event-based handoff) for updating the XR session depth near/far.
| this._xr._setClipPlanes(newValue, this._xrProperties.farClip); | |
| const xrManager = this._xr; | |
| if (typeof xrManager.setClipPlanes === 'function') { | |
| xrManager.setClipPlanes(newValue, this._xrProperties.farClip); | |
| } else if (typeof xrManager._setClipPlanes === 'function') { | |
| xrManager._setClipPlanes(newValue, this._xrProperties.farClip); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When XR is active, this setter can change the effective far clip (via
_xrProperties.farClip) even if_farClipalready equalsnewValue(e.g., if_xrProperties.farClipwas initialized from the XR view projection). In that case_projMatDirtyis not set, soprojectionMatrix(which uses the getters) can remain stale. Consider marking_projMatDirty = truewhenever_xrProperties.farClipchanges while XR is active (or broaden the equality check to include_xrProperties.farClip).