diff --git a/avatars/AnimationMapping.js b/avatars/AnimationMapping.js index 5810ac8c69..f56974ad0e 100644 --- a/avatars/AnimationMapping.js +++ b/avatars/AnimationMapping.js @@ -1,72 +1,73 @@ class AnimationMapping { - constructor(animationTrackName, boneName, isTop, isPosition) { + constructor(animationTrackName, boneName, isTop, isPosition, isArm) { this.animationTrackName = animationTrackName; this.boneName = boneName; this.isTop = isTop; + this.isArm = isArm; this.isPosition = isPosition; } clone() { - return new AnimationMapping(this.animationTrackName, this.boneName, this.isTop, this.isPosition); + return new AnimationMapping(this.animationTrackName, this.boneName, this.isTop, this.isPosition, this.isArm); } } export const animationMappingConfig = [ - new AnimationMapping('mixamorigHips.position', 'Hips', false, true), - new AnimationMapping('mixamorigHips.quaternion', 'Hips', false, false), - new AnimationMapping('mixamorigSpine.quaternion', 'Spine', true, false), - new AnimationMapping('mixamorigSpine1.quaternion', 'Chest', true, false), - new AnimationMapping('mixamorigSpine2.quaternion', 'UpperChest', true, false), - new AnimationMapping('mixamorigNeck.quaternion', 'Neck', true, false), - new AnimationMapping('mixamorigHead.quaternion', 'Head', true, false), + new AnimationMapping('mixamorigHips.position', 'Hips', false, true, false), + new AnimationMapping('mixamorigHips.quaternion', 'Hips', false, false, false), + new AnimationMapping('mixamorigSpine.quaternion', 'Spine', true, false, false), + new AnimationMapping('mixamorigSpine1.quaternion', 'Chest', true, false, false), + new AnimationMapping('mixamorigSpine2.quaternion', 'UpperChest', true, false, false), + new AnimationMapping('mixamorigNeck.quaternion', 'Neck', true, false, false), + new AnimationMapping('mixamorigHead.quaternion', 'Head', true, false, false), - new AnimationMapping('mixamorigLeftShoulder.quaternion', 'Left_shoulder', true, false), - new AnimationMapping('mixamorigLeftArm.quaternion', 'Left_arm', true, false), - new AnimationMapping('mixamorigLeftForeArm.quaternion', 'Left_elbow', true, false), - new AnimationMapping('mixamorigLeftHand.quaternion', 'Left_wrist', true, false), - new AnimationMapping('mixamorigLeftHandMiddle1.quaternion', 'Left_middleFinger1', true, false), - new AnimationMapping('mixamorigLeftHandMiddle2.quaternion', 'Left_middleFinger2', true, false), - new AnimationMapping('mixamorigLeftHandMiddle3.quaternion', 'Left_middleFinger3', true, false), - new AnimationMapping('mixamorigLeftHandThumb1.quaternion', 'Left_thumb0', true, false), - new AnimationMapping('mixamorigLeftHandThumb2.quaternion', 'Left_thumb1', true, false), - new AnimationMapping('mixamorigLeftHandThumb3.quaternion', 'Left_thumb2', true, false), - new AnimationMapping('mixamorigLeftHandIndex1.quaternion', 'Left_indexFinger1', true, false), - new AnimationMapping('mixamorigLeftHandIndex2.quaternion', 'Left_indexFinger2', true, false), - new AnimationMapping('mixamorigLeftHandIndex3.quaternion', 'Left_indexFinger3', true, false), - new AnimationMapping('mixamorigLeftHandRing1.quaternion', 'Left_ringFinger1', true, false), - new AnimationMapping('mixamorigLeftHandRing2.quaternion', 'Left_ringFinger2', true, false), - new AnimationMapping('mixamorigLeftHandRing3.quaternion', 'Left_ringFinger3', true, false), - new AnimationMapping('mixamorigLeftHandPinky1.quaternion', 'Left_littleFinger1', true, false), - new AnimationMapping('mixamorigLeftHandPinky2.quaternion', 'Left_littleFinger2', true, false), - new AnimationMapping('mixamorigLeftHandPinky3.quaternion', 'Left_littleFinger3', true, false), + new AnimationMapping('mixamorigLeftShoulder.quaternion', 'Left_shoulder', true, false, true), + new AnimationMapping('mixamorigLeftArm.quaternion', 'Left_arm', true, false, true), + new AnimationMapping('mixamorigLeftForeArm.quaternion', 'Left_elbow', true, false, true), + new AnimationMapping('mixamorigLeftHand.quaternion', 'Left_wrist', true, false, true), + new AnimationMapping('mixamorigLeftHandMiddle1.quaternion', 'Left_middleFinger1', true, false, true), + new AnimationMapping('mixamorigLeftHandMiddle2.quaternion', 'Left_middleFinger2', true, false, true), + new AnimationMapping('mixamorigLeftHandMiddle3.quaternion', 'Left_middleFinger3', true, false, true), + new AnimationMapping('mixamorigLeftHandThumb1.quaternion', 'Left_thumb0', true, false, true), + new AnimationMapping('mixamorigLeftHandThumb2.quaternion', 'Left_thumb1', true, false, true), + new AnimationMapping('mixamorigLeftHandThumb3.quaternion', 'Left_thumb2', true, false, true), + new AnimationMapping('mixamorigLeftHandIndex1.quaternion', 'Left_indexFinger1', true, false, true), + new AnimationMapping('mixamorigLeftHandIndex2.quaternion', 'Left_indexFinger2', true, false, true), + new AnimationMapping('mixamorigLeftHandIndex3.quaternion', 'Left_indexFinger3', true, false, true), + new AnimationMapping('mixamorigLeftHandRing1.quaternion', 'Left_ringFinger1', true, false, true), + new AnimationMapping('mixamorigLeftHandRing2.quaternion', 'Left_ringFinger2', true, false, true), + new AnimationMapping('mixamorigLeftHandRing3.quaternion', 'Left_ringFinger3', true, false, true), + new AnimationMapping('mixamorigLeftHandPinky1.quaternion', 'Left_littleFinger1', true, false, true), + new AnimationMapping('mixamorigLeftHandPinky2.quaternion', 'Left_littleFinger2', true, false, true), + new AnimationMapping('mixamorigLeftHandPinky3.quaternion', 'Left_littleFinger3', true, false, true), - new AnimationMapping('mixamorigRightShoulder.quaternion', 'Right_shoulder', true, false), - new AnimationMapping('mixamorigRightArm.quaternion', 'Right_arm', true, false), - new AnimationMapping('mixamorigRightForeArm.quaternion', 'Right_elbow', true, false), - new AnimationMapping('mixamorigRightHand.quaternion', 'Right_wrist', true, false), - new AnimationMapping('mixamorigRightHandMiddle1.quaternion', 'Right_middleFinger1', true, false), - new AnimationMapping('mixamorigRightHandMiddle2.quaternion', 'Right_middleFinger2', true, false), - new AnimationMapping('mixamorigRightHandMiddle3.quaternion', 'Right_middleFinger3', true, false), - new AnimationMapping('mixamorigRightHandThumb1.quaternion', 'Right_thumb0', true, false), - new AnimationMapping('mixamorigRightHandThumb2.quaternion', 'Right_thumb1', true, false), - new AnimationMapping('mixamorigRightHandThumb3.quaternion', 'Right_thumb2', true, false), - new AnimationMapping('mixamorigRightHandIndex1.quaternion', 'Right_indexFinger1', true, false), - new AnimationMapping('mixamorigRightHandIndex2.quaternion', 'Right_indexFinger2', true, false), - new AnimationMapping('mixamorigRightHandIndex3.quaternion', 'Right_indexFinger3', true, false), - new AnimationMapping('mixamorigRightHandRing1.quaternion', 'Right_ringFinger1', true, false), - new AnimationMapping('mixamorigRightHandRing2.quaternion', 'Right_ringFinger2', true, false), - new AnimationMapping('mixamorigRightHandRing3.quaternion', 'Right_ringFinger3', true, false), - new AnimationMapping('mixamorigRightHandPinky1.quaternion', 'Right_littleFinger1', true, false), - new AnimationMapping('mixamorigRightHandPinky2.quaternion', 'Right_littleFinger2', true, false), - new AnimationMapping('mixamorigRightHandPinky3.quaternion', 'Right_littleFinger3', true, false), + new AnimationMapping('mixamorigRightShoulder.quaternion', 'Right_shoulder', true, false, true), + new AnimationMapping('mixamorigRightArm.quaternion', 'Right_arm', true, false, true), + new AnimationMapping('mixamorigRightForeArm.quaternion', 'Right_elbow', true, false, true), + new AnimationMapping('mixamorigRightHand.quaternion', 'Right_wrist', true, false, true), + new AnimationMapping('mixamorigRightHandMiddle1.quaternion', 'Right_middleFinger1', true, false, true), + new AnimationMapping('mixamorigRightHandMiddle2.quaternion', 'Right_middleFinger2', true, false, true), + new AnimationMapping('mixamorigRightHandMiddle3.quaternion', 'Right_middleFinger3', true, false, true), + new AnimationMapping('mixamorigRightHandThumb1.quaternion', 'Right_thumb0', true, false, true), + new AnimationMapping('mixamorigRightHandThumb2.quaternion', 'Right_thumb1', true, false, true), + new AnimationMapping('mixamorigRightHandThumb3.quaternion', 'Right_thumb2', true, false, true), + new AnimationMapping('mixamorigRightHandIndex1.quaternion', 'Right_indexFinger1', true, false, true), + new AnimationMapping('mixamorigRightHandIndex2.quaternion', 'Right_indexFinger2', true, false, true), + new AnimationMapping('mixamorigRightHandIndex3.quaternion', 'Right_indexFinger3', true, false, true), + new AnimationMapping('mixamorigRightHandRing1.quaternion', 'Right_ringFinger1', true, false, true), + new AnimationMapping('mixamorigRightHandRing2.quaternion', 'Right_ringFinger2', true, false, true), + new AnimationMapping('mixamorigRightHandRing3.quaternion', 'Right_ringFinger3', true, false, true), + new AnimationMapping('mixamorigRightHandPinky1.quaternion', 'Right_littleFinger1', true, false, true), + new AnimationMapping('mixamorigRightHandPinky2.quaternion', 'Right_littleFinger2', true, false, true), + new AnimationMapping('mixamorigRightHandPinky3.quaternion', 'Right_littleFinger3', true, false, true), - new AnimationMapping('mixamorigRightUpLeg.quaternion', 'Right_leg', false, false), - new AnimationMapping('mixamorigRightLeg.quaternion', 'Right_knee', false, false), - new AnimationMapping('mixamorigRightFoot.quaternion', 'Right_ankle', false, false), - new AnimationMapping('mixamorigRightToeBase.quaternion', 'Right_toe', false, false), + new AnimationMapping('mixamorigRightUpLeg.quaternion', 'Right_leg', false, false, false), + new AnimationMapping('mixamorigRightLeg.quaternion', 'Right_knee', false, false, false), + new AnimationMapping('mixamorigRightFoot.quaternion', 'Right_ankle', false, false, false), + new AnimationMapping('mixamorigRightToeBase.quaternion', 'Right_toe', false, false, false), - new AnimationMapping('mixamorigLeftUpLeg.quaternion', 'Left_leg', false, false), - new AnimationMapping('mixamorigLeftLeg.quaternion', 'Left_knee', false, false), - new AnimationMapping('mixamorigLeftFoot.quaternion', 'Left_ankle', false, false), - new AnimationMapping('mixamorigLeftToeBase.quaternion', 'Left_toe', false, false), + new AnimationMapping('mixamorigLeftUpLeg.quaternion', 'Left_leg', false, false, false), + new AnimationMapping('mixamorigLeftLeg.quaternion', 'Left_knee', false, false, false), + new AnimationMapping('mixamorigLeftFoot.quaternion', 'Left_ankle', false, false, false), + new AnimationMapping('mixamorigLeftToeBase.quaternion', 'Left_toe', false, false, false), ]; diff --git a/avatars/animationHelpers.js b/avatars/animationHelpers.js index 3a1aa5195e..8445da90af 100644 --- a/avatars/animationHelpers.js +++ b/avatars/animationHelpers.js @@ -997,38 +997,35 @@ export const _applyAnimation = (avatar, now, moveFactors) => { animationTrackName: k, dst, // isTop, + isArm, isPosition, } = spec; - const aimAnimation = (avatar.aimAnimation && aimAnimations[avatar.aimAnimation]); _handleDefault(spec); - const t2 = (avatar.aimTime / aimMaxTime) % aimAnimation.duration; - if (!isPosition) { - if (aimAnimation) { + + const aimAnimation = (avatar.aimAnimation && aimAnimations[avatar.aimAnimation]); + if (aimAnimation) { + const t2 = (avatar.aimTime / aimMaxTime) % aimAnimation.duration; + const transitionFactor = Math.min(1, avatar.aimTime / 200); + if (!isPosition) { const src2 = aimAnimation.interpolants[k]; const v2 = src2.evaluate(t2); + localQuaternion2.fromArray(v2); - const idleAnimation = _getIdleAnimation('walk'); - const t3 = 0; - const src3 = idleAnimation.interpolants[k]; - const v3 = src3.evaluate(t3); + if (isArm) { + dst.slerp(localQuaternion2, transitionFactor * 0.5); + } else { + const t = (0.5 - idleWalkFactor * 0.5) * transitionFactor; + dst.slerp(localQuaternion2, t); + } + } else { + const src2 = aimAnimation.interpolants[k]; + const v2 = src2.evaluate(t2); + localVector2.fromArray(v2); + _clearXZ(localVector2, isPosition); - dst - .premultiply(localQuaternion2.fromArray(v3).invert()) - .premultiply(localQuaternion2.fromArray(v2)); + dst.lerp(localVector2, crouchFactor * transitionFactor); } - } else { - const src2 = aimAnimation.interpolants[k]; - const v2 = src2.evaluate(t2); - - const idleAnimation = _getIdleAnimation('walk'); - const t3 = 0; - const src3 = idleAnimation.interpolants[k]; - const v3 = src3.evaluate(t3); - - dst - .sub(localVector2.fromArray(v3)) - .add(localVector2.fromArray(v2)); } }; } else if (avatar.unuseAnimation && avatar.unuseTime >= 0) { diff --git a/public/animations/animations.z b/public/animations/animations.z index 29aa9cdb49..67c7bfa5c5 100644 Binary files a/public/animations/animations.z and b/public/animations/animations.z differ diff --git a/public/animations/sword_side_slash.fbx b/public/animations/sword_side_slash.fbx index 1e5cf1eb0e..c0f068a18f 100644 Binary files a/public/animations/sword_side_slash.fbx and b/public/animations/sword_side_slash.fbx differ diff --git a/public/animations/sword_side_slash_step.fbx b/public/animations/sword_side_slash_step.fbx index 0e4c92d750..8d81297ce9 100644 Binary files a/public/animations/sword_side_slash_step.fbx and b/public/animations/sword_side_slash_step.fbx differ diff --git a/public/animations/sword_topdown_slash.fbx b/public/animations/sword_topdown_slash.fbx index 1b4b8c5456..1fb5e96674 100644 Binary files a/public/animations/sword_topdown_slash.fbx and b/public/animations/sword_topdown_slash.fbx differ diff --git a/public/animations/sword_topdown_slash_step.fbx b/public/animations/sword_topdown_slash_step.fbx index c8e889ee25..1c162a28b7 100644 Binary files a/public/animations/sword_topdown_slash_step.fbx and b/public/animations/sword_topdown_slash_step.fbx differ