can place draft
This commit is contained in:
@@ -72,6 +72,7 @@ export const ItemTool: React.FC = () => {
|
|||||||
[gridPosition.current.x, 0, gridPosition.current.z],
|
[gridPosition.current.x, 0, gridPosition.current.z],
|
||||||
selectedItem.dimensions,
|
selectedItem.dimensions,
|
||||||
[0, 0, 0],
|
[0, 0, 0],
|
||||||
|
[draftItem.current.id],
|
||||||
);
|
);
|
||||||
console.log(
|
console.log(
|
||||||
"placeable",
|
"placeable",
|
||||||
|
|||||||
@@ -70,12 +70,6 @@ export class SpatialGridManager {
|
|||||||
item.asset.dimensions,
|
item.asset.dimensions,
|
||||||
item.rotation,
|
item.rotation,
|
||||||
);
|
);
|
||||||
console.log(
|
|
||||||
"inserting floor item",
|
|
||||||
item.id,
|
|
||||||
item.position,
|
|
||||||
item.asset.dimensions,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,13 +135,7 @@ export class SpatialGridManager {
|
|||||||
ignoreIds?: string[],
|
ignoreIds?: string[],
|
||||||
) {
|
) {
|
||||||
const grid = this.getFloorGrid(levelId);
|
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(
|
canPlaceOnWall(
|
||||||
|
|||||||
@@ -10,11 +10,15 @@ function resolveLevelId(node: AnyNode, nodes: Record<string, AnyNode>): string {
|
|||||||
// This assumes you track parentId or can derive it
|
// This assumes you track parentId or can derive it
|
||||||
let current: AnyNode | undefined = node;
|
let current: AnyNode | undefined = node;
|
||||||
|
|
||||||
while (current && current.parentId) {
|
while (current) {
|
||||||
if (current.type === "level") return current.id;
|
if (current.type === "level") return current.id;
|
||||||
// Find parent (you might need to add parentId to your schema or derive it)
|
// Find parent (you might need to add parentId to your schema or derive it)
|
||||||
|
if (!current.parentId) {
|
||||||
|
current = undefined;
|
||||||
|
} else {
|
||||||
current = nodes[current.parentId];
|
current = nodes[current.parentId];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return "default"; // fallback for orphaned items
|
return "default"; // fallback for orphaned items
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ export class SpatialGrid {
|
|||||||
const cellKeys = this.getItemCells(position, dimensions, rotation);
|
const cellKeys = this.getItemCells(position, dimensions, rotation);
|
||||||
const ignoreSet = new Set(ignoreIds);
|
const ignoreSet = new Set(ignoreIds);
|
||||||
const conflicts = new Set<string>();
|
const conflicts = new Set<string>();
|
||||||
console.log("checking cells", cellKeys);
|
|
||||||
|
|
||||||
for (const key of cellKeys) {
|
for (const key of cellKeys) {
|
||||||
const cell = this.cells.get(key);
|
const cell = this.cells.get(key);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ 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,
|
||||||
|
|||||||
Reference in New Issue
Block a user