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

Use fillPoses and fillJointRadii instead of getJointPose #5298

Merged
merged 3 commits into from
Jun 14, 2023

Conversation

mrxz
Copy link
Contributor

@mrxz mrxz commented Jun 5, 2023

Description:
Changes the logic in hand-tracking-controls to use fillPoses and fillJointRadii instead of calling getJointPose many times over. The downside of getJointPose is that it allocates temporary objects, which quickly becomes inefficient.

As described in the WebXR hand input explainer

Each use of getPose() allocates one short-lived XRPose object, one XRRigidTransform object, and at least one DOMPointReadOnly or Float32Array. For 25 joints per hand and two hands, this is 150-250 objects created per frame. This can have noticeable performance implications, especially around garbage collection.

Also removed the offset on the reference space. It didn't seem to serve any purpose and only required the rest of the code to apply a counter offset to get the actual position of the hand joints.

Changes proposed:

  • No longer apply an offset to the reference space
  • Per tick call fillPoses and fillJointRadii once
  • Let updateHandMeshModel, updateHandDotsModel and detectPinch use these poses and radii.

@dmarcos
Copy link
Member

dmarcos commented Jun 14, 2023

Thanks! I didn't know about fillPoses and fillJointRadii or didn't exist when I first wrote the code

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.

2 participants