forked from ppfun/pixelplanet
enable garbage collection for 3D (again)
This commit is contained in:
parent
32152fc9ba
commit
bedd7b82e5
|
@ -102,6 +102,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
ProtocolClient.deRegisterChunk([xc, yc]);
|
||||
}
|
||||
chunks.delete(key);
|
||||
value.destructor();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -58,6 +58,10 @@ class ChunkLoader {
|
|||
return 0;
|
||||
}
|
||||
|
||||
getAllChunks() {
|
||||
return this.chunks;
|
||||
}
|
||||
|
||||
getVoxelUpdate(
|
||||
xc: number,
|
||||
zc: number,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue
Block a user