mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-06 17:16:31 +02:00
Disable near and far lasers when tablet is grabbable
This commit is contained in:
parent
ecb58a9629
commit
f84f3b20cd
6 changed files with 82 additions and 4 deletions
|
@ -420,7 +420,8 @@ Script.include("/~/system/libraries/Xform.js");
|
|||
this.hand === RIGHT_HAND ? "RightFarTriggerEntity" : "LeftFarTriggerEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay"
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay",
|
||||
this.hand === RIGHT_HAND ? "RightNearTabletHighlight" : "LeftNearTabletHighlight"
|
||||
];
|
||||
|
||||
var nearGrabReadiness = [];
|
||||
|
|
|
@ -396,7 +396,8 @@ Script.include("/~/system/libraries/Xform.js");
|
|||
this.hand === RIGHT_HAND ? "RightFarTriggerEntity" : "LeftFarTriggerEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay"
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay",
|
||||
this.hand === RIGHT_HAND ? "RightNearTabletHighlight" : "LeftNearTabletHighlight"
|
||||
];
|
||||
|
||||
var nearGrabReadiness = [];
|
||||
|
|
|
@ -442,7 +442,8 @@ Script.include("/~/system/libraries/Xform.js");
|
|||
this.hand === RIGHT_HAND ? "RightFarTriggerEntity" : "LeftFarTriggerEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity",
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay"
|
||||
this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay",
|
||||
this.hand === RIGHT_HAND ? "RightNearTabletHighlight" : "LeftNearTabletHighlight"
|
||||
];
|
||||
|
||||
var nearGrabReadiness = [];
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
//
|
||||
// nearTabletHighlight.js
|
||||
//
|
||||
// Highlight the tablet if a hand is near enough to grab it.
|
||||
//
|
||||
// Created by David Rowe on 28 Aug 2018.
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
/* global LEFT_HAND, RIGHT_HAND, makeDispatcherModuleParameters, makeRunningValues, enableDispatcherModule,
|
||||
* disableDispatcherModule */
|
||||
|
||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||
|
||||
(function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
function NearTabletHighlight(hand) {
|
||||
this.hand = hand;
|
||||
|
||||
this.parameters = makeDispatcherModuleParameters(
|
||||
95,
|
||||
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
||||
[],
|
||||
100
|
||||
);
|
||||
|
||||
this.isNearTablet = function (controllerData) {
|
||||
return HMD.tabletID && controllerData.nearbyOverlayIDs[this.hand].indexOf(HMD.tabletID) !== -1;
|
||||
};
|
||||
|
||||
this.isReady = function (controllerData) {
|
||||
if (this.isNearTablet(controllerData)) {
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
return makeRunningValues(false, [], []);
|
||||
};
|
||||
|
||||
this.run = function (controllerData) {
|
||||
if (!this.isNearTablet(controllerData)) {
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
||||
if (controllerData.triggerClicks[this.hand]) {
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
||||
return makeRunningValues(true, [], []);
|
||||
};
|
||||
}
|
||||
|
||||
var leftNearTabletHighlight = new NearTabletHighlight(LEFT_HAND);
|
||||
var rightNearTabletHighlight = new NearTabletHighlight(RIGHT_HAND);
|
||||
enableDispatcherModule("LeftNearTabletHighlight", leftNearTabletHighlight);
|
||||
enableDispatcherModule("RightNearTabletHighlight", rightNearTabletHighlight);
|
||||
|
||||
function cleanUp() {
|
||||
disableDispatcherModule("LeftNearTabletHighlight");
|
||||
disableDispatcherModule("RightNearTabletHighlight");
|
||||
}
|
||||
Script.scriptEnding.connect(cleanUp);
|
||||
|
||||
}());
|
|
@ -43,6 +43,13 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
var nearTabletHighlightModule = getEnabledModuleByName(this.hand === RIGHT_HAND
|
||||
? "RightNearTabletHighlight" : "LeftNearTabletHighlight");
|
||||
if (nearTabletHighlightModule) {
|
||||
return nearTabletHighlightModule.isNearTablet(controllerData);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ var CONTOLLER_SCRIPTS = [
|
|||
"controllerModules/scaleEntity.js",
|
||||
"controllerModules/highlightNearbyEntities.js",
|
||||
"controllerModules/nearGrabHyperLinkEntity.js",
|
||||
"controllerModules/mouseHighlightEntities.js"
|
||||
"controllerModules/mouseHighlightEntities.js",
|
||||
"controllerModules/nearTabletHighlight.js"
|
||||
];
|
||||
|
||||
if (Settings.getValue("useFarGrabJoints", false)) {
|
||||
|
|
Loading…
Reference in a new issue