fix overlay issues during interstitial mode

This commit is contained in:
Dante Ruiz 2018-10-10 12:00:58 -07:00
parent 91df342ae9
commit 296ea8a5af

View file

@ -20,6 +20,7 @@ Script.include("/~/system/libraries/controllers.js");
this.hand = hand;
this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND;
this.running = false;
this.ignoredOverlays = [];
this.parameters = makeDispatcherModuleParameters(
160,
@ -67,6 +68,42 @@ Script.include("/~/system/libraries/controllers.js");
return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput;
};
this.addOverlayToIgnoreList = function(controllerData) {
if (Window.interstitialModeEnabled && !Window.isPhysicsEnabled()) {
var intersection = controllerData.rayPicks[this.hand];
var objectID = intersection.objectID;
if (intersection.type === Picks.INTERSECTED_OVERLAY) {
var overlayIndex = this.ignoredOverlays.indexOf(objectID);
if (overlayIndex === -1) {
var overlayName = Overlays.getProperty(objectID, "name");
if (overlayName !== "Loading-Destination-Card-Text" && overlayName !== "Loading-Destination-Card-GoTo-Image" &&
overlayName !== "Loading-Destination-Card-GoTo-Image-Hover") {
var data = {
action: 'add',
id: objectID
};
Messages.sendMessage('Hifi-Hand-RayPick-Blacklist', JSON.stringify(data));
this.ignoredOverlays.push(objectID);
}
}
}
}
};
this.restoreIgnoredOverlays = function() {
for (var index = 0; index < this.ignoredOverlays.length; index++) {
var data = {
action: 'remove',
id: this.ignoredOverlays[index]
};
Messages.sendMessage('Hifi-Hand-RayPick-Blacklist', JSON.stringify(data));
}
this.ignoredOverlays = [];
};
this.isPointingAtTriggerable = function(controllerData, triggerPressed, checkEntitiesOnly) {
// allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger,
// but for pointing at locked web entities or non-web overlays user must be pressing trigger
@ -143,6 +180,7 @@ Script.include("/~/system/libraries/controllers.js");
var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun;
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn;
this.addOverlayToIgnoreList(controllerData);
if (allowThisModule) {
if (isTriggerPressed && !this.isPointingAtTriggerable(controllerData, isTriggerPressed, true)) {
// if trigger is down + not pointing at a web entity, keep running web surface laser
@ -156,6 +194,7 @@ Script.include("/~/system/libraries/controllers.js");
this.deleteContextOverlay();
this.running = false;
this.dominantHandOverride = false;
this.restoreIgnoredOverlays();
return makeRunningValues(false, [], []);
}
}
@ -163,6 +202,7 @@ Script.include("/~/system/libraries/controllers.js");
this.deleteContextOverlay();
this.running = false;
this.dominantHandOverride = false;
this.restoreIgnoredOverlays();
return makeRunningValues(false, [], []);
};
}