Skip to content

Example of how to use pointer lock controls in Three Fiber with offsets for raycasting

Notifications You must be signed in to change notification settings

JacobJaffe/pointer-lock-controls-offset-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pointer Lock Controls Offset Example

This repo provides an example of how to use mouse offsets with pointer lock controls with Three Fiber.

Normally, when raycasting for pointer events, the raycast occurs from the offset of the mouse and camera.

However, when using a PointerLockControl, the offset should be disregarded, as the mouse position does not change. This can cause issues unless the mouse is set to the middle of the canvas before entering the pointer lock.

By setting the offset to be the middle of the canvas, the offset is ignored, and the raycasts operate as expected.

This is demo'd here by having the raycasted mouse location tracked with a red circle, and the expected raycast location tracked with a black reticle.

Without Offsetting

Without Offsetting

With Offsetting

With Offsetting

About

Example of how to use pointer lock controls in Three Fiber with offsets for raycasting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published