From 6da082d961582fb8c1d60ee3f2ed932302a4f0c8 Mon Sep 17 00:00:00 2001 From: Rahul Ghosh Date: Fri, 2 Aug 2024 22:49:29 +0530 Subject: [PATCH] fix viewport freeze on redocking (#10810) --- packages/spatial/src/input/systems/ClientInputSystem.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/spatial/src/input/systems/ClientInputSystem.tsx b/packages/spatial/src/input/systems/ClientInputSystem.tsx index 5e435e48e5..80cec9d226 100755 --- a/packages/spatial/src/input/systems/ClientInputSystem.tsx +++ b/packages/spatial/src/input/systems/ClientInputSystem.tsx @@ -229,7 +229,8 @@ const execute = () => { for (const eid of pointers()) { const pointer = getComponent(eid, InputPointerComponent) const inputSource = getComponent(eid, InputSourceComponent) - const camera = getComponent(pointer.cameraEntity, CameraComponent) + const camera = getOptionalComponent(pointer.cameraEntity, CameraComponent) + if (!camera) continue //when we reparent viewport we lose the camera temporarily pointer.movement.copy(pointer.position).sub(pointer.lastPosition) pointer.lastPosition.copy(pointer.position) inputSource.raycaster.setFromCamera(pointer.position, camera)