From 2a899501329f02bd4aa7dc1e22f521a77accb20c Mon Sep 17 00:00:00 2001 From: Aioros Date: Tue, 24 Sep 2024 14:05:43 -0400 Subject: [PATCH 1/2] fix: wait for all drawings to be ready before creating the masks --- src/particle-effects/drawings-mask.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/particle-effects/drawings-mask.js b/src/particle-effects/drawings-mask.js index 08e23136..3ac96133 100644 --- a/src/particle-effects/drawings-mask.js +++ b/src/particle-effects/drawings-mask.js @@ -2,7 +2,13 @@ import { packageId } from "../constants.js"; export function registeDrawingsMaskFunctionality() { Hooks.on("canvasReady", () => { - requestAnimationFrame(drawDrawingsMask); + Hooks.once(`${packageId}.drawingsReady`, drawDrawingsMask); + }); + + Hooks.on("refreshDrawing", (drawing) => { + if (canvas.drawings.placeables.every(drawing => drawing.shape.geometry.graphicsData.length > 0)) { + Hooks.call(`${packageId}.drawingsReady`); + } }); for (const hook of ["updateDrawing", "createDrawing", "deleteDrawing"]) { From 431a8e68d802eb7324232a4a8956eb4b5a79e1b3 Mon Sep 17 00:00:00 2001 From: Aioros Date: Tue, 24 Sep 2024 14:16:17 -0400 Subject: [PATCH 2/2] chore: eslint requirements --- src/particle-effects/drawings-mask.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/particle-effects/drawings-mask.js b/src/particle-effects/drawings-mask.js index 3ac96133..20557091 100644 --- a/src/particle-effects/drawings-mask.js +++ b/src/particle-effects/drawings-mask.js @@ -5,8 +5,8 @@ export function registeDrawingsMaskFunctionality() { Hooks.once(`${packageId}.drawingsReady`, drawDrawingsMask); }); - Hooks.on("refreshDrawing", (drawing) => { - if (canvas.drawings.placeables.every(drawing => drawing.shape.geometry.graphicsData.length > 0)) { + Hooks.on("refreshDrawing", () => { + if (canvas.drawings.placeables.every((drawing) => drawing.shape.geometry.graphicsData.length > 0)) { Hooks.call(`${packageId}.drawingsReady`); } });