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,9 +859,10 @@ 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_SEARCHING && (newState !== STATE_OFF &&
newState !== STATE_OVERLAY_STYLUS_TOUCHING)) { newState !== STATE_SEARCHING &&
newState !== STATE_OVERLAY_STYLUS_TOUCHING)) {
return; return;
} }
setGrabCommunications((newState === STATE_DISTANCE_HOLDING) || (newState === STATE_NEAR_GRABBING)); setGrabCommunications((newState === STATE_DISTANCE_HOLDING) || (newState === STATE_NEAR_GRABBING));
@ -1037,7 +1039,7 @@ function MyController(hand) {
} }
var searchSphereLocation = Vec3.sum(distantPickRay.origin, 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.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance,
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? (this.triggerSmoothedGrab() || this.secondarySqueezed()) ?
COLORS_GRAB_SEARCHING_FULL_SQUEEZE : COLORS_GRAB_SEARCHING_FULL_SQUEEZE :
@ -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,22 +1642,24 @@ function MyController(hand) {
return aDistance - bDistance; return aDistance - bDistance;
}); });
entity = grabbableEntities[0]; entity = grabbableEntities[0];
name = entityPropertiesCache.getProps(entity).name; if (!isInEditMode() || entity == HMD.tabletID) {
this.grabbedEntity = entity; name = entityPropertiesCache.getProps(entity).name;
if (this.entityWantsTrigger(entity)) { this.grabbedEntity = entity;
if (this.triggerSmoothedGrab()) { if (this.entityWantsTrigger(entity)) {
this.setState(STATE_NEAR_TRIGGER, "near trigger '" + name + "'"); if (this.triggerSmoothedGrab()) {
return; this.setState(STATE_NEAR_TRIGGER, "near trigger '" + name + "'");
return;
} else {
// potentialNearTriggerEntity = entity;
}
} else { } else {
// potentialNearTriggerEntity = entity; // If near something grabbable, grab it!
} if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) {
} else { this.setState(STATE_NEAR_GRABBING, "near grab '" + name + "'");
// If near something grabbable, grab it! return;
if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) { } else {
this.setState(STATE_NEAR_GRABBING, "near grab '" + name + "'"); // potentialNearGrabEntity = entity;
return; }
} else {
// potentialNearGrabEntity = entity;
} }
} }
} }
@ -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()) {
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ if (!this.editTriggered && rayPickInfo.entityID) {
method: "selectEntity", Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
entityID: rayPickInfo.entityID method: "selectEntity",
})); entityID: rayPickInfo.entityID
return; }));
}
this.editTriggered = true;
} }
Reticle.setVisible(false);
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,44 +1028,44 @@ 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) {
// var entityIntersection = Entities.findRayIntersection(pickRay, true); // var entityIntersection = Entities.findRayIntersection(pickRay, true);
// var overlayIntersection = Overlays.findRayIntersection(pickRay); // var overlayIntersection = Overlays.findRayIntersection(pickRay);
// if (entityIntersection.intersects && // if (entityIntersection.intersects &&
// (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) { // (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) {
// if (HMD.tabletID === entityIntersection.entityID) { // if (HMD.tabletID === entityIntersection.entityID) {
// return; // return;
// } // }
// selectionManager.setSelections([entityIntersection.entityID]); // selectionManager.setSelections([entityIntersection.entityID]);
// } // }
// } // }
// } // }
// } 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() {
@ -2064,7 +2064,7 @@ SelectionDisplay = (function() {
}); });
Overlays.editOverlay(grabberPointLightL, { Overlays.editOverlay(grabberPointLightL, {
visible: false visible: false
}); });
Overlays.editOverlay(grabberPointLightR, { Overlays.editOverlay(grabberPointLightR, {
visible: false visible: false
}); });