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

look around with mouse.

not finished, doesn't really allow you to turn around, should probably
use two degrees of rotation. needs some research before i can implement
it.
Lucas Stadler лет назад: 12
Родитель
Сommit
e6446aa31c
1 измененных файлов с 15 добавлено и 0 удалено
  1. 15 0
      js/pixl/public/trixl.html

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

@ -224,6 +224,21 @@
224 224
			trixl.input.keys.delete(ev.keyCode);
225 225
		});
226 226
227
		trixl.input.mouse = {last: null};
228
		trixl.stage.addEventListener("mousemove",  function(ev) {
229
			var mouse = trixl.input.mouse;
230
231
			if (mouse.last === null) {
232
				mouse.last = {x: ev.clientX, y: ev.clientY};
233
			}
234
235
			var diff = { x: mouse.last.x - ev.clientX, y: mouse.last.y - ev.clientY };
236
			trixl.focus.a += diff.x * 0.01;
237
			trixl.focus.y += diff.y * 0.01;
238
239
			mouse.last = {x: ev.clientX, y: ev.clientY};
240
		});
241
227 242
		window.onresize = function() {
228 243
			trixl.window.w = window.innerWidth;
229 244
			trixl.window.h = window.innerHeight;