Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I implement a FPS view with WebGL inside a browser?

I'm using Copperlicht, and I want to create a usable FPS. The demo controls shows why the browser environment makes this a pain.

In order to implement FPS camera control, you need to track the relative mouse position - in other words, its motion, not its absolute screen coordinates. The mouse can leave the browser at any time (rightfully so) and can't be tracked, unless the user initiates a drag event inside the page. Click events change focus and prevent the application from using mouse data as input.

The mouse position can be tracked during drag, but this requires the user to hold down their left mouse button. This isn't good since left clicking is usually used for other things. Holding the button down is also tiring and cumbersome.

The only thing I can think of is automating the middle mouse button. A middle mouse button press keeps focus in the browser, and keeps left/right click events outside the browser window in the browser's focus. Is it possible to cause middle mouse button to stay pressed using JavaScript?

If not, is there a "pure" solution to this ? I'd rather not go to flash or Java or a plugin as an answer.

like image 659
JRowe Avatar asked Apr 24 '11 05:04

JRowe


1 Answers

This thread is a nice reading on this topic. It seems like prototypes for this functionality are at least suggested for Firefox and Chrome.

like image 180
Daniel Baulig Avatar answered Oct 09 '22 18:10

Daniel Baulig