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));
|
||||
setMoveStart({x, y});
|
||||
setSelection({x, y, w: 1, h: 1});
|
||||
setStamp([[y * wt + x]]);
|
||||
setIndices([y * wt + x]);
|
||||
}}
|
||||
onMouseMove={(event) => {
|
||||
|
@ -172,19 +173,18 @@ export default function Tiles({eventsChannel}) {
|
|||
}
|
||||
setSelection(newSelection);
|
||||
const stamp = [];
|
||||
const tw = w / tileSize.x;
|
||||
for (let iy = 0; iy < sh; ++iy) {
|
||||
const row = [];
|
||||
for (let ix = 0; ix < sw; ++ix) {
|
||||
row.push((y + iy) * tw + x + ix);
|
||||
row.push((my + iy) * wt + mx + ix);
|
||||
}
|
||||
stamp.push(row);
|
||||
}
|
||||
setStamp(stamp);
|
||||
const indices = [];
|
||||
for (let sy = 0; sy < selection.h; ++sy) {
|
||||
for (let sx = 0; sx < selection.w; ++sx) {
|
||||
indices.push(((selection.y + sy) * wt) + (selection.x + sx));
|
||||
for (let sy = 0; sy < newSelection.h; ++sy) {
|
||||
for (let sx = 0; sx < newSelection.w; ++sx) {
|
||||
indices.push(((newSelection.y + sy) * wt) + (newSelection.x + sx));
|
||||
}
|
||||
}
|
||||
setIndices(indices);
|
||||
|
|
Loading…
Reference in New Issue
Block a user