@collabdt/core 0.5.1 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/components/AppSidebarContent.d.ts +2 -3
- package/dist/core/components/AppSidebarContent.d.ts.map +1 -1
- package/dist/core/components/AppSidebarContent.js +10 -1
- package/dist/core/components/AppSidebarContent.js.map +1 -1
- package/dist/core/components/Toolbar.d.ts +2 -3
- package/dist/core/components/Toolbar.d.ts.map +1 -1
- package/dist/core/components/Toolbar.js.map +1 -1
- package/dist/core/components/ui/AppSidebar.d.ts +2 -2
- package/dist/core/components/ui/AppSidebar.d.ts.map +1 -1
- package/dist/core/components/ui/AppSidebar.js.map +1 -1
- package/dist/core/components/ui/Comments/CommentsSection.d.ts.map +1 -1
- package/dist/core/components/ui/Comments/CommentsSection.js +10 -9
- package/dist/core/components/ui/Comments/CommentsSection.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.js +24 -23
- package/dist/core/components/ui/Sensors/SensorsSection.js.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/Shell.js +1 -1
- package/dist/core/components/ui/ViewerSidebar/Shell.js.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/TabStrip.d.ts +6 -5
- package/dist/core/components/ui/ViewerSidebar/TabStrip.d.ts.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/TabStrip.js +6 -4
- package/dist/core/components/ui/ViewerSidebar/TabStrip.js.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/sidebarTabs.d.ts +16 -9
- package/dist/core/components/ui/ViewerSidebar/sidebarTabs.d.ts.map +1 -1
- package/dist/core/components/ui/ViewerSidebar/sidebarTabs.js.map +1 -1
- package/dist/core/components/viewers/Viewer.d.ts.map +1 -1
- package/dist/core/components/viewers/Viewer.js +17 -8
- package/dist/core/components/viewers/Viewer.js.map +1 -1
- package/dist/core/components/viewers/bim/BimViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/BimViewer.js +6 -1
- package/dist/core/components/viewers/bim/BimViewer.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/index.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/index.js +5 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/index.js.map +1 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts +10 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.js +36 -1
- package/dist/core/components/viewers/bim/src/ElementAppearance.js.map +1 -1
- package/dist/core/components/viewers/bim/src/ModelsSync.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/ModelsSync.js +6 -5
- package/dist/core/components/viewers/bim/src/ModelsSync.js.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts +12 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js +18 -2
- package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js +6 -3
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.js +5 -1
- package/dist/core/components/viewers/map/src/MapSidebar/index.js.map +1 -1
- package/dist/core/components/viewers/map/utils/stringToColour.d.ts +3 -0
- package/dist/core/components/viewers/map/utils/stringToColour.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/stringToColour.js +72 -70
- package/dist/core/components/viewers/map/utils/stringToColour.js.map +1 -1
- package/dist/core/components/viewers/plugins/src/PluginCard.d.ts.map +1 -1
- package/dist/core/components/viewers/plugins/src/PluginCard.js +8 -4
- package/dist/core/components/viewers/plugins/src/PluginCard.js.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.d.ts.map +1 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.js +5 -1
- package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.js.map +1 -1
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts +10 -0
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.d.ts.map +1 -0
- package/dist/core/components/viewers/{map/legends/MapLegendHost.js → shared/legends/ViewerLegendHost.js} +48 -8
- package/dist/core/components/viewers/shared/legends/ViewerLegendHost.js.map +1 -0
- package/dist/core/components/viewers/viewerAccess.d.ts +7 -0
- package/dist/core/components/viewers/viewerAccess.d.ts.map +1 -0
- package/dist/core/components/viewers/viewerAccess.js +9 -0
- package/dist/core/components/viewers/viewerAccess.js.map +1 -0
- package/dist/core/i18n/messages/en.json +5 -0
- package/dist/core/i18n/messages/es.json +5 -0
- package/dist/core/i18n/messages/fr.json +5 -0
- package/dist/core/plugins/hello-bim/components/SpaceDialog.d.ts +13 -0
- package/dist/core/plugins/hello-bim/components/SpaceDialog.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpaceDialog.js +80 -0
- package/dist/core/plugins/hello-bim/components/SpaceDialog.js.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesLegend.d.ts +11 -0
- package/dist/core/plugins/hello-bim/components/SpacesLegend.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesLegend.js +16 -0
- package/dist/core/plugins/hello-bim/components/SpacesLegend.js.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesTab.d.ts +4 -0
- package/dist/core/plugins/hello-bim/components/SpacesTab.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesTab.js +211 -0
- package/dist/core/plugins/hello-bim/components/SpacesTab.js.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesTool.d.ts +8 -0
- package/dist/core/plugins/hello-bim/components/SpacesTool.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/SpacesTool.js +68 -0
- package/dist/core/plugins/hello-bim/components/SpacesTool.js.map +1 -0
- package/dist/core/plugins/hello-bim/components/icons.d.ts +13 -0
- package/dist/core/plugins/hello-bim/components/icons.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/components/icons.js +52 -0
- package/dist/core/plugins/hello-bim/components/icons.js.map +1 -0
- package/dist/core/plugins/hello-bim/index.d.ts +2 -6
- package/dist/core/plugins/hello-bim/index.d.ts.map +1 -1
- package/dist/core/plugins/hello-bim/index.js +27 -3
- package/dist/core/plugins/hello-bim/index.js.map +1 -1
- package/dist/core/plugins/hello-bim/manifest.json +97 -31
- package/dist/core/plugins/hello-bim/spaces.d.ts +57 -0
- package/dist/core/plugins/hello-bim/spaces.d.ts.map +1 -0
- package/dist/core/plugins/hello-bim/spaces.js +207 -0
- package/dist/core/plugins/hello-bim/spaces.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MapTool.d.ts +9 -0
- package/dist/core/plugins/hello-map/components/MapTool.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/{HelloMapTool.js → MapTool.js} +30 -11
- package/dist/core/plugins/hello-map/components/MapTool.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkerDialog.d.ts +9 -0
- package/dist/core/plugins/hello-map/components/MarkerDialog.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkerDialog.js +47 -0
- package/dist/core/plugins/hello-map/components/MarkerDialog.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersLayer.d.ts +8 -0
- package/dist/core/plugins/hello-map/components/MarkersLayer.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersLayer.js +133 -0
- package/dist/core/plugins/hello-map/components/MarkersLayer.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersLegend.d.ts +11 -0
- package/dist/core/plugins/hello-map/components/MarkersLegend.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersLegend.js +20 -0
- package/dist/core/plugins/hello-map/components/MarkersLegend.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersPage.d.ts +6 -0
- package/dist/core/plugins/hello-map/components/MarkersPage.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersPage.js +40 -0
- package/dist/core/plugins/hello-map/components/MarkersPage.js.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersTab.d.ts +4 -0
- package/dist/core/plugins/hello-map/components/MarkersTab.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/components/MarkersTab.js +275 -0
- package/dist/core/plugins/hello-map/components/MarkersTab.js.map +1 -0
- package/dist/core/plugins/hello-map/index.d.ts +2 -5
- package/dist/core/plugins/hello-map/index.d.ts.map +1 -1
- package/dist/core/plugins/hello-map/index.js +43 -3
- package/dist/core/plugins/hello-map/index.js.map +1 -1
- package/dist/core/plugins/hello-map/manifest.json +85 -12
- package/dist/core/plugins/hello-map/markers.d.ts +32 -0
- package/dist/core/plugins/hello-map/markers.d.ts.map +1 -0
- package/dist/core/plugins/hello-map/markers.js +143 -0
- package/dist/core/plugins/hello-map/markers.js.map +1 -0
- package/dist/core/plugins/host/PluginDataPageHost.d.ts +10 -0
- package/dist/core/plugins/host/PluginDataPageHost.d.ts.map +1 -0
- package/dist/core/plugins/host/PluginDataPageHost.js +142 -0
- package/dist/core/plugins/host/PluginDataPageHost.js.map +1 -0
- package/dist/core/plugins/host/PluginDialogHost.d.ts +7 -0
- package/dist/core/plugins/host/PluginDialogHost.d.ts.map +1 -0
- package/dist/core/plugins/host/PluginDialogHost.js +80 -0
- package/dist/core/plugins/host/PluginDialogHost.js.map +1 -0
- package/dist/core/plugins/host/PluginMapLayerHost.d.ts +6 -0
- package/dist/core/plugins/host/PluginMapLayerHost.d.ts.map +1 -0
- package/dist/core/plugins/host/PluginMapLayerHost.js +26 -0
- package/dist/core/plugins/host/PluginMapLayerHost.js.map +1 -0
- package/dist/core/plugins/host/dialogs.d.ts +25 -0
- package/dist/core/plugins/host/dialogs.d.ts.map +1 -0
- package/dist/core/plugins/host/dialogs.js +50 -0
- package/dist/core/plugins/host/dialogs.js.map +1 -0
- package/dist/core/plugins/host/host.d.ts.map +1 -1
- package/dist/core/plugins/host/host.js +2 -0
- package/dist/core/plugins/host/host.js.map +1 -1
- package/dist/core/plugins/host/pluginState.d.ts +28 -0
- package/dist/core/plugins/host/pluginState.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginState.js +49 -0
- package/dist/core/plugins/host/pluginState.js.map +1 -0
- package/dist/core/plugins/host/pluginViewerKey.d.ts +13 -0
- package/dist/core/plugins/host/pluginViewerKey.d.ts.map +1 -0
- package/dist/core/plugins/host/pluginViewerKey.js +18 -0
- package/dist/core/plugins/host/pluginViewerKey.js.map +1 -0
- package/dist/core/plugins/host/provider.d.ts.map +1 -1
- package/dist/core/plugins/host/provider.js +2 -1
- package/dist/core/plugins/host/provider.js.map +1 -1
- package/dist/core/plugins/host/runtimeShims.d.ts.map +1 -1
- package/dist/core/plugins/host/runtimeShims.js +61 -1
- package/dist/core/plugins/host/runtimeShims.js.map +1 -1
- package/dist/core/plugins/host/usePluginDataPages.d.ts +15 -0
- package/dist/core/plugins/host/usePluginDataPages.d.ts.map +1 -0
- package/dist/core/plugins/host/usePluginDataPages.js +22 -0
- package/dist/core/plugins/host/usePluginDataPages.js.map +1 -0
- package/dist/core/plugins/host/usePluginViewerTabs.d.ts +11 -0
- package/dist/core/plugins/host/usePluginViewerTabs.d.ts.map +1 -0
- package/dist/core/plugins/host/usePluginViewerTabs.js +41 -0
- package/dist/core/plugins/host/usePluginViewerTabs.js.map +1 -0
- package/dist/core/plugins/sdk/bimViewer.d.ts +29 -13
- package/dist/core/plugins/sdk/bimViewer.d.ts.map +1 -1
- package/dist/core/plugins/sdk/bimViewer.js +17 -1
- package/dist/core/plugins/sdk/bimViewer.js.map +1 -1
- package/dist/core/plugins/sdk/index.d.ts +1 -0
- package/dist/core/plugins/sdk/index.d.ts.map +1 -1
- package/dist/core/plugins/sdk/index.js +4 -1
- package/dist/core/plugins/sdk/index.js.map +1 -1
- package/dist/core/plugins/sdk/messages.d.ts +6 -0
- package/dist/core/plugins/sdk/messages.d.ts.map +1 -1
- package/dist/core/plugins/sdk/messages.js +11 -0
- package/dist/core/plugins/sdk/messages.js.map +1 -1
- package/dist/core/plugins/sdk/state.d.ts +6 -0
- package/dist/core/plugins/sdk/state.d.ts.map +1 -0
- package/dist/core/plugins/sdk/state.js +30 -0
- package/dist/core/plugins/sdk/state.js.map +1 -0
- package/dist/core/plugins/sdk/types.d.ts +55 -10
- package/dist/core/plugins/sdk/types.d.ts.map +1 -1
- package/dist/core/plugins/sdk/types.js +7 -3
- package/dist/core/plugins/sdk/types.js.map +1 -1
- package/dist/core/plugins/sdk/ui.d.ts +12 -0
- package/dist/core/plugins/sdk/ui.d.ts.map +1 -0
- package/dist/core/plugins/sdk/ui.js +16 -0
- package/dist/core/plugins/sdk/ui.js.map +1 -0
- package/dist/core/store/CombineProviders.d.ts.map +1 -1
- package/dist/core/store/CombineProviders.js +6 -2
- package/dist/core/store/CombineProviders.js.map +1 -1
- package/dist/core/store/Menus/reducer.d.ts +5 -3
- package/dist/core/store/Menus/reducer.d.ts.map +1 -1
- package/dist/core/store/Menus/reducer.js.map +1 -1
- package/dist/core/types/dbTypes.d.ts +5 -0
- package/dist/core/types/dbTypes.d.ts.map +1 -1
- package/dist/core/types/dbTypes.js.map +1 -1
- package/package.json +3 -1
- package/dist/core/components/viewers/map/legends/MapLegendHost.d.ts +0 -10
- package/dist/core/components/viewers/map/legends/MapLegendHost.d.ts.map +0 -1
- package/dist/core/components/viewers/map/legends/MapLegendHost.js.map +0 -1
- package/dist/core/plugins/hello-bim/components/HelloBimTool.d.ts +0 -18
- package/dist/core/plugins/hello-bim/components/HelloBimTool.d.ts.map +0 -1
- package/dist/core/plugins/hello-bim/components/HelloBimTool.js +0 -142
- package/dist/core/plugins/hello-bim/components/HelloBimTool.js.map +0 -1
- package/dist/core/plugins/hello-map/components/HelloMapTool.d.ts +0 -14
- package/dist/core/plugins/hello-map/components/HelloMapTool.d.ts.map +0 -1
- package/dist/core/plugins/hello-map/components/HelloMapTool.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/core/components/viewers/bim/BimViewer.tsx"],"sourcesContent":["\"use client\";\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as OBC from \"@thatopen/components\";\r\nimport * as OBF from \"@thatopen/components-front\"\r\nimport { useTranslations, useLocale } from 'next-intl';\r\nimport * as React from \"react\";\r\nimport * as THREE from \"three\";\r\n\r\nimport { useUndoRedoShortcuts } from \"../../../hooks/useUndoRedoShortcuts\";\r\nimport { ToolsContext, BimContext, MenusContext } from \"../../../store\";\r\nimport { SensorLegend } from \"../../ui/Sensors/SensorLegend\";\r\nimport { useBimCoordinateSystem } from \"../useCoordinateSystem\";\r\n\r\nimport { BimLoadingState } from \"./src/BimLoadingState\";\r\nimport { CurrentCamera } from './src/CurrentCamera';\r\nimport { CurrentWorld } from \"./src/CurrentWorld\";\r\nimport { ElementAppearance } from \"./src/ElementAppearance\";\r\nimport { ElevationsTool } from \"./src/ElevationsTool\";\r\nimport { FloorplanTool } from \"./src/FloorplanTool\";\r\nimport { Highlighter } from \"./src/Highlighter\";\r\nimport { IfcClasses } from \"./src/IfcClasses\";\r\nimport { ViewModeCoordinator } from \"./src/lib/ViewModeCoordinator\";\r\nimport { ModelsSync } from \"./src/ModelsSync\";\r\nimport { PropertiesMenu } from \"./src/propertiesMenu\";\r\nimport { SelectionSync } from \"./src/SelectionSync\";\r\nimport { ClippingPlanes } from \"./src/tools/ClippingTool/ClippingPlanes\";\r\nimport { ViewportGizmo } from \"./src/ViewportGizmo\";\r\n\r\n\r\nexport function BimViewer() {\r\n\r\n const t = useTranslations('ViewportGizmo');\r\n const locale = useLocale();\r\n\r\n const { dispatch: bimDispatch, state: bimState } = React.useContext(BimContext);\r\n const { bimComponents } = bimState.bim;\r\n\r\n const { dispatch: toolsDispatch, state: toolsState } = React.useContext(ToolsContext);\r\n const { currentToolId } = toolsState.tools;\r\n\r\n const { state: menusState } = React.useContext(MenusContext);\r\n const { currentViewer } = menusState.menus;\r\n\r\n // Steps appearance overrides (Layers tab) and clipping planes back and\r\n // forward. Bound at the viewer rather than in the tab or the toolbar so the\r\n // shortcuts survive switching tabs, and so neither the sidebar nor the\r\n // toolbar unmounting takes the history with it.\r\n //\r\n // Each feature keeps its own stack, so one keystroke has to pick a target:\r\n // whichever stack changed most recently wins, falling back to the other when\r\n // it has nothing left. `onChanged` also fires while a stack is being\r\n // replayed, which is what keeps CTRL+Z walking down the stack the user\r\n // started on.\r\n const lastTouchedHistory = React.useRef<'appearance' | 'clipping'>('appearance');\r\n\r\n React.useEffect(() => {\r\n if (!bimComponents) return;\r\n const appearance = bimComponents.get(ElementAppearance);\r\n const clipping = bimComponents.get(ClippingPlanes);\r\n const offAppearance = appearance.history.onChanged(() => {\r\n lastTouchedHistory.current = 'appearance';\r\n });\r\n const offClipping = clipping.history.onChanged(() => {\r\n lastTouchedHistory.current = 'clipping';\r\n });\r\n return () => {\r\n offAppearance();\r\n offClipping();\r\n };\r\n }, [bimComponents]);\r\n\r\n const undoRedoTarget = React.useCallback((direction: 'undo' | 'redo') => {\r\n if (!bimComponents) return null;\r\n const appearance = bimComponents.get(ElementAppearance);\r\n const clipping = bimComponents.get(ClippingPlanes);\r\n const canRun = (target: typeof appearance | typeof clipping) =>\r\n direction === 'undo' ? target.history.canUndo : target.history.canRedo;\r\n\r\n const preferred = lastTouchedHistory.current === 'clipping' ? clipping : appearance;\r\n if (canRun(preferred)) return preferred;\r\n\r\n const other = preferred === clipping ? appearance : clipping;\r\n return canRun(other) ? other : null;\r\n }, [bimComponents]);\r\n\r\n useUndoRedoShortcuts({\r\n undo: () => { void undoRedoTarget('undo')?.undo(); },\r\n redo: () => { void undoRedoTarget('redo')?.redo(); },\r\n });\r\n\r\n\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const workerUrlRef = React.useRef<string | null>(null);\r\n const resizeObserverRef = React.useRef<ResizeObserver | null>(null);\r\n // Tracks the Components instance THIS mount created, so cleanup disposes the\r\n // real one and the create-guard can't be defeated by a stale [] closure.\r\n const componentsRef = React.useRef<OBC.Components | null>(null);\r\n\r\n const createViewer = React.useCallback(\r\n async (isCancelled: () => boolean) => {\r\n // Re-entrancy guard keyed to the ref we actually set — NOT the stale\r\n // `bimComponents` from this useCallback's [] closure (always null on\r\n // first run, so it could never stop a second init). Without this,\r\n // React StrictMode (dev) and rapid viewer remounts (prod) build a\r\n // second Components + PostproductionRenderer — a second <canvas> —\r\n // and whichever instance wins the SET_COMPONENTS race may be the one\r\n // whose canvas was detached on remount. Models then load into a scene\r\n // that is never painted: the spatial tree builds (metadata) but no\r\n // geometry shows and floorplan nav drives the dead world's camera.\r\n if (!containerRef.current || componentsRef.current) return;\r\n\r\n const container = containerRef.current;\r\n const components = new OBC.Components();\r\n const worlds = components.get(OBC.Worlds);\r\n const world = worlds.create<\r\n OBC.ShadowedScene,\r\n OBC.OrthoPerspectiveCamera,\r\n OBF.PostproductionRenderer\r\n >();\r\n\r\n world.scene = new OBC.ShadowedScene(components);\r\n\r\n world.renderer = new OBF.PostproductionRenderer(components, container);\r\n world.camera = new OBC.OrthoPerspectiveCamera(components);\r\n\r\n components.init();\r\n\r\n world.scene.setup();\r\n world.scene.three.background = null;\r\n\r\n const grids = components.get(OBC.Grids);\r\n const grid = grids.create(world);\r\n\r\n if (grid) {\r\n bimDispatch({\r\n \"type\": \"SET_GRID\",\r\n \"payload\": { grid }\r\n });\r\n }\r\n\r\n const axesHelper = new THREE.AxesHelper(5);\r\n world.scene.three.add(axesHelper);\r\n\r\n const fragments = components.get(OBC.FragmentsManager);\r\n\r\n const githubUrl =\r\n \"https://thatopen.github.io/engine_fragment/resources/worker.mjs\";\r\n const fetchedUrl = await fetch(githubUrl);\r\n const workerBlob = await fetchedUrl.blob();\r\n const workerFile = new File([workerBlob], \"worker.mjs\", {\r\n type: \"text/javascript\",\r\n });\r\n const workerUrl = URL.createObjectURL(workerFile);\r\n workerUrlRef.current = workerUrl; // Store reference for cleanup\r\n fragments.init(workerUrl);\r\n\r\n world.camera.controls.addEventListener(\"control\", () =>\r\n fragments.core.update(),\r\n );\r\n\r\n world.camera.controls.restThreshold = 0.005;\r\n world.camera.controls.addEventListener(\"rest\", () =>\r\n fragments.core.update(true)\r\n );\r\n\r\n components.get(CurrentWorld).world = world;\r\n components.get(CurrentCamera).camera = world.camera;\r\n components.get(Highlighter);\r\n // Registered up front so it subscribes to model loads before any\r\n // model arrives, rather than when the sidebar first opens.\r\n components.get(IfcClasses);\r\n components.get(ViewModeCoordinator);\r\n // Same reason: it has to hear about model loads and about drawing\r\n // modes releasing the viewer, both of which need its overrides\r\n // repainted, whether or not the Layers tab has ever been opened.\r\n components.get(ElementAppearance);\r\n components.get(FloorplanTool);\r\n components.get(ElevationsTool);\r\n\r\n // Grid injection is safe here — fragments.core is initialized.\r\n if (grid) {\r\n components.get(FloorplanTool).setGrid(grid);\r\n components.get(ElevationsTool).setGrid(grid);\r\n }\r\n\r\n // Enable shadows\r\n world.renderer.three.shadowMap.enabled = true;\r\n world.renderer.three.shadowMap.type = THREE.PCFSoftShadowMap;\r\n world.scene.setup({\r\n shadows: {\r\n cascade: 1,\r\n resolution: 1024,\r\n },\r\n });\r\n\r\n world.scene.distanceRenderer.excludedObjects.add(grid.three);\r\n\r\n await world.scene.updateShadows();\r\n\r\n world.camera.controls.addEventListener(\"rest\", async () => {\r\n await world.scene.updateShadows();\r\n });\r\n\r\n world.scene.three.background = null;\r\n\r\n // If this init was superseded (StrictMode re-run) or the viewer\r\n // unmounted while we awaited the worker fetch / shadow update, throw\r\n // this instance away instead of publishing it. Prevents an orphaned\r\n // world (whose canvas is detached) from winning the store and starving\r\n // the visible canvas of geometry.\r\n if (isCancelled()) {\r\n components.dispose();\r\n return;\r\n }\r\n componentsRef.current = components;\r\n bimDispatch({\r\n type: \"SET_COMPONENTS\",\r\n payload: { bimComponents: components, world, fragments }\r\n });\r\n\r\n // Ensure canvas takes full container size\r\n const canvas = container.querySelector('canvas');\r\n if (canvas) {\r\n canvas.style.width = '100%';\r\n canvas.style.height = '100%';\r\n canvas.style.display = 'block';\r\n }\r\n\r\n // Handle resize using container dimensions\r\n const handleResize = () => {\r\n const width = container.clientWidth;\r\n const height = container.clientHeight;\r\n if (width && height) {\r\n world.renderer?.resize(new THREE.Vector2(width, height));\r\n }\r\n };\r\n\r\n // Initial resize\r\n handleResize();\r\n\r\n // Watch for container size changes using ResizeObserver. This\r\n // already covers the window-resize case: when the window resizes,\r\n // the flex layout reshapes this container, and ResizeObserver\r\n // fires.\r\n const resizeObserver = new ResizeObserver(() => {\r\n handleResize();\r\n });\r\n resizeObserver.observe(container);\r\n resizeObserverRef.current = resizeObserver;\r\n\r\n // The ResizeObserver above is sufficient for redraws. A window\r\n // 'resize' listener here previously leaked on every mount (no matching\r\n // removeEventListener), so it was removed.\r\n }, []\r\n );\r\n\r\n React.useEffect(() => {\r\n let cancelled = false;\r\n void createViewer(() => cancelled);\r\n\r\n // Cleanup: mark this init cancelled (so an in-flight createViewer disposes\r\n // itself instead of publishing), and dispose the instance we actually\r\n // created (componentsRef). The old `if (bimComponents)` read the stale []\r\n // closure value (null at mount), so the real Components was never disposed\r\n // — leaking its renderer/canvas and letting orphans race the store.\r\n return () => {\r\n cancelled = true;\r\n if (resizeObserverRef.current) {\r\n resizeObserverRef.current.disconnect();\r\n }\r\n // OBC walks components in insertion order and does not guard the loop, so one\r\n // component throwing during teardown aborts every disposal after it — including\r\n // FragmentsManager, which it deliberately leaves for last. The store must be cleared\r\n // either way, or it keeps handing out a dead Components/world to whatever mounts next.\r\n try {\r\n componentsRef.current?.dispose();\r\n } catch (error) {\r\n console.error(\"BIM teardown did not complete cleanly\", error);\r\n } finally {\r\n componentsRef.current = null;\r\n bimDispatch({\r\n type: \"DISPOSE-BIM\"\r\n });\r\n }\r\n };\r\n }, []);\r\n\r\n // Enforce Y-up coordinate system for Three.js / camera-controls.\r\n // Runs whenever the world (and its controls) becomes available, and resets on unmount.\r\n useBimCoordinateSystem(bimState.bim.world?.camera?.controls ?? null);\r\n\r\n // Control ViewportGizmo based on current viewer\r\n React.useEffect(() => {\r\n if (!bimComponents) return;\r\n\r\n const viewportGizmo = bimComponents.get(ViewportGizmo);\r\n\r\n viewportGizmo.setLabels({\r\n top: t('top'),\r\n right: t('right'),\r\n bottom: t('bottom'),\r\n left: t('left'),\r\n front: t('front'),\r\n back: t('back')\r\n });\r\n\r\n if (!viewportGizmo) return;\r\n\r\n if (currentViewer === 'bim') {\r\n viewportGizmo.enabled = true;\r\n viewportGizmo.add();\r\n } else {\r\n viewportGizmo.enabled = false;\r\n viewportGizmo.remove();\r\n }\r\n }, [bimComponents, currentViewer, locale, t]);\r\n\r\n return (\r\n <div\r\n style={{\r\n position: \"relative\",\r\n width: \"100%\",\r\n height: \"100%\",\r\n overflow: \"hidden\"\r\n }}\r\n >\r\n <BimLoadingState />\r\n <ModelsSync />\r\n <SelectionSync />\r\n <div\r\n className=\"bim-container\"\r\n id=\"bim-viewer-container\"\r\n ref={containerRef}\r\n style={{\r\n width: \"100%\",\r\n height: \"100%\",\r\n position: \"relative\",\r\n background: \"radial-gradient(circle, rgba(255, 255, 255, 1) 50%, rgba(220, 220, 220, 1) 100%)\",\r\n }}\r\n />\r\n {/* Bottom-left stack, mirroring MapViewer: cards stack upward with flex so a new\r\n overlay never needs a hand-tuned bottom offset. */}\r\n <div className=\"absolute bottom-20 md:bottom-3 left-3 z-10 flex max-w-[calc(100vw-1.5rem)] flex-col gap-2 pointer-events-none\">\r\n <SensorLegend />\r\n </div>\r\n <PropertiesMenu />\r\n </div>\r\n );\r\n}"],"mappings":";AAiUQ,SAQI,KARJ;AA5TR,YAAY,SAAS;AACrB,YAAY,SAAS;A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AAA,cACP,QAAQ;AAAA,cACR,UAAU;AAAA,cACV,YAAY;AAAA,YAChB;AAAA;AAAA,QACJ;AAAA,QAGA,oBAAC,SAAI,WAAU,iHACX,8BAAC,gBAAa,GAClB;AAAA,QACA,oBAAC,kBAAe;AAAA;AAAA;AAAA,EACpB;AAER;","names":["_a"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/components/viewers/bim/BimViewer.tsx"],"sourcesContent":["\"use client\";\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as OBC from \"@thatopen/components\";\r\nimport * as OBF from \"@thatopen/components-front\"\r\nimport { useTranslations, useLocale } from 'next-intl';\r\nimport * as React from \"react\";\r\nimport * as THREE from \"three\";\r\n\r\nimport { useUndoRedoShortcuts } from \"../../../hooks/useUndoRedoShortcuts\";\r\nimport { ToolsContext, BimContext, MenusContext } from \"../../../store\";\r\nimport { ViewerNames } from \"../../../types/dbTypes\";\r\nimport { SensorLegend } from \"../../ui/Sensors/SensorLegend\";\r\nimport { ViewerLegendHost } from \"../shared/legends/ViewerLegendHost\";\r\nimport { useBimCoordinateSystem } from \"../useCoordinateSystem\";\r\n\r\nimport { BimLoadingState } from \"./src/BimLoadingState\";\r\nimport { CurrentCamera } from './src/CurrentCamera';\r\nimport { CurrentWorld } from \"./src/CurrentWorld\";\r\nimport { ElementAppearance } from \"./src/ElementAppearance\";\r\nimport { ElevationsTool } from \"./src/ElevationsTool\";\r\nimport { FloorplanTool } from \"./src/FloorplanTool\";\r\nimport { Highlighter } from \"./src/Highlighter\";\r\nimport { IfcClasses } from \"./src/IfcClasses\";\r\nimport { ViewModeCoordinator } from \"./src/lib/ViewModeCoordinator\";\r\nimport { ModelsSync } from \"./src/ModelsSync\";\r\nimport { PropertiesMenu } from \"./src/propertiesMenu\";\r\nimport { SelectionSync } from \"./src/SelectionSync\";\r\nimport { ClippingPlanes } from \"./src/tools/ClippingTool/ClippingPlanes\";\r\nimport { ViewportGizmo } from \"./src/ViewportGizmo\";\r\n\r\n\r\nexport function BimViewer() {\r\n\r\n const t = useTranslations('ViewportGizmo');\r\n const locale = useLocale();\r\n\r\n const { dispatch: bimDispatch, state: bimState } = React.useContext(BimContext);\r\n const { bimComponents } = bimState.bim;\r\n\r\n const { dispatch: toolsDispatch, state: toolsState } = React.useContext(ToolsContext);\r\n const { currentToolId } = toolsState.tools;\r\n\r\n const { state: menusState } = React.useContext(MenusContext);\r\n const { currentViewer } = menusState.menus;\r\n\r\n // Steps appearance overrides (Layers tab) and clipping planes back and\r\n // forward. Bound at the viewer rather than in the tab or the toolbar so the\r\n // shortcuts survive switching tabs, and so neither the sidebar nor the\r\n // toolbar unmounting takes the history with it.\r\n //\r\n // Each feature keeps its own stack, so one keystroke has to pick a target:\r\n // whichever stack changed most recently wins, falling back to the other when\r\n // it has nothing left. `onChanged` also fires while a stack is being\r\n // replayed, which is what keeps CTRL+Z walking down the stack the user\r\n // started on.\r\n const lastTouchedHistory = React.useRef<'appearance' | 'clipping'>('appearance');\r\n\r\n React.useEffect(() => {\r\n if (!bimComponents) return;\r\n const appearance = bimComponents.get(ElementAppearance);\r\n const clipping = bimComponents.get(ClippingPlanes);\r\n const offAppearance = appearance.history.onChanged(() => {\r\n lastTouchedHistory.current = 'appearance';\r\n });\r\n const offClipping = clipping.history.onChanged(() => {\r\n lastTouchedHistory.current = 'clipping';\r\n });\r\n return () => {\r\n offAppearance();\r\n offClipping();\r\n };\r\n }, [bimComponents]);\r\n\r\n const undoRedoTarget = React.useCallback((direction: 'undo' | 'redo') => {\r\n if (!bimComponents) return null;\r\n const appearance = bimComponents.get(ElementAppearance);\r\n const clipping = bimComponents.get(ClippingPlanes);\r\n const canRun = (target: typeof appearance | typeof clipping) =>\r\n direction === 'undo' ? target.history.canUndo : target.history.canRedo;\r\n\r\n const preferred = lastTouchedHistory.current === 'clipping' ? clipping : appearance;\r\n if (canRun(preferred)) return preferred;\r\n\r\n const other = preferred === clipping ? appearance : clipping;\r\n return canRun(other) ? other : null;\r\n }, [bimComponents]);\r\n\r\n useUndoRedoShortcuts({\r\n undo: () => { void undoRedoTarget('undo')?.undo(); },\r\n redo: () => { void undoRedoTarget('redo')?.redo(); },\r\n });\r\n\r\n\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const workerUrlRef = React.useRef<string | null>(null);\r\n const resizeObserverRef = React.useRef<ResizeObserver | null>(null);\r\n // Tracks the Components instance THIS mount created, so cleanup disposes the\r\n // real one and the create-guard can't be defeated by a stale [] closure.\r\n const componentsRef = React.useRef<OBC.Components | null>(null);\r\n\r\n const createViewer = React.useCallback(\r\n async (isCancelled: () => boolean) => {\r\n // Re-entrancy guard keyed to the ref we actually set — NOT the stale\r\n // `bimComponents` from this useCallback's [] closure (always null on\r\n // first run, so it could never stop a second init). Without this,\r\n // React StrictMode (dev) and rapid viewer remounts (prod) build a\r\n // second Components + PostproductionRenderer — a second <canvas> —\r\n // and whichever instance wins the SET_COMPONENTS race may be the one\r\n // whose canvas was detached on remount. Models then load into a scene\r\n // that is never painted: the spatial tree builds (metadata) but no\r\n // geometry shows and floorplan nav drives the dead world's camera.\r\n if (!containerRef.current || componentsRef.current) return;\r\n\r\n const container = containerRef.current;\r\n const components = new OBC.Components();\r\n const worlds = components.get(OBC.Worlds);\r\n const world = worlds.create<\r\n OBC.ShadowedScene,\r\n OBC.OrthoPerspectiveCamera,\r\n OBF.PostproductionRenderer\r\n >();\r\n\r\n world.scene = new OBC.ShadowedScene(components);\r\n\r\n world.renderer = new OBF.PostproductionRenderer(components, container);\r\n world.camera = new OBC.OrthoPerspectiveCamera(components);\r\n\r\n components.init();\r\n\r\n world.scene.setup();\r\n world.scene.three.background = null;\r\n\r\n const grids = components.get(OBC.Grids);\r\n const grid = grids.create(world);\r\n\r\n if (grid) {\r\n bimDispatch({\r\n \"type\": \"SET_GRID\",\r\n \"payload\": { grid }\r\n });\r\n }\r\n\r\n const axesHelper = new THREE.AxesHelper(5);\r\n world.scene.three.add(axesHelper);\r\n\r\n const fragments = components.get(OBC.FragmentsManager);\r\n\r\n const githubUrl =\r\n \"https://thatopen.github.io/engine_fragment/resources/worker.mjs\";\r\n const fetchedUrl = await fetch(githubUrl);\r\n const workerBlob = await fetchedUrl.blob();\r\n const workerFile = new File([workerBlob], \"worker.mjs\", {\r\n type: \"text/javascript\",\r\n });\r\n const workerUrl = URL.createObjectURL(workerFile);\r\n workerUrlRef.current = workerUrl; // Store reference for cleanup\r\n fragments.init(workerUrl);\r\n\r\n world.camera.controls.addEventListener(\"control\", () =>\r\n fragments.core.update(),\r\n );\r\n\r\n world.camera.controls.restThreshold = 0.005;\r\n world.camera.controls.addEventListener(\"rest\", () =>\r\n fragments.core.update(true)\r\n );\r\n\r\n components.get(CurrentWorld).world = world;\r\n components.get(CurrentCamera).camera = world.camera;\r\n components.get(Highlighter);\r\n // Registered up front so it subscribes to model loads before any\r\n // model arrives, rather than when the sidebar first opens.\r\n components.get(IfcClasses);\r\n components.get(ViewModeCoordinator);\r\n // Same reason: it has to hear about model loads and about drawing\r\n // modes releasing the viewer, both of which need its overrides\r\n // repainted, whether or not the Layers tab has ever been opened.\r\n components.get(ElementAppearance);\r\n components.get(FloorplanTool);\r\n components.get(ElevationsTool);\r\n\r\n // Grid injection is safe here — fragments.core is initialized.\r\n if (grid) {\r\n components.get(FloorplanTool).setGrid(grid);\r\n components.get(ElevationsTool).setGrid(grid);\r\n }\r\n\r\n // Enable shadows\r\n world.renderer.three.shadowMap.enabled = true;\r\n world.renderer.three.shadowMap.type = THREE.PCFSoftShadowMap;\r\n world.scene.setup({\r\n shadows: {\r\n cascade: 1,\r\n resolution: 1024,\r\n },\r\n });\r\n\r\n world.scene.distanceRenderer.excludedObjects.add(grid.three);\r\n\r\n await world.scene.updateShadows();\r\n\r\n world.camera.controls.addEventListener(\"rest\", async () => {\r\n await world.scene.updateShadows();\r\n });\r\n\r\n world.scene.three.background = null;\r\n\r\n // If this init was superseded (StrictMode re-run) or the viewer\r\n // unmounted while we awaited the worker fetch / shadow update, throw\r\n // this instance away instead of publishing it. Prevents an orphaned\r\n // world (whose canvas is detached) from winning the store and starving\r\n // the visible canvas of geometry.\r\n if (isCancelled()) {\r\n components.dispose();\r\n return;\r\n }\r\n componentsRef.current = components;\r\n bimDispatch({\r\n type: \"SET_COMPONENTS\",\r\n payload: { bimComponents: components, world, fragments }\r\n });\r\n\r\n // Ensure canvas takes full container size\r\n const canvas = container.querySelector('canvas');\r\n if (canvas) {\r\n canvas.style.width = '100%';\r\n canvas.style.height = '100%';\r\n canvas.style.display = 'block';\r\n }\r\n\r\n // Handle resize using container dimensions\r\n const handleResize = () => {\r\n const width = container.clientWidth;\r\n const height = container.clientHeight;\r\n if (width && height) {\r\n world.renderer?.resize(new THREE.Vector2(width, height));\r\n }\r\n };\r\n\r\n // Initial resize\r\n handleResize();\r\n\r\n // Watch for container size changes using ResizeObserver. This\r\n // already covers the window-resize case: when the window resizes,\r\n // the flex layout reshapes this container, and ResizeObserver\r\n // fires.\r\n const resizeObserver = new ResizeObserver(() => {\r\n handleResize();\r\n });\r\n resizeObserver.observe(container);\r\n resizeObserverRef.current = resizeObserver;\r\n\r\n // The ResizeObserver above is sufficient for redraws. A window\r\n // 'resize' listener here previously leaked on every mount (no matching\r\n // removeEventListener), so it was removed.\r\n }, []\r\n );\r\n\r\n React.useEffect(() => {\r\n let cancelled = false;\r\n void createViewer(() => cancelled);\r\n\r\n // Cleanup: mark this init cancelled (so an in-flight createViewer disposes\r\n // itself instead of publishing), and dispose the instance we actually\r\n // created (componentsRef). The old `if (bimComponents)` read the stale []\r\n // closure value (null at mount), so the real Components was never disposed\r\n // — leaking its renderer/canvas and letting orphans race the store.\r\n return () => {\r\n cancelled = true;\r\n if (resizeObserverRef.current) {\r\n resizeObserverRef.current.disconnect();\r\n }\r\n // OBC walks components in insertion order and does not guard the loop, so one\r\n // component throwing during teardown aborts every disposal after it — including\r\n // FragmentsManager, which it deliberately leaves for last. The store must be cleared\r\n // either way, or it keeps handing out a dead Components/world to whatever mounts next.\r\n try {\r\n componentsRef.current?.dispose();\r\n } catch (error) {\r\n console.error(\"BIM teardown did not complete cleanly\", error);\r\n } finally {\r\n componentsRef.current = null;\r\n bimDispatch({\r\n type: \"DISPOSE-BIM\"\r\n });\r\n }\r\n };\r\n }, []);\r\n\r\n // Enforce Y-up coordinate system for Three.js / camera-controls.\r\n // Runs whenever the world (and its controls) becomes available, and resets on unmount.\r\n useBimCoordinateSystem(bimState.bim.world?.camera?.controls ?? null);\r\n\r\n // Control ViewportGizmo based on current viewer\r\n React.useEffect(() => {\r\n if (!bimComponents) return;\r\n\r\n const viewportGizmo = bimComponents.get(ViewportGizmo);\r\n\r\n viewportGizmo.setLabels({\r\n top: t('top'),\r\n right: t('right'),\r\n bottom: t('bottom'),\r\n left: t('left'),\r\n front: t('front'),\r\n back: t('back')\r\n });\r\n\r\n if (!viewportGizmo) return;\r\n\r\n if (currentViewer === 'bim') {\r\n viewportGizmo.enabled = true;\r\n viewportGizmo.add();\r\n } else {\r\n viewportGizmo.enabled = false;\r\n viewportGizmo.remove();\r\n }\r\n }, [bimComponents, currentViewer, locale, t]);\r\n\r\n return (\r\n <div\r\n style={{\r\n position: \"relative\",\r\n width: \"100%\",\r\n height: \"100%\",\r\n overflow: \"hidden\"\r\n }}\r\n >\r\n <BimLoadingState />\r\n <ModelsSync />\r\n <SelectionSync />\r\n <div\r\n className=\"bim-container\"\r\n id=\"bim-viewer-container\"\r\n ref={containerRef}\r\n style={{\r\n width: \"100%\",\r\n height: \"100%\",\r\n position: \"relative\",\r\n background: \"radial-gradient(circle, rgba(255, 255, 255, 1) 50%, rgba(220, 220, 220, 1) 100%)\",\r\n }}\r\n />\r\n {/* Bottom-left stack, mirroring MapViewer: cards stack upward with flex so a new\r\n overlay never needs a hand-tuned bottom offset. */}\r\n <div className=\"absolute bottom-20 md:bottom-3 left-3 z-10 flex max-w-[calc(100vw-1.5rem)] flex-col gap-2 pointer-events-none\">\r\n <S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;AAAA,MAEA;AAAA,4BAAC,mBAAgB;AAAA,QACjB,oBAAC,cAAW;AAAA,QACZ,oBAAC,iBAAc;AAAA,QACf;AAAA,UAAC;AAAA;AAAA,YACG,WAAU;AAAA,YACV,IAAG;AAAA,YACH,KAAK;AAAA,YACL,OAAO;AAAA,cACH,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,UAAU;AAAA,cACV,YAAY;AAAA,YAChB;AAAA;AAAA,QACJ;AAAA,QAGA,qBAAC,SAAI,WAAU,iHACX;AAAA,8BAAC,gBAAa;AAAA,UACd,oBAAC,oBAAiB,QAAQ,YAAY,KAAK;AAAA,WAC/C;AAAA,QACA,oBAAC,kBAAe;AAAA;AAAA;AAAA,EACpB;AAER;","names":["_a"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAa9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAGnE,wBAAgB,UAAU,CAAC,EAAE,YAAY,EAAE,EAAE;IAAE,YAAY,CAAC,EAAE,YAAY,CAAA;CAAE,qBAa3E"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { usePluginViewerTabs } from "../../../../../../plugins/host/usePluginViewerTabs";
|
|
4
|
+
import { ViewerNames } from "../../../../../../types/dbTypes";
|
|
3
5
|
import { CommunicationTab } from "../../../../../ui/ViewerSidebar/CommunicationTab";
|
|
4
6
|
import { SensorsTab } from "../../../../../ui/ViewerSidebar/SensorsTab";
|
|
5
7
|
import { ViewerSidebarShell } from "../../../../../ui/ViewerSidebar/Shell";
|
|
@@ -8,12 +10,14 @@ import { LayersTab } from "./LayersTab";
|
|
|
8
10
|
import { SettingsTab } from "./SettingsTab";
|
|
9
11
|
import { TopicsSection } from "./Topics/src/TopicsSection";
|
|
10
12
|
function BimSidebar({ organization }) {
|
|
13
|
+
const pluginTabs = usePluginViewerTabs(ViewerNames.bim);
|
|
11
14
|
const tabs = [
|
|
12
15
|
{ id: "file", content: /* @__PURE__ */ jsx(FileTab, {}) },
|
|
13
16
|
{ id: "layers", content: /* @__PURE__ */ jsx(LayersTab, {}) },
|
|
14
17
|
{ id: "communication", content: /* @__PURE__ */ jsx(CommunicationTab, { topics: /* @__PURE__ */ jsx(TopicsSection, {}) }) },
|
|
15
18
|
{ id: "sensors", content: /* @__PURE__ */ jsx(SensorsTab, {}) },
|
|
16
|
-
{ id: "settings", content: /* @__PURE__ */ jsx(SettingsTab, {}) }
|
|
19
|
+
{ id: "settings", content: /* @__PURE__ */ jsx(SettingsTab, {}) },
|
|
20
|
+
...pluginTabs
|
|
17
21
|
];
|
|
18
22
|
return /* @__PURE__ */ jsx(ViewerSidebarShell, { tabs, organization });
|
|
19
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/index.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { CommunicationTab } from '../../../../../ui/ViewerSidebar/CommunicationTab'\r\nimport { SensorsTab } from '../../../../../ui/ViewerSidebar/SensorsTab'\r\nimport { ViewerSidebarShell } from '../../../../../ui/ViewerSidebar/Shell'\r\n\r\nimport { FileTab } from './FileTab'\r\nimport { LayersTab } from './LayersTab'\r\nimport { SettingsTab } from './SettingsTab'\r\nimport { TopicsSection } from './Topics/src/TopicsSection'\r\n\r\nimport type { Organization } from '../../../../../../types/dbTypes'\r\nimport type { ViewerSidebarTab } from '../../../../../ui/ViewerSidebar/sidebarTabs'\r\n\r\nexport function BimSidebar({ organization }: { organization?: Organization }) {\r\n const tabs: ViewerSidebarTab[] = [\r\n { id: 'file', content: <FileTab /> },\r\n { id: 'layers', content: <LayersTab /> },\r\n { id: 'communication', content: <CommunicationTab topics={<TopicsSection />} /> },\r\n { id: 'sensors', content: <SensorsTab /> },\r\n { id: 'settings', content: <SettingsTab /> },\r\n ]\r\n\r\n return <ViewerSidebarShell tabs={tabs} organization={organization} />\r\n}\r\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/index.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as React from 'react'\r\n\r\nimport { usePluginViewerTabs } from '../../../../../../plugins/host/usePluginViewerTabs'\r\nimport { ViewerNames } from '../../../../../../types/dbTypes'\r\nimport { CommunicationTab } from '../../../../../ui/ViewerSidebar/CommunicationTab'\r\nimport { SensorsTab } from '../../../../../ui/ViewerSidebar/SensorsTab'\r\nimport { ViewerSidebarShell } from '../../../../../ui/ViewerSidebar/Shell'\r\n\r\nimport { FileTab } from './FileTab'\r\nimport { LayersTab } from './LayersTab'\r\nimport { SettingsTab } from './SettingsTab'\r\nimport { TopicsSection } from './Topics/src/TopicsSection'\r\n\r\nimport type { Organization } from '../../../../../../types/dbTypes'\r\nimport type { ViewerSidebarTab } from '../../../../../ui/ViewerSidebar/sidebarTabs'\r\n\r\nexport function BimSidebar({ organization }: { organization?: Organization }) {\r\n const pluginTabs = usePluginViewerTabs(ViewerNames.bim)\r\n\r\n const tabs: ViewerSidebarTab[] = [\r\n { id: 'file', content: <FileTab /> },\r\n { id: 'layers', content: <LayersTab /> },\r\n { id: 'communication', content: <CommunicationTab topics={<TopicsSection />} /> },\r\n { id: 'sensors', content: <SensorsTab /> },\r\n { id: 'settings', content: <SettingsTab /> },\r\n ...pluginTabs,\r\n ]\r\n\r\n return <ViewerSidebarShell tabs={tabs} organization={organization} />\r\n}\r\n"],"mappings":";AAyB2B;AAlB3B,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AAEnC,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAKvB,SAAS,WAAW,EAAE,aAAa,GAAoC;AAC5E,QAAM,aAAa,oBAAoB,YAAY,GAAG;AAEtD,QAAM,OAA2B;AAAA,IAC/B,EAAE,IAAI,QAAQ,SAAS,oBAAC,WAAQ,EAAG;AAAA,IACnC,EAAE,IAAI,UAAU,SAAS,oBAAC,aAAU,EAAG;AAAA,IACvC,EAAE,IAAI,iBAAiB,SAAS,oBAAC,oBAAiB,QAAQ,oBAAC,iBAAc,GAAI,EAAG;AAAA,IAChF,EAAE,IAAI,WAAW,SAAS,oBAAC,cAAW,EAAG;AAAA,IACzC,EAAE,IAAI,YAAY,SAAS,oBAAC,eAAY,EAAG;AAAA,IAC3C,GAAG;AAAA,EACL;AAEA,SAAO,oBAAC,sBAAmB,MAAY,cAA4B;AACrE;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as OBC from '@thatopen/components';
|
|
2
|
-
import { type AppearanceOverride, type AppearanceSource, type NodeAppearance } from './lib/appearanceOverrides';
|
|
2
|
+
import { type AppearanceOverride, type AppearanceSource, type ElementAppearanceGroup, type NodeAppearance } from './lib/appearanceOverrides';
|
|
3
3
|
import type { UndoHistory } from '../../../../utils/undoHistory';
|
|
4
4
|
/**
|
|
5
5
|
* Session-scoped colour and opacity overrides for the Layers tab's two
|
|
@@ -30,6 +30,8 @@ export declare class ElementAppearance extends OBC.Component implements OBC.Disp
|
|
|
30
30
|
*/
|
|
31
31
|
readonly history: UndoHistory;
|
|
32
32
|
private _overrides;
|
|
33
|
+
/** Per-element paint by owner, a plugin id. Outside {@link history}: CTRL+Z is the user's. */
|
|
34
|
+
private _elementOverrides;
|
|
33
35
|
private _seq;
|
|
34
36
|
/**
|
|
35
37
|
* Group the last change belonged to, so a slider drag is one undo step rather
|
|
@@ -63,6 +65,13 @@ export declare class ElementAppearance extends OBC.Component implements OBC.Disp
|
|
|
63
65
|
setNodeAppearance(source: AppearanceSource, nodeId: string, change: NodeAppearance, coalesceKey?: string): void;
|
|
64
66
|
/** Closes the current coalescing group, e.g. when a slider is released. */
|
|
65
67
|
endCoalescing(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Paints elements for one owner, replacing that owner's previous paint. Every group in one
|
|
70
|
+
* call: an owner holds one entry, so calling this per group leaves only the last.
|
|
71
|
+
*/
|
|
72
|
+
setElementAppearance(owner: string, groups: readonly ElementAppearanceGroup[]): void;
|
|
73
|
+
/** Drops one owner's paint, leaving every other owner's and both trees' alone. */
|
|
74
|
+
clearElementAppearance(owner: string): void;
|
|
66
75
|
/** Drops one node's override, giving its elements back to whatever they inherit. */
|
|
67
76
|
clearNode(source: AppearanceSource, nodeId: string): void;
|
|
68
77
|
/** Resets one tree to default colours, leaving the other tree's work alone. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementAppearance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/bim/src/ElementAppearance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAA;AAM3C,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"ElementAppearance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/bim/src/ElementAppearance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAA;AAM3C,OAAO,EAQL,KAAK,kBAA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GACnB,IAAI;IASP,2EAA2E;IAC3E,aAAa,IAAI,IAAI;IAIrB;;;OAGG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,sBAAsB,EAAE,GAAG,IAAI;IA8BpF,kFAAkF;IAClF,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM3C,oFAAoF;IACpF,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAKzD,+EAA+E;IAC/E,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAK3C;;;;;;OAMG;IACH,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAKxB,kDAAkD;IAClD,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAKxB;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM;IA2Bd,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,eAAe,CAOtB;IAED;;;;OAIG;IACH,OAAO,CAAC,cAAc,CAErB;IAED;;;;;;;;OAQG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAWxB;;;OAGG;YACW,SAAS;IAqCvB,OAAO,CAAC,aAAa;IAOrB,OAAO,IAAI,IAAI;CAwBhB"}
|
|
@@ -42,6 +42,8 @@ const _ElementAppearance = class _ElementAppearance extends OBC.Component {
|
|
|
42
42
|
*/
|
|
43
43
|
this.history = createUndoHistory();
|
|
44
44
|
this._overrides = [];
|
|
45
|
+
/** Per-element paint by owner, a plugin id. Outside {@link history}: CTRL+Z is the user's. */
|
|
46
|
+
this._elementOverrides = /* @__PURE__ */ new Map();
|
|
45
47
|
this._seq = 0;
|
|
46
48
|
/**
|
|
47
49
|
* Group the last change belonged to, so a slider drag is one undo step rather
|
|
@@ -114,6 +116,39 @@ const _ElementAppearance = class _ElementAppearance extends OBC.Component {
|
|
|
114
116
|
endCoalescing() {
|
|
115
117
|
this._coalescingKey = null;
|
|
116
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Paints elements for one owner, replacing that owner's previous paint. Every group in one
|
|
121
|
+
* call: an owner holds one entry, so calling this per group leaves only the last.
|
|
122
|
+
*/
|
|
123
|
+
setElementAppearance(owner, groups) {
|
|
124
|
+
const perOwner = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const { items, appearance } of groups) {
|
|
126
|
+
if (appearance.color === void 0 && appearance.opacity === void 0) continue;
|
|
127
|
+
for (const [modelId, localIds] of Object.entries(items)) {
|
|
128
|
+
const ids = [...localIds];
|
|
129
|
+
if (ids.length === 0) continue;
|
|
130
|
+
let perModel = perOwner.get(modelId);
|
|
131
|
+
if (!perModel) {
|
|
132
|
+
perModel = /* @__PURE__ */ new Map();
|
|
133
|
+
perOwner.set(modelId, perModel);
|
|
134
|
+
}
|
|
135
|
+
for (const localId of ids) perModel.set(localId, appearance);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (perOwner.size === 0) {
|
|
139
|
+
this.clearElementAppearance(owner);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this._elementOverrides.set(owner, perOwner);
|
|
143
|
+
this.onChanged.trigger();
|
|
144
|
+
void this.reapply();
|
|
145
|
+
}
|
|
146
|
+
/** Drops one owner's paint, leaving every other owner's and both trees' alone. */
|
|
147
|
+
clearElementAppearance(owner) {
|
|
148
|
+
if (!this._elementOverrides.delete(owner)) return;
|
|
149
|
+
this.onChanged.trigger();
|
|
150
|
+
void this.reapply();
|
|
151
|
+
}
|
|
117
152
|
/** Drops one node's override, giving its elements back to whatever they inherit. */
|
|
118
153
|
clearNode(source, nodeId) {
|
|
119
154
|
if (!findOverride(this._overrides, source, nodeId)) return;
|
|
@@ -200,7 +235,7 @@ const _ElementAppearance = class _ElementAppearance extends OBC.Component {
|
|
|
200
235
|
} catch (e) {
|
|
201
236
|
return;
|
|
202
237
|
}
|
|
203
|
-
const resolved = resolveAppearance(this._overrides, this.nodesBySource());
|
|
238
|
+
const resolved = resolveAppearance(this._overrides, this.nodesBySource(), this._elementOverrides);
|
|
204
239
|
const buckets = bucketByAppearance(resolved);
|
|
205
240
|
const nextTouched = touchedIdsByModel(resolved);
|
|
206
241
|
for (const [modelId, localIds] of this._touched) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/viewers/bim/src/ElementAppearance.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as OBC from '@thatopen/components'\r\nimport * as THREE from 'three'\r\n\r\nimport { createUndoHistory } from '../../../../utils/undoHistory'\r\n\r\nimport { IfcClasses } from './IfcClasses'\r\nimport {\r\n bucketByAppearance,\r\n clearSourceOverrides,\r\n findOverride,\r\n removeOverride,\r\n resolveAppearance,\r\n touchedIdsByModel,\r\n upsertOverride,\r\n type AppearanceOverride,\r\n type AppearanceSource,\r\n type NodeAppearance,\r\n} from './lib/appearanceOverrides'\r\nimport { safeRunAsync } from './lib/safeRun'\r\nimport { ViewModeCoordinator } from './lib/ViewModeCoordinator'\r\nimport { SpatialStructure } from './SpatialStructure'\r\n\r\nimport type { BimTreeNode } from './lib/bimTree'\r\nimport type { UndoHistory } from '../../../../utils/undoHistory'\r\nimport type * as FRAGS from '@thatopen/fragments'\r\n\r\n/** Trees rebuild in bursts as models load, so coalesce the repaints. */\r\nconst REAPPLY_DEBOUNCE_MS = 150\r\n\r\n/**\r\n * Turns one resolved appearance into a Fragments material definition.\r\n *\r\n * Only the keys the override actually sets are present. Fragments merges the\r\n * definition over the element's own material with `Object.assign`, so omitting\r\n * `color` keeps each element's colour (what an opacity-only override needs) and\r\n * omitting `opacity` leaves it opaque. `renderedFaces` is left out on purpose:\r\n * pinning it the way the floorplan highlighter does would force\r\n * `THREE.DoubleSide` onto everything this paints.\r\n *\r\n * `preserveOriginalMaterial` must stay `false`. Fragments skips content\r\n * deduplication for definitions that set it, and the definition list is\r\n * append-only behind a `Uint16` index — so the granular `setColor`/`setOpacity`\r\n * helpers, which set it to `true`, spend one slot per element per call and\r\n * exhaust the model's ~65 500 slots. At `false` an appearance costs one slot\r\n * however many elements wear it.\r\n *\r\n * The published `MaterialDefinition` marks colour, opacity, transparent and\r\n * renderedFaces required, so a partial needs the cast. Verified against\r\n * @thatopen/fragments 3.4.5, whose merge only copies the keys present here.\r\n */\r\nfunction materialFor(appearance: NodeAppearance): FRAGS.MaterialDefinition {\r\n const definition: Partial<FRAGS.MaterialDefinition> = {\r\n preserveOriginalMaterial: false,\r\n }\r\n\r\n if (appearance.color !== undefined) {\r\n definition.color = new THREE.Color(appearance.color)\r\n }\r\n if (appearance.opacity !== undefined) {\r\n definition.opacity = appearance.opacity\r\n definition.transparent = appearance.opacity < 1\r\n }\r\n\r\n return definition as FRAGS.MaterialDefinition\r\n}\r\n\r\n/**\r\n * Session-scoped colour and opacity overrides for the Layers tab's two\r\n * classifier trees, with a shared undo stack.\r\n *\r\n * A component rather than React state for two reasons: the sidebar unmounts the\r\n * tab you are not looking at, and CTRL+Z has to work from anywhere in the\r\n * viewer. Panels read and write through it and re-render off {@link onChanged},\r\n * the same way visibility is routed through `lib/bimItemActions` and announced by\r\n * `VisibilityState`.\r\n *\r\n * Overrides are deliberately not persisted. They are also not preserved across\r\n * floorplan and elevation modes — those repaint the whole model — so this\r\n * reapplies itself whenever the viewer returns to 3D, and whenever the trees\r\n * rebuild, which is what lets a newly loaded model pick up an existing IFC class\r\n * colour.\r\n */\r\nexport class ElementAppearance extends OBC.Component implements OBC.Disposable {\r\n static readonly uuid = 'd2a5f108-9c47-4b36-8e91-5f7a0c3e64d2' as const\r\n\r\n enabled = true\r\n\r\n readonly onChanged = new OBC.Event<void>()\r\n /** Required for `dispose()` to run: OBC checks for `dispose` + `onDisposed`. */\r\n readonly onDisposed = new OBC.Event<string>()\r\n\r\n /**\r\n * Undo/redo steps for colour and opacity only. Visibility, selection and\r\n * camera are deliberately out: they have their own affordances, and folding\r\n * them in would make CTRL+Z unpredictable.\r\n */\r\n readonly history: UndoHistory = createUndoHistory()\r\n\r\n private _overrides: AppearanceOverride[] = []\r\n private _seq = 0\r\n /**\r\n * Group the last change belonged to, so a slider drag is one undo step rather\r\n * than one per tick. Cleared by any change outside the group.\r\n */\r\n private _coalescingKey: string | null = null\r\n /** What the last pass painted, so the next one can un-paint exactly that. */\r\n private _touched = new Map<string, number[]>()\r\n /** Serialises passes: the resets of one must not interleave with another's. */\r\n private _applying: Promise<void> = Promise.resolve()\r\n /** Whether a pass is already waiting, so repeat requests collapse into it. */\r\n private _applyQueued = false\r\n private _reapplyTimeout: ReturnType<typeof setTimeout> | null = null\r\n private _disposed = false\r\n\r\n constructor(components: OBC.Components) {\r\n super(components)\r\n components.add(ElementAppearance.uuid, this)\r\n\r\n components.get(SpatialStructure).onSpatialStructureCreated.add(this.scheduleReapply)\r\n components.get(IfcClasses).onClassesChanged.add(this.scheduleReapply)\r\n // Leaving a drawing view resets every highlight in the model, ours included.\r\n components.get(ViewModeCoordinator).onReleased.add(this.scheduleReapply)\r\n\r\n const fragments = components.get(OBC.FragmentsManager)\r\n fragments.list.onItemDeleted.add(this.onModelRemoved)\r\n }\r\n\r\n get overrides(): readonly AppearanceOverride[] {\r\n return this._overrides\r\n }\r\n\r\n /** The override on one node, if it has one. */\r\n overrideFor(source: AppearanceSource, nodeId: string): NodeAppearance | undefined {\r\n const found = findOverride(this._overrides, source, nodeId)\r\n if (!found) return undefined\r\n return { color: found.color, opacity: found.opacity }\r\n }\r\n\r\n /** Whether one tree has anything to reset. */\r\n hasOverrides(source: AppearanceSource): boolean {\r\n return this._overrides.some(o => o.source === source)\r\n }\r\n\r\n /**\r\n * Sets a colour, an opacity, or both on one node. Merges into whatever that\r\n * node already carries, so picking a colour does not discard its opacity.\r\n *\r\n * `coalesceKey` folds a run of changes into a single undo step. Dragging the\r\n * opacity slider fires on every tick, and eighteen presses of CTRL+Z to get\r\n * back across one drag is not undo, it is a punishment. Pass a key that is\r\n * stable for the drag and different from anything else; the group ends as soon\r\n * as a change with another key arrives, or when {@link endCoalescing} is called.\r\n */\r\n setNodeAppearance(\r\n source: AppearanceSource,\r\n nodeId: string,\r\n change: NodeAppearance,\r\n coalesceKey?: string,\r\n ): void {\r\n if (change.color === undefined && change.opacity === undefined) return\r\n this.commit(\r\n upsertOverride(this._overrides, source, nodeId, change, this._seq++),\r\n change.color !== undefined ? 'Change colour' : 'Change opacity',\r\n coalesceKey,\r\n )\r\n }\r\n\r\n /** Closes the current coalescing group, e.g. when a slider is released. */\r\n endCoalescing(): void {\r\n this._coalescingKey = null\r\n }\r\n\r\n /** Drops one node's override, giving its elements back to whatever they inherit. */\r\n clearNode(source: AppearanceSource, nodeId: string): void {\r\n if (!findOverride(this._overrides, source, nodeId)) return\r\n this.commit(removeOverride(this._overrides, source, nodeId), 'Reset element appearance')\r\n }\r\n\r\n /** Resets one tree to default colours, leaving the other tree's work alone. */\r\n clearSource(source: AppearanceSource): void {\r\n if (!this.hasOverrides(source)) return\r\n this.commit(clearSourceOverrides(this._overrides, source), 'Reset colours')\r\n }\r\n\r\n /**\r\n * Steps back one colour or opacity change. Resolves false when there is\r\n * nothing to undo.\r\n *\r\n * Thin on purpose — {@link history} is the real thing, so a keyboard hook or a\r\n * toolbar button can drive it directly.\r\n */\r\n undo(): Promise<boolean> {\r\n this._coalescingKey = null\r\n return this.history.undo()\r\n }\r\n\r\n /** Re-applies the change that was just undone. */\r\n redo(): Promise<boolean> {\r\n this._coalescingKey = null\r\n return this.history.redo()\r\n }\r\n\r\n /**\r\n * Applies a new override list and records how to move between it and the old\r\n * one.\r\n *\r\n * Both directions close over a list rather than diffing: the list is a handful\r\n * of small plain objects, and replaying either way is the same code path as any\r\n * other change.\r\n */\r\n private commit(\r\n next: AppearanceOverride[],\r\n label: string,\r\n coalesceKey?: string,\r\n ): void {\r\n const continuesGroup = coalesceKey !== undefined && coalesceKey === this._coalescingKey\r\n this._coalescingKey = coalesceKey ?? null\r\n\r\n if (continuesGroup) {\r\n // The step on the stack already restores the state from before the group\r\n // started, which is where one undo should land. Only its forward target\r\n // moves, so redo lands where the drag finished rather than on its first tick.\r\n this.history.amendTop({ redo: () => this.restore(next) })\r\n } else {\r\n const previous = this._overrides\r\n this.history.push({\r\n label,\r\n undo: () => this.restore(previous),\r\n redo: () => this.restore(next),\r\n })\r\n }\r\n\r\n this._overrides = next\r\n this.onChanged.trigger()\r\n void this.reapply()\r\n }\r\n\r\n private restore(overrides: AppearanceOverride[]): Promise<void> {\r\n this._overrides = overrides\r\n this.onChanged.trigger()\r\n return this.reapply()\r\n }\r\n\r\n private scheduleReapply = (): void => {\r\n if (this._disposed) return\r\n if (this._reapplyTimeout !== null) clearTimeout(this._reapplyTimeout)\r\n this._reapplyTimeout = setTimeout(() => {\r\n this._reapplyTimeout = null\r\n void this.reapply()\r\n }, REAPPLY_DEBOUNCE_MS)\r\n }\r\n\r\n /**\r\n * Forgetting a removed model's painted ids keeps the next pass from resetting\r\n * highlights on a model that is gone. The overrides themselves are kept, so\r\n * reloading the same file brings its colours back.\r\n */\r\n private onModelRemoved = (modelId: string): void => {\r\n this._touched.delete(modelId)\r\n }\r\n\r\n /**\r\n * Repaints every override from scratch.\r\n *\r\n * Passes run one at a time, and at most one waits behind the running pass: a\r\n * pass reads the override list when it starts, so a queue of them would repaint\r\n * the same final state over and over. Dragging the opacity slider asks for a\r\n * repaint on every tick, and each one resets and re-highlights across the\r\n * model.\r\n */\r\n reapply(): Promise<void> {\r\n if (this._applyQueued) return this._applying\r\n\r\n this._applyQueued = true\r\n this._applying = this._applying.then(() => {\r\n this._applyQueued = false\r\n return this.applyPass()\r\n })\r\n return this._applying\r\n }\r\n\r\n /**\r\n * Recomputes the whole appearance rather than patching it: a removed override\r\n * has to un-paint elements that an incremental path would leave coloured.\r\n */\r\n private async applyPass(): Promise<void> {\r\n if (this._disposed) return\r\n\r\n let fragments: OBC.FragmentsManager\r\n try {\r\n fragments = this.components.get(OBC.FragmentsManager)\r\n } catch {\r\n // Nothing loaded yet; the tree events will bring us back.\r\n return\r\n }\r\n\r\n const resolved = resolveAppearance(this._overrides, this.nodesBySource())\r\n const buckets = bucketByAppearance(resolved)\r\n const nextTouched = touchedIdsByModel(resolved)\r\n\r\n // Scoped resets only. `resetHighlight()` with no ids wipes every highlight in\r\n // the model, which would take the floorplan tool's work with it.\r\n for (const [modelId, localIds] of this._touched) {\r\n const model = fragments.list.get(modelId)\r\n if (!model || localIds.length === 0) continue\r\n await safeRunAsync(() => model.resetHighlight(localIds), 'appearanceReset')\r\n }\r\n this._touched = nextTouched\r\n\r\n for (const bucket of buckets) {\r\n const model = fragments.list.get(bucket.modelId)\r\n if (!model || bucket.localIds.length === 0) continue\r\n await safeRunAsync(\r\n () => model.highlight(bucket.localIds, materialFor(bucket.appearance)),\r\n 'appearanceHighlight',\r\n )\r\n }\r\n\r\n // Highlighting only queues tile work; nothing renders until the core updates.\r\n await safeRunAsync(() => fragments.core.update(true), 'appearanceUpdate')\r\n }\r\n\r\n private nodesBySource(): Record<AppearanceSource, BimTreeNode[]> {\r\n return {\r\n 'spatial': this.components.get(SpatialStructure).trees,\r\n 'ifc-class': this.components.get(IfcClasses).classes,\r\n }\r\n }\r\n\r\n dispose(): void {\r\n this._disposed = true\r\n if (this._reapplyTimeout !== null) {\r\n clearTimeout(this._reapplyTimeout)\r\n this._reapplyTimeout = null\r\n }\r\n\r\n try {\r\n this.components.get(SpatialStructure).onSpatialStructureCreated.remove(this.scheduleReapply)\r\n this.components.get(IfcClasses).onClassesChanged.remove(this.scheduleReapply)\r\n this.components.get(ViewModeCoordinator).onReleased.remove(this.scheduleReapply)\r\n this.components.get(OBC.FragmentsManager).list.onItemDeleted.remove(this.onModelRemoved)\r\n } catch {\r\n // Components are disposed in order; anything already gone has taken its\r\n // listeners with it.\r\n }\r\n\r\n this._overrides = []\r\n this.history.clear()\r\n this._touched.clear()\r\n this.onChanged.reset()\r\n this.onDisposed.trigger(ElementAppearance.uuid)\r\n this.onDisposed.reset()\r\n }\r\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AA,IACzB;AAEA,QAAI;AACF,WAAK,WAAW,IAAI,gBAAgB,EAAE,0BAA0B,OAAO,KAAK,eAAe;AAC3F,WAAK,WAAW,IAAI,UAAU,EAAE,iBAAiB,OAAO,KAAK,eAAe;AAC5E,WAAK,WAAW,IAAI,mBAAmB,EAAE,WAAW,OAAO,KAAK,eAAe;AAC/E,WAAK,WAAW,IAAI,IAAI,gBAAgB,EAAE,KAAK,cAAc,OAAO,KAAK,cAAc;AAAA,IACzF,SAAQ;AAAA,IAGR;AAEA,SAAK,aAAa,CAAC;AACnB,SAAK,QAAQ,MAAM;AACnB,SAAK,SAAS,MAAM;AACpB,SAAK,UAAU,MAAM;AACrB,SAAK,WAAW,QAAQ,mBAAkB,IAAI;AAC9C,SAAK,WAAW,MAAM;AAAA,EACxB;AACF;AA/Qa,mBACK,OAAO;AADlB,IAAM,oBAAN;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/bim/src/ElementAppearance.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as OBC from '@thatopen/components'\r\nimport * as THREE from 'three'\r\n\r\nimport { createUndoHistory } from '../../../../utils/undoHistory'\r\n\r\nimport { IfcClasses } from './IfcClasses'\r\nimport {\r\n bucketByAppearance,\r\n clearSourceOverrides,\r\n findOverride,\r\n removeOverride,\r\n resolveAppearance,\r\n touchedIdsByModel,\r\n upsertOverride,\r\n type AppearanceOverride,\r\n type AppearanceSource,\r\n type ElementAppearanceGroup,\r\n type ElementAppearanceOverrides,\r\n type NodeAppearance,\r\n type ResolvedAppearance,\r\n} from './lib/appearanceOverrides'\r\nimport { safeRunAsync } from './lib/safeRun'\r\nimport { ViewModeCoordinator } from './lib/ViewModeCoordinator'\r\nimport { SpatialStructure } from './SpatialStructure'\r\n\r\nimport type { BimTreeNode } from './lib/bimTree'\r\nimport type { UndoHistory } from '../../../../utils/undoHistory'\r\nimport type * as FRAGS from '@thatopen/fragments'\r\n\r\n/** Trees rebuild in bursts as models load, so coalesce the repaints. */\r\nconst REAPPLY_DEBOUNCE_MS = 150\r\n\r\n/**\r\n * Turns one resolved appearance into a Fragments material definition.\r\n *\r\n * Only the keys the override actually sets are present. Fragments merges the\r\n * definition over the element's own material with `Object.assign`, so omitting\r\n * `color` keeps each element's colour (what an opacity-only override needs) and\r\n * omitting `opacity` leaves it opaque. `renderedFaces` is left out on purpose:\r\n * pinning it the way the floorplan highlighter does would force\r\n * `THREE.DoubleSide` onto everything this paints.\r\n *\r\n * `preserveOriginalMaterial` must stay `false`. Fragments skips content\r\n * deduplication for definitions that set it, and the definition list is\r\n * append-only behind a `Uint16` index — so the granular `setColor`/`setOpacity`\r\n * helpers, which set it to `true`, spend one slot per element per call and\r\n * exhaust the model's ~65 500 slots. At `false` an appearance costs one slot\r\n * however many elements wear it.\r\n *\r\n * The published `MaterialDefinition` marks colour, opacity, transparent and\r\n * renderedFaces required, so a partial needs the cast. Verified against\r\n * @thatopen/fragments 3.4.5, whose merge only copies the keys present here.\r\n */\r\nfunction materialFor(appearance: NodeAppearance): FRAGS.MaterialDefinition {\r\n const definition: Partial<FRAGS.MaterialDefinition> = {\r\n preserveOriginalMaterial: false,\r\n }\r\n\r\n if (appearance.color !== undefined) {\r\n definition.color = new THREE.Color(appearance.color)\r\n }\r\n if (appearance.opacity !== undefined) {\r\n definition.opacity = appearance.opacity\r\n definition.transparent = appearance.opacity < 1\r\n }\r\n\r\n return definition as FRAGS.MaterialDefinition\r\n}\r\n\r\n/**\r\n * Session-scoped colour and opacity overrides for the Layers tab's two\r\n * classifier trees, with a shared undo stack.\r\n *\r\n * A component rather than React state for two reasons: the sidebar unmounts the\r\n * tab you are not looking at, and CTRL+Z has to work from anywhere in the\r\n * viewer. Panels read and write through it and re-render off {@link onChanged},\r\n * the same way visibility is routed through `lib/bimItemActions` and announced by\r\n * `VisibilityState`.\r\n *\r\n * Overrides are deliberately not persisted. They are also not preserved across\r\n * floorplan and elevation modes — those repaint the whole model — so this\r\n * reapplies itself whenever the viewer returns to 3D, and whenever the trees\r\n * rebuild, which is what lets a newly loaded model pick up an existing IFC class\r\n * colour.\r\n */\r\nexport class ElementAppearance extends OBC.Component implements OBC.Disposable {\r\n static readonly uuid = 'd2a5f108-9c47-4b36-8e91-5f7a0c3e64d2' as const\r\n\r\n enabled = true\r\n\r\n readonly onChanged = new OBC.Event<void>()\r\n /** Required for `dispose()` to run: OBC checks for `dispose` + `onDisposed`. */\r\n readonly onDisposed = new OBC.Event<string>()\r\n\r\n /**\r\n * Undo/redo steps for colour and opacity only. Visibility, selection and\r\n * camera are deliberately out: they have their own affordances, and folding\r\n * them in would make CTRL+Z unpredictable.\r\n */\r\n readonly history: UndoHistory = createUndoHistory()\r\n\r\n private _overrides: AppearanceOverride[] = []\r\n /** Per-element paint by owner, a plugin id. Outside {@link history}: CTRL+Z is the user's. */\r\n private _elementOverrides: ElementAppearanceOverrides = new Map()\r\n private _seq = 0\r\n /**\r\n * Group the last change belonged to, so a slider drag is one undo step rather\r\n * than one per tick. Cleared by any change outside the group.\r\n */\r\n private _coalescingKey: string | null = null\r\n /** What the last pass painted, so the next one can un-paint exactly that. */\r\n private _touched = new Map<string, number[]>()\r\n /** Serialises passes: the resets of one must not interleave with another's. */\r\n private _applying: Promise<void> = Promise.resolve()\r\n /** Whether a pass is already waiting, so repeat requests collapse into it. */\r\n private _applyQueued = false\r\n private _reapplyTimeout: ReturnType<typeof setTimeout> | null = null\r\n private _disposed = false\r\n\r\n constructor(components: OBC.Components) {\r\n super(components)\r\n components.add(ElementAppearance.uuid, this)\r\n\r\n components.get(SpatialStructure).onSpatialStructureCreated.add(this.scheduleReapply)\r\n components.get(IfcClasses).onClassesChanged.add(this.scheduleReapply)\r\n // Leaving a drawing view resets every highlight in the model, ours included.\r\n components.get(ViewModeCoordinator).onReleased.add(this.scheduleReapply)\r\n\r\n const fragments = components.get(OBC.FragmentsManager)\r\n fragments.list.onItemDeleted.add(this.onModelRemoved)\r\n }\r\n\r\n get overrides(): readonly AppearanceOverride[] {\r\n return this._overrides\r\n }\r\n\r\n /** The override on one node, if it has one. */\r\n overrideFor(source: AppearanceSource, nodeId: string): NodeAppearance | undefined {\r\n const found = findOverride(this._overrides, source, nodeId)\r\n if (!found) return undefined\r\n return { color: found.color, opacity: found.opacity }\r\n }\r\n\r\n /** Whether one tree has anything to reset. */\r\n hasOverrides(source: AppearanceSource): boolean {\r\n return this._overrides.some(o => o.source === source)\r\n }\r\n\r\n /**\r\n * Sets a colour, an opacity, or both on one node. Merges into whatever that\r\n * node already carries, so picking a colour does not discard its opacity.\r\n *\r\n * `coalesceKey` folds a run of changes into a single undo step. Dragging the\r\n * opacity slider fires on every tick, and eighteen presses of CTRL+Z to get\r\n * back across one drag is not undo, it is a punishment. Pass a key that is\r\n * stable for the drag and different from anything else; the group ends as soon\r\n * as a change with another key arrives, or when {@link endCoalescing} is called.\r\n */\r\n setNodeAppearance(\r\n source: AppearanceSource,\r\n nodeId: string,\r\n change: NodeAppearance,\r\n coalesceKey?: string,\r\n ): void {\r\n if (change.color === undefined && change.opacity === undefined) return\r\n this.commit(\r\n upsertOverride(this._overrides, source, nodeId, change, this._seq++),\r\n change.color !== undefined ? 'Change colour' : 'Change opacity',\r\n coalesceKey,\r\n )\r\n }\r\n\r\n /** Closes the current coalescing group, e.g. when a slider is released. */\r\n endCoalescing(): void {\r\n this._coalescingKey = null\r\n }\r\n\r\n /**\r\n * Paints elements for one owner, replacing that owner's previous paint. Every group in one\r\n * call: an owner holds one entry, so calling this per group leaves only the last.\r\n */\r\n setElementAppearance(owner: string, groups: readonly ElementAppearanceGroup[]): void {\r\n const perOwner: ResolvedAppearance = new Map()\r\n\r\n for (const { items, appearance } of groups) {\r\n if (appearance.color === undefined && appearance.opacity === undefined) continue\r\n\r\n for (const [modelId, localIds] of Object.entries(items)) {\r\n // Spread, not `.length`: `ModelIdMap` holds Sets, so a length test is always false.\r\n const ids = [...localIds]\r\n if (ids.length === 0) continue\r\n\r\n let perModel = perOwner.get(modelId)\r\n if (!perModel) {\r\n perModel = new Map()\r\n perOwner.set(modelId, perModel)\r\n }\r\n for (const localId of ids) perModel.set(localId, appearance)\r\n }\r\n }\r\n\r\n if (perOwner.size === 0) {\r\n this.clearElementAppearance(owner)\r\n return\r\n }\r\n\r\n this._elementOverrides.set(owner, perOwner)\r\n this.onChanged.trigger()\r\n void this.reapply()\r\n }\r\n\r\n /** Drops one owner's paint, leaving every other owner's and both trees' alone. */\r\n clearElementAppearance(owner: string): void {\r\n if (!this._elementOverrides.delete(owner)) return\r\n this.onChanged.trigger()\r\n void this.reapply()\r\n }\r\n\r\n /** Drops one node's override, giving its elements back to whatever they inherit. */\r\n clearNode(source: AppearanceSource, nodeId: string): void {\r\n if (!findOverride(this._overrides, source, nodeId)) return\r\n this.commit(removeOverride(this._overrides, source, nodeId), 'Reset element appearance')\r\n }\r\n\r\n /** Resets one tree to default colours, leaving the other tree's work alone. */\r\n clearSource(source: AppearanceSource): void {\r\n if (!this.hasOverrides(source)) return\r\n this.commit(clearSourceOverrides(this._overrides, source), 'Reset colours')\r\n }\r\n\r\n /**\r\n * Steps back one colour or opacity change. Resolves false when there is\r\n * nothing to undo.\r\n *\r\n * Thin on purpose — {@link history} is the real thing, so a keyboard hook or a\r\n * toolbar button can drive it directly.\r\n */\r\n undo(): Promise<boolean> {\r\n this._coalescingKey = null\r\n return this.history.undo()\r\n }\r\n\r\n /** Re-applies the change that was just undone. */\r\n redo(): Promise<boolean> {\r\n this._coalescingKey = null\r\n return this.history.redo()\r\n }\r\n\r\n /**\r\n * Applies a new override list and records how to move between it and the old\r\n * one.\r\n *\r\n * Both directions close over a list rather than diffing: the list is a handful\r\n * of small plain objects, and replaying either way is the same code path as any\r\n * other change.\r\n */\r\n private commit(\r\n next: AppearanceOverride[],\r\n label: string,\r\n coalesceKey?: string,\r\n ): void {\r\n const continuesGroup = coalesceKey !== undefined && coalesceKey === this._coalescingKey\r\n this._coalescingKey = coalesceKey ?? null\r\n\r\n if (continuesGroup) {\r\n // The step on the stack already restores the state from before the group\r\n // started, which is where one undo should land. Only its forward target\r\n // moves, so redo lands where the drag finished rather than on its first tick.\r\n this.history.amendTop({ redo: () => this.restore(next) })\r\n } else {\r\n const previous = this._overrides\r\n this.history.push({\r\n label,\r\n undo: () => this.restore(previous),\r\n redo: () => this.restore(next),\r\n })\r\n }\r\n\r\n this._overrides = next\r\n this.onChanged.trigger()\r\n void this.reapply()\r\n }\r\n\r\n private restore(overrides: AppearanceOverride[]): Promise<void> {\r\n this._overrides = overrides\r\n this.onChanged.trigger()\r\n return this.reapply()\r\n }\r\n\r\n private scheduleReapply = (): void => {\r\n if (this._disposed) return\r\n if (this._reapplyTimeout !== null) clearTimeout(this._reapplyTimeout)\r\n this._reapplyTimeout = setTimeout(() => {\r\n this._reapplyTimeout = null\r\n void this.reapply()\r\n }, REAPPLY_DEBOUNCE_MS)\r\n }\r\n\r\n /**\r\n * Forgetting a removed model's painted ids keeps the next pass from resetting\r\n * highlights on a model that is gone. The overrides themselves are kept, so\r\n * reloading the same file brings its colours back.\r\n */\r\n private onModelRemoved = (modelId: string): void => {\r\n this._touched.delete(modelId)\r\n }\r\n\r\n /**\r\n * Repaints every override from scratch.\r\n *\r\n * Passes run one at a time, and at most one waits behind the running pass: a\r\n * pass reads the override list when it starts, so a queue of them would repaint\r\n * the same final state over and over. Dragging the opacity slider asks for a\r\n * repaint on every tick, and each one resets and re-highlights across the\r\n * model.\r\n */\r\n reapply(): Promise<void> {\r\n if (this._applyQueued) return this._applying\r\n\r\n this._applyQueued = true\r\n this._applying = this._applying.then(() => {\r\n this._applyQueued = false\r\n return this.applyPass()\r\n })\r\n return this._applying\r\n }\r\n\r\n /**\r\n * Recomputes the whole appearance rather than patching it: a removed override\r\n * has to un-paint elements that an incremental path would leave coloured.\r\n */\r\n private async applyPass(): Promise<void> {\r\n if (this._disposed) return\r\n\r\n let fragments: OBC.FragmentsManager\r\n try {\r\n fragments = this.components.get(OBC.FragmentsManager)\r\n } catch {\r\n // Nothing loaded yet; the tree events will bring us back.\r\n return\r\n }\r\n\r\n const resolved = resolveAppearance(this._overrides, this.nodesBySource(), this._elementOverrides)\r\n const buckets = bucketByAppearance(resolved)\r\n const nextTouched = touchedIdsByModel(resolved)\r\n\r\n // Scoped resets only. `resetHighlight()` with no ids wipes every highlight in\r\n // the model, which would take the floorplan tool's work with it.\r\n for (const [modelId, localIds] of this._touched) {\r\n const model = fragments.list.get(modelId)\r\n if (!model || localIds.length === 0) continue\r\n await safeRunAsync(() => model.resetHighlight(localIds), 'appearanceReset')\r\n }\r\n this._touched = nextTouched\r\n\r\n for (const bucket of buckets) {\r\n const model = fragments.list.get(bucket.modelId)\r\n if (!model || bucket.localIds.length === 0) continue\r\n await safeRunAsync(\r\n () => model.highlight(bucket.localIds, materialFor(bucket.appearance)),\r\n 'appearanceHighlight',\r\n )\r\n }\r\n\r\n // Highlighting only queues tile work; nothing renders until the core updates.\r\n await safeRunAsync(() => fragments.core.update(true), 'appearanceUpdate')\r\n }\r\n\r\n private nodesBySource(): Record<AppearanceSource, BimTreeNode[]> {\r\n return {\r\n 'spatial': this.components.get(SpatialStructure).trees,\r\n 'ifc-class': this.components.get(IfcClasses).classes,\r\n }\r\n }\r\n\r\n dispose(): void {\r\n this._disposed = true\r\n if (this._reapplyTimeout !== null) {\r\n clearTimeout(this._reapplyTimeout)\r\n this._reapplyTimeout = null\r\n }\r\n\r\n try {\r\n this.components.get(SpatialStructure).onSpatialStructureCreated.remove(this.scheduleReapply)\r\n this.components.get(IfcClasses).onClassesChanged.remove(this.scheduleReapply)\r\n this.components.get(ViewModeCoordinator).onReleased.remove(this.scheduleReapply)\r\n this.components.get(OBC.FragmentsManager).list.onItemDeleted.remove(this.onModelRemoved)\r\n } catch {\r\n // Components are disposed in order; anything already gone has taken its\r\n // listeners with it.\r\n }\r\n\r\n this._overrides = []\r\n this.history.clear()\r\n this._touched.clear()\r\n this.onChanged.reset()\r\n this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KAAK,cAAc;AAAA,IACzF,SAAQ;AAAA,IAGR;AAEA,SAAK,aAAa,CAAC;AACnB,SAAK,QAAQ,MAAM;AACnB,SAAK,SAAS,MAAM;AACpB,SAAK,UAAU,MAAM;AACrB,SAAK,WAAW,QAAQ,mBAAkB,IAAI;AAC9C,SAAK,WAAW,MAAM;AAAA,EACxB;AACF;AA1Ta,mBACK,OAAO;AADlB,IAAM,oBAAN;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsSync.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/bim/src/ModelsSync.tsx"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"ModelsSync.d.ts","sourceRoot":"","sources":["../../../../../../src/core/components/viewers/bim/src/ModelsSync.tsx"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,QAsCzB"}
|
|
@@ -13,18 +13,19 @@ function ModelsSync() {
|
|
|
13
13
|
} catch (e) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
+
const list = fragments.list;
|
|
16
17
|
const publish = () => {
|
|
17
18
|
dispatch({
|
|
18
19
|
type: "SET_MODEL_IDS",
|
|
19
|
-
payload: { modelIds: [...
|
|
20
|
+
payload: { modelIds: [...list.keys()] }
|
|
20
21
|
});
|
|
21
22
|
};
|
|
22
23
|
publish();
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
list.onItemSet.add(publish);
|
|
25
|
+
list.onItemDeleted.add(publish);
|
|
25
26
|
return () => {
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
list.onItemSet.remove(publish);
|
|
28
|
+
list.onItemDeleted.remove(publish);
|
|
28
29
|
};
|
|
29
30
|
}, [bimComponents, dispatch]);
|
|
30
31
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/core/components/viewers/bim/src/ModelsSync.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as OBC from '@thatopen/components'\r\nimport * as React from 'react'\r\n\r\nimport { BimContext } from '../../../../store/BIM/context'\r\n\r\n/**\r\n * Mirrors the loaded models into `BimState.modelIds`.\r\n *\r\n * `modelIds` existed on the store from the start but nothing ever wrote to it, so\r\n * it was permanently `[]` — anything deriving from it concluded no model was\r\n * loaded even with one on screen. `FragmentsManager.list` is the truth; this\r\n * publishes it.\r\n *\r\n * One central subscription, the same shape as `SelectionSync` and\r\n * `ShadowEnroller`, so every load path is covered rather than each caller wiring\r\n * its own listener. `IfcClasses` already subscribes to the\r\n * same two events to rebuild its class tree.\r\n *\r\n * Renders nothing. Mount it once inside the BIM viewer.\r\n */\r\nexport function ModelsSync() {\r\n const { state, dispatch } = React.useContext(BimContext)\r\n const { bimComponents } = state.bim\r\n\r\n React.useEffect(() => {\r\n if (!bimComponents) return\r\n\r\n let fragments: OBC.FragmentsManager\r\n try {\r\n fragments = bimComponents.get(OBC.FragmentsManager)\r\n } catch {\r\n return\r\n }\r\n\r\n const publish = () => {\r\n dispatch({\r\n type: 'SET_MODEL_IDS',\r\n payload: { modelIds: [...
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/core/components/viewers/bim/src/ModelsSync.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as OBC from '@thatopen/components'\r\nimport * as React from 'react'\r\n\r\nimport { BimContext } from '../../../../store/BIM/context'\r\n\r\n/**\r\n * Mirrors the loaded models into `BimState.modelIds`.\r\n *\r\n * `modelIds` existed on the store from the start but nothing ever wrote to it, so\r\n * it was permanently `[]` — anything deriving from it concluded no model was\r\n * loaded even with one on screen. `FragmentsManager.list` is the truth; this\r\n * publishes it.\r\n *\r\n * One central subscription, the same shape as `SelectionSync` and\r\n * `ShadowEnroller`, so every load path is covered rather than each caller wiring\r\n * its own listener. `IfcClasses` already subscribes to the\r\n * same two events to rebuild its class tree.\r\n *\r\n * Renders nothing. Mount it once inside the BIM viewer.\r\n */\r\nexport function ModelsSync() {\r\n const { state, dispatch } = React.useContext(BimContext)\r\n const { bimComponents } = state.bim\r\n\r\n React.useEffect(() => {\r\n if (!bimComponents) return\r\n\r\n let fragments: OBC.FragmentsManager\r\n try {\r\n fragments = bimComponents.get(OBC.FragmentsManager)\r\n } catch {\r\n return\r\n }\r\n\r\n // Held from setup: `list` throws once the manager is disposed, which happens first.\r\n const list = fragments.list\r\n\r\n const publish = () => {\r\n dispatch({\r\n type: 'SET_MODEL_IDS',\r\n payload: { modelIds: [...list.keys()] },\r\n })\r\n }\r\n\r\n // Publish once on mount: a model may already be loaded by the time this\r\n // subscribes, which is the common case when switching back to the viewer.\r\n publish()\r\n\r\n list.onItemSet.add(publish)\r\n list.onItemDeleted.add(publish)\r\n\r\n return () => {\r\n list.onItemSet.remove(publish)\r\n list.onItemDeleted.remove(publish)\r\n }\r\n }, [bimComponents, dispatch])\r\n\r\n return null\r\n}\r\n"],"mappings":";AAKA,YAAY,SAAS;AACrB,YAAY,WAAW;AAEvB,SAAS,kBAAkB;AAiBpB,SAAS,aAAa;AAC3B,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,WAAW,UAAU;AACvD,QAAM,EAAE,cAAc,IAAI,MAAM;AAEhC,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,cAAe;AAEpB,QAAI;AACJ,QAAI;AACF,kBAAY,cAAc,IAAI,IAAI,gBAAgB;AAAA,IACpD,SAAQ;AACN;AAAA,IACF;AAGA,UAAM,OAAO,UAAU;AAEvB,UAAM,UAAU,MAAM;AACpB,eAAS;AAAA,QACP,MAAM;AAAA,QACN,SAAS,EAAE,UAAU,CAAC,GAAG,KAAK,KAAK,CAAC,EAAE;AAAA,MACxC,CAAC;AAAA,IACH;AAIA,YAAQ;AAER,SAAK,UAAU,IAAI,OAAO;AAC1B,SAAK,cAAc,IAAI,OAAO;AAE9B,WAAO,MAAM;AACX,WAAK,UAAU,OAAO,OAAO;AAC7B,WAAK,cAAc,OAAO,OAAO;AAAA,IACnC;AAAA,EACF,GAAG,CAAC,eAAe,QAAQ,CAAC;AAE5B,SAAO;AACT;","names":[]}
|
|
@@ -20,6 +20,17 @@ export interface AppearanceOverride extends NodeAppearance {
|
|
|
20
20
|
}
|
|
21
21
|
/** `modelId` → `localId` → the appearance that element ends up with. */
|
|
22
22
|
export type ResolvedAppearance = Map<string, Map<number, NodeAppearance>>;
|
|
23
|
+
/**
|
|
24
|
+
* Appearances addressed by element rather than tree node, keyed by owner so two plugins
|
|
25
|
+
* painting the same model cannot clobber each other.
|
|
26
|
+
*/
|
|
27
|
+
export type ElementAppearanceOverrides = Map<string, ResolvedAppearance>;
|
|
28
|
+
/** One appearance and the elements wearing it. Several of these make up one owner's paint. */
|
|
29
|
+
export interface ElementAppearanceGroup {
|
|
30
|
+
/** `modelId` → local ids. Sets in practice, since that is what `ModelIdMap` holds. */
|
|
31
|
+
items: Record<string, Iterable<number>>;
|
|
32
|
+
appearance: NodeAppearance;
|
|
33
|
+
}
|
|
23
34
|
/** One `model.highlight()` call's worth of work. */
|
|
24
35
|
export interface AppearanceBucket {
|
|
25
36
|
modelId: string;
|
|
@@ -47,7 +58,7 @@ export interface AppearanceBucket {
|
|
|
47
58
|
* Overrides naming a node that is no longer in the tree (its model was unloaded)
|
|
48
59
|
* are skipped rather than dropped — reloading the file brings them back.
|
|
49
60
|
*/
|
|
50
|
-
export declare function resolveAppearance(overrides: readonly AppearanceOverride[], nodesBySource: Record<AppearanceSource, BimTreeNode[]
|
|
61
|
+
export declare function resolveAppearance(overrides: readonly AppearanceOverride[], nodesBySource: Record<AppearanceSource, BimTreeNode[]>, elementOverrides?: ElementAppearanceOverrides): ResolvedAppearance;
|
|
51
62
|
/**
|
|
52
63
|
* Groups elements by identical appearance, one bucket per `model.highlight()`
|
|
53
64
|
* call.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearanceOverrides.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/bim/src/lib/appearanceOverrides.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AAE1D,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,CAAA;AAEtD,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,MAAM,EAAE,gBAAgB,CAAA;IACxB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,wEAAwE;AACxE,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;AAEzE,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,UAAU,EAAE,cAAc,CAAA;CAC3B;AAiBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,kBAAkB,EAAE,EACxC,aAAa,EAAE,MAAM,CAAC,gBAAgB,EAAE,WAAW,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"appearanceOverrides.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/bim/src/lib/appearanceOverrides.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AAE1D,oDAAoD;AACpD,MAAM,MAA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AiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAOrF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,SAAS,kBAAkB,EAAE,EACxC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,MAAM,GACV,kBAAkB,EAAE,CAUtB;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,SAAS,kBAAkB,EAAE,EACxC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,GACb,kBAAkB,EAAE,CAEtB;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,kBAAkB,EAAE,EACxC,MAAM,EAAE,gBAAgB,GACvB,kBAAkB,EAAE,CAEtB;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,SAAS,kBAAkB,EAAE,EACxC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,GACb,kBAAkB,GAAG,SAAS,CAEhC"}
|
|
@@ -27,14 +27,14 @@ function indexNodes(roots) {
|
|
|
27
27
|
for (const root of roots) visit(root, 0);
|
|
28
28
|
return index;
|
|
29
29
|
}
|
|
30
|
-
function resolveAppearance(overrides, nodesBySource) {
|
|
30
|
+
function resolveAppearance(overrides, nodesBySource, elementOverrides) {
|
|
31
31
|
var _a;
|
|
32
32
|
const indexes = {
|
|
33
33
|
"spatial": indexNodes(nodesBySource.spatial),
|
|
34
34
|
"ifc-class": indexNodes(nodesBySource["ifc-class"])
|
|
35
35
|
};
|
|
36
36
|
const live = overrides.filter((o) => indexes[o.source].has(o.nodeId));
|
|
37
|
-
if (live.length === 0) return /* @__PURE__ */ new Map();
|
|
37
|
+
if (live.length === 0) return applyElementOverrides(/* @__PURE__ */ new Map(), elementOverrides);
|
|
38
38
|
const lastSeq = /* @__PURE__ */ new Map();
|
|
39
39
|
for (const o of live) {
|
|
40
40
|
lastSeq.set(o.source, Math.max((_a = lastSeq.get(o.source)) != null ? _a : -1, o.seq));
|
|
@@ -64,6 +64,22 @@ function resolveAppearance(overrides, nodesBySource) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
return applyElementOverrides(resolved, elementOverrides);
|
|
68
|
+
}
|
|
69
|
+
function applyElementOverrides(resolved, elementOverrides) {
|
|
70
|
+
if (!elementOverrides || elementOverrides.size === 0) return resolved;
|
|
71
|
+
for (const perOwner of elementOverrides.values()) {
|
|
72
|
+
for (const [modelId, perModel] of perOwner) {
|
|
73
|
+
let target = resolved.get(modelId);
|
|
74
|
+
if (!target) {
|
|
75
|
+
target = /* @__PURE__ */ new Map();
|
|
76
|
+
resolved.set(modelId, target);
|
|
77
|
+
}
|
|
78
|
+
for (const [localId, appearance] of perModel) {
|
|
79
|
+
target.set(localId, __spreadValues(__spreadValues({}, target.get(localId)), appearance));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
67
83
|
return resolved;
|
|
68
84
|
}
|
|
69
85
|
function bucketByAppearance(resolved) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/bim/src/lib/appearanceOverrides.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { subtreeItems, type BimTreeNode } from './bimTree'\r\n\r\n/** Which sidebar tree an override was made from. */\r\nexport type AppearanceSource = 'spatial' | 'ifc-class'\r\n\r\n/** A colour and/or opacity override. Either half may be absent. */\r\nexport interface NodeAppearance {\r\n /** `0xRRGGBB`. Absent means \"keep the element's own colour\". */\r\n color?: number\r\n /** `0`-`1`. Absent means \"keep the element fully opaque\". */\r\n opacity?: number\r\n}\r\n\r\nexport interface AppearanceOverride extends NodeAppearance {\r\n source: AppearanceSource\r\n /** `BimTreeNode.id`, stable across tree rebuilds and search filtering. */\r\n nodeId: string\r\n /**\r\n * Monotonic write counter. Orders the two trees against each other and breaks\r\n * depth ties within one; see {@link resolveAppearance}.\r\n */\r\n seq: number\r\n}\r\n\r\n/** `modelId` → `localId` → the appearance that element ends up with. */\r\nexport type ResolvedAppearance = Map<string, Map<number, NodeAppearance>>\r\n\r\n/** One `model.highlight()` call's worth of work. */\r\nexport interface AppearanceBucket {\r\n modelId: string\r\n localIds: number[]\r\n appearance: NodeAppearance\r\n}\r\n\r\ninterface IndexedNode {\r\n node: BimTreeNode\r\n depth: number\r\n}\r\n\r\nfunction indexNodes(roots: BimTreeNode[]): Map<string, IndexedNode> {\r\n const index = new Map<string, IndexedNode>()\r\n const visit = (node: BimTreeNode, depth: number): void => {\r\n index.set(node.id, { node, depth })\r\n for (const child of node.children) visit(child, depth + 1)\r\n }\r\n for (const root of roots) visit(root, 0)\r\n return index\r\n}\r\n\r\n/**\r\n * Flattens the overrides of both trees into a per-element appearance map.\r\n *\r\n * Two ordering rules meet here, and they want different things:\r\n *\r\n * - **Within one tree**, a node's override cascades to its whole subtree, but a\r\n * descendant that carries its own override keeps it. So the spatial tree is\r\n * replayed shallowest-first and later writes win — colouring a storey tints\r\n * everything in it, and the one wall you coloured separately stays as it was,\r\n * whichever order the two were set in.\r\n * - **Between the trees**, there is no containment to appeal to: `IFCWALL` and a\r\n * storey simply overlap. Recency decides, so the tree the user touched most\r\n * recently wins the overlap, and undoing that hands the elements back.\r\n *\r\n * Hence the sort: trees ordered by their most recent write, nodes within a tree\r\n * by depth. A half-override merges over what it inherits rather than replacing\r\n * it, so fading a wall inside a red storey leaves the wall red *and* faded.\r\n *\r\n * Overrides naming a node that is no longer in the tree (its model was unloaded)\r\n * are skipped rather than dropped — reloading the file brings them back.\r\n */\r\nexport function resolveAppearance(\r\n overrides: readonly AppearanceOverride[],\r\n nodesBySource: Record<AppearanceSource, BimTreeNode[]>,\r\n): ResolvedAppearance {\r\n const indexes: Record<AppearanceSource, Map<string, IndexedNode>> = {\r\n 'spatial': indexNodes(nodesBySource.spatial),\r\n 'ifc-class': indexNodes(nodesBySource['ifc-class']),\r\n }\r\n\r\n const live = overrides.filter(o => indexes[o.source].has(o.nodeId))\r\n if (live.length === 0) return new Map()\r\n\r\n const lastSeq = new Map<AppearanceSource, number>()\r\n for (const o of live) {\r\n lastSeq.set(o.source, Math.max(lastSeq.get(o.source) ?? -1, o.seq))\r\n }\r\n\r\n const ordered = [...live].sort((a, b) => {\r\n if (a.source !== b.source) {\r\n return (lastSeq.get(a.source) ?? -1) - (lastSeq.get(b.source) ?? -1)\r\n }\r\n const depthDelta =\r\n (indexes[a.source].get(a.nodeId)?.depth ?? 0) -\r\n (indexes[b.source].get(b.nodeId)?.depth ?? 0)\r\n return depthDelta !== 0 ? depthDelta : a.seq - b.seq\r\n })\r\n\r\n const resolved: ResolvedAppearance = new Map()\r\n for (const override of ordered) {\r\n const indexed = indexes[override.source].get(override.nodeId)\r\n if (!indexed) continue\r\n\r\n const items = subtreeItems(indexed.node)\r\n for (const modelId of Object.keys(items)) {\r\n let perModel = resolved.get(modelId)\r\n if (!perModel) {\r\n perModel = new Map()\r\n resolved.set(modelId, perModel)\r\n }\r\n for (const localId of items[modelId]) {\r\n const inherited = perModel.get(localId)\r\n perModel.set(localId, {\r\n ...inherited,\r\n ...(override.color !== undefined && { color: override.color }),\r\n ...(override.opacity !== undefined && { opacity: override.opacity }),\r\n })\r\n }\r\n }\r\n }\r\n\r\n return resolved\r\n}\r\n\r\n/**\r\n * Groups elements by identical appearance, one bucket per `model.highlight()`\r\n * call.\r\n *\r\n * Fragments keeps an append-only list of highlight material definitions indexed\r\n * by a `Uint16`, and only deduplicates definitions by content. Painting per\r\n * element would burn a slot per element out of ~65 500 for the model's lifetime;\r\n * painting per distinct appearance costs one slot each, however many elements\r\n * carry it.\r\n */\r\nexport function bucketByAppearance(resolved: ResolvedAppearance): AppearanceBucket[] {\r\n const buckets = new Map<string, AppearanceBucket>()\r\n\r\n for (const [modelId, perModel] of resolved) {\r\n for (const [localId, appearance] of perModel) {\r\n if (appearance.color === undefined && appearance.opacity === undefined) continue\r\n\r\n const key = `${modelId}|${appearance.color ?? ''}|${appearance.opacity ?? ''}`\r\n const existing = buckets.get(key)\r\n if (existing) {\r\n existing.localIds.push(localId)\r\n } else {\r\n buckets.set(key, { modelId, localIds: [localId], appearance: { ...appearance } })\r\n }\r\n }\r\n }\r\n\r\n return [...buckets.values()]\r\n}\r\n\r\n/** Every element the resolved map paints, per model. Used to scope the reset. */\r\nexport function touchedIdsByModel(resolved: ResolvedAppearance): Map<string, number[]> {\r\n const touched = new Map<string, number[]>()\r\n for (const [modelId, perModel] of resolved) {\r\n const ids = [...perModel.keys()]\r\n if (ids.length > 0) touched.set(modelId, ids)\r\n }\r\n return touched\r\n}\r\n\r\n/**\r\n * Adds or updates the override for one node, merging into any existing record so\r\n * setting a colour does not drop the opacity already on it.\r\n *\r\n * Returns a new list; one record per (source, node), moved to the end so it\r\n * counts as the tree's most recent write.\r\n */\r\nexport function upsertOverride(\r\n overrides: readonly AppearanceOverride[],\r\n source: AppearanceSource,\r\n nodeId: string,\r\n change: NodeAppearance,\r\n seq: number,\r\n): AppearanceOverride[] {\r\n const existing = overrides.find(o => o.source === source && o.nodeId === nodeId)\r\n const next: AppearanceOverride = {\r\n ...existing,\r\n ...change,\r\n source,\r\n nodeId,\r\n seq,\r\n }\r\n return [...overrides.filter(o => o !== existing), next]\r\n}\r\n\r\nexport function removeOverride(\r\n overrides: readonly AppearanceOverride[],\r\n source: AppearanceSource,\r\n nodeId: string,\r\n): AppearanceOverride[] {\r\n return overrides.filter(o => !(o.source === source && o.nodeId === nodeId))\r\n}\r\n\r\nexport function clearSourceOverrides(\r\n overrides: readonly AppearanceOverride[],\r\n source: AppearanceSource,\r\n): AppearanceOverride[] {\r\n return overrides.filter(o => o.source !== source)\r\n}\r\n\r\nexport function findOverride(\r\n overrides: readonly AppearanceOverride[],\r\n source: AppearanceSource,\r\n nodeId: string,\r\n): AppearanceOverride | undefined {\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,EACF;AAEA,SAAO,CAAC,GAAG,QAAQ,OAAO,CAAC;AAC7B;AAGO,SAAS,kBAAkB,UAAqD;AACrF,QAAM,UAAU,oBAAI,IAAsB;AAC1C,aAAW,CAAC,SAAS,QAAQ,KAAK,UAAU;AAC1C,UAAM,MAAM,CAAC,GAAG,SAAS,KAAK,CAAC;AAC/B,QAAI,IAAI,SAAS,EAAG,SAAQ,IAAI,SAAS,GAAG;AAAA,EAC9C;AACA,SAAO;AACT;AASO,SAAS,eACd,WACA,QACA,QACA,QACA,KACsB;AACtB,QAAM,WAAW,UAAU,KAAK,OAAK,EAAE,WAAW,UAAU,EAAE,WAAW,MAAM;AAC/E,QAAM,OAA2B,gDAC5B,WACA,SAF4B;AAAA,IAG/B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,CAAC,GAAG,UAAU,OAAO,OAAK,MAAM,QAAQ,GAAG,IAAI;AACxD;AAEO,SAAS,eACd,WACA,QACA,QACsB;AACtB,SAAO,UAAU,OAAO,OAAK,EAAE,EAAE,WAAW,UAAU,EAAE,WAAW,OAAO;AAC5E;AAEO,SAAS,qBACd,WACA,QACsB;AACtB,SAAO,UAAU,OAAO,OAAK,EAAE,WAAW,MAAM;AAClD;AAEO,SAAS,aACd,WACA,QACA,QACgC;AAChC,SAAO,UAAU,KAAK,OAAK,EAAE,WAAW,UAAU,EAAE,WAAW,MAAM;AACvE;","names":["_a"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/bim/src/lib/appearanceOverrides.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { subtreeItems, type BimTreeNode } from './bimTree'\r\n\r\n/** Which sidebar tree an override was made from. */\r\nexport type AppearanceSource = 'spatial' | 'ifc-class'\r\n\r\n/** A colour and/or opacity override. Either half may be absent. */\r\nexport interface NodeAppearance {\r\n /** `0xRRGGBB`. Absent means \"keep the element's own colour\". */\r\n color?: number\r\n /** `0`-`1`. Absent means \"keep the element fully opaque\". */\r\n opacity?: number\r\n}\r\n\r\nexport interface AppearanceOverride extends NodeAppearance {\r\n source: AppearanceSource\r\n /** `BimTreeNode.id`, stable across tree rebuilds and search filtering. */\r\n nodeId: string\r\n /**\r\n * Monotonic write counter. Orders the two trees against each other and breaks\r\n * depth ties within one; see {@link resolveAppearance}.\r\n */\r\n seq: number\r\n}\r\n\r\n/** `modelId` → `localId` → the appearance that element ends up with. */\r\nexport type ResolvedAppearance = Map<string, Map<number, NodeAppearance>>\r\n\r\n/**\r\n * Appearances addressed by element rather than tree node, keyed by owner so two plugins\r\n * painting the same model cannot clobber each other.\r\n */\r\nexport type ElementAppearanceOverrides = Map<string, ResolvedAppearance>\r\n\r\n/** One appearance and the elements wearing it. Several of these make up one owner's paint. */\r\nexport interface ElementAppearanceGroup {\r\n /** `modelId` → local ids. Sets in practice, since that is what `ModelIdMap` holds. */\r\n items: Record<string, Iterable<number>>\r\n appearance: NodeAppearance\r\n}\r\n\r\n/** One `model.highlight()` call's worth of work. */\r\nexport interface AppearanceBucket {\r\n modelId: string\r\n localIds: number[]\r\n appearance: NodeAppearance\r\n}\r\n\r\ninterface IndexedNode {\r\n node: BimTreeNode\r\n depth: number\r\n}\r\n\r\nfunction indexNodes(roots: BimTreeNode[]): Map<string, IndexedNode> {\r\n const index = new Map<string, IndexedNode>()\r\n const visit = (node: BimTreeNode, depth: number): void => {\r\n index.set(node.id, { node, depth })\r\n for (const child of node.children) visit(child, depth + 1)\r\n }\r\n for (const root of roots) visit(root, 0)\r\n return index\r\n}\r\n\r\n/**\r\n * Flattens the overrides of both trees into a per-element appearance map.\r\n *\r\n * Two ordering rules meet here, and they want different things:\r\n *\r\n * - **Within one tree**, a node's override cascades to its whole subtree, but a\r\n * descendant that carries its own override keeps it. So the spatial tree is\r\n * replayed shallowest-first and later writes win — colouring a storey tints\r\n * everything in it, and the one wall you coloured separately stays as it was,\r\n * whichever order the two were set in.\r\n * - **Between the trees**, there is no containment to appeal to: `IFCWALL` and a\r\n * storey simply overlap. Recency decides, so the tree the user touched most\r\n * recently wins the overlap, and undoing that hands the elements back.\r\n *\r\n * Hence the sort: trees ordered by their most recent write, nodes within a tree\r\n * by depth. A half-override merges over what it inherits rather than replacing\r\n * it, so fading a wall inside a red storey leaves the wall red *and* faded.\r\n *\r\n * Overrides naming a node that is no longer in the tree (its model was unloaded)\r\n * are skipped rather than dropped — reloading the file brings them back.\r\n */\r\nexport function resolveAppearance(\r\n overrides: readonly AppearanceOverride[],\r\n nodesBySource: Record<AppearanceSource, BimTreeNode[]>,\r\n elementOverrides?: ElementAppearanceOverrides,\r\n): ResolvedAppearance {\r\n const indexes: Record<AppearanceSource, Map<string, IndexedNode>> = {\r\n 'spatial': indexNodes(nodesBySource.spatial),\r\n 'ifc-class': indexNodes(nodesBySource['ifc-class']),\r\n }\r\n\r\n const live = overrides.filter(o => indexes[o.source].has(o.nodeId))\r\n // Not an early return: a plugin can be the only thing painting.\r\n if (live.length === 0) return applyElementOverrides(new Map(), elementOverrides)\r\n\r\n const lastSeq = new Map<AppearanceSource, number>()\r\n for (const o of live) {\r\n lastSeq.set(o.source, Math.max(lastSeq.get(o.source) ?? -1, o.seq))\r\n }\r\n\r\n const ordered = [...live].sort((a, b) => {\r\n if (a.source !== b.source) {\r\n return (lastSeq.get(a.source) ?? -1) - (lastSeq.get(b.source) ?? -1)\r\n }\r\n const depthDelta =\r\n (indexes[a.source].get(a.nodeId)?.depth ?? 0) -\r\n (indexes[b.source].get(b.nodeId)?.depth ?? 0)\r\n return depthDelta !== 0 ? depthDelta : a.seq - b.seq\r\n })\r\n\r\n const resolved: ResolvedAppearance = new Map()\r\n for (const override of ordered) {\r\n const indexed = indexes[override.source].get(override.nodeId)\r\n if (!indexed) continue\r\n\r\n const items = subtreeItems(indexed.node)\r\n for (const modelId of Object.keys(items)) {\r\n let perModel = resolved.get(modelId)\r\n if (!perModel) {\r\n perModel = new Map()\r\n resolved.set(modelId, perModel)\r\n }\r\n for (const localId of items[modelId]) {\r\n const inherited = perModel.get(localId)\r\n perModel.set(localId, {\r\n ...inherited,\r\n ...(override.color !== undefined && { color: override.color }),\r\n ...(override.opacity !== undefined && { opacity: override.opacity }),\r\n })\r\n }\r\n }\r\n }\r\n\r\n return applyElementOverrides(resolved, elementOverrides)\r\n}\r\n\r\n/**\r\n * Lays per-element overrides over the tree-resolved result, last, so a plugin's thematic\r\n * paint wins over a tinted storey rather than being quietly repainted by it.\r\n */\r\nfunction applyElementOverrides(\r\n resolved: ResolvedAppearance,\r\n elementOverrides: ElementAppearanceOverrides | undefined,\r\n): ResolvedAppearance {\r\n if (!elementOverrides || elementOverrides.size === 0) return resolved\r\n\r\n for (const perOwner of elementOverrides.values()) {\r\n for (const [modelId, perModel] of perOwner) {\r\n let target = resolved.get(modelId)\r\n if (!target) {\r\n target = new Map()\r\n resolved.set(modelId, target)\r\n }\r\n for (const [localId, appearance] of perModel) {\r\n target.set(localId, { ...target.get(localId), ...appearance })\r\n }\r\n }\r\n }\r\n\r\n return resolved\r\n}\r\n\r\n/**\r\n * Groups elements by identical appearance, one bucket per `model.highlight()`\r\n * call.\r\n *\r\n * Fragments keeps an append-only list of highlight material definitions indexed\r\n * by a `Uint16`, and only deduplicates definitions by content. Painting per\r\n * element would burn a slot per element out of ~65 500 for the model's lifetime;\r\n * painting per distinct appearance costs one slot each, however many elements\r\n * carry it.\r\n */\r\nexport function bucketByAppearance(resolved: ResolvedAppearance): AppearanceBucket[] {\r\n const buckets = new Map<string, AppearanceBucket>()\r\n\r\n for (const [modelId, perModel] of resolved) {\r\n for (const [localId, appearance] of perModel) {\r\n if (appearance.color === undefined && appearance.opacity === undefined) continue\r\n\r\n const key = `${modelId}|${appearance.color ?? ''}|${appearance.opacity ?? ''}`\r\n const existing = buckets.get(key)\r\n if (existing) {\r\n existing.localIds.push(localId)\r\n } else {\r\n buckets.set(key, { modelId, localIds: [localId], appearance: { ...appearance } })\r\n }\r\n }\r\n }\r\n\r\n return [...buckets.values()]\r\n}\r\n\r\n/** Every element the resolved map paints, per model. Used to scope the reset. */\r\nexport function touchedIdsByModel(resolved: ResolvedAppearance): Map<string, number[]> {\r\n const touched = new Map<string, number[]>()\r\n for (const [modelId, perModel] of resolved) {\r\n const ids = [...perModel.keys()]\r\n if (ids.length > 0) touched.set(modelId, ids)\r\n }\r\n return touched\r\n}\r\n\r\n/**\r\n * Adds or updates the override for one node, merging into any existing record so\r\n * setting a colour does not drop the opacity already on it.\r\n *\r\n * Returns a new list; one record per (source, node), moved to the end so it\r\n * counts as the tree's most recent write.\r\n */\r\nexport function upsertOverride(\r\n overrides: readonly AppearanceOverride[],\r\n source: AppearanceSource,\r\n nodeId: string,\r\n change: NodeAppearance,\r\n seq: number,\r\n): AppearanceOverride[] {\r\n const existing = overrides.find(o => o.source === source && o.nodeId === nodeId)\r\n const next: AppearanceOverride = {\r\n ...existing,\r\n ...change,\r\n source,\r\n nodeId,\r\n seq,\r\n }\r\n return [...overrides.filter(o => o !== existing), next]\r\n}\r\n\r\nexport function removeOverride(\r\n overrides: readonly AppearanceOverride[],\r\n source: AppearanceSource,\r\n nodeId: string,\r\n): AppearanceOverride[] {\r\n return overrides.filter(o => !(o.source === source && o.nodeId === nodeId))\r\n}\r\n\r\nexport function clearSourceOverrides(\r\n overrides: readonly AppearanceOverride[],\r\n source: AppearanceSource,\r\n): AppearanceOverride[] {\r\n return overrides.filter(o => o.source !== source)\r\n}\r\n\r\nexport function findOverride(\r\n overrides: readonly AppearanceOverride[],\r\n source: AppearanceSource,\r\n nodeId: string,\r\n): AppearanceOverride | undefined {\r\n return overrides.find(o => o.source === source && o.nodeId === nodeId)\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,SAAS,oBAAsC;AAoD/C,SAAS,WAAW,OAAgD;AAClE,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,QAAM,QAAQ,CAAC,MAAmB,UAAwB;AACxD,UAAM,IAAI,KAAK,IAAI,EAAE,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/core/components/viewers/map/MapViewer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"MapViewer.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/viewers/map/MapViewer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAsBzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAa1D,UAAU,KAAK;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,SAAS,CAAC,EAAE,KAAc,EAAE,MAAe,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,KAAK,qBA6L9F"}
|
|
@@ -4,12 +4,14 @@ import maplibregl from "maplibre-gl";
|
|
|
4
4
|
import { useSearchParams } from "next/navigation";
|
|
5
5
|
import React from "react";
|
|
6
6
|
import Map, { NavigationControl } from "react-map-gl/maplibre";
|
|
7
|
+
import { PluginMapLayerHost } from "../../../plugins/host/PluginMapLayerHost";
|
|
8
|
+
import { ViewerNames } from "../../../types/dbTypes";
|
|
9
|
+
import { ViewerLegendHost } from "../shared/legends/ViewerLegendHost";
|
|
7
10
|
import { MapContext } from "../../../store";
|
|
8
11
|
import { SensorLegend } from "../../ui/Sensors/SensorLegend";
|
|
9
12
|
import SettingsButton from "../../ui/SettingsButton";
|
|
10
13
|
import { StatsOverlay } from "../../ui/stats";
|
|
11
14
|
import DatasetManagerMenu from "./datasets/DatasetManager";
|
|
12
|
-
import { MapLegendHost } from "./legends/MapLegendHost";
|
|
13
15
|
import { MapLayers } from "./src/MapLayers";
|
|
14
16
|
import { MapClickManager } from "./utils/MapEventManager/MapClickManager";
|
|
15
17
|
import { MapHoverManager } from "./utils/MapEventManager/MapHoverManager";
|
|
@@ -149,14 +151,15 @@ function MapViewer({ width = "100%", height = "100%", organization, maptilerKey
|
|
|
149
151
|
/* @__PURE__ */ jsxs("div", { className: "absolute bottom-20 md:bottom-[10px] left-3 z-10 flex max-w-[calc(100vw-1.5rem)] flex-col gap-2 pointer-events-none", children: [
|
|
150
152
|
/* @__PURE__ */ jsx("div", { id: "wms-time-slot", style: { display: "contents" } }),
|
|
151
153
|
/* @__PURE__ */ jsx(SensorLegend, {}),
|
|
152
|
-
/* @__PURE__ */ jsx(
|
|
154
|
+
/* @__PURE__ */ jsx(ViewerLegendHost, { viewer: ViewerNames.map }),
|
|
153
155
|
/* @__PURE__ */ jsx(DatasetManagerMenu, {})
|
|
154
156
|
] })
|
|
155
157
|
] })
|
|
156
158
|
]
|
|
157
159
|
}
|
|
158
160
|
),
|
|
159
|
-
/* @__PURE__ */ jsx(StatsOverlay, { mapRef, enabled: isDebug })
|
|
161
|
+
/* @__PURE__ */ jsx(StatsOverlay, { mapRef, enabled: isDebug }),
|
|
162
|
+
/* @__PURE__ */ jsx(PluginMapLayerHost, {})
|
|
160
163
|
] });
|
|
161
164
|
}
|
|
162
165
|
export {
|