handles etc work better

This commit is contained in:
Seth Alves 2017-02-14 13:57:48 -08:00
parent b86886667b
commit 3a23ec86d5
4 changed files with 80 additions and 66 deletions

View file

@ -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,7 +859,8 @@ function MyController(hand) {
};
this.setState = function(newState, reason) {
if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID )&& (newState !== STATE_OFF &&
if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID) &&
(newState !== STATE_OFF &&
newState !== STATE_SEARCHING &&
newState !== STATE_OVERLAY_STYLUS_TOUCHING)) {
return;
@ -1199,6 +1201,10 @@ function MyController(hand) {
this.checkForUnexpectedChildren();
if (this.editTriggered) {
this.editTriggered = false;
}
if (this.triggerSmoothedReleased() && this.secondaryReleased()) {
this.waitForTriggerRelease = false;
}
@ -1636,6 +1642,7 @@ function MyController(hand) {
return aDistance - bDistance;
});
entity = grabbableEntities[0];
if (!isInEditMode() || entity == HMD.tabletID) {
name = entityPropertiesCache.getProps(entity).name;
this.grabbedEntity = entity;
if (this.entityWantsTrigger(entity)) {
@ -1655,6 +1662,7 @@ function MyController(hand) {
}
}
}
}
if (rayPickInfo.distance >= WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) {
this.handleLaserOnHomeButton(rayPickInfo);
@ -1666,16 +1674,22 @@ function MyController(hand) {
}
}
if (rayPickInfo.entityID) {
if (this.triggerSmoothedGrab() && isInEditMode()) {
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)) {

View file

@ -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;

View file

@ -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;

View file

@ -1028,18 +1028,18 @@ 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({});
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) {
@ -1058,14 +1058,14 @@ SelectionDisplay = (function() {
// }
// }
// }
// } 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));
} 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() {