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.grabPointIntersectsEntity = false;
this.stylus = null; this.stylus = null;
this.homeButtonTouched = false; this.homeButtonTouched = false;
this.editTriggered = false;
// Until there is some reliable way to keep track of a "stack" of parentIDs, we'll have problems // 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 // 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) { 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_SEARCHING &&
newState !== STATE_OVERLAY_STYLUS_TOUCHING)) { newState !== STATE_OVERLAY_STYLUS_TOUCHING)) {
return; return;
@ -1199,6 +1201,10 @@ function MyController(hand) {
this.checkForUnexpectedChildren(); this.checkForUnexpectedChildren();
if (this.editTriggered) {
this.editTriggered = false;
}
if (this.triggerSmoothedReleased() && this.secondaryReleased()) { if (this.triggerSmoothedReleased() && this.secondaryReleased()) {
this.waitForTriggerRelease = false; this.waitForTriggerRelease = false;
} }
@ -1636,6 +1642,7 @@ function MyController(hand) {
return aDistance - bDistance; return aDistance - bDistance;
}); });
entity = grabbableEntities[0]; entity = grabbableEntities[0];
if (!isInEditMode() || entity == HMD.tabletID) {
name = entityPropertiesCache.getProps(entity).name; name = entityPropertiesCache.getProps(entity).name;
this.grabbedEntity = entity; this.grabbedEntity = entity;
if (this.entityWantsTrigger(entity)) { if (this.entityWantsTrigger(entity)) {
@ -1655,6 +1662,7 @@ function MyController(hand) {
} }
} }
} }
}
if (rayPickInfo.distance >= WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) { if (rayPickInfo.distance >= WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) {
this.handleLaserOnHomeButton(rayPickInfo); this.handleLaserOnHomeButton(rayPickInfo);
@ -1666,16 +1674,22 @@ function MyController(hand) {
} }
} }
if (rayPickInfo.entityID) { if (isInEditMode()) {
if (this.triggerSmoothedGrab() && isInEditMode()) {
this.searchIndicatorOn(rayPickInfo.searchRay); this.searchIndicatorOn(rayPickInfo.searchRay);
if (this.triggerSmoothedGrab()) {
if (!this.editTriggered && rayPickInfo.entityID) {
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
method: "selectEntity", method: "selectEntity",
entityID: rayPickInfo.entityID entityID: rayPickInfo.entityID
})); }));
}
this.editTriggered = true;
}
Reticle.setVisible(false);
return; return;
} }
if (rayPickInfo.entityID) {
entity = rayPickInfo.entityID; entity = rayPickInfo.entityID;
name = entityPropertiesCache.getProps(entity).name; name = entityPropertiesCache.getProps(entity).name;
if (this.entityWantsTrigger(entity)) { if (this.entityWantsTrigger(entity)) {

View file

@ -330,10 +330,10 @@ function loaded() {
} }
} else if (data.type == "update") { } else if (data.type == "update") {
var newEntities = data.entities; var newEntities = data.entities;
if (newEntities.length == 0) { if (newEntities && newEntities.length == 0) {
elNoEntitiesMessage.style.display = "block"; elNoEntitiesMessage.style.display = "block";
elFooter.firstChild.nodeValue = "0 entities found"; elFooter.firstChild.nodeValue = "0 entities found";
} else { } else if (newEntities) {
elNoEntitiesMessage.style.display = "none"; elNoEntitiesMessage.style.display = "none";
for (var i = 0; i < newEntities.length; i++) { for (var i = 0; i < newEntities.length; i++) {
var id = newEntities[i].id; var id = newEntities[i].id;

View file

@ -732,7 +732,7 @@ function loaded() {
} }
} else if (data.type == "update") { } else if (data.type == "update") {
if (data.selections.length == 0) { if (!data.selections || data.selections.length == 0) {
if (editor !== null && lastEntityID !== null) { if (editor !== null && lastEntityID !== null) {
saveJSONUserData(true); saveJSONUserData(true);
deleteJSONEditor(); deleteJSONEditor();
@ -741,7 +741,7 @@ function loaded() {
elType.innerHTML = "<i>No selection</i>"; elType.innerHTML = "<i>No selection</i>";
elID.innerHTML = ""; elID.innerHTML = "";
disableProperties(); disableProperties();
} else if (data.selections.length > 1) { } else if (data.selections && data.selections.length > 1) {
deleteJSONEditor(); deleteJSONEditor();
var selections = data.selections; var selections = data.selections;

View file

@ -1028,18 +1028,18 @@ SelectionDisplay = (function() {
that.TRIGGER_OFF_VALUE = 0.15; that.TRIGGER_OFF_VALUE = 0.15;
that.triggered = false; that.triggered = false;
var activeHand = Controller.Standard.RightHand; var activeHand = Controller.Standard.RightHand;
// function makeTriggerHandler(hand) { function makeTriggerHandler(hand) {
// return function (value) { return function (value) {
// if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth? if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth?
// that.triggered = true; that.triggered = true;
// if (activeHand !== hand) { if (activeHand !== hand) {
// // No switching while the other is already triggered, so no need to release. // No switching while the other is already triggered, so no need to release.
// activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand;
// } }
// if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) { if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) {
// return; return;
// } }
// var eventResult = that.mousePressEvent({}); var eventResult = that.mousePressEvent({});
// if (!eventResult || (eventResult === 'selectionBox')) { // if (!eventResult || (eventResult === 'selectionBox')) {
// var pickRay = controllerComputePickRay(); // var pickRay = controllerComputePickRay();
// if (pickRay) { // if (pickRay) {
@ -1058,14 +1058,14 @@ SelectionDisplay = (function() {
// } // }
// } // }
// } // }
// } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) {
// that.triggered = false; that.triggered = false;
// that.mouseReleaseEvent({}); that.mouseReleaseEvent({});
// } }
// }; };
// } }
// that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand)); that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand));
// that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand)); that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand));
function controllerComputePickRay() { function controllerComputePickRay() {