Fix error with hidding all fog shapes, and visiual bug with hiding first fog shape

This commit is contained in:
Mitchell McCaffrey 2021-01-14 11:38:52 +11:00
parent 2311bf2b5b
commit 61b4c8abc3

View File

@ -311,6 +311,9 @@ export function mergeShapes(shapes) {
let shapeGeom = [[shapePoints, ...shapeHoles]]; let shapeGeom = [[shapePoints, ...shapeHoles]];
geometries.push(shapeGeom); geometries.push(shapeGeom);
} }
if (geometries.length === 0) {
return geometries;
}
let union = polygonClipping.union(...geometries); let union = polygonClipping.union(...geometries);
let merged = []; let merged = [];
for (let i = 0; i < union.length; i++) { for (let i = 0; i < union.length; i++) {
@ -321,7 +324,8 @@ export function mergeShapes(shapes) {
} }
} }
merged.push({ merged.push({
...shapes[0], // Use the data of the first visible shape as the merge
...shapes.find((shape) => shape.visible),
id: `merged-${i}`, id: `merged-${i}`,
data: { data: {
points: union[i][0].map(([x, y]) => ({ x, y })), points: union[i][0].map(([x, y]) => ({ x, y })),