Pointer

The Pointer API deals with locking and unlocking pointers. This is beneficial for first person games that control the player using the mouse pointer. By locking the pointer, it will not be rendered anymore and all pointer events will now only return relative movement on X and Y axis. The pointer can not leave the render view anymore and will be invisibly held where it was when the lock occurred.

Reference

pointer.lock()

Lock the pointer. This will cause the pointer to disappear and be locked in the render view. Pointer events


will now have static x/y position and only the movementX/movementY values will change. There is no guarantee the lock will happen as the browser will decide on this. In case the lock did not happen you will have an error in the log and the isLocked() function will return false. Also note that locking is an async operation so the result may not be available right after the call

pointer.unlock()

Unlock the pointer in case it is locked. Will have no effect in case there was no lock

pointer.isLocked()

Check if the pointer is locked

Returns:

true in case the pointer is locked, otherwise false

Return type:

boolean

Examples