1 ViewFrame.initInfobox = function (ibox, iboxSlots) {
4 .chunkMetadataNames.forEach((item, i) => {
5 const slot = document.createElement('tr');
6 const head = document.createElement('th');
8 const row = document.createElement('td');
11 slot.append(head, row);
16 ViewFrame.prototype.updateEdges = function () {
17 if (this.width != window.innerWidth || this.height != window.innerHeight) {
18 this.width = window.innerWidth;
19 this.map.canvas.width = this.width;
20 this.height = window.innerHeight;
21 this.map.canvas.height = this.height;
22 this.map.imageSmoothingEnabled = false;
24 const chunksWide = Math.ceil(this.width / this.zoom);
25 const chunksHigh = Math.ceil(this.height / this.zoom);
27 this.east = this.x + chunksWide / 2; // this is fractional and is used to keep track of the edges of the window
28 this.eastChunk = Math.ceil(this.east); // this is not and is used to track the chunks that need to load
29 this.west = this.x - chunksWide / 2;
30 this.westChunk = Math.floor(this.west);
31 this.north = this.y + chunksHigh / 2;
32 this.northChunk = Math.ceil(this.north);
33 this.south = this.y - chunksHigh / 2;
34 this.southChunk = Math.floor(this.south);
38 * dx and dy are the distances in chunks
40 ViewFrame.prototype.moveCenter = function (dx, dy) {
41 // to pan when we click on the map!
42 this.x += (dx - this.width / 2) / this.zoom;
43 this.y += (dy - this.height / 2) / this.zoom;
47 * x and y are positions in chunks
49 ViewFrame.prototype.setCenter = function (x, y) {
55 * x and y are positions in BLOCKS!!!!
57 ViewFrame.prototype.setBlockwiseCenter = function (x, y) {
58 this.x = x / this.zoom;
59 this.y = y / this.zoom;
62 ViewFrame.prototype.clear = function () {
63 this.loadedChunksByName.clear();
64 this.loadedChunksByCoords.clear();
65 if (this.chunkScript) this.chunkScript.remove();
66 delete this.chunkScript;
67 delete ViewFrame.chunks;
68 this.map.clearRect(0, 0, window.innerWidth, window.innerHeight);
71 function decode(img, cb) {
76 .catch(() => {}); // so images arent added on error