Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project / blackhole.js
blob: 28252d15834c68841b4372c68b8d9a2b563e493b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
blackHolesBuf = [];

BlackHole = function(center, size) {
	if (blackHolesBuf.length == BLACKHOLE_MAX_COUNT)
		throw 'Error: cannot add more black holes, limit of ' + BLACKHOLE_MAX_COUNT + ' reached!'

	this.rs = size / 3;
	this.index = blackHolesBuf.push([]) - 1;
	this.moveTo(center);
}
BlackHole.prototype.moveTo = function(newCenter) {
	blackHolesBuf[this.index] = newCenter.concat(this.rs);
	gl.uniform4fv(gl.getUniformLocation(glprog, 'uBH[' + this.index + ']'), blackHolesBuf[this.index]);
}
BlackHole.prototype.draw = function() {
	// Black holes are not "drawn"
}