|
|
@ -49,6 +49,26 @@
|
|
49
|
49
|
}
|
|
50
|
50
|
}
|
|
51
|
51
|
</script>
|
|
|
52
|
<script>
|
|
|
53
|
var polyfill = {};
|
|
|
54
|
|
|
|
55
|
polyfill.pointerLockElement = function() {
|
|
|
56
|
return document.pointerLockElement ||
|
|
|
57
|
document.webkitPointerLockElement ||
|
|
|
58
|
document.mozPointerLockElement;
|
|
|
59
|
}
|
|
|
60
|
|
|
|
61
|
Element.prototype.requestPointerLock =
|
|
|
62
|
Element.prototype.mozRequestPointerLock ||
|
|
|
63
|
Element.prototype.webkitRequestPointerLock ||
|
|
|
64
|
Element.prototype.requestPointerLock;
|
|
|
65
|
|
|
|
66
|
polyfill.mouseEvent = function(ev) {
|
|
|
67
|
ev.movementX = ev.movementX || ev.mozMovementX;
|
|
|
68
|
ev.movementY = ev.movementY || ev.mozMovementY;
|
|
|
69
|
return ev;
|
|
|
70
|
}
|
|
|
71
|
</script>
|
|
52
|
72
|
<script src="gl.js"></script>
|
|
53
|
73
|
<script src="geometry.js"></script>
|
|
54
|
74
|
<script src="matrix.js"></script>
|
|
|
@ -323,12 +343,22 @@
|
|
323
|
343
|
mouse.last = {x: ev.clientX, y: ev.clientY};
|
|
324
|
344
|
}
|
|
325
|
345
|
|
|
326
|
|
var diff = { x: mouse.last.x - ev.clientX, y: mouse.last.y - ev.clientY };
|
|
|
346
|
ev = polyfill.mouseEvent(ev);
|
|
|
347
|
var diff = {
|
|
|
348
|
x: -ev.movementX || mouse.last.x - ev.clientX,
|
|
|
349
|
y: -ev.movementY || mouse.last.y - ev.clientY
|
|
|
350
|
};
|
|
327
|
351
|
trixl.camera.rotate(diff.x * trixl.speed.turn, diff.y * trixl.speed.turn);
|
|
328
|
352
|
|
|
329
|
353
|
mouse.last = {x: ev.clientX, y: ev.clientY};
|
|
330
|
354
|
});
|
|
331
|
355
|
|
|
|
356
|
trixl.stage.addEventListener("mousedown", function(ev) {
|
|
|
357
|
if (polyfill.pointerLockElement() === null) {
|
|
|
358
|
trixl.stage.requestPointerLock();
|
|
|
359
|
}
|
|
|
360
|
});
|
|
|
361
|
|
|
332
|
362
|
window.onresize = function() {
|
|
333
|
363
|
trixl.window.w = window.innerWidth;
|
|
334
|
364
|
trixl.window.h = window.innerHeight;
|