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
| Name | Type | Description |
|---|---|---|
options | ChunkRegionArenasOptions | - |
maxSectionsPerRegion | number | - |
getMaterial | () => ChunkMaterial | - |
parent | Object3D<Object3DEventMap> | - |
positionUnitsPerBlock | number | - |
onRegionMesh? | (mesh: BatchedMesh, isAdded: boolean) => void | Told 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
Accessors
stats
• get stats(): Object
Returns
Object
| Name | Type |
|---|---|
pages | number |
regions | number |
sections | number |
Methods
clearChunk
▸ clearChunk(cx, cz): void
Parameters
| Name | Type |
|---|---|
cx | number |
cz | number |
Returns
void
clearSection
▸ clearSection(cx, cz, level): void
Parameters
| Name | Type |
|---|---|
cx | number |
cz | number |
level | number |
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
| Name | Type |
|---|---|
minCx | number |
maxCx | number |
minCz | number |
maxCz | number |
out | Object3D<Object3DEventMap>[] |
Returns
void
dispose
▸ dispose(): void
Returns
void
setSectionGeometry
▸ setSectionGeometry(cx, cz, level, geometry, x, y, z): void
Parameters
| Name | Type |
|---|---|
cx | number |
cz | number |
level | number |
geometry | BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap> |
x | number |
y | number |
z | number |
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
| Name | Type |
|---|---|
cx | number |
cz | number |
level | number |
reveal | number |
Returns
boolean
setSectionVisible
▸ setSectionVisible(cx, cz, level, isVisible): void
Parameters
| Name | Type |
|---|---|
cx | number |
cz | number |
level | number |
isVisible | boolean |
Returns
void