jeromeetienne/threex — Issue #17: MouseX and MouseY relative to canvas, not to window
Author: TheJVH
Created: 2012-02-09 13:26:19+00:00
State: open

The MouseX and MouseY position is currently calculated with the complete browser window size. When you use a smaller canvas, threex.domevent intersection calculations are slightly off (depending on your canvas size compared to your window size).

This could be fixed using offsetTop / offsetLeft, but those are not very reliable cross-browser and with complicated layouts.

The obvious fix to this problem would be embedding the canvas in an iFrame (example: http://learningthreejs.com/blog/2012/01/17/dom-events-in-3d-space/), but that isn't a real solution in my opinion.

Maybe it's an idea to let the user pass mouse variables if he wants to (or give an option between different methods)?

I think it would be a good idea to document this problem since it is quite difficult to adress this problem if you've never worked on things like this before :) .