Skip to content
Snippets Groups Projects
Commit f373baa7 authored by joni's avatar joni
Browse files

Fix getting the mixer in a hacky way. This still needs to be done properly.

parent c324948a
No related branches found
No related tags found
No related merge requests found
......@@ -20,16 +20,28 @@ AFRAME.registerComponent("hand-poses", {
init() {
this.animatePose = this.animatePose.bind(this);
this.animatePoses = this.animatePoses.bind(this);
this.mixer = this.el.querySelector(this.data.mixer).components["animation-mixer"];
this.firstUpdate = this.firstUpdate.bind(this);
if (this.el.querySelector(this.data.mixer)) {
this.mixer = this.el.querySelector(this.data.mixer).components["animation-mixer"];
}
let onLoad;
onLoad = () => {
console.log("loaded!"); // TODO: This isn't getting called
this.mixer = this.el.querySelector(this.data.mixer).components["animation-mixer"];
// this.animatePoses();
if (this.el.querySelector(this.data.mixer)) {
this.mixer = this.el.querySelector(this.data.mixer).components["animation-mixer"];
}
if (!this.mixer) {
// Can't find the mixer until spawned into the scene.
// TODO: Figure out the right event to listen to to get this done.
window.setTimeout(onLoad, 100);
return;
}
this.el.querySelector(this.data.gltfEntity).removeEventListener("loaded", onLoad);
};
this.el.querySelector(this.data.gltfEntity).addEventListener("loaded", onLoad);
//TODO: the loaded event isn't being caught, so we do it in a timeout
window.setTimeout(onLoad, 10);
},
update(oldData) {
......@@ -38,18 +50,19 @@ AFRAME.registerComponent("hand-poses", {
const object3DMap = this.mixer.el.object3DMap;
const rootObj = object3DMap.mesh || object3DMap.scene;
this.clipActionObject = rootObj.parent;
}
if (!oldData.leftPose) {
// first update
this.leftClipFrom = this.leftClipTo = this.mixer.mixer.clipAction(POSES.open + "_L", this.clipActionObject);
this.rightClipFrom = this.rightClipTo = this.mixer.mixer.clipAction(POSES.open + "_R", this.clipActionObject);
this.leftClipTo.play();
this.rightClipTo.play();
this.firstUpdate();
} else {
this.animatePoses(oldData);
}
},
firstUpdate() {
this.leftClipFrom = this.leftClipTo = this.mixer.mixer.clipAction(POSES.open + "_L", this.clipActionObject);
this.rightClipFrom = this.rightClipTo = this.mixer.mixer.clipAction(POSES.open + "_R", this.clipActionObject);
this.leftClipTo.play();
this.rightClipTo.play();
},
animatePose(hand, prev, curr) {
this[`${hand}ClipFrom`].stop();
this[`${hand}ClipTo`].stop();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment