mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-18 20:20:12 +02:00
Don't highlight tablet when it is grabbed
This commit is contained in:
parent
f84f3b20cd
commit
9203bbc5d8
2 changed files with 55 additions and 48 deletions
|
@ -37,20 +37,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
PROFILE = true;
|
||||
}
|
||||
|
||||
var TABLET_GRABBABLE_SELECTION_NAME = "tabletGrabbableSelection";
|
||||
var TABLET_GRABBABLE_SELECTION_STYLE = {
|
||||
outlineUnoccludedColor: { red: 0, green: 180, blue: 239 }, // #00b4ef
|
||||
outlineUnoccludedAlpha: 1,
|
||||
outlineOccludedColor: { red: 0, green: 0, blue: 0 },
|
||||
outlineOccludedAlpha: 0,
|
||||
fillUnoccludedColor: { red: 0, green: 0, blue: 0 },
|
||||
fillUnoccludedAlpha: 0,
|
||||
fillOccludedColor: { red: 0, green: 0, blue: 0 },
|
||||
fillOccludedAlpha: 0,
|
||||
outlineWidth: 2,
|
||||
isOutlineSmooth: false
|
||||
};
|
||||
|
||||
function ControllerDispatcher() {
|
||||
var _this = this;
|
||||
this.lastInterval = Date.now();
|
||||
|
@ -182,8 +168,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
Script.setTimeout(_this.update, BASIC_TIMER_INTERVAL_MS);
|
||||
};
|
||||
|
||||
this.isTabletNearGrabbable = false;
|
||||
|
||||
this.updateInternal = function () {
|
||||
if (PROFILE) {
|
||||
Script.beginProfileRange("dispatch.pre");
|
||||
|
@ -222,7 +206,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
|
||||
// find 3d overlays near each hand
|
||||
var nearbyOverlayIDs = [];
|
||||
var isTabletNearGrabbable = false;
|
||||
var h;
|
||||
for (h = LEFT_HAND; h <= RIGHT_HAND; h++) {
|
||||
if (controllerLocations[h].valid) {
|
||||
|
@ -235,26 +218,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
var bDistance = Vec3.distance(bPosition, controllerLocations[h].position);
|
||||
return aDistance - bDistance;
|
||||
});
|
||||
if (HMD.tabletID && nearbyOverlays.indexOf(HMD.tabletID) !== -1) {
|
||||
isTabletNearGrabbable = true;
|
||||
}
|
||||
nearbyOverlayIDs.push(nearbyOverlays);
|
||||
} else {
|
||||
nearbyOverlayIDs.push([]);
|
||||
}
|
||||
}
|
||||
|
||||
// Highlight tablet if it is near-grabbable.
|
||||
if (isTabletNearGrabbable !== _this.isTabletNearGrabbable) {
|
||||
if (isTabletNearGrabbable) {
|
||||
Selection.addToSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID);
|
||||
} else {
|
||||
Selection.removeFromSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID);
|
||||
}
|
||||
_this.isTabletNearGrabbable = isTabletNearGrabbable;
|
||||
}
|
||||
|
||||
|
||||
// find entities near each hand
|
||||
var nearbyEntityProperties = [[], []];
|
||||
var nearbyEntityPropertiesByID = {};
|
||||
|
@ -540,24 +509,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
Overlays.mousePressOnOverlay.connect(mousePress);
|
||||
Entities.mousePressOnEntity.connect(mousePress);
|
||||
|
||||
function onDisplayModeChanged() {
|
||||
if (HMD.active) {
|
||||
Selection.enableListHighlight(TABLET_GRABBABLE_SELECTION_NAME, TABLET_GRABBABLE_SELECTION_STYLE);
|
||||
} else {
|
||||
Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME);
|
||||
Selection.clearSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
HMD.displayModeChanged.connect(onDisplayModeChanged);
|
||||
HMD.mountedChanged.connect(onDisplayModeChanged);
|
||||
|
||||
var controllerDispatcher = new ControllerDispatcher();
|
||||
Messages.subscribe('Hifi-Hand-RayPick-Blacklist');
|
||||
Messages.messageReceived.connect(controllerDispatcher.handleHandMessage);
|
||||
Script.scriptEnding.connect(function () {
|
||||
controllerDispatcher.cleanup();
|
||||
Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME);
|
||||
});
|
||||
Script.scriptEnding.connect(controllerDispatcher.cleanup);
|
||||
Script.setTimeout(controllerDispatcher.update, BASIC_TIMER_INTERVAL_MS);
|
||||
}());
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// nearTabletHighlight.js
|
||||
//
|
||||
// Highlight the tablet if a hand is near enough to grab it.
|
||||
// Highlight the tablet if a hand is near enough to grab it and it isn't grabbed.
|
||||
//
|
||||
// Created by David Rowe on 28 Aug 2018.
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
|
@ -19,6 +19,43 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
|
||||
"use strict";
|
||||
|
||||
var TABLET_GRABBABLE_SELECTION_NAME = "tabletGrabbableSelection";
|
||||
var TABLET_GRABBABLE_SELECTION_STYLE = {
|
||||
outlineUnoccludedColor: { red: 0, green: 180, blue: 239 }, // #00b4ef
|
||||
outlineUnoccludedAlpha: 1,
|
||||
outlineOccludedColor: { red: 0, green: 0, blue: 0 },
|
||||
outlineOccludedAlpha: 0,
|
||||
fillUnoccludedColor: { red: 0, green: 0, blue: 0 },
|
||||
fillUnoccludedAlpha: 0,
|
||||
fillOccludedColor: { red: 0, green: 0, blue: 0 },
|
||||
fillOccludedAlpha: 0,
|
||||
outlineWidth: 2,
|
||||
isOutlineSmooth: false
|
||||
};
|
||||
|
||||
var isTabletNearGrabbable = [false, false];
|
||||
var isTabletHighlighted = false;
|
||||
|
||||
function setTabletNearGrabbable(hand, enabled) {
|
||||
if (enabled === isTabletNearGrabbable[hand]) {
|
||||
return;
|
||||
}
|
||||
|
||||
isTabletNearGrabbable[hand] = enabled;
|
||||
|
||||
if (isTabletNearGrabbable[LEFT_HAND] || isTabletNearGrabbable[RIGHT_HAND]) {
|
||||
if (!isTabletHighlighted) {
|
||||
Selection.addToSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID);
|
||||
isTabletHighlighted = true;
|
||||
}
|
||||
} else {
|
||||
if (isTabletHighlighted) {
|
||||
Selection.removeFromSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME, "overlay", HMD.tabletID);
|
||||
isTabletHighlighted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function NearTabletHighlight(hand) {
|
||||
this.hand = hand;
|
||||
|
||||
|
@ -37,18 +74,22 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
if (this.isNearTablet(controllerData)) {
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
setTabletNearGrabbable(this.hand, false);
|
||||
return makeRunningValues(false, [], []);
|
||||
};
|
||||
|
||||
this.run = function (controllerData) {
|
||||
if (!this.isNearTablet(controllerData)) {
|
||||
setTabletNearGrabbable(this.hand, false);
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
||||
if (controllerData.triggerClicks[this.hand]) {
|
||||
setTabletNearGrabbable(this.hand, false);
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
||||
setTabletNearGrabbable(this.hand, true);
|
||||
return makeRunningValues(true, [], []);
|
||||
};
|
||||
}
|
||||
|
@ -58,9 +99,21 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
enableDispatcherModule("LeftNearTabletHighlight", leftNearTabletHighlight);
|
||||
enableDispatcherModule("RightNearTabletHighlight", rightNearTabletHighlight);
|
||||
|
||||
function onDisplayModeChanged() {
|
||||
if (HMD.active) {
|
||||
Selection.enableListHighlight(TABLET_GRABBABLE_SELECTION_NAME, TABLET_GRABBABLE_SELECTION_STYLE);
|
||||
} else {
|
||||
Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME);
|
||||
Selection.clearSelectedItemsList(TABLET_GRABBABLE_SELECTION_NAME);
|
||||
}
|
||||
}
|
||||
HMD.displayModeChanged.connect(onDisplayModeChanged);
|
||||
HMD.mountedChanged.connect(onDisplayModeChanged);
|
||||
|
||||
function cleanUp() {
|
||||
disableDispatcherModule("LeftNearTabletHighlight");
|
||||
disableDispatcherModule("RightNearTabletHighlight");
|
||||
Selection.disableListHighlight(TABLET_GRABBABLE_SELECTION_NAME);
|
||||
}
|
||||
Script.scriptEnding.connect(cleanUp);
|
||||
|
||||
|
|
Loading…
Reference in a new issue