diff --git a/src/assets.html b/src/assets.html
index d1dba68..600141b 100644
--- a/src/assets.html
+++ b/src/assets.html
@@ -84,27 +84,28 @@
diff --git a/src/components/beat.js b/src/components/beat.js
index 4d0dda4..94b380b 100644
--- a/src/components/beat.js
+++ b/src/components/beat.js
@@ -8,6 +8,13 @@ const BEAT_WARMUP_ROTATION_TIME = 750;
const ONCE = {once: true};
const SIGN_MATERIAL = {shader: 'flat', color: '#88f'};
+const SCORE_POOL = {
+ OK : 'pool__beatscoreok',
+ GOOD : 'pool__beatscoregood',
+ EXCELLENT : 'pool__beatscoreexcellent',
+ SUPER : 'pool__beatscoresuper'
+};
+
/**
* Bears, beats, Battlestar Galactica.
* Create beat from pool, collision detection, clipping planes, movement, scoring.
@@ -744,18 +751,13 @@ AFRAME.registerComponent('beat', {
this.el.emit('beathit', hitEventDetail, true);
let beatScorePool;
- if (score < 60) { beatScorePool = 'pool__beatscoreok'; }
- else if (score < 80) { beatScorePool = 'pool__beatscoregood'; }
- else if (score < 100) { beatScorePool = 'pool__beatscoreexcellent'; }
+ if (score < 60) { beatScorePool = SCORE_POOL.OK; }
+ else if (score < 80) { beatScorePool = SCORE_POOL.GOOD; }
+ else if (score < 100) { beatScorePool = SCORE_POOL.EXCELLENT; }
else {
- beatScorePool = 'pool__beatscoresuper';
+ beatScorePool = SCORE_POOL.SUPER;
- const supercut = this.superCuts[this.superCutIdx].getObject3D('mesh');
- supercut.position.copy(this.el.object3D.position);
- supercut.position.z = -1;
- supercut.visible = true;
- setTimeout(() => { supercut.visible = false; }, 1000);
- supercut.material.uniforms.starttime.value = this.el.sceneEl.time - 50;
+ this.superCuts[this.superCutIdx].components.supercutfx.createSuperCut(this.el.object3D.position);
this.superCutIdx = (this.superCutIdx + 1) % this.superCuts.length;
}
diff --git a/src/components/score-beat.js b/src/components/score-beat.js
index eec906d..e5937bc 100644
--- a/src/components/score-beat.js
+++ b/src/components/score-beat.js
@@ -3,11 +3,11 @@
*/
AFRAME.registerComponent('score-beat', {
schema: {
- type: 'string'
+ type: { type: 'string' }
},
play: function () {
- this.poolComponent = `pool__beatscore${this.data}`;
+ this.poolComponent = `pool__beatscore${this.data.type}`;
this.startTime = this.el.sceneEl.time;
},
diff --git a/src/components/supercutfx-shader.js b/src/components/supercutfx-shader.js
index 170d0ed..52cbc2d 100644
--- a/src/components/supercutfx-shader.js
+++ b/src/components/supercutfx-shader.js
@@ -1,6 +1,6 @@
AFRAME.registerShader('superCutFxShader', {
schema: {
- starttime: {type: 'float', is: 'uniform'},
+ startTime: {type: 'float', is: 'uniform'},
timems: {type: 'time', is: 'uniform'}
},
@@ -14,7 +14,7 @@ AFRAME.registerShader('superCutFxShader', {
`,
fragmentShader: `
- uniform float starttime;
+ uniform float startTime;
uniform float timems;
varying vec2 uvs;
varying vec3 worldPos;
@@ -22,7 +22,7 @@ AFRAME.registerShader('superCutFxShader', {
#define COLOR vec3(0, 0.67, 0.98)
void main() {
- float time = (timems - starttime) / 2000.0;
+ float time = (timems - startTime) / 2000.0;
vec2 p = uvs.xy - 0.5;
float r = p.x * p.x + p.y * p.y;
float alpha = 1.0 - smoothstep(time - 0.01, time, r);
diff --git a/src/components/supercutfx.js b/src/components/supercutfx.js
new file mode 100644
index 0000000..d17adab
--- /dev/null
+++ b/src/components/supercutfx.js
@@ -0,0 +1,23 @@
+AFRAME.registerComponent('supercutfx', {
+ init: function () {
+ this.startTime = -1100; // pause on first tick
+ },
+
+ createSuperCut: function (position) {
+ const mesh = this.el.getObject3D('mesh');
+ this.el.object3D.position.copy(position);
+ this.el.object3D.position.z = -1;
+ this.el.object3D.visible = true;
+
+ this.startTime = this.el.sceneEl.time;
+ mesh.material.uniforms.startTime.value = this.startTime - 50;
+ this.el.play();
+ },
+
+ tick: function (time) {
+ if (time > this.startTime + 1000) {
+ this.el.object3D.visible = false;
+ this.el.pause();
+ }
+ }
+});
diff --git a/src/index.html b/src/index.html
index 1f3c321..2538dac 100644
--- a/src/index.html
+++ b/src/index.html
@@ -83,7 +83,7 @@
{% for i in range(1, 5) %}
-
+
{% endfor %}