Skip to content

Conversation

@myers
Copy link

@myers myers commented Dec 4, 2025

Summary

XRLayers were incorrectly positioned when inside components that override updateWorldMatrix (e.g., UIKit's Content component which applies layout transforms like globalMatrix and childrenMatrix).

The bug: Compositor layers appeared at wrong positions while fallback meshes rendered correctly.

Root cause: The previous implementation accumulated local matrices via premultiply(object.matrix), which missed any custom transforms applied during updateWorldMatrix().

The fix: Switch to using matrixWorld directly after calling updateWorldMatrix(true, false), ensuring any custom matrix computations are properly reflected in XRLayer positioning.

Test plan

  • Tested XRLayers inside UIKit Content components on Quest 3 hardware
  • Verified both compositor layers now appear at correct positions (matching fallback meshes)
  • Tested standalone XRLayers (not inside UIKit) still work correctly

@bbohlender
Copy link
Collaborator

thanks, the PR looks good, but as explained before using "blendTextureSourceAlpha" and transparency as synonym is not correct

However, I do not see a reason to change so much:

the offset calculation could still happen inside getXRSpaceFromAncestorsRec limiting the fix to this one function (I prefer minimal PRs or a reason why a bigger change is necassary)

@myers myers force-pushed the fix/xrlayer-uikit-world-matrix branch from e16f043 to e9f756a Compare December 5, 2025 15:15
@myers myers force-pushed the fix/xrlayer-uikit-world-matrix branch from ac4cd7b to 8af02f1 Compare December 5, 2025 22:13
@myers
Copy link
Author

myers commented Dec 5, 2025

thanks, the PR looks good, but as explained before using "blendTextureSourceAlpha" and transparency as synonym is not correct

Sorry about that it was a zombie commit 🧟

@myers
Copy link
Author

myers commented Dec 5, 2025

@bbohlender I think this is ready for your review again.

// Calculate offset using world matrices instead of accumulating local matrices.
// This correctly handles components that override updateWorldMatrix (e.g., UIKit Content).
if (targetOffsetMatrix != null) {
targetObject.updateWorldMatrix(true, false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be executed in getSoaceFromAncestors or else we would immediately conflict with the requirement

In this function we do not know that targetObject is the child of object but in getSpaceFromAncestors, we know this so executing upateMatrixWorld once is enough

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for clarifying, I misunderstood what you had said on the previous version.

Move updateWorldMatrix call from getXRSpaceFromAncestorsRec to
getSpaceFromAncestors, ensuring world matrices are up to date before
traversing ancestors. This correctly handles components that override
updateWorldMatrix (e.g., UIKit Content) and satisfies the @requires
precondition on getXRSpaceFromAncestorsRec.
@myers myers force-pushed the fix/xrlayer-uikit-world-matrix branch from 8af02f1 to 9f04ac2 Compare December 6, 2025 22:15
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