Skip to content

Commit cd1326b

Browse files
kylebakeriodmarcos
andauthored
handle update on rayOrigin from mouse -> entity (#4760)
* handle update on rayOrigin from mouse -> entity fixes issue #4759 * remove space --------- Co-authored-by: Diego Marcos <diego.marcos@gmail.com>
1 parent 9230d86 commit cd1326b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/components/cursor.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ module.exports.Component = registerComponent('cursor', {
8686

8787
update: function (oldData) {
8888
if (this.data.rayOrigin === oldData.rayOrigin) { return; }
89+
if (this.data.rayOrigin === 'entity') { this.resetRaycaster(); }
8990
this.updateMouseEventListeners();
9091
// Update the WebXR event listeners if needed
9192
if (this.data.rayOrigin === 'xrselect') {
@@ -220,6 +221,13 @@ module.exports.Component = registerComponent('cursor', {
220221
this.updateCanvasBounds();
221222
},
222223

224+
resetRaycaster: function () {
225+
this.el.setAttribute('raycaster', {
226+
direction: new THREE.Vector3().set(0, 0, -1),
227+
origin: new THREE.Vector3()
228+
});
229+
},
230+
223231
addWebXREventListeners: function () {
224232
var self = this;
225233
var xrSession = this.el.sceneEl.xrSession;

0 commit comments

Comments
 (0)