adjustable mouse sensitivity added (#118)
This commit is contained in:
parent
f53ebe0e4f
commit
52df0ee8cf
1 changed files with 10 additions and 2 deletions
12
index.js
12
index.js
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue