in STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING, when the ray moves off of the entity, switch back to search state

This commit is contained in:
Seth Alves 2015-10-16 11:39:27 -07:00
parent 066696e201
commit c98685f6d3

View file

@ -579,9 +579,7 @@ function MyController(hand, triggerAction) {
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
}
Entities.callEntityMethod(this.grabbedEntity, "startFarGrabNonColliding");
// TODO -- figure out how to make this work.
// this.setState(STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING);
this.setState(STATE_RELEASE);
this.setState(STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING);
};
this.continueNearGrabbingNonColliding = function() {
@ -589,7 +587,7 @@ function MyController(hand, triggerAction) {
this.setState(STATE_RELEASE);
return;
}
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrabbingNonColliding");
};
@ -605,6 +603,16 @@ function MyController(hand, triggerAction) {
direction: Quat.getUp(this.getHandRotation())
};
var now = Date.now();
if (now - this.lastPickTime > MSECS_PER_SEC / PICKS_PER_SECOND_PER_HAND) {
var intersection = Entities.findRayIntersection(pickRay, true);
this.lastPickTime = now;
if (intersection.entityID != this.grabbedEntity) {
this.setState(STATE_RELEASE);
return;
}
}
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
Entities.callEntityMethod(this.grabbedEntity, "continueFarGrabbingNonColliding");
};