integrate unreliable camera_drag_move
This commit is contained in:
@ -20,6 +20,7 @@ import {
|
|||||||
EngineCommand,
|
EngineCommand,
|
||||||
Subscription,
|
Subscription,
|
||||||
EngineCommandManager,
|
EngineCommandManager,
|
||||||
|
UnreliableSubscription,
|
||||||
} from 'lang/std/engineConnection'
|
} from 'lang/std/engineConnection'
|
||||||
import { uuidv4 } from 'lib/utils'
|
import { uuidv4 } from 'lib/utils'
|
||||||
import { deg2Rad } from 'lib/utils2d'
|
import { deg2Rad } from 'lib/utils2d'
|
||||||
@ -232,9 +233,18 @@ export class CameraControls {
|
|||||||
this.update()
|
this.update()
|
||||||
this._usePerspectiveCamera()
|
this._usePerspectiveCamera()
|
||||||
|
|
||||||
const cb: Subscription<
|
type CallBackParam = Parameters<
|
||||||
'default_camera_zoom' | 'camera_drag_end' | 'default_camera_get_settings'
|
(
|
||||||
>['callback'] = ({ data, type }) => {
|
| 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
|
const camSettings = data.settings
|
||||||
this.camera.position.set(
|
this.camera.position.set(
|
||||||
camSettings.pos.x,
|
camSettings.pos.x,
|
||||||
@ -287,6 +297,10 @@ export class CameraControls {
|
|||||||
event: 'default_camera_get_settings',
|
event: 'default_camera_get_settings',
|
||||||
callback: cb,
|
callback: cb,
|
||||||
})
|
})
|
||||||
|
this.engineCommandManager.subscribeToUnreliable({
|
||||||
|
event: 'camera_drag_move',
|
||||||
|
callback: cb,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,6 +559,8 @@ class EngineConnection {
|
|||||||
) {
|
) {
|
||||||
this.engineCommandManager.inSequence = result.data.sequence
|
this.engineCommandManager.inSequence = result.data.sequence
|
||||||
callback(result)
|
callback(result)
|
||||||
|
} else if (result.type !== 'highlight_set_entity') {
|
||||||
|
callback(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -876,7 +878,7 @@ type UnreliableResponses = Extract<
|
|||||||
Models['OkModelingCmdResponse_type'],
|
Models['OkModelingCmdResponse_type'],
|
||||||
{ type: 'highlight_set_entity' | 'camera_drag_move' }
|
{ type: 'highlight_set_entity' | 'camera_drag_move' }
|
||||||
>
|
>
|
||||||
interface UnreliableSubscription<T extends UnreliableResponses['type']> {
|
export interface UnreliableSubscription<T extends UnreliableResponses['type']> {
|
||||||
event: T
|
event: T
|
||||||
callback: (data: Extract<UnreliableResponses, { type: T }>) => void
|
callback: (data: Extract<UnreliableResponses, { type: T }>) => void
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user