From 2da135754ddeda72ad050ec9f428a4340328f406 Mon Sep 17 00:00:00 2001 From: Felix Z Date: Thu, 5 Dec 2024 22:35:00 +0000 Subject: [PATCH] fix anchor sample: anchor creation timing --- anchors.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/anchors.html b/anchors.html index 83f62904d..4431b315d 100644 --- a/anchors.html +++ b/anchors.html @@ -252,12 +252,14 @@ }); tracked_anchors.forEach(anchor => { - const anchorPose = frame.getPose(anchor.anchorSpace, xrRefSpace); - if (anchorPose) { - anchor.context.sceneObject.matrix = anchorPose.transform.matrix; - anchor.context.sceneObject.visible = true; - } else { - anchor.context.sceneObject.visible = false; + if (anchor.context) { + const anchorPose = frame.getPose(anchor.anchorSpace, xrRefSpace); + if (anchorPose) { + anchor.context.sceneObject.matrix = anchorPose.transform.matrix; + anchor.context.sceneObject.visible = true; + } else { + anchor.context.sceneObject.visible = false; + } } });