Skip to content

Commit 9e7f022

Browse files
authored
Merge pull request #202 from felixtrz/anchors-sample-fix
fix anchor sample: anchor creation timing
2 parents f846e7d + 2da1357 commit 9e7f022

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

anchors.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,14 @@
252252
});
253253

254254
tracked_anchors.forEach(anchor => {
255-
const anchorPose = frame.getPose(anchor.anchorSpace, xrRefSpace);
256-
if (anchorPose) {
257-
anchor.context.sceneObject.matrix = anchorPose.transform.matrix;
258-
anchor.context.sceneObject.visible = true;
259-
} else {
260-
anchor.context.sceneObject.visible = false;
255+
if (anchor.context) {
256+
const anchorPose = frame.getPose(anchor.anchorSpace, xrRefSpace);
257+
if (anchorPose) {
258+
anchor.context.sceneObject.matrix = anchorPose.transform.matrix;
259+
anchor.context.sceneObject.visible = true;
260+
} else {
261+
anchor.context.sceneObject.visible = false;
262+
}
261263
}
262264
});
263265

0 commit comments

Comments
 (0)