Update updateSightLine for cube coords
This commit is contained in:
parent
2d3a8df1a8
commit
fb0e8847b3
@ -87,11 +87,14 @@ function clearSightLine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateSightLine(cell) {
|
function updateSightLine(cell) {
|
||||||
const { dataset: { x: sX }, parentElement: { dataset: { y: sY }}} = cell,
|
const CURRENT_ELEVATION_LEVEL = 0;
|
||||||
{ dataset: { x: tX }, parentElement: { dataset: { y: tY }}} = sightLine.getLockTarget();
|
const { q: sq, r: sr, s: ss } = cell.dataset;
|
||||||
|
const { q: tq, r: tr, s: ts } = sightLine.getLockTarget().dataset;
|
||||||
|
const sourceIndex = { q: +sq, r: +sr, s: +ss };
|
||||||
|
const targetIndex = { q: +tq, r: +tr, s: +ts };
|
||||||
|
|
||||||
const selector = sightLine.calcIndexes(+sX, +sY, +tX, +tY)
|
const selector = sightLine.calcIndexes(sourceIndex, targetIndex)
|
||||||
.map(([x, y]) => `g.grid g[data-y="${y}"] g[data-x="${x}"] use[href="#hex"]`)
|
.map(({ q, r, s }) => `g[data-q="${q}"][data-r="${r}"][data-s="${s}"][data-t="${CURRENT_ELEVATION_LEVEL}"] use[href="#hex"]`)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
||||||
const hexes = svg.querySelectorAll(selector);
|
const hexes = svg.querySelectorAll(selector);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user