@needle-tools/engine 5.1.0-alpha.3 → 5.1.0-alpha.5
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/CHANGELOG.md +68 -0
- package/SKILL.md +4 -1
- package/components.needle.json +1 -1
- package/dist/{needle-engine.bundle-DF01sSGQ.js → needle-engine.bundle-C-LG00ZZ.js} +10681 -10100
- package/dist/needle-engine.bundle-D7tzaiYE.min.js +1733 -0
- package/dist/{needle-engine.bundle-C-ixARur.umd.cjs → needle-engine.bundle-OPkPmdUM.umd.cjs} +161 -161
- package/dist/needle-engine.d.ts +1349 -317
- package/dist/needle-engine.js +556 -555
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/three.js +1 -0
- package/dist/three.min.js +21 -21
- package/dist/three.umd.cjs +16 -16
- package/lib/engine/api.d.ts +5 -0
- package/lib/engine/api.js +4 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +10 -18
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_camera.fit.js +16 -4
- package/lib/engine/engine_camera.fit.js.map +1 -1
- package/lib/engine/engine_context.d.ts +20 -7
- package/lib/engine/engine_context.js +31 -15
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_context_eventbus.d.ts +47 -0
- package/lib/engine/engine_context_eventbus.js +47 -0
- package/lib/engine/engine_context_eventbus.js.map +1 -0
- package/lib/engine/engine_disposable.d.ts +172 -0
- package/lib/engine/engine_disposable.js +136 -0
- package/lib/engine/engine_disposable.js.map +1 -0
- package/lib/engine/engine_gameobject.d.ts +1 -10
- package/lib/engine/engine_gameobject.js +20 -118
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js +7 -69
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_input.d.ts +23 -4
- package/lib/engine/engine_input.js +2 -1
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
- package/lib/engine/engine_instantiate_resolve.js +372 -0
- package/lib/engine/engine_instantiate_resolve.js.map +1 -0
- package/lib/engine/engine_mainloop_utils.js +2 -2
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +51 -37
- package/lib/engine/engine_networking.js +132 -82
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
- package/lib/engine/engine_networking.transport.websocket.js +38 -0
- package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
- package/lib/engine/engine_networking_instantiate.js +2 -2
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_networking_types.d.ts +39 -1
- package/lib/engine/engine_networking_types.js +7 -0
- package/lib/engine/engine_networking_types.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +21 -3
- package/lib/engine/engine_physics_rapier.js +94 -25
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.js +1 -5
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/engine_serialization_core.d.ts +1 -0
- package/lib/engine/engine_serialization_core.js +7 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_types.d.ts +29 -11
- package/lib/engine/engine_types.js +1 -1
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_util_decorator.js +7 -2
- package/lib/engine/engine_util_decorator.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js +19 -5
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine-components/AnimationBuilder.d.ts +158 -0
- package/lib/engine-components/AnimationBuilder.js +305 -0
- package/lib/engine-components/AnimationBuilder.js.map +1 -0
- package/lib/engine-components/Animator.d.ts +6 -0
- package/lib/engine-components/Animator.js +23 -13
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.builder.d.ts +191 -0
- package/lib/engine-components/AnimatorController.builder.js +263 -0
- package/lib/engine-components/AnimatorController.builder.js.map +1 -0
- package/lib/engine-components/AnimatorController.d.ts +2 -119
- package/lib/engine-components/AnimatorController.js +33 -232
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +18 -9
- package/lib/engine-components/Collider.js +61 -14
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +72 -9
- package/lib/engine-components/Component.js +114 -10
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/ContactShadows.d.ts +1 -0
- package/lib/engine-components/ContactShadows.js +14 -1
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/lib/engine-components/DragControls.js +0 -7
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.js +3 -0
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/EventList.d.ts +31 -9
- package/lib/engine-components/EventList.js +37 -76
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/Joints.d.ts +4 -2
- package/lib/engine-components/Joints.js +19 -3
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/Light.js +9 -1
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +0 -2
- package/lib/engine-components/OrbitControls.js +14 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +12 -4
- package/lib/engine-components/RigidBody.js +18 -4
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.js +3 -0
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/api.d.ts +2 -1
- package/lib/engine-components/api.js +2 -1
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +7 -13
- package/lib/engine-components/codegen/components.js +7 -13
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
- package/lib/engine-components/timeline/PlayableDirector.d.ts +21 -11
- package/lib/engine-components/timeline/PlayableDirector.js +75 -67
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
- package/lib/engine-components/timeline/SignalAsset.js +1 -0
- package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
- package/lib/engine-components/timeline/TimelineBuilder.d.ts +413 -0
- package/lib/engine-components/timeline/TimelineBuilder.js +506 -0
- package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
- package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
- package/lib/engine-components/timeline/TimelineModels.js +3 -0
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.d.ts +37 -6
- package/lib/engine-components/timeline/TimelineTracks.js +92 -26
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/timeline/index.d.ts +2 -1
- package/lib/engine-components/timeline/index.js +2 -0
- package/lib/engine-components/timeline/index.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +0 -1
- package/lib/engine-components/web/CursorFollow.js +0 -1
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/package.json +2 -83
- package/plugins/common/cloud.js +6 -1
- package/plugins/common/license.js +5 -2
- package/plugins/common/worker.js +9 -4
- package/plugins/vite/dependencies.js +1 -11
- package/plugins/vite/dependency-watcher.js +2 -2
- package/plugins/vite/editor-connection.js +3 -3
- package/plugins/vite/license.js +19 -1
- package/plugins/vite/reload.js +1 -1
- package/plugins/vite/server.js +2 -1
- package/src/engine/api.ts +7 -0
- package/src/engine/codegen/register_types.ts +10 -18
- package/src/engine/engine_camera.fit.ts +15 -4
- package/src/engine/engine_context.ts +32 -16
- package/src/engine/engine_context_eventbus.ts +73 -0
- package/src/engine/engine_disposable.ts +214 -0
- package/src/engine/engine_gameobject.ts +52 -157
- package/src/engine/engine_gltf_builtin_components.ts +7 -76
- package/src/engine/engine_input.ts +27 -6
- package/src/engine/engine_instantiate_resolve.ts +407 -0
- package/src/engine/engine_mainloop_utils.ts +2 -2
- package/src/engine/engine_networking.transport.websocket.ts +45 -0
- package/src/engine/engine_networking.ts +161 -137
- package/src/engine/engine_networking_instantiate.ts +2 -2
- package/src/engine/engine_networking_types.ts +41 -1
- package/src/engine/engine_physics_rapier.ts +102 -33
- package/src/engine/engine_serialization_builtin_serializer.ts +1 -6
- package/src/engine/engine_serialization_core.ts +9 -0
- package/src/engine/engine_types.ts +46 -27
- package/src/engine/engine_util_decorator.ts +7 -2
- package/src/engine/engine_utils.ts +16 -5
- package/src/engine-components/AnimationBuilder.ts +472 -0
- package/src/engine-components/Animator.ts +24 -12
- package/src/engine-components/AnimatorController.builder.ts +387 -0
- package/src/engine-components/AnimatorController.ts +20 -291
- package/src/engine-components/Collider.ts +66 -18
- package/src/engine-components/Component.ts +118 -20
- package/src/engine-components/ContactShadows.ts +15 -1
- package/src/engine-components/DragControls.ts +0 -9
- package/src/engine-components/DropListener.ts +3 -0
- package/src/engine-components/EventList.ts +45 -83
- package/src/engine-components/Joints.ts +20 -4
- package/src/engine-components/Light.ts +10 -2
- package/src/engine-components/OrbitControls.ts +16 -5
- package/src/engine-components/RigidBody.ts +18 -4
- package/src/engine-components/SceneSwitcher.ts +3 -0
- package/src/engine-components/api.ts +2 -1
- package/src/engine-components/codegen/components.ts +7 -13
- package/src/engine-components/timeline/PlayableDirector.ts +83 -81
- package/src/engine-components/timeline/SignalAsset.ts +4 -1
- package/src/engine-components/timeline/TimelineBuilder.ts +824 -0
- package/src/engine-components/timeline/TimelineModels.ts +5 -1
- package/src/engine-components/timeline/TimelineTracks.ts +96 -27
- package/src/engine-components/timeline/index.ts +2 -1
- package/src/engine-components/web/CursorFollow.ts +0 -1
- package/dist/needle-engine.bundle-CHmXdnE1.min.js +0 -1733
- package/lib/engine-components/AvatarLoader.d.ts +0 -80
- package/lib/engine-components/AvatarLoader.js +0 -232
- package/lib/engine-components/AvatarLoader.js.map +0 -1
- package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
- package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
- package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
- package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
- package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
- package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
- package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
- package/src/engine-components/AvatarLoader.ts +0 -264
- package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
- package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
- package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
- package/src/engine-components/avatar/Avatar_MustacheShake.ts +0 -32
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { AnimationClip, Object3D } from "three";
|
|
2
|
+
import type { Light, Material, PerspectiveCamera } from "three";
|
|
3
|
+
import type { Animator } from "../Animator.js";
|
|
4
|
+
import type { AudioSource } from "../AudioSource.js";
|
|
5
|
+
import { type TrackDescriptor, type TrackOptions, type AnimationKeyframe, type Tween, type Vec3Value, type QuatValue, type EulerValue, type ColorValue } from "../AnimationBuilder.js";
|
|
6
|
+
/** Keyframe array or tween shorthand */
|
|
7
|
+
type KF<V> = AnimationKeyframe<V>[] | Tween<V>;
|
|
8
|
+
import { SignalReceiver } from "./SignalAsset.js";
|
|
9
|
+
import type { PlayableDirector } from "./PlayableDirector.js";
|
|
10
|
+
import { ClipExtrapolation } from "./TimelineModels.js";
|
|
11
|
+
import type { TimelineAssetModel } from "./TimelineModels.js";
|
|
12
|
+
/**
|
|
13
|
+
* Options for an animation clip in the timeline builder
|
|
14
|
+
*/
|
|
15
|
+
export declare type AnimationClipOptions = {
|
|
16
|
+
/** Start time of the clip in seconds. If omitted, placed after the previous clip on this track. */
|
|
17
|
+
start?: number;
|
|
18
|
+
/** Duration of the clip in seconds. Defaults to the animation clip duration. */
|
|
19
|
+
duration?: number;
|
|
20
|
+
/** Playback speed multiplier (default: 1) */
|
|
21
|
+
speed?: number;
|
|
22
|
+
/** Whether the animation should loop within the clip (default: false) */
|
|
23
|
+
loop?: boolean;
|
|
24
|
+
/** Ease-in duration in seconds (default: 0) */
|
|
25
|
+
easeIn?: number;
|
|
26
|
+
/** Ease-out duration in seconds (default: 0) */
|
|
27
|
+
easeOut?: number;
|
|
28
|
+
/** Offset into the source animation clip in seconds (default: 0) */
|
|
29
|
+
clipIn?: number;
|
|
30
|
+
/** Whether to remove the start offset of the animation (default: false) */
|
|
31
|
+
removeStartOffset?: boolean;
|
|
32
|
+
/** Pre-extrapolation mode (default: None) */
|
|
33
|
+
preExtrapolation?: ClipExtrapolation;
|
|
34
|
+
/** Post-extrapolation mode (default: None) */
|
|
35
|
+
postExtrapolation?: ClipExtrapolation;
|
|
36
|
+
/** Play the clip in reverse */
|
|
37
|
+
reversed?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Options for an audio clip in the timeline builder
|
|
41
|
+
*/
|
|
42
|
+
export declare type AudioClipOptions = {
|
|
43
|
+
/** Start time of the clip in seconds. If omitted, placed after the previous clip on this track. */
|
|
44
|
+
start?: number;
|
|
45
|
+
/** Duration of the clip in seconds (required for audio since we can't infer it) */
|
|
46
|
+
duration: number;
|
|
47
|
+
/** Playback speed multiplier (default: 1) */
|
|
48
|
+
speed?: number;
|
|
49
|
+
/** Volume multiplier for this clip (default: 1) */
|
|
50
|
+
volume?: number;
|
|
51
|
+
/** Whether the audio should loop within the clip (default: false) */
|
|
52
|
+
loop?: boolean;
|
|
53
|
+
/** Ease-in duration in seconds (default: 0) */
|
|
54
|
+
easeIn?: number;
|
|
55
|
+
/** Ease-out duration in seconds (default: 0) */
|
|
56
|
+
easeOut?: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Options for an activation clip in the timeline builder
|
|
60
|
+
*/
|
|
61
|
+
export declare type ActivationClipOptions = {
|
|
62
|
+
/** Start time of the clip in seconds. If omitted, placed after the previous clip on this track. */
|
|
63
|
+
start?: number;
|
|
64
|
+
/** Duration of the clip in seconds (required) */
|
|
65
|
+
duration: number;
|
|
66
|
+
/** Ease-in duration in seconds (default: 0) */
|
|
67
|
+
easeIn?: number;
|
|
68
|
+
/** Ease-out duration in seconds (default: 0) */
|
|
69
|
+
easeOut?: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Options for a control clip in the timeline builder
|
|
73
|
+
*/
|
|
74
|
+
export declare type ControlClipOptions = {
|
|
75
|
+
/** Start time of the clip in seconds. If omitted, placed after the previous clip on this track. */
|
|
76
|
+
start?: number;
|
|
77
|
+
/** Duration of the clip in seconds (required) */
|
|
78
|
+
duration: number;
|
|
79
|
+
/** Whether to control the activation of the source object (default: true) */
|
|
80
|
+
controlActivation?: boolean;
|
|
81
|
+
/** Whether to update a nested PlayableDirector on the source object (default: true) */
|
|
82
|
+
updateDirector?: boolean;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Options for a signal marker in the timeline builder
|
|
86
|
+
*/
|
|
87
|
+
export declare type SignalMarkerOptions = {
|
|
88
|
+
/** Whether the signal should fire if the playback starts past its time (default: false) */
|
|
89
|
+
retroActive?: boolean;
|
|
90
|
+
/** Whether the signal should only fire once (default: false) */
|
|
91
|
+
emitOnce?: boolean;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Shared methods available on all track builders and the TimelineBuilder entry point.
|
|
95
|
+
* Provides track creation, build, and install methods.
|
|
96
|
+
*
|
|
97
|
+
* @category Animation and Sequencing
|
|
98
|
+
*/
|
|
99
|
+
export interface TimelineBuilderBase {
|
|
100
|
+
/** Adds an animation track. Chain `.clip()` or `.track()` to add content. */
|
|
101
|
+
animationTrack(name: string, binding?: Animator | Object3D | null): AnimationTrackBuilder;
|
|
102
|
+
/** Adds an audio track. Chain `.clip()` to add audio clips. */
|
|
103
|
+
audioTrack(name: string, binding?: AudioSource | Object3D | null, volume?: number): AudioTrackBuilder;
|
|
104
|
+
/** Adds an activation track. Chain `.clip()` to define activation windows. */
|
|
105
|
+
activationTrack(name: string, binding?: Object3D | null): ActivationTrackBuilder;
|
|
106
|
+
/** Adds a control track. Chain `.clip()` to control nested objects/timelines. */
|
|
107
|
+
controlTrack(name: string): ControlTrackBuilder;
|
|
108
|
+
/** Adds a signal track. Chain `.signal()` or `.marker()` to add events. */
|
|
109
|
+
signalTrack(name: string, binding?: SignalReceiver | Object3D | null): SignalTrackBuilder;
|
|
110
|
+
/** Adds a marker track. Chain `.marker()` to add markers. */
|
|
111
|
+
markerTrack(name: string): MarkerTrackBuilder;
|
|
112
|
+
/** Builds and returns the {@link TimelineAssetModel}. */
|
|
113
|
+
build(): TimelineAssetModel;
|
|
114
|
+
/** Builds the timeline, assigns it to the director, and wires up signal callbacks. */
|
|
115
|
+
install(director: PlayableDirector): TimelineAssetModel;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Builder for animation tracks.
|
|
119
|
+
* Provides `.clip()` for pre-built AnimationClips and `.track()` for inline animation definition.
|
|
120
|
+
*
|
|
121
|
+
* @category Animation and Sequencing
|
|
122
|
+
*/
|
|
123
|
+
export interface AnimationTrackBuilder extends TimelineBuilderBase {
|
|
124
|
+
/** Adds a pre-built AnimationClip */
|
|
125
|
+
clip(asset: AnimationClip, options?: AnimationClipOptions): AnimationTrackBuilder;
|
|
126
|
+
/** Adds a clip from a single {@link TrackDescriptor} */
|
|
127
|
+
clip(descriptor: TrackDescriptor, options?: AnimationClipOptions): AnimationTrackBuilder;
|
|
128
|
+
/** Adds a clip from multiple {@link TrackDescriptor}s */
|
|
129
|
+
clip(descriptors: TrackDescriptor[], options?: AnimationClipOptions): AnimationTrackBuilder;
|
|
130
|
+
/** Adds an animation track for an Object3D's position or scale */
|
|
131
|
+
track(target: Object3D, property: "position" | "scale", keyframes: KF<Vec3Value>, options?: TrackOptions): AnimationTrackBuilder;
|
|
132
|
+
/** Adds an animation track for an Object3D's quaternion */
|
|
133
|
+
track(target: Object3D, property: "quaternion", keyframes: KF<QuatValue>, options?: TrackOptions): AnimationTrackBuilder;
|
|
134
|
+
/** Adds an animation track for an Object3D's rotation (Euler, converted to quaternion) */
|
|
135
|
+
track(target: Object3D, property: "rotation", keyframes: KF<EulerValue>, options?: TrackOptions): AnimationTrackBuilder;
|
|
136
|
+
/** Adds an animation track for an Object3D's visibility */
|
|
137
|
+
track(target: Object3D, property: "visible", keyframes: KF<boolean>, options?: TrackOptions): AnimationTrackBuilder;
|
|
138
|
+
/** Adds an animation track for a material's numeric property */
|
|
139
|
+
track(target: Material, property: "opacity" | "roughness" | "metalness" | "alphaTest" | "emissiveIntensity" | "envMapIntensity" | "bumpScale" | "displacementScale" | "displacementBias", keyframes: KF<number>, options?: TrackOptions): AnimationTrackBuilder;
|
|
140
|
+
/** Adds an animation track for a material's color property */
|
|
141
|
+
track(target: Material, property: "color" | "emissive", keyframes: KF<ColorValue>, options?: TrackOptions): AnimationTrackBuilder;
|
|
142
|
+
/** Adds an animation track for a light's numeric property */
|
|
143
|
+
track(target: Light, property: "intensity" | "distance" | "angle" | "penumbra" | "decay", keyframes: KF<number>, options?: TrackOptions): AnimationTrackBuilder;
|
|
144
|
+
/** Adds an animation track for a light's color */
|
|
145
|
+
track(target: Light, property: "color", keyframes: KF<ColorValue>, options?: TrackOptions): AnimationTrackBuilder;
|
|
146
|
+
/** Adds an animation track for a camera's numeric property */
|
|
147
|
+
track(target: PerspectiveCamera, property: "fov" | "near" | "far" | "zoom", keyframes: KF<number>, options?: TrackOptions): AnimationTrackBuilder;
|
|
148
|
+
/** Mutes this track so it is skipped during playback */
|
|
149
|
+
muted(muted?: boolean): AnimationTrackBuilder;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Builder for audio tracks. Provides `.clip()` for adding audio clips by URL.
|
|
153
|
+
* @category Animation and Sequencing
|
|
154
|
+
*/
|
|
155
|
+
export interface AudioTrackBuilder extends TimelineBuilderBase {
|
|
156
|
+
/** Adds an audio clip by URL */
|
|
157
|
+
clip(url: string, options: AudioClipOptions): AudioTrackBuilder;
|
|
158
|
+
/** Mutes this track so it is skipped during playback */
|
|
159
|
+
muted(muted?: boolean): AudioTrackBuilder;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Builder for activation tracks. Provides `.clip()` for defining activation windows.
|
|
163
|
+
* @category Animation and Sequencing
|
|
164
|
+
*/
|
|
165
|
+
export interface ActivationTrackBuilder extends TimelineBuilderBase {
|
|
166
|
+
/** Adds an activation clip that shows/hides the bound object */
|
|
167
|
+
clip(options: ActivationClipOptions): ActivationTrackBuilder;
|
|
168
|
+
/** Mutes this track so it is skipped during playback */
|
|
169
|
+
muted(muted?: boolean): ActivationTrackBuilder;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Builder for control tracks. Provides `.clip()` for controlling nested objects/timelines.
|
|
173
|
+
* @category Animation and Sequencing
|
|
174
|
+
*/
|
|
175
|
+
export interface ControlTrackBuilder extends TimelineBuilderBase {
|
|
176
|
+
/** Adds a control clip for a source object */
|
|
177
|
+
clip(sourceObject: Object3D, options: ControlClipOptions): ControlTrackBuilder;
|
|
178
|
+
/** Mutes this track so it is skipped during playback */
|
|
179
|
+
muted(muted?: boolean): ControlTrackBuilder;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Builder for signal tracks. Provides `.signal()` for callback-based signals and `.marker()` for asset-based markers.
|
|
183
|
+
* @category Animation and Sequencing
|
|
184
|
+
*/
|
|
185
|
+
export interface SignalTrackBuilder extends TimelineBuilderBase {
|
|
186
|
+
/** Adds a signal with a callback that fires at the given time */
|
|
187
|
+
signal(time: number, callback: Function, options?: SignalMarkerOptions): SignalTrackBuilder;
|
|
188
|
+
/** Adds a signal marker referencing a signal asset by guid */
|
|
189
|
+
marker(time: number, asset: string, options?: SignalMarkerOptions): SignalTrackBuilder;
|
|
190
|
+
/** Mutes this track so it is skipped during playback */
|
|
191
|
+
muted(muted?: boolean): SignalTrackBuilder;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Builder for marker tracks. Provides `.marker()` for adding markers.
|
|
195
|
+
* @category Animation and Sequencing
|
|
196
|
+
*/
|
|
197
|
+
export interface MarkerTrackBuilder extends TimelineBuilderBase {
|
|
198
|
+
/** Adds a marker referencing a signal asset by guid */
|
|
199
|
+
marker(time: number, asset: string, options?: SignalMarkerOptions): MarkerTrackBuilder;
|
|
200
|
+
/** Mutes this track so it is skipped during playback */
|
|
201
|
+
muted(muted?: boolean): MarkerTrackBuilder;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* A fluent builder for creating timeline assets ({@link TimelineAssetModel}) from code.
|
|
205
|
+
*
|
|
206
|
+
* Use {@link TimelineBuilder.create} to start building a timeline.
|
|
207
|
+
*
|
|
208
|
+
* @example Using build() for timelines without signal callbacks
|
|
209
|
+
* ```ts
|
|
210
|
+
* const timeline = TimelineBuilder.create("MySequence")
|
|
211
|
+
* .animationTrack("Character", animator)
|
|
212
|
+
* .clip(walkClip, { duration: 2, easeIn: 0.3 })
|
|
213
|
+
* .clip(runClip, { duration: 3, easeIn: 0.5, easeOut: 0.5 })
|
|
214
|
+
* .activationTrack("FX", particleObject)
|
|
215
|
+
* .clip({ start: 1, duration: 2 })
|
|
216
|
+
* .audioTrack("Music", audioSource)
|
|
217
|
+
* .clip("music.mp3", { start: 0, duration: 5, volume: 0.8 })
|
|
218
|
+
* .build();
|
|
219
|
+
*
|
|
220
|
+
* director.playableAsset = timeline;
|
|
221
|
+
* director.play();
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @example With inline tracks (no pre-built clips needed)
|
|
225
|
+
* ```ts
|
|
226
|
+
* TimelineBuilder.create("DoorSequence")
|
|
227
|
+
* .animationTrack("Door", door)
|
|
228
|
+
* .track(door, "position", { from: [0, 0, 0], to: [2, 0, 0], duration: 1 })
|
|
229
|
+
* .track(light, "intensity", { from: 0, to: 5, duration: 1 })
|
|
230
|
+
* .signalTrack("Events")
|
|
231
|
+
* .signal(0.5, () => playSound("creak"))
|
|
232
|
+
* .install(director);
|
|
233
|
+
*
|
|
234
|
+
* director.play();
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
237
|
+
* @example Using install() with signal callbacks
|
|
238
|
+
* ```ts
|
|
239
|
+
* TimelineBuilder.create("WithSignals")
|
|
240
|
+
* .animationTrack("Character", animator)
|
|
241
|
+
* .clip(walkClip, { duration: 2 })
|
|
242
|
+
* .signalTrack("Events")
|
|
243
|
+
* .signal(1.0, () => console.log("1 second!"))
|
|
244
|
+
* .signal(2.0, () => spawnParticles())
|
|
245
|
+
* .install(director);
|
|
246
|
+
*
|
|
247
|
+
* director.play();
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @category Animation and Sequencing
|
|
251
|
+
* @group Utilities
|
|
252
|
+
*/
|
|
253
|
+
export declare class TimelineBuilder {
|
|
254
|
+
private _name;
|
|
255
|
+
private _tracks;
|
|
256
|
+
private _currentTrack;
|
|
257
|
+
private _pendingSignals;
|
|
258
|
+
private _idProvider;
|
|
259
|
+
private constructor();
|
|
260
|
+
/**
|
|
261
|
+
* Creates a new TimelineBuilder instance.
|
|
262
|
+
* @param name - Name for the timeline asset
|
|
263
|
+
* @param seed - Optional numeric seed for deterministic guid generation. Defaults to `Date.now()`.
|
|
264
|
+
*/
|
|
265
|
+
static create(name?: string, seed?: number): TimelineBuilderBase;
|
|
266
|
+
/**
|
|
267
|
+
* Adds an animation track. Chain `.clip()` calls to add pre-built clips,
|
|
268
|
+
* or chain `.track()` calls to define animation data inline:
|
|
269
|
+
*
|
|
270
|
+
* @example With pre-built AnimationClip
|
|
271
|
+
* ```ts
|
|
272
|
+
* .animationTrack("Character", animator)
|
|
273
|
+
* .clip(walkClip, { duration: 2, easeIn: 0.3 })
|
|
274
|
+
* .clip(runClip, { duration: 3 })
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* @example With inline tracks
|
|
278
|
+
* ```ts
|
|
279
|
+
* .animationTrack("Door", door)
|
|
280
|
+
* .track(door, "position", { from: [0, 0, 0], to: [2, 0, 0], duration: 1 })
|
|
281
|
+
* .track(light, "intensity", { from: 0, to: 5, duration: 1 })
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @param name - Display name for the track
|
|
285
|
+
* @param binding - The Animator or Object3D to animate
|
|
286
|
+
*/
|
|
287
|
+
animationTrack(name: string, binding?: Animator | Object3D | null): AnimationTrackBuilder;
|
|
288
|
+
/**
|
|
289
|
+
* Adds an audio track. Subsequent `.clip()` calls add audio clips to this track.
|
|
290
|
+
* @param name - Display name for the track
|
|
291
|
+
* @param binding - The AudioSource to play audio on (optional)
|
|
292
|
+
* @param volume - Track volume multiplier (default: 1)
|
|
293
|
+
*/
|
|
294
|
+
audioTrack(name: string, binding?: AudioSource | Object3D | null, volume?: number): AudioTrackBuilder;
|
|
295
|
+
/**
|
|
296
|
+
* Adds an activation track. Subsequent `.clip()` calls define when the bound object is active.
|
|
297
|
+
* @param name - Display name for the track
|
|
298
|
+
* @param binding - The Object3D to show/hide
|
|
299
|
+
*/
|
|
300
|
+
activationTrack(name: string, binding?: Object3D | null): ActivationTrackBuilder;
|
|
301
|
+
/**
|
|
302
|
+
* Adds a control track. Subsequent `.clip()` calls control nested timelines or objects.
|
|
303
|
+
* @param name - Display name for the track
|
|
304
|
+
*/
|
|
305
|
+
controlTrack(name: string): ControlTrackBuilder;
|
|
306
|
+
/**
|
|
307
|
+
* Adds a signal track. Use `.signal()` or `.marker()` to add signal markers.
|
|
308
|
+
* @param name - Display name for the track
|
|
309
|
+
* @param binding - The SignalReceiver component (optional — if using `.signal()` with callbacks, one is created automatically by {@link install})
|
|
310
|
+
*/
|
|
311
|
+
signalTrack(name: string, binding?: SignalReceiver | Object3D | null): SignalTrackBuilder;
|
|
312
|
+
/**
|
|
313
|
+
* Adds a marker track. Use `.marker()` to add markers.
|
|
314
|
+
* @param name - Display name for the track
|
|
315
|
+
*/
|
|
316
|
+
markerTrack(name: string): MarkerTrackBuilder;
|
|
317
|
+
/**
|
|
318
|
+
* Adds a clip to the current track. The clip type must match the track type.
|
|
319
|
+
*
|
|
320
|
+
* - On an **animation track**: pass an `AnimationClip`, a {@link TrackDescriptor}, or a `TrackDescriptor[]` — and optional {@link AnimationClipOptions}
|
|
321
|
+
* - On an **audio track**: pass a clip URL (string) and {@link AudioClipOptions}
|
|
322
|
+
* - On an **activation track**: pass {@link ActivationClipOptions}
|
|
323
|
+
* - On a **control track**: pass an Object3D and {@link ControlClipOptions}
|
|
324
|
+
*/
|
|
325
|
+
clip(asset: AnimationClip, options?: AnimationClipOptions): this;
|
|
326
|
+
clip(descriptor: TrackDescriptor, options?: AnimationClipOptions): this;
|
|
327
|
+
clip(descriptors: TrackDescriptor[], options?: AnimationClipOptions): this;
|
|
328
|
+
clip(url: string, options: AudioClipOptions): this;
|
|
329
|
+
clip(options: ActivationClipOptions): this;
|
|
330
|
+
clip(sourceObject: Object3D, options: ControlClipOptions): this;
|
|
331
|
+
/**
|
|
332
|
+
* Adds a signal marker to the current signal or marker track.
|
|
333
|
+
* @param time - Time in seconds when the signal fires
|
|
334
|
+
* @param asset - The signal asset identifier (guid string)
|
|
335
|
+
* @param options - Optional marker configuration
|
|
336
|
+
*/
|
|
337
|
+
marker(time: number, asset: string, options?: SignalMarkerOptions): this;
|
|
338
|
+
/**
|
|
339
|
+
* Adds a signal with a callback to the current signal track.
|
|
340
|
+
* This is a convenience method that automatically generates a signal asset guid,
|
|
341
|
+
* adds the marker, and registers the callback so that {@link install} can wire up
|
|
342
|
+
* the `SignalReceiver` on the director's GameObject.
|
|
343
|
+
*
|
|
344
|
+
* @param time - Time in seconds when the signal fires
|
|
345
|
+
* @param callback - The function to invoke when the signal fires
|
|
346
|
+
* @param options - Optional marker configuration
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* const timeline = TimelineBuilder.create("Sequence")
|
|
351
|
+
* .signalTrack("Events")
|
|
352
|
+
* .signal(1.0, () => console.log("1 second reached!"))
|
|
353
|
+
* .signal(3.5, () => console.log("halfway!"), { emitOnce: true })
|
|
354
|
+
* .install(director);
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
signal(time: number, callback: Function, options?: SignalMarkerOptions): this;
|
|
358
|
+
/**
|
|
359
|
+
* Mutes the current track so it is skipped during playback.
|
|
360
|
+
*/
|
|
361
|
+
muted(muted?: boolean): this;
|
|
362
|
+
/** Adds an animation track descriptor for an Object3D's position or scale to the current animation track */
|
|
363
|
+
track(target: Object3D, property: "position" | "scale", keyframes: KF<Vec3Value>, options?: TrackOptions): this;
|
|
364
|
+
/** Adds an animation track descriptor for an Object3D's quaternion to the current animation track */
|
|
365
|
+
track(target: Object3D, property: "quaternion", keyframes: KF<QuatValue>, options?: TrackOptions): this;
|
|
366
|
+
/** Adds an animation track descriptor for an Object3D's rotation (Euler, converted to quaternion) to the current animation track */
|
|
367
|
+
track(target: Object3D, property: "rotation", keyframes: KF<EulerValue>, options?: TrackOptions): this;
|
|
368
|
+
/** Adds an animation track descriptor for an Object3D's visibility to the current animation track */
|
|
369
|
+
track(target: Object3D, property: "visible", keyframes: KF<boolean>, options?: TrackOptions): this;
|
|
370
|
+
/** Adds an animation track descriptor for a material's numeric property to the current animation track */
|
|
371
|
+
track(target: Material, property: "opacity" | "roughness" | "metalness" | "alphaTest" | "emissiveIntensity" | "envMapIntensity" | "bumpScale" | "displacementScale" | "displacementBias", keyframes: KF<number>, options?: TrackOptions): this;
|
|
372
|
+
/** Adds an animation track descriptor for a material's color property to the current animation track */
|
|
373
|
+
track(target: Material, property: "color" | "emissive", keyframes: KF<ColorValue>, options?: TrackOptions): this;
|
|
374
|
+
/** Adds an animation track descriptor for a light's numeric property to the current animation track */
|
|
375
|
+
track(target: Light, property: "intensity" | "distance" | "angle" | "penumbra" | "decay", keyframes: KF<number>, options?: TrackOptions): this;
|
|
376
|
+
/** Adds an animation track descriptor for a light's color to the current animation track */
|
|
377
|
+
track(target: Light, property: "color", keyframes: KF<ColorValue>, options?: TrackOptions): this;
|
|
378
|
+
/** Adds an animation track descriptor for a camera's numeric property to the current animation track */
|
|
379
|
+
track(target: PerspectiveCamera, property: "fov" | "near" | "far" | "zoom", keyframes: KF<number>, options?: TrackOptions): this;
|
|
380
|
+
/**
|
|
381
|
+
* Builds and returns the {@link TimelineAssetModel}.
|
|
382
|
+
* Assign the result to `PlayableDirector.playableAsset` to play it.
|
|
383
|
+
*
|
|
384
|
+
* If you used `.signal()` with callbacks, use {@link install} instead — it calls `build()`
|
|
385
|
+
* internally and also wires up the SignalReceiver on the director's GameObject.
|
|
386
|
+
*/
|
|
387
|
+
build(): TimelineAssetModel;
|
|
388
|
+
/**
|
|
389
|
+
* Builds the timeline asset, assigns it to the director, and wires up any
|
|
390
|
+
* `.signal()` callbacks by creating/configuring a {@link SignalReceiver} on the
|
|
391
|
+
* director's GameObject.
|
|
392
|
+
*
|
|
393
|
+
* @param director - The PlayableDirector to install the timeline on
|
|
394
|
+
* @returns The built TimelineAssetModel (also assigned to `director.playableAsset`)
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* TimelineBuilder.create("MyTimeline")
|
|
399
|
+
* .animationTrack("Anim", animator)
|
|
400
|
+
* .clip(walkClip, { duration: 2 })
|
|
401
|
+
* .signalTrack("Events")
|
|
402
|
+
* .signal(1.0, () => console.log("signal fired!"))
|
|
403
|
+
* .install(director);
|
|
404
|
+
*
|
|
405
|
+
* director.play();
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
install(director: PlayableDirector): TimelineAssetModel;
|
|
409
|
+
private pushTrack;
|
|
410
|
+
/** Commits any pending `.track()` descriptors on the current animation track into a clip */
|
|
411
|
+
private commitInlineTracks;
|
|
412
|
+
}
|
|
413
|
+
export {};
|