Skip to content

Class: Chunk<SectionMeshing> ​

Defined in: packages/minerender/src/world/Chunk.ts:36

A 16×16×16 block section and its render objects. Constructor coordinates identify the section. Block accessors use world block coordinates unless their name explicitly refers to positions within the chunk.

Type Parameters ​

Type ParameterDefault type
SectionMeshing extends booleanfalse

Constructors ​

Constructor ​

ts
new Chunk<SectionMeshing>(
   scene, 
   x, 
   y, 
   z, 
   onBlocksChanged?, 
   sectionModels?, 
   neighborCell?, 
   biomeAt?, 
   onBiomesChanged?, 
   lightAt?, 
   onLightCleared?, 
   ambientLight?, 
   biomeBlend?
): Chunk<SectionMeshing>;

Defined in: packages/minerender/src/world/Chunk.ts:60

Parameters ​

ParameterTypeDefault value
sceneMineRenderSceneundefined
xnumberundefined
ynumberundefined
znumberundefined
onBlocksChanged?(positions, deferCulling?) => Promise<void>undefined
sectionModels?SectionModelsundefined
neighborCell?(x, y, z) => numberundefined
biomeAt?(x, y, z) => Maybe<string>undefined
onBiomesChanged?(biomes?) => Promise<void>undefined
lightAt?(x, y, z) => numberundefined
onLightCleared?() => Promise<void>undefined
ambientLight?number0
biomeBlend?() => BiomeBlend | undefinedundefined

Returns ​

Chunk<SectionMeshing>

Properties ​

PropertyModifierTypeDefined in
scenereadonlyMineRenderScenepackages/minerender/src/world/Chunk.ts:38
xreadonlynumberpackages/minerender/src/world/Chunk.ts:40
yreadonlynumberpackages/minerender/src/world/Chunk.ts:41
zreadonlynumberpackages/minerender/src/world/Chunk.ts:42

Methods ​

chunkPosToWorldPos() ​

ts
chunkPosToWorldPos(pos): Vector3;

Defined in: packages/minerender/src/world/Chunk.ts:868

Parameters ​

ParameterType
posVector3

Returns ​

Vector3


clear() ​

ts
clear(notify?): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:818

Removes stored blocks and render objects. Set notify to false to skip the owning world's update.

Parameters ​

ParameterTypeDefault value
notifybooleantrue

Returns ​

Promise<void>


dispose() ​

ts
dispose(): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:844

Returns ​

Promise<void>


fluidByteIndex() ​

ts
fluidByteIndex(index): number;

Defined in: packages/minerender/src/world/Chunk.ts:667

Fluid kind bits and level of a cell, or 0. Hidden cells report 0.

Parameters ​

ParameterType
indexnumber

Returns ​

number


getBiomeAt() ​

Call Signature ​

ts
getBiomeAt(
   x, 
   y, 
   z
): Maybe<string>;

Defined in: packages/minerender/src/world/Chunk.ts:158

Returns the saved 4-block biome sample at integer world block coordinates, or undefined if absent.

Parameters ​
ParameterType
xnumber
ynumber
znumber
Returns ​

Maybe<string>

Call Signature ​

ts
getBiomeAt(pos): Maybe<string>;

Defined in: packages/minerender/src/world/Chunk.ts:159

Returns the saved 4-block biome sample at integer world block coordinates, or undefined if absent.

Parameters ​
ParameterType
posVector3
Returns ​

Maybe<string>

Call Signature ​

ts
getBiomeAt(pos): Maybe<string>;

Defined in: packages/minerender/src/world/Chunk.ts:160

Returns the saved 4-block biome sample at integer world block coordinates, or undefined if absent.

Parameters ​
ParameterType
posTripleArray
Returns ​

Maybe<string>


getBlockAt() ​

Call Signature ​

ts
getBlockAt(
   x, 
   y, 
   z
): Maybe<BlockInfo<SectionMeshing>>;

Defined in: packages/minerender/src/world/Chunk.ts:142

Parameters ​
ParameterType
xnumber
ynumber
znumber
Returns ​

Maybe<BlockInfo<SectionMeshing>>

Call Signature ​

ts
getBlockAt(pos): Maybe<BlockInfo<SectionMeshing>>;

Defined in: packages/minerender/src/world/Chunk.ts:143

Parameters ​
ParameterType
posVector3
Returns ​

