Skip to main content

Class: ChunkSharedPool

Methods​

ensureChunk​

▸ ensureChunk(chunk): boolean

Puts a chunk's voxels and lights on the shared buffer, so a worker reads them where they are instead of being sent a copy. True when the chunk's arrays are views of the pool afterwards.

A chunk that already holds a slot is checked, not trusted: the server sending it again (Chunk.setData) swaps in plain arrays, and its slot then holds what it had before. Answering "already shared" for that chunk left every dispatch after it copying the whole column on the main thread (nine columns a mesh job) for the rest of the session, with nothing to say so. Its new data is moved into the slot it has.

Parameters​

NameType
chunkRawChunk

Returns​

boolean


getInstance​

▸ getInstance(): ChunkSharedPool

Returns​

ChunkSharedPool


getStats​

▸ getStats(): ChunkSharedPoolStats

Returns​

ChunkSharedPoolStats


hasSlot​

▸ hasSlot(key): boolean

Parameters​

NameType
keystring

Returns​

boolean


isSharedArrayBufferAvailable​

▸ isSharedArrayBufferAvailable(): boolean

Returns​

boolean


releaseChunk​

▸ releaseChunk(key): void

Parameters​

NameType
keystring

Returns​

void


resetForTests​

▸ resetForTests(): void

Returns​

void