fix default spatial grid

This commit is contained in:
wass08 2026-01-23 11:31:14 +09:00
parent 3240266476
commit aaadec8add
3 changed files with 11 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import { CustomCameraControls } from './custom-camera-controls'
import { SelectionManager } from './selection-manager'
useScene.getState().loadScene()
console.log('Loaded scene in editor')
initSpatialGridSync()
export default function Editor() {

View File

@ -26,6 +26,14 @@ export function resolveLevelId(node: AnyNode, nodes: Record<string, AnyNode>): s
// Call this once at app initialization
export function initSpatialGridSync() {
const store = useScene
// 1. Initial sync - process all existing nodes
const state = store.getState()
for (const node of Object.values(state.nodes)) {
const levelId = resolveLevelId(node, state.nodes)
spatialGridManager.handleNodeCreated(node, levelId)
}
// 2. Then subscribe to future changes
// Subscribe to all changes
store.subscribe((state, prevState) => {

View File

@ -163,7 +163,8 @@ const useScene = create<SceneState>()(
zoneIds: state.zoneIds,
}),
onRehydrateStorage: (state) => {
console.log('hydration starts')
console.log('hydrating...')
// optional
return (state, error) => {