@forgeax/engine-animation 0.1.2
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/LICENSE +202 -0
- package/README.md +141 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/__tests__/animation-diagnostic.unit.test.d.ts +2 -0
- package/dist/__tests__/animation-diagnostic.unit.test.d.ts.map +1 -0
- package/dist/__tests__/animation-recovery.integration.test.d.ts +2 -0
- package/dist/__tests__/animation-recovery.integration.test.d.ts.map +1 -0
- package/dist/__tests__/animation-target-id.browser.test.d.ts +2 -0
- package/dist/__tests__/animation-target-id.browser.test.d.ts.map +1 -0
- package/dist/__tests__/animation-target-id.unit.test.d.ts +2 -0
- package/dist/__tests__/animation-target-id.unit.test.d.ts.map +1 -0
- package/dist/__tests__/animation-target-isolation.integration.test.d.ts +2 -0
- package/dist/__tests__/animation-target-isolation.integration.test.d.ts.map +1 -0
- package/dist/__tests__/animation-target-relationship.unit.test.d.ts +2 -0
- package/dist/__tests__/animation-target-relationship.unit.test.d.ts.map +1 -0
- package/dist/__tests__/animation-target-source-boundary.unit.test.d.ts +2 -0
- package/dist/__tests__/animation-target-source-boundary.unit.test.d.ts.map +1 -0
- package/dist/__tests__/bind-animation-targets.unit.test.d.ts +2 -0
- package/dist/__tests__/bind-animation-targets.unit.test.d.ts.map +1 -0
- package/dist/__tests__/documentation-contract.unit.test.d.ts +2 -0
- package/dist/__tests__/documentation-contract.unit.test.d.ts.map +1 -0
- package/dist/__tests__/ecs-consumer.integration.test.d.ts +2 -0
- package/dist/__tests__/ecs-consumer.integration.test.d.ts.map +1 -0
- package/dist/__tests__/errors.unit.test.d.ts +2 -0
- package/dist/__tests__/errors.unit.test.d.ts.map +1 -0
- package/dist/__tests__/graph-player.integration.test.d.ts +2 -0
- package/dist/__tests__/graph-player.integration.test.d.ts.map +1 -0
- package/dist/__tests__/graph-player.unit.test.d.ts +2 -0
- package/dist/__tests__/graph-player.unit.test.d.ts.map +1 -0
- package/dist/__tests__/handle-errors.unit.test.d.ts +2 -0
- package/dist/__tests__/handle-errors.unit.test.d.ts.map +1 -0
- package/dist/__tests__/loader-boundary.unit.test.d.ts +2 -0
- package/dist/__tests__/loader-boundary.unit.test.d.ts.map +1 -0
- package/dist/__tests__/morph-weights-playback.integration.test.d.ts +2 -0
- package/dist/__tests__/morph-weights-playback.integration.test.d.ts.map +1 -0
- package/dist/__tests__/morph-weights.unit.test.d.ts +2 -0
- package/dist/__tests__/morph-weights.unit.test.d.ts.map +1 -0
- package/dist/__tests__/public-animation-target-api.test-d.d.ts +2 -0
- package/dist/__tests__/public-animation-target-api.test-d.d.ts.map +1 -0
- package/dist/__tests__/resolver-ownership.integration.test.d.ts +2 -0
- package/dist/__tests__/resolver-ownership.integration.test.d.ts.map +1 -0
- package/dist/__tests__/root-surface.unit.test.d.ts +2 -0
- package/dist/__tests__/root-surface.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scene-instance-target-collection.integration.test.d.ts +2 -0
- package/dist/__tests__/scene-instance-target-collection.integration.test.d.ts.map +1 -0
- package/dist/__tests__/scriptable-pack-consumer.test-d.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-consumer.test-d.d.ts.map +1 -0
- package/dist/__tests__/time-delta-regression.integration.test.d.ts +2 -0
- package/dist/__tests__/time-delta-regression.integration.test.d.ts.map +1 -0
- package/dist/__tests__/transform-target-playback.integration.test.d.ts +2 -0
- package/dist/__tests__/transform-target-playback.integration.test.d.ts.map +1 -0
- package/dist/animation-diagnostic.d.ts +27 -0
- package/dist/animation-diagnostic.d.ts.map +1 -0
- package/dist/animation-player.d.ts +13 -0
- package/dist/animation-player.d.ts.map +1 -0
- package/dist/animation-target.d.ts +21 -0
- package/dist/animation-target.d.ts.map +1 -0
- package/dist/assets/animation-decoder.d.ts +4 -0
- package/dist/assets/animation-decoder.d.ts.map +1 -0
- package/dist/chunk-DMXAQUPI.mjs +52 -0
- package/dist/chunk-DMXAQUPI.mjs.map +1 -0
- package/dist/errors.d.ts +120 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/graph/define-animation-graph.d.ts +42 -0
- package/dist/graph/define-animation-graph.d.ts.map +1 -0
- package/dist/graph/describe-animation-graph.d.ts +37 -0
- package/dist/graph/describe-animation-graph.d.ts.map +1 -0
- package/dist/graph/serialize-animation-graph.d.ts +27 -0
- package/dist/graph/serialize-animation-graph.d.ts.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1457 -0
- package/dist/index.mjs.map +1 -0
- package/dist/player-errors.d.ts +43 -0
- package/dist/player-errors.d.ts.map +1 -0
- package/dist/plugin.d.ts +13 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/resolve-animation-asset.d.ts +42 -0
- package/dist/resolve-animation-asset.d.ts.map +1 -0
- package/dist/systems/advance-animation-player.d.ts +40 -0
- package/dist/systems/advance-animation-player.d.ts.map +1 -0
- package/dist/systems/evaluate-animation-graph.d.ts +32 -0
- package/dist/systems/evaluate-animation-graph.d.ts.map +1 -0
- package/dist/target-id.d.ts +4 -0
- package/dist/target-id.d.ts.map +1 -0
- package/dist/target-id.mjs +9 -0
- package/dist/target-id.mjs.map +1 -0
- package/package.json +65 -0
- package/src/__tests__/animation-diagnostic.unit.test.ts +237 -0
- package/src/__tests__/animation-recovery.integration.test.ts +125 -0
- package/src/__tests__/animation-target-id.browser.test.ts +22 -0
- package/src/__tests__/animation-target-id.unit.test.ts +41 -0
- package/src/__tests__/animation-target-isolation.integration.test.ts +179 -0
- package/src/__tests__/animation-target-relationship.unit.test.ts +65 -0
- package/src/__tests__/animation-target-source-boundary.unit.test.ts +49 -0
- package/src/__tests__/bind-animation-targets.unit.test.ts +167 -0
- package/src/__tests__/documentation-contract.unit.test.ts +94 -0
- package/src/__tests__/ecs-consumer.integration.test.ts +10 -0
- package/src/__tests__/errors.unit.test.ts +19 -0
- package/src/__tests__/graph-player.integration.test.ts +22 -0
- package/src/__tests__/graph-player.unit.test.ts +12 -0
- package/src/__tests__/handle-errors.unit.test.ts +17 -0
- package/src/__tests__/loader-boundary.unit.test.ts +66 -0
- package/src/__tests__/morph-weights-playback.integration.test.ts +84 -0
- package/src/__tests__/morph-weights.unit.test.ts +26 -0
- package/src/__tests__/public-animation-target-api.test-d.ts +47 -0
- package/src/__tests__/resolver-ownership.integration.test.ts +99 -0
- package/src/__tests__/root-surface.unit.test.ts +10 -0
- package/src/__tests__/scene-instance-target-collection.integration.test.ts +26 -0
- package/src/__tests__/scriptable-pack-consumer.test-d.ts +8 -0
- package/src/__tests__/time-delta-regression.integration.test.ts +79 -0
- package/src/__tests__/transform-target-playback.integration.test.ts +198 -0
- package/src/animation-diagnostic.ts +88 -0
- package/src/animation-player.ts +84 -0
- package/src/animation-target.ts +257 -0
- package/src/assets/animation-decoder.ts +107 -0
- package/src/errors.ts +201 -0
- package/src/graph/define-animation-graph.ts +193 -0
- package/src/graph/describe-animation-graph.ts +74 -0
- package/src/graph/serialize-animation-graph.ts +90 -0
- package/src/index.ts +57 -0
- package/src/player-errors.ts +72 -0
- package/src/plugin.ts +73 -0
- package/src/resolve-animation-asset.ts +128 -0
- package/src/systems/advance-animation-player.ts +971 -0
- package/src/systems/evaluate-animation-graph.ts +261 -0
- package/src/target-id.ts +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"morph-weights-playback.integration.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/morph-weights-playback.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"morph-weights.unit.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/morph-weights.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-animation-target-api.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/public-animation-target-api.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver-ownership.integration.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/resolver-ownership.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-surface.unit.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/root-surface.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene-instance-target-collection.integration.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/scene-instance-target-collection.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptable-pack-consumer.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/scriptable-pack-consumer.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-delta-regression.integration.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/time-delta-regression.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-target-playback.integration.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/transform-target-playback.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { World } from '@forgeax/engine-ecs';
|
|
2
|
+
export type AnimationDiagnosticCode = 'animation-target-missing' | 'animation-target-transform-missing' | 'animation-target-id-duplicate' | 'animation-target-owner-stale' | 'animation-channel-missing' | 'animation-target-morph-weights-missing' | 'animation-morph-weight-count-mismatch';
|
|
3
|
+
export interface AnimationDiagnosticDetail {
|
|
4
|
+
readonly player: number;
|
|
5
|
+
readonly clip: number;
|
|
6
|
+
readonly channel: number;
|
|
7
|
+
readonly targetId: string;
|
|
8
|
+
readonly reason: 'target-missing' | 'transform-missing' | 'target-id-duplicate' | 'target-stale' | 'channel-missing' | 'morph-weights-missing' | 'morph-weight-count-mismatch';
|
|
9
|
+
readonly target?: number;
|
|
10
|
+
readonly property?: 'translation' | 'rotation' | 'scale' | 'weights';
|
|
11
|
+
readonly expectedWeightCount?: number;
|
|
12
|
+
readonly actualWeightCount?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface AnimationDiagnostic {
|
|
15
|
+
readonly code: AnimationDiagnosticCode;
|
|
16
|
+
readonly hint: string;
|
|
17
|
+
readonly detail: Readonly<AnimationDiagnosticDetail>;
|
|
18
|
+
}
|
|
19
|
+
export type AnimationDiagnosticListener = (world: World, diagnostic: Readonly<AnimationDiagnostic>) => void;
|
|
20
|
+
/** Observe unique channel-level diagnostic facts for editor/runtime projection. */
|
|
21
|
+
export declare function subscribeAnimationDiagnostics(listener: AnimationDiagnosticListener): () => void;
|
|
22
|
+
/** @internal */
|
|
23
|
+
export declare function isAnimationDevMode(): boolean;
|
|
24
|
+
export declare function emitAnimationDiagnostic(world: World, diagnostic: AnimationDiagnostic): void;
|
|
25
|
+
/** @internal */
|
|
26
|
+
export declare function _resetAnimationWarnsForTests(world: World): void;
|
|
27
|
+
//# sourceMappingURL=animation-diagnostic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-diagnostic.d.ts","sourceRoot":"","sources":["../src/animation-diagnostic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,MAAM,uBAAuB,GAC/B,0BAA0B,GAC1B,oCAAoC,GACpC,+BAA+B,GAC/B,8BAA8B,GAC9B,2BAA2B,GAC3B,wCAAwC,GACxC,uCAAuC,CAAC;AAE5C,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EACX,gBAAgB,GAChB,mBAAmB,GACnB,qBAAqB,GACrB,cAAc,GACd,iBAAiB,GACjB,uBAAuB,GACvB,6BAA6B,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IACrE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC;CACtD;AAED,MAAM,MAAM,2BAA2B,GAAG,CACxC,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,QAAQ,CAAC,mBAAmB,CAAC,KACtC,IAAI,CAAC;AAKV,mFAAmF;AACnF,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,2BAA2B,GAAG,MAAM,IAAI,CAG/F;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,mBAAmB,GAAG,IAAI,CAyB3F;AAED,gBAAgB;AAChB,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAE/D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const AnimationPlayer: import("@forgeax/engine-ecs").Component<"AnimationPlayer", {
|
|
2
|
+
readonly clips: "array<shared<AnimationClip>>";
|
|
3
|
+
readonly times: "array<f32>";
|
|
4
|
+
readonly weights: "array<f32>";
|
|
5
|
+
readonly speeds: "array<f32>";
|
|
6
|
+
readonly graph: "shared<AnimationGraph>";
|
|
7
|
+
readonly nodeWeights: "array<f32>";
|
|
8
|
+
readonly nodeTimes: "array<f32>";
|
|
9
|
+
readonly nodeSpeeds: "array<f32>";
|
|
10
|
+
readonly paused: "bool";
|
|
11
|
+
readonly looping: "bool";
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=animation-player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-player.d.ts","sourceRoot":"","sources":["../src/animation-player.ts"],"names":[],"mappings":"AAoEA,eAAO,MAAM,eAAe;;;;;;;;;;;EAe1B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type EntityHandle, type World } from '@forgeax/engine-ecs';
|
|
2
|
+
import { type Result } from '@forgeax/engine-types';
|
|
3
|
+
export declare const AnimationTargetId: import("@forgeax/engine-ecs").Component<"AnimationTargetId", {
|
|
4
|
+
readonly value: "string";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const AnimationTargets: import("@forgeax/engine-ecs").RelationshipTargetComponent<import("@forgeax/engine-ecs").Component<"AnimationTargets", {
|
|
7
|
+
targets: "array<entity>";
|
|
8
|
+
}>>, AnimatedBy: import("@forgeax/engine-ecs").Component<"AnimatedBy", {
|
|
9
|
+
player: "entity";
|
|
10
|
+
}>;
|
|
11
|
+
export type BindAnimationTargetsErrorCode = 'animation-target-player-invalid' | 'animation-target-invalid' | 'animation-target-outside-player-root' | 'animation-target-name-missing' | 'animation-target-id-invalid' | 'animation-target-id-duplicate' | 'animation-target-player-conflict' | 'animation-target-capacity-reserve-failed' | 'animation-target-bind-failed';
|
|
12
|
+
export declare class BindAnimationTargetsError extends Error {
|
|
13
|
+
readonly code: BindAnimationTargetsErrorCode;
|
|
14
|
+
readonly expected: string;
|
|
15
|
+
readonly hint: string;
|
|
16
|
+
readonly detail: Readonly<Record<string, unknown>>;
|
|
17
|
+
readonly name = "BindAnimationTargetsError";
|
|
18
|
+
constructor(code: BindAnimationTargetsErrorCode, expected: string, hint: string, detail: Readonly<Record<string, unknown>>);
|
|
19
|
+
}
|
|
20
|
+
export declare function bindAnimationTargets(world: World, player: EntityHandle, targets: readonly EntityHandle[]): Result<void, BindAnimationTargetsError>;
|
|
21
|
+
//# sourceMappingURL=animation-target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-target.d.ts","sourceRoot":"","sources":["../src/animation-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,KAAK,EACX,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAwC,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI1F,eAAO,MAAM,iBAAiB;;EAE5B,CAAC;AAEH,eAAO,MAAgB,gBAAgB;;KAAU,UAAU;;EAQzD,CAAC;AAEH,MAAM,MAAM,6BAA6B,GACrC,iCAAiC,GACjC,0BAA0B,GAC1B,sCAAsC,GACtC,+BAA+B,GAC/B,6BAA6B,GAC7B,+BAA+B,GAC/B,kCAAkC,GAClC,0CAA0C,GAC1C,8BAA8B,CAAC;AAEnC,qBAAa,yBAA0B,SAAQ,KAAK;IAIhD,QAAQ,CAAC,IAAI,EAAE,6BAA6B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IANpD,SAAkB,IAAI,+BAA+B;gBAG1C,IAAI,EAAE,6BAA6B,EACnC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAIrD;AAsHD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,MAAM,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAsFzC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type AnimationClip, type AnimationGraph, type AssetDecoderContribution } from '@forgeax/engine-types';
|
|
2
|
+
export declare const animationClipContribution: AssetDecoderContribution<AnimationClip, 'animation-clip'>;
|
|
3
|
+
export declare const animationGraphContribution: AssetDecoderContribution<AnimationGraph, 'animation-graph'>;
|
|
4
|
+
//# sourceMappingURL=animation-decoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-decoder.d.ts","sourceRoot":"","sources":["../../src/assets/animation-decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EAEnB,KAAK,wBAAwB,EAI9B,MAAM,uBAAuB,CAAC;AAiD/B,eAAO,MAAM,yBAAyB,EAAE,wBAAwB,CAAC,aAAa,EAAE,gBAAgB,CAc7F,CAAC;AAEJ,eAAO,MAAM,0BAA0B,EAAE,wBAAwB,CAC/D,cAAc,EACd,iBAAiB,CA+BlB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/target-id.ts
|
|
2
|
+
import { blake3 } from "@noble/hashes/blake3.js";
|
|
3
|
+
var NAMESPACE = Uint8Array.of(
|
|
4
|
+
49,
|
|
5
|
+
121,
|
|
6
|
+
245,
|
|
7
|
+
25,
|
|
8
|
+
217,
|
|
9
|
+
39,
|
|
10
|
+
79,
|
|
11
|
+
242,
|
|
12
|
+
181,
|
|
13
|
+
150,
|
|
14
|
+
111,
|
|
15
|
+
208,
|
|
16
|
+
119,
|
|
17
|
+
2,
|
|
18
|
+
57,
|
|
19
|
+
17
|
|
20
|
+
);
|
|
21
|
+
var TARGET_ID_PATTERN = /^[0-9a-f]{32}$/;
|
|
22
|
+
var textEncoder = new TextEncoder();
|
|
23
|
+
function deriveAnimationTargetId(path) {
|
|
24
|
+
const segments = path.map((segment) => textEncoder.encode(segment));
|
|
25
|
+
const input = new Uint8Array(
|
|
26
|
+
NAMESPACE.length + segments.reduce((length, segment) => length + 4 + segment.length, 0)
|
|
27
|
+
);
|
|
28
|
+
input.set(NAMESPACE);
|
|
29
|
+
const view = new DataView(input.buffer);
|
|
30
|
+
let offset = NAMESPACE.length;
|
|
31
|
+
for (const segment of segments) {
|
|
32
|
+
view.setUint32(offset, segment.length, true);
|
|
33
|
+
offset += 4;
|
|
34
|
+
input.set(segment, offset);
|
|
35
|
+
offset += segment.length;
|
|
36
|
+
}
|
|
37
|
+
const bytes = blake3(input).slice(0, 16);
|
|
38
|
+
bytes[6] = (bytes[6] ?? 0) & 15 | 128;
|
|
39
|
+
bytes[8] = (bytes[8] ?? 0) & 63 | 128;
|
|
40
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join(
|
|
41
|
+
""
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
function isAnimationTargetId(value) {
|
|
45
|
+
return typeof value === "string" && TARGET_ID_PATTERN.test(value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
deriveAnimationTargetId,
|
|
50
|
+
isAnimationTargetId
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chunk-DMXAQUPI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/target-id.ts"],"sourcesContent":["import type { AnimationTargetIdValue } from '@forgeax/engine-types';\nimport { blake3 } from '@noble/hashes/blake3.js';\n\nconst NAMESPACE = Uint8Array.of(\n 0x31,\n 0x79,\n 0xf5,\n 0x19,\n 0xd9,\n 0x27,\n 0x4f,\n 0xf2,\n 0xb5,\n 0x96,\n 0x6f,\n 0xd0,\n 0x77,\n 0x02,\n 0x39,\n 0x11,\n);\nconst TARGET_ID_PATTERN = /^[0-9a-f]{32}$/;\nconst textEncoder = new TextEncoder();\n\nexport function deriveAnimationTargetId(path: readonly string[]): AnimationTargetIdValue {\n const segments = path.map((segment) => textEncoder.encode(segment));\n const input = new Uint8Array(\n NAMESPACE.length + segments.reduce((length, segment) => length + 4 + segment.length, 0),\n );\n input.set(NAMESPACE);\n\n const view = new DataView(input.buffer);\n let offset = NAMESPACE.length;\n for (const segment of segments) {\n view.setUint32(offset, segment.length, true);\n offset += 4;\n input.set(segment, offset);\n offset += segment.length;\n }\n\n const bytes = blake3(input).slice(0, 16);\n bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x80;\n bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join(\n '',\n ) as AnimationTargetIdValue;\n}\n\nexport function isAnimationTargetId(value: unknown): value is AnimationTargetIdValue {\n return typeof value === 'string' && TARGET_ID_PATTERN.test(value);\n}\n"],"mappings":";AACA,SAAS,cAAc;AAEvB,IAAM,YAAY,WAAW;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAM,oBAAoB;AAC1B,IAAM,cAAc,IAAI,YAAY;AAE7B,SAAS,wBAAwB,MAAiD;AACvF,QAAM,WAAW,KAAK,IAAI,CAAC,YAAY,YAAY,OAAO,OAAO,CAAC;AAClE,QAAM,QAAQ,IAAI;AAAA,IAChB,UAAU,SAAS,SAAS,OAAO,CAAC,QAAQ,YAAY,SAAS,IAAI,QAAQ,QAAQ,CAAC;AAAA,EACxF;AACA,QAAM,IAAI,SAAS;AAEnB,QAAM,OAAO,IAAI,SAAS,MAAM,MAAM;AACtC,MAAI,SAAS,UAAU;AACvB,aAAW,WAAW,UAAU;AAC9B,SAAK,UAAU,QAAQ,QAAQ,QAAQ,IAAI;AAC3C,cAAU;AACV,UAAM,IAAI,SAAS,MAAM;AACzB,cAAU,QAAQ;AAAA,EACpB;AAEA,QAAM,QAAQ,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AACvC,QAAM,CAAC,KAAM,MAAM,CAAC,KAAK,KAAK,KAAQ;AACtC,QAAM,CAAC,KAAM,MAAM,CAAC,KAAK,KAAK,KAAQ;AACtC,SAAO,MAAM,KAAK,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE;AAAA,IACrE;AAAA,EACF;AACF;AAEO,SAAS,oBAAoB,OAAiD;AACnF,SAAO,OAAO,UAAU,YAAY,kBAAkB,KAAK,KAAK;AAClE;","names":[]}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error for an empty graph (zero nodes).
|
|
3
|
+
*
|
|
4
|
+
* - `.code = 'animation-graph-empty'`
|
|
5
|
+
* - `.expected` -- a graph declares at least one node
|
|
6
|
+
* - `.hint` -- add at least one clip/blend/add node before returning the root
|
|
7
|
+
*/
|
|
8
|
+
export declare class AnimationGraphEmptyError extends Error {
|
|
9
|
+
readonly code: "animation-graph-empty";
|
|
10
|
+
readonly expected: string;
|
|
11
|
+
readonly hint: string;
|
|
12
|
+
constructor();
|
|
13
|
+
}
|
|
14
|
+
/** Detail for `'animation-graph-node-out-of-range'`. */
|
|
15
|
+
export interface AnimationGraphNodeOutOfRangeDetail {
|
|
16
|
+
/** Index of the node holding the offending reference, or the graph root. */
|
|
17
|
+
readonly node: number;
|
|
18
|
+
/** The out-of-range reference value that was encountered. */
|
|
19
|
+
readonly ref: number;
|
|
20
|
+
/** Total node count -- valid refs live in `[0, nodeCount)`. */
|
|
21
|
+
readonly nodeCount: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Structured error for a node reference that points outside `[0, nodeCount)`.
|
|
25
|
+
*
|
|
26
|
+
* - `.code = 'animation-graph-node-out-of-range'`
|
|
27
|
+
* - `.expected` -- every child/base/additive/root ref is in `[0, nodeCount)`
|
|
28
|
+
* - `.hint` -- reference only node refs returned by the builder in this graph
|
|
29
|
+
* - `.detail = { node, ref, nodeCount }`
|
|
30
|
+
*/
|
|
31
|
+
export declare class AnimationGraphNodeOutOfRangeError extends Error {
|
|
32
|
+
readonly code: "animation-graph-node-out-of-range";
|
|
33
|
+
readonly expected: string;
|
|
34
|
+
readonly hint: string;
|
|
35
|
+
readonly detail: AnimationGraphNodeOutOfRangeDetail;
|
|
36
|
+
constructor(detail: AnimationGraphNodeOutOfRangeDetail);
|
|
37
|
+
}
|
|
38
|
+
/** Detail for `'animation-graph-node-weight-invalid'`. */
|
|
39
|
+
export interface AnimationGraphNodeWeightInvalidDetail {
|
|
40
|
+
/** Index of the node whose static weight is invalid. */
|
|
41
|
+
readonly node: number;
|
|
42
|
+
/** The offending weight value (negative or non-finite / NaN). */
|
|
43
|
+
readonly weight: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Structured error for a negative or non-finite (NaN / Infinity) static weight.
|
|
47
|
+
*
|
|
48
|
+
* - `.code = 'animation-graph-node-weight-invalid'`
|
|
49
|
+
* - `.expected` -- every node static weight is a finite value `>= 0`
|
|
50
|
+
* - `.hint` -- pass a finite non-negative weight (Add layers may exceed 1)
|
|
51
|
+
* - `.detail = { node, weight }`
|
|
52
|
+
*/
|
|
53
|
+
export declare class AnimationGraphNodeWeightInvalidError extends Error {
|
|
54
|
+
readonly code: "animation-graph-node-weight-invalid";
|
|
55
|
+
readonly expected: string;
|
|
56
|
+
readonly hint: string;
|
|
57
|
+
readonly detail: AnimationGraphNodeWeightInvalidDetail;
|
|
58
|
+
constructor(detail: AnimationGraphNodeWeightInvalidDetail);
|
|
59
|
+
}
|
|
60
|
+
/** Detail for `'animation-graph-cycle'`. */
|
|
61
|
+
export interface AnimationGraphCycleDetail {
|
|
62
|
+
/** A node index that participates in the detected cycle (the back edge). */
|
|
63
|
+
readonly node: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Structured error for a cycle in the (must-be-acyclic) graph.
|
|
67
|
+
*
|
|
68
|
+
* - `.code = 'animation-graph-cycle'`
|
|
69
|
+
* - `.expected` -- the graph is a DAG (no node reaches itself)
|
|
70
|
+
* - `.hint` -- remove the self/back reference so the graph is acyclic
|
|
71
|
+
* - `.detail = { node }`
|
|
72
|
+
*/
|
|
73
|
+
export declare class AnimationGraphCycleError extends Error {
|
|
74
|
+
readonly code: "animation-graph-cycle";
|
|
75
|
+
readonly expected: string;
|
|
76
|
+
readonly hint: string;
|
|
77
|
+
readonly detail: AnimationGraphCycleDetail;
|
|
78
|
+
constructor(detail: AnimationGraphCycleDetail);
|
|
79
|
+
}
|
|
80
|
+
/** Detail for `'animation-graph-clip-missing'`. */
|
|
81
|
+
export interface AnimationGraphClipMissingDetail {
|
|
82
|
+
/** Index of the clip node whose `shared<AnimationClip>` handle failed to resolve. */
|
|
83
|
+
readonly node: number;
|
|
84
|
+
/** The raw clip handle that did not resolve (never registered / rc released). */
|
|
85
|
+
readonly clip: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Structured error for a graph clip leaf whose `shared<AnimationClip>` handle
|
|
89
|
+
* cannot be resolved at evaluation time (never registered, or its refcount was
|
|
90
|
+
* released). Raised by `evaluateAnimationGraph` (M3 / w25) BEFORE any derived
|
|
91
|
+
* slot is written, so a dangling clip never leaves a dirty pose (requirements
|
|
92
|
+
* AC-11 clip-missing branch, plan §8). Unlike the construction-time
|
|
93
|
+
* {@link AnimationGraphError} shapes, this is an EVALUATION-time error: it is not
|
|
94
|
+
* part of `defineAnimationGraph`'s `Result` (topology is validated at build, clip
|
|
95
|
+
* liveness only at eval), so it stays out of the construction closed union.
|
|
96
|
+
*
|
|
97
|
+
* - `.code = 'animation-graph-clip-missing'`
|
|
98
|
+
* - `.expected` -- every clip node's handle resolves to a live AnimationClip
|
|
99
|
+
* - `.hint` -- keep the clip asset registered (rc retained) while the graph
|
|
100
|
+
* references it
|
|
101
|
+
* - `.detail = { node, clip }`
|
|
102
|
+
*/
|
|
103
|
+
export declare class AnimationGraphClipMissingError extends Error {
|
|
104
|
+
readonly code: "animation-graph-clip-missing";
|
|
105
|
+
readonly expected: string;
|
|
106
|
+
readonly hint: string;
|
|
107
|
+
readonly detail: AnimationGraphClipMissingDetail;
|
|
108
|
+
constructor(detail: AnimationGraphClipMissingDetail);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Closed union of AnimationGraph-cluster error codes. AI users perform
|
|
112
|
+
* exhaustive `switch (err.code)` without default; TS guards completeness.
|
|
113
|
+
*/
|
|
114
|
+
export type AnimationGraphErrorCode = 'animation-graph-empty' | 'animation-graph-node-out-of-range' | 'animation-graph-node-weight-invalid' | 'animation-graph-cycle';
|
|
115
|
+
/**
|
|
116
|
+
* Closed union of the AnimationGraph-cluster structured error classes, each
|
|
117
|
+
* carrying an `AnimationGraphErrorCode` discriminant on `.code`.
|
|
118
|
+
*/
|
|
119
|
+
export type AnimationGraphError = AnimationGraphEmptyError | AnimationGraphNodeOutOfRangeError | AnimationGraphNodeWeightInvalidError | AnimationGraphCycleError;
|
|
120
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,EAAG,uBAAuB,CAAU;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;;CASvB;AAID,wDAAwD;AACxD,MAAM,WAAW,kCAAkC;IACjD,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,qBAAa,iCAAkC,SAAQ,KAAK;IAC1D,QAAQ,CAAC,IAAI,EAAG,mCAAmC,CAAU;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,kCAAkC,CAAC;gBAExC,MAAM,EAAE,kCAAkC;CAUvD;AAID,0DAA0D;AAC1D,MAAM,WAAW,qCAAqC;IACpD,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,qBAAa,oCAAqC,SAAQ,KAAK;IAC7D,QAAQ,CAAC,IAAI,EAAG,qCAAqC,CAAU;IAC/D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,qCAAqC,CAAC;gBAE3C,MAAM,EAAE,qCAAqC;CAQ1D;AAID,4CAA4C;AAC5C,MAAM,WAAW,yBAAyB;IACxC,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,EAAG,uBAAuB,CAAU;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC;gBAE/B,MAAM,EAAE,yBAAyB;CAQ9C;AAID,mDAAmD;AACnD,MAAM,WAAW,+BAA+B;IAC9C,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,QAAQ,CAAC,IAAI,EAAG,8BAA8B,CAAU;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,+BAA+B,CAAC;gBAErC,MAAM,EAAE,+BAA+B;CAQpD;AAID;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAC/B,uBAAuB,GACvB,mCAAmC,GACnC,qCAAqC,GACrC,uBAAuB,CAAC;AAE5B;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC3B,wBAAwB,GACxB,iCAAiC,GACjC,oCAAoC,GACpC,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AnimationGraph, AnimationGraphNode } from '@forgeax/engine-types';
|
|
2
|
+
import { type Result } from '@forgeax/engine-types';
|
|
3
|
+
import { type AnimationGraphError } from '../errors';
|
|
4
|
+
/**
|
|
5
|
+
* Opaque reference to a node inside the graph under construction. Branded so a
|
|
6
|
+
* raw number cannot be passed where a node ref is expected without an explicit
|
|
7
|
+
* cast (the illegal-graph tests forge refs deliberately). At runtime it is the
|
|
8
|
+
* node's index in {@link AnimationGraph.nodes}.
|
|
9
|
+
*/
|
|
10
|
+
export type AnimationGraphNodeRef = number & {
|
|
11
|
+
readonly __animationGraphNodeRef: unique symbol;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Declarative builder handed to the `defineAnimationGraph` callback. Exposes
|
|
15
|
+
* exactly the three node kinds (clip / blend / add) + nesting -- no FSM /
|
|
16
|
+
* transition / mask surface is reserved (OOS-1..4, charter F4). Each method
|
|
17
|
+
* appends a node and returns its {@link AnimationGraphNodeRef}.
|
|
18
|
+
*/
|
|
19
|
+
export interface AnimationGraphBuilder {
|
|
20
|
+
/** Add a Clip leaf sampling `clip` with the given static `weight` (default 1). */
|
|
21
|
+
clip(clip: string, weight?: number): AnimationGraphNodeRef;
|
|
22
|
+
/** Add a Blend node (normalizing lerp) over `children` with static `weight` (default 1). */
|
|
23
|
+
blend(children: readonly AnimationGraphNodeRef[], weight?: number): AnimationGraphNodeRef;
|
|
24
|
+
/** Add an Add node (non-normalizing) stacking `additive` layers onto `base`; static `weight` default 1. */
|
|
25
|
+
add(base: AnimationGraphNodeRef, additive: readonly AnimationGraphNodeRef[], weight?: number): AnimationGraphNodeRef;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Enumerate the child node indices a node references: clip -> none; blend ->
|
|
29
|
+
* its children; add -> `[base, ...additive]`. Exhaustive over the closed node
|
|
30
|
+
* union (charter P3). Shared by the validator here and describeAnimationGraph.
|
|
31
|
+
*/
|
|
32
|
+
export declare function animationGraphNodeChildren(node: AnimationGraphNode): readonly number[];
|
|
33
|
+
/**
|
|
34
|
+
* Construct an {@link AnimationGraph} declaratively. The callback receives a
|
|
35
|
+
* builder, adds clip/blend/add nodes, and returns the ref of the root node.
|
|
36
|
+
* The graph's topology is validated at construction time; on success the POD is
|
|
37
|
+
* returned in `ok(graph)` ready to be minted into a `shared<AnimationGraph>`
|
|
38
|
+
* handle (AC-02) and serialized (AC-14). On an illegal topology a structured
|
|
39
|
+
* {@link AnimationGraphError} is returned in `err(...)` (AC-11).
|
|
40
|
+
*/
|
|
41
|
+
export declare function defineAnimationGraph(build: (builder: AnimationGraphBuilder) => AnimationGraphNodeRef): Result<AnimationGraph, AnimationGraphError>;
|
|
42
|
+
//# sourceMappingURL=define-animation-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-animation-graph.d.ts","sourceRoot":"","sources":["../../src/graph/define-animation-graph.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAGL,KAAK,mBAAmB,EAGzB,MAAM,WAAW,CAAC;AAEnB;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG;IAC3C,QAAQ,CAAC,uBAAuB,EAAE,OAAO,MAAM,CAAC;CACjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAC3D,4FAA4F;IAC5F,KAAK,CAAC,QAAQ,EAAE,SAAS,qBAAqB,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAC1F,2GAA2G;IAC3G,GAAG,CACD,IAAI,EAAE,qBAAqB,EAC3B,QAAQ,EAAE,SAAS,qBAAqB,EAAE,EAC1C,MAAM,CAAC,EAAE,MAAM,GACd,qBAAqB,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,kBAAkB,GAAG,SAAS,MAAM,EAAE,CAStF;AAqGD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,qBAAqB,GAC/D,MAAM,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAM7C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AnimationGraph, AnimationGraphNode } from '@forgeax/engine-types';
|
|
2
|
+
/**
|
|
3
|
+
* Machine-readable description of a single graph node: its index in the
|
|
4
|
+
* construction order, its `type` discriminant, its static `weight`, and the
|
|
5
|
+
* child node indices it references (construction order, canonical child ordering).
|
|
6
|
+
*/
|
|
7
|
+
export interface AnimationGraphNodeDescription {
|
|
8
|
+
/** Index of this node in {@link AnimationGraphDescription.nodes} (construction order). */
|
|
9
|
+
readonly index: number;
|
|
10
|
+
/** Node kind discriminant (clip / blend / add). */
|
|
11
|
+
readonly type: AnimationGraphNode['type'];
|
|
12
|
+
/** The node's static weight (effective weight = runtime weight x static). */
|
|
13
|
+
readonly weight: number;
|
|
14
|
+
/** Child node indices referenced by this node (clip -> []), construction order. */
|
|
15
|
+
readonly children: readonly number[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Machine-readable description of an entire {@link AnimationGraph}: the ordered
|
|
19
|
+
* per-node descriptions (construction order), the root node index, and the
|
|
20
|
+
* per-node static weights (a flat projection of each node's `weight`).
|
|
21
|
+
*/
|
|
22
|
+
export interface AnimationGraphDescription {
|
|
23
|
+
/** Per-node descriptions, in graph POD construction order. */
|
|
24
|
+
readonly nodes: readonly AnimationGraphNodeDescription[];
|
|
25
|
+
/** Index of the graph's root (output) node, in construction order. */
|
|
26
|
+
readonly root: number;
|
|
27
|
+
/** Per-node static weights, in construction order. */
|
|
28
|
+
readonly staticWeights: readonly number[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Enumerate a validated {@link AnimationGraph}'s nodes, topology, root, and
|
|
32
|
+
* per-node static weights for machine-readable introspection (AC-12). Pure and
|
|
33
|
+
* read-only -- returns a fresh description derived from the POD in construction
|
|
34
|
+
* order so described indices match runtime `nodeWeights` indices.
|
|
35
|
+
*/
|
|
36
|
+
export declare function describeAnimationGraph(graph: AnimationGraph): AnimationGraphDescription;
|
|
37
|
+
//# sourceMappingURL=describe-animation-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-animation-graph.d.ts","sourceRoot":"","sources":["../../src/graph/describe-animation-graph.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGhF;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC1C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,SAAS,6BAA6B,EAAE,CAAC;IACzD,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,yBAAyB,CAavF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AnimationGraph } from '@forgeax/engine-types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a Clip leaf's durable GUID string to the form stored in Pack
|
|
4
|
+
* `refs[]`. Returns `undefined` when the GUID is unavailable, which aborts
|
|
5
|
+
* serialization.
|
|
6
|
+
* The caller supplies this so serialize stays free of AssetRegistry / World
|
|
7
|
+
* coupling; the graph already carries durable GUID strings at this boundary.
|
|
8
|
+
*/
|
|
9
|
+
export type ClipGuidResolver = (clip: string) => string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Output of {@link serializeAnimationGraph}: the pack `payload` object (a flat
|
|
12
|
+
* `{ nodes, root }` shape where Clip leaves reference `refs[]` by index) plus the
|
|
13
|
+
* deduped `refs[]` array of clip GUID strings.
|
|
14
|
+
*/
|
|
15
|
+
export interface SerializedAnimationGraph {
|
|
16
|
+
readonly payload: Record<string, unknown>;
|
|
17
|
+
readonly refs: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Serialize an {@link AnimationGraph} POD into a pack payload + refs pair. Clip
|
|
21
|
+
* leaves are rewritten from durable GUIDs to deduped `refs[]` GUID indices via
|
|
22
|
+
* `resolveClipGuid`; Blend/Add node references and `root` (all intra-graph node
|
|
23
|
+
* indices) pass through. Returns `undefined` if any durable clip GUID cannot be
|
|
24
|
+
* resolved -- an unresolvable clip means the graph cannot be persisted losslessly.
|
|
25
|
+
*/
|
|
26
|
+
export declare function serializeAnimationGraph(graph: AnimationGraph, resolveClipGuid?: ClipGuidResolver): SerializedAnimationGraph | undefined;
|
|
27
|
+
//# sourceMappingURL=serialize-animation-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize-animation-graph.d.ts","sourceRoot":"","sources":["../../src/graph/serialize-animation-graph.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,cAAc,EACrB,eAAe,GAAE,gBAAiC,GACjD,wBAAwB,GAAG,SAAS,CAoCtC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation graphs, players, and stable Transform targets.
|
|
3
|
+
*
|
|
4
|
+
* AI consumers should collect explicit entities, call
|
|
5
|
+
* {@link bindAnimationTargets} once, then configure the existing
|
|
6
|
+
* {@link AnimationPlayer} directly or through {@link defineAnimationGraph}.
|
|
7
|
+
* Binding failures expose stable `code`, `hint`, and `detail` fields.
|
|
8
|
+
*
|
|
9
|
+
* @see ../README.md
|
|
10
|
+
*/
|
|
11
|
+
export type { AnimationDiagnostic, AnimationDiagnosticCode, AnimationDiagnosticDetail, AnimationDiagnosticListener, } from './animation-diagnostic';
|
|
12
|
+
export { subscribeAnimationDiagnostics } from './animation-diagnostic';
|
|
13
|
+
export { AnimationPlayer } from './animation-player';
|
|
14
|
+
/** Stable target identity, explicit ownership, and atomic batch binding. */
|
|
15
|
+
export { AnimatedBy, AnimationTargetId, AnimationTargets, type BindAnimationTargetsErrorCode, bindAnimationTargets, } from './animation-target';
|
|
16
|
+
export { animationClipContribution, animationGraphContribution } from './assets/animation-decoder';
|
|
17
|
+
/** Build the existing graph-to-player slot path; this is not an animation FSM. */
|
|
18
|
+
export { type AnimationGraphNodeRef, animationGraphNodeChildren, defineAnimationGraph, } from './graph/define-animation-graph';
|
|
19
|
+
export { describeAnimationGraph } from './graph/describe-animation-graph';
|
|
20
|
+
export { serializeAnimationGraph } from './graph/serialize-animation-graph';
|
|
21
|
+
export { animationPayloadsPlugin, animationPlugin, animationRuntimePlugin } from './plugin';
|
|
22
|
+
export { AnimationAssetError, type AnimationAssetErrorCode, type AnimationAssetErrorDetail, resolveAnimationAsset, } from './resolve-animation-asset';
|
|
23
|
+
export { _resetAnimationWarnsForTests, ADVANCE_ANIMATION_PLAYER_SYSTEM, AdvanceAnimationPlayer, AnimationSet, advanceAnimationPlayer, registerAdvanceAnimationPlayer, } from './systems/advance-animation-player';
|
|
24
|
+
export type { AnimationPayloadLookup } from './systems/evaluate-animation-graph';
|
|
25
|
+
export { EvaluateAnimationGraph, evaluateAnimationGraph, } from './systems/evaluate-animation-graph';
|
|
26
|
+
/** Derive or validate the canonical 32-lowercase-hex animation target wire. */
|
|
27
|
+
export { deriveAnimationTargetId, isAnimationTargetId } from './target-id';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,4EAA4E;AAC5E,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,6BAA6B,EAClC,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACnG,kFAAkF;AAClF,OAAO,EACL,KAAK,qBAAqB,EAC1B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC5F,OAAO,EACL,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,sBAAsB,EACtB,YAAY,EACZ,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,+EAA+E;AAC/E,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|