adjustable mouse sensitivity added (#118)

This commit is contained in:
Petr Melentev 2021-03-19 13:01:37 +03:00 committed by GitHub
commit 52df0ee8cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -143,6 +143,14 @@ async function connect (options) {
window.pathfinder = pathfinder
window.debugMenu = debugMenu
window.renderer = renderer
window.settings = {
mouseSensXValue: window.localStorage.getItem('mouseSensX') ?? 0.005,
mouseSensYValue: window.localStorage.getItem('mouseSensY') ?? 0.005,
set mouseSensX (v) { this.mouseSensXValue = v; window.localStorage.setItem('mouseSensX', v) },
set mouseSensY (v) { this.mouseSensYValue = v; window.localStorage.setItem('mouseSensY', v) },
get mouseSensX () { return this.mouseSensXValue },
get mouseSensY () { return this.mouseSensYValue }
}
// Link WorldView and Viewer
viewer.listen(worldView)
@ -177,9 +185,9 @@ async function connect (options) {
loadingScreen.status = 'Setting callbacks...'
function moveCallback (e) {
bot.entity.pitch -= e.movementY * 0.01
bot.entity.pitch -= e.movementY * window.settings.mouseSensYValue
bot.entity.pitch = Math.max(minPitch, Math.min(maxPitch, bot.entity.pitch))
bot.entity.yaw -= e.movementX * 0.01
bot.entity.yaw -= e.movementX * window.settings.mouseSensXValue
viewer.setFirstPersonCamera(null, bot.entity.yaw, bot.entity.pitch)
updateCursor()