API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classTileColliderStreamer
Keeps a physics world's static tile colliders in sync with a TileLayer: one static body per chunk-sized partition of the layer, rebuilt when that partition changes, destroyed when it is evicted. The bridge owns every body it creates and nothing else. It observes the layer through its public revision counters, so it works with any chunk source - import('@codexo/exojs-tilemap').ChunkStreamer, a hand-rolled loader, or a fully resident bounded layer. Tick it from `preFrame`, before the frame's fixed steps run - not from `update`, which runs after them: ```ts const colliders = new TileColliderStreamer(world, layer); scene.systems.add({ preFrame: () => colliders.sync() }); ``` `SceneScope` runs `preFrame` once per frame, before any of that frame's fixed steps, and `update` after all of them. A chunk that becomes resident this frame needs its collider body built before the world steps over the hole, and a chunk evicted this frame must not keep its body for a whole extra frame of stepping - `update` gets both of those one step too late. Wiring `sync()` into `fixedUpdate` instead (ordered before SystemOrder.Physics) also works, and additionally re-syncs on every fixed step within a frame rather than once per frame. Two consequences worth knowing before shipping a level: - Whole-cell merging never crosses a partition boundary, so a solid run spanning two of them is at least two rectangles. This is what makes the result independent of the order chunks were loaded in. - A dynamic body resting on a chunk that gets evicted falls. Eviction is the chunk source's decision; widen its unload radius if that matters. - With TileColliderOptions.cells, a bounded layer's partitions are all covered, resident or not - collision authored per cell does not depend on tiles being placed.
import { TileColliderStreamer } from '@codexo/exojs-tilemap-physics'Keeps a physics world's static tile colliders in sync with a TileLayer: one static body per chunk-sized partition of the layer, rebuilt when that partition changes, destroyed when it is evicted.
The bridge owns every body it creates and nothing else. It observes the layer through its public revision counters, so it works with any chunk source - import('@codexo/exojs-tilemap').ChunkStreamer, a hand-rolled loader, or a fully resident bounded layer.
Tick it from `preFrame`, before the frame's fixed steps run - not from `update`, which runs after them:
```ts const colliders = new TileColliderStreamer(world, layer); scene.systems.add({ preFrame: () => colliders.sync() }); ```
`SceneScope` runs `preFrame` once per frame, before any of that frame's fixed steps, and `update` after all of them. A chunk that becomes resident this frame needs its collider body built before the world steps over the hole, and a chunk evicted this frame must not keep its body for a whole extra frame of stepping - `update` gets both of those one step too late. Wiring `sync()` into `fixedUpdate` instead (ordered before SystemOrder.Physics) also works, and additionally re-syncs on every fixed step within a frame rather than once per frame.
Two consequences worth knowing before shipping a level:
- Whole-cell merging never crosses a partition boundary, so a solid run spanning two of them is at least two rectangles. This is what makes the result independent of the order chunks were loaded in. - A dynamic body resting on a chunk that gets evicted falls. Eviction is the chunk source's decision; widen its unload radius if that matters. - With TileColliderOptions.cells, a bounded layer's partitions are all covered, resident or not - collision authored per cell does not depend on tiles being placed.
new(world: PhysicsWorldThe collision/query world: owns bodies, colliders, the detection backend, bindings, the query engine and the fixed-step accumulator. Stepped by the caller (com…, layer: TileLayerA generic, format-independent tile layer with chunk-first storage. Tile data is stored in fixed-size TileChunks indexed by signed chunk coordinates. For finite…, options: TileColliderOptionsOptions for a TileColliderStreamer. All optional.): TileColliderStreamerdestroy(): voidsync(): voidbodyCount: number