can place draft

This commit is contained in:
wass08
2026-01-18 11:03:48 +09:00
parent 8bf933ed36
commit 35a479df15
5 changed files with 9 additions and 16 deletions
@@ -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",
@@ -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(
@@ -10,11 +10,15 @@ function resolveLevelId(node: AnyNode, nodes: Record<string, AnyNode>): 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)
if (!current.parentId) {
current = undefined;
} else {
current = nodes[current.parentId];
}
}
return "default"; // fallback for orphaned items
}
@@ -117,7 +117,6 @@ export class SpatialGrid {
const cellKeys = this.getItemCells(position, dimensions, rotation);
const ignoreSet = new Set(ignoreIds);
const conflicts = new Set<string>();
console.log("checking cells", cellKeys);
for (const key of cellKeys) {
const cell = this.cells.get(key);
@@ -11,6 +11,7 @@ export function useSpatialQuery() {
rotation: [number, number, number],
ignoreIds?: string[],
) => {
console.log("spatialGridManager in useSpatialQuery:", spatialGridManager);
return spatialGridManager.canPlaceOnFloor(
levelId,
position,