From 9eae5aee36904e883e93c533dde9e48802a52959 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Jan 2024 14:00:37 +0800 Subject: [PATCH] fix: return [0, 0] from calculatePosition if camera projection fails --- src/Html.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Html.tsx b/src/Html.tsx index ff5c29b..2ea3909 100644 --- a/src/Html.tsx +++ b/src/Html.tsx @@ -23,6 +23,9 @@ function calculatePosition( ) { const objectPos = v1.setFromMatrixPosition(el.matrixWorld); objectPos.project(camera); + if (isNaN(objectPos.x) || isNaN(objectPos.y)) { + return [0, 0]; + } const widthHalf = size.width / 2; const heightHalf = size.height / 2; return [