diff --git a/src/client.js b/src/client.js index e442bef1..03fd16d8 100644 --- a/src/client.js +++ b/src/client.js @@ -102,6 +102,7 @@ document.addEventListener('DOMContentLoaded', () => { ProtocolClient.deRegisterChunk([xc, yc]); } chunks.delete(key); + value.destructor(); } } }); diff --git a/src/ui/ChunkLoader3D.js b/src/ui/ChunkLoader3D.js index daefcc1f..d1c51dc2 100644 --- a/src/ui/ChunkLoader3D.js +++ b/src/ui/ChunkLoader3D.js @@ -58,6 +58,10 @@ class ChunkLoader { return 0; } + getAllChunks() { + return this.chunks; + } + getVoxelUpdate( xc: number, zc: number, diff --git a/src/ui/ChunkRGB.js b/src/ui/ChunkRGB.js index 0b0bd52c..7450d9d5 100644 --- a/src/ui/ChunkRGB.js +++ b/src/ui/ChunkRGB.js @@ -8,14 +8,13 @@ import { TILE_SIZE } from '../core/constants'; class ChunkRGB { cell: Array; - key: string; image: HTMLCanvasElement; ready: boolean; timestamp: number; palette: Palette; isBasechunk: boolean; - constructor(palette: Palette, key, zoom = 0, cx = 0, cy = 0) { + constructor(palette: Palette, zoom = 0, cx = 0, cy = 0) { // isBasechunk gets set to true by RECEIVE_BIG_CHUNK // if true => chunk got requested from api/chunk and // receives websocket pixel updates @@ -25,12 +24,16 @@ class ChunkRGB { this.image = document.createElement('canvas'); this.image.width = TILE_SIZE; this.image.height = TILE_SIZE; - this.key = key; this.cell = [zoom, cx, cy]; this.ready = false; this.timestamp = Date.now(); } + // eslint-disable-next-line class-methods-use-this + destructor() { + return null; + } + fromBuffer(chunkBuffer: Uint8Array) { const imageData = new ImageData(TILE_SIZE, TILE_SIZE); const imageView = new Uint32Array(imageData.data.buffer); diff --git a/src/ui/Renderer3D.js b/src/ui/Renderer3D.js index 5f997597..d62d16f8 100644 --- a/src/ui/Renderer3D.js +++ b/src/ui/Renderer3D.js @@ -262,7 +262,7 @@ class Renderer { // TODO use GC to dispose unused chunks // eslint-disable-next-line class-methods-use-this getAllChunks() { - return null; + return this.chunkLoader.getAllChunks(); } renderPixel(