Skip to content

Commit

Permalink
hotfix: only set cursor in ar-mode for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-liang committed Jun 7, 2023
1 parent a3e2194 commit d39414e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/components/ar-hit-test-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,26 @@ AFRAME.registerComponent('ar-hit-test-listener', {
if (this.el.is('ar-mode')) {
this.el.addEventListener('ar-hit-test-select-start', this.hitStartHandler);
this.el.addEventListener('ar-hit-test-select', this.hitEndHandler);
this.el.setAttribute('cursor', {rayOrigin: 'xrselect', fuse: false});
this.el.setAttribute('raycaster', {objects: '[click-listener],[click-listener-local]'});
this.mouseCursor.removeAttribute('cursor');
this.mouseCursor.removeAttribute('raycaster');
if (AFRAME.utils.device.isMobile()) {
this.el.setAttribute('cursor', {rayOrigin: 'xrselect', fuse: false});
this.el.setAttribute('raycaster', {objects: '[click-listener],[click-listener-local]'});
this.mouseCursor.removeAttribute('cursor');
this.mouseCursor.removeAttribute('raycaster');

this.el.components['cursor'].onEnterVR(); // Manually trigger cursor
this.el.components['cursor'].onEnterVR(); // Manually trigger cursor
}
}
},

exitARHandler: function() {
this.el.removeEventListener('ar-hit-test-select-start', this.hitStartHandler);
this.el.removeEventListener('ar-hit-test-select', this.hitEndHandler);
this.el.removeAttribute('cursor');
this.el.removeAttribute('raycaster');
this.mouseCursor.setAttribute('cursor', {rayOrigin: 'mouse'});
this.mouseCursor.setAttribute('raycaster', {objects: '[click-listener],[click-listener-local]'});
if (AFRAME.utils.device.isMobile()) {
this.el.removeAttribute('cursor');
this.el.removeAttribute('raycaster');
this.mouseCursor.setAttribute('cursor', {rayOrigin: 'mouse'});
this.mouseCursor.setAttribute('raycaster', {objects: '[click-listener],[click-listener-local]'});
}
},

hitStartHandler: function(evt) {
Expand Down

0 comments on commit d39414e

Please sign in to comment.