Capítulo 253 de 411

Chapter 253: VelocityTracker (Overview)

Core Idea

The object underlying InertiaPlugin.track() — automatically records timestamped samples of tracked properties so their velocity can be read anytime via getVelocity(), without hand-rolled position/timestamp bookkeeping.

Code Examples

let tracker = VelocityTracker.track(obj, "x,y")[0];
// after at least ~100ms and 2 ticks:
let vx = tracker.get("x");
let vy = tracker.get("y");

Key Takeaways

  1. Use the static VelocityTracker.track() (or InertiaPlugin.track(), equivalent) rather than the constructor directly — only one tracker instance should exist per object.
  2. In most workflows you never touch VelocityTracker directly; InertiaPlugin.getVelocity() is the more common entry point.

Connects To

  • InertiaPlugin.track(), getVelocity(): the higher-level API most code should use instead of VelocityTracker directly.