mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
handles etc work better
This commit is contained in:
parent
b86886667b
commit
3a23ec86d5
4 changed files with 80 additions and 66 deletions
|
@ -738,6 +738,7 @@ function MyController(hand) {
|
|||
this.grabPointIntersectsEntity = false;
|
||||
this.stylus = null;
|
||||
this.homeButtonTouched = false;
|
||||
this.editTriggered = false;
|
||||
|
||||
// Until there is some reliable way to keep track of a "stack" of parentIDs, we'll have problems
|
||||
// when more than one avatar does parenting grabs on things. This script tries to work
|
||||
|
@ -858,9 +859,10 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.setState = function(newState, reason) {
|
||||
if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID )&& (newState !== STATE_OFF &&
|
||||
newState !== STATE_SEARCHING &&
|
||||
newState !== STATE_OVERLAY_STYLUS_TOUCHING)) {
|
||||
if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID) &&
|
||||
(newState !== STATE_OFF &&
|
||||
newState !== STATE_SEARCHING &&
|
||||
newState !== STATE_OVERLAY_STYLUS_TOUCHING)) {
|
||||
return;
|
||||
}
|
||||
setGrabCommunications((newState === STATE_DISTANCE_HOLDING) || (newState === STATE_NEAR_GRABBING));
|
||||
|
@ -1037,7 +1039,7 @@ function MyController(hand) {
|
|||
}
|
||||
|
||||
var searchSphereLocation = Vec3.sum(distantPickRay.origin,
|
||||
Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
||||
Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
||||
this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance,
|
||||
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ?
|
||||
COLORS_GRAB_SEARCHING_FULL_SQUEEZE :
|
||||
|
@ -1199,6 +1201,10 @@ function MyController(hand) {
|
|||
|
||||
this.checkForUnexpectedChildren();
|
||||
|
||||
if (this.editTriggered) {
|
||||
this.editTriggered = false;
|
||||
}
|
||||
|
||||
if (this.triggerSmoothedReleased() && this.secondaryReleased()) {
|
||||
this.waitForTriggerRelease = false;
|
||||
}
|
||||
|
@ -1636,22 +1642,24 @@ function MyController(hand) {
|
|||
return aDistance - bDistance;
|
||||
});
|
||||
entity = grabbableEntities[0];
|
||||
name = entityPropertiesCache.getProps(entity).name;
|
||||
this.grabbedEntity = entity;
|
||||
if (this.entityWantsTrigger(entity)) {
|
||||
if (this.triggerSmoothedGrab()) {
|
||||
this.setState(STATE_NEAR_TRIGGER, "near trigger '" + name + "'");
|
||||
return;
|
||||
if (!isInEditMode() || entity == HMD.tabletID) {
|
||||
name = entityPropertiesCache.getProps(entity).name;
|
||||
this.grabbedEntity = entity;
|
||||
if (this.entityWantsTrigger(entity)) {
|
||||
if (this.triggerSmoothedGrab()) {
|
||||
this.setState(STATE_NEAR_TRIGGER, "near trigger '" + name + "'");
|
||||
return;
|
||||
} else {
|
||||
// potentialNearTriggerEntity = entity;
|
||||
}
|
||||
} else {
|
||||
// potentialNearTriggerEntity = entity;
|
||||
}
|
||||
} else {
|
||||
// If near something grabbable, grab it!
|
||||
if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) {
|
||||
this.setState(STATE_NEAR_GRABBING, "near grab '" + name + "'");
|
||||
return;
|
||||
} else {
|
||||
// potentialNearGrabEntity = entity;
|
||||
// If near something grabbable, grab it!
|
||||
if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) {
|
||||
this.setState(STATE_NEAR_GRABBING, "near grab '" + name + "'");
|
||||
return;
|
||||
} else {
|
||||
// potentialNearGrabEntity = entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1666,16 +1674,22 @@ function MyController(hand) {
|
|||
}
|
||||
}
|
||||
|
||||
if (rayPickInfo.entityID) {
|
||||
if (this.triggerSmoothedGrab() && isInEditMode()) {
|
||||
this.searchIndicatorOn(rayPickInfo.searchRay);
|
||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||
method: "selectEntity",
|
||||
entityID: rayPickInfo.entityID
|
||||
}));
|
||||
return;
|
||||
if (isInEditMode()) {
|
||||
this.searchIndicatorOn(rayPickInfo.searchRay);
|
||||
if (this.triggerSmoothedGrab()) {
|
||||
if (!this.editTriggered && rayPickInfo.entityID) {
|
||||
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
|
||||
method: "selectEntity",
|
||||
entityID: rayPickInfo.entityID
|
||||
}));
|
||||
}
|
||||
this.editTriggered = true;
|
||||
}
|
||||
Reticle.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rayPickInfo.entityID) {
|
||||
entity = rayPickInfo.entityID;
|
||||
name = entityPropertiesCache.getProps(entity).name;
|
||||
if (this.entityWantsTrigger(entity)) {
|
||||
|
|
|
@ -330,10 +330,10 @@ function loaded() {
|
|||
}
|
||||
} else if (data.type == "update") {
|
||||
var newEntities = data.entities;
|
||||
if (newEntities.length == 0) {
|
||||
if (newEntities && newEntities.length == 0) {
|
||||
elNoEntitiesMessage.style.display = "block";
|
||||
elFooter.firstChild.nodeValue = "0 entities found";
|
||||
} else {
|
||||
} else if (newEntities) {
|
||||
elNoEntitiesMessage.style.display = "none";
|
||||
for (var i = 0; i < newEntities.length; i++) {
|
||||
var id = newEntities[i].id;
|
||||
|
|
|
@ -732,7 +732,7 @@ function loaded() {
|
|||
}
|
||||
} else if (data.type == "update") {
|
||||
|
||||
if (data.selections.length == 0) {
|
||||
if (!data.selections || data.selections.length == 0) {
|
||||
if (editor !== null && lastEntityID !== null) {
|
||||
saveJSONUserData(true);
|
||||
deleteJSONEditor();
|
||||
|
@ -741,7 +741,7 @@ function loaded() {
|
|||
elType.innerHTML = "<i>No selection</i>";
|
||||
elID.innerHTML = "";
|
||||
disableProperties();
|
||||
} else if (data.selections.length > 1) {
|
||||
} else if (data.selections && data.selections.length > 1) {
|
||||
deleteJSONEditor();
|
||||
var selections = data.selections;
|
||||
|
||||
|
|
|
@ -1028,44 +1028,44 @@ SelectionDisplay = (function() {
|
|||
that.TRIGGER_OFF_VALUE = 0.15;
|
||||
that.triggered = false;
|
||||
var activeHand = Controller.Standard.RightHand;
|
||||
// function makeTriggerHandler(hand) {
|
||||
// return function (value) {
|
||||
// if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth?
|
||||
// that.triggered = true;
|
||||
// if (activeHand !== hand) {
|
||||
// // No switching while the other is already triggered, so no need to release.
|
||||
// activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand;
|
||||
// }
|
||||
// if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) {
|
||||
// return;
|
||||
// }
|
||||
// var eventResult = that.mousePressEvent({});
|
||||
// if (!eventResult || (eventResult === 'selectionBox')) {
|
||||
// var pickRay = controllerComputePickRay();
|
||||
// if (pickRay) {
|
||||
// var entityIntersection = Entities.findRayIntersection(pickRay, true);
|
||||
function makeTriggerHandler(hand) {
|
||||
return function (value) {
|
||||
if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth?
|
||||
that.triggered = true;
|
||||
if (activeHand !== hand) {
|
||||
// No switching while the other is already triggered, so no need to release.
|
||||
activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand;
|
||||
}
|
||||
if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) {
|
||||
return;
|
||||
}
|
||||
var eventResult = that.mousePressEvent({});
|
||||
// if (!eventResult || (eventResult === 'selectionBox')) {
|
||||
// var pickRay = controllerComputePickRay();
|
||||
// if (pickRay) {
|
||||
// var entityIntersection = Entities.findRayIntersection(pickRay, true);
|
||||
|
||||
|
||||
// var overlayIntersection = Overlays.findRayIntersection(pickRay);
|
||||
// if (entityIntersection.intersects &&
|
||||
// (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) {
|
||||
// var overlayIntersection = Overlays.findRayIntersection(pickRay);
|
||||
// if (entityIntersection.intersects &&
|
||||
// (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) {
|
||||
|
||||
// if (HMD.tabletID === entityIntersection.entityID) {
|
||||
// return;
|
||||
// }
|
||||
// if (HMD.tabletID === entityIntersection.entityID) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// selectionManager.setSelections([entityIntersection.entityID]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) {
|
||||
// that.triggered = false;
|
||||
// that.mouseReleaseEvent({});
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
// that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand));
|
||||
// that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand));
|
||||
// selectionManager.setSelections([entityIntersection.entityID]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) {
|
||||
that.triggered = false;
|
||||
that.mouseReleaseEvent({});
|
||||
}
|
||||
};
|
||||
}
|
||||
that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand));
|
||||
that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand));
|
||||
|
||||
|
||||
function controllerComputePickRay() {
|
||||
|
@ -2064,7 +2064,7 @@ SelectionDisplay = (function() {
|
|||
});
|
||||
Overlays.editOverlay(grabberPointLightL, {
|
||||
visible: false
|
||||
});
|
||||
});
|
||||
Overlays.editOverlay(grabberPointLightR, {
|
||||
visible: false
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue