Skip to main content

Class: Chunk

Hierarchy​

  • RawChunk

    ↳ Chunk

Constructors​

constructor​

• new Chunk(id, coords, options): Chunk

Parameters​

NameType
idstring
coordsCoords2
optionsRawChunkOptions

Returns​

Chunk

Overrides​

RawChunk.constructor

Properties​

added​

• added: boolean = false


biomeTints​

• biomeTints: Uint8Array<ArrayBufferLike>


coords​

• coords: Coords2

Inherited from​

RawChunk.coords


group​

• group: StaticGroup


id​

• id: string

Inherited from​

RawChunk.id


isDirty​

• isDirty: boolean = false


lights​

• lights: NdArray<Uint32Array<ArrayBufferLike>>

Inherited from​

RawChunk.lights


max​

• max: Coords3

Inherited from​

RawChunk.max


meshes​

• meshes: Map<number, Mesh<BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>, Material | Material[], Object3DEventMap>[]>


min​

• min: Coords3

Inherited from​

RawChunk.min


name​

• name: string

Inherited from​

RawChunk.name


options​

• options: RawChunkOptions

Inherited from​

RawChunk.options


plantsShown​

• plantsShown: boolean = null

Whether this chunk's plant meshes are currently shown, or null when the question has not been asked since its meshes last changed. Lets the per-frame distance check skip chunks whose band has not moved.


sectionVisibleMask​

• sectionVisibleMask: number = null

Bit-per-level mask of which sections the occlusion walk last left visible, or null when it must be reapplied (fresh meshes default to visible). Lets the per-frame walk skip rewriting mesh visibility for chunks whose answer has not changed.


voxels​

• voxels: NdArray<Uint32Array<ArrayBufferLike>>

Inherited from​

RawChunk.voxels

Accessors​

isReady​

• get isReady(): boolean

Whether or not is this chunk ready to be rendered and seen in the world.

Returns​

boolean

Inherited from​

RawChunk.isReady

Methods​

deserialize​

▸ deserialize(data): RawChunk

Parameters​

NameType
dataSerializedChunkPayload

Returns​

RawChunk

Inherited from​

RawChunk.deserialize


dispose​

▸ dispose(): void

Returns​

void


getBlueLight​

▸ getBlueLight(vx, vy, vz): number

Get the blue light level at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate

Returns​

number

The blue light level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.getBlueLight


getGreenLight​

▸ getGreenLight(vx, vy, vz): number

Get the green light level at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate

Returns​

number

The green light level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.getGreenLight


getRawLight​

▸ getRawLight(vx, vy, vz): number

Get the raw light value at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.

Returns​

number

The raw light value at the given voxel coordinate.

Inherited from​

RawChunk.getRawLight


getRawValue​

▸ getRawValue(vx, vy, vz): number

Get the raw voxel value at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.

Returns​

number

The raw voxel value at the given voxel coordinate. If the voxel is not within the chunk, this method returns 0.

Inherited from​

RawChunk.getRawValue


getRedLight​

▸ getRedLight(vx, vy, vz): number

Get the red light level at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.

Returns​

number

The red light level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.getRedLight


getSunlight​

▸ getSunlight(vx, vy, vz): number

Get the sunlight level at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate

Returns​

number

The sunlight level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.getSunlight


getTorchLight​

▸ getTorchLight(vx, vy, vz, color): number

Get the colored torch light level at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate
colorLightColorThe color of the light to get at the given voxel coordinate.

Returns​

number

The light level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.getTorchLight


getVoxel​

▸ getVoxel(vx, vy, vz): number

Get the voxel type ID at a given voxel or world coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.

Returns​

number

The voxel type ID at the given voxel coordinate.

Inherited from​

RawChunk.getVoxel


getVoxelRotation​

▸ getVoxelRotation(vx, vy, vz): BlockRotation

Get the voxel rotation at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.

Returns​

BlockRotation

The voxel rotation at the given voxel coordinate.

Inherited from​

RawChunk.getVoxelRotation


getVoxelStage​

▸ getVoxelStage(vx, vy, vz): number

Get the voxel stage at a given voxel coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.

Returns​

number

The voxel stage at the given voxel coordinate.

Inherited from​

RawChunk.getVoxelStage


getVoxelWaterlogLevel​

▸ getVoxelWaterlogLevel(vx, vy, vz): number

The level of waterlogging fluid held by the voxel at a given coordinate.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.

Returns​

number

Inherited from​

RawChunk.getVoxelWaterlogLevel


getVoxelWaterlogged​

▸ getVoxelWaterlogged(vx, vy, vz): boolean

Whether the voxel at a given coordinate holds the world's waterlogging fluid alongside its block.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.

