HTML and CSS Reference
In-Depth Information
That's enough mobile excitement for now; in the next section you're going back to the
desktop and the Pointer Lock API, a necessary component of most 3D games.
I.3.7. The Pointer Lock API: tracking mouse motion instead of pointer position
Pointer lock may sound like it's another way of doing setCapture , but it's targeted at
a different use case. Whereas setCapture allows you to continue tracking the mouse
pointer position even when it moves outside the target element, pointer lock takes the point-
er position out of the equation entirely. Instead of tracking the position of the mouse point-
er, it tracks motion from the mouse itself. The difference is that the pointer position is lim-
ited by the bounds of the screen; the mouse can carry on moving. This is crucially important
in immersive games like first-person shooters, where the mouse is used to orient the player.
Figure I.17 shows an example taken from http://media.tojicode.com/q3bsp/ ; note that the
mouse pointer doesn't even appear.
Figure I.17. Pointer lock in action along with WebGL; note that the mouse pointer isn't visible.
The Pointer Lock API involves only a few properties, methods, and events. A summary is
shown in table I.8 .
 
Search WWH ::




Custom Search