@haiyue/extensions 0.1.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/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/animation/Animation2DComponent.d.ts +46 -0
- package/dist/animation/Animation2DExtensionRegistry.d.ts +27 -0
- package/dist/animation/Animation2DRenderSystem.d.ts +89 -0
- package/dist/animation/Animation2DRuntime.d.ts +99 -0
- package/dist/animation/Animation2DStateMachine.d.ts +13 -0
- package/dist/animation/Animation2DStateMachineComponent.d.ts +54 -0
- package/dist/animation/Animation2DStateMachineRuntime.d.ts +30 -0
- package/dist/animation/Animation2DStateMachineSystem.d.ts +14 -0
- package/dist/animation/Animation2DStateMachineVisualRuntime.d.ts +27 -0
- package/dist/animation/Animation2DSystem.d.ts +14 -0
- package/dist/animation/AnimationAssetLoader.d.ts +9 -0
- package/dist/animation/AnimationAudioClip.d.ts +26 -0
- package/dist/animation/AnimationPathTessellator.d.ts +52 -0
- package/dist/animation/AnimationTextRasterizer.d.ts +21 -0
- package/dist/animation/AnimationVisual2D.d.ts +68 -0
- package/dist/animation/HyaAnimation2DClipAdapter.d.ts +16 -0
- package/dist/animation/Particle2DDescriptorAdapter.d.ts +5 -0
- package/dist/animation/runtime/mixer/Action.d.ts +150 -0
- package/dist/animation/runtime/mixer/Mixer.d.ts +54 -0
- package/dist/animation/runtime/mixer/PoseBuffer.d.ts +23 -0
- package/dist/animation/runtime/mixer/Sampler.d.ts +17 -0
- package/dist/animation/runtime/mixer/Types.d.ts +101 -0
- package/dist/animation/runtime/mixer/index.d.ts +6 -0
- package/dist/animation-state-machine/AnimationStateMachine.d.ts +111 -0
- package/dist/animation-state-machine/AnimationStateMachineChannels.d.ts +23 -0
- package/dist/animation-state-machine/runtime/Animation2DStateMachineMixerAdapter.d.ts +51 -0
- package/dist/animation-state-machine/runtime/AnimationStateMachineBlendTreeWeights.d.ts +14 -0
- package/dist/animation-state-machine/runtime/AnimationStateMachineCompiler.d.ts +109 -0
- package/dist/animation-state-machine/runtime/AnimationStateMachineController.d.ts +103 -0
- package/dist/animation-state-machine/runtime/AnimationStateMachineMixerPort.d.ts +35 -0
- package/dist/animation-state-machine/runtime/index.d.ts +7 -0
- package/dist/animation.d.ts +15 -0
- package/dist/animation.js +1171 -0
- package/dist/animation3d/Animation3DAction.d.ts +46 -0
- package/dist/animation3d/Animation3DBinding.d.ts +85 -0
- package/dist/animation3d/Animation3DClip.d.ts +20 -0
- package/dist/animation3d/Animation3DError.d.ts +13 -0
- package/dist/animation3d/Animation3DMixer.d.ts +27 -0
- package/dist/animation3d/Animation3DPose.d.ts +40 -0
- package/dist/animation3d/Animation3DPoseBuffer.d.ts +24 -0
- package/dist/animation3d/Animation3DResource.d.ts +28 -0
- package/dist/animation3d/Animation3DStateMachine.d.ts +95 -0
- package/dist/animation3d/Animation3DStateMachineRuntime.d.ts +70 -0
- package/dist/animation3d/Animation3DTrack.d.ts +19 -0
- package/dist/animation3d/hya/HyaAnimation3DRuntime.d.ts +73 -0
- package/dist/animation3d/hya/HyaAnimation3DStateMachineRuntime.d.ts +65 -0
- package/dist/animation3d/hya/HyaAnimation3DTypes.d.ts +170 -0
- package/dist/animation3d/hya/index.d.ts +4 -0
- package/dist/animation3d/index.d.ts +14 -0
- package/dist/animation3d/runtime/integration/Animation3DStateMachineMixerAdapter.d.ts +81 -0
- package/dist/animation3d/runtime/integration/Animation3DStateMachineMixerIntegration.d.ts +39 -0
- package/dist/animation3d/runtime/integration/index.d.ts +2 -0
- package/dist/animation3d/runtime/mixer/Action.d.ts +150 -0
- package/dist/animation3d/runtime/mixer/Animation3DMixerRuntimeStore.d.ts +6 -0
- package/dist/animation3d/runtime/mixer/Mixer.d.ts +59 -0
- package/dist/animation3d/runtime/mixer/PoseBuffer.d.ts +1 -0
- package/dist/animation3d/runtime/mixer/TrackSampler.d.ts +24 -0
- package/dist/animation3d/runtime/mixer/index.d.ts +4 -0
- package/dist/animation3d/runtime/state-machine/Animation3DBlendTreeWeights.d.ts +1 -0
- package/dist/animation3d/runtime/state-machine/Animation3DStateMachineCompiler.d.ts +1 -0
- package/dist/animation3d/runtime/state-machine/Animation3DStateMachineController.d.ts +1 -0
- package/dist/animation3d/runtime/state-machine/Animation3DStateMachineMixerPort.d.ts +1 -0
- package/dist/animation3d/runtime/state-machine/index.d.ts +6 -0
- package/dist/animation3d.d.ts +5 -0
- package/dist/animation3d.js +1708 -0
- package/dist/benchmark.d.ts +30 -0
- package/dist/benchmark.js +119 -0
- package/dist/canvas-text/CanvasText2DRenderSystem.d.ts +24 -0
- package/dist/canvas-text/CanvasTextComponent.d.ts +18 -0
- package/dist/canvas-text.d.ts +4 -0
- package/dist/canvas-text.js +276 -0
- package/dist/chunks/2d-ui-animation-2d.generated-D4aHzFU2.js +4 -0
- package/dist/chunks/2d-ui-canvas-text-2d.generated-C0Eaej2m.js +4 -0
- package/dist/chunks/2d-ui-spine2d.generated-CUUi8xjl.js +4 -0
- package/dist/chunks/2d-ui-tilemap2d.generated-gebw4mX7.js +4 -0
- package/dist/chunks/Animation2DStateMachine-9IonguNa.js +3245 -0
- package/dist/chunks/AnimationStateMachineController-BIcAh-sT.js +1438 -0
- package/dist/chunks/GltfAnimation3DAdapter-Cu3rQQsW.js +2240 -0
- package/dist/chunks/GltfAnimationRuntime-CRHsLycN.js +631 -0
- package/dist/chunks/RenderSystem2DBase-DDT61dAu.js +227 -0
- package/dist/chunks/Spine2DRuntime-D9M9LAQR.js +3056 -0
- package/dist/chunks/SpineAssetParser-BSDmPge1.js +378 -0
- package/dist/chunks/gltfLoader-Dm22jLYB.js +2085 -0
- package/dist/chunks/pluginUtils-CvwroRMd.js +33 -0
- package/dist/experimental-gltf-worker.d.ts +4 -0
- package/dist/experimental-gltf-worker.js +138 -0
- package/dist/experimental-spine-worker.d.ts +4 -0
- package/dist/experimental-spine-worker.js +110 -0
- package/dist/gltf/GltfAccessorReader.d.ts +7 -0
- package/dist/gltf/GltfAnimation3DAdapter.d.ts +47 -0
- package/dist/gltf/GltfAnimationRuntime.d.ts +10 -0
- package/dist/gltf/GltfAssetWorkerClient.d.ts +20 -0
- package/dist/gltf/GltfCompatibilityReport.d.ts +70 -0
- package/dist/gltf/GltfConservativeBounds.d.ts +18 -0
- package/dist/gltf/GltfDracoDecoder.d.ts +4 -0
- package/dist/gltf/GltfExtensionAdapter.d.ts +54 -0
- package/dist/gltf/GltfLoaderContract.d.ts +249 -0
- package/dist/gltf/GltfLoaderErrors.d.ts +4 -0
- package/dist/gltf/GltfMaterialDescriptor.d.ts +23 -0
- package/dist/gltf/GltfMaterialEncoder.d.ts +20 -0
- package/dist/gltf/GltfMaterialLoader.d.ts +6 -0
- package/dist/gltf/GltfModelComponent.d.ts +72 -0
- package/dist/gltf/GltfModelSystem.d.ts +37 -0
- package/dist/gltf/GltfPlugin.d.ts +6 -0
- package/dist/gltf/GltfSchema.d.ts +225 -0
- package/dist/gltf/GltfUvSemanticPlanner.d.ts +33 -0
- package/dist/gltf/gltfLoader.d.ts +9 -0
- package/dist/gltf-animation3d.d.ts +3 -0
- package/dist/gltf-animation3d.js +8 -0
- package/dist/gltf-worker-runtime.d.ts +7 -0
- package/dist/gltf-worker-runtime.js +6981 -0
- package/dist/gltf.d.ts +12 -0
- package/dist/gltf.js +517 -0
- package/dist/grid/Grid2DComponent.d.ts +25 -0
- package/dist/grid.d.ts +2 -0
- package/dist/grid.js +56 -0
- package/dist/hya-state-machine.d.ts +7 -0
- package/dist/hya-state-machine.js +2934 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/internal/2d-ui-shader-artifact.js +870 -0
- package/dist/plugins/pluginUtils.d.ts +20 -0
- package/dist/plugins.d.ts +6 -0
- package/dist/shaders/generated/2d-ui-artifact.generated.d.ts +658 -0
- package/dist/spine/Spine2DComponent.d.ts +116 -0
- package/dist/spine/Spine2DGpuRenderer.d.ts +65 -0
- package/dist/spine/Spine2DRenderSystem.d.ts +27 -0
- package/dist/spine/Spine2DRuntime.d.ts +103 -0
- package/dist/spine/SpineAnimationBoneTimelines.d.ts +8 -0
- package/dist/spine/SpineAssetParser.d.ts +18 -0
- package/dist/spine/SpineAssetWorkerClient.d.ts +19 -0
- package/dist/spine/SpineAssetWorkerContract.d.ts +6 -0
- package/dist/spine/SpineAtlasParser.d.ts +21 -0
- package/dist/spine/SpineFloatBuilder.d.ts +15 -0
- package/dist/spine/SpinePathConstraintSolver.d.ts +32 -0
- package/dist/spine/SpinePlugin.d.ts +8 -0
- package/dist/spine/SpineSkeletonRuntime.d.ts +185 -0
- package/dist/spine/SpineSlotAnimation.d.ts +17 -0
- package/dist/spine/SpineTimelineRuntime.d.ts +25 -0
- package/dist/spine/SpineVertexBuilder.d.ts +61 -0
- package/dist/spine.d.ts +7 -0
- package/dist/spine.js +578 -0
- package/dist/tilemap/Tilemap2DComponent.d.ts +110 -0
- package/dist/tilemap/Tilemap2DRenderSystem.d.ts +11 -0
- package/dist/tilemap/Tilemap2DRenderer.d.ts +24 -0
- package/dist/tilemap/TilemapPlugin.d.ts +8 -0
- package/dist/tilemap.d.ts +6 -0
- package/dist/tilemap.js +535 -0
- package/dist/tween/Tween2DComponent.d.ts +70 -0
- package/dist/tween/Tween2DSystem.d.ts +12 -0
- package/dist/tween.d.ts +4 -0
- package/dist/tween.js +138 -0
- package/dist/utils/RenderSystem2DBase.d.ts +42 -0
- package/dist/utils/arrayAccess.d.ts +4 -0
- package/dist/utils/camera2d.d.ts +12 -0
- package/dist/utils/render2dGpu.d.ts +32 -0
- package/package.json +124 -0
- package/src/animation/Animation2DComponent.ts +135 -0
- package/src/animation/Animation2DExtensionRegistry.ts +52 -0
- package/src/animation/Animation2DRenderSystem.ts +1026 -0
- package/src/animation/Animation2DRuntime.ts +1326 -0
- package/src/animation/Animation2DStateMachine.ts +39 -0
- package/src/animation/Animation2DStateMachineComponent.ts +228 -0
- package/src/animation/Animation2DStateMachineRuntime.ts +141 -0
- package/src/animation/Animation2DStateMachineSystem.ts +60 -0
- package/src/animation/Animation2DStateMachineVisualRuntime.ts +282 -0
- package/src/animation/Animation2DSystem.ts +72 -0
- package/src/animation/AnimationAssetLoader.ts +84 -0
- package/src/animation/AnimationAudioClip.ts +140 -0
- package/src/animation/AnimationPathTessellator.ts +691 -0
- package/src/animation/AnimationTextRasterizer.ts +340 -0
- package/src/animation/AnimationVisual2D.ts +153 -0
- package/src/animation/HyaAnimation2DClipAdapter.ts +845 -0
- package/src/animation/Particle2DDescriptorAdapter.ts +35 -0
- package/src/animation/runtime/mixer/Action.ts +876 -0
- package/src/animation/runtime/mixer/Mixer.ts +505 -0
- package/src/animation/runtime/mixer/PoseBuffer.ts +105 -0
- package/src/animation/runtime/mixer/Sampler.ts +252 -0
- package/src/animation/runtime/mixer/Types.ts +138 -0
- package/src/animation/runtime/mixer/index.ts +31 -0
- package/src/animation-state-machine/AnimationStateMachine.ts +146 -0
- package/src/animation-state-machine/AnimationStateMachineChannels.ts +116 -0
- package/src/animation-state-machine/runtime/Animation2DStateMachineMixerAdapter.ts +197 -0
- package/src/animation-state-machine/runtime/AnimationStateMachineBlendTreeWeights.ts +503 -0
- package/src/animation-state-machine/runtime/AnimationStateMachineCompiler.ts +763 -0
- package/src/animation-state-machine/runtime/AnimationStateMachineController.ts +987 -0
- package/src/animation-state-machine/runtime/AnimationStateMachineMixerPort.ts +54 -0
- package/src/animation-state-machine/runtime/index.ts +47 -0
- package/src/animation.ts +33 -0
- package/src/animation3d/Animation3DAction.ts +73 -0
- package/src/animation3d/Animation3DBinding.ts +116 -0
- package/src/animation3d/Animation3DClip.ts +22 -0
- package/src/animation3d/Animation3DError.ts +34 -0
- package/src/animation3d/Animation3DMixer.ts +82 -0
- package/src/animation3d/Animation3DPose.ts +100 -0
- package/src/animation3d/Animation3DPoseBuffer.ts +85 -0
- package/src/animation3d/Animation3DResource.ts +49 -0
- package/src/animation3d/Animation3DStateMachine.ts +126 -0
- package/src/animation3d/Animation3DStateMachineRuntime.ts +191 -0
- package/src/animation3d/Animation3DTrack.ts +29 -0
- package/src/animation3d/hya/HyaAnimation3DRuntime.ts +756 -0
- package/src/animation3d/hya/HyaAnimation3DStateMachineRuntime.ts +618 -0
- package/src/animation3d/hya/HyaAnimation3DTypes.ts +168 -0
- package/src/animation3d/hya/index.ts +10 -0
- package/src/animation3d/index.ts +76 -0
- package/src/animation3d/runtime/integration/Animation3DStateMachineMixerAdapter.ts +325 -0
- package/src/animation3d/runtime/integration/Animation3DStateMachineMixerIntegration.ts +158 -0
- package/src/animation3d/runtime/integration/index.ts +9 -0
- package/src/animation3d/runtime/mixer/Action.ts +833 -0
- package/src/animation3d/runtime/mixer/Animation3DMixerRuntimeStore.ts +26 -0
- package/src/animation3d/runtime/mixer/Mixer.ts +562 -0
- package/src/animation3d/runtime/mixer/PoseBuffer.ts +1 -0
- package/src/animation3d/runtime/mixer/TrackSampler.ts +399 -0
- package/src/animation3d/runtime/mixer/index.ts +8 -0
- package/src/animation3d/runtime/state-machine/Animation3DBlendTreeWeights.ts +4 -0
- package/src/animation3d/runtime/state-machine/Animation3DStateMachineCompiler.ts +1 -0
- package/src/animation3d/runtime/state-machine/Animation3DStateMachineController.ts +1 -0
- package/src/animation3d/runtime/state-machine/Animation3DStateMachineMixerPort.ts +1 -0
- package/src/animation3d/runtime/state-machine/index.ts +45 -0
- package/src/animation3d.ts +5 -0
- package/src/benchmark.ts +168 -0
- package/src/canvas-text/CanvasText2DRenderSystem.ts +292 -0
- package/src/canvas-text/CanvasTextComponent.ts +47 -0
- package/src/canvas-text.ts +4 -0
- package/src/experimental-gltf-worker.ts +18 -0
- package/src/experimental-spine-worker.ts +9 -0
- package/src/gltf/GltfAccessorReader.ts +271 -0
- package/src/gltf/GltfAnimation3DAdapter.ts +680 -0
- package/src/gltf/GltfAnimationRuntime.ts +392 -0
- package/src/gltf/GltfAssetWorkerClient.ts +136 -0
- package/src/gltf/GltfCompatibilityReport.ts +214 -0
- package/src/gltf/GltfConservativeBounds.ts +219 -0
- package/src/gltf/GltfDracoDecoder.ts +251 -0
- package/src/gltf/GltfExtensionAdapter.ts +340 -0
- package/src/gltf/GltfLoaderContract.ts +333 -0
- package/src/gltf/GltfLoaderErrors.ts +59 -0
- package/src/gltf/GltfMaterialDescriptor.ts +134 -0
- package/src/gltf/GltfMaterialEncoder.ts +173 -0
- package/src/gltf/GltfMaterialLoader.ts +293 -0
- package/src/gltf/GltfModelComponent.ts +115 -0
- package/src/gltf/GltfModelSystem.ts +208 -0
- package/src/gltf/GltfPlugin.ts +84 -0
- package/src/gltf/GltfSchema.ts +229 -0
- package/src/gltf/GltfUvSemanticPlanner.ts +166 -0
- package/src/gltf/gltfLoader.ts +910 -0
- package/src/gltf-animation3d.ts +10 -0
- package/src/gltf-worker-runtime.ts +10 -0
- package/src/gltf.ts +56 -0
- package/src/grid/Grid2DComponent.ts +69 -0
- package/src/grid.ts +2 -0
- package/src/hya-state-machine.ts +19 -0
- package/src/index.ts +2 -0
- package/src/plugins/pluginUtils.ts +50 -0
- package/src/plugins.ts +6 -0
- package/src/shaders/generated/2d-ui-animation-2d.generated.wgsl +242 -0
- package/src/shaders/generated/2d-ui-artifact.generated.ts +867 -0
- package/src/shaders/generated/2d-ui-canvas-text-2d.generated.wgsl +38 -0
- package/src/shaders/generated/2d-ui-spine2d.generated.wgsl +41 -0
- package/src/shaders/generated/2d-ui-tilemap2d.generated.wgsl +36 -0
- package/src/spine/Spine2DComponent.ts +168 -0
- package/src/spine/Spine2DGpuRenderer.ts +449 -0
- package/src/spine/Spine2DRenderSystem.ts +199 -0
- package/src/spine/Spine2DRuntime.ts +1529 -0
- package/src/spine/SpineAnimationBoneTimelines.ts +30 -0
- package/src/spine/SpineAssetParser.ts +20 -0
- package/src/spine/SpineAssetWorkerClient.ts +112 -0
- package/src/spine/SpineAssetWorkerContract.ts +4 -0
- package/src/spine/SpineAtlasParser.ts +127 -0
- package/src/spine/SpineFloatBuilder.ts +66 -0
- package/src/spine/SpinePathConstraintSolver.ts +582 -0
- package/src/spine/SpinePlugin.ts +76 -0
- package/src/spine/SpineSkeletonRuntime.ts +521 -0
- package/src/spine/SpineSlotAnimation.ts +195 -0
- package/src/spine/SpineTimelineRuntime.ts +453 -0
- package/src/spine/SpineVertexBuilder.ts +686 -0
- package/src/spine.ts +7 -0
- package/src/tilemap/Tilemap2DComponent.ts +232 -0
- package/src/tilemap/Tilemap2DRenderSystem.ts +58 -0
- package/src/tilemap/Tilemap2DRenderer.ts +289 -0
- package/src/tilemap/TilemapPlugin.ts +75 -0
- package/src/tilemap.ts +6 -0
- package/src/tween/Tween2DComponent.ts +83 -0
- package/src/tween/Tween2DSystem.ts +78 -0
- package/src/tween.ts +4 -0
- package/src/types/earcut.d.ts +7 -0
- package/src/types/wgsl.d.ts +4 -0
- package/src/utils/RenderSystem2DBase.ts +164 -0
- package/src/utils/arrayAccess.ts +17 -0
- package/src/utils/camera2d.ts +68 -0
- package/src/utils/render2dGpu.ts +132 -0
- package/test/fixtures/gltf/animation-characterization.gltf +344 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnimationStateMachineBindingMask,
|
|
3
|
+
AnimationStateMachineBlendMode,
|
|
4
|
+
AnimationStateMachineLoopMode,
|
|
5
|
+
} from '../AnimationStateMachine.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The only action shape the state-machine runtime needs. Concrete mixer
|
|
9
|
+
* actions are adapted to this interface by the integration layer.
|
|
10
|
+
*/
|
|
11
|
+
export interface AnimationStateMachineActionHandle {
|
|
12
|
+
/** Source clip duration in seconds. */
|
|
13
|
+
readonly duration: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AnimationStateMachineActionOptions {
|
|
17
|
+
readonly layerId: string;
|
|
18
|
+
readonly stateId: string;
|
|
19
|
+
readonly loop: AnimationStateMachineLoopMode;
|
|
20
|
+
readonly blendMode: AnimationStateMachineBlendMode;
|
|
21
|
+
readonly mask: AnimationStateMachineBindingMask | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal boundary between the state-machine controller and an animation
|
|
26
|
+
* mixer. It deliberately has no dependency on Animation3DMixer or
|
|
27
|
+
* Animation3DAction.
|
|
28
|
+
*/
|
|
29
|
+
export interface AnimationStateMachineMixerPort<
|
|
30
|
+
TAction extends AnimationStateMachineActionHandle =
|
|
31
|
+
AnimationStateMachineActionHandle,
|
|
32
|
+
> {
|
|
33
|
+
createAction(
|
|
34
|
+
clipId: string,
|
|
35
|
+
options: AnimationStateMachineActionOptions,
|
|
36
|
+
): TAction;
|
|
37
|
+
play(action: TAction): void;
|
|
38
|
+
stop(action: TAction): void;
|
|
39
|
+
fade(action: TAction, targetWeight: number, durationSeconds: number): void;
|
|
40
|
+
setWeight(action: TAction, weight: number): void;
|
|
41
|
+
setTime(action: TAction, timeSeconds: number): void;
|
|
42
|
+
setTimeScale(action: TAction, timeScale: number): void;
|
|
43
|
+
destroyAction(action: TAction): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Compatibility aliases for the original 3D-prefixed runtime boundary. */
|
|
47
|
+
export type Animation3DStateMachineActionHandle =
|
|
48
|
+
AnimationStateMachineActionHandle;
|
|
49
|
+
export type Animation3DStateMachineActionOptions =
|
|
50
|
+
AnimationStateMachineActionOptions;
|
|
51
|
+
export type Animation3DStateMachineMixerPort<
|
|
52
|
+
TAction extends AnimationStateMachineActionHandle =
|
|
53
|
+
AnimationStateMachineActionHandle,
|
|
54
|
+
> = AnimationStateMachineMixerPort<TAction>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export {
|
|
2
|
+
evaluateAnimation3DBlend1DWeights as evaluateAnimationBlend1DWeights,
|
|
3
|
+
evaluateAnimation3DBlend2DWeights as evaluateAnimationBlend2DWeights,
|
|
4
|
+
} from './AnimationStateMachineBlendTreeWeights.js';
|
|
5
|
+
export {
|
|
6
|
+
AnimationStateMachineValidationError,
|
|
7
|
+
compileAnimationStateMachineDefinition as compileAnimationStateMachine,
|
|
8
|
+
compileAnimationStateMachineDefinition,
|
|
9
|
+
validateAnimationStateMachineDefinition,
|
|
10
|
+
} from './AnimationStateMachineCompiler.js';
|
|
11
|
+
export type {
|
|
12
|
+
Animation3DStateMachineValidationCode as AnimationStateMachineValidationCode,
|
|
13
|
+
Animation3DStateMachineValidationIssue as AnimationStateMachineValidationIssue,
|
|
14
|
+
CompiledAnimation3DBlend1DChild as CompiledAnimationBlend1DChild,
|
|
15
|
+
CompiledAnimation3DBlend1DMotion as CompiledAnimationBlend1DMotion,
|
|
16
|
+
CompiledAnimation3DBlend2DChild as CompiledAnimationBlend2DChild,
|
|
17
|
+
CompiledAnimation3DBlend2DMotion as CompiledAnimationBlend2DMotion,
|
|
18
|
+
CompiledAnimation3DClipMotion as CompiledAnimationClipMotion,
|
|
19
|
+
CompiledAnimation3DCondition as CompiledAnimationCondition,
|
|
20
|
+
CompiledAnimation3DConditionOperator as CompiledAnimationConditionOperator,
|
|
21
|
+
CompiledAnimation3DLayer as CompiledAnimationLayer,
|
|
22
|
+
CompiledAnimation3DMotion as CompiledAnimationMotion,
|
|
23
|
+
CompiledAnimation3DParameter as CompiledAnimationParameter,
|
|
24
|
+
CompiledAnimation3DParameterType as CompiledAnimationParameterType,
|
|
25
|
+
CompiledAnimation3DState as CompiledAnimationState,
|
|
26
|
+
CompiledAnimation3DStateMachine as CompiledAnimationStateMachine,
|
|
27
|
+
CompiledAnimation3DTransition as CompiledAnimationTransition,
|
|
28
|
+
} from './AnimationStateMachineCompiler.js';
|
|
29
|
+
export {
|
|
30
|
+
Animation3DStateMachineController as AnimationStateMachineController,
|
|
31
|
+
createAnimation3DStateMachineController as createAnimationStateMachineController,
|
|
32
|
+
runAnimationStateMachineControllerUpdateTransaction,
|
|
33
|
+
} from './AnimationStateMachineController.js';
|
|
34
|
+
export type {
|
|
35
|
+
Animation3DStateMachineControllerOptions as AnimationStateMachineControllerOptions,
|
|
36
|
+
Animation3DStateMachineControllerStatus as AnimationStateMachineControllerStatus,
|
|
37
|
+
Animation3DStateMachineLayerSnapshot as AnimationStateMachineLayerSnapshot,
|
|
38
|
+
} from './AnimationStateMachineController.js';
|
|
39
|
+
export type {
|
|
40
|
+
AnimationStateMachineActionHandle,
|
|
41
|
+
AnimationStateMachineActionOptions,
|
|
42
|
+
AnimationStateMachineMixerPort,
|
|
43
|
+
} from './AnimationStateMachineMixerPort.js';
|
|
44
|
+
export {
|
|
45
|
+
Animation2DStateMachineActionRuntimeHandle,
|
|
46
|
+
Animation2DStateMachineMixerAdapter,
|
|
47
|
+
} from './Animation2DStateMachineMixerAdapter.js';
|
package/src/animation.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { Animation2DComponent } from './animation/Animation2DComponent';
|
|
2
|
+
export type { Animation2DComponentOptions, Animation2DRuntimeStats } from './animation/Animation2DComponent';
|
|
3
|
+
export { Animation2DSystem } from './animation/Animation2DSystem';
|
|
4
|
+
export type { Animation2DSystemOptions } from './animation/Animation2DSystem';
|
|
5
|
+
export { Animation2DRenderSystem } from './animation/Animation2DRenderSystem';
|
|
6
|
+
export type { Animation2DRenderStats, Animation2DRenderSystemOptions } from './animation/Animation2DRenderSystem';
|
|
7
|
+
export { tessellateAnimationPath } from './animation/AnimationPathTessellator';
|
|
8
|
+
export { createAnimationAssetLoader, HAIYUE_ANIMATION_ASSET_TYPE } from './animation/AnimationAssetLoader';
|
|
9
|
+
export type { AnimationAssetLoaderOptions } from './animation/AnimationAssetLoader';
|
|
10
|
+
export { Animation2DExtensionRegistry } from './animation/Animation2DExtensionRegistry';
|
|
11
|
+
export type {
|
|
12
|
+
Animation2DExtensionContext,
|
|
13
|
+
Animation2DExtensionHandler,
|
|
14
|
+
Animation2DExtensionInstance,
|
|
15
|
+
} from './animation/Animation2DExtensionRegistry';
|
|
16
|
+
export {
|
|
17
|
+
createAnimation2DStateMachineController,
|
|
18
|
+
} from './animation/Animation2DStateMachine';
|
|
19
|
+
export type {
|
|
20
|
+
AnimationStateMachineDefinition,
|
|
21
|
+
} from './animation-state-machine/AnimationStateMachine';
|
|
22
|
+
export {
|
|
23
|
+
AnimationStateMachineController,
|
|
24
|
+
AnimationStateMachineValidationError,
|
|
25
|
+
compileAnimationStateMachine,
|
|
26
|
+
validateAnimationStateMachineDefinition,
|
|
27
|
+
} from './animation-state-machine/runtime/index';
|
|
28
|
+
export type {
|
|
29
|
+
AnimationStateMachineControllerOptions,
|
|
30
|
+
AnimationStateMachineLayerSnapshot,
|
|
31
|
+
AnimationStateMachineMixerPort,
|
|
32
|
+
AnimationStateMachineValidationIssue,
|
|
33
|
+
} from './animation-state-machine/runtime/index';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Animation3DBindingMask,
|
|
3
|
+
} from './Animation3DBinding';
|
|
4
|
+
import type { Animation3DClip } from './Animation3DClip';
|
|
5
|
+
|
|
6
|
+
export type Animation3DLoopMode =
|
|
7
|
+
| 'once'
|
|
8
|
+
| 'repeat'
|
|
9
|
+
| 'ping-pong';
|
|
10
|
+
|
|
11
|
+
export type Animation3DBlendMode =
|
|
12
|
+
| 'override'
|
|
13
|
+
| 'additive';
|
|
14
|
+
|
|
15
|
+
export type Animation3DActionStatus =
|
|
16
|
+
| 'idle'
|
|
17
|
+
| 'scheduled'
|
|
18
|
+
| 'running'
|
|
19
|
+
| 'paused'
|
|
20
|
+
| 'finished'
|
|
21
|
+
| 'stopped';
|
|
22
|
+
|
|
23
|
+
export interface Animation3DActionOptions {
|
|
24
|
+
readonly id?: string;
|
|
25
|
+
readonly loop?: Animation3DLoopMode;
|
|
26
|
+
/** Infinity is valid for repeat and ping-pong. */
|
|
27
|
+
readonly repetitions?: number;
|
|
28
|
+
readonly clampWhenFinished?: boolean;
|
|
29
|
+
readonly timeScale?: number;
|
|
30
|
+
readonly weight?: number;
|
|
31
|
+
readonly blendMode?: Animation3DBlendMode;
|
|
32
|
+
readonly mask?: Animation3DBindingMask;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One mutable playback instance of an immutable clip.
|
|
37
|
+
* Actions are mixer-owned and become invalid after removal or mixer destroy.
|
|
38
|
+
*/
|
|
39
|
+
export interface Animation3DAction {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly clip: Animation3DClip;
|
|
42
|
+
readonly status: Animation3DActionStatus;
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
paused: boolean;
|
|
45
|
+
time: number;
|
|
46
|
+
timeScale: number;
|
|
47
|
+
weight: number;
|
|
48
|
+
loop: Animation3DLoopMode;
|
|
49
|
+
repetitions: number;
|
|
50
|
+
clampWhenFinished: boolean;
|
|
51
|
+
blendMode: Animation3DBlendMode;
|
|
52
|
+
mask: Animation3DBindingMask | null;
|
|
53
|
+
readonly effectiveTimeScale: number;
|
|
54
|
+
readonly effectiveWeight: number;
|
|
55
|
+
|
|
56
|
+
play(): this;
|
|
57
|
+
stop(): this;
|
|
58
|
+
reset(): this;
|
|
59
|
+
startAt(mixerTimeSeconds: number): this;
|
|
60
|
+
fadeIn(durationSeconds: number): this;
|
|
61
|
+
fadeOut(durationSeconds: number): this;
|
|
62
|
+
crossFadeFrom(
|
|
63
|
+
source: Animation3DAction,
|
|
64
|
+
durationSeconds: number,
|
|
65
|
+
warp?: boolean,
|
|
66
|
+
): this;
|
|
67
|
+
crossFadeTo(
|
|
68
|
+
destination: Animation3DAction,
|
|
69
|
+
durationSeconds: number,
|
|
70
|
+
warp?: boolean,
|
|
71
|
+
): this;
|
|
72
|
+
stopFading(): this;
|
|
73
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logical targets keep authored clips independent from a concrete ECS World.
|
|
3
|
+
* A runtime resolver maps one of these stable references to an actual target.
|
|
4
|
+
*/
|
|
5
|
+
export type Animation3DBindingTarget =
|
|
6
|
+
| Readonly<{
|
|
7
|
+
kind: 'node-id';
|
|
8
|
+
nodeId: string;
|
|
9
|
+
}>
|
|
10
|
+
| Readonly<{
|
|
11
|
+
kind: 'node-path';
|
|
12
|
+
segments: readonly string[];
|
|
13
|
+
}>
|
|
14
|
+
| Readonly<{
|
|
15
|
+
kind: 'slot';
|
|
16
|
+
slot: string;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export type Animation3DFixedValueType =
|
|
20
|
+
| 'scalar'
|
|
21
|
+
| 'vec2'
|
|
22
|
+
| 'vec3'
|
|
23
|
+
| 'vec4'
|
|
24
|
+
| 'quaternion';
|
|
25
|
+
|
|
26
|
+
export type Animation3DValueType =
|
|
27
|
+
| Animation3DFixedValueType
|
|
28
|
+
| 'weights';
|
|
29
|
+
|
|
30
|
+
export interface Animation3DTranslationBinding {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly target: Animation3DBindingTarget;
|
|
33
|
+
readonly path: 'transform.translation';
|
|
34
|
+
readonly valueType: 'vec3';
|
|
35
|
+
readonly valueSize: 3;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Animation3DRotationBinding {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly target: Animation3DBindingTarget;
|
|
41
|
+
readonly path: 'transform.rotation';
|
|
42
|
+
readonly valueType: 'quaternion';
|
|
43
|
+
readonly valueSize: 4;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface Animation3DScaleBinding {
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly target: Animation3DBindingTarget;
|
|
49
|
+
readonly path: 'transform.scale';
|
|
50
|
+
readonly valueType: 'vec3';
|
|
51
|
+
readonly valueSize: 3;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface Animation3DMorphWeightsBinding {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly target: Animation3DBindingTarget;
|
|
57
|
+
readonly path: 'morph.weights';
|
|
58
|
+
readonly valueType: 'weights';
|
|
59
|
+
/** Positive morph target count. Loaders must reject zero or negative values. */
|
|
60
|
+
readonly valueSize: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type Animation3DFixedValueSize = {
|
|
64
|
+
readonly scalar: 1;
|
|
65
|
+
readonly vec2: 2;
|
|
66
|
+
readonly vec3: 3;
|
|
67
|
+
readonly vec4: 4;
|
|
68
|
+
readonly quaternion: 4;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type Animation3DPropertyBinding = {
|
|
72
|
+
[TValueType in Animation3DFixedValueType]: Readonly<{
|
|
73
|
+
id: string;
|
|
74
|
+
target: Animation3DBindingTarget;
|
|
75
|
+
path: 'property';
|
|
76
|
+
/** Stable component or adapter namespace, never a constructor reference. */
|
|
77
|
+
component: string;
|
|
78
|
+
property: string;
|
|
79
|
+
valueType: TValueType;
|
|
80
|
+
valueSize: Animation3DFixedValueSize[TValueType];
|
|
81
|
+
}>;
|
|
82
|
+
}[Animation3DFixedValueType];
|
|
83
|
+
|
|
84
|
+
export type Animation3DBinding =
|
|
85
|
+
| Animation3DTranslationBinding
|
|
86
|
+
| Animation3DRotationBinding
|
|
87
|
+
| Animation3DScaleBinding
|
|
88
|
+
| Animation3DMorphWeightsBinding
|
|
89
|
+
| Animation3DPropertyBinding;
|
|
90
|
+
|
|
91
|
+
export interface Animation3DResolvedBinding<
|
|
92
|
+
TBinding extends Animation3DBinding = Animation3DBinding,
|
|
93
|
+
> {
|
|
94
|
+
readonly binding: TBinding;
|
|
95
|
+
/** Writes exactly binding.valueSize values into out. */
|
|
96
|
+
read(out: Float32Array): void;
|
|
97
|
+
/** Reads exactly binding.valueSize values from value. */
|
|
98
|
+
write(value: ArrayLike<number>): void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Resolver revisions invalidate cached resolved bindings after hierarchy or
|
|
103
|
+
* component structure changes.
|
|
104
|
+
*/
|
|
105
|
+
export interface Animation3DBindingResolver {
|
|
106
|
+
readonly revision: number;
|
|
107
|
+
resolve<TBinding extends Animation3DBinding>(
|
|
108
|
+
binding: TBinding,
|
|
109
|
+
): Animation3DResolvedBinding<TBinding> | null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface Animation3DBindingMask {
|
|
113
|
+
/** Empty or omitted include means all bindings are eligible. */
|
|
114
|
+
readonly include?: readonly string[];
|
|
115
|
+
readonly exclude?: readonly string[];
|
|
116
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Animation3DTrack } from './Animation3DTrack';
|
|
2
|
+
|
|
3
|
+
export interface Animation3DEvent {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly time: number;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** Loader-validated, structured-cloneable event data. */
|
|
8
|
+
readonly payload?: Readonly<Record<string, unknown>>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Immutable, source-format-independent CPU animation resource.
|
|
13
|
+
* Times are seconds; rotations are normalized XYZW quaternions.
|
|
14
|
+
*/
|
|
15
|
+
export interface Animation3DClip {
|
|
16
|
+
readonly format: 'haiyue-animation3d-clip@1';
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly duration: number;
|
|
20
|
+
readonly tracks: readonly Animation3DTrack[];
|
|
21
|
+
readonly events: readonly Animation3DEvent[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type Animation3DErrorCode =
|
|
2
|
+
| 'mixer-destroyed'
|
|
3
|
+
| 'invalid-clip'
|
|
4
|
+
| 'invalid-track'
|
|
5
|
+
| 'invalid-action'
|
|
6
|
+
| 'duplicate-action-id'
|
|
7
|
+
| 'resolver-miss';
|
|
8
|
+
|
|
9
|
+
export type Animation3DErrorDetails = Readonly<Record<
|
|
10
|
+
string,
|
|
11
|
+
string | number | boolean | null
|
|
12
|
+
>>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Stable domain error for the Animation3D facade.
|
|
16
|
+
*
|
|
17
|
+
* Callers should branch on `code`; messages remain diagnostic and may gain
|
|
18
|
+
* additional context without changing the error contract.
|
|
19
|
+
*/
|
|
20
|
+
export class Animation3DError extends Error {
|
|
21
|
+
readonly code: Animation3DErrorCode;
|
|
22
|
+
readonly details: Animation3DErrorDetails;
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
code: Animation3DErrorCode,
|
|
26
|
+
message: string,
|
|
27
|
+
details: Animation3DErrorDetails = {},
|
|
28
|
+
) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = 'Animation3DError';
|
|
31
|
+
this.code = code;
|
|
32
|
+
this.details = Object.freeze({ ...details });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Animation3DBindingResolver,
|
|
3
|
+
} from './Animation3DBinding.js';
|
|
4
|
+
import type {
|
|
5
|
+
Animation3DAction,
|
|
6
|
+
Animation3DActionOptions,
|
|
7
|
+
} from './Animation3DAction.js';
|
|
8
|
+
import type { Animation3DClip } from './Animation3DClip.js';
|
|
9
|
+
import type {
|
|
10
|
+
Animation3DMutablePose,
|
|
11
|
+
Animation3DPose,
|
|
12
|
+
} from './Animation3DPose.js';
|
|
13
|
+
import { Animation3DMixerRuntime } from './runtime/mixer/Mixer.js';
|
|
14
|
+
import {
|
|
15
|
+
registerAnimation3DMixerRuntime,
|
|
16
|
+
} from './runtime/mixer/Animation3DMixerRuntimeStore.js';
|
|
17
|
+
|
|
18
|
+
export type Animation3DMixerState =
|
|
19
|
+
| 'active'
|
|
20
|
+
| 'destroyed';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Public mixer facade. Controller-only clock/transaction hooks remain on the
|
|
24
|
+
* internal runtime and are intentionally absent from this surface.
|
|
25
|
+
*/
|
|
26
|
+
export class Animation3DMixer {
|
|
27
|
+
#runtime: Animation3DMixerRuntime;
|
|
28
|
+
|
|
29
|
+
constructor(resolver: Animation3DBindingResolver) {
|
|
30
|
+
this.#runtime = new Animation3DMixerRuntime(resolver);
|
|
31
|
+
registerAnimation3DMixerRuntime(this, this.#runtime);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get state(): Animation3DMixerState { return this.#runtime.state; }
|
|
35
|
+
get resolver(): Animation3DBindingResolver { return this.#runtime.resolver; }
|
|
36
|
+
get actions(): readonly Animation3DAction[] { return this.#runtime.actions; }
|
|
37
|
+
get time(): number { return this.#runtime.time; }
|
|
38
|
+
get timeScale(): number { return this.#runtime.timeScale; }
|
|
39
|
+
set timeScale(value: number) { this.#runtime.timeScale = value; }
|
|
40
|
+
|
|
41
|
+
createAction(
|
|
42
|
+
clip: Animation3DClip,
|
|
43
|
+
options?: Animation3DActionOptions,
|
|
44
|
+
): Animation3DAction {
|
|
45
|
+
return this.#runtime.createAction(clip, options);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getAction(actionId: string): Animation3DAction | null {
|
|
49
|
+
return this.#runtime.getAction(actionId);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
removeAction(action: Animation3DAction | string): boolean {
|
|
53
|
+
return this.#runtime.removeAction(action);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
stopAllActions(): this {
|
|
57
|
+
this.#runtime.stopAllActions();
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
update(
|
|
62
|
+
deltaSeconds: number,
|
|
63
|
+
out: Animation3DMutablePose,
|
|
64
|
+
): Animation3DPose {
|
|
65
|
+
return this.#runtime.update(deltaSeconds, out);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
evaluate(out: Animation3DMutablePose): Animation3DPose {
|
|
69
|
+
return this.#runtime.evaluate(out);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setTime(
|
|
73
|
+
timeSeconds: number,
|
|
74
|
+
out: Animation3DMutablePose,
|
|
75
|
+
): Animation3DPose {
|
|
76
|
+
return this.#runtime.setTime(timeSeconds, out);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
destroy(): void {
|
|
80
|
+
this.#runtime.destroy();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Animation3DBinding,
|
|
3
|
+
Animation3DBindingResolver,
|
|
4
|
+
Animation3DResolvedBinding,
|
|
5
|
+
} from './Animation3DBinding.js';
|
|
6
|
+
import type { Animation3DEvent } from './Animation3DClip.js';
|
|
7
|
+
import { Animation3DError } from './Animation3DError.js';
|
|
8
|
+
|
|
9
|
+
export interface Animation3DPoseChannel<
|
|
10
|
+
TBinding extends Animation3DBinding = Animation3DBinding,
|
|
11
|
+
> {
|
|
12
|
+
readonly binding: TBinding;
|
|
13
|
+
/** Exactly binding.valueSize sampled and blended values. */
|
|
14
|
+
readonly value: Readonly<Float32Array>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface Animation3DPoseEvent {
|
|
18
|
+
readonly actionId: string;
|
|
19
|
+
readonly clipId: string;
|
|
20
|
+
readonly event: Animation3DEvent;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Frame-transient mixer output. Implementations may reuse its arrays on the
|
|
25
|
+
* next evaluate/update call; callers must copy values they need to retain.
|
|
26
|
+
*/
|
|
27
|
+
export interface Animation3DPose {
|
|
28
|
+
readonly sequence: number;
|
|
29
|
+
readonly mixerTime: number;
|
|
30
|
+
readonly channels: readonly Animation3DPoseChannel[];
|
|
31
|
+
readonly events: readonly Animation3DPoseEvent[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Caller-provided scratch target used to keep mixer evaluation allocation-free.
|
|
36
|
+
* reset() begins a new pose and seal() returns the current read-only view.
|
|
37
|
+
*/
|
|
38
|
+
export interface Animation3DMutablePose {
|
|
39
|
+
reset(mixerTime: number): void;
|
|
40
|
+
write(
|
|
41
|
+
binding: Animation3DBinding,
|
|
42
|
+
value: ArrayLike<number>,
|
|
43
|
+
): void;
|
|
44
|
+
emit(event: Animation3DPoseEvent): void;
|
|
45
|
+
seal(): Animation3DPose;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface Animation3DPoseApplierState {
|
|
49
|
+
readonly resolver: Animation3DBindingResolver;
|
|
50
|
+
resolverRevision: number;
|
|
51
|
+
readonly resolvedBindings: Map<
|
|
52
|
+
string,
|
|
53
|
+
Animation3DResolvedBinding | null
|
|
54
|
+
>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const POSE_APPLIER_STATES = new WeakMap<
|
|
58
|
+
Animation3DPoseApplier,
|
|
59
|
+
Animation3DPoseApplierState
|
|
60
|
+
>();
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Applies pose channels through a revision-aware binding resolver cache.
|
|
64
|
+
* Resolver misses fail explicitly and never write to a fallback target.
|
|
65
|
+
*/
|
|
66
|
+
export class Animation3DPoseApplier {
|
|
67
|
+
constructor(resolver: Animation3DBindingResolver) {
|
|
68
|
+
POSE_APPLIER_STATES.set(this, {
|
|
69
|
+
resolver,
|
|
70
|
+
resolverRevision: Number.NaN,
|
|
71
|
+
resolvedBindings: new Map(),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
apply(pose: Animation3DPose): void {
|
|
76
|
+
const state = POSE_APPLIER_STATES.get(this)!;
|
|
77
|
+
const { resolver } = state;
|
|
78
|
+
if (state.resolverRevision !== resolver.revision) {
|
|
79
|
+
state.resolverRevision = resolver.revision;
|
|
80
|
+
state.resolvedBindings.clear();
|
|
81
|
+
}
|
|
82
|
+
for (let index = 0; index < pose.channels.length; index++) {
|
|
83
|
+
const channel = pose.channels[index]!;
|
|
84
|
+
const bindingId = channel.binding.id;
|
|
85
|
+
let resolved = state.resolvedBindings.get(bindingId);
|
|
86
|
+
if (resolved === undefined && !state.resolvedBindings.has(bindingId)) {
|
|
87
|
+
resolved = resolver.resolve(channel.binding);
|
|
88
|
+
state.resolvedBindings.set(bindingId, resolved);
|
|
89
|
+
}
|
|
90
|
+
if (!resolved) {
|
|
91
|
+
throw new Animation3DError(
|
|
92
|
+
'resolver-miss',
|
|
93
|
+
`Animation3D binding resolver could not resolve "${bindingId}".`,
|
|
94
|
+
{ resolver: 'binding', bindingId },
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
resolved.write(channel.value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Animation3DBinding } from './Animation3DBinding.js';
|
|
2
|
+
import type {
|
|
3
|
+
Animation3DMutablePose,
|
|
4
|
+
Animation3DPose,
|
|
5
|
+
Animation3DPoseChannel,
|
|
6
|
+
Animation3DPoseEvent,
|
|
7
|
+
} from './Animation3DPose.js';
|
|
8
|
+
|
|
9
|
+
class ReusablePoseChannel implements Animation3DPoseChannel {
|
|
10
|
+
binding: Animation3DBinding;
|
|
11
|
+
value: Float32Array;
|
|
12
|
+
|
|
13
|
+
constructor(binding: Animation3DBinding) {
|
|
14
|
+
this.binding = binding;
|
|
15
|
+
this.value = new Float32Array(binding.valueSize);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
write(binding: Animation3DBinding, source: ArrayLike<number>): void {
|
|
19
|
+
this.binding = binding;
|
|
20
|
+
if (this.value.length !== binding.valueSize) {
|
|
21
|
+
this.value = new Float32Array(binding.valueSize);
|
|
22
|
+
}
|
|
23
|
+
for (let index = 0; index < binding.valueSize; index++) {
|
|
24
|
+
this.value[index] = source[index] ?? 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Reusable caller-owned mixer output.
|
|
31
|
+
*
|
|
32
|
+
* Channel records and value arrays are pooled after first use. seal() returns
|
|
33
|
+
* this object as the read-only pose view rather than allocating a snapshot.
|
|
34
|
+
*/
|
|
35
|
+
export class Animation3DPoseBuffer implements Animation3DMutablePose, Animation3DPose {
|
|
36
|
+
private readonly _channelPool: ReusablePoseChannel[] = [];
|
|
37
|
+
private readonly _channels: ReusablePoseChannel[] = [];
|
|
38
|
+
private readonly _events: Animation3DPoseEvent[] = [];
|
|
39
|
+
private _sequence = 0;
|
|
40
|
+
private _mixerTime = 0;
|
|
41
|
+
private _sealed = true;
|
|
42
|
+
|
|
43
|
+
get sequence(): number { return this._sequence; }
|
|
44
|
+
get mixerTime(): number { return this._mixerTime; }
|
|
45
|
+
get channels(): readonly Animation3DPoseChannel[] { return this._channels; }
|
|
46
|
+
get events(): readonly Animation3DPoseEvent[] { return this._events; }
|
|
47
|
+
|
|
48
|
+
reset(mixerTime: number): void {
|
|
49
|
+
if (!Number.isFinite(mixerTime)) {
|
|
50
|
+
throw new RangeError(`Animation3D pose mixerTime must be finite; received ${mixerTime}.`);
|
|
51
|
+
}
|
|
52
|
+
this._mixerTime = mixerTime;
|
|
53
|
+
this._channels.length = 0;
|
|
54
|
+
this._events.length = 0;
|
|
55
|
+
this._sealed = false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
write(binding: Animation3DBinding, value: ArrayLike<number>): void {
|
|
59
|
+
if (value.length < binding.valueSize) {
|
|
60
|
+
throw new RangeError(
|
|
61
|
+
`Animation3D pose channel "${binding.id}" requires ${binding.valueSize} values; received ${value.length}.`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const index = this._channels.length;
|
|
65
|
+
let channel = this._channelPool[index];
|
|
66
|
+
if (!channel) {
|
|
67
|
+
channel = new ReusablePoseChannel(binding);
|
|
68
|
+
this._channelPool.push(channel);
|
|
69
|
+
}
|
|
70
|
+
channel.write(binding, value);
|
|
71
|
+
this._channels.push(channel);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
emit(event: Animation3DPoseEvent): void {
|
|
75
|
+
this._events.push(event);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
seal(): Animation3DPose {
|
|
79
|
+
if (!this._sealed) {
|
|
80
|
+
this._sequence++;
|
|
81
|
+
this._sealed = true;
|
|
82
|
+
}
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
}
|