Returns​

boolean

Inherited from​

RawChunk.getVoxelWaterlogged


isAirRange​

▸ isAirRange(minY, maxY): boolean

Whether a full-width, half-open vertical range contains only raw air. Used before serializing a meshing stencil: empty sky needs no worker. Reads current storage every time, so bulk loads, edits and shared-buffer replacement cannot leave a stale occupancy cache. Nonzero metadata is conservatively sent to the mesher too.

Parameters​

NameType
minYnumber
maxYnumber

Returns​

boolean

Inherited from​

RawChunk.isAirRange


serialize​

▸ serialize(): [SerializedChunkPayload, ArrayBuffer[]]

Returns​

[SerializedChunkPayload, ArrayBuffer[]]

Inherited from​

RawChunk.serialize


setBlueLight​

▸ setBlueLight(vx, vy, vz, level): number

Set the blue light level at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate
levelnumberThe blue light level to set at the given voxel coordinate.

Returns​

number

The blue light level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.setBlueLight


setData​

▸ setData(data): boolean

See RawChunk.setData: adopts a new server id for the same coordinates.

Parameters​

NameType
dataChunkProtocol

Returns​

boolean

Overrides​

RawChunk.setData


setGreenLight​

▸ setGreenLight(vx, vy, vz, level): number

Set the green light level at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate
levelnumberThe green light level to set at the given voxel coordinate.

Returns​

number

The green light level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.setGreenLight


setRawLight​

▸ setRawLight(vx, vy, vz, level): number

Set the raw light value at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.
levelnumberThe raw light level to set at the given voxel coordinate.

Returns​

number

The raw light level at the given voxel coordinate.

Inherited from​

RawChunk.setRawLight


setRawValue​

▸ setRawValue(vx, vy, vz, val): number

Set the raw voxel value at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.
valnumber-

Returns​

number

The raw voxel value at the given voxel coordinate.

Inherited from​

RawChunk.setRawValue


setRedLight​

▸ setRedLight(vx, vy, vz, level): number

Set the red light level at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate
levelnumberThe red light level to set at the given voxel coordinate.

Returns​

number

The red light level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.setRedLight


setSunlight​

▸ setSunlight(vx, vy, vz, level): number

Set the sunlight level at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate
levelnumberThe sunlight level to set at the given voxel coordinate.

Returns​

number

The sunlight level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.setSunlight


setTorchLight​

▸ setTorchLight(vx, vy, vz, level, color): number

Set the colored torch light level at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate
vynumberThe y voxel coordinate
vznumberThe z voxel coordinate
levelnumberThe light level to set at the given voxel coordinate.
colorLightColorThe color of the light to set at the given voxel coordinate.

Returns​

number

The light level at the given voxel coordinate. If the voxel coordinate is out of bounds, returns 0.

Inherited from​

RawChunk.setTorchLight


setVoxel​

▸ setVoxel(vx, vy, vz, id): number

Set the voxel type ID at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.
idnumberThe voxel type ID to set at the given voxel coordinate.

Returns​

number

The voxel type ID at the given voxel coordinate.

Inherited from​

RawChunk.setVoxel


setVoxelRotation​

▸ setVoxelRotation(vx, vy, vz, rotation): void

Set the voxel rotation at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.
rotationBlockRotationThe voxel rotation to set at the given voxel coordinate.

Returns​

void

Inherited from​

RawChunk.setVoxelRotation


setVoxelStage​

▸ setVoxelStage(vx, vy, vz, stage): number

Set the voxel stage at a given voxel coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.
stagenumberThe voxel stage to set at the given voxel coordinate.

Returns​

number

The voxel stage at the given voxel coordinate.

Inherited from​

RawChunk.setVoxelStage


setVoxelWaterlogLevel​

▸ setVoxelWaterlogLevel(vx, vy, vz, level): number

Set the level of waterlogging fluid held by the voxel at a coordinate.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.
levelnumberThe fluid level, 0 through 7.

Returns​

number

Inherited from​

RawChunk.setVoxelWaterlogLevel


setVoxelWaterlogged​

▸ setVoxelWaterlogged(vx, vy, vz, isWaterlogged): boolean

Set whether the voxel at a given coordinate holds the waterlogging fluid.

Note: This method is purely client-side and does not affect the actual values on the server.

Parameters​

NameTypeDescription
vxnumberThe x voxel coordinate.
vynumberThe y voxel coordinate.
vznumberThe z voxel coordinate.
isWaterloggedbooleanWhether the voxel holds the waterlogging fluid.

Returns​

boolean

Inherited from​

RawChunk.setVoxelWaterlogged