converting existing JS scripts to use new damping

Old formula the scripts were using:  v *= damping

So a value of 0.999 was "little damping" and a value of 0.001 was "very strong damping",
but now that is reversed.

New formula: v *= (1 j- damping)^dt

A damping value of 0.001 now means "very little damping"
and a value of 0.999 means "very strong damping".
This commit is contained in:
Andrew Meadows 2015-01-05 11:25:15 -08:00
parent 3b7770f405
commit 21b2d14956
7 changed files with 11 additions and 11 deletions

View file

@ -79,7 +79,7 @@ function addButterfly() {
rotation: Quat.fromPitchYawRollDegrees(-80 + Math.random() * 20, Math.random() * 360.0, 0.0),
velocity: { x: 0, y: 0, z: 0 },
gravity: { x: 0, y: GRAVITY, z: 0 },
damping: 0.9999,
damping: 0.00001,
dimensions: dimensions,
color: color,
animationURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/models/content/butterfly/butterfly.fbx",
@ -138,4 +138,4 @@ Script.scriptEnding.connect(function() {
for (var i = 0; i < numButterflies; i++) {
Entities.deleteEntity(butterflies[i]);
}
});
});

View file

@ -11,7 +11,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var damping = 0.9;
var damping = 0.001;
var yaw = 0.0;
var pitch = 0.0;
var roll = 0.0;

View file

@ -208,7 +208,7 @@ function checkControllerSide(hand) {
gravity: { x: 0, y: 0, z: 0},
inHand: true,
dimensions: { x: FRISBEE_RADIUS, y: FRISBEE_RADIUS / 5, z: FRISBEE_RADIUS },
damping: 0.999,
damping: 0.00001,
modelURL: modelUrl,
modelScale: FRISBEE_MODEL_SCALE,
modelRotation: hand.holdRotation(),
@ -235,7 +235,7 @@ function checkControllerSide(hand) {
gravity: { x: 0, y: 0, z: 0},
inHand: true,
dimensions: { x: FRISBEE_RADIUS, y: FRISBEE_RADIUS / 5, z: FRISBEE_RADIUS },
damping: 0.999,
damping: 0.00001,
modelURL: frisbeeURL(),
modelScale: FRISBEE_MODEL_SCALE,
modelRotation: hand.holdRotation(),
@ -444,4 +444,4 @@ Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
Menu.menuItemEvent.connect(menuItemEvent);
Script.scriptEnding.connect(scriptEnding);
Script.update.connect(checkController);
Script.update.connect(controlFrisbees);
Script.update.connect(controlFrisbees);

View file

@ -145,7 +145,7 @@ function shootTarget() {
velocity: velocity,
gravity: { x: 0, y: TARGET_GRAVITY, z: 0 },
lifetime: 1000.0,
damping: 0.99 });
damping: 0.0001 });
// Record start time
shotTime = new Date();

View file

@ -144,7 +144,7 @@ function shootTarget() {
velocity: velocity,
gravity: { x: 0, y: TARGET_GRAVITY, z: 0 },
lifetime: TARGET_LIFETIME,
damping: 0.99 });
damping: 0.0001 });
// Record start time
shotTime = new Date();

View file

@ -137,7 +137,7 @@ function checkControllerSide(whichSide) {
gravity: { x: 0, y: 0, z: 0},
inHand: true,
radius: { x: BALL_RADIUS * 2, y: BALL_RADIUS * 2, z: BALL_RADIUS * 2 },
damping: 0.999,
damping: 0.00001,
color: HELD_COLOR,
lifetime: 600 // 10 seconds - same as default, not needed but here as an example

View file

@ -12,7 +12,7 @@ var properties = {
velocity: { x: 0, y: 0, z: 0},
gravity: { x: 0, y: -0.05, z: 0},
radius: radius,
damping: 0.999,
damping: 0.00001,
color: { red: 200, green: 0, blue: 0 },
lifetime: 60
};
@ -22,4 +22,4 @@ position.x -= radius * 1.0;
properties.position = position;
var newEntityTwo = Entities.addEntity(properties);
Script.stop(); // no need to run anymore
Script.stop(); // no need to run anymore