Performance
haath is built for 72 to 120 Hz render loops on Quest-class mobile chips. Per-hand classification is a fixed pass over 25 joints, and hit tests are closed-form sphere, cylinder, and disc checks instead of raycasts.
Rules #
update()andupdateFromPoses()allocate nothing per frame.haath.stateand its arrays are reused, so copy values out if you need them after the frame.- Reuse option objects passed to per-frame calls, such as
HandSphereTestOptions, instead of creating literals in the loop. - Call
update()exactly once per XR frame with a realdeltaSeconds. Velocity, clap timing, and circle history depend on it. - One-frame flags (
clap.singleClap,clap.doubleClap,circle.triggered,blast.triggered,hold.triggered) are true for a single frame. Read them in the same frame.
Cost #
- Hand vs enemy: one sphere distance check per enemy per hand. 20 enemies and 2 hands is 40 checks a frame.
- Triangle laser and circle disc: vector projection only, no mesh triangles.
- Collision with a BVH raycaster (for example three-mesh-bvh) does far more work per frame for no extra accuracy in arcade combat.