physics-animator 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,17 +45,17 @@ exports.SpringAnimator = {
|
|
|
45
45
|
var Spring;
|
|
46
46
|
(function (Spring) {
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Exponential decay without any bounce
|
|
49
49
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* `strength = damping * damping / 4`
|
|
50
|
+
* Control with either duration_s or halfLife_s
|
|
53
51
|
*/
|
|
54
52
|
function Exponential(options) {
|
|
55
53
|
// found numerically
|
|
56
54
|
const halfLifeConstant = 3.356694; // from solve (1+u)*exp(-u)=0.5 for u, and constant = 2u
|
|
57
55
|
const pointOnePercentConstant = 18.46682; // from solve (1+u)*exp(-u)=0.001 for u, and constant = 2u
|
|
58
|
-
const damping =
|
|
56
|
+
const damping = ('halfLife_s' in options)
|
|
57
|
+
? halfLifeConstant / options.halfLife_s
|
|
58
|
+
: pointOnePercentConstant / options.duration_s;
|
|
59
59
|
let strength = damping * damping / 4;
|
|
60
60
|
return { damping, strength };
|
|
61
61
|
}
|
|
@@ -42,17 +42,17 @@ export const SpringAnimator = {
|
|
|
42
42
|
export var Spring;
|
|
43
43
|
(function (Spring) {
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Exponential decay without any bounce
|
|
46
46
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* `strength = damping * damping / 4`
|
|
47
|
+
* Control with either duration_s or halfLife_s
|
|
50
48
|
*/
|
|
51
49
|
function Exponential(options) {
|
|
52
50
|
// found numerically
|
|
53
51
|
const halfLifeConstant = 3.356694; // from solve (1+u)*exp(-u)=0.5 for u, and constant = 2u
|
|
54
52
|
const pointOnePercentConstant = 18.46682; // from solve (1+u)*exp(-u)=0.001 for u, and constant = 2u
|
|
55
|
-
const damping =
|
|
53
|
+
const damping = ('halfLife_s' in options)
|
|
54
|
+
? halfLifeConstant / options.halfLife_s
|
|
55
|
+
: pointOnePercentConstant / options.duration_s;
|
|
56
56
|
let strength = damping * damping / 4;
|
|
57
57
|
return { damping, strength };
|
|
58
58
|
}
|
|
@@ -8,6 +8,8 @@ export declare const SpringAnimator: IFieldAnimator<SpringParameters, SpringStat
|
|
|
8
8
|
type ExponentialParameters = {
|
|
9
9
|
/** Defined as the point in time we'll reach within 0.01% of target from 0 velocity start */
|
|
10
10
|
duration_s: number;
|
|
11
|
+
} | {
|
|
12
|
+
halfLife_s: number;
|
|
11
13
|
};
|
|
12
14
|
type UnderdampedParameters = {
|
|
13
15
|
/** Defined as the point in time we'll reach within 0.01% of target from 0 velocity start */
|
|
@@ -31,11 +33,9 @@ export declare namespace Spring {
|
|
|
31
33
|
damping: number;
|
|
32
34
|
};
|
|
33
35
|
/**
|
|
34
|
-
*
|
|
36
|
+
* Exponential decay without any bounce
|
|
35
37
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* `strength = damping * damping / 4`
|
|
38
|
+
* Control with either duration_s or halfLife_s
|
|
39
39
|
*/
|
|
40
40
|
function Exponential(options: ExponentialParameters): PhysicsParameters;
|
|
41
41
|
function Underdamped(options: UnderdampedParameters): PhysicsParameters;
|
package/package.json
CHANGED