fix: stamps and indices
This commit is contained in:
parent
c848b07668
commit
10d6638452
|
@ -129,6 +129,7 @@ export default function Tiles({eventsChannel}) {
|
||||||
const y = Math.floor((c.y - top) / (tileSize.y * factor));
|
const y = Math.floor((c.y - top) / (tileSize.y * factor));
|
||||||
setMoveStart({x, y});
|
setMoveStart({x, y});
|
||||||
setSelection({x, y, w: 1, h: 1});
|
setSelection({x, y, w: 1, h: 1});
|
||||||
|
setStamp([[y * wt + x]]);
|
||||||
setIndices([y * wt + x]);
|
setIndices([y * wt + x]);
|
||||||
}}
|
}}
|
||||||
onMouseMove={(event) => {
|
onMouseMove={(event) => {
|
||||||
|
@ -172,19 +173,18 @@ export default function Tiles({eventsChannel}) {
|
||||||
}
|
}
|
||||||
setSelection(newSelection);
|
setSelection(newSelection);
|
||||||
const stamp = [];
|
const stamp = [];
|
||||||
const tw = w / tileSize.x;
|
|
||||||
for (let iy = 0; iy < sh; ++iy) {
|
for (let iy = 0; iy < sh; ++iy) {
|
||||||
const row = [];
|
const row = [];
|
||||||
for (let ix = 0; ix < sw; ++ix) {
|
for (let ix = 0; ix < sw; ++ix) {
|
||||||
row.push((y + iy) * tw + x + ix);
|
row.push((my + iy) * wt + mx + ix);
|
||||||
}
|
}
|
||||||
stamp.push(row);
|
stamp.push(row);
|
||||||
}
|
}
|
||||||
setStamp(stamp);
|
setStamp(stamp);
|
||||||
const indices = [];
|
const indices = [];
|
||||||
for (let sy = 0; sy < selection.h; ++sy) {
|
for (let sy = 0; sy < newSelection.h; ++sy) {
|
||||||
for (let sx = 0; sx < selection.w; ++sx) {
|
for (let sx = 0; sx < newSelection.w; ++sx) {
|
||||||
indices.push(((selection.y + sy) * wt) + (selection.x + sx));
|
indices.push(((newSelection.y + sy) * wt) + (newSelection.x + sx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setIndices(indices);
|
setIndices(indices);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user