Clip deltaY to +/- 100 (#5793)

* Clip deltaY to +/- 100
Should fix #5120

* Lint

* Fix the clip with @nickmccleery's suggestion
This commit is contained in:
Pierre Jacquier
2025-03-14 13:17:10 -04:00
committed by GitHub
parent 0229105158
commit e9806b83d7

View File

@ -503,10 +503,13 @@ export class CameraControls {
if (interaction === 'none') return
event.preventDefault()
// TODO: find a better way than this clipping to +/- 100 to prevent the bug in #5120
const deltaY = Math.max(-100, Math.min(100, event.deltaY))
if (this.syncDirection === 'engineToClient') {
if (interaction === 'zoom') {
this.zoomSender.send(() => {
this.doZoom(event.deltaY)
this.doZoom(deltaY)
})
} else {
// This case will get handled when we add pan and rotate using Apple trackpad.
@ -526,7 +529,7 @@ export class CameraControls {
this.handleStart()
if (interaction === 'zoom') {
this.pendingZoom = 1 + (event.deltaY / window.devicePixelRatio) * 0.001
this.pendingZoom = 1 + (deltaY / window.devicePixelRatio) * 0.001
} else {
// This case will get handled when we add pan and rotate using Apple trackpad.
console.error(