mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Make tablet highlight not display if editing an entity with hand
This commit is contained in:
parent
0eead13fb9
commit
1460e43f6e
1 changed files with 30 additions and 3 deletions
|
@ -11,7 +11,7 @@
|
|||
//
|
||||
|
||||
/* global LEFT_HAND, RIGHT_HAND, makeDispatcherModuleParameters, makeRunningValues, enableDispatcherModule,
|
||||
* disableDispatcherModule */
|
||||
* disableDispatcherModule, HIFI_EDIT_MANIPULATION_CHANNEL */
|
||||
|
||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||
|
||||
|
@ -66,12 +66,17 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
100
|
||||
);
|
||||
|
||||
this.isEditing = false;
|
||||
this.setIsEditing = function (editing) {
|
||||
this.isEditing = editing;
|
||||
};
|
||||
|
||||
this.isNearTablet = function (controllerData) {
|
||||
return HMD.tabletID && controllerData.nearbyOverlayIDs[this.hand].indexOf(HMD.tabletID) !== -1;
|
||||
};
|
||||
|
||||
this.isReady = function (controllerData) {
|
||||
if (this.isNearTablet(controllerData)) {
|
||||
if (!this.isEditing && this.isNearTablet(controllerData)) {
|
||||
return makeRunningValues(true, [], []);
|
||||
}
|
||||
setTabletNearGrabbable(this.hand, false);
|
||||
|
@ -79,7 +84,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
};
|
||||
|
||||
this.run = function (controllerData) {
|
||||
if (!this.isNearTablet(controllerData)) {
|
||||
if (this.isEditing || !this.isNearTablet(controllerData)) {
|
||||
setTabletNearGrabbable(this.hand, false);
|
||||
return makeRunningValues(false, [], []);
|
||||
}
|
||||
|
@ -111,6 +116,28 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
|||
HMD.mountedChanged.connect(onDisplayModeChanged);
|
||||
onDisplayModeChanged();
|
||||
|
||||
function onMessageReceived(channel, data, senderID) {
|
||||
var message;
|
||||
|
||||
if (channel !== HIFI_EDIT_MANIPULATION_CHANNEL || senderID !== MyAvatar.sessionUUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
message = JSON.parse(data);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.hand === Controller.Standard.LeftHand) {
|
||||
leftNearTabletHighlight.setIsEditing(message.action === "startEdit");
|
||||
} else if (message.hand === Controller.Standard.RightHand) {
|
||||
rightNearTabletHighlight.setIsEditing(message.action === "startEdit");
|
||||
}
|
||||
}
|
||||
Messages.subscribe(HIFI_EDIT_MANIPULATION_CHANNEL);
|
||||
Messages.messageReceived.connect(onMessageReceived);
|
||||
|
||||
function cleanUp() {
|
||||
disableDispatcherModule("LeftNearTabletHighlight");
|
||||
disableDispatcherModule("RightNearTabletHighlight");
|
||||
|
|
Loading…
Reference in a new issue