Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project / blackhole.js
diff options
context:
space:
mode:
1 files changed, 5 insertions, 5 deletions
-rw-r--r--Year 2/Computer Graphics with WebGL/Project/blackhole.js10
diff --git a/Year 2/Computer Graphics with WebGL/Project/blackhole.js b/Year 2/Computer Graphics with WebGL/Project/blackhole.js
index 28252d1..0bd0ff5 100644
--- a/Year 2/Computer Graphics with WebGL/Project/blackhole.js
+++ b/Year 2/Computer Graphics with WebGL/Project/blackhole.js
@@ -1,14 +1,14 @@
-blackHolesBuf = [];
-
-BlackHole = function(center, size) {
+BlackHole = function(center, size, blackHolesBuf) {
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);
+ this.center = center;
+
+ blackHolesBuf[this.index] = center.concat(this.rs);
}
-BlackHole.prototype.moveTo = function(newCenter) {
+BlackHole.prototype.moveTo = function(newCenter, blackHolesBuf) {
blackHolesBuf[this.index] = newCenter.concat(this.rs);
gl.uniform4fv(gl.getUniformLocation(glprog, 'uBH[' + this.index + ']'), blackHolesBuf[this.index]);
}