Use a smaller near grab radius for tablet and mini-tablet
This commit is contained in:
parent
8a8bf6dc04
commit
5e7f68d4b7
@ -25,7 +25,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
Script.include("/~/system/libraries/pointersUtils.js");
|
Script.include("/~/system/libraries/pointersUtils.js");
|
||||||
|
|
||||||
var NEAR_MAX_RADIUS = 0.1;
|
var NEAR_MAX_RADIUS = 0.1;
|
||||||
|
var NEAR_TABLET_MAX_RADIUS = 0.05;
|
||||||
|
|
||||||
var TARGET_UPDATE_HZ = 60; // 50hz good enough, but we're using update
|
var TARGET_UPDATE_HZ = 60; // 50hz good enough, but we're using update
|
||||||
var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ;
|
var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ;
|
||||||
@ -49,6 +51,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||||||
this.tabletID = null;
|
this.tabletID = null;
|
||||||
this.blacklist = [];
|
this.blacklist = [];
|
||||||
this.pointerManager = new PointerManager();
|
this.pointerManager = new PointerManager();
|
||||||
|
this.miniTabletID = null;
|
||||||
|
|
||||||
// a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are
|
// a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are
|
||||||
// not set to false (not in use), a module cannot start. When a module is using a slot, that module's name
|
// not set to false (not in use), a module cannot start. When a module is using a slot, that module's name
|
||||||
@ -211,6 +214,22 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||||||
if (controllerLocations[h].valid) {
|
if (controllerLocations[h].valid) {
|
||||||
var nearbyOverlays =
|
var nearbyOverlays =
|
||||||
Overlays.findOverlays(controllerLocations[h].position, NEAR_MAX_RADIUS * sensorScaleFactor);
|
Overlays.findOverlays(controllerLocations[h].position, NEAR_MAX_RADIUS * sensorScaleFactor);
|
||||||
|
|
||||||
|
// Tablet and mini-tablet must be within NEAR_TABLET_MAX_RADIUS in order to be grabbed.
|
||||||
|
var tabletIndex = nearbyOverlays.indexOf(HMD.tabletID);
|
||||||
|
var miniTabletIndex = nearbyOverlays.indexOf(_this.miniTabletID);
|
||||||
|
if (tabletIndex !== -1 || miniTabletIndex !== -1) {
|
||||||
|
var closebyOverlays =
|
||||||
|
Overlays.findOverlays(controllerLocations[h].position, NEAR_TABLET_MAX_RADIUS * sensorScaleFactor);
|
||||||
|
// Assumes that the tablet and mini-tablet are not displayed at the same time.
|
||||||
|
if (tabletIndex !== -1 && closebyOverlays.indexOf(HMD.tabletID) === -1) {
|
||||||
|
nearbyOverlays.splice(tabletIndex, 1);
|
||||||
|
}
|
||||||
|
if (miniTabletIndex !== -1 && closebyOverlays.indexOf(_this.miniTabletID) === -1) {
|
||||||
|
nearbyOverlays.splice(miniTabletIndex, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nearbyOverlays.sort(function (a, b) {
|
nearbyOverlays.sort(function (a, b) {
|
||||||
var aPosition = Overlays.getProperty(a, "position");
|
var aPosition = Overlays.getProperty(a, "position");
|
||||||
var aDistance = Vec3.distance(aPosition, controllerLocations[h].position);
|
var aDistance = Vec3.distance(aPosition, controllerLocations[h].position);
|
||||||
@ -218,6 +237,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||||||
var bDistance = Vec3.distance(bPosition, controllerLocations[h].position);
|
var bDistance = Vec3.distance(bPosition, controllerLocations[h].position);
|
||||||
return aDistance - bDistance;
|
return aDistance - bDistance;
|
||||||
});
|
});
|
||||||
|
|
||||||
nearbyOverlayIDs.push(nearbyOverlays);
|
nearbyOverlayIDs.push(nearbyOverlays);
|
||||||
} else {
|
} else {
|
||||||
nearbyOverlayIDs.push([]);
|
nearbyOverlayIDs.push([]);
|
||||||
@ -470,6 +490,8 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||||||
_this.setBlacklist();
|
_this.setBlacklist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (channel === 'Hifi-MiniTablet-ID') {
|
||||||
|
_this.miniTabletID = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -508,6 +530,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||||||
Entities.mousePressOnEntity.connect(mousePress);
|
Entities.mousePressOnEntity.connect(mousePress);
|
||||||
var controllerDispatcher = new ControllerDispatcher();
|
var controllerDispatcher = new ControllerDispatcher();
|
||||||
Messages.subscribe('Hifi-Hand-RayPick-Blacklist');
|
Messages.subscribe('Hifi-Hand-RayPick-Blacklist');
|
||||||
|
Messages.subscribe('Hifi-MiniTablet-ID');
|
||||||
Messages.messageReceived.connect(controllerDispatcher.handleHandMessage);
|
Messages.messageReceived.connect(controllerDispatcher.handleHandMessage);
|
||||||
Script.scriptEnding.connect(controllerDispatcher.cleanup);
|
Script.scriptEnding.connect(controllerDispatcher.cleanup);
|
||||||
Script.setTimeout(controllerDispatcher.update, BASIC_TIMER_INTERVAL_MS);
|
Script.setTimeout(controllerDispatcher.update, BASIC_TIMER_INTERVAL_MS);
|
||||||
|
@ -169,6 +169,11 @@
|
|||||||
|
|
||||||
// #region Communications ==================================================================================================
|
// #region Communications ==================================================================================================
|
||||||
|
|
||||||
|
function updateMiniTabletID() {
|
||||||
|
// Send mini-tablet overlay ID to controllerDispatcher so that it can use a smaller near grab distance.
|
||||||
|
Messages.sendLocalMessage("Hifi-MiniTablet-ID", proxyOverlay);
|
||||||
|
}
|
||||||
|
|
||||||
function updateMutedStatus() {
|
function updateMutedStatus() {
|
||||||
var isMuted = Audio.muted;
|
var isMuted = Audio.muted;
|
||||||
proxyOverlayObject.emitScriptEvent(JSON.stringify({
|
proxyOverlayObject.emitScriptEvent(JSON.stringify({
|
||||||
@ -257,6 +262,8 @@
|
|||||||
|
|
||||||
proxyOverlayObject = Overlays.getOverlayObject(proxyUIOverlay);
|
proxyOverlayObject = Overlays.getOverlayObject(proxyUIOverlay);
|
||||||
proxyOverlayObject.webEventReceived.connect(onWebEventReceived);
|
proxyOverlayObject.webEventReceived.connect(onWebEventReceived);
|
||||||
|
|
||||||
|
updateMiniTabletID();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showUI(hand) {
|
function showUI(hand) {
|
||||||
@ -320,6 +327,7 @@
|
|||||||
proxyOverlayObject = null;
|
proxyOverlayObject = null;
|
||||||
proxyUIOverlay = null;
|
proxyUIOverlay = null;
|
||||||
proxyOverlay = null;
|
proxyOverlay = null;
|
||||||
|
updateMiniTabletID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user