Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/components/animation-mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/components/hand-poses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down