kill gravity in near-held objects

This commit is contained in:
Seth Alves 2015-10-02 17:54:09 -07:00
parent 6a770a870b
commit 26310d8ce4

View file

@ -431,7 +431,7 @@ function MyController(hand, triggerAction) {
this.activateEntity(this.grabbedEntity);
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, ["position", "rotation"]);
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, ["position", "rotation", "gravity"]);
var handRotation = this.getHandRotation();
var handPosition = this.getHandPosition();
@ -443,6 +443,9 @@ function MyController(hand, triggerAction) {
var offset = Vec3.subtract(currentObjectPosition, handPosition);
var offsetPosition = Vec3.multiplyQbyV(Quat.inverse(Quat.multiply(handRotation, offsetRotation)), offset);
this.saveGravity = grabbedProperties.gravity;
Entities.editEntity(this.grabbedEntity, {gravity: {x:0, y:0, z:0}});
this.actionID = NULL_ACTION_ID;
this.actionID = Entities.addAction("kinematic-hold", this.grabbedEntity, {
hand: this.hand === RIGHT_HAND ? "right" : "left",
@ -472,6 +475,7 @@ function MyController(hand, triggerAction) {
this.continueNearGrabbing = function() {
if (this.triggerSmoothedReleased()) {
this.state = STATE_RELEASE;
Entities.editEntity(this.grabbedEntity, {gravity: this.saveGravity});
return;
}