clean up scripts

This commit is contained in:
Dante Ruiz 2018-04-10 09:23:40 -07:00
parent 2e1ebac03f
commit 447163bd07
4 changed files with 47 additions and 4 deletions

View file

@ -484,6 +484,12 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
this.clearEquipHaptics();
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
unhighlightTargetEntity(this.targetEntityID);
var message = {
hand: this.hand,
entityID: this.targetEntityID
};
Messages.sendMessage('Hifi-unhighlight-entity', JSON.stringify(message));
var grabbedProperties = Entities.getEntityProperties(this.targetEntityID);
// if an object is "equipped" and has a predefined offset, use it.

View file

@ -9,7 +9,7 @@
/* global Script, Controller, RIGHT_HAND, LEFT_HAND, MyAvatar, getGrabPointSphereOffset,
makeRunningValues, Entities, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters,
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
DEFAULT_SEARCH_SPHERE_DISTANCE, getGrabbableData, makeLaserParams, entityIsCloneable
DEFAULT_SEARCH_SPHERE_DISTANCE, getGrabbableData, makeLaserParams, entityIsCloneable, Messages, print
*/
(function () {
@ -19,8 +19,6 @@
var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
function differenceInArrays(firstArray, secondArray) {
print("first " + firstArray);
print("second " + secondArray);
var differenceArray = firstArray.filter(function(element) {
return secondArray.indexOf(element) < 0;
});
@ -57,6 +55,13 @@
return (props.href !== "" && props.href !== undefined);
};
this.removeEntityFromHighlightList = function(entityID) {
var index = this.highlightedEntities.indexOf(entityID);
if (index > -1) {
this.highlightedEntities.splice(index, 1);
}
};
this.getOtherModule = function() {
var otherModule = this.hand === dispatcherUtils.RIGHT_HAND ? leftHighlightNearbyEntities :
rightHighlightNearbyEntities;
@ -103,6 +108,25 @@
};
}
var handleMessage = function(channel, message, sender) {
var data;
if (sender === MyAvatar.sessionUUID) {
if (channel === 'Hifi-unhighlight-entity') {
try {
data = JSON.parse(message);
var hand = data.hand;
if (hand === dispatcherUtils.LEFT_HAND) {
leftHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID);
} else if (hand === dispatcherUtils.RIGHT_HAND) {
rightHighlightNearbyEntities.removeEntityFromHighlightList(data.entityID);
}
} catch (e) {
print("Failed to parse message");
}
}
}
};
var leftHighlightNearbyEntities = new HighlightNearbyEntities(dispatcherUtils.LEFT_HAND);
var rightHighlightNearbyEntities = new HighlightNearbyEntities(dispatcherUtils.RIGHT_HAND);
@ -113,6 +137,7 @@
dispatcherUtils.disableDispatcherModule("LeftHighlightNearbyEntities");
dispatcherUtils.disableDispatcherModule("RightHighlightNearbyEntities");
}
Messages.subscribe('Hifi-unhighlight-entity');
Messages.messageReceived.connect(handleMessage);
Script.scriptEnding.connect(cleanup);
}());

View file

@ -115,6 +115,12 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
Entities.callEntityMethod(this.targetEntityID, "startNearGrab", args);
unhighlightTargetEntity(this.targetEntityID);
var message = {
hand: this.hand,
entityID: this.targetEntityID
};
Messages.sendMessage('Hifi-unhighlight-entity', JSON.stringify(message));
};
// this is for when the action is going to time-out

View file

@ -90,6 +90,12 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
this.startNearParentingGrabEntity = function (controllerData, targetProps) {
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
unhighlightTargetEntity(this.targetEntityID);
var message = {
hand: this.hand,
entityID: this.targetEntityID
};
Messages.sendMessage('Hifi-unhighlight-entity', JSON.stringify(message));
var handJointIndex;
// if (this.ignoreIK) {
// handJointIndex = this.controllerJointIndex;