Skip to content

Make camera controls script play nice with XR#7128

Merged
willeastcott merged 8 commits intomainfrom
xr-camera-controls
Dec 3, 2024
Merged

Make camera controls script play nice with XR#7128
willeastcott merged 8 commits intomainfrom
xr-camera-controls

Conversation

@willeastcott
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

@willeastcott
Copy link
Copy Markdown
Contributor Author

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

Needs testing - I'll do that today.

Comment thread scripts/esm/camera-controls.mjs Outdated

// Set the camera's position to the ground
const pos = this.entity.getPosition();
this.entity.setPosition(pos.x, 0, pos.z);
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: xr XR related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants