Skip to content
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

WebXRManager: Decompose cameraVR.matrixWorld #21964

Merged
merged 2 commits into from
Jun 9, 2021
Merged

WebXRManager: Decompose cameraVR.matrixWorld #21964

merged 2 commits into from
Jun 9, 2021

Conversation

mrdoob
Copy link
Owner

@mrdoob mrdoob commented Jun 9, 2021

@mrdoob mrdoob added this to the r130 milestone Jun 9, 2021
@mrdoob mrdoob changed the title Webxr WebXRManager: Decompose cameraVR.matrixWorld Jun 9, 2021
@mrdoob mrdoob merged commit 31565e6 into dev Jun 9, 2021
@mrdoob mrdoob deleted the webxr branch June 9, 2021 08:58
@elalish
Copy link
Contributor

elalish commented Jun 10, 2021

Thanks!

@zalo
Copy link
Contributor

zalo commented Aug 18, 2021

Looks like this PR causes a bug whenever you move the Camera's parent (because the cameraVR's World Matrix is being decomposed/copied into cameraVR+camera's Local Position/Quaternion/Scale). I encountered this when testing out a VR Locomotion method that relies on moving the rendering camera's parent.

@elalish I don't fully understand the comment that lead to this; What was wrong with the old method?

zalo added a commit to zalo/three.js that referenced this pull request Aug 18, 2021
This PR attempts to move XR Camera calculations back into local space by undoing mrdoob#21964 (which appears to conflate `matrixWorld` and `matrix`).

This enables the XR camera to be parented to another object again without odd behavior.

If this isn't the correct fix; I'd be happy to test alternatives in the context of my application.
@elalish
Copy link
Contributor

elalish commented Aug 19, 2021

The WebXR manager was updating most, but not all of the vr camera state; specifically it was missing the decompose, which forced apps to do it themselves separately (and debugging to figure out what was happening was pretty tricky). I haven't thought about the re-parenting aspect; there may well be a better way, but we should not revert to the old way.

@zalo
Copy link
Contributor

zalo commented Aug 19, 2021

That is, it wasn’t setting the xrCamera’s position, rotation, and scale? (Was there anything wrong with the normal camera’s transform data?)

If the issue was the normal camera, then rather than copying the worldMatrix between the two, would it be acceptable to continue copying only the local matrix (with local pos/rot/scale), but then force the camera to recalculate its world matrix from that and it’s hierarchy?

@elalish
Copy link
Contributor

elalish commented Aug 19, 2021

That is, it wasn’t setting the xrCamera’s position, rotation, and scale?

Yes, that was the problem.

If the issue was the normal camera, then rather than copying the worldMatrix between the two, would it be acceptable to continue copying only the local matrix (with local pos/rot/scale), but then force the camera to recalculate its world matrix from that and it’s hierarchy?

Maybe? As long as the two cameras' states are in sync, I think I'll be happy.

@DePasqualeOrg
Copy link

DePasqualeOrg commented Oct 30, 2021

I noticed recently that when I exit immersive mode, the location of the camera changes, and when I enter immersive mode again it goes back to where it should be. Could that be related to this issue?

This behavior occurs on the VR rollercoaster example, for instance, where the camera is parented.

Edit: Pending pull request #22362 appears to fix this bug.

mrdoob pushed a commit that referenced this pull request Aug 16, 2022
This PR attempts to move XR Camera calculations back into local space by undoing #21964 (which appears to conflate `matrixWorld` and `matrix`).

This enables the XR camera to be parented to another object again without odd behavior.

If this isn't the correct fix; I'd be happy to test alternatives in the context of my application.
abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
…b#22362)

This PR attempts to move XR Camera calculations back into local space by undoing mrdoob#21964 (which appears to conflate `matrixWorld` and `matrix`).

This enables the XR camera to be parented to another object again without odd behavior.

If this isn't the correct fix; I'd be happy to test alternatives in the context of my application.
snagy pushed a commit to snagy/three.js-1 that referenced this pull request Sep 21, 2022
…b#22362)

This PR attempts to move XR Camera calculations back into local space by undoing mrdoob#21964 (which appears to conflate `matrixWorld` and `matrix`).

This enables the XR camera to be parented to another object again without odd behavior.

If this isn't the correct fix; I'd be happy to test alternatives in the context of my application.
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.

4 participants