Skip to content

Commit

Permalink
Make cursor component work when camera is not an entity like in the i…
Browse files Browse the repository at this point in the history
…nspector (#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
  • Loading branch information
vincentfretin authored Nov 25, 2024
1 parent d26ea9f commit 1047eac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1047eac

Please sign in to comment.