Maybe<BlockInfo<SectionMeshing>>

Call Signature ​

ts
getBlockAt(pos): Maybe<BlockInfo<SectionMeshing>>;

Defined in: packages/minerender/src/world/Chunk.ts:144

Parameters ​
ParameterType
posTripleArray
Returns ​

Maybe<BlockInfo<SectionMeshing>>


isBlockVisibleAt() ​

ts
isBlockVisibleAt(pos): boolean;

Defined in: packages/minerender/src/world/Chunk.ts:652

Parameters ​

ParameterType
posVector3

Returns ​

boolean


isBlockVisibleIndex() ​

ts
isBlockVisibleIndex(index): boolean;

Defined in: packages/minerender/src/world/Chunk.ts:657

Reports whether a cell has a visible render object or section entry.

Parameters ​

ParameterType
indexnumber

Returns ​

boolean


isFluidIndex() ​

ts
isFluidIndex(index): boolean;

Defined in: packages/minerender/src/world/Chunk.ts:672

Whether the cell holds a fluid, merged or per-block.

Parameters ​

ParameterType
indexnumber

Returns ​

boolean


isOccludingAt() ​

ts
isOccludingAt(pos): boolean;

Defined in: packages/minerender/src/world/Chunk.ts:676

Parameters ​

ParameterType
posVector3

Returns ​

boolean


isOccludingIndex() ​

ts
isOccludingIndex(index): boolean;

Defined in: packages/minerender/src/world/Chunk.ts:681

Reports whether a visible cell hides neighboring cube faces.

Parameters ​

ParameterType
indexnumber

Returns ​

boolean


placeBlocks() ​

ts
placeBlocks(blocks): Promise<Vector3[]>;

Defined in: packages/minerender/src/world/Chunk.ts:293

Places cells in input order and returns changed world positions without refreshing neighbors.

Parameters ​

ParameterType
blocksreadonly object[]

Returns ​

Promise<Vector3[]>


placeSection() ​

ts
placeSection(data): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:400

Replaces every cell from parsed section data. The caller refreshes neighbor culling.

Parameters ​

ParameterType
dataChunkData

Returns ​

Promise<void>


rebuildSectionMesh() ​

ts
rebuildSectionMesh(): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:753

Rebuilds visible section geometry and discards results superseded by another rebuild or clear.

Returns ​

Promise<void>


refreshAmbientOcclusion() ​

ts
refreshAmbientOcclusion(enabled): void;

Defined in: packages/minerender/src/world/Chunk.ts:506

Refreshes baked corner shading after edits or a world setting change. Disabled chunks keep no AO neighborhood.

Parameters ​

ParameterType
enabledboolean

Returns ​

void


refreshBiomes() ​

ts
refreshBiomes(columns?, deferCulling?): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:185

Rebuilds biome-tinted blocks while preserving hidden blocks and unrelated render objects. The owning world can defer neighbor culling until all affected chunks are refreshed.

Parameters ​

ParameterTypeDefault value
columns?readonly object[]undefined
deferCulling?booleanfalse

Returns ​

Promise<void>


refreshLight() ​

ts
refreshLight(indices?): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:498

Refreshes saved lighting after adjacent columns load or unload, including columns with only light data.

Parameters ​

ParameterType
indices?Iterable<number, any, any>

Returns ​

Promise<void>


setBiomes() ​

ts
setBiomes(biomes?): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:171

Copies 64 biome IDs in x + z * 4 + y * 16 order and refreshes placed blocks. Omit the array to clear biome data.

Parameters ​

ParameterType
biomes?readonly string[]

Returns ​

Promise<void>


setBlockAt() ​

Call Signature ​

ts
setBlockAt(
   x, 
   y, 
   z, 
   block
): Promise<Maybe<BlockInfo<SectionMeshing>>>;

Defined in: packages/minerender/src/world/Chunk.ts:257

Places a block at integer world block coordinates. Pass undefined to remove it.

Parameters ​
ParameterType
xnumber
ynumber
znumber
blockMaybe<Block>
Returns ​

Promise<Maybe<BlockInfo<SectionMeshing>>>

Call Signature ​

ts
setBlockAt(pos, block): Promise<Maybe<BlockInfo<SectionMeshing>>>;

Defined in: packages/minerender/src/world/Chunk.ts:258

Places a block at integer world block coordinates. Pass undefined to remove it.

