From 1047eacb9bc532683adeb8e20d6981f18ad7037c Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Mon, 25 Nov 2024 23:26:40 +0100 Subject: [PATCH] Make cursor component work when camera is not an entity like in the inspector (#5614) * Make cursor component work when camera is not an entity like in the inspector * Assign cameraElParent and do the world transform only if we have a pose --- src/components/cursor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/cursor.js b/src/components/cursor.js index 6d5518e8f28..f5524836136 100644 --- a/src/components/cursor.js +++ b/src/components/cursor.js @@ -263,7 +263,7 @@ module.exports.Component = registerComponent('cursor', { return function (evt) { var bounds = this.canvasBounds; var camera = this.el.sceneEl.camera; - var cameraElParent = camera.el.object3D.parent; + var cameraElParent; var left; var point; var top; @@ -301,6 +301,7 @@ module.exports.Component = registerComponent('cursor', { origin.copy(transform.position); // Transform XRPose into world space + cameraElParent = camera.el.object3D.parent; cameraElParent.localToWorld(origin); direction.transformDirection(cameraElParent.matrixWorld); }