From 159b61d22ad637acb514b9ad95658462c0940d37 Mon Sep 17 00:00:00 2001 From: wass08 Date: Sun, 18 Jan 2026 11:09:05 +0900 Subject: [PATCH] showing what is placeable or not --- apps/editor/components/tools/item/item-tool.tsx | 11 +++++------ packages/core/src/hooks/spatial-grid/spatial-grid.ts | 5 ++++- .../core/src/hooks/spatial-grid/use-spatial-query.ts | 1 - 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/editor/components/tools/item/item-tool.tsx b/apps/editor/components/tools/item/item-tool.tsx index c2d821d5..c6675091 100644 --- a/apps/editor/components/tools/item/item-tool.tsx +++ b/apps/editor/components/tools/item/item-tool.tsx @@ -74,12 +74,11 @@ export const ItemTool: React.FC = () => { [0, 0, 0], [draftItem.current.id], ); - console.log( - "placeable", - placeable, - [gridPosition.current.x, 0, gridPosition.current.z], - selectedItem.dimensions, - ); + if (placeable.valid) { + cursorRef.current.material.color.set("green"); + } else { + cursorRef.current.material.color.set("red"); + } } } }; diff --git a/packages/core/src/hooks/spatial-grid/spatial-grid.ts b/packages/core/src/hooks/spatial-grid/spatial-grid.ts index 3a63ebbb..9fe6061e 100644 --- a/packages/core/src/hooks/spatial-grid/spatial-grid.ts +++ b/packages/core/src/hooks/spatial-grid/spatial-grid.ts @@ -49,7 +49,10 @@ export class SpatialGrid { const maxZ = z + rotatedD / 2; const [minCx, minCz] = this.posToCell(minX, minZ); - const [maxCx, maxCz] = this.posToCell(maxX, maxZ); + // Use exclusive upper bound: subtract epsilon so exact boundaries don't overlap + // This allows adjacent items (touching but not overlapping) to not conflict + const epsilon = 1e-6; + const [maxCx, maxCz] = this.posToCell(maxX - epsilon, maxZ - epsilon); const keys: CellKey[] = []; for (let cx = minCx; cx <= maxCx; cx++) { 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 e645c03c..62577408 100644 --- a/packages/core/src/hooks/spatial-grid/use-spatial-query.ts +++ b/packages/core/src/hooks/spatial-grid/use-spatial-query.ts @@ -11,7 +11,6 @@ export function useSpatialQuery() { rotation: [number, number, number], ignoreIds?: string[], ) => { - console.log("spatialGridManager in useSpatialQuery:", spatialGridManager); return spatialGridManager.canPlaceOnFloor( levelId, position,