Parcourir la Source

position debug facility.

for noticing when things go off-screen.
Lucas Stadler 12 ans auparavant
Parent
commit
ee6a3081fb
1 fichiers modifiés avec 21 ajouts et 0 suppressions
  1. 21 0
      js/pixl/public/trixl.html

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

@ -9,6 +9,12 @@
9 9
			top: 0;
10 10
			left: 0;
11 11
		}
12
13
		#debug {
14
			position: absolute;
15
			bottom: 0;
16
			right: 0;
17
		}
12 18
	</style>
13 19
</head>
14 20
@ -18,6 +24,7 @@
18 24
		temporal leap to a minimally brighter future where browsers can
19 25
		investigate the third dimension.
20 26
	</canvas>
27
	<span id="debug"></span>
21 28
	<script type="gl/vertex-shader">
22 29
		attribute vec3 pos;
23 30
		varying vec3 world_pos;
@ -223,6 +230,20 @@
223 230
		trixl.window = {w: window.innerWidth, h: window.innerHeight};
224 231
		trixl.stage.width = trixl.window.w;
225 232
		trixl.stage.height = trixl.window.h;
233
		trixl.debug = document.querySelector("#debug");
234
		trixl.debug_pos = function(pos) {
235
			var coord_html = function(coord) {
236
				var s = (coord.toString() + "    ").slice(0, 6);
237
				if (coord < -1.0 || coord > 1.0) {
238
					return '<span style="color: red">' + s + '</span>';
239
				} else {
240
					return '<span>' + s + '</span>';
241
				}
242
				return s;
243
			}
244
245
			trixl.debug.innerHTML = coord_html(pos[0]) + ", " + coord_html(pos[1]) + ", " + coord_html(pos[2]);
246
		}
226 247
		var gl = trixl.gl = trixl.stage.getContext("webgl");
227 248
		//gl.enable(gl.CULL_FACE);
228 249
		gl.enable(gl.DEPTH_TEST);