Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / index / ThrowVelocityTracker

Class: ThrowVelocityTracker ​

Defined in: xr/throwVelocity.ts:52

Rolling buffer of hand positions used to recover throw velocity.

One per active grab; cleared on release.

Constructors ​

Constructor ​

ts
new ThrowVelocityTracker(): ThrowVelocityTracker;

Returns ​

ThrowVelocityTracker

Methods ​

record() ​

ts
record(position, time): void;

Defined in: xr/throwVelocity.ts:56

Record where the hand is now. Call once per frame while held.

Parameters ​

ParameterType
positionVector3
timenumber

Returns ​

void


computeVelocity() ​

ts
computeVelocity(now): Vector3;

Defined in: xr/throwVelocity.ts:71

Velocity to release with, in metres/second.

Uses the FASTEST segment inside the window rather than the most recent or the window average. Users decelerate as they open their hand, so the last segment understates the throw and the average washes it out; peak speed is what matches the motion the user actually felt they made.

Parameters ​

ParameterType
nownumber

Returns ​

Vector3


clear() ​

ts
clear(): void;

Defined in: xr/throwVelocity.ts:105

Returns ​

void