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
  • Loading branch information
vincentfretin committed Nov 25, 2024
1 parent d26ea9f commit a793ad5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions 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 = camera.el ? camera.el.object3D.parent : null;
var left;
var point;
var top;
Expand Down Expand Up @@ -301,8 +301,10 @@ module.exports.Component = registerComponent('cursor', {
origin.copy(transform.position);

// Transform XRPose into world space
cameraElParent.localToWorld(origin);
direction.transformDirection(cameraElParent.matrixWorld);
if (cameraElParent) {
cameraElParent.localToWorld(origin);
direction.transformDirection(cameraElParent.matrixWorld);
}
}
} else if (evt.type === 'fakeselectout') {
direction.set(0, 1, 0);
Expand Down

0 comments on commit a793ad5

Please sign in to comment.