diff --git a/src/components/animation-mixer.js b/src/components/animation-mixer.js index d2abfd79b8..ce5b30e6bd 100644 --- a/src/components/animation-mixer.js +++ b/src/components/animation-mixer.js @@ -3,6 +3,10 @@ * @component animation-mixer */ +import { NETWORK_POSES } from "./hand-poses"; + +const leftRightFilter = new RegExp("(_L)|(_R)"); + const components = []; export class AnimationMixerSystem { tick(dt) { @@ -20,6 +24,17 @@ AFRAME.registerComponent("animation-mixer", { this.mixer = new THREE.AnimationMixer(this.el.object3D); this.el.object3D.animations = animations; this.animations = animations; + + //Fix hand pose animations by removing unnecessary VectorKeyframeTracks (Position and Scale) + this.animations.forEach(animClip => { + //Check if this is really a hand pose + if (animClip && NETWORK_POSES.includes(animClip.name.replace(leftRightFilter, ""))) { + //Filter out EVERY track that is NOT a quaternion track and therefor not rotation related + animClip.tracks = animClip.tracks.filter(track => track.ValueTypeName == "quaternion"); + //Filter out the quaternion track of the Hand bone!!! Otherwise the hand still rotation flickers in place + animClip.tracks.splice(animClip.tracks.length - 3, 3); + } + }); }, play() { components.push(this); diff --git a/src/components/hand-poses.js b/src/components/hand-poses.js index 3da274d396..3cead4ef1b 100644 --- a/src/components/hand-poses.js +++ b/src/components/hand-poses.js @@ -12,7 +12,7 @@ const POSES = { pinch: "pinch" }; -const NETWORK_POSES = ["allOpen", "thumbDown", "indexDown", "mrpDown", "thumbsUp", "point", "allGrip", "pinch"]; +export const NETWORK_POSES = ["allOpen", "thumbDown", "indexDown", "mrpDown", "thumbsUp", "point", "allGrip", "pinch"]; /** * Animates between poses based on networked pose state using an animation mixer.