physics-animator 0.9.1 → 0.11.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.
- package/dist/cjs/Animator.js +7 -3
- package/dist/cjs/animators/IFieldAnimator.js +2 -0
- package/dist/cjs/animators/SpringAnimator.js +3 -3
- package/dist/cjs/animators/TweenAnimator.js +3 -3
- package/dist/cjs/animators/index.js +19 -0
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/utils/index.js +17 -0
- package/dist/esm/Animator.js +5 -1
- package/dist/esm/animators/IFieldAnimator.js +1 -0
- package/dist/esm/animators/SpringAnimator.js +1 -1
- package/dist/esm/animators/TweenAnimator.js +1 -1
- package/dist/esm/animators/index.js +3 -0
- package/dist/esm/index.js +0 -2
- package/dist/esm/utils/index.js +1 -0
- package/dist/types/Animator.d.ts +5 -1
- package/dist/types/{IFieldAnimator.d.ts → animators/IFieldAnimator.d.ts} +1 -4
- package/dist/types/animators/SpringAnimator.d.ts +1 -1
- package/dist/types/animators/TweenAnimator.d.ts +1 -1
- package/dist/types/animators/index.d.ts +3 -0
- package/dist/types/index.d.ts +0 -2
- package/dist/types/react/useSpringState.d.ts +1 -1
- package/dist/types/react/useSpringValue.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +10 -1
- package/dist/cjs/IFieldAnimator.js +0 -8
- package/dist/esm/IFieldAnimator.js +0 -5
- /package/dist/cjs/{AnimationSequencer.js → utils/AnimationSequencer.js} +0 -0
- /package/dist/esm/{AnimationSequencer.js → utils/AnimationSequencer.js} +0 -0
- /package/dist/types/{AnimationSequencer.d.ts → utils/AnimationSequencer.d.ts} +0 -0
package/dist/cjs/Animator.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Animator = void 0;
|
|
3
|
+
exports.StepResult = exports.Animator = void 0;
|
|
4
4
|
const event_signal_1 = require("@haxiomic/event-signal");
|
|
5
|
-
const IFieldAnimator_js_1 = require("./IFieldAnimator.js");
|
|
6
5
|
const SpringAnimator_js_1 = require("./animators/SpringAnimator.js");
|
|
7
6
|
const TweenAnimator_js_1 = require("./animators/TweenAnimator.js");
|
|
8
7
|
/**
|
|
@@ -155,7 +154,7 @@ class Animator {
|
|
|
155
154
|
this.dispatchChangeFieldEvent(object, field);
|
|
156
155
|
// handle animation completion
|
|
157
156
|
switch (result) {
|
|
158
|
-
case
|
|
157
|
+
case StepResult.Complete:
|
|
159
158
|
{
|
|
160
159
|
objectAnims.delete(field);
|
|
161
160
|
this.events.completeField.dispatch({ object, field });
|
|
@@ -374,6 +373,11 @@ class Animator {
|
|
|
374
373
|
}
|
|
375
374
|
}
|
|
376
375
|
exports.Animator = Animator;
|
|
376
|
+
var StepResult;
|
|
377
|
+
(function (StepResult) {
|
|
378
|
+
StepResult[StepResult["Continue"] = 0] = "Continue";
|
|
379
|
+
StepResult[StepResult["Complete"] = 1] = "Complete";
|
|
380
|
+
})(StepResult || (exports.StepResult = StepResult = {}));
|
|
377
381
|
function forObjectFieldsRecursive(sourceObj, targetObj, callback) {
|
|
378
382
|
for (let field in targetObj) {
|
|
379
383
|
if (Object.prototype.hasOwnProperty.call(targetObj, field)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Spring = exports.SpringAnimator = void 0;
|
|
4
|
-
const
|
|
4
|
+
const Animator_js_1 = require("../Animator.js");
|
|
5
5
|
const defaultSpringParameters = {
|
|
6
6
|
duration_s: 0.5,
|
|
7
7
|
};
|
|
@@ -35,10 +35,10 @@ exports.SpringAnimator = {
|
|
|
35
35
|
// complete the animation if it's close enough to the target and velocity is close to 0
|
|
36
36
|
if (Math.abs(state.x - state.targetX) < 0.0001 && Math.abs(state.v) < 0.0001) {
|
|
37
37
|
object[field] = state.targetX;
|
|
38
|
-
return
|
|
38
|
+
return Animator_js_1.StepResult.Complete;
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
return
|
|
41
|
+
return Animator_js_1.StepResult.Continue;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -5,7 +5,7 @@ exports.linearStep = linearStep;
|
|
|
5
5
|
exports.easeInOutStep = easeInOutStep;
|
|
6
6
|
exports.easeInStep = easeInStep;
|
|
7
7
|
exports.easeOutStep = easeOutStep;
|
|
8
|
-
const
|
|
8
|
+
const Animator_js_1 = require("../Animator.js");
|
|
9
9
|
const defaultParams = {
|
|
10
10
|
duration_s: 0.5, // default duration of the tween in seconds
|
|
11
11
|
easingFn: linearStep, // default easing function is linear
|
|
@@ -37,10 +37,10 @@ exports.TweenAnimator = {
|
|
|
37
37
|
let deltaTime_s = (performance.now() - state.t0_ms) / 1000;
|
|
38
38
|
if (deltaTime_s >= state.duration_s) {
|
|
39
39
|
object[field] = state.target;
|
|
40
|
-
return
|
|
40
|
+
return Animator_js_1.StepResult.Complete;
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
|
-
return
|
|
43
|
+
return Animator_js_1.StepResult.Continue;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./SpringAnimator.js"), exports);
|
|
18
|
+
__exportStar(require("./TweenAnimator.js"), exports);
|
|
19
|
+
__exportStar(require("./IFieldAnimator.js"), exports);
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,6 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./AnimationSequencer.js"), exports);
|
|
18
17
|
__exportStar(require("./Animator.js"), exports);
|
|
19
|
-
__exportStar(require("./IFieldAnimator.js"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AnimationSequencer.js"), exports);
|
package/dist/esm/Animator.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EventSignal } from "@haxiomic/event-signal";
|
|
2
|
-
import { StepResult } from "./IFieldAnimator.js";
|
|
3
2
|
import { SpringAnimator } from "./animators/SpringAnimator.js";
|
|
4
3
|
import { easeInOutStep, easeInStep, easeOutStep, linearStep, TweenAnimator } from "./animators/TweenAnimator.js";
|
|
5
4
|
/**
|
|
@@ -370,6 +369,11 @@ export class Animator {
|
|
|
370
369
|
return animation;
|
|
371
370
|
}
|
|
372
371
|
}
|
|
372
|
+
export var StepResult;
|
|
373
|
+
(function (StepResult) {
|
|
374
|
+
StepResult[StepResult["Continue"] = 0] = "Continue";
|
|
375
|
+
StepResult[StepResult["Complete"] = 1] = "Complete";
|
|
376
|
+
})(StepResult || (StepResult = {}));
|
|
373
377
|
function forObjectFieldsRecursive(sourceObj, targetObj, callback) {
|
|
374
378
|
for (let field in targetObj) {
|
|
375
379
|
if (Object.prototype.hasOwnProperty.call(targetObj, field)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AnimationSequencer.js';
|
package/dist/types/Animator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventSignal } from "@haxiomic/event-signal";
|
|
2
|
-
import { IFieldAnimator } from "./IFieldAnimator.js";
|
|
2
|
+
import { IFieldAnimator } from "./animators/IFieldAnimator.js";
|
|
3
3
|
import { SpringParameters } from "./animators/SpringAnimator.js";
|
|
4
4
|
import { EasingStepFn } from "./animators/TweenAnimator.js";
|
|
5
5
|
/**
|
|
@@ -141,6 +141,10 @@ export declare class Animator {
|
|
|
141
141
|
*/
|
|
142
142
|
private syncAnimation;
|
|
143
143
|
}
|
|
144
|
+
export declare enum StepResult {
|
|
145
|
+
Continue = 0,// continue stepping
|
|
146
|
+
Complete = 1
|
|
147
|
+
}
|
|
144
148
|
type FieldAnimation<Params, State> = {
|
|
145
149
|
animator: IFieldAnimator<Params, State, any>;
|
|
146
150
|
state: State;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Continue = 0,// continue stepping
|
|
3
|
-
Complete = 1
|
|
4
|
-
}
|
|
1
|
+
import { StepResult } from "../Animator.js";
|
|
5
2
|
export interface IFieldAnimator<Params, State, FieldType> {
|
|
6
3
|
createState<Name extends keyof Obj, Obj extends Record<Name, FieldType>>(object: Obj, field: Name, target: Obj[Name], params: Params | null): State;
|
|
7
4
|
updateState<Name extends keyof Obj, Obj extends Record<Name, FieldType>>(state: State, object: Obj, field: Name, target: Obj[Name], params: Params | null): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Animator } from "../Animator.js";
|
|
2
|
-
import { SpringParameters } from "
|
|
2
|
+
import { SpringParameters } from "../animators/SpringAnimator.js";
|
|
3
3
|
/**
|
|
4
4
|
* A value that animates to a target value using a spring animation.
|
|
5
5
|
* This **will** cause a re-render when the value changes.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Animator } from "../Animator.js";
|
|
2
|
-
import { SpringParameters } from "
|
|
2
|
+
import { SpringParameters } from "../animators/SpringAnimator.js";
|
|
3
3
|
/**
|
|
4
4
|
* A value that animates to a target value using a spring animation.
|
|
5
5
|
* This will **not** cause a re-render when the value changes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AnimationSequencer.js';
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "physics-animator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"author": "haxiomic (George Corney)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A TypeScript animation system grounded in physics with three.js and react support.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"physics",
|
|
9
|
+
"animation",
|
|
10
|
+
"three.js",
|
|
11
|
+
"react",
|
|
12
|
+
"typescript",
|
|
13
|
+
"spring",
|
|
14
|
+
"tween"
|
|
15
|
+
],
|
|
7
16
|
"type": "module",
|
|
8
17
|
"main": "dist/cjs/index.js",
|
|
9
18
|
"module": "dist/esm/index.js",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StepResult = void 0;
|
|
4
|
-
var StepResult;
|
|
5
|
-
(function (StepResult) {
|
|
6
|
-
StepResult[StepResult["Continue"] = 0] = "Continue";
|
|
7
|
-
StepResult[StepResult["Complete"] = 1] = "Complete";
|
|
8
|
-
})(StepResult || (exports.StepResult = StepResult = {}));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|