prepare to make TILE_ZOOM_LEVEL actually change
This commit is contained in:
parent
d3e6010e07
commit
8ccbcddb59
|
@ -47,36 +47,41 @@ function deleteSubtilefromTile(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* adds an RGB tile as a shrunken tile to another
|
||||||
|
* @param subtilesInTile width of a subtile compared to the tile (power of 2)
|
||||||
|
* @param cell subtile coordinates [dx, dy]
|
||||||
|
* @param inpTile input tile
|
||||||
|
* @param tile output tile
|
||||||
|
*/
|
||||||
function addShrunkenSubtileToTile(
|
function addShrunkenSubtileToTile(
|
||||||
subtilesInTile,
|
subtilesInTile,
|
||||||
cell,
|
cell,
|
||||||
subtile,
|
inpTile,
|
||||||
buffer,
|
tile,
|
||||||
) {
|
) {
|
||||||
const tileSize = TILE_SIZE;
|
const tileSize = TILE_SIZE;
|
||||||
const [dx, dy] = cell;
|
const [dx, dy] = cell;
|
||||||
const offset = (dx + dy * subtilesInTile * tileSize / 4) * tileSize / 4;
|
const target = tileSize / subtilesInTile;
|
||||||
const target = tileSize / 4;
|
const offset = (dx + dy * tileSize) * target;
|
||||||
let tr;
|
let posA = 0;
|
||||||
let tg;
|
let posB;
|
||||||
let tb;
|
const pxlPad = (subtilesInTile - 1) * 3;
|
||||||
let pos;
|
const linePad = (tileSize * (subtilesInTile - 1) - 1) * 3;
|
||||||
let tmp;
|
|
||||||
const linePad = (tileSize * 3 - 1) * 3;
|
|
||||||
for (let row = 0; row < target; row += 1) {
|
for (let row = 0; row < target; row += 1) {
|
||||||
let channelOffset = (offset + row * target * subtilesInTile) * 3;
|
let channelOffset = (offset + row * tileSize) * 3;
|
||||||
const max = channelOffset + target * 3;
|
const max = channelOffset + target * 3;
|
||||||
pos = row * tileSize * 12;
|
|
||||||
while (channelOffset < max) {
|
while (channelOffset < max) {
|
||||||
tr = subtile[pos++];
|
const tr = inpTile[posA++];
|
||||||
tg = subtile[pos++];
|
const tg = inpTile[posA++];
|
||||||
tb = subtile[pos++];
|
const tb = inpTile[posA++];
|
||||||
pos += 9;
|
posA += pxlPad;
|
||||||
tmp = pos + linePad;
|
posB = posA + linePad;
|
||||||
buffer[channelOffset++] = (subtile[tmp++] + tr) / 2;
|
tile[channelOffset++] = (inpTile[posB++] + tr) >>> 1;
|
||||||
buffer[channelOffset++] = (subtile[tmp++] + tg) / 2;
|
tile[channelOffset++] = (inpTile[posB++] + tg) >>> 1;
|
||||||
buffer[channelOffset++] = (subtile[tmp++] + tb) / 2;
|
tile[channelOffset++] = (inpTile[posB] + tb) >>> 1;
|
||||||
}
|
}
|
||||||
|
posA = posB + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +481,7 @@ export async function createTexture(
|
||||||
// dont create textures larger than 4096
|
// dont create textures larger than 4096
|
||||||
const targetSize = Math.min(canvasSize, 4096);
|
const targetSize = Math.min(canvasSize, 4096);
|
||||||
const amount = targetSize / TILE_SIZE;
|
const amount = targetSize / TILE_SIZE;
|
||||||
const zoom = Math.log2(amount) / 2;
|
const zoom = Math.log2(amount) * 2 / TILE_ZOOM_LEVEL;
|
||||||
const textureBuffer = new Uint8Array(targetSize * targetSize * 3);
|
const textureBuffer = new Uint8Array(targetSize * targetSize * 3);
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user