draft wall builder

This commit is contained in:
wass08
2026-01-16 13:58:01 +09:00
parent 1b954d3416
commit 536c2e94cc
11 changed files with 225 additions and 16 deletions
+45 -1
View File
@@ -1,5 +1,7 @@
"use client";
import { BuildingNode, LevelNode, useScene } from "@pascal-app/core";
import { useViewer } from "@pascal-app/viewer";
import { create } from "zustand";
export type Phase = "site" | "structure" | "furnish";
@@ -45,7 +47,49 @@ type EditorState = {
const useEditor = create<EditorState>()((set, get) => ({
phase: "site",
setPhase: (phase) => set({ phase }),
setPhase: (phase) => {
const currentPhase = get().phase;
if (currentPhase === phase) return;
set({ phase });
const viewer = useViewer.getState();
const scene = useScene.getState();
switch (phase) {
case "site":
// In Site mode, we zoom out and deselect specific levels/buildings
viewer.setCurrentBuildingId(null);
viewer.setCurrentLevelId(null);
viewer.setLevelMode("stacked");
break;
case "structure":
// In Structure mode, we often want to focus on a specific building/level
// Auto-select the first building if none is selected
if (!viewer.currentBuildingId) {
const firstBuildingId = scene.rootNodeIds.find((id) => {
const node = scene.nodes[id];
return node?.type === "building" || null;
});
if (firstBuildingId) {
viewer.setCurrentBuildingId(firstBuildingId as BuildingNode["id"]);
const buildingNode = scene.nodes[firstBuildingId] as BuildingNode;
const firstLevelId = buildingNode.children[0];
if (firstLevelId) {
viewer.setCurrentLevelId(firstLevelId as LevelNode["id"]);
}
}
}
viewer.setLevelMode("exploded"); // Better for structure editing
break;
case "furnish":
// Maybe in furnish mode we force "solo" level view to see inside rooms
viewer.setLevelMode("solo");
break;
}
},
mode: "select",
setMode: (mode) => set({ mode }),
tool: null,