Class
VirtualClock
View sourceExtendsClock
Provides the app-wide mutable virtual time resource.
VirtualClock extends Clock and is the clock resource
exposed by TimePlugin. Access it from a World when
application code needs shared virtual time.
The resource preserves the serialized state defined by Clock, so
the same virtual-time state can be restored later.
Examples
import { VirtualClock } from '@wimaengine/time'
function readFrameTime(world) {
const clock = world.getResource(VirtualClock)
console.log(clock.getDelta(), clock.getElapsed())
}Constructor
Methods
staticserialize(value: Clock): ClockSerial
View sourceConverts a clock into the plain state used by the type registry.
The returned object contains the elapsed time and delta in seconds, plus the most recent timestamp in milliseconds.
staticdeserialize(value: ClockSerial, out?: VirtualClock): Clock
View sourceRestores clock state from a serialized value.
When out is supplied, it is updated and returned. Otherwise a new
Clock is created. Deserialization restores elapsed, lastTick, and
delta exactly; it does not advance the clock or read the current time.
