diff --git a/src/clientSideScene/CameraControls.ts b/src/clientSideScene/CameraControls.ts index 361262c8d..1b6313beb 100644 --- a/src/clientSideScene/CameraControls.ts +++ b/src/clientSideScene/CameraControls.ts @@ -20,6 +20,7 @@ import { EngineCommand, Subscription, EngineCommandManager, + UnreliableSubscription, } from 'lang/std/engineConnection' import { uuidv4 } from 'lib/utils' import { deg2Rad } from 'lib/utils2d' @@ -232,9 +233,18 @@ export class CameraControls { this.update() this._usePerspectiveCamera() - const cb: Subscription< - 'default_camera_zoom' | 'camera_drag_end' | 'default_camera_get_settings' - >['callback'] = ({ data, type }) => { + type CallBackParam = Parameters< + ( + | Subscription< + | 'default_camera_zoom' + | 'camera_drag_end' + | 'default_camera_get_settings' + > + | UnreliableSubscription<'camera_drag_move'> + )['callback'] + >[0] + + const cb = ({ data, type }: CallBackParam) => { const camSettings = data.settings this.camera.position.set( camSettings.pos.x, @@ -287,6 +297,10 @@ export class CameraControls { event: 'default_camera_get_settings', callback: cb, }) + this.engineCommandManager.subscribeToUnreliable({ + event: 'camera_drag_move', + callback: cb, + }) }) } diff --git a/src/lang/std/engineConnection.ts b/src/lang/std/engineConnection.ts index 97ba9a9d1..894cf68b8 100644 --- a/src/lang/std/engineConnection.ts +++ b/src/lang/std/engineConnection.ts @@ -559,6 +559,8 @@ class EngineConnection { ) { this.engineCommandManager.inSequence = result.data.sequence callback(result) + } else if (result.type !== 'highlight_set_entity') { + callback(result) } } ) @@ -876,7 +878,7 @@ type UnreliableResponses = Extract< Models['OkModelingCmdResponse_type'], { type: 'highlight_set_entity' | 'camera_drag_move' } > -interface UnreliableSubscription { +export interface UnreliableSubscription { event: T callback: (data: Extract) => void }