fix zone-system solo camera mode

This commit is contained in:
wass08
2026-01-30 10:15:47 +09:00
parent fe4ca47193
commit 1f10cbdf1c
2 changed files with 25 additions and 14 deletions
@@ -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 useEditor from '@/store/use-editor'
export const ZoneSystem = () => {
const structureLayer = useEditor((state) => state.structureLayer)
const levelMode = useViewer((state) => state.levelMode)
const selectedLevelId = useViewer((state) => state.selection.levelId)
useEffect(() => {
const visible = structureLayer === 'zones'
const zones = sceneRegistry.byType.zone || new Set()
const nodes = useScene.getState().nodes
zones.forEach((zoneId) => {
const node = sceneRegistry.nodes.get(zoneId)
if (node) {
node.visible = visible;
const label = node.getObjectByName('label');
if (label) {
label.position.y = visible ? 1 : -1000;
// Hacky way to hide the label when not visible
}
const obj = sceneRegistry.nodes.get(zoneId)
if (!obj) return
const zone = nodes[zoneId as ZoneNode['id']] as ZoneNode | undefined
// In solo mode, hide labels for zones not on the current level
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])
return null;
}, [structureLayer, levelMode, selectedLevelId])
return null
}
@@ -12,12 +12,11 @@ export type ToolConfig = {
export const tools: ToolConfig[] = [
{ id: 'wall', iconSrc: '/icons/wall.png', label: 'Wall' },
{ id: 'room', iconSrc: '/icons/room.png', label: 'Room' },
{ id: 'custom-room', iconSrc: '/icons/custom-room.png', label: 'Custom Room' },
// { id: 'room', iconSrc: '/icons/room.png', label: 'Room' },
// { id: 'custom-room', iconSrc: '/icons/custom-room.png', label: 'Custom Room' },
{ id: 'slab', iconSrc: '/icons/floor.png', label: 'Slab' },
{ id: 'ceiling', iconSrc: '/icons/ceiling.png', label: 'Ceiling' },
{ 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/window.png', label: 'Window', catalogCategory: 'window' },
{ id: 'zone', iconSrc: '/icons/zone.png', label: 'Zone' },