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

feat: add teleportation support #263

Merged
merged 11 commits into from
Jul 2, 2023

Conversation

richardanaya
Copy link

@richardanaya richardanaya commented Mar 12, 2023

This PR adds two helpers for building teleportation experiences

useTeleportation - provides functionality for teleporting to global positions

<TeleportationPlane> - A simple plane based teleportation plane that can specify which hand to use as teleportation hand trigger, max distance from camera to teleport, and simple interaction visuals.

Demo: https://avatarposer.com/

com.oculus.browser-20230313-115217.mp4

Future ideas:

Allow for thumbstick to determine final direction so that you land with a specific rotation. That said, I think even just positional teleportation will be a boon to react-xr users.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 12, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2d75191:

Sandbox Source
examples Configuration

@richardanaya
Copy link
Author

richardanaya commented Mar 13, 2023

I take into account head pose relative to local_floor base reference frame ( I only use X and Z to preserve head height ), that way you always land right above the dot when you select at your correct head height.

@richardanaya richardanaya force-pushed the teleport branch 3 times, most recently from 9a364b4 to 4fc3e27 Compare March 13, 2023 01:01
@adamistheanswer
Copy link

This is awesome!

Copy link

@adamistheanswer adamistheanswer left a comment

Choose a reason for hiding this comment

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

I was unable to get the white circle indicator to render in my scene. I fixed this by manually declaring the Y axis as 0 in its mesh position

@richardanaya
Copy link
Author

richardanaya commented Mar 13, 2023

thanks! @adamistheanswer

@richardanaya
Copy link
Author

richardanaya commented Mar 13, 2023

Fixed warning messages as per build and added video of demo.

@saitonakamura
Copy link
Collaborator

@richardanaya awesome work! would you be so kind and add example of this to the examples/demos?

@richardanaya
Copy link
Author

@saitonakamura done! :)

@richardanaya
Copy link
Author

@CodyJasonBennett fixed!

Comment on lines 38 to 48
const offsetX = pose?.transform.position.x || 0
const offsetZ = pose?.transform.position.z || 0

const offsetFromBase = {
x: -worldPosition.x + offsetX,
y: -worldPosition.y,
z: -worldPosition.z + offsetZ
}
const transform = new XRRigidTransform(offsetFromBase, new Quaternion())
const teleportSpaceOffset = baseReferenceSpace.getOffsetReferenceSpace(transform)
xrManager.setReferenceSpace(teleportSpaceOffset)
Copy link
Member

@CodyJasonBennett CodyJasonBennett Mar 17, 2023

Choose a reason for hiding this comment

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

Can this be done by moving useXR().player or are there any ramifications in leaving pose unmodified?

Copy link
Author

@richardanaya richardanaya Mar 17, 2023

Choose a reason for hiding this comment

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

Hmm, I may not be the best person to answer this question about WebXR, but I think the reason for modifying XR reference space instead of player objects in WebXR is to handle weird device specific issues around player camera positioning. I think it may also come into play when we do anchors since they get poses relative to the base reference frame. I think there might be some complexity if we start asking for anchors relative to base reference and also modifying player. :)

@CodyJasonBennett CodyJasonBennett changed the title Adding teleportation support feat: add teleportation support Mar 30, 2023
@richardanaya
Copy link
Author

richardanaya commented Jul 1, 2023

Any thoughts on this? @saitonakamura @CodyJasonBennett

@CodyJasonBennett
Copy link
Member

I meant to triage this. I'll get back to it today and include in a minor.

@richardanaya
Copy link
Author

richardanaya commented Jul 1, 2023 via email

@CodyJasonBennett CodyJasonBennett merged commit a5e748b into pmndrs:master Jul 2, 2023
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