-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.js
More file actions
56 lines (45 loc) · 1.17 KB
/
state.js
File metadata and controls
56 lines (45 loc) · 1.17 KB
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
import { vec3 } from "./gl-matrix-min.js"
import { Sprite } from "./Sprite.js"
//Core Data
export let gl = null;
export function setGl(context) {
gl = context;
}
export let player = null;
export function setPlayer(obj) {
player = obj;
}
export let inventory = null;
export function setInventory(obj) {
inventory = obj;
}
export let updateRegistry = {
updateList : {},
registerUpdate : function(name, callback) {
this.updateList[name] = callback;
},
unregisterUpdate : function(name) {
delete this.updateList[name];
},
update : function(delta) {
for (let updateName in this.updateList)
this.updateList[updateName](delta);
},
}
//TODO review
export let level = {
objects: [],
lights: new Array(180), //TODO move
updateLight: function(lightID, color, pos, dir, cutoff, intensity) {
let startPos = lightID * 9;
this.lights[startPos] = color[0]
this.lights[startPos + 1] = color[1]
this.lights[startPos + 2] = color[2]
this.lights[startPos + 3] = pos[0]
this.lights[startPos + 4] = pos[1]
this.lights[startPos + 5] = dir[0]
this.lights[startPos + 6] = dir[1]
this.lights[startPos + 7] = cutoff
this.lights[startPos + 8] = intensity
}
};