Disable grab.js picks when in HMD

This commit is contained in:
sabrina-shanman 2019-07-18 12:54:36 -07:00
parent fcaa64b9ef
commit 79d09f68fd

View file

@ -221,6 +221,20 @@ function Grabber() {
});
}
Grabber.prototype.setPicksEnabled = function(enabled) {
if (enabled) {
Picks.enablePick(this.mouseRayOverlays);
Pointers.enablePointer(this.mouseRayEntities);
} else {
Picks.disablePick(this.mouseRayOverlays);
Pointers.disablePointer(this.mouseRayEntities);
}
}
Grabber.prototype.displayModeChanged = function(isHMDMode) {
this.setPicksEnabled(!isHMDMode);
}
Grabber.prototype.computeNewGrabPlane = function() {
if (!this.isGrabbing) {
return;
@ -488,6 +502,10 @@ Grabber.prototype.cleanup = function() {
var grabber = new Grabber();
function displayModeChanged(isHMDMode) {
grabber.displayModeChanged(isHMDMode);
}
function pressEvent(event) {
grabber.pressEvent(event);
}
@ -517,6 +535,7 @@ Controller.mouseMoveEvent.connect(moveEvent);
Controller.mouseReleaseEvent.connect(releaseEvent);
Controller.keyPressEvent.connect(keyPressEvent);
Controller.keyReleaseEvent.connect(keyReleaseEvent);
HMD.displayModeChanged.connect(displayModeChanged);
Script.scriptEnding.connect(cleanup);
}()); // END LOCAL_SCOPE