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


coords

coords: Coords2

Inherited from

RawChunk.coords


group

group: Group<Object3DEventMap>


id

id: string

Inherited from

RawChunk.id


isDirty

isDirty: boolean = false


lights

lights: NdArray<Uint32Array>

Inherited from

RawChunk.lights


max

max: Coords3

Inherited from

RawChunk.max


meshes

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


min

min: Coords3

Inherited from

RawChunk.min


name

name: string

Inherited from

RawChunk.name


options

options: RawChunkOptions

Inherited from

RawChunk.options


voxels

voxels: NdArray<Uint32Array>

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
dataany

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


serialize

serialize(): [object, ArrayBuffer[]]

Returns

[object, 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): void

Parameters

NameType
dataChunkProtocol

Returns

void

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