Просмотр исходного кода

support drawing circles.

yay! next up, spheres.
Lucas Stadler лет назад: 12
Родитель
Сommit
49283576f0
1 измененных файлов с 21 добавлено и 0 удалено
  1. 21 0
      js/pixl/public/trixl.html

+ 21 - 0
js/pixl/public/trixl.html

61
			}
61
			}
62
			return m;
62
			return m;
63
		}
63
		}
64
65
		var range = function(lo, hi) {
66
			var both = hi !== undefined,
67
			    l = both ? lo : 0,
68
			    h = both ? hi : lo;
69
			return Array.apply(null, Array(h - l)).map(function(_, i) {
70
				return l + i;
71
			});
72
		}
64
	</script>
73
	</script>
65
	<script>
74
	<script>
66
		window.trixl = {};
75
		window.trixl = {};
182
			trixl.generate.many(1000, -100, 100);
191
			trixl.generate.many(1000, -100, 100);
183
		}
192
		}
184
193
194
		trixl.geometry = {};
195
196
		trixl.geometry.circle = function(pos, radius, color) {
197
			range(0, 2 * radius).map(function(i) {
198
				trixl.world.set([
199
					pos[0] + radius * Math.sin(i * Math.PI / radius),
200
					pos[1] + radius * Math.cos(i * Math.PI / radius),
201
					pos[2]
202
				], {color: color || trixl.color});
203
			});
204
		}
205
185
		var angle = {x: 0, y: 0, z: 0};
206
		var angle = {x: 0, y: 0, z: 0};
186
		var offset = {x: 0, y: 0, z: 0};
207
		var offset = {x: 0, y: 0, z: 0};
187
		program.transform = gl.getUniformLocation(program, 'transform');
208
		program.transform = gl.getUniformLocation(program, 'transform');