equip highlight works now

This commit is contained in:
Seth Alves 2017-08-15 10:30:47 -07:00
parent 774cb33303
commit b2d7eefc97
5 changed files with 34 additions and 6 deletions

View file

@ -271,6 +271,8 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js");
} }
} }
// print("QQQ running plugins: " + JSON.stringify(_this.runningPluginNames));
// give time to running plugins // give time to running plugins
for (var runningPluginName in _this.runningPluginNames) { for (var runningPluginName in _this.runningPluginNames) {
if (_this.runningPluginNames.hasOwnProperty(runningPluginName)) { if (_this.runningPluginNames.hasOwnProperty(runningPluginName)) {

View file

@ -17,6 +17,7 @@
COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE,
COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE,
COLORS_GRAB_DISTANCE_HOLD, COLORS_GRAB_DISTANCE_HOLD,
NEAR_GRAB_RADIUS,
Entities, Entities,
makeDispatcherModuleParameters, makeDispatcherModuleParameters,
makeRunningValues, makeRunningValues,
@ -66,6 +67,9 @@ COLORS_GRAB_SEARCHING_FULL_SQUEEZE = { red: 250, green: 10, blue: 10 };
COLORS_GRAB_DISTANCE_HOLD = { red: 238, green: 75, blue: 214 }; COLORS_GRAB_DISTANCE_HOLD = { red: 238, green: 75, blue: 214 };
NEAR_GRAB_RADIUS = 0.1;
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step // priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step
// activitySlots -- indicates which "slots" must not yet be in use for this module to start // activitySlots -- indicates which "slots" must not yet be in use for this module to start

View file

@ -82,7 +82,7 @@ EquipHotspotBuddy.prototype.updateHotspot = function(hotspot, timestamp) {
ignoreRayIntersection: true ignoreRayIntersection: true
})); }));
overlayInfoSet.type = "model"; overlayInfoSet.type = "model";
print("QQQ adding hopspot: " + hotspot.key); print("QQQ adding hotspot: " + hotspot.key);
this.map[hotspot.key] = overlayInfoSet; this.map[hotspot.key] = overlayInfoSet;
} else { } else {
print("QQQ updating hopspot: " + hotspot.key); print("QQQ updating hopspot: " + hotspot.key);
@ -520,7 +520,9 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
this.targetEntityID = null; this.targetEntityID = null;
}; };
this.isReady = function (controllerData, deltaTime) { this.checkNearbyHotspots = function (controllerData, deltaTime) {
var timestamp = Date.now();
this.rawTriggerValue = controllerData.triggerValues[this.hand]; this.rawTriggerValue = controllerData.triggerValues[this.hand];
this.triggerClicked = controllerData.triggerClicks[this.hand]; this.triggerClicked = controllerData.triggerClicks[this.hand];
@ -548,7 +550,6 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
} }
var nearEquipHotspots = this.chooseNearEquipHotspots(candidateEntityProps, controllerData); var nearEquipHotspots = this.chooseNearEquipHotspots(candidateEntityProps, controllerData);
var timestamp = Date.now();
equipHotspotBuddy.updateHotspots(nearEquipHotspots, timestamp); equipHotspotBuddy.updateHotspots(nearEquipHotspots, timestamp);
if (potentialEquipHotspot) { if (potentialEquipHotspot) {
equipHotspotBuddy.highlightHotspot(potentialEquipHotspot); equipHotspotBuddy.highlightHotspot(potentialEquipHotspot);
@ -556,11 +557,22 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
equipHotspotBuddy.update(deltaTime, timestamp, controllerData); equipHotspotBuddy.update(deltaTime, timestamp, controllerData);
return makeRunningValues(false, [], []); if (potentialEquipHotspot) {
return makeRunningValues(true, [potentialEquipHotspot.entityID], []);
} else {
return makeRunningValues(false, [], []);
}
};
this.isReady = function (controllerData, deltaTime) {
return this.checkNearbyHotspots(controllerData, deltaTime);
}; };
this.run = function (controllerData, deltaTime) { this.run = function (controllerData, deltaTime) {
return this.checkNearbyHotspots(controllerData, deltaTime);
if (controllerData.secondaryValues[this.hand]) { if (controllerData.secondaryValues[this.hand]) {
// this.secondaryReleased() will always be true when not depressed // this.secondaryReleased() will always be true when not depressed
// so we cannot simply rely on that for release - ensure that the // so we cannot simply rely on that for release - ensure that the

View file

@ -9,7 +9,7 @@
getControllerJointIndex, getGrabbableData, NULL_UUID, enableDispatcherModule, disableDispatcherModule, getControllerJointIndex, getGrabbableData, NULL_UUID, enableDispatcherModule, disableDispatcherModule,
propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable,
Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues, Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues,
TRIGGER_OFF_VALUE TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS
*/ */
Script.include("/~/system/controllers/controllerDispatcherUtils.js"); Script.include("/~/system/controllers/controllerDispatcherUtils.js");
@ -146,6 +146,11 @@ Script.include("/~/system/libraries/controllers.js");
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand]; var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
for (var i = 0; i < nearbyEntityProperties.length; i++) { for (var i = 0; i < nearbyEntityProperties.length; i++) {
var props = nearbyEntityProperties[i]; var props = nearbyEntityProperties[i];
var handPosition = controllerData.controllerLocations[this.hand].position;
var distance = Vec3.distance(props.position, handPosition);
if (distance > NEAR_GRAB_RADIUS) {
break;
}
if (entityIsGrabbable(props)) { if (entityIsGrabbable(props)) {
return props; return props;
} }

View file

@ -9,7 +9,7 @@
/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID,
getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule, getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule,
propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE,
makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS
*/ */
Script.include("/~/system/controllers/controllerDispatcherUtils.js"); Script.include("/~/system/controllers/controllerDispatcherUtils.js");
@ -129,6 +129,11 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js");
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand]; var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
for (var i = 0; i < nearbyEntityProperties.length; i++) { for (var i = 0; i < nearbyEntityProperties.length; i++) {
var props = nearbyEntityProperties[i]; var props = nearbyEntityProperties[i];
var handPosition = controllerData.controllerLocations[this.hand].position;
var distance = Vec3.distance(props.position, handPosition);
if (distance > NEAR_GRAB_RADIUS) {
break;
}
if (entityIsGrabbable(props)) { if (entityIsGrabbable(props)) {
return props; return props;
} }