fix issue when switching phase/structure layer

This commit is contained in:
wass08
2026-03-06 13:09:25 +01:00
parent ca0a3acf17
commit 8d26a4d81c
2 changed files with 86 additions and 64 deletions
@@ -28,54 +28,6 @@ export const CATALOG_ITEMS: AssetInput[] = [
5 5
] ]
}, },
{
"id": "recessed-light",
category: "furniture",
"tags": ["ceiling", "lighting"],
"name": "Recessed Light",
"thumbnail": "/items/recessed-light/thumbnail.webp",
"src": "/items/recessed-light/model.glb",
"scale": [
1,
1,
1
],
"offset": [
0,
0.094,
0
],
"rotation": [
0,
0,
0
],
"dimensions": [
0.5,
0.1,
0.5
],
"attachTo": "ceiling",
interactive: {
controls: [
{
kind: 'toggle',
},
{
kind: 'slider', label: 'Intensity', min: 0, max: 100, unit: '%', displayMode: 'dial',
default: 100
}
],
effects: [
{
kind: 'light',
intensityRange: [0, 2],
color: '#ffffff',
offset: [0, -0.1, 0],
}
]
}
},
{ {
"id": "ev-wall-charger", "id": "ev-wall-charger",
"category": "appliance", "category": "appliance",
@@ -1263,19 +1215,19 @@ export const CATALOG_ITEMS: AssetInput[] = [
dimensions: [1.5, 2.5, 3.5], dimensions: [1.5, 2.5, 3.5],
}, },
{ // {
id: "suspended-fireplace", // id: "suspended-fireplace",
category: "furniture", // category: "furniture",
tags: ["ceiling", "decor"], // tags: ["ceiling", "decor"],
name: "Suspended Fireplace", // name: "Suspended Fireplace",
thumbnail: "/items/suspended-fireplace/thumbnail.webp", // thumbnail: "/items/suspended-fireplace/thumbnail.webp",
src: "/items/suspended-fireplace/model.glb", // src: "/items/suspended-fireplace/model.glb",
scale: [1, 1, 1], // scale: [1, 1, 1],
offset: [0, 0.45, 0], // offset: [0, 0.45, 0],
rotation: [0, 0, 0], // rotation: [0, 0, 0],
dimensions: [0.5, 0.5, 0.5], // dimensions: [0.5, 0.5, 0.5],
attachTo: "ceiling", // attachTo: "ceiling",
}, // },
{ {
id: "tv-stand", id: "tv-stand",
@@ -1354,6 +1306,54 @@ export const CATALOG_ITEMS: AssetInput[] = [
] ]
} }
}, },
{
"id": "recessed-light",
category: "furniture",
"tags": ["ceiling", "lighting"],
"name": "Recessed Light",
"thumbnail": "/items/recessed-light/thumbnail.webp",
"src": "/items/recessed-light/model.glb",
"scale": [
1,
1,
1
],
"offset": [
0,
0.094,
0
],
"rotation": [
0,
0,
0
],
"dimensions": [
0.5,
0.1,
0.5
],
"attachTo": "ceiling",
interactive: {
controls: [
{
kind: 'toggle',
},
{
kind: 'slider', label: 'Intensity', min: 0, max: 100, unit: '%', displayMode: 'dial',
default: 100
}
],
effects: [
{
kind: 'light',
intensityRange: [0, 2],
color: '#ffffff',
offset: [0, -0.1, 0],
}
]
}
},
{ {
id: "floor-lamp", id: "floor-lamp",
+25 -3
View File
@@ -86,8 +86,23 @@ const useEditor = create<EditorState>()((set, get) => ({
set({ phase }) set({ phase })
// Reset to select mode and clear tool/catalog when switching phases const { mode, structureLayer } = get()
set({ mode: 'select', tool: null, catalogCategory: null })
if (mode === 'build') {
// Stay in build mode, select the first tool for the new phase
if (phase === 'site') {
set({ tool: 'property-line', catalogCategory: null })
} else if (phase === 'structure' && structureLayer === 'zones') {
set({ tool: 'zone', catalogCategory: null })
} else if (phase === 'structure') {
set({ tool: 'wall', catalogCategory: null })
} else if (phase === 'furnish') {
set({ tool: 'item', catalogCategory: 'furniture' })
}
} else {
// Reset to select mode and clear tool/catalog when switching phases
set({ mode: 'select', tool: null, catalogCategory: null })
}
const viewer = useViewer.getState() const viewer = useViewer.getState()
const scene = useScene.getState() const scene = useScene.getState()
@@ -177,7 +192,14 @@ const useEditor = create<EditorState>()((set, get) => ({
setTool: (tool) => set({ tool }), setTool: (tool) => set({ tool }),
structureLayer: 'elements', structureLayer: 'elements',
setStructureLayer: (layer) => { setStructureLayer: (layer) => {
set({ structureLayer: layer, mode: 'select', tool: null }) const { mode } = get()
if (mode === 'build') {
const tool = layer === 'zones' ? 'zone' : 'wall'
set({ structureLayer: layer, tool })
} else {
set({ structureLayer: layer, mode: 'select', tool: null })
}
const viewer = useViewer.getState() const viewer = useViewer.getState()
viewer.setSelection({ viewer.setSelection({