toggle controller raycaster only in VR

This commit is contained in:
Kevin Ngo
2018-09-20 18:05:32 -07:00
parent 2804a41bb6
commit 2cc1fac9c9
3 changed files with 11 additions and 3 deletions

View File

@@ -30,6 +30,9 @@ AFRAME.registerComponent('debug-controller', {
secondaryHand.setAttribute('controller', 'controllerType', 'vive-controls');
}
// Enable raycaster.
this.el.emit('enter-vr', null, false);
document.addEventListener('keydown', evt => {
var primaryPosition;
var primaryRotation;

View File

@@ -63,9 +63,9 @@
{% macro saber (hand, otherHand, color) %}
<a-entity id="{{ hand }}Hand"
mixin="raycaster"
bind__hand-swapper="enabled: menu.active && activeHand === '{{ otherHand }}'"
bind__hand-swapper="enabled: {{ otherHand }}RaycasterActive"
bind__pauser="enabled: !menu.active"
bind__raycaster="enabled: menu.active && activeHand === '{{ hand }}'; showLine: menu.active && activeHand === '{{ hand }}'"
bind__raycaster="enabled: {{ hand }}RaycasterActive; showLine: {{ hand }}RaycasterActive"
bind__saber-controls="bladeEnabled: !menu.active"
cursor
saber-controls="hand: {{ hand }}"

View File

@@ -164,7 +164,12 @@ AFRAME.registerState({
/**
* Post-process the state after each action.
*/
// computeState: (state) => { }
computeState: (state) => {
state.leftRaycasterActive = state.menu.active && state.activeHand === 'left' &&
state.inVR;
state.rightRaycasterActive = state.menu.active && state.activeHand === 'right' &&
state.inVR;
}
});
function computeSearchPagination (state) {