Skip to content

Commit

Permalink
feat: add function to get the next chunk processing data
Browse files Browse the repository at this point in the history
  • Loading branch information
Sceat committed Jan 24, 2025
1 parent bd3d10e commit c4877ce
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/processing/ChunksBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ export class ViewChunksBatch extends BatchProcess<ChunksProcessor> {
return viewChanged
}

computeView(viewCenter: Vector2, viewRange: number) {
const bmin = viewCenter.clone().subScalar(viewRange)
const bmax = viewCenter.clone().addScalar(viewRange)
const patchViewRange = new Box2(bmin, bmax)
const patchIndex: Record<PatchKey, boolean> = {}
// const patchIds = []
const { min, max } = patchViewRange
for (let { y } = min; y <= max.y; y++) {
for (let { x } = min; x <= max.x; x++) {
const patchId = new Vector2(x, y)
const patchKey = serializePatchId(patchId)
patchIndex[patchKey] = true
}
}
return patchIndex
}

/**
* called each time view center or range change to regen chunks index
*/
Expand Down

0 comments on commit c4877ce

Please sign in to comment.