-
Notifications
You must be signed in to change notification settings - Fork 489
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
Add body tracking sample #178
base: main
Are you sure you want to change the base?
Conversation
This is amazing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you said, this is just an FYI for now but I've got some comments for you anyway!
|
||
<meta http-equiv="origin-trial" content="Ahfj+MLeL6bh+LNmpnSdepftxoDHHwjUG2KWZ4jjCb1WoZxtBlzF3cDHuJNVqnhr3HXJwQ+kLaw57NO15S0mRwwAAABkeyJvcmlnaW4iOiJodHRwczovL2ltbWVyc2l2ZS13ZWIuZ2l0aHViLmlvOjQ0MyIsImZlYXR1cmUiOiJXZWJYUlBsYW5lRGV0ZWN0aW9uIiwiZXhwaXJ5IjoxNjI5ODQ5NTk5fQ=="> | ||
|
||
<title>AR Plane Detection</title> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update title
proposals/body-tracking.html
Outdated
scene = new THREE.Scene(); | ||
scene.background = new THREE.Color( 0x505050 ); | ||
|
||
camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 50 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is kind of all over the place in this sample. Seems like you've probably got your editor set to tabs and these files use spaces? It'd be appreciated if you could normalize it.
document.querySelector('header').appendChild(xrButton.domElement); | ||
|
||
if (navigator.xr) { | ||
navigator.xr.isSessionSupported('immersive-ar') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this functionality only available in AR on Quest? If not, is there any way can we make this demo work in either AR or VR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cabanier Sorry, let me rephrase. Is the WebXR implementation in the browser providing you all the information for the body tracking? Using the body-tracking
feature? Or you are generating this information somewhere else and injecting in the browser? I am asking because body-tracking
is not officially described/supported by the WebXR specification.
I am just very curious to understand where the bones positions/rotations comes from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cabanier Sorry, let me rephrase. Is the WebXR implementation in the browser providing you all the information for the body tracking? Using the
body-tracking
feature? Or you are generating this information somewhere else and injecting in the browser?
It's a new extension to WebXR that I'm proposing: https://cabanier.github.io/webxr-body-tracking/
It uses Meta's body tracking OpenXR implementation under the hood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cabanier Thanks for explaining. Nice work, I hope it's accepted! 🤞
@@ -132,6 +132,9 @@ <h2 class='tagline'>Proposals</h2> | |||
description: 'Demonstrates use of the mesh detection API in an immersive-ar session. ' + | |||
'Implements JavaScript-level hit-test on the meshes and leverages the Anchors API.' }, | |||
|
|||
{ title: 'Body tracking', category: 'AR', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my question above, doesn't seem like this is an AR-only feature? So I'd recommend using a category other than "AR" here.
Go ahead and make up something that feels appropriate. You can see from the Test Pages tab that we don't exactly stick to a rigid system here. I just don't want to give the impression that it's limited to a given session type unless it actually is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, just like hands this will also work in VR. I'll code something up
proposals/body-tracking.html
Outdated
const material = new THREE.MeshLambertMaterial(); | ||
|
||
spheres = new THREE.InstancedMesh( geometry, material, body.size ); | ||
spheres.translateZ( -1 ).setRotationFromMatrix (new THREE.Matrix4().makeRotationY(Math.PI)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear on how this works, and it's probably worth a comment for developers sake.
My guess is that this is a transform applied to the entire collection of instances spheres as a sort of root transform? If so, how does this result in the behavior in the video you linked, which appears to mirror your movements rather than show them rotated 180? (Although to be fair you never really moved your hands one at a time, so it's hard to tell. Full body movement suggests a mirror instead of a rotation, though.)
In any case, more comments throughout would be welcome!
proposals/body-tracking.html
Outdated
matrix.identity(); | ||
} | ||
|
||
matrix.setPosition( -position.x, position.y, position.z ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and I see that the positions are being inverted in X here too? Is THAT what causes the mirroring effect?
const position = pose.transform.position; | ||
|
||
if (!part.jointName.includes("hand")) { | ||
matrix.copy(scalehand); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do hands need to be scaled up 3x? In your video it looks like the opposite, and the hands are scaled down?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wait, I see. This is checking to ensure that "hand" isn't part of the name. That's pretty confusing. Can you invert the logic here?
let space = renderer.xr.getReferenceSpace(); | ||
body.forEach(part => { | ||
|
||
const pose = frame.getPose(part, space); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to encourage people to use fillPoses()
here? Or does that introduce too many complications for an otherwise simple sample.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. I forgot about that call :-)
I will update the code
c591ea1
to
795d0cc
Compare
FYI @toji
Not ready for merging yet.
example video:
https://github.com/immersive-web/webxr-samples/assets/1513308/6e5227c6-d451-4846-a0a2-6607bfcce627