feat(scene): shared zoom/pan for control and presentation

Keep effects pinned to map coordinates when the viewport changes; materials/NPC overlays stay screen-fixed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ivan Fontosh
2026-07-23 14:08:19 +08:00
parent 2c0e6fbf09
commit eb127c11c2
13 changed files with 688 additions and 19 deletions
@@ -0,0 +1,31 @@
import { useEffect, useState } from 'react';
import { ipcChannels } from '../../../shared/ipc/contracts';
import type { SceneViewEvent, SceneViewState } from '../../../shared/types';
import { getDndApi } from '../dndApi';
export function useSceneViewState(): readonly [
SceneViewState | null,
{ dispatch: (event: SceneViewEvent) => Promise<void> },
] {
const api = getDndApi();
const [state, setState] = useState<SceneViewState | null>(null);
useEffect(() => {
void api.invoke(ipcChannels.sceneView.getState, {}).then((r) => {
setState(r.state);
});
return api.on(ipcChannels.sceneView.stateChanged, ({ state: next }) => {
setState(next);
});
}, [api]);
return [
state,
{
dispatch: async (event) => {
await api.invoke(ipcChannels.sceneView.dispatch, { event });
},
},
] as const;
}