@aura3d/animation 1.4.0 → 1.4.1

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.
Files changed (46) hide show
  1. package/package.json +36 -3
  2. package/src/AnimationAction.ts +0 -166
  3. package/src/AnimationClip.ts +0 -63
  4. package/src/AnimationClipEvents.ts +0 -501
  5. package/src/AnimationClipRegistry.ts +0 -404
  6. package/src/AnimationController.ts +0 -1017
  7. package/src/AnimationEvents.ts +0 -34
  8. package/src/AnimationLayer.ts +0 -73
  9. package/src/AnimationMixer.ts +0 -402
  10. package/src/AnimationStateGraph.ts +0 -105
  11. package/src/AnimationStateMachine.ts +0 -265
  12. package/src/AnimationTrack.ts +0 -176
  13. package/src/BlendTree.ts +0 -89
  14. package/src/Bone.ts +0 -40
  15. package/src/CrowdAnimation.ts +0 -25
  16. package/src/ECSAnimationBridge.ts +0 -30
  17. package/src/FighterAnimationAdapter.ts +0 -124
  18. package/src/FootIk.ts +0 -251
  19. package/src/HumanoidBoneInference.ts +0 -323
  20. package/src/HumanoidRetargeting.ts +0 -700
  21. package/src/IK.ts +0 -117
  22. package/src/Inertialization.ts +0 -269
  23. package/src/Keyframe.ts +0 -159
  24. package/src/LocomotionController.ts +0 -155
  25. package/src/LocomotionKit.ts +0 -89
  26. package/src/MotionMatchingFixtures.ts +0 -254
  27. package/src/MotionQuality.ts +0 -182
  28. package/src/RigQuality.ts +0 -101
  29. package/src/RootMotion.ts +0 -124
  30. package/src/SceneAnimationBridge.ts +0 -80
  31. package/src/SecondaryAnimationFixtures.ts +0 -210
  32. package/src/Skeleton.ts +0 -78
  33. package/src/Skinning.ts +0 -18
  34. package/src/SpringBones.ts +0 -243
  35. package/src/browser-index.ts +0 -66
  36. package/src/index.ts +0 -66
  37. package/src/library/performanceStateGraph.ts +0 -173
  38. package/src/library/standardHumanoidClips.ts +0 -659
  39. package/src/threejs-compatibility/AnimationAction.ts +0 -27
  40. package/src/threejs-compatibility/AnimationClip.ts +0 -16
  41. package/src/threejs-compatibility/AnimationDiagnostics.ts +0 -42
  42. package/src/threejs-compatibility/AnimationMixer.ts +0 -24
  43. package/src/threejs-compatibility/MorphTargetMixer.ts +0 -16
  44. package/src/threejs-compatibility/Skeleton.ts +0 -9
  45. package/src/threejs-compatibility/SkinnedMesh.ts +0 -12
  46. package/src/threejs-compatibility/index.ts +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aura3d/animation",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,6 +12,39 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
- "@aura3d/math": "1.4.0"
16
- }
15
+ "@aura3d/math": "1.4.1"
16
+ },
17
+ "description": "Deterministic animation clips, mixers, root motion, skeleton palettes, blend trees, state machines, and scene/ECS animation bridges for Aura3D.",
18
+ "keywords": [
19
+ "aura3d",
20
+ "3d",
21
+ "browser-3d",
22
+ "web-3d",
23
+ "typescript",
24
+ "animation",
25
+ "animation-engine",
26
+ "skeletal-animation",
27
+ "blend-trees",
28
+ "state-machine",
29
+ "root-motion",
30
+ "skinning",
31
+ "game-animation"
32
+ ],
33
+ "homepage": "https://aura3d.auraone.ai",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/auraoneai/aura3d.git",
37
+ "directory": "packages/animation"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/auraoneai/aura3d/issues"
41
+ },
42
+ "license": "MIT",
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "files": [
47
+ "README.md",
48
+ "dist"
49
+ ]
17
50
  }
