Skip to main content

Class: ChunkRegionArenas

Region buffer arenas for batched chunk buckets, adapted from Sodium's region-arena renderer. Every section of the bucket inside an NxN block of chunk columns lives as one slot of the region's pages, so a region draws as one multi-draw call per page per pass instead of one draw per (section x bucket) mesh, and a remesh rewrites a slot in place (setGeometryAt) instead of disposing and recreating GPU buffers.

A region is pages of pageVertexCapacity vertices that never grow: a region that fills opens another page. Growing one buffer instead meant rebuilding and re-uploading the whole region in one frame, tens of megabytes once a forest region passed a million vertices, which landed as a hitch every time a region crossed a threshold. Opening a page uploads one page, and a page that ran out of room between freed slots is compacted (optimize), which also moves one page at most.

BatchedMesh culls and sorts per instance against whichever camera renders it, so sections keep per-section frustum culling in the main pass while the CSM depth passes — which render with the light's camera — still see every caster they need. That per-pass behavior is what the whole-object chunkCullShadowSafeDistance bypass exists to approximate for regular meshes; arena sections need no such bypass.

Constructors​

constructor​

• new ChunkRegionArenas(options, maxSectionsPerRegion, getMaterial, parent, positionUnitsPerBlock, onRegionMesh?): ChunkRegionArenas

Parameters​

NameTypeDescription
optionsChunkRegionArenasOptions-
maxSectionsPerRegionnumber-
getMaterial() => ChunkMaterial-
parentObject3D<Object3DEventMap>-
positionUnitsPerBlocknumber-
onRegionMesh?(mesh: BatchedMesh, isAdded: boolean) => voidTold of each page mesh as it joins the scene (true) and before it leaves (false), for a host that registers the meshes it draws (the shadow casters it hides, the see-through surfaces it plans).

Returns​

ChunkRegionArenas

Accessors​

stats​

• get stats(): Object

Returns​

Object

NameType
pagesnumber
regionsnumber
sectionsnumber

Methods​

clearChunk​

▸ clearChunk(cx, cz): void

Parameters​

NameType
cxnumber
cznumber

Returns​

void


clearSection​

▸ clearSection(cx, cz, level): void

Parameters​

NameType
cxnumber
cznumber
levelnumber

Returns​

void


collectPagesIn​

▸ collectPagesIn(minCx, maxCx, minCz, maxCz, out): void

The page meshes of every region holding a chunk column in minCx..maxCx x minCz..maxCz, pushed onto out: what a depth pass confined to that area (a local light's shadow faces) draws of this bucket. Each page culls its own sections against the pass's camera.

Parameters​

NameType
minCxnumber
maxCxnumber
minCznumber
maxCznumber
outObject3D<Object3DEventMap>[]

Returns​

void


dispose​

▸ dispose(): void

Returns​

void


setSectionGeometry​

▸ setSectionGeometry(cx, cz, level, geometry, x, y, z): void

Parameters​

NameType
cxnumber
cznumber
levelnumber
geometryBufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>
xnumber
ynumber
znumber

Returns​

void


setSectionReveal​

▸ setSectionReveal(cx, cz, level, reveal): boolean

How much of a section shows through its own fog color, 0 (pure fog tint) to 1 (drawn as itself). Rides the slot's batching color, so a remesh that rewrites the slot in place keeps the value; a slot allocated fresh starts at 1.

Parameters​

NameType
cxnumber
cznumber
levelnumber
revealnumber

Returns​

boolean


setSectionVisible​

▸ setSectionVisible(cx, cz, level, isVisible): void

Parameters​

NameType
cxnumber
cznumber
levelnumber
isVisibleboolean

Returns​

void