@zephyr3d/scene 0.9.10 → 0.9.11
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/dist/animation/animationset.js +189 -170
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtimeline.js +117 -117
- package/dist/animation/animationtimeline.js.map +1 -1
- package/dist/app/scriptregistry.js +20 -15
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/index.d.ts +30 -9
- package/package.json +3 -3
|
@@ -8,9 +8,9 @@ import { HumanoidBodyRig } from './skeleton.js';
|
|
|
8
8
|
import { createSkeletalMaskedAnimationClip } from './animationmask.js';
|
|
9
9
|
|
|
10
10
|
let nextAnimationPlaybackId = 1;
|
|
11
|
-
/**
|
|
12
|
-
* Runtime handle for one playback of an AnimationClip.
|
|
13
|
-
* @public
|
|
11
|
+
/**
|
|
12
|
+
* Runtime handle for one playback of an AnimationClip.
|
|
13
|
+
* @public
|
|
14
14
|
*/ class AnimationPlayback extends Observable {
|
|
15
15
|
/** @internal */ _animationSet;
|
|
16
16
|
/** @internal */ _clip;
|
|
@@ -606,7 +606,26 @@ function bakeHumanoidRotationTracks(sourceClip, srcSkeleton, dstSkeleton, srcRoo
|
|
|
606
606
|
dstClip.addTrack(remap.dstNode, track);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
|
|
609
|
+
/**
|
|
610
|
+
* Animation set
|
|
611
|
+
*
|
|
612
|
+
* Manages a collection of named animation clips for a model and orchestrates:
|
|
613
|
+
* - Playback state (time, loops, speed, weights, fade-in/out).
|
|
614
|
+
* - Blending across multiple tracks targeting the same property via weighted averages.
|
|
615
|
+
* - Skeleton usage and application for clips that drive skeletal animation.
|
|
616
|
+
* - Active track registration and cleanup as clips start/stop.
|
|
617
|
+
*
|
|
618
|
+
* Usage:
|
|
619
|
+
* - Create or retrieve `AnimationClip`s by name.
|
|
620
|
+
* - Start playback with `playAnimation(name, options)`.
|
|
621
|
+
* - Advance animation with `update(deltaSeconds)`.
|
|
622
|
+
* - Optionally adjust weight while playing with `setAnimationWeight(name, weight)`.
|
|
623
|
+
*
|
|
624
|
+
* Lifetime:
|
|
625
|
+
* - Disposing the set releases references to the model, clips, and clears active state.
|
|
626
|
+
*
|
|
627
|
+
* @public
|
|
628
|
+
*/ class AnimationSet extends makeObservable(Disposable)() {
|
|
610
629
|
/** @internal */ _model;
|
|
611
630
|
/** @internal */ _animations;
|
|
612
631
|
/** @internal */ _skeletons;
|
|
@@ -615,18 +634,18 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
615
634
|
/** @internal */ _activeSkinBindings;
|
|
616
635
|
/** @internal */ _activeRigs;
|
|
617
636
|
/** @internal */ _activeAnimations;
|
|
618
|
-
/**
|
|
619
|
-
* Callbacks driven by the same logical clock as the animations (see {@link update}).
|
|
620
|
-
*
|
|
621
|
-
* Used by higher-level constructs (e.g. timeline runners) that need to advance
|
|
622
|
-
* wall-clock-independent timers in sync with playback, so they pause/scale with the
|
|
623
|
-
* game clock instead of running on real time.
|
|
624
|
-
* @internal
|
|
637
|
+
/**
|
|
638
|
+
* Callbacks driven by the same logical clock as the animations (see {@link update}).
|
|
639
|
+
*
|
|
640
|
+
* Used by higher-level constructs (e.g. timeline runners) that need to advance
|
|
641
|
+
* wall-clock-independent timers in sync with playback, so they pause/scale with the
|
|
642
|
+
* game clock instead of running on real time.
|
|
643
|
+
* @internal
|
|
625
644
|
*/ _timelineTickers;
|
|
626
|
-
/**
|
|
627
|
-
* Create an AnimationSet controlling the provided model.
|
|
628
|
-
*
|
|
629
|
-
* @param model - The SceneNode (model root) controlled by this animation set.
|
|
645
|
+
/**
|
|
646
|
+
* Create an AnimationSet controlling the provided model.
|
|
647
|
+
*
|
|
648
|
+
* @param model - The SceneNode (model root) controlled by this animation set.
|
|
630
649
|
*/ constructor(model){
|
|
631
650
|
super();
|
|
632
651
|
this._model = model;
|
|
@@ -639,40 +658,40 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
639
658
|
this._rigs = [];
|
|
640
659
|
this._timelineTickers = new Set();
|
|
641
660
|
}
|
|
642
|
-
/**
|
|
643
|
-
* Register a callback advanced by {@link update} using the same delta time as the animations.
|
|
644
|
-
* @internal
|
|
661
|
+
/**
|
|
662
|
+
* Register a callback advanced by {@link update} using the same delta time as the animations.
|
|
663
|
+
* @internal
|
|
645
664
|
*/ _registerTimelineTicker(ticker) {
|
|
646
665
|
this._timelineTickers.add(ticker);
|
|
647
666
|
}
|
|
648
|
-
/**
|
|
649
|
-
* Unregister a callback previously registered with {@link _registerTimelineTicker}.
|
|
650
|
-
* @internal
|
|
667
|
+
/**
|
|
668
|
+
* Unregister a callback previously registered with {@link _registerTimelineTicker}.
|
|
669
|
+
* @internal
|
|
651
670
|
*/ _unregisterTimelineTicker(ticker) {
|
|
652
671
|
this._timelineTickers.delete(ticker);
|
|
653
672
|
}
|
|
654
|
-
/**
|
|
655
|
-
* The model (SceneNode) controlled by this animation set.
|
|
673
|
+
/**
|
|
674
|
+
* The model (SceneNode) controlled by this animation set.
|
|
656
675
|
*/ get model() {
|
|
657
676
|
return this._model;
|
|
658
677
|
}
|
|
659
|
-
/**
|
|
660
|
-
* Number of animation clips registered in this set.
|
|
678
|
+
/**
|
|
679
|
+
* Number of animation clips registered in this set.
|
|
661
680
|
*/ get numAnimations() {
|
|
662
681
|
return Object.getOwnPropertyNames(this._animations).length;
|
|
663
682
|
}
|
|
664
|
-
/**
|
|
665
|
-
* The skeletons used by animations in this set.
|
|
683
|
+
/**
|
|
684
|
+
* The skeletons used by animations in this set.
|
|
666
685
|
*/ get skeletons() {
|
|
667
686
|
return this._skeletons;
|
|
668
687
|
}
|
|
669
|
-
/**
|
|
670
|
-
* The shared rigs used by animations in this set.
|
|
688
|
+
/**
|
|
689
|
+
* The shared rigs used by animations in this set.
|
|
671
690
|
*/ get rigs() {
|
|
672
691
|
return this._rigs;
|
|
673
692
|
}
|
|
674
|
-
/**
|
|
675
|
-
* Per-skin bindings used by skinned meshes in this set.
|
|
693
|
+
/**
|
|
694
|
+
* Per-skin bindings used by skinned meshes in this set.
|
|
676
695
|
*/ get skinBindings() {
|
|
677
696
|
return this._skeletons;
|
|
678
697
|
}
|
|
@@ -694,20 +713,20 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
694
713
|
}
|
|
695
714
|
return rig;
|
|
696
715
|
}
|
|
697
|
-
/**
|
|
698
|
-
* Retrieve an animation clip by name.
|
|
699
|
-
*
|
|
700
|
-
* @param name - Name of the animation.
|
|
701
|
-
* @returns The clip if present; otherwise null.
|
|
716
|
+
/**
|
|
717
|
+
* Retrieve an animation clip by name.
|
|
718
|
+
*
|
|
719
|
+
* @param name - Name of the animation.
|
|
720
|
+
* @returns The clip if present; otherwise null.
|
|
702
721
|
*/ get(name) {
|
|
703
722
|
return this._animations[name] ?? null;
|
|
704
723
|
}
|
|
705
|
-
/**
|
|
706
|
-
* Create and register a new animation clip.
|
|
707
|
-
*
|
|
708
|
-
* @param name - Unique name for the animation clip.
|
|
709
|
-
* @param embedded - Whether the clip is embedded/owned (implementation-specific). Default false.
|
|
710
|
-
* @returns The created clip, or null if the name is empty or not unique.
|
|
724
|
+
/**
|
|
725
|
+
* Create and register a new animation clip.
|
|
726
|
+
*
|
|
727
|
+
* @param name - Unique name for the animation clip.
|
|
728
|
+
* @param embedded - Whether the clip is embedded/owned (implementation-specific). Default false.
|
|
729
|
+
* @returns The created clip, or null if the name is empty or not unique.
|
|
711
730
|
*/ createAnimation(name, embedded = false) {
|
|
712
731
|
if (!name || this._animations[name]) {
|
|
713
732
|
console.error('Animation must have unique name');
|
|
@@ -719,12 +738,12 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
719
738
|
return animation;
|
|
720
739
|
}
|
|
721
740
|
}
|
|
722
|
-
/**
|
|
723
|
-
* Delete and dispose an animation clip by name.
|
|
724
|
-
*
|
|
725
|
-
* - If the animation is currently playing, it is first stopped (immediately).
|
|
726
|
-
*
|
|
727
|
-
* @param name - Name of the animation to remove.
|
|
741
|
+
/**
|
|
742
|
+
* Delete and dispose an animation clip by name.
|
|
743
|
+
*
|
|
744
|
+
* - If the animation is currently playing, it is first stopped (immediately).
|
|
745
|
+
*
|
|
746
|
+
* @param name - Name of the animation to remove.
|
|
728
747
|
*/ deleteAnimation(name) {
|
|
729
748
|
const animation = this._animations[name];
|
|
730
749
|
if (animation) {
|
|
@@ -733,24 +752,24 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
733
752
|
animation.dispose();
|
|
734
753
|
}
|
|
735
754
|
}
|
|
736
|
-
/**
|
|
737
|
-
* Get the list of all registered animation names.
|
|
738
|
-
*
|
|
739
|
-
* @returns An array of clip names.
|
|
755
|
+
/**
|
|
756
|
+
* Get the list of all registered animation names.
|
|
757
|
+
*
|
|
758
|
+
* @returns An array of clip names.
|
|
740
759
|
*/ getAnimationNames() {
|
|
741
760
|
return Object.keys(this._animations);
|
|
742
761
|
}
|
|
743
|
-
/**
|
|
744
|
-
* Advance and apply active animations.
|
|
745
|
-
*
|
|
746
|
-
* Responsibilities per call:
|
|
747
|
-
* - Update time cursor for each active clip (respecting speedRatio and looping).
|
|
748
|
-
* - Enforce repeat limits and apply fade-out termination if configured.
|
|
749
|
-
* - For each animated target, blend active tracks (weighted by clip weight × fade-in × fade-out)
|
|
750
|
-
* and apply the resulting state to the target.
|
|
751
|
-
* - Apply shared rig modifiers once, then update skin binding palettes.
|
|
752
|
-
*
|
|
753
|
-
* @param deltaInSeconds - Time step in seconds since last update.
|
|
762
|
+
/**
|
|
763
|
+
* Advance and apply active animations.
|
|
764
|
+
*
|
|
765
|
+
* Responsibilities per call:
|
|
766
|
+
* - Update time cursor for each active clip (respecting speedRatio and looping).
|
|
767
|
+
* - Enforce repeat limits and apply fade-out termination if configured.
|
|
768
|
+
* - For each animated target, blend active tracks (weighted by clip weight × fade-in × fade-out)
|
|
769
|
+
* and apply the resulting state to the target.
|
|
770
|
+
* - Apply shared rig modifiers once, then update skin binding palettes.
|
|
771
|
+
*
|
|
772
|
+
* @param deltaInSeconds - Time step in seconds since last update.
|
|
754
773
|
*/ update(deltaInSeconds) {
|
|
755
774
|
this._activeAnimations.forEach((v, k)=>{
|
|
756
775
|
if (!v.started) {
|
|
@@ -891,11 +910,11 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
891
910
|
this._timelineTickers.forEach((ticker)=>ticker(deltaInSeconds));
|
|
892
911
|
}
|
|
893
912
|
}
|
|
894
|
-
/**
|
|
895
|
-
* Check whether an animation is currently playing.
|
|
896
|
-
*
|
|
897
|
-
* @param name - Optional animation name. If omitted, returns true if any animation is playing.
|
|
898
|
-
* @returns True if playing; otherwise false.
|
|
913
|
+
/**
|
|
914
|
+
* Check whether an animation is currently playing.
|
|
915
|
+
*
|
|
916
|
+
* @param name - Optional animation name. If omitted, returns true if any animation is playing.
|
|
917
|
+
* @returns True if playing; otherwise false.
|
|
899
918
|
*/ isPlayingAnimation(name) {
|
|
900
919
|
if (name) {
|
|
901
920
|
const animation = this._animations[name];
|
|
@@ -903,23 +922,23 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
903
922
|
}
|
|
904
923
|
return this._activeAnimations.size > 0;
|
|
905
924
|
}
|
|
906
|
-
/**
|
|
907
|
-
* Get an animation clip by name.
|
|
908
|
-
*
|
|
909
|
-
* Alias of `get(name)` returning a nullable type.
|
|
910
|
-
*
|
|
911
|
-
* @param name - Name of the animation.
|
|
912
|
-
* @returns The clip if present; otherwise null.
|
|
925
|
+
/**
|
|
926
|
+
* Get an animation clip by name.
|
|
927
|
+
*
|
|
928
|
+
* Alias of `get(name)` returning a nullable type.
|
|
929
|
+
*
|
|
930
|
+
* @param name - Name of the animation.
|
|
931
|
+
* @returns The clip if present; otherwise null.
|
|
913
932
|
*/ getAnimationClip(name) {
|
|
914
933
|
return this._animations[name] ?? null;
|
|
915
934
|
}
|
|
916
|
-
/**
|
|
917
|
-
* Set the runtime blend weight for a currently playing animation.
|
|
918
|
-
*
|
|
919
|
-
* Has no effect if the clip is not active.
|
|
920
|
-
*
|
|
921
|
-
* @param name - Name of the playing animation.
|
|
922
|
-
* @param weight - New weight value used during blending.
|
|
935
|
+
/**
|
|
936
|
+
* Set the runtime blend weight for a currently playing animation.
|
|
937
|
+
*
|
|
938
|
+
* Has no effect if the clip is not active.
|
|
939
|
+
*
|
|
940
|
+
* @param name - Name of the playing animation.
|
|
941
|
+
* @param weight - New weight value used during blending.
|
|
923
942
|
*/ setAnimationWeight(name, weight) {
|
|
924
943
|
const ani = this._animations[name];
|
|
925
944
|
if (!ani) {
|
|
@@ -933,8 +952,8 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
933
952
|
info.playback._setWeight(weight);
|
|
934
953
|
}
|
|
935
954
|
}
|
|
936
|
-
/**
|
|
937
|
-
* Create a playback handle without starting it.
|
|
955
|
+
/**
|
|
956
|
+
* Create a playback handle without starting it.
|
|
938
957
|
*/ createPlayback(name, options) {
|
|
939
958
|
const ani = this._animations[name];
|
|
940
959
|
if (!ani) {
|
|
@@ -943,15 +962,15 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
943
962
|
}
|
|
944
963
|
return new AnimationPlayback(this, ani, options);
|
|
945
964
|
}
|
|
946
|
-
/**
|
|
947
|
-
* Start an animation and return its playback handle.
|
|
965
|
+
/**
|
|
966
|
+
* Start an animation and return its playback handle.
|
|
948
967
|
*/ play(name, options) {
|
|
949
968
|
const playback = this.createPlayback(name, options);
|
|
950
969
|
playback?.play();
|
|
951
970
|
return playback;
|
|
952
971
|
}
|
|
953
|
-
/**
|
|
954
|
-
* Get currently active playbacks.
|
|
972
|
+
/**
|
|
973
|
+
* Get currently active playbacks.
|
|
955
974
|
*/ getPlaybacks(name) {
|
|
956
975
|
const playbacks = [];
|
|
957
976
|
this._activeAnimations.forEach((info, clip)=>{
|
|
@@ -961,28 +980,28 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
961
980
|
});
|
|
962
981
|
return playbacks;
|
|
963
982
|
}
|
|
964
|
-
/**
|
|
965
|
-
* Get the currently active playback for a clip.
|
|
983
|
+
/**
|
|
984
|
+
* Get the currently active playback for a clip.
|
|
966
985
|
*/ getPlayback(name) {
|
|
967
986
|
const clip = this._animations[name];
|
|
968
987
|
return clip ? this._activeAnimations.get(clip)?.playback ?? null : null;
|
|
969
988
|
}
|
|
970
|
-
/**
|
|
971
|
-
* Start (or update) playback of an animation clip.
|
|
972
|
-
*
|
|
973
|
-
* Behavior:
|
|
974
|
-
* - If the clip is already playing, stops it first.
|
|
975
|
-
* - Otherwise initializes playback state (repeat counter, speed, weight, initial time).
|
|
976
|
-
* - Registers clip tracks and skeletons into the active sets for blending and application.
|
|
977
|
-
*
|
|
978
|
-
* @param name - Name of the animation to play.
|
|
979
|
-
* @param options - Playback options (repeat, speedRatio, fadeIn).
|
|
989
|
+
/**
|
|
990
|
+
* Start (or update) playback of an animation clip.
|
|
991
|
+
*
|
|
992
|
+
* Behavior:
|
|
993
|
+
* - If the clip is already playing, stops it first.
|
|
994
|
+
* - Otherwise initializes playback state (repeat counter, speed, weight, initial time).
|
|
995
|
+
* - Registers clip tracks and skeletons into the active sets for blending and application.
|
|
996
|
+
*
|
|
997
|
+
* @param name - Name of the animation to play.
|
|
998
|
+
* @param options - Playback options (repeat, speedRatio, fadeIn).
|
|
980
999
|
*/ playAnimation(name, options) {
|
|
981
1000
|
this.play(name, options);
|
|
982
1001
|
}
|
|
983
|
-
/**
|
|
984
|
-
* Start a previously created playback.
|
|
985
|
-
* @internal
|
|
1002
|
+
/**
|
|
1003
|
+
* Start a previously created playback.
|
|
1004
|
+
* @internal
|
|
986
1005
|
*/ startPlayback(playback) {
|
|
987
1006
|
const ani = playback.clip;
|
|
988
1007
|
if (!ani) {
|
|
@@ -1137,17 +1156,17 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1137
1156
|
const offset = ((time - range.start) % range.duration + range.duration) % range.duration;
|
|
1138
1157
|
return range.start + offset;
|
|
1139
1158
|
}
|
|
1140
|
-
/**
|
|
1141
|
-
* Stop a playback handle.
|
|
1142
|
-
* @internal
|
|
1159
|
+
/**
|
|
1160
|
+
* Stop a playback handle.
|
|
1161
|
+
* @internal
|
|
1143
1162
|
*/ stopPlayback(playback, options) {
|
|
1144
1163
|
if (this._activeAnimations.get(playback.clip)?.playback === playback) {
|
|
1145
1164
|
this.stopAnimation(playback.clip.name, options);
|
|
1146
1165
|
}
|
|
1147
1166
|
}
|
|
1148
|
-
/**
|
|
1149
|
-
* Pause a playback handle.
|
|
1150
|
-
* @internal
|
|
1167
|
+
/**
|
|
1168
|
+
* Pause a playback handle.
|
|
1169
|
+
* @internal
|
|
1151
1170
|
*/ pausePlayback(playback) {
|
|
1152
1171
|
const info = this._activeAnimations.get(playback.clip);
|
|
1153
1172
|
if (info?.playback === playback && !info.paused) {
|
|
@@ -1158,9 +1177,9 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1158
1177
|
this.dispatchEvent('playbackpause', event);
|
|
1159
1178
|
}
|
|
1160
1179
|
}
|
|
1161
|
-
/**
|
|
1162
|
-
* Resume a playback handle.
|
|
1163
|
-
* @internal
|
|
1180
|
+
/**
|
|
1181
|
+
* Resume a playback handle.
|
|
1182
|
+
* @internal
|
|
1164
1183
|
*/ resumePlayback(playback) {
|
|
1165
1184
|
const info = this._activeAnimations.get(playback.clip);
|
|
1166
1185
|
if (info?.playback === playback && info.paused) {
|
|
@@ -1171,9 +1190,9 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1171
1190
|
this.dispatchEvent('playbackresume', event);
|
|
1172
1191
|
}
|
|
1173
1192
|
}
|
|
1174
|
-
/**
|
|
1175
|
-
* Seek a playback handle.
|
|
1176
|
-
* @internal
|
|
1193
|
+
/**
|
|
1194
|
+
* Seek a playback handle.
|
|
1195
|
+
* @internal
|
|
1177
1196
|
*/ seekPlayback(playback, time, options) {
|
|
1178
1197
|
const clip = playback.clip;
|
|
1179
1198
|
const info = this._activeAnimations.get(clip);
|
|
@@ -1193,9 +1212,9 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1193
1212
|
}
|
|
1194
1213
|
}
|
|
1195
1214
|
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Set playback weight.
|
|
1198
|
-
* @internal
|
|
1215
|
+
/**
|
|
1216
|
+
* Set playback weight.
|
|
1217
|
+
* @internal
|
|
1199
1218
|
*/ setPlaybackWeight(playback, weight) {
|
|
1200
1219
|
playback._setWeight(weight);
|
|
1201
1220
|
const info = this._activeAnimations.get(playback.clip);
|
|
@@ -1204,9 +1223,9 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1204
1223
|
info.targetWeight = weight;
|
|
1205
1224
|
}
|
|
1206
1225
|
}
|
|
1207
|
-
/**
|
|
1208
|
-
* Set playback speed ratio.
|
|
1209
|
-
* @internal
|
|
1226
|
+
/**
|
|
1227
|
+
* Set playback speed ratio.
|
|
1228
|
+
* @internal
|
|
1210
1229
|
*/ setPlaybackSpeedRatio(playback, speedRatio) {
|
|
1211
1230
|
playback._setSpeedRatio(speedRatio);
|
|
1212
1231
|
const info = this._activeAnimations.get(playback.clip);
|
|
@@ -1214,9 +1233,9 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1214
1233
|
info.speedRatio = speedRatio;
|
|
1215
1234
|
}
|
|
1216
1235
|
}
|
|
1217
|
-
/**
|
|
1218
|
-
* Fade playback weight to a target value.
|
|
1219
|
-
* @internal
|
|
1236
|
+
/**
|
|
1237
|
+
* Fade playback weight to a target value.
|
|
1238
|
+
* @internal
|
|
1220
1239
|
*/ fadePlaybackTo(playback, weight, duration) {
|
|
1221
1240
|
const info = this._activeAnimations.get(playback.clip);
|
|
1222
1241
|
if (info?.playback === playback) {
|
|
@@ -1302,18 +1321,18 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1302
1321
|
crossedBackward(fromTime, toTime, targetTime, duration) {
|
|
1303
1322
|
return toTime <= fromTime ? targetTime < fromTime && targetTime >= toTime : duration > 0 && targetTime < fromTime && targetTime >= 0 || targetTime >= toTime;
|
|
1304
1323
|
}
|
|
1305
|
-
/**
|
|
1306
|
-
* Stop playback of an animation clip.
|
|
1307
|
-
*
|
|
1308
|
-
* Behavior:
|
|
1309
|
-
* - If `options.fadeOut > 0`, marks the clip for fade-out; actual removal occurs after fade completes.
|
|
1310
|
-
* - If `fadeOut` is 0 or omitted, immediately:
|
|
1311
|
-
* - Removes the clip from active animations.
|
|
1312
|
-
* - Unregisters its tracks from active track maps.
|
|
1313
|
-
* - Decrements skeleton reference counts; resets and removes skeletons when refcount reaches 0.
|
|
1314
|
-
*
|
|
1315
|
-
* @param name - Name of the animation to stop.
|
|
1316
|
-
* @param options - Optional fade-out configuration.
|
|
1324
|
+
/**
|
|
1325
|
+
* Stop playback of an animation clip.
|
|
1326
|
+
*
|
|
1327
|
+
* Behavior:
|
|
1328
|
+
* - If `options.fadeOut > 0`, marks the clip for fade-out; actual removal occurs after fade completes.
|
|
1329
|
+
* - If `fadeOut` is 0 or omitted, immediately:
|
|
1330
|
+
* - Removes the clip from active animations.
|
|
1331
|
+
* - Unregisters its tracks from active track maps.
|
|
1332
|
+
* - Decrements skeleton reference counts; resets and removes skeletons when refcount reaches 0.
|
|
1333
|
+
*
|
|
1334
|
+
* @param name - Name of the animation to stop.
|
|
1335
|
+
* @param options - Optional fade-out configuration.
|
|
1317
1336
|
*/ stopAnimation(name, options) {
|
|
1318
1337
|
const ani = this._animations[name];
|
|
1319
1338
|
if (!ani) {
|
|
@@ -1378,17 +1397,17 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1378
1397
|
}
|
|
1379
1398
|
}
|
|
1380
1399
|
}
|
|
1381
|
-
/**
|
|
1382
|
-
* Create a skeletal-only masked clip from an existing clip in this set.
|
|
1383
|
-
*
|
|
1384
|
-
* The generated clip is a regular `AnimationClip`: it contains cloned node transform tracks
|
|
1385
|
-
* for the selected rig joints and can be played/blended through the normal animation system.
|
|
1386
|
-
* Non-skeletal tracks are skipped by default.
|
|
1387
|
-
*
|
|
1388
|
-
* @param sourceName - Name of the source clip.
|
|
1389
|
-
* @param targetName - Name of the generated clip.
|
|
1390
|
-
* @param options - Humanoid semantic or joint-name based mask options.
|
|
1391
|
-
* @returns The generated clip, or null on failure.
|
|
1400
|
+
/**
|
|
1401
|
+
* Create a skeletal-only masked clip from an existing clip in this set.
|
|
1402
|
+
*
|
|
1403
|
+
* The generated clip is a regular `AnimationClip`: it contains cloned node transform tracks
|
|
1404
|
+
* for the selected rig joints and can be played/blended through the normal animation system.
|
|
1405
|
+
* Non-skeletal tracks are skipped by default.
|
|
1406
|
+
*
|
|
1407
|
+
* @param sourceName - Name of the source clip.
|
|
1408
|
+
* @param targetName - Name of the generated clip.
|
|
1409
|
+
* @param options - Humanoid semantic or joint-name based mask options.
|
|
1410
|
+
* @returns The generated clip, or null on failure.
|
|
1392
1411
|
*/ createSkeletalMaskedAnimation(sourceName, targetName, options) {
|
|
1393
1412
|
const sourceClip = this.get(sourceName);
|
|
1394
1413
|
if (!sourceClip) {
|
|
@@ -1595,21 +1614,21 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1595
1614
|
}
|
|
1596
1615
|
return dstClip;
|
|
1597
1616
|
}
|
|
1598
|
-
/**
|
|
1599
|
-
* Copy an animation clip from another AnimationSet into this one.
|
|
1600
|
-
*
|
|
1601
|
-
* Prerequisites:
|
|
1602
|
-
* - Both sets must reference skeletons with identical joint names and counts.
|
|
1603
|
-
* - The source clip must exist in `sourceSet`.
|
|
1604
|
-
*
|
|
1605
|
-
* @param sourceSet - The AnimationSet to copy from.
|
|
1606
|
-
* @param animationName - Name of the clip to copy.
|
|
1607
|
-
* @param targetName - Name for the new clip in this set. Defaults to `animationName`.
|
|
1608
|
-
* @param excludeJoint - Optional predicate; joints whose name returns true are excluded from
|
|
1609
|
-
* skeleton structure matching.
|
|
1610
|
-
* @returns The newly created AnimationClip, or null on failure.
|
|
1611
|
-
*
|
|
1612
|
-
* @deprecated Use AnimationSet.copyHumanoidAnimationFrom instead.
|
|
1617
|
+
/**
|
|
1618
|
+
* Copy an animation clip from another AnimationSet into this one.
|
|
1619
|
+
*
|
|
1620
|
+
* Prerequisites:
|
|
1621
|
+
* - Both sets must reference skeletons with identical joint names and counts.
|
|
1622
|
+
* - The source clip must exist in `sourceSet`.
|
|
1623
|
+
*
|
|
1624
|
+
* @param sourceSet - The AnimationSet to copy from.
|
|
1625
|
+
* @param animationName - Name of the clip to copy.
|
|
1626
|
+
* @param targetName - Name for the new clip in this set. Defaults to `animationName`.
|
|
1627
|
+
* @param excludeJoint - Optional predicate; joints whose name returns true are excluded from
|
|
1628
|
+
* skeleton structure matching.
|
|
1629
|
+
* @returns The newly created AnimationClip, or null on failure.
|
|
1630
|
+
*
|
|
1631
|
+
* @deprecated Use AnimationSet.copyHumanoidAnimationFrom instead.
|
|
1613
1632
|
*/ copyAnimationFrom(sourceSet, animationName, targetName, excludeJoint) {
|
|
1614
1633
|
const destName = targetName ?? animationName;
|
|
1615
1634
|
const sourceClip = sourceSet.get(animationName);
|
|
@@ -1755,8 +1774,8 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1755
1774
|
return ordered;
|
|
1756
1775
|
}
|
|
1757
1776
|
}
|
|
1758
|
-
/**
|
|
1759
|
-
* Reset all skeleton modifiers
|
|
1777
|
+
/**
|
|
1778
|
+
* Reset all skeleton modifiers
|
|
1760
1779
|
*/ resetSkeletonModifiers() {
|
|
1761
1780
|
for (const sk of this._skeletons){
|
|
1762
1781
|
for (const modifier of sk.get().modifiers){
|
|
@@ -1764,12 +1783,12 @@ class AnimationSet extends makeObservable(Disposable)() {
|
|
|
1764
1783
|
}
|
|
1765
1784
|
}
|
|
1766
1785
|
}
|
|
1767
|
-
/**
|
|
1768
|
-
* Dispose the animation set and release owned resources.
|
|
1769
|
-
*
|
|
1770
|
-
* - Disposes the weak reference to the model.
|
|
1771
|
-
* - Disposes all registered animation clips.
|
|
1772
|
-
* - Clears active animations, tracks, and skeleton references.
|
|
1786
|
+
/**
|
|
1787
|
+
* Dispose the animation set and release owned resources.
|
|
1788
|
+
*
|
|
1789
|
+
* - Disposes the weak reference to the model.
|
|
1790
|
+
* - Disposes all registered animation clips.
|
|
1791
|
+
* - Clears active animations, tracks, and skeleton references.
|
|
1773
1792
|
*/ onDispose() {
|
|
1774
1793
|
super.onDispose();
|
|
1775
1794
|
for(const k in this._animations){
|