Interface Chunk

One fixed-size tile of the world bitmap.

Chunks are the unit of dirty tracking, GPU texture upload, and Box2D collider rebuild. They are owned by ChunkedBitmap and exposed read-mostly to higher layers; only the dirty flags and contours cache may be mutated from outside core.

interface Chunk {
    bitmap: Uint8Array;
    contours: null | Contour[];
    cx: number;
    cy: number;
    dirty: boolean;
    visualDirty: boolean;
}

Properties

bitmap: Uint8Array

Row-major byte grid of material ids. Length is chunkSize * chunkSize.

contours: null | Contour[]

Cached marching-squares output, or null if not yet computed or invalidated.

cx: number

Chunk-grid X coordinate.

cy: number

Chunk-grid Y coordinate.

dirty: boolean

Set when the chunk's bitmap changed and colliders need rebuild.

visualDirty: boolean

Set when the chunk's bitmap changed and the visual texture needs upload.