Skip to content

Commit 555b715

Browse files
regnaiogbzclaudelocal
authored
Restore AnimatorAvatar fixes from Claude (#18248)
Please see @Popov72 's comment here: #18234 (comment) I accidentally removed some of the fixes from Claude, and this PR looks to restore them. Thank you for your help! --------- Co-authored-by: gbz <gbz@gbzs-MacBook-Pro.local> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: local <local@local.local>
1 parent d562bd9 commit 555b715

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

packages/dev/core/src/Animations/animatorAvatar.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -820,29 +820,29 @@ export class AnimatorAvatar {
820820
}
821821
} else {
822822
// No axis provided: assume the vertical axis is the one with the larger difference between the reference and the ground reference transform nodes
823-
if (Math.abs(sourceRootGroundReferenceDiff.y) > Math.abs(sourceRootGroundReferenceDiff.x)) {
823+
const absX = Math.abs(sourceRootGroundReferenceDiff.x);
824+
const absY = Math.abs(sourceRootGroundReferenceDiff.y);
825+
const absZ = Math.abs(sourceRootGroundReferenceDiff.z);
826+
if (absY > absX && absY >= absZ) {
824827
verticalAxis = 1;
825-
}
826-
if (Math.abs(sourceRootGroundReferenceDiff.z) > Math.abs(sourceRootGroundReferenceDiff.y)) {
828+
} else if (absZ > absX && absZ > absY) {
827829
verticalAxis = 2;
828830
}
829831
}
830832

831833
const targetRootGroundReferenceDiff = targetRootTransformNodeOrBone.getAbsolutePosition().subtract(targetGroundReferenceTransformNodeOrBone.getAbsolutePosition());
832834

835+
const sourceDiff = verticalAxis === 0 ? sourceRootGroundReferenceDiff.x : verticalAxis === 1 ? sourceRootGroundReferenceDiff.y : sourceRootGroundReferenceDiff.z;
836+
const targetDiff = verticalAxis === 0 ? targetRootGroundReferenceDiff.x : verticalAxis === 1 ? targetRootGroundReferenceDiff.y : targetRootGroundReferenceDiff.z;
837+
833838
return {
834839
verticalAxis,
835840
sourceRootTransformNode,
836841
sourceGroundReferenceTransformNode,
837842
targetRootTransformNodeOrBone,
838843
targetRootPositionAnimation,
839844
targetGroundReferenceTransformNodeOrBone,
840-
proportionRatio:
841-
verticalAxis === 0
842-
? targetRootGroundReferenceDiff.x / sourceRootGroundReferenceDiff.x
843-
: verticalAxis === 1
844-
? targetRootGroundReferenceDiff.y / sourceRootGroundReferenceDiff.y
845-
: targetRootGroundReferenceDiff.z / sourceRootGroundReferenceDiff.z,
845+
proportionRatio: sourceDiff !== 0 ? targetDiff / sourceDiff : 1.0,
846846
};
847847
}
848848

0 commit comments

Comments
 (0)