From 5cc5a2ab33aa2df0edfb622849d17b220c3c1a00 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 17 Dec 2015 10:58:14 -0800 Subject: [PATCH] working non kinematic release --- examples/controllers/handControllerGrab.js | 71 ++++++++++++------- examples/light_modifier/lightLoader.js | 6 +- examples/light_modifier/lightModifier.js | 8 +-- .../light_modifier/lightModifierTestScene.js | 3 +- 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 9efbff7c58..f21df807b4 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -817,26 +817,35 @@ function MyController(hand) { Entities.callEntityMethod(this.grabbedEntity, "continueDistantGrab"); + var defaultMoveWithHeadData = { + disableMoveWithHead: false + }; + var handControllerData = getEntityCustomData('handControllerKey', this.grabbedEntity, defaultMoveWithHeadData); - // mix in head motion - if (MOVE_WITH_HEAD) { - var objDistance = Vec3.length(objectToAvatar); - var before = Vec3.multiplyQbyV(this.currentCameraOrientation, { - x: 0.0, - y: 0.0, - z: objDistance - }); - var after = Vec3.multiplyQbyV(Camera.orientation, { - x: 0.0, - y: 0.0, - z: objDistance - }); - var change = Vec3.subtract(before, after); - this.currentCameraOrientation = Camera.orientation; - this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, change); + if (handControllerData.disableMoveWithHead !== true) { + // mix in head motion + if (MOVE_WITH_HEAD) { + var objDistance = Vec3.length(objectToAvatar); + var before = Vec3.multiplyQbyV(this.currentCameraOrientation, { + x: 0.0, + y: 0.0, + z: objDistance + }); + var after = Vec3.multiplyQbyV(Camera.orientation, { + x: 0.0, + y: 0.0, + z: objDistance + }); + var change = Vec3.subtract(before, after); + this.currentCameraOrientation = Camera.orientation; + this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, change); + } + } else { + print('should not head move!'); } + var defaultConstraintData = { axisStart: false, axisEnd: false, @@ -846,7 +855,6 @@ function MyController(hand) { var clampedVector; var targetPosition; if (constraintData.axisStart !== false) { - print('CONSTRAINING OBJECT') clampedVector = this.projectVectorAlongAxis(this.currentObjectPosition, constraintData.axisStart, constraintData.axisEnd); targetPosition = clampedVector; } else { @@ -1249,15 +1257,29 @@ function MyController(hand) { disableReleaseVelocity: false }; - var releaseVelocityData = getEntityCustomData('releaseVelocityKey', this.grabbedEntity, defaultReleaseVelocityData); + var releaseVelocityData = getEntityCustomData('handControllerKey', this.grabbedEntity, defaultReleaseVelocityData); if (releaseVelocityData.disableReleaseVelocity === true) { - Entities.updateAction(this.grabbedEntity, this.actionID, { - ttl: 1, - kinematic: false, - kinematicSetVelocity: false, + print('SHOULD NOT BE KINEMATIC AT RELEASE') + // Entities.updateAction(this.grabbedEntity, this.actionID, { + // ttl: 1, + // kinematic: false, + // kinematicSetVelocity: false, + // }); + Entities.deleteAction(this.grabbedEntity, this.actionID); - }); - // Entities.deleteAction(this.grabbedEntity, this.actionID); + Entities.editEntity(this.grabbedEntity,{ + velocity:{ + x:0, + y:0, + z:0 + }, + angularVelocity:{ + x:0, + y:0, + z:0 + } + }) + Entities.deleteAction(this.grabbedEntity, this.actionID); } else { //don't make adjustments @@ -1266,7 +1288,6 @@ function MyController(hand) { } } } - this.deactivateEntity(this.grabbedEntity); this.grabbedEntity = null; diff --git a/examples/light_modifier/lightLoader.js b/examples/light_modifier/lightLoader.js index e4022e7bc1..83618f85c2 100644 --- a/examples/light_modifier/lightLoader.js +++ b/examples/light_modifier/lightLoader.js @@ -10,11 +10,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var grabScript = Script.resolvePath('../controllers/handControllerGrab.js'); +var grabScript = Script.resolvePath('../controllers/handControllerGrab.js?' + Math.random(0 - 100)); Script.load(grabScript); -var lightModifier = Script.resolvePath('lightModifier.js'); +var lightModifier = Script.resolvePath('lightModifier.js?' + Math.random(0 - 100)); Script.load(lightModifier); Script.setTimeout(function() { - var lightModifierTestScene = Script.resolvePath('lightModifierTestScene.js'); + var lightModifierTestScene = Script.resolvePath('lightModifierTestScene.js?' + Math.random(0 - 100)); Script.load(lightModifierTestScene); }, 750) \ No newline at end of file diff --git a/examples/light_modifier/lightModifier.js b/examples/light_modifier/lightModifier.js index 7cd442e9ed..8eae5cc2a4 100644 --- a/examples/light_modifier/lightModifier.js +++ b/examples/light_modifier/lightModifier.js @@ -251,15 +251,15 @@ entitySlider.prototype = { axisStart: position, axisEnd: this.endOfAxis, }, - releaseVelocityKey: { - disableReleaseVelocity: true + handControllerKey: { + disableReleaseVelocity: true, + disableMoveWithHead: true } - }) + }), }; this.sliderIndicator = Entities.addEntity(properties); }, - setValueFromMessage: function(message) { //message is not for our light diff --git a/examples/light_modifier/lightModifierTestScene.js b/examples/light_modifier/lightModifierTestScene.js index 84fb779469..761eb4786d 100644 --- a/examples/light_modifier/lightModifierTestScene.js +++ b/examples/light_modifier/lightModifierTestScene.js @@ -75,8 +75,7 @@ function createBlock() { }, position: position, userData: JSON.stringify({ - - releaseVelocityKey: { + handControllerKey: { disableReleaseVelocity: true } })