From 26310d8ce421369193be808b451cf09d7418c787 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 2 Oct 2015 17:54:09 -0700 Subject: [PATCH] kill gravity in near-held objects --- examples/controllers/handControllerGrab.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index a8a95cb4ca..d143df1e83 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -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; }