Entities · interface
WorldSnapshot
A world's whole state at one instant, for a rewind. Not a save file, and the two are not interchangeable.
Explained in Entities.
interface WorldSnapshotimport type { WorldSnapshot } from '@driftengine/entities';In depth
serializeWorld in scene.ts writes a scene: it carries every component's schema so a load can
migrate across a change, keys values by stable field id so a renamed field still loads, and
creates entities so a scene can be loaded into a world that already holds things. Every one of
those properties is wrong here. A rewind needs the handles it had — an input recorded for entity
4,194,307 means nothing if the restore hands that slot a new generation — and it needs to cost
nothing per tick, which rules out an object per component per entity.
SerializedScene |
WorldSnapshot |
|
|---|---|---|
| Keyed by | stable field id | column position |
| Handles | remapped, all of them change | preserved, generations included |
| On load | creates, appending | overwrites in place |
| Migration | yes | no |
| Allocates | per entity, per component | nothing after the first save |
| Goes on a wire | yes | never |
A rewind covers every store the world holds, and takes no list of types. That is the other
half of the difference: serializeWorld is handed the types because a scene is a decision about
what to save, and a rewind is not a decision at all. A component type left out of a restore is
state that survived the rewind, which is the definition of a desync.
Properties
| Name | Type | Description |
|---|---|---|
allocatorreadonly | AllocatorSnapshot | |
storesreadonly | Map<number, StoreSnapshot> | By ComponentType.id. Holds a slot for every store the world had when this was written. |