mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 03:53:52 +02:00
clean up scripts
This commit is contained in:
parent
2e1ebac03f
commit
447163bd07
4 changed files with 47 additions and 4 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue