-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclick-action.js
More file actions
34 lines (28 loc) · 903 Bytes
/
click-action.js
File metadata and controls
34 lines (28 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
AFRAME.registerComponent("click-action", {
init: function () {
this.model = null;
this.mixer = null;
var model = this.el.getObject3D("mesh");
let el = this.el;
this.addAnimation = function (e) {
model = document.getElementById("model").getObject3D("mesh");
mixer = new THREE.AnimationMixer(model);
model.animations.forEach((animation) => {
mixer.clipAction(animation, model).play();
});
console.log("animation added");
};
this.el.addEventListener("click", this.addAnimation);
console.log("click-action init");
},
load: function (model) {
this.model = model;
this.mixer = new THREE.AnimationMixer(model);
this.model.animations.forEach((animation) => {
this.mixer.clipAction(animation, model).play();
});
},
remove: function () {
this.el.removeEventListener("click", this.addMarker);
},
});