3d logo with flashlight animation
This commit is contained in:
@@ -9,26 +9,18 @@ AFRAME.registerComponent('logoflicker', {
|
||||
this.setOff = this.setOff.bind(this);
|
||||
this.setOn = this.setOn.bind(this);
|
||||
|
||||
this.defaultColor = new THREE.Color().setStyle(this.el.components.text.data.color);
|
||||
this.color = new THREE.Color().setStyle('#0A0228');
|
||||
this.colorUniform = this.el.components.text.material.uniforms.color.value;
|
||||
|
||||
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)}
|
||||
{position: new THREE.Vector3(0, 0.10, 0)},
|
||||
{position: new THREE.Vector3(0.3, 0.8, 0)},
|
||||
{position: new THREE.Vector3(-0.3, 0.8, 0)}
|
||||
];
|
||||
|
||||
this.setOn();
|
||||
},
|
||||
|
||||
setOff: function () {
|
||||
this.colorUniform.x = this.color.r;
|
||||
this.colorUniform.y = this.color.g;
|
||||
this.colorUniform.z = this.color.b;
|
||||
this.colorUniform.needsUpdate = true;
|
||||
|
||||
this.el.object3D.visible = false;
|
||||
this.sparks.emit('logoflicker',
|
||||
this.sparkPositions[Math.floor(Math.random() * this.sparkPositions.length)],
|
||||
false);
|
||||
@@ -38,11 +30,7 @@ AFRAME.registerComponent('logoflicker', {
|
||||
},
|
||||
|
||||
setOn: function () {
|
||||
this.colorUniform.x = this.defaultColor.r;
|
||||
this.colorUniform.y = this.defaultColor.g;
|
||||
this.colorUniform.z = this.defaultColor.b;
|
||||
this.colorUniform.needsUpdate = true;
|
||||
|
||||
this.el.object3D.visible = true;
|
||||
setTimeout(this.setOff,
|
||||
Math.floor((this.data.delay * 3 / 10) + Math.random() * this.data.delay));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user