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

Proposed fix for 5411 #5412

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 @@ -66,6 +66,7 @@ module.exports.Component = registerComponent('cursor', {
this.canvasBounds = document.body.getBoundingClientRect();
this.isCursorDown = false;
this.activeXRInput = null;
this.mouseAvailable = true;

// Debounce.
this.updateCanvasBounds = utils.debounce(function updateCanvasBounds () {
Expand Down Expand Up @@ -230,6 +231,7 @@ module.exports.Component = registerComponent('cursor', {
var pose;
var transform;

this.mouseAvailable = true;
camera.parent.updateMatrixWorld();

// Calculate mouse position based on the canvas element
Expand Down Expand Up @@ -276,6 +278,7 @@ module.exports.Component = registerComponent('cursor', {
* Trigger mousedown and keep track of the mousedowned entity.
*/
onCursorDown: function (evt) {
this.mouseAvailable = true;
this.isCursorDown = true;
// Raycast again for touch.
if (this.data.rayOrigin === 'mouse' && evt.type === 'touchstart') {
Expand Down Expand Up @@ -313,6 +316,7 @@ module.exports.Component = registerComponent('cursor', {
* in case user mousedowned one entity, dragged to another, and mouseupped.
*/
onCursorUp: function (evt) {
this.mouseAvailable = true;
if (!this.isCursorDown) { return; }

this.isCursorDown = false;
Expand Down Expand Up @@ -393,6 +397,7 @@ module.exports.Component = registerComponent('cursor', {
},

onEnterVR: function () {
this.mouseAvailable = false;
this.clearCurrentIntersection(true);
var xrSession = this.el.sceneEl.xrSession;
var self = this;
Expand All @@ -411,6 +416,9 @@ module.exports.Component = registerComponent('cursor', {
var data = this.data;
var self = this;

// mouse not available for use as rayOrigin (e.g. in VR w/o mouse)
if (this.data.rayOrigin === 'mouse' && !this.mouseAvailable) { return; }

// Already intersecting.
if (this.intersectedEl === intersectedEl) { return; }

Expand Down