fix zone-system solo camera mode
This commit is contained in:
@@ -1,24 +1,36 @@
|
|||||||
import { sceneRegistry } from '@pascal-app/core'
|
import { type ZoneNode, sceneRegistry, useScene } from '@pascal-app/core'
|
||||||
|
import { useViewer } from '@pascal-app/viewer'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import useEditor from '@/store/use-editor'
|
import useEditor from '@/store/use-editor'
|
||||||
|
|
||||||
export const ZoneSystem = () => {
|
export const ZoneSystem = () => {
|
||||||
const structureLayer = useEditor((state) => state.structureLayer)
|
const structureLayer = useEditor((state) => state.structureLayer)
|
||||||
|
const levelMode = useViewer((state) => state.levelMode)
|
||||||
|
const selectedLevelId = useViewer((state) => state.selection.levelId)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const visible = structureLayer === 'zones'
|
const visible = structureLayer === 'zones'
|
||||||
const zones = sceneRegistry.byType.zone || new Set()
|
const zones = sceneRegistry.byType.zone || new Set()
|
||||||
|
const nodes = useScene.getState().nodes
|
||||||
|
|
||||||
zones.forEach((zoneId) => {
|
zones.forEach((zoneId) => {
|
||||||
const node = sceneRegistry.nodes.get(zoneId)
|
const obj = sceneRegistry.nodes.get(zoneId)
|
||||||
if (node) {
|
if (!obj) return
|
||||||
node.visible = visible;
|
|
||||||
const label = node.getObjectByName('label');
|
const zone = nodes[zoneId as ZoneNode['id']] as ZoneNode | undefined
|
||||||
if (label) {
|
|
||||||
label.position.y = visible ? 1 : -1000;
|
// In solo mode, hide labels for zones not on the current level
|
||||||
// Hacky way to hide the label when not visible
|
const isOnSelectedLevel = zone?.parentId === selectedLevelId
|
||||||
}
|
const hideInSoloMode = levelMode === 'solo' && selectedLevelId && !isOnSelectedLevel
|
||||||
|
|
||||||
|
obj.visible = visible
|
||||||
|
const label = obj.getObjectByName('label')
|
||||||
|
if (label) {
|
||||||
|
// Hide label if zone layer is off OR if in solo mode on a different level
|
||||||
|
label.position.y = (visible && !hideInSoloMode) ? 1 : -1000
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [structureLayer])
|
}, [structureLayer, levelMode, selectedLevelId])
|
||||||
return null;
|
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,11 @@ export type ToolConfig = {
|
|||||||
|
|
||||||
export const tools: ToolConfig[] = [
|
export const tools: ToolConfig[] = [
|
||||||
{ id: 'wall', iconSrc: '/icons/wall.png', label: 'Wall' },
|
{ id: 'wall', iconSrc: '/icons/wall.png', label: 'Wall' },
|
||||||
{ id: 'room', iconSrc: '/icons/room.png', label: 'Room' },
|
// { id: 'room', iconSrc: '/icons/room.png', label: 'Room' },
|
||||||
{ id: 'custom-room', iconSrc: '/icons/custom-room.png', label: 'Custom Room' },
|
// { id: 'custom-room', iconSrc: '/icons/custom-room.png', label: 'Custom Room' },
|
||||||
{ id: 'slab', iconSrc: '/icons/floor.png', label: 'Slab' },
|
{ id: 'slab', iconSrc: '/icons/floor.png', label: 'Slab' },
|
||||||
{ id: 'ceiling', iconSrc: '/icons/ceiling.png', label: 'Ceiling' },
|
{ id: 'ceiling', iconSrc: '/icons/ceiling.png', label: 'Ceiling' },
|
||||||
{ id: 'roof', iconSrc: '/icons/roof.png', label: 'Gable Roof' },
|
{ id: 'roof', iconSrc: '/icons/roof.png', label: 'Gable Roof' },
|
||||||
{ id: 'column', iconSrc: '/icons/column.png', label: 'Column' },
|
|
||||||
{ id: 'item', iconSrc: '/icons/door.png', label: 'Door', catalogCategory: 'door' },
|
{ id: 'item', iconSrc: '/icons/door.png', label: 'Door', catalogCategory: 'door' },
|
||||||
{ id: 'item', iconSrc: '/icons/window.png', label: 'Window', catalogCategory: 'window' },
|
{ id: 'item', iconSrc: '/icons/window.png', label: 'Window', catalogCategory: 'window' },
|
||||||
{ id: 'zone', iconSrc: '/icons/zone.png', label: 'Zone' },
|
{ id: 'zone', iconSrc: '/icons/zone.png', label: 'Zone' },
|
||||||
|
|||||||
Reference in New Issue
Block a user