mirror of
https://github.com/overte-org/overte.git
synced 2025-04-30 02:22:55 +02:00
pushing what i coded out loud - it broke the way grabbing works
This commit is contained in:
parent
1942eaf68f
commit
5276d84aa5
2 changed files with 40 additions and 17 deletions
|
@ -298,6 +298,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
triggerValues: [_this.leftTriggerValue, _this.rightTriggerValue],
|
triggerValues: [_this.leftTriggerValue, _this.rightTriggerValue],
|
||||||
triggerClicks: [_this.leftTriggerClicked, _this.rightTriggerClicked],
|
triggerClicks: [_this.leftTriggerClicked, _this.rightTriggerClicked],
|
||||||
secondaryValues: [_this.leftSecondaryValue, _this.rightSecondaryValue],
|
secondaryValues: [_this.leftSecondaryValue, _this.rightSecondaryValue],
|
||||||
|
pointers: [_this.leftPointer, _this.rightPointer ],
|
||||||
controllerLocations: controllerLocations,
|
controllerLocations: controllerLocations,
|
||||||
nearbyEntityProperties: nearbyEntityProperties,
|
nearbyEntityProperties: nearbyEntityProperties,
|
||||||
nearbyEntityPropertiesByID: nearbyEntityPropertiesByID,
|
nearbyEntityPropertiesByID: nearbyEntityPropertiesByID,
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule,
|
/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, getControllerWorldLocation,
|
||||||
makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD,
|
enableDispatcherModule, disableDispatcherModule, makeRunningValues, Messages, Quat, Vec3,
|
||||||
INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE,
|
makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT,
|
||||||
COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE,
|
getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE,
|
||||||
TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, ContextOverlay, Picks, makeLaserParams
|
COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE,
|
||||||
|
getEnabledModuleByName, PICK_MAX_DISTANCE, ContextOverlay, Picks, makeLaserParams
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
@ -19,6 +20,8 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
function WebSurfaceLaserInput(hand) {
|
function WebSurfaceLaserInput(hand) {
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND;
|
this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND;
|
||||||
|
this.ignoredEntities = [];
|
||||||
|
this.lastObjectID = null;
|
||||||
this.running = false;
|
this.running = false;
|
||||||
|
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
|
@ -60,16 +63,20 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput;
|
return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.isPointingAtGrabbableEntity = function(controllerData, triggerPressed) {
|
this.isPointingAtNearGrabbableEntity = function(controllerData, triggerPressed) {
|
||||||
// we are searching for an entity that is not a web entity. We want to be able to
|
// we are searching for an entity that is not a web entity. We want to be able to
|
||||||
// grab a non-web entity if the ray-pick intersects one.
|
// grab a non-web entity if the ray-pick intersects one.
|
||||||
var intersection = controllerData.rayPicks[this.hand];
|
var intersection = controllerData.rayPicks[this.hand];
|
||||||
if (intersection.type === Picks.INTERSECTED_ENTITY) {
|
if (intersection.type === Picks.INTERSECTED_ENTITY) {
|
||||||
// is pointing at an entity.
|
// is pointing at an entity.
|
||||||
var entityProperty = Entities.getEntityProperties(intersection.objectID);
|
var entityProperties = Entities.getEntityProperties(intersection.objectID);
|
||||||
var entityType = entityProperty.type;
|
var entityType = entityProperties.type;
|
||||||
var isGrabbable = entityIsGrabbable(entityProperty);
|
if (entityIsGrabbable(entityProperties)) {
|
||||||
return (isGrabbable && triggerPressed && entityType !== "Web");
|
// check if entity is near grabbable.
|
||||||
|
var distance = Vec3.distance(entityProperties.position, controllerData.controllerLocations[this.hand].position);
|
||||||
|
if (distance <= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale)
|
||||||
|
return (triggerPressed && entityType !== "Web");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -78,21 +85,30 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
// allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger,
|
// allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger,
|
||||||
// but for pointing at locked web entities or non-web overlays user must be pressing trigger
|
// but for pointing at locked web entities or non-web overlays user must be pressing trigger
|
||||||
var intersection = controllerData.rayPicks[this.hand];
|
var intersection = controllerData.rayPicks[this.hand];
|
||||||
|
var objectID = intersection.objectID;
|
||||||
if (intersection.type === Picks.INTERSECTED_OVERLAY) {
|
if (intersection.type === Picks.INTERSECTED_OVERLAY) {
|
||||||
var objectID = intersection.objectID;
|
|
||||||
if ((HMD.tabletID && objectID === HMD.tabletID) ||
|
if ((HMD.tabletID && objectID === HMD.tabletID) ||
|
||||||
(HMD.tabletScreenID && objectID === HMD.tabletScreenID) ||
|
(HMD.tabletScreenID && objectID === HMD.tabletScreenID) ||
|
||||||
(HMD.homeButtonID && objectID === HMD.homeButtonID)) {
|
(HMD.homeButtonID && objectID === HMD.homeButtonID)) {
|
||||||
|
this.lastObjectID = objectID;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
var overlayType = Overlays.getOverlayType(objectID);
|
var overlayType = Overlays.getOverlayType(objectID);
|
||||||
|
this.lastObjectID = objectID;
|
||||||
return overlayType === "web3d" || triggerPressed;
|
return overlayType === "web3d" || triggerPressed;
|
||||||
}
|
}
|
||||||
} else if (intersection.type === Picks.INTERSECTED_ENTITY) {
|
} else if (intersection.type === Picks.INTERSECTED_ENTITY) {
|
||||||
var entityProperty = Entities.getEntityProperties(intersection.objectID);
|
var entityProperty = Entities.getEntityProperties(objectID);
|
||||||
var entityType = entityProperty.type;
|
if (entityProperty.type === "Web") {
|
||||||
var isLocked = entityProperty.locked;
|
var isLocked = entityProperty.locked;
|
||||||
return entityType === "Web" && (!isLocked || triggerPressed);
|
this.lastObjectID = objectID;
|
||||||
|
return (!isLocked || triggerPressed);
|
||||||
|
} else if (this.ignoredEntities.indexOf(objectID) === -1 && triggerPressed && this.lastObjectID !== objectID) {
|
||||||
|
// ignore, preserve whether it's running or not.
|
||||||
|
console.log("I'm here");
|
||||||
|
Pointers.setIgnoreItems(controllerData.pointers[this.hand], [objectID]);
|
||||||
|
this.ignoredEntities.push(objectID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -110,6 +126,11 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.reAddIgnoredEntities = function(controllerData) {
|
||||||
|
Pointers.setIncludeItems(controllerData.pointers[this.hand], this.ignoredEntities);
|
||||||
|
this.ignoredEntities = [];
|
||||||
|
}
|
||||||
|
|
||||||
this.updateAllwaysOn = function() {
|
this.updateAllwaysOn = function() {
|
||||||
var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser";
|
var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser";
|
||||||
this.parameters.handLaser.allwaysOn = !Settings.getValue(PREFER_STYLUS_OVER_LASER, false);
|
this.parameters.handLaser.allwaysOn = !Settings.getValue(PREFER_STYLUS_OVER_LASER, false);
|
||||||
|
@ -128,7 +149,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
|
controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
|
||||||
var allowThisModule = !otherModuleRunning || isTriggerPressed;
|
var allowThisModule = !otherModuleRunning || isTriggerPressed;
|
||||||
if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) &&
|
if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) &&
|
||||||
!this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) {
|
!this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) {
|
||||||
this.updateAllwaysOn();
|
this.updateAllwaysOn();
|
||||||
if (isTriggerPressed) {
|
if (isTriggerPressed) {
|
||||||
this.dominantHandOverride = true; // Override dominant hand.
|
this.dominantHandOverride = true; // Override dominant hand.
|
||||||
|
@ -150,11 +171,12 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
|
var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
|
||||||
var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn;
|
var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn;
|
||||||
if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) &&
|
if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) &&
|
||||||
!this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) {
|
!this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) {
|
||||||
this.running = true;
|
this.running = true;
|
||||||
return makeRunningValues(true, [], []);
|
return makeRunningValues(true, [], []);
|
||||||
}
|
}
|
||||||
this.deleteContextOverlay();
|
this.deleteContextOverlay();
|
||||||
|
this.reAddIgnoredEntities(controllerData);
|
||||||
this.running = false;
|
this.running = false;
|
||||||
this.dominantHandOverride = false;
|
this.dominantHandOverride = false;
|
||||||
return makeRunningValues(false, [], []);
|
return makeRunningValues(false, [], []);
|
||||||
|
|
Loading…
Reference in a new issue