@ifc-lite/viewer 1.6.0 → 1.7.0
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/CHANGELOG.md +78 -0
- package/dist/assets/{Arrow.dom-BjDQoB2M.js → Arrow.dom-BGPQieQQ.js} +1 -1
- package/dist/assets/ifc-lite_bg-DyIN_nBM.wasm +0 -0
- package/dist/assets/{index-YBtrHPu3.js → index-dgdgiQ9p.js} +40212 -30008
- package/dist/assets/index-yTqs8kgX.css +1 -0
- package/dist/assets/{native-bridge-CULtTDX3.js → native-bridge-DD0SNyQ5.js} +1 -1
- package/dist/assets/{wasm-bridge-CjL-lSak.js → wasm-bridge-D54YMO7X.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +18 -15
- package/src/components/viewer/BCFPanel.tsx +7 -789
- package/src/components/viewer/Drawing2DCanvas.tsx +1048 -0
- package/src/components/viewer/DrawingSettingsPanel.tsx +3 -3
- package/src/components/viewer/HierarchyPanel.tsx +110 -842
- package/src/components/viewer/IDSExportDialog.tsx +281 -0
- package/src/components/viewer/IDSPanel.tsx +126 -17
- package/src/components/viewer/KeyboardShortcutsDialog.tsx +9 -0
- package/src/components/viewer/LensPanel.tsx +603 -0
- package/src/components/viewer/MainToolbar.tsx +188 -21
- package/src/components/viewer/PropertiesPanel.tsx +171 -663
- package/src/components/viewer/PropertyEditor.tsx +866 -77
- package/src/components/viewer/Section2DPanel.tsx +76 -2648
- package/src/components/viewer/ToolOverlays.tsx +3 -1097
- package/src/components/viewer/ViewerLayout.tsx +132 -45
- package/src/components/viewer/Viewport.tsx +237 -1659
- package/src/components/viewer/ViewportContainer.tsx +11 -3
- package/src/components/viewer/bcf/BCFCreateTopicForm.tsx +134 -0
- package/src/components/viewer/bcf/BCFTopicDetail.tsx +388 -0
- package/src/components/viewer/bcf/BCFTopicList.tsx +239 -0
- package/src/components/viewer/bcf/bcfHelpers.tsx +109 -0
- package/src/components/viewer/hierarchy/HierarchyNode.tsx +328 -0
- package/src/components/viewer/hierarchy/treeDataBuilder.ts +464 -0
- package/src/components/viewer/hierarchy/types.ts +54 -0
- package/src/components/viewer/hierarchy/useHierarchyTree.ts +280 -0
- package/src/components/viewer/lists/ListBuilder.tsx +486 -0
- package/src/components/viewer/lists/ListPanel.tsx +540 -0
- package/src/components/viewer/lists/ListResultsTable.tsx +193 -0
- package/src/components/viewer/properties/ClassificationCard.tsx +70 -0
- package/src/components/viewer/properties/CoordinateDisplay.tsx +49 -0
- package/src/components/viewer/properties/DocumentCard.tsx +89 -0
- package/src/components/viewer/properties/MaterialCard.tsx +201 -0
- package/src/components/viewer/properties/ModelMetadataPanel.tsx +335 -0
- package/src/components/viewer/properties/PropertySetCard.tsx +132 -0
- package/src/components/viewer/properties/QuantitySetCard.tsx +79 -0
- package/src/components/viewer/properties/RelationshipsCard.tsx +100 -0
- package/src/components/viewer/properties/encodingUtils.ts +29 -0
- package/src/components/viewer/tools/MeasurePanel.tsx +218 -0
- package/src/components/viewer/tools/MeasurementVisuals.tsx +644 -0
- package/src/components/viewer/tools/SectionPanel.tsx +183 -0
- package/src/components/viewer/tools/SectionVisualization.tsx +78 -0
- package/src/components/viewer/tools/formatDistance.ts +18 -0
- package/src/components/viewer/tools/sectionConstants.ts +14 -0
- package/src/components/viewer/useAnimationLoop.ts +166 -0
- package/src/components/viewer/useGeometryStreaming.ts +398 -0
- package/src/components/viewer/useKeyboardControls.ts +221 -0
- package/src/components/viewer/useMouseControls.ts +1009 -0
- package/src/components/viewer/useRenderUpdates.ts +165 -0
- package/src/components/viewer/useTouchControls.ts +245 -0
- package/src/hooks/ids/idsColorSystem.ts +125 -0
- package/src/hooks/ids/idsDataAccessor.ts +237 -0
- package/src/hooks/ids/idsExportService.ts +444 -0
- package/src/hooks/useBCF.ts +7 -0
- package/src/hooks/useDrawingExport.ts +627 -0
- package/src/hooks/useDrawingGeneration.ts +627 -0
- package/src/hooks/useFloorplanView.ts +108 -0
- package/src/hooks/useIDS.ts +270 -463
- package/src/hooks/useIfc.ts +26 -1628
- package/src/hooks/useIfcFederation.ts +803 -0
- package/src/hooks/useIfcLoader.ts +508 -0
- package/src/hooks/useIfcServer.ts +465 -0
- package/src/hooks/useKeyboardShortcuts.ts +1 -1
- package/src/hooks/useLens.ts +129 -0
- package/src/hooks/useMeasure2D.ts +365 -0
- package/src/hooks/useViewControls.ts +218 -0
- package/src/lib/ifc4-pset-definitions.test.ts +161 -0
- package/src/lib/ifc4-pset-definitions.ts +621 -0
- package/src/lib/ifc4-qto-definitions.ts +315 -0
- package/src/lib/lens/adapter.ts +138 -0
- package/src/lib/lens/index.ts +5 -0
- package/src/lib/lists/adapter.ts +69 -0
- package/src/lib/lists/index.ts +28 -0
- package/src/lib/lists/persistence.ts +64 -0
- package/src/services/fs-cache.ts +1 -1
- package/src/services/tauri-modules.d.ts +25 -0
- package/src/store/index.ts +38 -2
- package/src/store/slices/cameraSlice.ts +14 -1
- package/src/store/slices/dataSlice.ts +14 -1
- package/src/store/slices/lensSlice.ts +184 -0
- package/src/store/slices/listSlice.ts +74 -0
- package/src/store/slices/pinboardSlice.ts +114 -0
- package/src/store/types.ts +5 -0
- package/src/utils/ifcConfig.ts +16 -3
- package/src/utils/serverDataModel.ts +64 -101
- package/src/vite-env.d.ts +3 -0
- package/dist/assets/ifc-lite_bg-C6kblxf9.wasm +0 -0
- package/dist/assets/index-v3mcCUPN.css +0 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook for automatic floorplan views per storey.
|
|
7
|
+
* Activates section plane + orthographic top-down view at storey elevation.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useCallback, useMemo } from 'react';
|
|
11
|
+
import { useViewerStore } from '@/store';
|
|
12
|
+
import { useIfc } from './useIfc';
|
|
13
|
+
|
|
14
|
+
interface StoreyInfo {
|
|
15
|
+
expressId: number;
|
|
16
|
+
modelId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
elevation: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useFloorplanView() {
|
|
22
|
+
const { models, ifcDataStore } = useIfc();
|
|
23
|
+
const setSectionPlaneAxis = useViewerStore((s) => s.setSectionPlaneAxis);
|
|
24
|
+
const setSectionPlanePosition = useViewerStore((s) => s.setSectionPlanePosition);
|
|
25
|
+
const setActiveTool = useViewerStore((s) => s.setActiveTool);
|
|
26
|
+
const cameraCallbacks = useViewerStore((s) => s.cameraCallbacks);
|
|
27
|
+
const setProjectionMode = useViewerStore((s) => s.setProjectionMode);
|
|
28
|
+
|
|
29
|
+
// Collect all available storeys sorted by elevation (descending)
|
|
30
|
+
const availableStoreys = useMemo((): StoreyInfo[] => {
|
|
31
|
+
const storeys: StoreyInfo[] = [];
|
|
32
|
+
|
|
33
|
+
if (models.size > 0) {
|
|
34
|
+
for (const [modelId, model] of models) {
|
|
35
|
+
const dataStore = model.ifcDataStore;
|
|
36
|
+
if (!dataStore?.spatialHierarchy) continue;
|
|
37
|
+
const { byStorey, storeyElevations } = dataStore.spatialHierarchy;
|
|
38
|
+
|
|
39
|
+
for (const [storeyId] of byStorey.entries()) {
|
|
40
|
+
const elevation = storeyElevations.get(storeyId) ?? 0;
|
|
41
|
+
const name = dataStore.entities.getName(storeyId) || `Storey #${storeyId}`;
|
|
42
|
+
storeys.push({ expressId: storeyId, modelId, name, elevation });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else if (ifcDataStore?.spatialHierarchy) {
|
|
46
|
+
const { byStorey, storeyElevations } = ifcDataStore.spatialHierarchy;
|
|
47
|
+
for (const [storeyId] of byStorey.entries()) {
|
|
48
|
+
const elevation = storeyElevations.get(storeyId) ?? 0;
|
|
49
|
+
const name = ifcDataStore.entities.getName(storeyId) || `Storey #${storeyId}`;
|
|
50
|
+
storeys.push({ expressId: storeyId, modelId: 'legacy', name, elevation });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Deduplicate storeys at similar elevations (within 0.5m tolerance)
|
|
55
|
+
const seen = new Map<string, StoreyInfo>();
|
|
56
|
+
for (const s of storeys) {
|
|
57
|
+
const key = (Math.round(s.elevation * 2) / 2).toFixed(2);
|
|
58
|
+
if (!seen.has(key) || s.name.length < seen.get(key)!.name.length) {
|
|
59
|
+
seen.set(key, s);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return Array.from(seen.values()).sort((a, b) => b.elevation - a.elevation);
|
|
64
|
+
}, [models, ifcDataStore]);
|
|
65
|
+
|
|
66
|
+
// Activate a floorplan view at the given storey elevation
|
|
67
|
+
const activateFloorplan = useCallback((storey: StoreyInfo) => {
|
|
68
|
+
// 1. Calculate section position as percentage of Y bounds
|
|
69
|
+
// Section cut at 1.2m above floor level (standard architectural practice)
|
|
70
|
+
const cutHeight = storey.elevation + 1.2;
|
|
71
|
+
|
|
72
|
+
// Find Y bounds from all models using coordinateInfo (pre-computed AABB)
|
|
73
|
+
let yMin = Infinity;
|
|
74
|
+
let yMax = -Infinity;
|
|
75
|
+
if (models.size > 0) {
|
|
76
|
+
for (const [, model] of models) {
|
|
77
|
+
const bounds = model.geometryResult?.coordinateInfo?.shiftedBounds;
|
|
78
|
+
if (bounds) {
|
|
79
|
+
yMin = Math.min(yMin, bounds.min.y);
|
|
80
|
+
yMax = Math.max(yMax, bounds.max.y);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Fallback bounds if no coordinate info available
|
|
86
|
+
if (!Number.isFinite(yMin) || !Number.isFinite(yMax)) {
|
|
87
|
+
yMin = -10;
|
|
88
|
+
yMax = 50;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Convert to 0-100 percentage
|
|
92
|
+
const range = yMax - yMin;
|
|
93
|
+
const percentage = range > 0 ? ((cutHeight - yMin) / range) * 100 : 50;
|
|
94
|
+
|
|
95
|
+
// 2. Set section plane: axis=down (Y), position=calculated, enabled
|
|
96
|
+
setSectionPlaneAxis('down');
|
|
97
|
+
setSectionPlanePosition(Math.max(0, Math.min(100, percentage)));
|
|
98
|
+
setActiveTool('section');
|
|
99
|
+
|
|
100
|
+
// 3. Switch to orthographic projection
|
|
101
|
+
setProjectionMode('orthographic');
|
|
102
|
+
|
|
103
|
+
// 4. Set camera to top-down view
|
|
104
|
+
cameraCallbacks.setPresetView?.('top');
|
|
105
|
+
}, [models, setSectionPlaneAxis, setSectionPlanePosition, setActiveTool, setProjectionMode, cameraCallbacks]);
|
|
106
|
+
|
|
107
|
+
return { availableStoreys, activateFloorplan };
|
|
108
|
+
}
|