working non kinematic release

This commit is contained in:
James B. Pollack 2015-12-17 10:58:14 -08:00
parent cd911b31d2
commit 5cc5a2ab33
4 changed files with 54 additions and 34 deletions

View file

@ -817,8 +817,13 @@ function MyController(hand) {
Entities.callEntityMethod(this.grabbedEntity, "continueDistantGrab"); Entities.callEntityMethod(this.grabbedEntity, "continueDistantGrab");
var defaultMoveWithHeadData = {
disableMoveWithHead: false
};
var handControllerData = getEntityCustomData('handControllerKey', this.grabbedEntity, defaultMoveWithHeadData);
if (handControllerData.disableMoveWithHead !== true) {
// mix in head motion // mix in head motion
if (MOVE_WITH_HEAD) { if (MOVE_WITH_HEAD) {
var objDistance = Vec3.length(objectToAvatar); var objDistance = Vec3.length(objectToAvatar);
@ -836,6 +841,10 @@ function MyController(hand) {
this.currentCameraOrientation = Camera.orientation; this.currentCameraOrientation = Camera.orientation;
this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, change); this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, change);
} }
} else {
print('should not head move!');
}
var defaultConstraintData = { var defaultConstraintData = {
axisStart: false, axisStart: false,
@ -846,7 +855,6 @@ function MyController(hand) {
var clampedVector; var clampedVector;
var targetPosition; var targetPosition;
if (constraintData.axisStart !== false) { if (constraintData.axisStart !== false) {
print('CONSTRAINING OBJECT')
clampedVector = this.projectVectorAlongAxis(this.currentObjectPosition, constraintData.axisStart, constraintData.axisEnd); clampedVector = this.projectVectorAlongAxis(this.currentObjectPosition, constraintData.axisStart, constraintData.axisEnd);
targetPosition = clampedVector; targetPosition = clampedVector;
} else { } else {
@ -1249,15 +1257,29 @@ function MyController(hand) {
disableReleaseVelocity: false disableReleaseVelocity: false
}; };
var releaseVelocityData = getEntityCustomData('releaseVelocityKey', this.grabbedEntity, defaultReleaseVelocityData); var releaseVelocityData = getEntityCustomData('handControllerKey', this.grabbedEntity, defaultReleaseVelocityData);
if (releaseVelocityData.disableReleaseVelocity === true) { if (releaseVelocityData.disableReleaseVelocity === true) {
Entities.updateAction(this.grabbedEntity, this.actionID, { print('SHOULD NOT BE KINEMATIC AT RELEASE')
ttl: 1, // Entities.updateAction(this.grabbedEntity, this.actionID, {
kinematic: false, // ttl: 1,
kinematicSetVelocity: false, // kinematic: false,
// kinematicSetVelocity: false,
// });
Entities.deleteAction(this.grabbedEntity, this.actionID);
}); Entities.editEntity(this.grabbedEntity,{
// Entities.deleteAction(this.grabbedEntity, this.actionID); velocity:{
x:0,
y:0,
z:0
},
angularVelocity:{
x:0,
y:0,
z:0
}
})
Entities.deleteAction(this.grabbedEntity, this.actionID);
} else { } else {
//don't make adjustments //don't make adjustments
@ -1266,7 +1288,6 @@ function MyController(hand) {
} }
} }
} }
this.deactivateEntity(this.grabbedEntity); this.deactivateEntity(this.grabbedEntity);
this.grabbedEntity = null; this.grabbedEntity = null;

View file

@ -10,11 +10,11 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // 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); Script.load(grabScript);
var lightModifier = Script.resolvePath('lightModifier.js'); var lightModifier = Script.resolvePath('lightModifier.js?' + Math.random(0 - 100));
Script.load(lightModifier); Script.load(lightModifier);
Script.setTimeout(function() { Script.setTimeout(function() {
var lightModifierTestScene = Script.resolvePath('lightModifierTestScene.js'); var lightModifierTestScene = Script.resolvePath('lightModifierTestScene.js?' + Math.random(0 - 100));
Script.load(lightModifierTestScene); Script.load(lightModifierTestScene);
}, 750) }, 750)

View file

@ -251,15 +251,15 @@ entitySlider.prototype = {
axisStart: position, axisStart: position,
axisEnd: this.endOfAxis, axisEnd: this.endOfAxis,
}, },
releaseVelocityKey: { handControllerKey: {
disableReleaseVelocity: true disableReleaseVelocity: true,
disableMoveWithHead: true
} }
}) }),
}; };
this.sliderIndicator = Entities.addEntity(properties); this.sliderIndicator = Entities.addEntity(properties);
}, },
setValueFromMessage: function(message) { setValueFromMessage: function(message) {
//message is not for our light //message is not for our light

View file

@ -75,8 +75,7 @@ function createBlock() {
}, },
position: position, position: position,
userData: JSON.stringify({ userData: JSON.stringify({
handControllerKey: {
releaseVelocityKey: {
disableReleaseVelocity: true disableReleaseVelocity: true
} }
}) })