diff --git a/apps/editor/components/tools/item/item-tool.tsx b/apps/editor/components/tools/item/item-tool.tsx index 6a1d9803..c2d821d5 100644 --- a/apps/editor/components/tools/item/item-tool.tsx +++ b/apps/editor/components/tools/item/item-tool.tsx @@ -72,6 +72,7 @@ export const ItemTool: React.FC = () => { [gridPosition.current.x, 0, gridPosition.current.z], selectedItem.dimensions, [0, 0, 0], + [draftItem.current.id], ); console.log( "placeable", diff --git a/packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts b/packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts index 2ec270af..9dbed911 100644 --- a/packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts +++ b/packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts @@ -70,12 +70,6 @@ export class SpatialGridManager { item.asset.dimensions, item.rotation, ); - console.log( - "inserting floor item", - item.id, - item.position, - item.asset.dimensions, - ); } } } @@ -141,13 +135,7 @@ export class SpatialGridManager { ignoreIds?: string[], ) { const grid = this.getFloorGrid(levelId); - console.log("canPlaceOnFloor - grid item count:", grid.getItemCount()); - return grid.canPlace( - position, - dimensions, - rotation, - ignoreIds, - ); + return grid.canPlace(position, dimensions, rotation, ignoreIds); } canPlaceOnWall( diff --git a/packages/core/src/hooks/spatial-grid/spatial-grid-sync.ts b/packages/core/src/hooks/spatial-grid/spatial-grid-sync.ts index 2e8f4872..ab186b42 100644 --- a/packages/core/src/hooks/spatial-grid/spatial-grid-sync.ts +++ b/packages/core/src/hooks/spatial-grid/spatial-grid-sync.ts @@ -10,10 +10,14 @@ function resolveLevelId(node: AnyNode, nodes: Record): string { // This assumes you track parentId or can derive it let current: AnyNode | undefined = node; - while (current && current.parentId) { + while (current) { if (current.type === "level") return current.id; // Find parent (you might need to add parentId to your schema or derive it) - current = nodes[current.parentId]; + if (!current.parentId) { + current = undefined; + } else { + current = nodes[current.parentId]; + } } return "default"; // fallback for orphaned items diff --git a/packages/core/src/hooks/spatial-grid/spatial-grid.ts b/packages/core/src/hooks/spatial-grid/spatial-grid.ts index 7da0f362..3a63ebbb 100644 --- a/packages/core/src/hooks/spatial-grid/spatial-grid.ts +++ b/packages/core/src/hooks/spatial-grid/spatial-grid.ts @@ -117,7 +117,6 @@ export class SpatialGrid { const cellKeys = this.getItemCells(position, dimensions, rotation); const ignoreSet = new Set(ignoreIds); const conflicts = new Set(); - console.log("checking cells", cellKeys); for (const key of cellKeys) { const cell = this.cells.get(key); diff --git a/packages/core/src/hooks/spatial-grid/use-spatial-query.ts b/packages/core/src/hooks/spatial-grid/use-spatial-query.ts index 62577408..e645c03c 100644 --- a/packages/core/src/hooks/spatial-grid/use-spatial-query.ts +++ b/packages/core/src/hooks/spatial-grid/use-spatial-query.ts @@ -11,6 +11,7 @@ export function useSpatialQuery() { rotation: [number, number, number], ignoreIds?: string[], ) => { + console.log("spatialGridManager in useSpatialQuery:", spatialGridManager); return spatialGridManager.canPlaceOnFloor( levelId, position,