Skip to content

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