From 1f10cbdf1cfb93f41183d9b4b62b6e7ce6550859 Mon Sep 17 00:00:00 2001 From: wass08 Date: Fri, 30 Jan 2026 10:15:47 +0900 Subject: [PATCH] fix zone-system solo camera mode --- .../components/systems/zone/zone-system.tsx | 34 +++++++++++++------ .../ui/action-menu/structure-tools.tsx | 5 ++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/apps/editor/components/systems/zone/zone-system.tsx b/apps/editor/components/systems/zone/zone-system.tsx index 8f7554f8..2c775526 100644 --- a/apps/editor/components/systems/zone/zone-system.tsx +++ b/apps/editor/components/systems/zone/zone-system.tsx @@ -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 } diff --git a/apps/editor/components/ui/action-menu/structure-tools.tsx b/apps/editor/components/ui/action-menu/structure-tools.tsx index b7cda3e6..b228c643 100644 --- a/apps/editor/components/ui/action-menu/structure-tools.tsx +++ b/apps/editor/components/ui/action-menu/structure-tools.tsx @@ -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' },