From 5eb4f5c432733b39678eb8b26e4d2eda680805ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cchrisshank=E2=80=9D?= Date: Sun, 1 Dec 2024 20:14:41 -0800 Subject: [PATCH] fix sdf bug --- src/distance-field.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/distance-field.ts b/src/distance-field.ts index 81c45f0..ac354b9 100644 --- a/src/distance-field.ts +++ b/src/distance-field.ts @@ -158,11 +158,12 @@ export class DistanceField extends HTMLElement { const rect = geometry.getClientRect(); const windowWidth = window.innerWidth; + const windowHeight = window.innerHeight; // Convert DOM coordinates to Normalized Device Coordinates (NDC) const x1 = (rect.left / windowWidth) * 2 - 1; - const y1 = -((rect.top / windowWidth) * 2 - 1); + const y1 = -((rect.top / windowHeight) * 2 - 1); const x2 = (rect.right / windowWidth) * 2 - 1; - const y2 = -((rect.bottom / windowWidth) * 2 - 1); + const y2 = -((rect.bottom / windowHeight) * 2 - 1); const shapeID = index + 1; // Avoid zero to prevent hash function issues