Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle update on rayOrigin from mouse -> entity #4760

Merged
merged 3 commits into from
Nov 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading