sync: update core and viewer from monorepo (#143)

Major changes:
- Roof system rewrite with roof-segment support
- Scene store refactor
- Spatial grid improvements
- Item light system
- Post-processing and selection manager updates
- Perf monitor component

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Aymeric Rabot
2026-03-20 23:18:30 -04:00
committed by GitHub
co-authored by Claude Opus 4.6
parent bafc5973a3
commit 1d28e4208f
32 changed files with 1921 additions and 619 deletions
@@ -17,11 +17,20 @@ export const sceneRegistry = {
slab: new Set<string>(),
zone: new Set<string>(),
roof: new Set<string>(),
'roof-segment': new Set<string>(),
scan: new Set<string>(),
guide: new Set<string>(),
window: new Set<string>(),
door: new Set<string>(),
},
/** Remove all entries. Call when unloading a scene to prevent stale 3D refs. */
clear() {
this.nodes.clear()
for (const set of Object.values(this.byType)) {
set.clear()
}
},
}
export function useRegistry(
@@ -273,15 +273,19 @@ export function wallOverlapsPolygon(
}
export class SpatialGridManager {
private floorGrids = new Map<string, SpatialGrid>() // levelId -> grid
private wallGrids = new Map<string, WallSpatialGrid>() // levelId -> wall grid
private walls = new Map<string, WallNode>() // wallId -> wall data (for length calculations)
private slabsByLevel = new Map<string, Map<string, SlabNode>>() // levelId -> (slabId -> slab)
private ceilingGrids = new Map<string, SpatialGrid>() // ceilingId -> grid
private ceilings = new Map<string, CeilingNode>() // ceilingId -> ceiling data
private itemCeilingMap = new Map<string, string>() // itemId -> ceilingId (reverse lookup)
private readonly floorGrids = new Map<string, SpatialGrid>() // levelId -> grid
private readonly wallGrids = new Map<string, WallSpatialGrid>() // levelId -> wall grid
private readonly walls = new Map<string, WallNode>() // wallId -> wall data (for length calculations)
private readonly slabsByLevel = new Map<string, Map<string, SlabNode>>() // levelId -> (slabId -> slab)
private readonly ceilingGrids = new Map<string, SpatialGrid>() // ceilingId -> grid
private readonly ceilings = new Map<string, CeilingNode>() // ceilingId -> ceiling data
private readonly itemCeilingMap = new Map<string, string>() // itemId -> ceilingId (reverse lookup)
constructor(private cellSize = 0.5) {}
private readonly cellSize: number
constructor(cellSize = 0.5) {
this.cellSize = cellSize
}
private getFloorGrid(levelId: string): SpatialGrid {
if (!this.floorGrids.has(levelId)) {
@@ -9,10 +9,14 @@ interface SpatialGridConfig {
}
export class SpatialGrid {
private cells = new Map<CellKey, GridCell>()
private itemCells = new Map<string, Set<CellKey>>() // reverse lookup
private readonly cells = new Map<CellKey, GridCell>()
private readonly itemCells = new Map<string, Set<CellKey>>() // reverse lookup
constructor(private config: SpatialGridConfig) {}
private readonly config: SpatialGridConfig
constructor(config: SpatialGridConfig) {
this.config = config
}
private posToCell(x: number, z: number): [number, number] {
return [Math.floor(x / this.config.cellSize), Math.floor(z / this.config.cellSize)]
@@ -75,7 +79,7 @@ export class SpatialGrid {
if (!this.cells.has(key)) {
this.cells.set(key, { itemIds: new Set() })
}
this.cells.get(key)!.itemIds.add(itemId)
this.cells.get(key)?.itemIds.add(itemId)
}
}
@@ -49,8 +49,8 @@ function autoAdjustYPosition(
}
export class WallSpatialGrid {
private wallItems = new Map<string, WallItemPlacement[]>() // wallId -> placements
private itemToWall = new Map<string, string>() // itemId -> wallId (reverse lookup)
private readonly wallItems = new Map<string, WallItemPlacement[]>() // wallId -> placements
private readonly itemToWall = new Map<string, string>() // itemId -> wallId (reverse lookup)
/**
* Check if an item can be placed on a wall with auto-adjustment for vertical position
@@ -152,7 +152,7 @@ export class WallSpatialGrid {
if (!this.wallItems.has(wallId)) {
this.wallItems.set(wallId, [])
}
this.wallItems.get(wallId)!.push(placement)
this.wallItems.get(wallId)?.push(placement)
this.itemToWall.set(itemId, wallId)
}