-
-
Notifications
You must be signed in to change notification settings - Fork 384
Add hasExitTime and fix error when set state startTime and transition duration is 0 #2359
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
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
hasExitTimeproperty 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
hasExitTimetofalseensures consistent default behavior for transitions.The code changes are approved.
packages/loader/src/AnimatorControllerLoader.ts (2)
118-118: LGTM!The assignment of
hasExitTimeensures 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
hasExitTimetoITransitionDataenhances 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
hasExitTimeby 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
hasExitTimeby adding them to the front of the_transitionsarray.The code changes are approved.
tests/src/core/Animator.test.ts (14)
567-568: Ensure proper instantiation of Entity and Animator components.The
EntityandAnimatorcomponents are correctly instantiated and added.The code changes are approved.
568-568: Ensure proper instantiation of AnimatorController.The
AnimatorControlleris correctly instantiated and assigned to theanimator.The code changes are approved.
645-646: Ensure proper instantiation of Entity and Animator components.The
EntityandAnimatorcomponents are correctly instantiated and added.The code changes are approved.
646-646: Ensure proper instantiation of AnimatorController.The
AnimatorControlleris correctly instantiated and assigned to theanimator.The code changes are approved.
713-714: Ensure proper handling of animatorController and layerData.The
animatorControllerandlayerDataare correctly handled.The code changes are approved.
714-717: Ensure proper addition of parameter and state machine transitions.The
playRunparameter is correctly added, and state machine transitions are correctly handled.The code changes are approved.
725-725: Ensure proper handling of clipStartTime.The
clipStartTimeis 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
animatorControllerandlayerDataare correctly handled.The code changes are approved.
751-755: Ensure proper addition of parameter and state machine transitions.The
triggerIdleparameter 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, andrunStateare correctly handled.The code changes are approved.
771-775: Ensure proper handling of transition properties.The transition properties
hasExitTime,exitTime, anddurationare 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
_applyStateTransitionsis correctly implemented with the additional parameters.The code changes are approved.
667-672: LGTM!The method
_updateCrossFadeStatecorrectly uses the new parametercrossFadeTransitionand updates the logic for calculatingtransitionDuration.The code changes are approved.
Line range hint
1107-1133: LGTM!The method
_checkSubTransitioncorrectly includes logic for handlinghasExitTime.The code changes are approved.
1142-1148: LGTM!The method
_checkBackwardsSubTransitioncorrectly includes logic for handlinghasExitTime.The code changes are approved.
Line range hint
1155-1164: LGTM!The method
_applyTransitionsByConditionhas been correctly replaced with_applyStateTransitions.The code changes are approved.
Line range hint
1185-1211: LGTM!The method
_prepareCrossFadeByTransitioncorrectly includes logic for handlingcrossFadeTransition.The code changes are approved.
819-819: LGTM!The method
_updateCrossFadeFromPoseStatecorrectly uses the new parametercrossFadeTransitionand 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
aniUpdatehas been replaced withdeltaTime. Ensure that all calls to theupdatemethod have been updated accordingly.Run the following script to verify the method usage:
Verification successful
Method Signature Change Verified
The change in the
updatemethod's signature fromaniUpdatetodeltaTimehas been correctly propagated throughout the codebase. Test files such astests/src/core/Animator.test.tsare 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
Entityis correct.The code changes are approved.
567-568: LGTM!The code correctly creates an
Entityand adds anAnimatorcomponent to it.The code changes are approved.
645-646: LGTM!The code correctly creates an
Entityand adds anAnimatorcomponent to it.The code changes are approved.
713-747: LGTM!The test case correctly tests the
anyTransitionfeature. It ensures that the animator transitions to the correct state when theplayRunparameter is set to 1.The code changes are approved.
749-797: LGTM!The test case correctly tests the
hasExitTimefeature. It ensures that the animator transitions to the correct state based on thehasExitTimeandexitTimeproperties.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
anyTransitionIndexis 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
anyTransitionIndexis used correctly in the codebase.The
anyTransitionIndexproperty is integrated into the logic of theAnimator.tsfile, where it is used to manage transition indices appropriately. No issues were found with its usage.
- Files Involved:
packages/core/src/animation/Animator.tsScripts 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
_updateTransitionsIndexis correctly defined.The code changes are approved.
9-9: LGTM!The abstract method
_updateSoloTransitionis correctly defined.The code changes are approved.
11-31: LGTM!The method
_addTransitionis correctly implemented and handles bothAnimatorStateTransitionandAnimatorStateappropriately.The code changes are approved.
33-37: LGTM!The method
_removeTransitionis correctly implemented and handles the removal of transitions appropriately.The code changes are approved.
39-53: LGTM!The method
_addHasExitTimeTransitionis 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
TransitionSourceis correctly added.The code changes are approved.
25-25: LGTM!The property
_isEntryis correctly added and initialized tofalse.The code changes are approved.
27-27: LGTM!The property
_isAnyis correctly added and initialized tofalse.The code changes are approved.
33-33: LGTM!The property
_hasExitTimeis correctly added and initialized totrue.The code changes are approved.
52-52: LGTM!The setter for
solois 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
hasExitTimeare 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
_sourceis 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
_sourceproperty is used appropriately across the codebase.The
_sourceproperty is integrated and utilized in various files, indicating that it is functioning as intended.
- Files with
_sourceusage:
packages/shader-lab/src/lexer/Lexer.tspackages/shader-lab/src/contentParser/Scanner.tspackages/shader-lab/src/preprocessor/PpScanner.tspackages/shader-lab/src/common/BaseScanner.tspackages/core/src/animation/AnimatorStateTransition.tspackages/core/src/animation/Animator.tspackages/core/src/animation/internal/TransitionSource.tsScripts 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
TransitionSourceenhances the capabilities ofAnimatorStateMachinefor transition management.The code changes are approved.
Also applies to: 11-11
22-22: LGTM!The new internal properties
_entryHasSoloand_anyHasSoloeffectively track the solo state of transitions.The code changes are approved.
Also applies to: 25-25
104-104: LGTM!The updated logic in
addEntryStateTransitionensures 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
removeEntryStateTransitioncorrectly resets the_isEntryflag.The code changes are approved.
132-132: LGTM!The updated logic in
addAnyStateTransitionensures 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
removeAnyStateTransitioncorrectly resets the_isAnyflag.The code changes are approved.
156-162: LGTM!The new internal methods
_updateTransitionsIndexand_updateSoloTransitionenhance 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
Entityis appropriate for the new test cases.The code changes are approved.
719-753: LGTM!The new test case for
anyTransitionensures that the functionality is correctly validated.The code changes are approved.
755-803: LGTM!The new test case for
hasExitTimeensures that the functionality is correctly validated.The code changes are approved.
Line range hint
651-703: LGTM!The new test case for
stateMachineScriptensures that the functionality is correctly validated.The code changes are approved.
packages/core/src/animation/Animator.ts (6)
13-13: LGTM!The import of
AnimatorStateMachineis 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: booleantodeltaTime: numberimproves 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
_applyTransitionsByConditionwith_applyStateTransitionsprovides 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
hasExitTimeproperty, ensuring accurate calculations ofplayCostTimebased on the playback direction.The code changes are approved.
689-697: LGTM!The refined handling of
crossFadeTransitionensures 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
_applyStateTransitionswith 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
_applyStateTransitionsmethod 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
_updatePlayingStatemethod has been updated to include logic for calculatingplayCostTimebased ontransition.hasExitTime. This enhances the accuracy of the animation state updates.The code changes are approved.
689-697: LGTM!The
_updateCrossFadeStatemethod has been updated to include logic for calculatingdstPlayCostTimebased ontransitionDuration. This enhances the accuracy of the cross-fade state updates.The code changes are approved.
Line range hint
924-936: LGTM!The
_updateFinishedStatemethod 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
_applyTransitionsByConditionmethod 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
_checkSubTransitionmethod 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
_checkBackwardsSubTransitionmethod 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
_prepareCrossFadeByTransitionmethod 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
_checkConditionsmethod 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
updatemethod 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
_fireAnimationEventsmethod 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
_fireBackwardSubAnimationEventsmethod 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 replacethiswith the class name.The class contains only static methods, which can be refactored to use simple functions. Using
thisin 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
_sourceprovides more flexibility in representing the source of the transition.The code changes are approved.
25-25: LGTM!The new
_isEntryproperty enhances the state management capabilities within the animator.The code changes are approved.
27-27: LGTM!The new
_isAnyproperty enhances the state management capabilities within the animator.The code changes are approved.
33-33: LGTM!The new
_hasExitTimeproperty provides better control over the transition's exit time condition.The code changes are approved.
64-72: LGTM!The
hasExitTimegetter 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
TransitionUtilis necessary for utilizing the class.The code changes are approved.
106-107: LGTM!The refactoring of the
addTransitionmethod simplifies the logic and improves readability.The code changes are approved.
120-120: LGTM!The update to the
addExitTransitionmethod promotes code reuse and maintainability.The code changes are approved.
127-131: LGTM!The update to the
removeTransitionmethod centralizes the logic for removing transitions and enhances clarity.The code changes are approved.
202-210: LGTM!The new
_updateTransitionsIndexmethod 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
_updateSoloTransitionmethod 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
hasExitTimeproperty for more nuanced control over transitions.AnimatorStateTransitionCollectionfor structured transition management.Bug Fixes
Documentation
Tests