@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,168 @@
|
|
|
1
|
+
import type { Scene } from '@haiyue/engine';
|
|
2
|
+
import type { ParticleEmitter3DOptions } from '@haiyue/engine/components';
|
|
3
|
+
import type { PbrMaterial } from '@haiyue/engine/material';
|
|
4
|
+
import type { LoadedGltfModel, LoadGltfOptions } from '../../gltf/GltfLoaderContract';
|
|
5
|
+
import type { Animation3DActionOptions } from '../Animation3DAction';
|
|
6
|
+
import type { Animation3DBinding } from '../Animation3DBinding';
|
|
7
|
+
import type { Animation3DEvent } from '../Animation3DClip';
|
|
8
|
+
import type { Animation3DStateMachineDefinition } from '../Animation3DStateMachine';
|
|
9
|
+
|
|
10
|
+
export interface HyaAnimation3DResource {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly type: 'image' | 'audio' | 'binary';
|
|
13
|
+
readonly uri: string;
|
|
14
|
+
readonly mimeType?: string;
|
|
15
|
+
readonly integrity?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface HyaAnimation3DMaterialDescriptor {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly baseColorFactor: readonly [number, number, number, number];
|
|
22
|
+
readonly metallicFactor: number;
|
|
23
|
+
readonly roughnessFactor: number;
|
|
24
|
+
readonly emissiveFactor: readonly [number, number, number];
|
|
25
|
+
readonly alphaMode: 'opaque' | 'mask' | 'blend';
|
|
26
|
+
readonly alphaCutoff?: number;
|
|
27
|
+
readonly doubleSided: boolean;
|
|
28
|
+
readonly baseColorTexture?: string;
|
|
29
|
+
readonly normalTexture?: string;
|
|
30
|
+
readonly metallicRoughnessTexture?: string;
|
|
31
|
+
readonly emissiveTexture?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface HyaAnimation3DTransformDescriptor {
|
|
35
|
+
readonly translation: readonly [number, number, number];
|
|
36
|
+
readonly rotation: readonly [number, number, number, number];
|
|
37
|
+
readonly scale: readonly [number, number, number];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type HyaAnimation3DCameraProjection =
|
|
41
|
+
| Readonly<{ kind: 'perspective'; fovYRadians: number; near: number; far: number }>
|
|
42
|
+
| Readonly<{ kind: 'orthographic'; orthoHeight: number; near: number; far: number }>;
|
|
43
|
+
|
|
44
|
+
export type HyaAnimation3DComponentDescriptor =
|
|
45
|
+
| Readonly<{ id: string; kind: 'camera3d'; projection: HyaAnimation3DCameraProjection }>
|
|
46
|
+
| Readonly<{
|
|
47
|
+
id: string;
|
|
48
|
+
kind: 'primitive3d';
|
|
49
|
+
primitive: 'box' | 'sphere' | 'plane' | 'cylinder' | 'cone';
|
|
50
|
+
materialId: string;
|
|
51
|
+
}>
|
|
52
|
+
| Readonly<{
|
|
53
|
+
id: string;
|
|
54
|
+
kind: 'model3d';
|
|
55
|
+
resource: string;
|
|
56
|
+
materialOverrides?: readonly Readonly<{ slot: string; materialId: string }>[];
|
|
57
|
+
}>
|
|
58
|
+
| Readonly<{ id: string; kind: 'particle3d'; descriptor: ParticleEmitter3DOptions & Readonly<{ textureResource?: string }> }>;
|
|
59
|
+
|
|
60
|
+
export interface HyaAnimation3DNodeDescriptor {
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly parent?: string;
|
|
64
|
+
readonly start?: number;
|
|
65
|
+
readonly duration?: number;
|
|
66
|
+
readonly transform: HyaAnimation3DTransformDescriptor;
|
|
67
|
+
readonly components: readonly HyaAnimation3DComponentDescriptor[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface HyaAnimation3DClipDescriptor {
|
|
71
|
+
readonly format: 'haiyue-animation3d-clip@1';
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly name: string;
|
|
74
|
+
readonly duration: number;
|
|
75
|
+
readonly tracks: readonly Readonly<{
|
|
76
|
+
id: string;
|
|
77
|
+
binding: Animation3DBinding;
|
|
78
|
+
interpolation: 'step' | 'linear' | 'cubic-spline';
|
|
79
|
+
times: ArrayLike<number>;
|
|
80
|
+
values: ArrayLike<number>;
|
|
81
|
+
}>[];
|
|
82
|
+
readonly events: readonly Animation3DEvent[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Runtime port implemented by the validated animation-spec payload. */
|
|
86
|
+
export interface HyaAnimation3DPayload {
|
|
87
|
+
readonly format: 'haiyue-animation-3d@1';
|
|
88
|
+
readonly mode: 'native-3d';
|
|
89
|
+
readonly viewport: Readonly<{ width: number; height: number }>;
|
|
90
|
+
readonly materials: readonly HyaAnimation3DMaterialDescriptor[];
|
|
91
|
+
readonly nodes: readonly HyaAnimation3DNodeDescriptor[];
|
|
92
|
+
readonly clips: readonly HyaAnimation3DClipDescriptor[];
|
|
93
|
+
readonly stateMachine?: Animation3DStateMachineDefinition | null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface HyaAnimation3DRuntimeOptions {
|
|
97
|
+
readonly scene: Scene;
|
|
98
|
+
/** Payload returned by animation-spec native3d validation. */
|
|
99
|
+
readonly payload: HyaAnimation3DPayload;
|
|
100
|
+
readonly resources: readonly HyaAnimation3DResource[];
|
|
101
|
+
readonly signal?: AbortSignal;
|
|
102
|
+
readonly useAuthoredCamera?: boolean;
|
|
103
|
+
readonly addPreviewLights?: boolean;
|
|
104
|
+
readonly loadModel?: (uri: string, options: LoadGltfOptions) => Promise<LoadedGltfModel>;
|
|
105
|
+
readonly disposeModel?: (model: LoadedGltfModel) => void;
|
|
106
|
+
readonly resolveTexture?: (
|
|
107
|
+
resource: HyaAnimation3DResource,
|
|
108
|
+
material: PbrMaterial | null,
|
|
109
|
+
) => ParticleEmitter3DOptions['textureSource'] | null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface HyaAnimation3DPlayOptions extends Animation3DActionOptions {
|
|
113
|
+
readonly fadeFrom?: HyaAnimation3DActionGroup;
|
|
114
|
+
readonly fadeDuration?: number;
|
|
115
|
+
readonly warp?: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface HyaAnimation3DActionGroup {
|
|
119
|
+
readonly id: string;
|
|
120
|
+
readonly clipId: string;
|
|
121
|
+
readonly actionCount: number;
|
|
122
|
+
readonly playing: boolean;
|
|
123
|
+
play(): this;
|
|
124
|
+
stop(): this;
|
|
125
|
+
reset(): this;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface HyaAnimation3DRuntimeDiagnostics {
|
|
129
|
+
readonly state: 'active' | 'destroyed';
|
|
130
|
+
readonly entityCount: number;
|
|
131
|
+
readonly materialCount: number;
|
|
132
|
+
readonly modelCount: number;
|
|
133
|
+
readonly actionGroupCount: number;
|
|
134
|
+
readonly ownerResidualCount: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface HyaAnimation3DStateMachineLayerSnapshot {
|
|
138
|
+
readonly layerId: string;
|
|
139
|
+
readonly currentStateId: string;
|
|
140
|
+
readonly currentTime: number;
|
|
141
|
+
readonly transitionId: string | null;
|
|
142
|
+
readonly sourceStateId: string | null;
|
|
143
|
+
readonly destinationStateId: string | null;
|
|
144
|
+
readonly transitionProgress: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Stable parameter/query port for the runtime's unique state-machine clock. */
|
|
148
|
+
export interface HyaAnimation3DStateMachineController {
|
|
149
|
+
readonly status: 'active' | 'destroyed';
|
|
150
|
+
readonly layerSnapshots: readonly HyaAnimation3DStateMachineLayerSnapshot[];
|
|
151
|
+
getLayerSnapshot(layerId: string): HyaAnimation3DStateMachineLayerSnapshot;
|
|
152
|
+
setFloat(name: string, value: number): this;
|
|
153
|
+
setInteger(name: string, value: number): this;
|
|
154
|
+
setBoolean(name: string, value: boolean): this;
|
|
155
|
+
setTrigger(name: string): this;
|
|
156
|
+
resetTrigger(name: string): this;
|
|
157
|
+
getParameter(name: string): number | boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Stable lifecycle and diagnostic view of the HYA state-machine owner. */
|
|
161
|
+
export interface HyaAnimation3DStateMachineRuntimeControl {
|
|
162
|
+
readonly controller: HyaAnimation3DStateMachineController;
|
|
163
|
+
readonly time: number;
|
|
164
|
+
readonly liveActionCount: number;
|
|
165
|
+
readonly liveBindingCount: number;
|
|
166
|
+
readonly sideEffectOwnerCount: number;
|
|
167
|
+
reset(): void;
|
|
168
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { HyaAnimation3DRuntime, createHyaAnimation3DRuntime } from './HyaAnimation3DRuntime';
|
|
2
|
+
export {
|
|
3
|
+
HyaAnimation3DStateMachineRuntime,
|
|
4
|
+
} from './HyaAnimation3DStateMachineRuntime';
|
|
5
|
+
export type {
|
|
6
|
+
HyaAnimation3DParticleCue,
|
|
7
|
+
HyaAnimation3DStateMachinePartition,
|
|
8
|
+
HyaAnimation3DStateMachineRuntimeOptions,
|
|
9
|
+
} from './HyaAnimation3DStateMachineRuntime';
|
|
10
|
+
export type * from './HyaAnimation3DTypes';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
Animation3DBinding,
|
|
3
|
+
Animation3DBindingMask,
|
|
4
|
+
Animation3DBindingResolver,
|
|
5
|
+
Animation3DBindingTarget,
|
|
6
|
+
Animation3DFixedValueSize,
|
|
7
|
+
Animation3DFixedValueType,
|
|
8
|
+
Animation3DMorphWeightsBinding,
|
|
9
|
+
Animation3DPropertyBinding,
|
|
10
|
+
Animation3DResolvedBinding,
|
|
11
|
+
Animation3DRotationBinding,
|
|
12
|
+
Animation3DScaleBinding,
|
|
13
|
+
Animation3DTranslationBinding,
|
|
14
|
+
Animation3DValueType,
|
|
15
|
+
} from './Animation3DBinding.js';
|
|
16
|
+
export type {
|
|
17
|
+
Animation3DInterpolation,
|
|
18
|
+
Animation3DTrack,
|
|
19
|
+
Animation3DTrackFor,
|
|
20
|
+
} from './Animation3DTrack.js';
|
|
21
|
+
export type {
|
|
22
|
+
Animation3DClip,
|
|
23
|
+
Animation3DEvent,
|
|
24
|
+
} from './Animation3DClip.js';
|
|
25
|
+
export type {
|
|
26
|
+
Animation3DMutablePose,
|
|
27
|
+
Animation3DPose,
|
|
28
|
+
Animation3DPoseChannel,
|
|
29
|
+
Animation3DPoseEvent,
|
|
30
|
+
} from './Animation3DPose.js';
|
|
31
|
+
export { Animation3DPoseApplier } from './Animation3DPose.js';
|
|
32
|
+
export { Animation3DPoseBuffer } from './Animation3DPoseBuffer.js';
|
|
33
|
+
export type {
|
|
34
|
+
Animation3DAction,
|
|
35
|
+
Animation3DActionOptions,
|
|
36
|
+
Animation3DActionStatus,
|
|
37
|
+
Animation3DBlendMode,
|
|
38
|
+
Animation3DLoopMode,
|
|
39
|
+
} from './Animation3DAction.js';
|
|
40
|
+
export { Animation3DMixer } from './Animation3DMixer.js';
|
|
41
|
+
export type { Animation3DMixerState } from './Animation3DMixer.js';
|
|
42
|
+
export { Animation3DError } from './Animation3DError.js';
|
|
43
|
+
export type {
|
|
44
|
+
Animation3DErrorCode,
|
|
45
|
+
Animation3DErrorDetails,
|
|
46
|
+
} from './Animation3DError.js';
|
|
47
|
+
export type {
|
|
48
|
+
Animation3DBlend1DChild,
|
|
49
|
+
Animation3DBlend1DMotion,
|
|
50
|
+
Animation3DBlend2DChild,
|
|
51
|
+
Animation3DBlend2DMotion,
|
|
52
|
+
Animation3DClipMotion,
|
|
53
|
+
Animation3DMotionDefinition,
|
|
54
|
+
Animation3DParameterDefinition,
|
|
55
|
+
Animation3DStateDefinition,
|
|
56
|
+
Animation3DStateMachineDefinition,
|
|
57
|
+
Animation3DStateMachineLayer,
|
|
58
|
+
Animation3DTransitionCondition,
|
|
59
|
+
Animation3DTransitionDefinition,
|
|
60
|
+
Animation3DTransitionInterruption,
|
|
61
|
+
} from './Animation3DStateMachine.js';
|
|
62
|
+
export {
|
|
63
|
+
Animation3DStateMachineController,
|
|
64
|
+
Animation3DStateMachineValidationError,
|
|
65
|
+
compileAnimation3DStateMachineDefinition,
|
|
66
|
+
validateAnimation3DStateMachineDefinition,
|
|
67
|
+
} from './Animation3DStateMachineRuntime.js';
|
|
68
|
+
export type {
|
|
69
|
+
Animation3DCompiledStateMachine,
|
|
70
|
+
Animation3DStateMachineClipResolver,
|
|
71
|
+
Animation3DStateMachineControllerOptions,
|
|
72
|
+
Animation3DStateMachineControllerStatus,
|
|
73
|
+
Animation3DStateMachineLayerSnapshot,
|
|
74
|
+
Animation3DStateMachineValidationCode,
|
|
75
|
+
Animation3DStateMachineValidationIssue,
|
|
76
|
+
} from './Animation3DStateMachineRuntime.js';
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import type { Animation3DClip } from '../../Animation3DClip.js';
|
|
2
|
+
import { Animation3DError } from '../../Animation3DError.js';
|
|
3
|
+
import type { Animation3DMutablePose } from '../../Animation3DPose.js';
|
|
4
|
+
import type {
|
|
5
|
+
AnimationStateMachineActionOptions,
|
|
6
|
+
AnimationStateMachineMixerPort,
|
|
7
|
+
} from '../../../animation-state-machine/runtime/AnimationStateMachineMixerPort.js';
|
|
8
|
+
import {
|
|
9
|
+
Animation3DActionRuntime,
|
|
10
|
+
type Animation3DActionSynchronizedState,
|
|
11
|
+
} from '../mixer/Action.js';
|
|
12
|
+
import { Animation3DMixerRuntime } from '../mixer/Mixer.js';
|
|
13
|
+
|
|
14
|
+
let nextAdapterId = 1;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the serializable clip ids stored in state-machine definitions.
|
|
18
|
+
* Returned clips remain resolver/caller-owned.
|
|
19
|
+
*/
|
|
20
|
+
export interface Animation3DStateMachineClipResolver {
|
|
21
|
+
resolve(clipId: string): Animation3DClip | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class Animation3DStateMachineActionRuntimeHandle {
|
|
25
|
+
readonly duration: number;
|
|
26
|
+
readonly clipId: string;
|
|
27
|
+
readonly layerId: string;
|
|
28
|
+
readonly stateId: string;
|
|
29
|
+
readonly action: Animation3DActionRuntime;
|
|
30
|
+
|
|
31
|
+
targetTime = 0;
|
|
32
|
+
appliedTime = 0;
|
|
33
|
+
playing = false;
|
|
34
|
+
destroyed = false;
|
|
35
|
+
pendingDestroy = false;
|
|
36
|
+
|
|
37
|
+
private readonly _actionCheckpoint: Animation3DActionSynchronizedState;
|
|
38
|
+
private _checkpointTargetTime = 0;
|
|
39
|
+
private _checkpointAppliedTime = 0;
|
|
40
|
+
private _checkpointPlaying = false;
|
|
41
|
+
|
|
42
|
+
constructor(
|
|
43
|
+
clipId: string,
|
|
44
|
+
options: AnimationStateMachineActionOptions,
|
|
45
|
+
action: Animation3DActionRuntime,
|
|
46
|
+
) {
|
|
47
|
+
this.duration = action.clip.duration;
|
|
48
|
+
this.clipId = clipId;
|
|
49
|
+
this.layerId = options.layerId;
|
|
50
|
+
this.stateId = options.stateId;
|
|
51
|
+
this.action = action;
|
|
52
|
+
this._actionCheckpoint = action.createSynchronizedState();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
captureTransactionState(): void {
|
|
56
|
+
this._checkpointTargetTime = this.targetTime;
|
|
57
|
+
this._checkpointAppliedTime = this.appliedTime;
|
|
58
|
+
this._checkpointPlaying = this.playing;
|
|
59
|
+
this.action.captureSynchronizedState(this._actionCheckpoint);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
restoreTransactionState(): void {
|
|
63
|
+
this.targetTime = this._checkpointTargetTime;
|
|
64
|
+
this.appliedTime = this._checkpointAppliedTime;
|
|
65
|
+
this.playing = this._checkpointPlaying;
|
|
66
|
+
this.pendingDestroy = false;
|
|
67
|
+
this.action.restoreSynchronizedState(this._actionCheckpoint);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Adapts the dimension-neutral state-machine port to the real 3D mixer.
|
|
73
|
+
*
|
|
74
|
+
* The controller owns every action playhead. The adapter applies its absolute
|
|
75
|
+
* times to actions while a synchronized mixer frame is open; it never calls
|
|
76
|
+
* mixer.update(), so the mixer clock cannot advance the same actions again.
|
|
77
|
+
*/
|
|
78
|
+
export class Animation3DStateMachineMixerAdapter implements
|
|
79
|
+
AnimationStateMachineMixerPort<Animation3DStateMachineActionRuntimeHandle> {
|
|
80
|
+
readonly mixer: Animation3DMixerRuntime;
|
|
81
|
+
readonly clipResolver: Animation3DStateMachineClipResolver;
|
|
82
|
+
|
|
83
|
+
private readonly _handles = new Set<Animation3DStateMachineActionRuntimeHandle>();
|
|
84
|
+
private readonly _transactionHandles: Animation3DStateMachineActionRuntimeHandle[] = [];
|
|
85
|
+
private readonly _transactionCreated: Animation3DStateMachineActionRuntimeHandle[] = [];
|
|
86
|
+
private readonly _transactionPendingDestroy: Animation3DStateMachineActionRuntimeHandle[] = [];
|
|
87
|
+
private readonly _actionIdPrefix: string;
|
|
88
|
+
private _nextActionId = 1;
|
|
89
|
+
private _transactionNextActionId = 1;
|
|
90
|
+
private _frameOut: Animation3DMutablePose | null = null;
|
|
91
|
+
private _controllerTransactionActive = false;
|
|
92
|
+
private _destroyed = false;
|
|
93
|
+
|
|
94
|
+
constructor(
|
|
95
|
+
mixer: Animation3DMixerRuntime,
|
|
96
|
+
clipResolver: Animation3DStateMachineClipResolver,
|
|
97
|
+
) {
|
|
98
|
+
this.mixer = mixer;
|
|
99
|
+
this.clipResolver = clipResolver;
|
|
100
|
+
this._actionIdPrefix = `animation3d-state-machine:${nextAdapterId++}`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
get liveActionCount(): number {
|
|
104
|
+
return this._handles.size;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
createAction(
|
|
108
|
+
clipId: string,
|
|
109
|
+
options: AnimationStateMachineActionOptions,
|
|
110
|
+
): Animation3DStateMachineActionRuntimeHandle {
|
|
111
|
+
this._requireActive();
|
|
112
|
+
const clip = this.clipResolver.resolve(clipId);
|
|
113
|
+
if (!clip) {
|
|
114
|
+
throw new Animation3DError(
|
|
115
|
+
'resolver-miss',
|
|
116
|
+
`Animation3D clip resolver could not resolve "${clipId}".`,
|
|
117
|
+
{ resolver: 'clip', clipId },
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
const action = this.mixer.createAction(clip, {
|
|
121
|
+
id: `${this._actionIdPrefix}:${this._nextActionId++}`,
|
|
122
|
+
loop: options.loop,
|
|
123
|
+
repetitions: options.loop === 'once' ? 1 : Infinity,
|
|
124
|
+
clampWhenFinished: true,
|
|
125
|
+
weight: 0,
|
|
126
|
+
blendMode: options.blendMode,
|
|
127
|
+
...(options.mask ? { mask: options.mask } : {}),
|
|
128
|
+
}) as Animation3DActionRuntime;
|
|
129
|
+
const handle = new Animation3DStateMachineActionRuntimeHandle(
|
|
130
|
+
clipId,
|
|
131
|
+
options,
|
|
132
|
+
action,
|
|
133
|
+
);
|
|
134
|
+
this._handles.add(handle);
|
|
135
|
+
if (this._controllerTransactionActive) this._transactionCreated.push(handle);
|
|
136
|
+
return handle;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
play(action: Animation3DStateMachineActionRuntimeHandle): void {
|
|
140
|
+
this._requireHandle(action);
|
|
141
|
+
action.action.play();
|
|
142
|
+
action.playing = true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
stop(action: Animation3DStateMachineActionRuntimeHandle): void {
|
|
146
|
+
this._requireHandle(action);
|
|
147
|
+
action.action.stop();
|
|
148
|
+
action.playing = false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
fade(
|
|
152
|
+
action: Animation3DStateMachineActionRuntimeHandle,
|
|
153
|
+
_targetWeight: number,
|
|
154
|
+
_durationSeconds: number,
|
|
155
|
+
): void {
|
|
156
|
+
this._requireHandle(action);
|
|
157
|
+
// The controller computes exact source/destination weights for every
|
|
158
|
+
// transition segment. Scheduling an action-local fade here would multiply
|
|
159
|
+
// that weight and introduce a second transition clock.
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
setWeight(
|
|
163
|
+
action: Animation3DStateMachineActionRuntimeHandle,
|
|
164
|
+
weight: number,
|
|
165
|
+
): void {
|
|
166
|
+
this._requireHandle(action);
|
|
167
|
+
action.action.weight = weight;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
setTime(
|
|
171
|
+
action: Animation3DStateMachineActionRuntimeHandle,
|
|
172
|
+
timeSeconds: number,
|
|
173
|
+
): void {
|
|
174
|
+
this._requireHandle(action);
|
|
175
|
+
action.targetTime = timeSeconds;
|
|
176
|
+
if (!action.playing) {
|
|
177
|
+
action.action.seekSynchronizedTime(timeSeconds);
|
|
178
|
+
action.appliedTime = timeSeconds;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (this._frameOut) this._applyTime(action, this._frameOut);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setTimeScale(
|
|
185
|
+
action: Animation3DStateMachineActionRuntimeHandle,
|
|
186
|
+
timeScale: number,
|
|
187
|
+
): void {
|
|
188
|
+
this._requireHandle(action);
|
|
189
|
+
action.action.timeScale = timeScale;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
destroyAction(action: Animation3DStateMachineActionRuntimeHandle): void {
|
|
193
|
+
if (action.destroyed) return;
|
|
194
|
+
if (!this._handles.has(action)) {
|
|
195
|
+
throw new Error('Animation3D state-machine action belongs to another adapter.');
|
|
196
|
+
}
|
|
197
|
+
if (this._controllerTransactionActive) {
|
|
198
|
+
if (action.pendingDestroy) return;
|
|
199
|
+
action.pendingDestroy = true;
|
|
200
|
+
this._transactionPendingDestroy.push(action);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this._destroyHandleNow(action);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** @internal Called by the shared controller transaction boundary. */
|
|
207
|
+
beginControllerTransaction(): void {
|
|
208
|
+
this._requireActive();
|
|
209
|
+
if (this._controllerTransactionActive) {
|
|
210
|
+
throw new Error('Animation3D state-machine adapter transaction is already active.');
|
|
211
|
+
}
|
|
212
|
+
this._controllerTransactionActive = true;
|
|
213
|
+
this._transactionNextActionId = this._nextActionId;
|
|
214
|
+
this._transactionHandles.length = 0;
|
|
215
|
+
this._transactionCreated.length = 0;
|
|
216
|
+
this._transactionPendingDestroy.length = 0;
|
|
217
|
+
for (const handle of this._handles) {
|
|
218
|
+
handle.captureTransactionState();
|
|
219
|
+
this._transactionHandles.push(handle);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** @internal Makes deferred action destruction observable atomically. */
|
|
224
|
+
commitControllerTransaction(): void {
|
|
225
|
+
if (!this._controllerTransactionActive) {
|
|
226
|
+
throw new Error('Animation3D state-machine adapter has no active transaction.');
|
|
227
|
+
}
|
|
228
|
+
this._controllerTransactionActive = false;
|
|
229
|
+
for (let index = 0; index < this._transactionPendingDestroy.length; index++) {
|
|
230
|
+
this._destroyHandleNow(this._transactionPendingDestroy[index]!);
|
|
231
|
+
}
|
|
232
|
+
this._clearControllerTransaction();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** @internal Removes new actions and restores exact event/playhead state. */
|
|
236
|
+
rollbackControllerTransaction(): void {
|
|
237
|
+
if (!this._controllerTransactionActive) return;
|
|
238
|
+
this._controllerTransactionActive = false;
|
|
239
|
+
for (let index = this._transactionCreated.length - 1; index >= 0; index--) {
|
|
240
|
+
this._destroyHandleNow(this._transactionCreated[index]!);
|
|
241
|
+
}
|
|
242
|
+
for (let index = 0; index < this._transactionHandles.length; index++) {
|
|
243
|
+
const handle = this._transactionHandles[index]!;
|
|
244
|
+
if (!handle.destroyed) handle.restoreTransactionState();
|
|
245
|
+
}
|
|
246
|
+
this._nextActionId = this._transactionNextActionId;
|
|
247
|
+
this._clearControllerTransaction();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
beginFrame(out: Animation3DMutablePose): void {
|
|
251
|
+
this._requireActive();
|
|
252
|
+
if (this._frameOut) {
|
|
253
|
+
throw new Error('Animation3D state-machine adapter already has an active frame.');
|
|
254
|
+
}
|
|
255
|
+
this._frameOut = out;
|
|
256
|
+
for (const handle of this._handles) {
|
|
257
|
+
if (handle.playing) this._applyTime(handle, out);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
endFrame(out: Animation3DMutablePose): void {
|
|
262
|
+
if (this._frameOut !== out) {
|
|
263
|
+
throw new Error('Animation3D state-machine adapter output does not match its active frame.');
|
|
264
|
+
}
|
|
265
|
+
this._frameOut = null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
cancelFrame(out: Animation3DMutablePose): void {
|
|
269
|
+
if (this._frameOut === out) this._frameOut = null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Releases adapter-created actions only. The mixer, clips, and clip resolver
|
|
274
|
+
* are externally owned and are never destroyed by this adapter.
|
|
275
|
+
*/
|
|
276
|
+
destroy(): void {
|
|
277
|
+
if (this._destroyed) return;
|
|
278
|
+
this.rollbackControllerTransaction();
|
|
279
|
+
this._frameOut = null;
|
|
280
|
+
for (const handle of this._handles) this._destroyHandleNow(handle);
|
|
281
|
+
this._destroyed = true;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private _applyTime(
|
|
285
|
+
handle: Animation3DStateMachineActionRuntimeHandle,
|
|
286
|
+
out: Animation3DMutablePose,
|
|
287
|
+
): void {
|
|
288
|
+
handle.action.synchronizeTime(handle.targetTime, out);
|
|
289
|
+
handle.appliedTime = handle.targetTime;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private _destroyHandleNow(action: Animation3DStateMachineActionRuntimeHandle): void {
|
|
293
|
+
if (action.destroyed) return;
|
|
294
|
+
if (action.playing) action.action.stop();
|
|
295
|
+
this.mixer.removeAction(action.action);
|
|
296
|
+
action.playing = false;
|
|
297
|
+
action.pendingDestroy = false;
|
|
298
|
+
action.destroyed = true;
|
|
299
|
+
this._handles.delete(action);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private _clearControllerTransaction(): void {
|
|
303
|
+
for (let index = 0; index < this._transactionPendingDestroy.length; index++) {
|
|
304
|
+
this._transactionPendingDestroy[index]!.pendingDestroy = false;
|
|
305
|
+
}
|
|
306
|
+
this._transactionHandles.length = 0;
|
|
307
|
+
this._transactionCreated.length = 0;
|
|
308
|
+
this._transactionPendingDestroy.length = 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private _requireActive(): void {
|
|
312
|
+
if (this._destroyed) {
|
|
313
|
+
throw new Error('Animation3D state-machine mixer adapter has been destroyed.');
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
private _requireHandle(
|
|
318
|
+
handle: Animation3DStateMachineActionRuntimeHandle,
|
|
319
|
+
): void {
|
|
320
|
+
this._requireActive();
|
|
321
|
+
if (handle.destroyed || !this._handles.has(handle)) {
|
|
322
|
+
throw new Error('Animation3D state-machine action is no longer valid.');
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|