-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hasExitTime and fix error when set state startTime and transition duration is 0 #2359
Conversation
…to feat/animatorTransition
WalkthroughThe changes encompass enhancements to the animation system, focusing on state transitions and exit time management. Key modifications include the introduction of the Changes
Sequence Diagram(s)sequenceDiagram
participant Animator
participant AnimatorStateMachine
participant AnimatorStateTransition
Animator->>AnimatorStateMachine: Request transition
AnimatorStateMachine->>AnimatorStateTransition: Check hasExitTime
alt hasExitTime is true
AnimatorStateTransition->>AnimatorStateMachine: Retrieve exit time
AnimatorStateMachine->>AnimatorStateTransition: Determine transition order
else hasExitTime is false
AnimatorStateTransition->>AnimatorStateMachine: Add transition to front
end
AnimatorStateMachine->>Animator: Execute transition
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- packages/core/src/animation/Animator.ts (8 hunks)
- packages/core/src/animation/AnimatorState.ts (1 hunks)
- packages/core/src/animation/AnimatorStateMachine.ts (3 hunks)
- packages/core/src/animation/AnimatorStateTransition.ts (1 hunks)
- packages/loader/src/AnimatorControllerLoader.ts (3 hunks)
- tests/src/core/Animator.test.ts (6 hunks)
Additional comments not posted (31)
packages/core/src/animation/AnimatorStateTransition.ts (1)
20-21
: LGTM!The
hasExitTime
property is correctly added and initialized.The code changes are approved.
packages/core/src/animation/AnimatorStateMachine.ts (3)
97-98
: LGTM!The comment update enhances the clarity of the method behavior.
The code changes are approved.
121-122
: LGTM!The comment update enhances the clarity of the method behavior.
The code changes are approved.
145-145
: LGTM!The initialization of
hasExitTime
tofalse
ensures consistent default behavior for transitions.The code changes are approved.
packages/loader/src/AnimatorControllerLoader.ts (2)
118-118
: LGTM!The assignment of
hasExitTime
ensures that the property is correctly propagated from the transition data to the transition object.The code changes are approved.
159-159
: LGTM!The addition of
hasExitTime
toITransitionData
enhances the data structure to include additional state information.The code changes are approved.
packages/core/src/animation/AnimatorState.ts (3)
115-115
: Ensure proper handling of transition source state.The transition's source state is correctly set to
this
.The code changes are approved.
116-125
: Handle transitions with exit time correctly.The logic correctly handles transitions with
hasExitTime
by inserting them in the appropriate position based on theirexitTime
.The code changes are approved.
127-127
: Handle transitions without exit time correctly.The logic correctly handles transitions without
hasExitTime
by adding them to the front of the_transitions
array.The code changes are approved.
tests/src/core/Animator.test.ts (14)
567-568
: Ensure proper instantiation of Entity and Animator components.The
Entity
andAnimator
components are correctly instantiated and added.The code changes are approved.
568-568
: Ensure proper instantiation of AnimatorController.The
AnimatorController
is correctly instantiated and assigned to theanimator
.The code changes are approved.
645-646
: Ensure proper instantiation of Entity and Animator components.The
Entity
andAnimator
components are correctly instantiated and added.The code changes are approved.
646-646
: Ensure proper instantiation of AnimatorController.The
AnimatorController
is correctly instantiated and assigned to theanimator
.The code changes are approved.
713-714
: Ensure proper handling of animatorController and layerData.The
animatorController
andlayerData
are correctly handled.The code changes are approved.
714-717
: Ensure proper addition of parameter and state machine transitions.The
playRun
parameter is correctly added, and state machine transitions are correctly handled.The code changes are approved.
725-725
: Ensure proper handling of clipStartTime.The
clipStartTime
is correctly set to 0.5 for thewalkState
.The code changes are approved.
733-737
: Ensure proper handling of transition conditions and duration.The transition conditions and duration are correctly handled.
The code changes are approved.
739-747
: Ensure proper handling of animator play and update logic.The animator play and update logic are correctly handled.
The code changes are approved.
749-751
: Ensure proper handling of animatorController and layerData.The
animatorController
andlayerData
are correctly handled.The code changes are approved.
751-755
: Ensure proper addition of parameter and state machine transitions.The
triggerIdle
parameter is correctly added, and state machine transitions are correctly handled.The code changes are approved.
763-767
: Ensure proper handling of state transitions.The state transitions for
idleState
,walkState
, andrunState
are correctly handled.The code changes are approved.
771-775
: Ensure proper handling of transition properties.The transition properties
hasExitTime
,exitTime
, andduration
are correctly handled.The code changes are approved.
776-797
: Ensure proper handling of animator play and update logic.The animator play and update logic are correctly handled.
The code changes are approved.
packages/core/src/animation/Animator.ts (8)
556-567
: LGTM!The method
_applyStateTransitions
is correctly implemented with the additional parameters.The code changes are approved.
667-672
: LGTM!The method
_updateCrossFadeState
correctly uses the new parametercrossFadeTransition
and updates the logic for calculatingtransitionDuration
.The code changes are approved.
Line range hint
1107-1133
: LGTM!The method
_checkSubTransition
correctly includes logic for handlinghasExitTime
.The code changes are approved.
1142-1148
: LGTM!The method
_checkBackwardsSubTransition
correctly includes logic for handlinghasExitTime
.The code changes are approved.
Line range hint
1155-1164
: LGTM!The method
_applyTransitionsByCondition
has been correctly replaced with_applyStateTransitions
.The code changes are approved.
Line range hint
1185-1211
: LGTM!The method
_prepareCrossFadeByTransition
correctly includes logic for handlingcrossFadeTransition
.The code changes are approved.
819-819
: LGTM!The method
_updateCrossFadeFromPoseState
correctly uses the new parametercrossFadeTransition
and updates the logic for calculatingtransitionDuration
.The code changes are approved.
Line range hint
72-72
: Verify the impact of the method signature change.The parameter
aniUpdate
has been replaced withdeltaTime
. Ensure that all calls to theupdate
method have been updated accordingly.Run the following script to verify the method usage:
Verification successful
Method Signature Change Verified
The change in the
update
method's signature fromaniUpdate
todeltaTime
has been correctly propagated throughout the codebase. Test files such astests/src/core/Animator.test.ts
are using the method with the expected argument type. No further action is required.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to the `update` method match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type ts -A 5 $'update('Length of output: 94
Script:
#!/bin/bash # Description: Verify all calls to the `update` method match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type ts -A 5 $'update\\('Length of output: 52523
…sition duration is 0
f3d3d78
to
e127b27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- packages/core/src/animation/Animator.ts (7 hunks)
- packages/core/src/animation/AnimatorStateMachine.ts (3 hunks)
- packages/core/src/animation/AnimatorStateTransition.ts (1 hunks)
- packages/loader/src/AnimatorControllerLoader.ts (3 hunks)
- tests/src/core/Animator.test.ts (6 hunks)
Files skipped from review due to trivial changes (1)
- packages/core/src/animation/AnimatorStateMachine.ts
Files skipped from review as they are similar to previous changes (3)
- packages/core/src/animation/Animator.ts
- packages/core/src/animation/AnimatorStateTransition.ts
- packages/loader/src/AnimatorControllerLoader.ts
Additional comments not posted (5)
tests/src/core/Animator.test.ts (5)
19-19
: LGTM!The import statement for
Entity
is correct.The code changes are approved.
567-568
: LGTM!The code correctly creates an
Entity
and adds anAnimator
component to it.The code changes are approved.
645-646
: LGTM!The code correctly creates an
Entity
and adds anAnimator
component to it.The code changes are approved.
713-747
: LGTM!The test case correctly tests the
anyTransition
feature. It ensures that the animator transitions to the correct state when theplayRun
parameter is set to 1.The code changes are approved.
749-797
: LGTM!The test case correctly tests the
hasExitTime
feature. It ensures that the animator transitions to the correct state based on thehasExitTime
andexitTime
properties.The code changes are approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/core/src/animation/AnimatorState.ts (2 hunks)
- packages/core/src/animation/AnimatorStateTransition.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- packages/core/src/animation/AnimatorState.ts
- packages/core/src/animation/AnimatorStateTransition.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/core/src/animation/Animator.ts (7 hunks)
- packages/core/src/animation/AnimatorState.ts (2 hunks)
- packages/core/src/animation/AnimatorStateTransition.ts (2 hunks)
Files skipped from review as they are similar to previous changes (3)
- packages/core/src/animation/Animator.ts
- packages/core/src/animation/AnimatorState.ts
- packages/core/src/animation/AnimatorStateTransition.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- packages/core/src/animation/Animator.ts (17 hunks)
- packages/core/src/animation/AnimatorState.ts (5 hunks)
- packages/core/src/animation/AnimatorStateMachine.ts (6 hunks)
- packages/core/src/animation/AnimatorStateTransition.ts (4 hunks)
- packages/core/src/animation/internal/AnimatorLayerData.ts (1 hunks)
- packages/core/src/animation/internal/TransitionSource.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/core/src/animation/AnimatorStateMachine.ts
Additional comments not posted (25)
packages/core/src/animation/internal/AnimatorLayerData.ts (1)
17-17
: LGTM! But verify the property usage in the codebase.The property
anyTransitionIndex
is correctly added to the class. Ensure that it is used appropriately in the codebase.The code changes are approved.
Run the following script to verify the property usage:
Verification successful
Property
anyTransitionIndex
is used correctly in the codebase.The
anyTransitionIndex
property is integrated into the logic of theAnimator.ts
file, where it is used to manage transition indices appropriately. No issues were found with its usage.
- Files Involved:
packages/core/src/animation/Animator.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all usages of `anyTransitionIndex` in the codebase. # Test: Search for the property usage. Expect: Appropriate usage across the codebase. rg --type python -A 5 $'anyTransitionIndex'Length of output: 73
Script:
#!/bin/bash # Description: Verify all usages of `anyTransitionIndex` in the codebase. # Test: Search for the property usage. Expect: Appropriate usage across the codebase. rg --type ts -A 5 'anyTransitionIndex'Length of output: 3789
packages/core/src/animation/internal/TransitionSource.ts (5)
8-8
: LGTM!The abstract method
_updateTransitionsIndex
is correctly defined.The code changes are approved.
9-9
: LGTM!The abstract method
_updateSoloTransition
is correctly defined.The code changes are approved.
11-31
: LGTM!The method
_addTransition
is correctly implemented and handles bothAnimatorStateTransition
andAnimatorState
appropriately.The code changes are approved.
33-37
: LGTM!The method
_removeTransition
is correctly implemented and handles the removal of transitions appropriately.The code changes are approved.
39-53
: LGTM!The method
_addHasExitTimeTransition
is correctly implemented and handles the addition of transitions with exit times appropriately.The code changes are approved.
packages/core/src/animation/AnimatorStateTransition.ts (7)
5-5
: LGTM!The import statement for
TransitionSource
is correctly added.The code changes are approved.
25-25
: LGTM!The property
_isEntry
is correctly added and initialized tofalse
.The code changes are approved.
27-27
: LGTM!The property
_isAny
is correctly added and initialized tofalse
.The code changes are approved.
33-33
: LGTM!The property
_hasExitTime
is correctly added and initialized totrue
.The code changes are approved.
52-52
: LGTM!The setter for
solo
is correctly implemented and includes logic to update the transition index through the_source
.The code changes are approved.
64-72
: LGTM!The getter and setter for
hasExitTime
are correctly implemented. The setter includes logic to update the transition index through the_source
.The code changes are approved.
23-23
: LGTM! But verify the property usage in the codebase.The property
_source
is correctly added to the class. Ensure that it is used appropriately in the codebase.The code changes are approved.
Run the following script to verify the property usage:
Verification successful
The
_source
property is used appropriately across the codebase.The
_source
property is integrated and utilized in various files, indicating that it is functioning as intended.
- Files with
_source
usage:
packages/shader-lab/src/lexer/Lexer.ts
packages/shader-lab/src/contentParser/Scanner.ts
packages/shader-lab/src/preprocessor/PpScanner.ts
packages/shader-lab/src/common/BaseScanner.ts
packages/core/src/animation/AnimatorStateTransition.ts
packages/core/src/animation/Animator.ts
packages/core/src/animation/internal/TransitionSource.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all usages of `_source` in the codebase. # Test: Search for the property usage. Expect: Appropriate usage across the codebase. rg --type python -A 5 $'_source'Length of output: 62
Script:
#!/bin/bash # Description: Verify all usages of `_source` in the TypeScript codebase. # Test: Search for the property usage. Expect: Appropriate usage across the codebase. rg --type ts -A 5 '_source'Length of output: 14009
packages/core/src/animation/AnimatorState.ts (6)
11-11
: LGTM!The class extension is correctly implemented.
The code changes are approved.
107-108
: LGTM!The refactoring improves readability and maintainability.
The code changes are approved.
121-121
: LGTM!The refactoring improves readability and maintainability.
The code changes are approved.
128-132
: LGTM!The refactoring improves readability and maintainability.
The code changes are approved.
203-211
: LGTM!The method improves the control flow and logic of the class.
The code changes are approved.
216-216
: LGTM!The refactoring improves the handling of transitions based on their exit status.
The code changes are approved.
packages/core/src/animation/Animator.ts (6)
557-569
: LGTM!The refactoring improves the calculation of play cost time during animations.
The code changes are approved.
590-609
: LGTM!The refactoring improves the accuracy of play cost time calculations.
The code changes are approved.
689-697
: LGTM!The refactoring improves the handling of cross fade transitions.
The code changes are approved.
Line range hint
924-936
: LGTM!The refactoring improves the handling of finished states.
The code changes are approved.
Line range hint
1005-1103
: LGTM!The method improves the control flow and logic of the class.
The code changes are approved.
1128-1147
: LGTM!The refactoring improves the handling of sub transitions.
The code changes are approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/core/src/animation/Animator.ts (17 hunks)
- packages/core/src/animation/AnimatorStateMachine.ts (6 hunks)
- tests/src/core/Animator.test.ts (6 hunks)
Additional comments not posted (17)
packages/core/src/animation/AnimatorStateMachine.ts (7)
3-3
: LGTM!The new inheritance from
TransitionSource
enhances the capabilities ofAnimatorStateMachine
for transition management.The code changes are approved.
Also applies to: 11-11
22-22
: LGTM!The new internal properties
_entryHasSolo
and_anyHasSolo
effectively track the solo state of transitions.The code changes are approved.
Also applies to: 25-25
104-104
: LGTM!The updated logic in
addEntryStateTransition
ensures that entry transitions are correctly flagged and solo states are updated.The code changes are approved.
Also applies to: 111-114
123-123
: LGTM!The updated logic in
removeEntryStateTransition
correctly resets the_isEntry
flag.The code changes are approved.
132-132
: LGTM!The updated logic in
addAnyStateTransition
ensures that any state transitions are correctly flagged and solo states are updated.The code changes are approved.
Also applies to: 138-141
150-150
: LGTM!The updated logic in
removeAnyStateTransition
correctly resets the_isAny
flag.The code changes are approved.
156-162
: LGTM!The new internal methods
_updateTransitionsIndex
and_updateSoloTransition
enhance the transition management capabilities of the state machine.The code changes are approved.
Also applies to: 169-186
tests/src/core/Animator.test.ts (4)
19-19
: LGTM!The addition of
Entity
is appropriate for the new test cases.The code changes are approved.
719-753
: LGTM!The new test case for
anyTransition
ensures that the functionality is correctly validated.The code changes are approved.
755-803
: LGTM!The new test case for
hasExitTime
ensures that the functionality is correctly validated.The code changes are approved.
Line range hint
651-703
: LGTM!The new test case for
stateMachineScript
ensures that the functionality is correctly validated.The code changes are approved.
packages/core/src/animation/Animator.ts (6)
13-13
: LGTM!The import of
AnimatorStateMachine
is necessary for the new transition logic.The code changes are approved.
Line range hint
100-100
: LGTM!The change in the method signature from
aniUpdate: boolean
todeltaTime: number
improves clarity and aligns with standard practices. The logic inside the method correctly handles the new parameter.The code changes are approved.
557-569
: LGTM!The replacement of
_applyTransitionsByCondition
with_applyStateTransitions
provides a more detailed and conditionally nuanced approach to managing transitions. The additional parameters improve the flexibility and accuracy of the transition logic.The code changes are approved.
590-609
: LGTM!The updated logic correctly handles the
hasExitTime
property, ensuring accurate calculations ofplayCostTime
based on the playback direction.The code changes are approved.
689-697
: LGTM!The refined handling of
crossFadeTransition
ensures that the transition duration is accurately calculated based on the current state data.The code changes are approved.
Line range hint
1005-1103
: LGTM!The introduction of
_applyStateTransitions
with additional parameters and refined logic improves the robustness and adaptability of the state transition management.The code changes are approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/core/src/animation/Animator.ts (17 hunks)
Additional comments not posted (12)
packages/core/src/animation/Animator.ts (12)
557-569
: LGTM!The
_applyStateTransitions
method has been updated to handle state transitions with exit times. The additional parameters and logic enhance the transition handling.The code changes are approved.
590-609
: LGTM!The
_updatePlayingState
method has been updated to include logic for calculatingplayCostTime
based ontransition.hasExitTime
. This enhances the accuracy of the animation state updates.The code changes are approved.
689-697
: LGTM!The
_updateCrossFadeState
method has been updated to include logic for calculatingdstPlayCostTime
based ontransitionDuration
. This enhances the accuracy of the cross-fade state updates.The code changes are approved.
Line range hint
924-936
: LGTM!The
_updateFinishedState
method has been updated to include logic for applying state transitions with exit times. This enhances the accuracy of the finished state updates.The code changes are approved.
1214-1231
: LGTM!The
_applyTransitionsByCondition
method has been updated to include logic for applying transitions with exit times. This enhances the accuracy of the transition handling based on conditions.The code changes are approved.
1123-1148
: LGTM!The
_checkSubTransition
method has been updated to include logic for checking and applying transitions with exit times. This enhances the accuracy of the sub-transition handling.The code changes are approved.
1168-1196
: LGTM!The
_checkBackwardsSubTransition
method has been updated to include logic for checking and applying backwards transitions with exit times. This enhances the accuracy of the backwards sub-transition handling.The code changes are approved.
Line range hint
1258-1273
: LGTM!The
_prepareCrossFadeByTransition
method has been updated to include logic for preparing cross-fade transitions with exit times. This enhances the accuracy of the cross-fade preparation.The code changes are approved.
Line range hint
1275-1295
: LGTM!The
_checkConditions
method has been updated to include logic for checking conditions for transitions with exit times. This enhances the accuracy of the condition checking.The code changes are approved.
Line range hint
69-69
: LGTM!The
update
method signature has been updated to includedeltaTime
. This enhances the clarity and accuracy of the update process.The code changes are approved.
Line range hint
1204-1204
: LGTM!The
_fireAnimationEvents
method has been updated to include logic for firing animation events based on transitions with exit times. This enhances the accuracy of the event handling.The code changes are approved.
Line range hint
1204-1204
: LGTM!The
_fireBackwardSubAnimationEvents
method has been updated to include logic for firing backward sub-animation events based on transitions with exit times. This enhances the accuracy of the event handling.The code changes are approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- packages/core/src/animation/AnimatorState.ts (4 hunks)
- packages/core/src/animation/AnimatorStateMachine.ts (4 hunks)
- packages/core/src/animation/AnimatorStateTransition.ts (4 hunks)
- packages/core/src/animation/internal/TransitionUtil.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/core/src/animation/AnimatorStateMachine.ts
Additional context used
Biome
packages/core/src/animation/internal/TransitionUtil.ts
[error] 8-50: Avoid classes that contain only static members.
Prefer using simple functions instead of classes with only static members.
(lint/complexity/noStaticOnlyClass)
[error] 25-25: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.(lint/complexity/noThisInStatic)
Additional comments not posted (12)
packages/core/src/animation/internal/TransitionUtil.ts (1)
8-50
: Refactor to use simple functions and replacethis
with the class name.The class contains only static methods, which can be refactored to use simple functions. Using
this
in a static context can be confusing and should be replaced with the class name.Apply this diff to refactor the class:
-export class TransitionUtil { - static addTransition( - source: AnimatorState | AnimatorStateMachine, - transitionOrAnimatorState: AnimatorStateTransition | AnimatorState, - transitions: AnimatorStateTransition[] - ): AnimatorStateTransition { +export function addTransition( + source: AnimatorState | AnimatorStateMachine, + transitionOrAnimatorState: AnimatorStateTransition | AnimatorState, + transitions: AnimatorStateTransition[] +): AnimatorStateTransition { let transition: AnimatorStateTransition; if (transitionOrAnimatorState instanceof AnimatorState) { transition = new AnimatorStateTransition(); transition.hasExitTime = false; transition.destinationState = transitionOrAnimatorState; } else { transition = transitionOrAnimatorState; } transition._source = source; if (transition.hasExitTime) { - this.addHasExitTimeTransition(transition, transitions); + addHasExitTimeTransition(transition, transitions); } else { transitions.unshift(transition); } return transition; - } +} - static removeTransition(transition: AnimatorStateTransition, transitions: AnimatorStateTransition[]): void { +export function removeTransition(transition: AnimatorStateTransition, transitions: AnimatorStateTransition[]): void { const index = transitions.indexOf(transition); index !== -1 && transitions.splice(index, 1); transition._source = null; - } +} - static addHasExitTimeTransition(transition: AnimatorStateTransition, transitions: AnimatorStateTransition[]): void { +export function addHasExitTimeTransition(transition: AnimatorStateTransition, transitions: AnimatorStateTransition[]): void { const time = transition.exitTime; const count = transitions.length; const maxExitTime = count ? transitions[count - 1].exitTime : 0; if (time >= maxExitTime) { transitions.push(transition); } else { let index = count; while (--index >= 0 && time < transitions[index].exitTime); transitions.splice(index + 1, 0, transition); } - } -} +}Tools
Biome
[error] 8-50: Avoid classes that contain only static members.
Prefer using simple functions instead of classes with only static members.
(lint/complexity/noStaticOnlyClass)
[error] 25-25: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.(lint/complexity/noThisInStatic)
packages/core/src/animation/AnimatorStateTransition.ts (5)
23-23
: LGTM!The updated type for
_source
provides more flexibility in representing the source of the transition.The code changes are approved.
25-25
: LGTM!The new
_isEntry
property enhances the state management capabilities within the animator.The code changes are approved.
27-27
: LGTM!The new
_isAny
property enhances the state management capabilities within the animator.The code changes are approved.
33-33
: LGTM!The new
_hasExitTime
property provides better control over the transition's exit time condition.The code changes are approved.
64-72
: LGTM!The
hasExitTime
getter and setter provide better encapsulation and control over the transition's exit time condition. The setter's logic ensures that the transition index is updated correctly.The code changes are approved.
packages/core/src/animation/AnimatorState.ts (6)
5-5
: LGTM!The import statement for
TransitionUtil
is necessary for utilizing the class.The code changes are approved.
106-107
: LGTM!The refactoring of the
addTransition
method simplifies the logic and improves readability.The code changes are approved.
120-120
: LGTM!The update to the
addExitTransition
method promotes code reuse and maintainability.The code changes are approved.
127-131
: LGTM!The update to the
removeTransition
method centralizes the logic for removing transitions and enhances clarity.The code changes are approved.
202-210
: LGTM!The new
_updateTransitionsIndex
method refines the control flow and logic within the class by handling the ordering of transitions based on their exit times.The code changes are approved.
215-215
: LGTM!The modification to the
_updateSoloTransition
method allows it to manage transitions more effectively based on their exit status.The code changes are approved.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
What is the current behavior? (You can also link to an open issue here)
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
Other information:
Summary by CodeRabbit
New Features
hasExitTime
property for more nuanced control over transitions.AnimatorStateTransitionCollection
for structured transition management.Bug Fixes
Documentation
Tests