showing what is placeable or not

This commit is contained in:
wass08
2026-01-18 11:09:05 +09:00
parent 35a479df15
commit 159b61d22a
3 changed files with 9 additions and 8 deletions
@@ -74,12 +74,11 @@ export const ItemTool: React.FC = () => {
[0, 0, 0], [0, 0, 0],
[draftItem.current.id], [draftItem.current.id],
); );
console.log( if (placeable.valid) {
"placeable", cursorRef.current.material.color.set("green");
placeable, } else {
[gridPosition.current.x, 0, gridPosition.current.z], cursorRef.current.material.color.set("red");
selectedItem.dimensions, }
);
} }
} }
}; };
@@ -49,7 +49,10 @@ export class SpatialGrid {
const maxZ = z + rotatedD / 2; const maxZ = z + rotatedD / 2;
const [minCx, minCz] = this.posToCell(minX, minZ); 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[] = []; const keys: CellKey[] = [];
for (let cx = minCx; cx <= maxCx; cx++) { for (let cx = minCx; cx <= maxCx; cx++) {
@@ -11,7 +11,6 @@ export function useSpatialQuery() {
rotation: [number, number, number], rotation: [number, number, number],
ignoreIds?: string[], ignoreIds?: string[],
) => { ) => {
console.log("spatialGridManager in useSpatialQuery:", spatialGridManager);
return spatialGridManager.canPlaceOnFloor( return spatialGridManager.canPlaceOnFloor(
levelId, levelId,
position, position,