Spaces:
Running
Running
antimatter15
commited on
Commit
•
fbb4dad
1
Parent(s):
ab7554b
blur should stop all keys
Browse files
main.js
CHANGED
@@ -843,6 +843,9 @@ async function main() {
|
|
843 |
window.addEventListener("keyup", (e) => {
|
844 |
activeKeys = activeKeys.filter((k) => k !== e.key);
|
845 |
});
|
|
|
|
|
|
|
846 |
|
847 |
window.addEventListener(
|
848 |
"wheel",
|
@@ -904,6 +907,7 @@ async function main() {
|
|
904 |
startY = e.clientY;
|
905 |
down = 2;
|
906 |
});
|
|
|
907 |
canvas.addEventListener("mousemove", (e) => {
|
908 |
e.preventDefault();
|
909 |
if (down == 1) {
|
@@ -911,12 +915,15 @@ async function main() {
|
|
911 |
let dx = 5 * (e.clientX - startX) / innerWidth;
|
912 |
let dy = 5 * (e.clientY - startY) / innerHeight;
|
913 |
let d = 4;
|
|
|
|
|
914 |
inv = translate4(inv, 0, 0, d);
|
915 |
-
// inv = translate4(inv, -x, -y, -z);
|
916 |
-
// inv = translate4(inv, x, y, z);
|
917 |
inv = rotate4(inv, dx, 0, 1, 0);
|
918 |
inv = rotate4(inv, -dy, 1, 0, 0);
|
919 |
inv = translate4(inv, 0, 0, -d);
|
|
|
|
|
|
|
920 |
viewMatrix = invert4(inv);
|
921 |
|
922 |
startX = e.clientX;
|
|
|
843 |
window.addEventListener("keyup", (e) => {
|
844 |
activeKeys = activeKeys.filter((k) => k !== e.key);
|
845 |
});
|
846 |
+
window.addEventListener('blur', () => {
|
847 |
+
activeKeys = []
|
848 |
+
})
|
849 |
|
850 |
window.addEventListener(
|
851 |
"wheel",
|
|
|
907 |
startY = e.clientY;
|
908 |
down = 2;
|
909 |
});
|
910 |
+
|
911 |
canvas.addEventListener("mousemove", (e) => {
|
912 |
e.preventDefault();
|
913 |
if (down == 1) {
|
|
|
915 |
let dx = 5 * (e.clientX - startX) / innerWidth;
|
916 |
let dy = 5 * (e.clientY - startY) / innerHeight;
|
917 |
let d = 4;
|
918 |
+
|
919 |
+
|
920 |
inv = translate4(inv, 0, 0, d);
|
|
|
|
|
921 |
inv = rotate4(inv, dx, 0, 1, 0);
|
922 |
inv = rotate4(inv, -dy, 1, 0, 0);
|
923 |
inv = translate4(inv, 0, 0, -d);
|
924 |
+
// let postAngle = Math.atan2(inv[0], inv[10])
|
925 |
+
// inv = rotate4(inv, postAngle - preAngle, 0, 0, 1)
|
926 |
+
// console.log(postAngle)
|
927 |
viewMatrix = invert4(inv);
|
928 |
|
929 |
startX = e.clientX;
|