Skip to content

Commit

Permalink
handle update on rayOrigin from mouse -> entity (#4760)
Browse files Browse the repository at this point in the history
* handle update on rayOrigin from mouse -> entity

fixes issue #4759

* remove space

---------

Co-authored-by: Diego Marcos <[email protected]>
  • Loading branch information
kylebakerio and dmarcos authored Nov 23, 2024
1 parent 9230d86 commit cd1326b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module.exports.Component = registerComponent('cursor', {

update: function (oldData) {
if (this.data.rayOrigin === oldData.rayOrigin) { return; }
if (this.data.rayOrigin === 'entity') { this.resetRaycaster(); }
this.updateMouseEventListeners();
// Update the WebXR event listeners if needed
if (this.data.rayOrigin === 'xrselect') {
Expand Down Expand Up @@ -220,6 +221,13 @@ module.exports.Component = registerComponent('cursor', {
this.updateCanvasBounds();
},

resetRaycaster: function () {
this.el.setAttribute('raycaster', {
direction: new THREE.Vector3().set(0, 0, -1),
origin: new THREE.Vector3()
});
},

addWebXREventListeners: function () {
var self = this;
var xrSession = this.el.sceneEl.xrSession;
Expand Down

0 comments on commit cd1326b

Please sign in to comment.