fix issue when switching phase/structure layer
This commit is contained in:
@@ -28,54 +28,6 @@ export const CATALOG_ITEMS: AssetInput[] = [
|
||||
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",
|
||||
"category": "appliance",
|
||||
@@ -1263,19 +1215,19 @@ export const CATALOG_ITEMS: AssetInput[] = [
|
||||
dimensions: [1.5, 2.5, 3.5],
|
||||
},
|
||||
|
||||
{
|
||||
id: "suspended-fireplace",
|
||||
category: "furniture",
|
||||
tags: ["ceiling", "decor"],
|
||||
name: "Suspended Fireplace",
|
||||
thumbnail: "/items/suspended-fireplace/thumbnail.webp",
|
||||
src: "/items/suspended-fireplace/model.glb",
|
||||
scale: [1, 1, 1],
|
||||
offset: [0, 0.45, 0],
|
||||
rotation: [0, 0, 0],
|
||||
dimensions: [0.5, 0.5, 0.5],
|
||||
attachTo: "ceiling",
|
||||
},
|
||||
// {
|
||||
// id: "suspended-fireplace",
|
||||
// category: "furniture",
|
||||
// tags: ["ceiling", "decor"],
|
||||
// name: "Suspended Fireplace",
|
||||
// thumbnail: "/items/suspended-fireplace/thumbnail.webp",
|
||||
// src: "/items/suspended-fireplace/model.glb",
|
||||
// scale: [1, 1, 1],
|
||||
// offset: [0, 0.45, 0],
|
||||
// rotation: [0, 0, 0],
|
||||
// dimensions: [0.5, 0.5, 0.5],
|
||||
// attachTo: "ceiling",
|
||||
// },
|
||||
|
||||
{
|
||||
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",
|
||||
|
||||
@@ -86,8 +86,23 @@ const useEditor = create<EditorState>()((set, get) => ({
|
||||
|
||||
set({ phase })
|
||||
|
||||
// Reset to select mode and clear tool/catalog when switching phases
|
||||
set({ mode: 'select', tool: null, catalogCategory: null })
|
||||
const { mode, structureLayer } = get()
|
||||
|
||||
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 scene = useScene.getState()
|
||||
@@ -177,7 +192,14 @@ const useEditor = create<EditorState>()((set, get) => ({
|
||||
setTool: (tool) => set({ tool }),
|
||||
structureLayer: 'elements',
|
||||
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()
|
||||
viewer.setSelection({
|
||||
|
||||
Reference in New Issue
Block a user