Skip to main content

Class: ChunkPipeline

Constructors​

constructor​

• new ChunkPipeline(): ChunkPipeline

Returns​

ChunkPipeline

Properties​

loadedGeneration​

• loadedGeneration: number = 0

Bumps whenever a chunk enters or leaves the loaded stage. A caller that memoizes a loaded-chunk lookup (the world's by-coords getter) compares against it instead of re-resolving the name on every voxel read.


sentStampAttempts​

• sentStampAttempts: number = 0

How many send stamps were offered, and how many landed on a waiting request.


sentStampHits​

• sentStampHits: number = 0

Accessors​

loadedCount​

• get loadedCount(): number

Returns​

number


processingCount​

• get processingCount(): number

Returns​

number


requestedCount​

• get requestedCount(): number

Returns​

number


totalCount​

• get totalCount(): number

Returns​

number

Methods​

expireRequest​

▸ expireRequest(name): void

Drop a request presumed lost so the chunk is asked for again. Unlike remove, the chunk's ChunkRequestHistory stays: the chunk is still missing.

Parameters​

NameType
namestring

Returns​

void


forEach​

▸ forEach(stage, callback): void

Parameters​

NameType
stage"requested" | "processing" | "loaded"
callback(name: string) => void

Returns​

void


forEachLoaded​

▸ forEachLoaded(callback): void

Parameters​

NameType
callback(chunk: Chunk, name: string) => void

Returns​

void


forgetRequestsWhere​

▸ forgetRequestsWhere(isForgotten): void

Forget the requests of chunks the caller no longer wants, including ones between attempts that hold no stage to be removed by.

Parameters​

NameType
isForgotten(name: string) => boolean

Returns​

void


getInStage​

▸ getInStage(stage): Set<string>

Parameters​

NameType
stage"requested" | "processing" | "loaded"

Returns​

Set<string>


getLoadedChunk​

▸ getLoadedChunk(name): Chunk

Parameters​

NameType
namestring

Returns​

Chunk


getProcessingData​

▸ getProcessingData(name): Object

Parameters​

NameType
namestring

Returns​

Object

NameType
dataChunkProtocol
source"load" | "update"

getReloads​

▸ getReloads(): ReadonlyMap<string, PendingChunkData>

Data waiting for chunks that stay loaded; see reloads.

Returns​

ReadonlyMap<string, PendingChunkData>


getRequestHistory​

▸ getRequestHistory(name): ChunkRequestHistory

How long this chunk has been asked for, if it still is.

Parameters​

NameType
namestring

Returns​

ChunkRequestHistory


getStage​

▸ getStage(name): "requested" | "processing" | "loaded"

Parameters​

NameType
namestring

Returns​

"requested" | "processing" | "loaded"


getTiming​

▸ getTiming(name): ChunkLoadTiming

Parameters​

NameType
namestring

Returns​

ChunkLoadTiming


isAwaitingData​

▸ isAwaitingData(name): boolean

Whether data for this chunk is still waiting to be applied.

Parameters​

NameType
namestring

Returns​

boolean


isInStage​

▸ isInStage(name, stage): boolean

Parameters​

NameType
namestring
stage"requested" | "processing" | "loaded"

Returns​

boolean


isRequestStale​

▸ isRequestStale(name, staleAfterMs): boolean

Whether a request has gone unanswered long enough to be presumed lost. Measured in elapsed time rather than in world updates, so a chunk asks again on schedule however slowly the client happens to be running.

Parameters​

NameType
namestring
staleAfterMsnumber

Returns​

boolean


markLoaded​

▸ markLoaded(coords, chunk): void

Parameters​

NameType
coordsCoords2
chunkChunk

Returns​

void


markProcessing​

▸ markProcessing(coords, source, data, arrivedAt?): void

Parameters​

NameTypeDefault value
coordsCoords2undefined
source"load" | "update"undefined
dataChunkProtocolundefined
arrivedAtnumbernull

Returns​

void


markRequested​

▸ markRequested(coords): void

Parameters​

NameType
coordsCoords2

Returns​

void


markSent​

▸ markSent(coords, sentAt): void

The queued LOAD for this chunk reached the socket at sentAt.

Parameters​

NameType
coordsCoords2
sentAtnumber

Returns​

void


readRecentRoundTrips​

▸ readRecentRoundTrips(): readonly ChunkRoundTrip[]

The last few chunk round trips this client completed: wire is socket send to raw arrival (server + transport + the main thread getting to the socket event), load is arrival to data applied. Lets a slow join window be compared against the same path during play, when the main thread is idle.

Returns​

readonly ChunkRoundTrip[]


remove​

▸ remove(name): Chunk

Parameters​

NameType
namestring

Returns​

Chunk


resyncForRejoin​

▸ resyncForRejoin(): string[]

Returns​

string[]


takeOverdueRequests​

▸ takeOverdueRequests(now, overdueMs): OverdueChunkRequest[]

Requests outstanding for at least overdueMs. Each one is returned again only once another overdueMs has passed, so a caller asking every frame names a stuck chunk once per interval for as long as it stays stuck.

Parameters​

NameType
nownumber
overdueMsnumber

Returns​

OverdueChunkRequest[]