ソースを参照

support generating plane geometry.

maybe such objects should be optimized? it's quite expensive to draw
such simple things. or maybe buffering the draw calls would help. not
sure.
Lucas Stadler 12 年 前
コミット
e5c91a0881
共有1 個のファイルを変更した16 個の追加0 個の削除を含む
  1. 16 0
      js/pixl/public/trixl.html

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

@ -372,6 +372,22 @@
372 372
			}
373 373
		}
374 374
375
		trixl.geometry.plane = function(pos, v, w, width, height, color) {
376
			var v = vec3.normalize([], v), w = vec3.normalize([], w);
377
378
			for (var i = 0; i < width; i++) {
379
				for (var j = 0; j < height; j++) {
380
					var pos = vec3.create();
381
					vec3.scaleAndAdd(pos, pos, v, i);
382
					vec3.scaleAndAdd(pos, pos, w, j);
383
384
					trixl.world.set([
385
						Math.round(pos[0]), Math.round(pos[1]), Math.round(pos[2])
386
					], {color: color || trixl.color});
387
				}
388
			}
389
		}
390
375 391
		var angle = {x: 0, y: 0, z: 0};
376 392
		var offset = {x: 0, y: 0, z: 0};
377 393
		program.transform = gl.getUniformLocation(program, 'transform');