registerAnimation = aframe.registerComponent(`note`, {
schema: schema,
init: function() {
var data = this.data;
var el = this.el;
let height = 5;
let width = 0.95;
if (data.noteType == "sharp") {
height = 3;
width = 0.5;
}
this.geometry = new THREE.BoxBufferGeometry(width, height, 0.5);
let color = data.noteType == "sharp" ? "#000000" : "#FFFFFF";
this.material = new THREE.MeshStandardMaterial({
color: color
});
this.mesh = new THREE.Mesh(this.geometry, this.material);
el.setObject3D('mesh', this.mesh);
let self = this;
this.el.addEventListener('generateNote', function(event) {
self.el.emit("animate");
self.el.getObject3D('mesh').material.color = new THREE.Color("#E4FF33");
setTimeout(function() {
self.el.emit("animate_back");
self.el.getObject3D('mesh').material.color = new THREE.Color(color);
}, animationDuration);
});
},
remove: function() {
this.el.removeObject3D('mesh');
}
})