Parameters ​
ParameterType
posVector3
blockMaybe<Block>
Returns ​

Promise<Maybe<BlockInfo<SectionMeshing>>>

Call Signature ​

ts
setBlockAt(pos, block): Promise<Maybe<BlockInfo<SectionMeshing>>>;

Defined in: packages/minerender/src/world/Chunk.ts:259

Places a block at integer world block coordinates. Pass undefined to remove it.

Parameters ​
ParameterType
posTripleArray
blockMaybe<Block>
Returns ​

Promise<Maybe<BlockInfo<SectionMeshing>>>


setBlockInChunkAt() ​

ts
setBlockInChunkAt(
   pos, 
   block?, 
   worldPos?, 
   onBlocksChanged?
): Promise<Maybe<BlockInfo<SectionMeshing>>>;

Defined in: packages/minerender/src/world/Chunk.ts:277

Places a block at integer chunk-local coordinates from 0 to 15.

Parameters ​

ParameterType
posVector3
block?Block
worldPos?Vector3
onBlocksChanged?((positions, deferCulling?) => Promise<void>) | undefined

Returns ​

Promise<Maybe<BlockInfo<SectionMeshing>>>


setBlockVisibleAt() ​

ts
setBlockVisibleAt(pos, visible): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:628

Changes visibility at world block coordinates while preserving the block's data.

Parameters ​

ParameterType
posVector3
visibleboolean

Returns ​

Promise<void>


setCullMaskAt() ​

ts
setCullMaskAt(pos, mask): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:687

Parameters ​

ParameterType
posVector3
masknumber

Returns ​

Promise<void>


setCullMaskIndex() ​

ts
setCullMaskIndex(index, mask): Promise<void>;

Defined in: packages/minerender/src/world/Chunk.ts:737

Updates hidden faces for a cell's section entry or individual render object.

Parameters ​

ParameterType
indexnumber
masknumber

Returns ​

Promise<void>


updateCullMasks() ​

ts
updateCullMasks(
   indices, 
   occludes, 
   culling?, 
   blockAt?
): [number, number][];

Defined in: packages/minerender/src/world/Chunk.ts:695

Recomputes section masks and returns changed per-block masks. Omit indices to visit every cell. culling supplies neighbor face rules; blockAt supplies visible states outside this chunk.

Parameters ​

ParameterType
indicesIterable<number, any, any> | undefined
occludes(x, y, z) => boolean
culling?{ blocks: Record<string, number>; groups?: Record<string, string[]>; profiles: object[]; }
culling.blocks?Record<string, number>
culling.groups?Record<string, string[]>
culling.profiles?object[]
blockAt?(x, y, z) => Maybe<Pick<Block, "type" | "properties">>

Returns ​

[number, number][]


visibleBlockIndex() ​

ts
visibleBlockIndex(index): Maybe<Pick<Block, "type" | "properties">>;

Defined in: packages/minerender/src/world/Chunk.ts:662

Stored state of a rendered, visible cell, or undefined.

Parameters ​

ParameterType
indexnumber

Returns ​

Maybe<Pick<Block, "type" | "properties">>


worldPosToChunkPos() ​

ts
worldPosToChunkPos(pos): Vector3;

Defined in: packages/minerender/src/world/Chunk.ts:860

Parameters ​

ParameterType
posVector3

Returns ​

Vector3


chunkPosToBlockIndex() ​

ts
static chunkPosToBlockIndex(pos): number;

Defined in: packages/minerender/src/world/Chunk.ts:853

Maps chunk-local coordinates from 0 to 15 to a storage index, with x varying fastest, then z, then y.

Parameters ​

ParameterType
posVector3

Returns ​

number


isAir() ​

ts
static isAir(block): boolean;

Defined in: packages/minerender/src/world/Chunk.ts:848

Parameters ​

ParameterType
blockMaybe<Block>

Returns ​

boolean


raycast() ​

ts
static raycast<SectionMeshing>(chunks, raycaster): 
  | WorldBlockIntersection
  | undefined;

Defined in: packages/minerender/src/world/Chunk.ts:77

Finds the nearest owned block hit across sections, testing each shared mesh once.

Type Parameters ​

Type Parameter
SectionMeshing extends boolean

Parameters ​

ParameterType
chunksIterable<Chunk<SectionMeshing>>
raycasterRaycaster

Returns ​

| WorldBlockIntersection | undefined