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

Star = function(center, size) {
	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();
}