Преглед на файлове

a sphere!

exciting! (thank you, wikipedia.)
Lucas Stadler преди 12 години
родител
ревизия
633ba1ecf6
променени са 1 файла, в които са добавени 11 реда и са изтрити 0 реда
  1. 11 0
      js/pixl/public/trixl.html

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

@ -214,6 +214,17 @@
214 214
			});
215 215
		}
216 216
217
		trixl.geometry.sphere = function(pos, radius, color) {
218
			for (var i = 0; i < 2 * Math.PI; i += Math.PI / radius) {
219
				for (var j = 0; j < Math.PI; j += Math.PI / radius) {
220
					var x = pos[0] + radius * Math.cos(i) * Math.sin(j),
221
					    y = pos[1] + radius * Math.sin(i) * Math.sin(j),
222
						 z = pos[2] + radius * Math.cos(j);
223
					trixl.world.set([x, y, z], {color: color});
224
				}
225
			}
226
		}
227
217 228
		var angle = {x: 0, y: 0, z: 0};
218 229
		var offset = {x: 0, y: 0, z: 0};
219 230
		program.transform = gl.getUniformLocation(program, 'transform');