Skip to content

Commit b7f65b8

Browse files
committed
Fix entity rect sizes shown on map do not adapt to zoom
1 parent ef29721 commit b7f65b8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/worker/MapRendererWorker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,11 @@ export class MapRendererWorker {
140140
}, MAP_MAX_UPDATE_INTERVAL)
141141
context.clearRect(0, 0, context.canvas.width, context.canvas.height)
142142
context.fillStyle = rectColor
143+
const normalizedRectSize = Math.max(1, Math.round(rectSize / 15 * msg.surfaceRectSize))
143144
msg.entities.forEach((e) => {
144-
const x = Math.round(e.x * msg.surfaceRectSize / TILESIZE - msg.offset.x - rectSize / 2)
145-
const y = Math.round(e.z * msg.surfaceRectSize / TILESIZE - msg.offset.y - rectSize / 2)
146-
context.fillRect(x, y, rectSize, rectSize)
145+
const x = Math.round(e.x * msg.surfaceRectSize / TILESIZE - msg.offset.x - normalizedRectSize / 2)
146+
const y = Math.round(e.z * msg.surfaceRectSize / TILESIZE - msg.offset.y - normalizedRectSize / 2)
147+
context.fillRect(x, y, normalizedRectSize, normalizedRectSize)
147148
})
148149
}
149150

0 commit comments

Comments
 (0)