-
Notifications
You must be signed in to change notification settings - Fork 0
/
Publisher.js
35 lines (28 loc) · 1.02 KB
/
Publisher.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
import * as THREE from 'three';
// import HelvetikerFont from 'three/examples/fonts/helvetiker_regular.typeface.json';
export default class Publisher{
constructor(init_posX, init_posY, science_ratio, scene, geometry, material){
this.science_ratio = science_ratio
this.posX = init_posX
this.posY = init_posY
this.releases = []
for(var i = 0; i<this.science_ratio[0]; i++){
this.releases.push(1)
}
for(var i = 0; i<this.science_ratio[1]; i++){
this.releases.push(0)
}
// Three.js object instanciation
this.geometry = geometry
this.material = material
this.mesh = new THREE.Mesh(geometry, material);
this.mesh.name = 'publisher'
this.mesh.position.x = init_posX
this.mesh.position.y = init_posY
scene.add(this.mesh)
}
publish(){
// spread info to the audience
return this.releases[Math.round(Math.random() * (this.releases.length-1))]
}
}