I’ll try:
How do FPS’s control the camera?
In most “conventional” 1st person shooter games, you move the camera around by moving the mouse. But you’ll notice that the cursor “pointer” is hidden - and you can keep on moving the mouse endlessly in the same direction - and the camera will spin around and around in that same direction - forever. In a sense, the POSITION of the mouse controls the POSITION of the camera…except that the mouse is on an infinitely large tabletop.
If you think about it - the “invisible” mouse pointer ought to have moved off the edge of the window - off the edge of the desktop - ages ago. So how can this work?
In most games, the game reads the mouse position - and then repositions the (invisible) mouse pointer to the center of the screen every frame. Thus, the mouse can never escape off the edge of the window/screen - and the game can measure how much it moved in each frame.
So what’s the problem?
HOWEVER: When games run in the browser, there is a problem. The browser doesn’t provide functions to reposition the mouse…you simply cannot reposition the mouse from inside the browser using JavaScript alone.
Hence, even if you turn off the mouse pointer to make it invisible (which is also getting tough to do!) - because you can’t keep repositioning it - it will soon run off the edge of the window/screen - and then you lose focus - and the game stops getting mouse position data.
So - as things are right now - it is quite utterly impossible to make the camera move like it does in traditional 1st person games. There is literally no conceivable way to do that.
What are the alternatives?
Well - that’s what we’ve been discussing here. Bottom line is that you end up with some kind of a system where the mouse POSITION controls the camera’s VELOCITY. So you move the mouse away from the center of the screen and the camera starts spinning. If you let go of the mouse - the camera keeps on spinning…until you move the mouse back to the center again. The further you move the mouse from the center of the screen, the faster the camera spings.
That’s NOT like conventional FPS games - and there are good reasons to believe that it won’t be anywhere near as convenient.
Why won’t the browser writers let us reposition the mouse?
The reason is because of security and malware. Imagine you go to some website that wants to play a three minute advert video before it lets you into the site. Right now, you can say “screw that!” and hit the back button - or click on the menu - or even shut down the browser. But if the application writer can reposition the mouse pointer - they can stop you from clicking on ANYTHING except the advert itself! That’s really nasty!
There are other, even more nasty things they could do - but that’s enough to convince the browser folks to completely disallow mouse repositioning in software from JavaScript.
What do we wish could happen?
Well, we don’t want lunatic advertisers trapping our mice! So the proposal here is to allow mouse positioning - but ONLY when the browser is running “full screen” - and to forceably trap the escape key to drop you out of full-screen and return mouse control to the user.
That’s a pretty good suggestion - and I’d certainly back a proposal by the browser folks to get that agreed upon. But standards grow only fairly slowly - and it would take months to years to get this agreed on - and a year or more to get it into all of the mainstream browsers.
So if you’re planning on writing something like an FPS - you’re going to have to think rather carefully about how you’re going to control it - because, for the forseeable future, you can’t make it work like a normal PC-based FPS.
– Steve