fix-another-highlighting-issue

This commit is contained in:
Dante Ruiz 2018-05-04 14:20:17 -07:00
parent ea230d8698
commit 176d69444f
2 changed files with 11 additions and 1 deletions

View file

@ -56,6 +56,12 @@
return canGrabEntity; return canGrabEntity;
}; };
this.clearAll = function() {
this.highlightedEntities.forEach(function(entity) {
dispatcherUtils.unhighlightTargetEntity(entity);
});
};
this.hasHyperLink = function(props) { this.hasHyperLink = function(props) {
return (props.href !== "" && props.href !== undefined); return (props.href !== "" && props.href !== undefined);
}; };
@ -121,7 +127,6 @@
if (channel === 'Hifi-unhighlight-entity') { if (channel === 'Hifi-unhighlight-entity') {
try { try {
data = JSON.parse(message); data = JSON.parse(message);
var hand = data.hand; var hand = data.hand;
if (hand === dispatcherUtils.LEFT_HAND) { if (hand === dispatcherUtils.LEFT_HAND) {
leftHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID); leftHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID);
@ -131,6 +136,9 @@
} catch (e) { } catch (e) {
print("Failed to parse message"); print("Failed to parse message");
} }
} else if (channel === 'Hifi-unhighlight-all') {
leftHighlightNearbyEntities.clearAll();
rightHighlightNearbyEntities.clearAll();
} }
} }
}; };
@ -145,6 +153,7 @@
dispatcherUtils.disableDispatcherModule("RightHighlightNearbyEntities"); dispatcherUtils.disableDispatcherModule("RightHighlightNearbyEntities");
} }
Messages.subscribe('Hifi-unhighlight-entity'); Messages.subscribe('Hifi-unhighlight-entity');
Messages.subscribe('Hifi-unhighlight-all');
Messages.messageReceived.connect(handleMessage); Messages.messageReceived.connect(handleMessage);
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -78,6 +78,7 @@ Script.include("/~/system/libraries/utils.js");
if (controllerData.triggerValues[this.hand] < TRIGGER_ON_VALUE) { if (controllerData.triggerValues[this.hand] < TRIGGER_ON_VALUE) {
this.triggerClicked = false; this.triggerClicked = false;
} }
Messages.sendLocalMessage('Hifi-unhighlight-all', '');
return makeRunningValues(true, [], []); return makeRunningValues(true, [], []);
} }
this.triggerClicked = false; this.triggerClicked = false;