broken neon effect on logo

This commit is contained in:
Diego F. Goberna
2018-09-21 01:44:25 +02:00
parent 33f84734ca
commit bea3ab72f9
7 changed files with 55 additions and 4 deletions

View File

@@ -0,0 +1,29 @@
AFRAME.registerComponent('logoflicker', {
dependencies: ['text'],
schema: {
default: 1000.0,
},
init: function () {
this.defaultColor = this.el.components['text'].data.color;
this.sparks = document.getElementById('logosparks');
this.sparkPositions = [
{ position: new THREE.Vector3(0, 0.1, 0) },
{ position: new THREE.Vector3(0.5, 1.2, 0) },
{ position: new THREE.Vector3(0, 1.2, 0) }
];
this.setOn();
},
setOff: function () {
this.el.setAttribute('text', {color: '#0a0228'});
this.sparks.emit('flicker',
this.sparkPositions[Math.floor(Math.random() * this.sparkPositions.length)]);
setTimeout(this.setOn.bind(this),
50 + Math.floor(Math.random() * 100));
},
setOn: function () {
this.el.setAttribute('text', {color: this.defaultColor});
setTimeout(this.setOff.bind(this),
Math.floor((this.data * 3 / 10) + Math.random() * this.data));
}
});