@@ -1,166 +0,0 @@
1
- import type { AnimationClip } from "./AnimationClip.js";
2
- import { eventsBetween, type AnimationEvent } from "./AnimationEvents.js";
3
-
4
- export type LoopMode = "once" | "repeat" | "pingpong";
5
-
6
- export type AnimationActionSnapshot = {
7
- readonly clipName: string;
8
- readonly duration: number;
9
- readonly time: number;
10
- readonly weight: number;
11
- readonly timeScale: number;
12
- readonly playing: boolean;
13
- readonly paused: boolean;
14
- readonly loopMode: LoopMode;
15
- };
16
-
17
- export class AnimationAction {
18
- readonly clip: AnimationClip;
19
- time = 0;
20
- weight = 1;
21
- timeScale = 1;
22
- loopMode: LoopMode = "repeat";
23
- playing = false;
24
- paused = false;
25
- private pingPongForward = true;
26
- private fadeDuration = 0;
27
- private fadeElapsed = 0;
28
- private fadeStartWeight = 1;
29
- private fadeTargetWeight = 1;
30
-
31
- constructor(clip: AnimationClip) {
32
- this.clip = clip;
33
- }
34
-
35
- play(): this {
36
- this.playing = true;
37
- this.paused = false;
38
- return this;
39
- }
40
-
41
- pause(): this {
42
- this.paused = true;
43
- return this;
44
- }
45
-
46
- stop(): this {
47
- this.playing = false;
48
- this.paused = false;
49
- this.time = 0;
50
- return this;
51
- }
52
-
53
- setWeight(weight: number): this {
54
- if (!Number.isFinite(weight) || weight < 0) {
55
- throw new Error("AnimationAction weight must be finite and non-negative.");
56
- }
57
- this.weight = weight;
58
- return this;
59
- }
60
-
61
- setTimeScale(timeScale: number): this {
62
- if (!Number.isFinite(timeScale) || timeScale < 0) {
63
- throw new Error("AnimationAction timeScale must be finite and non-negative.");
64
- }
65
- this.timeScale = timeScale;
66
- return this;
67
- }
68
-
69
- setLoop(loopMode: LoopMode): this {
70
- this.loopMode = loopMode;
71
- return this;
72
- }
73
-
74
- reset(): this {
75
- this.time = 0;
76
- this.pingPongForward = true;
77
- return this;
78
- }
79
-
80
- seek(time: number): this {
81
- if (!Number.isFinite(time) || time < 0) {
82
- throw new Error("AnimationAction seek time must be finite and non-negative.");
83
- }
84
- this.time = this.clip.duration > 0 ? Math.min(time, this.clip.duration) : 0;
85
- return this;
86
- }
87
-
88
- fadeTo(weight: number, duration: number): this {
89
- if (!Number.isFinite(duration) || duration < 0 || !Number.isFinite(weight) || weight < 0) {
90
- throw new Error("AnimationAction fade target and duration must be valid.");
91
- }
92
- this.fadeStartWeight = this.weight;
93
- this.fadeTargetWeight = weight;
94
- this.fadeDuration = duration;
95
- this.fadeElapsed = 0;
96
- if (duration === 0) {
97
- this.weight = weight;
98
- }
99
- return this;
100
- }
101
-
102
- update(delta: number): readonly AnimationEvent[] {
103
- if (!Number.isFinite(delta) || delta < 0) {
104
- throw new Error("AnimationAction delta must be finite and non-negative.");
105
- }
106
- if (this.fadeDuration > 0) {
107
- this.fadeElapsed = Math.min(this.fadeDuration, this.fadeElapsed + delta);
108
- const t = this.fadeElapsed / this.fadeDuration;
109
- this.weight = this.fadeStartWeight + (this.fadeTargetWeight - this.fadeStartWeight) * t;
110
- if (this.fadeElapsed === this.fadeDuration) {
111
- this.fadeDuration = 0;
112
- }
113
- }
114
- if (!this.playing || this.paused || this.clip.duration === 0) {
115
- return [];
116
- }
117
- const previous = this.time;
118
- const scaledDelta = delta * this.timeScale;
119
- let next = previous + scaledDelta;
120
- let looped = false;
121
- if (this.loopMode === "repeat") {
122
- while (next > this.clip.duration) {
123
- next -= this.clip.duration;
124
- looped = true;
125
- }
126
- } else if (this.loopMode === "once") {
127
- next = Math.min(next, this.clip.duration);
128
- if (next === this.clip.duration) {
129
- this.playing = false;
130
- }
131
- } else {
132
- if (this.pingPongForward) {
133
- while (next > this.clip.duration) {
134
- next = this.clip.duration - (next - this.clip.duration);
135
- this.pingPongForward = false;
136
- looped = true;
137
- }
138
- } else {
139
- next = previous - scaledDelta;
140
- while (next < 0) {
141
- next = -next;
142
- this.pingPongForward = true;
143
- looped = true;
144
- }
145
- }
146
- }
147
- this.time = next;
148
- if (this.clip.events.length === 0) {
149
- return [];
150
- }
151
- return eventsBetween(this.clip.events, this.clip.name, previous, next, this.clip.duration, looped);
152
- }
153
-
154
- snapshot(): AnimationActionSnapshot {
155
- return {
156
- clipName: this.clip.name,
157
- duration: this.clip.duration,
158
- time: this.time,
159
- weight: this.weight,
160
- timeScale: this.timeScale,
161
- playing: this.playing,
162
- paused: this.paused,
163
- loopMode: this.loopMode
164
- };
165
- }
166
- }
@@ -1,63 +0,0 @@
1
- import type { AnimationEventMarker } from "./AnimationEvents.js";
2
- import { AnimationTrack, type SerializedAnimationTrack } from "./AnimationTrack.js";
3
-
4
- export type AnimationClipDescriptor = {
5
- readonly name: string;
6
- readonly duration?: number;
7
- readonly tracks: readonly AnimationTrack[];
8
- readonly events?: readonly AnimationEventMarker[];
9
- };
10
-
11
- export type SerializedAnimationClip = {
12
- readonly name: string;
13
- readonly duration: number;
14
- readonly tracks: readonly SerializedAnimationTrack[];
15
- readonly events: readonly AnimationEventMarker[];
16
- };
17
-
18
- export class AnimationClip {
19
- readonly name: string;
20
- readonly tracks: readonly AnimationTrack[];
21
- readonly events: readonly AnimationEventMarker[];
22
- readonly duration: number;
23
-
24
- constructor(descriptor: AnimationClipDescriptor) {
25
- if (descriptor.name.trim().length === 0) {
26
- throw new Error("AnimationClip name cannot be empty.");
27
- }
28
- this.name = descriptor.name;
29
- this.tracks = [...descriptor.tracks];
30
- this.events = [...(descriptor.events ?? [])].sort((a, b) => a.time - b.time || a.name.localeCompare(b.name));
31
- const trackDuration = this.tracks.reduce((duration, track) => Math.max(duration, track.duration), 0);
32
- this.duration = descriptor.duration ?? trackDuration;
33
- if (!Number.isFinite(this.duration) || this.duration < 0) {
34
- throw new Error("AnimationClip duration must be finite and non-negative.");
35
- }
36
- if (this.duration < trackDuration) {
37
- throw new Error("AnimationClip duration cannot be shorter than its tracks.");
38
- }
39
- for (const event of this.events) {
40
- if (!Number.isFinite(event.time) || event.time < 0 || event.time > this.duration) {
41
- throw new Error(`Animation event ${event.name} is outside clip duration.`);
42
- }
43
- }
44
- }
45
-
46
- toJSON(): SerializedAnimationClip {
47
- return {
48
- name: this.name,
49
- duration: this.duration,
50
- tracks: this.tracks.map((track) => track.toJSON()),
51
- events: this.events.map((event) => ({ ...event }))
52
- };
53
- }
54
-
55
- static fromJSON(serialized: SerializedAnimationClip): AnimationClip {
56
- return new AnimationClip({
57
- name: serialized.name,
58
- duration: serialized.duration,
59
- tracks: serialized.tracks.map((track) => AnimationTrack.fromJSON(track)),
60
- events: serialized.events
61
- });
62
- }
63
- }