diff --git a/src/Toolbar.tsx b/src/Toolbar.tsx index 563920a70..37194ad97 100644 --- a/src/Toolbar.tsx +++ b/src/Toolbar.tsx @@ -23,7 +23,10 @@ import { import { isDesktop } from 'lib/isDesktop' import { openExternalBrowserIfDesktop } from 'lib/openWindow' import { EngineConnectionStateType } from 'lang/std/engineConnection' -import useEngineStreamContext, { EngineStreamState, EngineStreamTransition } from 'hooks/useEngineStreamContext' +import useEngineStreamContext, { + EngineStreamState, + EngineStreamTransition, +} from 'hooks/useEngineStreamContext' export function Toolbar({ className = '', diff --git a/src/clientSideScene/CameraControls.ts b/src/clientSideScene/CameraControls.ts index 11f790098..44680189c 100644 --- a/src/clientSideScene/CameraControls.ts +++ b/src/clientSideScene/CameraControls.ts @@ -97,10 +97,12 @@ export class CameraControls { wasDragging: boolean mouseDownPosition: Vector2 mouseNewPosition: Vector2 - old: { - camera: PerspectiveCamera, - target: Vector3, - } | undefined + old: + | { + camera: PerspectiveCamera + target: Vector3 + } + | undefined rotationSpeed = 0.3 enableRotate = true enablePan = true @@ -960,33 +962,51 @@ export class CameraControls { // camera coordinates after a zoom-to-fit... So this is much easier, and // maps better to screen coordinates. - await this.engineCommandManager.sendSceneCommand({ - type: 'modeling_cmd_batch_req', - batch_id: uuidv4(), - responses: true, - requests: [ - { - type: 'modeling_cmd_req', - cmd_id: uuidv4(), - cmd: { - type: 'zoom_to_fit', - object_ids: zoomObjectId ? [zoomObjectId] : [], // leave empty to zoom to all objects - padding: panesWidth > 0 ? (window.innerWidth / panesWidth) : 0.2, // padding around the objects + await this.engineCommandManager + .sendSceneCommand({ + type: 'modeling_cmd_batch_req', + batch_id: uuidv4(), + responses: true, + requests: [ + { + type: 'modeling_cmd_req', + cmd_id: uuidv4(), + cmd: { + type: 'zoom_to_fit', + object_ids: zoomObjectId ? [zoomObjectId] : [], // leave empty to zoom to all objects + padding: panesWidth > 0 ? window.innerWidth / panesWidth : 0.2, // padding around the objects + }, }, - }, - { - type: 'modeling_cmd_req', - cmd: { - type: 'camera_drag_start', - interaction: 'pan', - window: { x: 0, y: 0 }, + { + type: 'modeling_cmd_req', + cmd: { + type: 'camera_drag_start', + interaction: 'pan', + window: { x: 0, y: 0 }, + }, + cmd_id: uuidv4(), }, - cmd_id: uuidv4(), - }, - { + { + type: 'modeling_cmd_req', + cmd: { + type: 'camera_drag_move', + interaction: 'pan', + window: { + x: goRightPx, + y: 0, + }, + }, + cmd_id: uuidv4(), + }, + ], + }) + // engineCommandManager can't subscribe to batch responses so we'll send + // this one off by its lonesome after. + .then(() => + this.engineCommandManager.sendSceneCommand({ type: 'modeling_cmd_req', cmd: { - type: 'camera_drag_move', + type: 'camera_drag_end', interaction: 'pan', window: { x: goRightPx, @@ -994,23 +1014,8 @@ export class CameraControls { }, }, cmd_id: uuidv4(), - }, - ] - }) - // engineCommandManager can't subscribe to batch responses so we'll send - // this one off by its lonesome after. - .then(() => this.engineCommandManager.sendSceneCommand({ - type: 'modeling_cmd_req', - cmd: { - type: 'camera_drag_end', - interaction: 'pan', - window: { - x: goRightPx, - y: 0, - }, - }, - cmd_id: uuidv4(), - })) + }) + ) } async tweenCameraToQuaternion( diff --git a/src/components/CommandBar/CommandBar.tsx b/src/components/CommandBar/CommandBar.tsx index 5cd4401ef..6cc692478 100644 --- a/src/components/CommandBar/CommandBar.tsx +++ b/src/components/CommandBar/CommandBar.tsx @@ -29,7 +29,9 @@ export const CommandBar = () => { }, [pathname]) useEffect(() => { - if (immediateState.type !== EngineConnectionStateType.ConnectionEstablished) { + if ( + immediateState.type !== EngineConnectionStateType.ConnectionEstablished + ) { commandBarSend({ type: 'Close' }) } }, [immediateState]) diff --git a/src/components/CommandBarOpenButton.tsx b/src/components/CommandBarOpenButton.tsx index 12e0a5fdd..e2aceffe9 100644 --- a/src/components/CommandBarOpenButton.tsx +++ b/src/components/CommandBarOpenButton.tsx @@ -11,7 +11,8 @@ export function CommandBarOpenButton() { const { immediateState } = useNetworkContext() const platform = usePlatform() - const isDisabled = immediateState.type !== EngineConnectionStateType.ConnectionEstablished + const isDisabled = + immediateState.type !== EngineConnectionStateType.ConnectionEstablished return (