mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-09 12:08:21 +02:00
clean up functionality
This commit is contained in:
parent
1113202a90
commit
2e1ebac03f
2 changed files with 37 additions and 8 deletions
|
@ -10,7 +10,7 @@
|
||||||
getControllerJointIndex, enableDispatcherModule, disableDispatcherModule,
|
getControllerJointIndex, enableDispatcherModule, disableDispatcherModule,
|
||||||
Messages, makeDispatcherModuleParameters, makeRunningValues, Settings, entityHasActions,
|
Messages, makeDispatcherModuleParameters, makeRunningValues, Settings, entityHasActions,
|
||||||
Vec3, Overlays, flatten, Xform, getControllerWorldLocation, ensureDynamic, entityIsCloneable,
|
Vec3, Overlays, flatten, Xform, getControllerWorldLocation, ensureDynamic, entityIsCloneable,
|
||||||
cloneEntity, DISPATCHER_PROPERTIES, TEAR_AWAY_DISTANCE, Uuid
|
cloneEntity, DISPATCHER_PROPERTIES, TEAR_AWAY_DISTANCE, Uuid, unhighlightTargetEntity
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/Xform.js");
|
Script.include("/~/system/libraries/Xform.js");
|
||||||
|
@ -483,7 +483,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
|
||||||
this.dropGestureReset();
|
this.dropGestureReset();
|
||||||
this.clearEquipHaptics();
|
this.clearEquipHaptics();
|
||||||
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
|
||||||
|
unhighlightTargetEntity(this.targetEntityID);
|
||||||
var grabbedProperties = Entities.getEntityProperties(this.targetEntityID);
|
var grabbedProperties = Entities.getEntityProperties(this.targetEntityID);
|
||||||
|
|
||||||
// if an object is "equipped" and has a predefined offset, use it.
|
// if an object is "equipped" and has a predefined offset, use it.
|
||||||
|
|
|
@ -17,8 +17,21 @@
|
||||||
Script.include("/~/system/libraries/controllers.js");
|
Script.include("/~/system/libraries/controllers.js");
|
||||||
Script.include("/~/system/libraries/cloneEntityUtils.js");
|
Script.include("/~/system/libraries/cloneEntityUtils.js");
|
||||||
var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
|
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;
|
||||||
|
});
|
||||||
|
|
||||||
|
return differenceArray;
|
||||||
|
}
|
||||||
|
|
||||||
function HighlightNearbyEntities(hand) {
|
function HighlightNearbyEntities(hand) {
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
|
this.otherHand = hand === dispatcherUtils.RIGHT_HAND ? dispatcherUtils.LEFT_HAND :
|
||||||
|
dispatcherUtils.RIGHT_HAND;
|
||||||
this.highlightedEntities = [];
|
this.highlightedEntities = [];
|
||||||
|
|
||||||
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
||||||
|
@ -44,13 +57,20 @@
|
||||||
return (props.href !== "" && props.href !== undefined);
|
return (props.href !== "" && props.href !== undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.highlightEntities = function(controllerData) {
|
this.getOtherModule = function() {
|
||||||
if (this.highlightedEntities.length > 0) {
|
var otherModule = this.hand === dispatcherUtils.RIGHT_HAND ? leftHighlightNearbyEntities :
|
||||||
dispatcherUtils.clearHighlightedEntities();
|
rightHighlightNearbyEntities;
|
||||||
this.highlightedEntities = [];
|
return otherModule;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
this.getOtherHandHighlightedEntities = function() {
|
||||||
|
return this.getOtherModule().highlightedEntities;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.highlightEntities = function(controllerData) {
|
||||||
var nearbyEntitiesProperties = controllerData.nearbyEntityProperties[this.hand];
|
var nearbyEntitiesProperties = controllerData.nearbyEntityProperties[this.hand];
|
||||||
|
var otherHandHighlightedEntities = this.getOtherHandHighlightedEntities();
|
||||||
|
var newHighlightedEntities = [];
|
||||||
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
for (var i = 0; i < nearbyEntitiesProperties.length; i++) {
|
for (var i = 0; i < nearbyEntitiesProperties.length; i++) {
|
||||||
var props = nearbyEntitiesProperties[i];
|
var props = nearbyEntitiesProperties[i];
|
||||||
|
@ -59,9 +79,18 @@
|
||||||
}
|
}
|
||||||
if (this.isGrabable(controllerData, props) || this.hasHyperLink(props)) {
|
if (this.isGrabable(controllerData, props) || this.hasHyperLink(props)) {
|
||||||
dispatcherUtils.highlightTargetEntity(props.id);
|
dispatcherUtils.highlightTargetEntity(props.id);
|
||||||
this.highlightedEntities.push(props.id);
|
newHighlightedEntities.push(props.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var unhighlightEntities = differenceInArrays(this.highlightedEntities, newHighlightedEntities);
|
||||||
|
|
||||||
|
unhighlightEntities.forEach(function(entityID) {
|
||||||
|
if (otherHandHighlightedEntities.indexOf(entityID) < 0 ) {
|
||||||
|
dispatcherUtils.unhighlightTargetEntity(entityID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.highlightedEntities = newHighlightedEntities;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.isReady = function(controllerData) {
|
this.isReady = function(controllerData) {
|
||||||
|
|
Loading…
Reference in a new issue