diff --git a/src/components/Stream.tsx b/src/components/Stream.tsx index 7464529f8..2b201d955 100644 --- a/src/components/Stream.tsx +++ b/src/components/Stream.tsx @@ -7,7 +7,7 @@ import { } from 'react' import { v4 as uuidv4 } from 'uuid' import { useStore } from '../useStore' -import { getNormalisedCoordinates } from '../lib/utils' +import { getNormalisedCoordinates, throttle } from '../lib/utils' import Loading from './Loading' import { cameraMouseDragGuards } from 'lib/cameraControls' import { useGlobalStateContext } from 'hooks/useGlobalStateContext' @@ -115,9 +115,9 @@ export const Stream = ({ className = '' }) => { setClickCoords({ x, y }) } - const handleScroll: WheelEventHandler = (e) => { + const fps = 60 + const handleScroll: WheelEventHandler = throttle((e) => { if (!cameraMouseDragGuards[cameraControls].zoom.scrollCallback(e)) return - engineCommandManager.sendSceneCommand({ type: 'modeling_cmd_req', cmd: { @@ -126,7 +126,7 @@ export const Stream = ({ className = '' }) => { }, cmd_id: uuidv4(), }) - } + }, Math.round(1000 / fps)) const handleMouseUp: MouseEventHandler = ({ clientX,