Class TJSVelocityTrack
Index
Constructors
constructor
- new TJSVelocity
Track (opts?): TJSVelocityTrack Creates a velocity tracker instance.
Parameters
Optional
opts: {
resetDeltaTime?: number;
scaleTime?: number;
}Optional parameters.
Optional
resetDelta ?: numberTime Delta time in milliseconds that resets velocity tracking.
Optional
scaleTime ?: numberScales velocity calculation to new time frame. 1000 is velocity per second.
Returns TJSVelocityTrack
Accessors
resetDeltaTime
- get resetDeltaTime(): number
Returns number
Gets
resetDeltaTime
.- set resetDeltaTime(resetDeltaTime): void
Sets
resetDeltaTime
.Parameters
- resetDeltaTime: number
Delta time in milliseconds that resets velocity tracking.
Returns void
- resetDeltaTime: number
scaleTime
- get scaleTime(): number
Returns number
Gets
scaleTime
.- set scaleTime(scaleTime): void
Sets
scaleTime
.Parameters
- scaleTime: number
Scales velocity calculation to new time frame. 1000 is velocity per second.
Returns void
- scaleTime: number
Methods
get
reset
- reset(x?, y?, z?, sampleTime?): void
Resets velocity tracking data.
Parameters
Optional
x: number'X' value to set to last sample point.
Optional
y: number'Y' value to set to last sample point.
Optional
z: number'Z' value to set to last sample point.
Optional
sampleTime: numberA sample time in milliseconds resolution.
Returns void
update
- update(x?, y?, z?, sampleTime?): {
x: number;
y: number;
z: number;
} Runs ongoing velocity calculation of x / y / z given a sample time.
Parameters
Optional
x: numberNew sample X
Optional
y: numberNew sample Y
Optional
z: numberNew sample Z
Optional
sampleTime: numberAn optional specific time w/ millisecond resolution.
Returns {
x: number;
y: number;
z: number;
}current velocity.
x: number
y: number
z: number
Provides a way to calculate velocity via effectively creating a "complementary filter".
velQuick
andvelSmooth
separately accumulate over time.velInstant
andvelUsed
do not accumulate and are discarded each update.velQuick
is responsive, but noisy.velSmooth
is laggy but eventually more accurate. By tracking them separately the used result can be responsive in the short term and accurate in the long term.