starsBuf = []; Star = function(center, size) { if (starsBuf.length == STAR_MAX_COUNT) throw "Error: cannot add more stars, limit of " + STAR_MAX_COUNT + " reached!" this.sphere = new Sphere(center, size); this.sphere.color = [0.956,0.5,0.215]; this.index = starsBuf.push([]) - 1; this.moveTo(center); } Star.prototype.moveTo = function(newCenter) { this.sphere.center = newCenter; starsBuf[this.index] = newCenter.concat(this.sphere.size); gl.uniform4fv(gl.getUniformLocation(glprog, "uStars[" + this.index + "]"), starsBuf[this.index]); } Star.prototype.draw = function() { this.sphere.draw(); }