From 61b4c8abc3df2c1dde1bae391c80cf632d454a5d Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 14 Jan 2021 11:38:52 +1100 Subject: [PATCH] Fix error with hidding all fog shapes, and visiual bug with hiding first fog shape --- src/helpers/drawing.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpers/drawing.js b/src/helpers/drawing.js index 4e60ffa..69853b2 100644 --- a/src/helpers/drawing.js +++ b/src/helpers/drawing.js @@ -311,6 +311,9 @@ export function mergeShapes(shapes) { let shapeGeom = [[shapePoints, ...shapeHoles]]; geometries.push(shapeGeom); } + if (geometries.length === 0) { + return geometries; + } let union = polygonClipping.union(...geometries); let merged = []; for (let i = 0; i < union.length; i++) { @@ -321,7 +324,8 @@ export function mergeShapes(shapes) { } } merged.push({ - ...shapes[0], + // Use the data of the first visible shape as the merge + ...shapes.find((shape) => shape.visible), id: `merged-${i}`, data: { points: union[i][0].map(([x, y]) => ({ x, y })),