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

XR seems to be taking control over any camera #52

Closed
ablaszkiewicz opened this issue May 14, 2021 · 3 comments
Closed

XR seems to be taking control over any camera #52

ablaszkiewicz opened this issue May 14, 2021 · 3 comments

Comments

@ablaszkiewicz
Copy link

ablaszkiewicz commented May 14, 2021

I have created simple AR demo with portal - it works fine in web browser with AR disabled. Portal renders object placed in paralell scene and when I move arround it doesn't change position (as intended).

When I move to AR and launch this app on my phone strange things are happening. It seems like portal is rendering stuff based on my phone position. I have added a THREE.CameraHelper to see what is going on and it seems that XR takes control over my other-dimension camera and snaps its position and rotation to my device position and rotation.

I thought that maybe it just takes first camera created from code and sets is as an XR camera which is used to displaying thus I have created another dummyCamera. It turns out that no matter how many cameras I create (these cameras aren't even on current THREE.Scene), XR always takes control over them and snaps them to device transform

On PC with AR disabled I can see cameras' wireframes by using THREE.CameraHelper and on phone I can just see this helper stick to my position. How do I tell XR not to control cameras?

@MaartenBreeedveld
Copy link

MaartenBreeedveld commented Jun 23, 2021

I'm not sure if this is react-xr related or ThreeJS behaviour.
A suggestion perhaps: have you tried creating an actual react portal?

@CodyJasonBennett
Copy link
Member

Can you provide a reproduction?

@jure
Copy link

jure commented Jul 25, 2021

I'm seeing the same thing. I think it's a Three.js issue. It gets updated due to https://github.com/mrdoob/three.js/blob/d0340e3a147e290fa86d14bc3ed97d8e1c20602e/src/renderers/WebGLRenderer.js#L983-L989

A workaround, if you have access to where the rendering is happening, is to flip the cameraAutoUpdate off before rendering:

state.gl.xr.cameraAutoUpdate = false
state.gl.render(scene, state.camera)
state.gl.xr.cameraAutoUpdate = true

I think Three.js should check if the camera that it wants to update is the state.camera and not just any camera. I'll think about it a bit more and submit a PR, if it checks out.

Here's a repro: https://codesandbox.io/s/react-xr-issue-52-repro-0m65f

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

No branches or pull requests

4 participants