/
index.js
60 lines (55 loc) · 1.64 KB
/
index.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Camera from 'famous/components/Camera';
import DOMElement from 'famous/dom-renderables/DOMElement';
import FamousEngine from 'famous/core/FamousEngine';
import Node from 'famous/core/Node';
import Opacity from 'famous/components/Opacity';
import Background from './Background';
import Lights from './Lights';
import Grid from './Grid';
import Audio from './utils/Audio';
import RefreshRate from './utils/RefreshRate';
require('./styles.css');
FamousEngine.init();
const PRIMITIVE_TYPES = [
'POINTS',
'LINES',
'LINE_STRIP',
'LINE_LOOP',
'TRIANGLES',
'TRIANGLE_STRIP',
'TRIANGLE_FAN'
];
class Vizzy {
init() {
this.scene = FamousEngine.createScene()
this.camera = new Camera(this.scene);
this.camera.setDepth(120);
this.root = this.scene.addChild()
this.background = this.root.addChild(new Background());
this.lights = this.root.addChild(new Lights());
this.audio = new Audio(this.root);
this.grid = new Grid(this.root.addChild(), this.audio);
this.data = {};
this.refreshRate = new RefreshRate(100);
this.id = this.root.addComponent(this);
this.root.requestUpdate(this.id);
}
onUpdate() {
this.data = this.audio.getData();
// this.refreshRate.throttle(() => {
// if (this.data.fftBufferFloat[0]) {
// if (this.data.fftBufferFloat[0][this.data.fftSize - 8] > -90) {
// this.background.show();
// } else {
// this.background.hide();
// }
// } else {
// this.background.hide();
// }
// });
this.grid.updateItems(this.data);
this.root.requestUpdateOnNextTick(this.id);
}
}
let vizzy = new Vizzy();
vizzy.init();