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

Make camera controls script play nice with XR #7128

Merged
merged 8 commits into from
Dec 3, 2024
Merged

Conversation

willeastcott
Copy link
Contributor

@willeastcott willeastcott commented Nov 21, 2024

  • Disable script update when XR session is active

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@mvaligursky
Copy link
Contributor

@willeastcott - good to merge or other plans with this?

@willeastcott
Copy link
Contributor Author

@willeastcott - good to merge or other plans with this?

Needs testing - I'll do that today.


// Set the camera's position to the ground
const pos = this.entity.getPosition();
this.entity.setPosition(pos.x, 0, pos.z);
Copy link
Collaborator

Choose a reason for hiding this comment

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

XR will override this position on every update, as now there is no parent node, offsetting the camera from origin is only done by moving in XR. So this line won't do anything.
For offsetting position in XR, a parent node is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I have removed that for now. Everything else OK?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This also implies that initial setup of a scene, should have camera at the origin, and content somewhere in front of it, to make sure when entering in XR we are not inside of a content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How should we handle that then? I don't want to reintroduce the magical hidden parent node in the camera-controls.mjs script again...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do a proper parent node for the camera entity. And only use it for XR (not camera orbiting). And reset it when exiting XR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I should create a new script called xr-navigation.mjs I guess...

@willeastcott willeastcott merged commit 9a00b94 into main Dec 3, 2024
8 checks passed
@willeastcott willeastcott deleted the xr-camera-controls branch December 3, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: xr XR related issue enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants