New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox: clicking (left/right) retargets camera #56

Closed
satoshinm opened this Issue Apr 12, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@satoshinm
Owner

satoshinm commented Apr 12, 2017

Firefox only (using 53.0b9, not a problem on Chrome or Safari), when you click to either place or break a block, left or right click, the camera shifts bizarrely:

screen shot 2017-04-11 at 11 06 43 pm

screen shot 2017-04-11 at 11 06 46 pm

@satoshinm satoshinm added bug ui labels Apr 12, 2017

@satoshinm satoshinm added this to the important milestone Apr 17, 2017

@satoshinm

This comment has been minimized.

Owner

satoshinm commented Apr 17, 2017

Several reports of this issue (or what I suspect to be this issue: https://www.spigotmc.org/threads/websandboxmc.232807/#post-2356412 and https://forums.glowstone.net/topic/56/websandboxmc-web-based-client-providing-an-interactive-glimpse-of-a-part-of-your-server-using-webgl-html5/4), adding to "important" milestone. I guess more people use Firefox than I suspected?


This occurs even on d21b994 Tue Apr 4, so may not be a recent bug, there since the beginning of this emscripten Craft port.


Doesn't occur when pressing Enter or Control-Enter, to simulate clicks (calls on_left_click() and on_right_click()), so it's something higher.


It's almost as if clicking translates to mouse movement - the player faces downwards, and rotates about 90º on mouse down, then another 90º on release.


Adding logging on click and move:

--- a/src/main.c
+++ b/src/main.c
@@ -2403,6 +2403,7 @@ void on_scroll(GLFWwindow *window, double xdelta, double ydelta) {
 
 
 void on_mouse_button(GLFWwindow *window, int button, int action, int mods) {
+    printf("on_mouse_button, button=%d\n", button);
     int control = mods & GLFW_MOD_CONTROL;
     int exclusive =
         glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED;
@@ -2605,6 +2606,7 @@ void handle_mouse_input() {
     if (exclusive && (px || py)) {
         double mx, my;
         glfwGetCursorPos(g->window, &mx, &my);
+        printf("handle_mouse_input getCursorPos mx-px=%g-%g=%g, my-py=%g-%g=%g\n", mx,px,mx-px, my,py,my-py);
         float m = 0.0025;
         s->rx += (mx - px) * m;
         if (INVERT_MOUSE) {

Chrome and Safari have glfwGetInputMode() return the same value before and after the click, so the movement delta is 0:

22craft.html:1233 handle_mouse_input getCursorPos mx-px=726-726=0, my-py=838-838=0
craft.html:1233 on_mouse_button, button=1
53craft.html:1233 handle_mouse_input getCursorPos mx-px=726-726=0, my-py=838-838=0
craft.html:1233 on_mouse_button, button=1

whereas Firefox 53.0 (64-bit) calculate a positive delta:

on_mouse_button, button=1 craft.html:1233:13
handle_mouse_input getCursorPos mx-px=2730-1982=748, my-py=1326-710=616 craft.html:1233:13
handle_mouse_input getCursorPos mx-px=2730-2730=0, my-py=1326-1326=0 craft.html:1233:13
on_mouse_button, button=1 craft.html:1233:13
handle_mouse_input getCursorPos mx-px=3478-2730=748, my-py=1942-1326=616 craft.html:1233:13
handle_mouse_input getCursorPos mx-px=3478-3478=0, my-py=1942-1942=0

It is 748 and 616 in this log, but if I shrink the window, 487, appears to be a function of the window size. If I resize the window client area to exactly 1000x100, then mx-px is 500 and my-py is 671.

@satoshinm satoshinm closed this in 83ab510 Apr 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment