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

position debug facility.

for noticing when things go off-screen.
Lucas Stadler лет назад: 12
Родитель
Сommit
ee6a3081fb
1 измененных файлов с 21 добавлено и 0 удалено
  1. 21 0
      js/pixl/public/trixl.html

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

9
			top: 0;
9
			top: 0;
10
			left: 0;
10
			left: 0;
11
		}
11
		}
12
13
		#debug {
14
			position: absolute;
15
			bottom: 0;
16
			right: 0;
17
		}
12
	</style>
18
	</style>
13
</head>
19
</head>
14
20
18
		temporal leap to a minimally brighter future where browsers can
24
		temporal leap to a minimally brighter future where browsers can
19
		investigate the third dimension.
25
		investigate the third dimension.
20
	</canvas>
26
	</canvas>
27
	<span id="debug"></span>
21
	<script type="gl/vertex-shader">
28
	<script type="gl/vertex-shader">
22
		attribute vec3 pos;
29
		attribute vec3 pos;
23
		varying vec3 world_pos;
30
		varying vec3 world_pos;
223
		trixl.window = {w: window.innerWidth, h: window.innerHeight};
230
		trixl.window = {w: window.innerWidth, h: window.innerHeight};
224
		trixl.stage.width = trixl.window.w;
231
		trixl.stage.width = trixl.window.w;
225
		trixl.stage.height = trixl.window.h;
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
		var gl = trixl.gl = trixl.stage.getContext("webgl");
247
		var gl = trixl.gl = trixl.stage.getContext("webgl");
227
		//gl.enable(gl.CULL_FACE);
248
		//gl.enable(gl.CULL_FACE);
228
		gl.enable(gl.DEPTH_TEST);
249
		gl.enable(gl.DEPTH_TEST);