@collabdt/core 0.3.1 → 0.3.2
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/authentication/ForgotPassword.d.ts.map +1 -1
- package/dist/core/components/authentication/ForgotPassword.js +0 -1
- package/dist/core/components/authentication/ForgotPassword.js.map +1 -1
- package/dist/core/components/ui/Comments/CollapsibleCommentItem.d.ts +12 -2
- package/dist/core/components/ui/Comments/CollapsibleCommentItem.d.ts.map +1 -1
- package/dist/core/components/ui/Comments/CollapsibleCommentItem.js +137 -139
- package/dist/core/components/ui/Comments/CollapsibleCommentItem.js.map +1 -1
- package/dist/core/components/ui/Comments/Comment.d.ts +18 -1
- package/dist/core/components/ui/Comments/Comment.d.ts.map +1 -1
- package/dist/core/components/ui/Comments/Comment.js +94 -23
- package/dist/core/components/ui/Comments/Comment.js.map +1 -1
- package/dist/core/components/ui/Comments/CommentActionButtons.d.ts +34 -0
- package/dist/core/components/ui/Comments/CommentActionButtons.d.ts.map +1 -0
- package/dist/core/components/ui/Comments/CommentActionButtons.js +106 -0
- package/dist/core/components/ui/Comments/CommentActionButtons.js.map +1 -0
- package/dist/core/components/ui/Comments/CommentInput.d.ts.map +1 -1
- package/dist/core/components/ui/Comments/CommentInput.js +5 -2
- package/dist/core/components/ui/Comments/CommentInput.js.map +1 -1
- package/dist/core/components/ui/Comments/CommentsSection.d.ts.map +1 -1
- package/dist/core/components/ui/Comments/CommentsSection.js +86 -42
- package/dist/core/components/ui/Comments/CommentsSection.js.map +1 -1
- package/dist/core/components/ui/Comments/commentUtils.d.ts.map +1 -1
- package/dist/core/components/ui/Comments/commentUtils.js +2 -1
- package/dist/core/components/ui/Comments/commentUtils.js.map +1 -1
- package/dist/core/components/ui/FilesManager/src/useFileUploadWithProgress.d.ts.map +1 -1
- package/dist/core/components/ui/FilesManager/src/useFileUploadWithProgress.js +0 -1
- package/dist/core/components/ui/FilesManager/src/useFileUploadWithProgress.js.map +1 -1
- package/dist/core/components/ui/InfoSidebar/Container.d.ts.map +1 -1
- package/dist/core/components/ui/InfoSidebar/Container.js +16 -12
- package/dist/core/components/ui/InfoSidebar/Container.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorInput.d.ts.map +1 -1
- package/dist/core/components/ui/Sensors/SensorInput.js +0 -1
- package/dist/core/components/ui/Sensors/SensorInput.js.map +1 -1
- package/dist/core/components/ui/Sensors/SensorsSection.js +0 -2
- package/dist/core/components/ui/Sensors/SensorsSection.js.map +1 -1
- package/dist/core/components/ui/Sidebar.d.ts.map +1 -1
- package/dist/core/components/ui/Sidebar.js +27 -4
- package/dist/core/components/ui/Sidebar.js.map +1 -1
- package/dist/core/components/ui/ToolbarButton.d.ts.map +1 -1
- package/dist/core/components/ui/ToolbarButton.js +0 -1
- package/dist/core/components/ui/ToolbarButton.js.map +1 -1
- package/dist/core/components/viewers/Data/advancedFilter/FiltersDialog.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/advancedFilter/FiltersDialog.js +0 -2
- package/dist/core/components/viewers/Data/advancedFilter/FiltersDialog.js.map +1 -1
- package/dist/core/components/viewers/Data/details/EnergySourcesGrid.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/details/EnergySourcesGrid.js +0 -10
- package/dist/core/components/viewers/Data/details/EnergySourcesGrid.js.map +1 -1
- package/dist/core/components/viewers/Data/files/DatatableFileAdder.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/files/DatatableFileAdder.js +0 -1
- package/dist/core/components/viewers/Data/files/DatatableFileAdder.js.map +1 -1
- package/dist/core/components/viewers/Data/files/utils/fuzzySearch.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/files/utils/fuzzySearch.js +0 -1
- package/dist/core/components/viewers/Data/files/utils/fuzzySearch.js.map +1 -1
- package/dist/core/components/viewers/Data/userDetails/UserMoreOptions.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/userDetails/UserMoreOptions.js +0 -1
- package/dist/core/components/viewers/Data/userDetails/UserMoreOptions.js.map +1 -1
- package/dist/core/components/viewers/Data/utils/filterHelper.d.ts.map +1 -1
- package/dist/core/components/viewers/Data/utils/filterHelper.js +0 -2
- package/dist/core/components/viewers/Data/utils/filterHelper.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/TopicsSection.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/TopicsSection.js +0 -3
- package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/TopicsSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/FilesSection.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/FilesSection.js +1 -7
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/FilesSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.js +1 -9
- package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.js.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/TabSelector.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/BimSidebar/src/TabSelector.js +4 -3
- package/dist/core/components/viewers/bim/src/BimSidebar/src/TabSelector.js.map +1 -1
- package/dist/core/components/viewers/bim/src/ClippingPlane.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/ClippingPlane.js +0 -1
- package/dist/core/components/viewers/bim/src/ClippingPlane.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/BimComment.d.ts +16 -10
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/BimComment.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/BimComment.js +26 -6
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/BimComment.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/BimCommentCluster.d.ts +23 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/BimCommentCluster.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/BimCommentCluster.js +108 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/BimCommentCluster.js.map +1 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/clusterMarkersByScreenSpace.d.ts +44 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/clusterMarkersByScreenSpace.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/clusterMarkersByScreenSpace.js +77 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/clusterMarkersByScreenSpace.js.map +1 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/commentCameraUtils.d.ts +24 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/commentCameraUtils.d.ts.map +1 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/commentCameraUtils.js +27 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/commentCameraUtils.js.map +1 -0
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/renderCSS2DMarkers.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/renderCSS2DMarkers.js +2 -2
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/renderCSS2DMarkers.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useCommentMarkers.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useCommentMarkers.js +242 -61
- package/dist/core/components/viewers/bim/src/tools/AddToBim/src/useCommentMarkers.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.js +1 -5
- package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/ExplodeByLevelTool.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/ExplodeByLevelTool.js +0 -1
- package/dist/core/components/viewers/bim/src/tools/ExplodeByLevelTool.js.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/measureBimTool.d.ts.map +1 -1
- package/dist/core/components/viewers/bim/src/tools/measureBimTool.js +1 -2
- package/dist/core/components/viewers/bim/src/tools/measureBimTool.js.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
- package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/arcGISDatasets.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/arcGISDatasets.js +11 -14
- package/dist/core/components/viewers/map/datasets/src/arcGISDatasets.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/ckanDatasets.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/ckanDatasets.js +2 -5
- package/dist/core/components/viewers/map/datasets/src/ckanDatasets.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/localDatasets.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/localDatasets.js +0 -3
- package/dist/core/components/viewers/map/datasets/src/localDatasets.js.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/opendatasoftDatasets.d.ts.map +1 -1
- package/dist/core/components/viewers/map/datasets/src/opendatasoftDatasets.js +0 -11
- package/dist/core/components/viewers/map/datasets/src/opendatasoftDatasets.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.js +0 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/src/BuildingsTools.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.js +0 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.js +0 -1
- package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.js +174 -53
- package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/components/MapFileManager.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/components/MapFileManager.js +2 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/components/MapFileManager.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js +0 -3
- package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/TabSelector.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/TabSelector.js +4 -3
- package/dist/core/components/viewers/map/src/MapSidebar/TabSelector.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/FilesSection.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/FilesSection.js +0 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/FilesSection.js.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/ModelsSection.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/ModelsSection.js +1 -5
- package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/src/ModelsSection.js.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/utils/uploadToPresignedURLS.d.ts.map +1 -1
- package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/utils/uploadToPresignedURLS.js +1 -3
- package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/utils/uploadToPresignedURLS.js.map +1 -1
- package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.js +0 -1
- package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.js.map +1 -1
- package/dist/core/components/viewers/map/utils/flyToEach.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/flyToEach.js +0 -1
- package/dist/core/components/viewers/map/utils/flyToEach.js.map +1 -1
- package/dist/core/components/viewers/map/utils/getOsmIdbyCoordinates.d.ts.map +1 -1
- package/dist/core/components/viewers/map/utils/getOsmIdbyCoordinates.js +0 -2
- package/dist/core/components/viewers/map/utils/getOsmIdbyCoordinates.js.map +1 -1
- package/dist/core/hooks/comments/comments.d.ts +11 -0
- package/dist/core/hooks/comments/comments.d.ts.map +1 -1
- package/dist/core/hooks/comments/comments.js +3 -1
- package/dist/core/hooks/comments/comments.js.map +1 -1
- package/dist/core/hooks/comments/createCommentHooks.d.ts +11 -0
- package/dist/core/hooks/comments/createCommentHooks.d.ts.map +1 -1
- package/dist/core/hooks/comments/createCommentHooks.js +30 -1
- package/dist/core/hooks/comments/createCommentHooks.js.map +1 -1
- package/dist/core/hooks/files/files.d.ts.map +1 -1
- package/dist/core/hooks/files/files.js +0 -1
- package/dist/core/hooks/files/files.js.map +1 -1
- package/dist/core/hooks/ui/useResizableSidebarWidth.d.ts +30 -0
- package/dist/core/hooks/ui/useResizableSidebarWidth.d.ts.map +1 -0
- package/dist/core/hooks/ui/useResizableSidebarWidth.js +75 -0
- package/dist/core/hooks/ui/useResizableSidebarWidth.js.map +1 -0
- package/dist/core/i18n/messages/en.json +5 -0
- package/dist/core/i18n/messages/es.json +6 -1
- package/dist/core/i18n/messages/fr.json +6 -1
- package/dist/core/store/Datasets/reducer.d.ts.map +1 -1
- package/dist/core/store/Datasets/reducer.js +0 -2
- package/dist/core/store/Datasets/reducer.js.map +1 -1
- package/dist/core/store/Files/reducer.js +0 -1
- package/dist/core/store/Files/reducer.js.map +1 -1
- package/dist/core/store/Menus/context.d.ts.map +1 -1
- package/dist/core/store/Menus/context.js +4 -1
- package/dist/core/store/Menus/context.js.map +1 -1
- package/dist/core/store/Menus/reducer.d.ts +20 -0
- package/dist/core/store/Menus/reducer.d.ts.map +1 -1
- package/dist/core/store/Menus/reducer.js +21 -3
- package/dist/core/store/Menus/reducer.js.map +1 -1
- package/dist/core/utils/markerUtils.d.ts +10 -0
- package/dist/core/utils/markerUtils.d.ts.map +1 -1
- package/dist/core/utils/markerUtils.js +9 -1
- package/dist/core/utils/markerUtils.js.map +1 -1
- package/dist/core/utils/memcache.d.ts.map +1 -1
- package/dist/core/utils/memcache.js +0 -7
- package/dist/core/utils/memcache.js.map +1 -1
- package/package.json +4 -1
|
@@ -18,23 +18,170 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
return a;
|
|
19
19
|
};
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
import { useSession } from "next-auth/react";
|
|
21
22
|
import * as React from "react";
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
23
|
+
import { createRoot } from "react-dom/client";
|
|
24
|
+
import * as THREE from "three";
|
|
25
|
+
import { CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
|
|
26
|
+
import { useComments, useDeleteComments } from "../../../../../../../hooks/comments/comments";
|
|
27
|
+
import { HooksCtx, useCoreHooks } from "../../../../../../../hooks/provider";
|
|
24
28
|
import { useUsers } from "../../../../../../../hooks/users/users";
|
|
25
29
|
import { MenusContext } from "../../../../../../../store";
|
|
26
30
|
import { ViewerNames } from "../../../../../../../types/dbTypes";
|
|
27
31
|
import BimComment from "./BimComment";
|
|
32
|
+
import BimCommentCluster from "./BimCommentCluster";
|
|
33
|
+
import { clusterMarkersByScreenSpace } from "./clusterMarkersByScreenSpace";
|
|
34
|
+
import { computeCommentLookAt } from "./commentCameraUtils";
|
|
28
35
|
import { renderCSS2DMarkers } from "./renderCSS2DMarkers";
|
|
36
|
+
function makeCommentPropsMapper(state) {
|
|
37
|
+
const { currentCommentId, focusedCommentId, currentUserId, onSelect, onFocus, onEdit, onReply, onRemove } = state;
|
|
38
|
+
return (comment) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const base = {
|
|
41
|
+
userName: comment.authorName,
|
|
42
|
+
userImageFileId: (_a = comment.imageFileId) != null ? _a : null,
|
|
43
|
+
userImage: (_b = comment.imageFileId) != null ? _b : null,
|
|
44
|
+
buildingId: comment.buildingId,
|
|
45
|
+
timestamp: new Date(comment.createdAt),
|
|
46
|
+
text: comment.text,
|
|
47
|
+
isPending: comment.isPending || false,
|
|
48
|
+
highlight: currentCommentId === comment.id,
|
|
49
|
+
focused: focusedCommentId === comment.id
|
|
50
|
+
};
|
|
51
|
+
if (comment.isPending) return base;
|
|
52
|
+
const isAuthor = currentUserId != null && String(comment.authorId) === currentUserId;
|
|
53
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
54
|
+
showActions: true,
|
|
55
|
+
canEdit: isAuthor,
|
|
56
|
+
canDelete: isAuthor,
|
|
57
|
+
onSelect: () => onSelect(comment.id),
|
|
58
|
+
onFocus: () => onFocus(comment.id),
|
|
59
|
+
onReply: () => onReply(comment.id),
|
|
60
|
+
onEdit: isAuthor ? () => onEdit(comment.id) : void 0,
|
|
61
|
+
onRemove: isAuthor ? () => onRemove(comment.id) : void 0
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function clearSingles(world, registry) {
|
|
66
|
+
renderCSS2DMarkers(world, {
|
|
67
|
+
items: [],
|
|
68
|
+
markerIdKey: "commentId",
|
|
69
|
+
registry,
|
|
70
|
+
component: BimComment,
|
|
71
|
+
propsMapper: () => ({}),
|
|
72
|
+
sphereColor: "white",
|
|
73
|
+
isVisible: false,
|
|
74
|
+
onRemove: () => {
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function clearClusters(world, registry) {
|
|
79
|
+
registry.current.forEach(({ root, css2dObject }) => {
|
|
80
|
+
world.scene.three.remove(css2dObject);
|
|
81
|
+
const el = css2dObject.element;
|
|
82
|
+
el == null ? void 0 : el.remove();
|
|
83
|
+
root.unmount();
|
|
84
|
+
});
|
|
85
|
+
registry.current.clear();
|
|
86
|
+
}
|
|
87
|
+
function renderMarkers(state, singleRegistry, clusterRegistry, lastSignatureRef) {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
const { world, items, pending, isVisible, currentCommentId, focusedCommentId, coreHooks, onRemove, onSelect, onFocus } = state;
|
|
90
|
+
if (!world) return;
|
|
91
|
+
if (!isVisible) {
|
|
92
|
+
if (lastSignatureRef.current === "hidden") return;
|
|
93
|
+
clearSingles(world, singleRegistry);
|
|
94
|
+
clearClusters(world, clusterRegistry);
|
|
95
|
+
lastSignatureRef.current = "hidden";
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const camera = (_a = world.camera) == null ? void 0 : _a.three;
|
|
99
|
+
const dom = (_c = (_b = world.renderer) == null ? void 0 : _b.three) == null ? void 0 : _c.domElement;
|
|
100
|
+
if (!camera || !dom) return;
|
|
101
|
+
const width = dom.clientWidth || dom.width || 0;
|
|
102
|
+
const height = dom.clientHeight || dom.height || 0;
|
|
103
|
+
if (!width || !height) return;
|
|
104
|
+
const { clusters, singles } = clusterMarkersByScreenSpace(items, camera, width, height, 44);
|
|
105
|
+
const singleItems = [...singles, ...pending];
|
|
106
|
+
const clusterKeys = clusters.map((c) => c.key);
|
|
107
|
+
const dataHash = [...items, ...pending].map((c) => {
|
|
108
|
+
var _a2;
|
|
109
|
+
return `${c.id}:${(_a2 = c.text) != null ? _a2 : ""}:${c.isPending ? 1 : 0}`;
|
|
110
|
+
}).join(";");
|
|
111
|
+
const signature = `v2|${currentCommentId}|${focusedCommentId}|C:${clusterKeys.join(",")}|S:${singleItems.map((s) => s.id).join(",")}|D:${dataHash}`;
|
|
112
|
+
if (signature === lastSignatureRef.current) return;
|
|
113
|
+
lastSignatureRef.current = signature;
|
|
114
|
+
renderCSS2DMarkers(world, {
|
|
115
|
+
items: singleItems,
|
|
116
|
+
markerIdKey: "commentId",
|
|
117
|
+
registry: singleRegistry,
|
|
118
|
+
component: BimComment,
|
|
119
|
+
hooksContextValue: coreHooks,
|
|
120
|
+
propsMapper: makeCommentPropsMapper(state),
|
|
121
|
+
sphereColor: "white",
|
|
122
|
+
isVisible: true,
|
|
123
|
+
onRemove
|
|
124
|
+
});
|
|
125
|
+
singleRegistry.current.forEach((ref, id) => {
|
|
126
|
+
const nid = Number(id);
|
|
127
|
+
ref.css2dObject.renderOrder = nid === currentCommentId || nid === focusedCommentId ? 1 : 0;
|
|
128
|
+
});
|
|
129
|
+
const reg = clusterRegistry.current;
|
|
130
|
+
const wanted = new Set(clusterKeys);
|
|
131
|
+
for (const [key, ref] of reg) {
|
|
132
|
+
if (!wanted.has(key)) {
|
|
133
|
+
world.scene.three.remove(ref.css2dObject);
|
|
134
|
+
const el = ref.css2dObject.element;
|
|
135
|
+
el == null ? void 0 : el.remove();
|
|
136
|
+
ref.root.unmount();
|
|
137
|
+
reg.delete(key);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
for (const cluster of clusters) {
|
|
141
|
+
const members = cluster.members.map((m) => {
|
|
142
|
+
var _a2;
|
|
143
|
+
return {
|
|
144
|
+
id: m.id,
|
|
145
|
+
userName: m.authorName,
|
|
146
|
+
imageFileId: (_a2 = m.imageFileId) != null ? _a2 : null
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
const highlight = currentCommentId != null && members.some((m) => m.id === currentCommentId);
|
|
150
|
+
const element = React.createElement(BimCommentCluster, { members, highlight, onSelect, onFocus });
|
|
151
|
+
const wrapped = coreHooks ? React.createElement(HooksCtx.Provider, { value: coreHooks }, element) : element;
|
|
152
|
+
const existing = reg.get(cluster.key);
|
|
153
|
+
if (existing) {
|
|
154
|
+
existing.root.render(wrapped);
|
|
155
|
+
existing.css2dObject.position.set(cluster.worldCenter.x, cluster.worldCenter.y + 0.2, cluster.worldCenter.z);
|
|
156
|
+
existing.css2dObject.renderOrder = highlight ? 1 : 0;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const labelDiv = document.createElement("div");
|
|
160
|
+
labelDiv.style.pointerEvents = "auto";
|
|
161
|
+
const root = createRoot(labelDiv);
|
|
162
|
+
root.render(wrapped);
|
|
163
|
+
const css2dObject = new CSS2DObject(labelDiv);
|
|
164
|
+
css2dObject.position.set(cluster.worldCenter.x, cluster.worldCenter.y + 0.2, cluster.worldCenter.z);
|
|
165
|
+
css2dObject.element.style.pointerEvents = "auto";
|
|
166
|
+
css2dObject.renderOrder = highlight ? 1 : 0;
|
|
167
|
+
world.scene.three.add(css2dObject);
|
|
168
|
+
reg.set(cluster.key, { root, css2dObject });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
29
171
|
function useCommentMarkers(world, buildingId) {
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
const
|
|
172
|
+
var _a, _b, _c, _d;
|
|
173
|
+
const { state: menusState, dispatch: menusDispatch, setIsSidebarOpen } = React.useContext(MenusContext);
|
|
174
|
+
const { commentsVisibleInViewer, currentCommentId, focusedCommentId, focusRequestId } = menusState.menus;
|
|
175
|
+
const singleRegistry = React.useRef(/* @__PURE__ */ new Map());
|
|
176
|
+
const clusterRegistry = React.useRef(/* @__PURE__ */ new Map());
|
|
177
|
+
const lastSignatureRef = React.useRef("");
|
|
178
|
+
const stateRef = React.useRef(null);
|
|
179
|
+
const commentsRef = React.useRef([]);
|
|
33
180
|
const { comments } = useComments();
|
|
34
181
|
const { users } = useUsers();
|
|
35
182
|
const coreHooks = useCoreHooks();
|
|
36
|
-
const
|
|
37
|
-
const {
|
|
183
|
+
const currentUserId = (_c = (_b = (_a = useSession().data) == null ? void 0 : _a.user) == null ? void 0 : _b.id) != null ? _c : null;
|
|
184
|
+
const { deleteComments } = useDeleteComments();
|
|
38
185
|
const eligibleComments = comments.filter((comment) => {
|
|
39
186
|
const { x, y, z, viewer } = comment;
|
|
40
187
|
if (x == null || y == null || z == null) return false;
|
|
@@ -42,23 +189,38 @@ function useCommentMarkers(world, buildingId) {
|
|
|
42
189
|
if (buildingId !== -1 && comment.buildingId !== buildingId) return false;
|
|
43
190
|
return true;
|
|
44
191
|
}).map((comment) => {
|
|
45
|
-
var
|
|
192
|
+
var _a2, _b2, _c2;
|
|
46
193
|
const user = users.find((u) => u.id === comment.authorId);
|
|
47
194
|
return __spreadProps(__spreadValues({}, comment), {
|
|
48
|
-
authorName: (
|
|
49
|
-
imageFileId: (
|
|
50
|
-
image: (
|
|
195
|
+
authorName: (_a2 = user == null ? void 0 : user.name) != null ? _a2 : "Unknown User",
|
|
196
|
+
imageFileId: (_b2 = user == null ? void 0 : user.imageFileId) != null ? _b2 : null,
|
|
197
|
+
image: (_c2 = user == null ? void 0 : user.imageFileId) != null ? _c2 : null
|
|
51
198
|
});
|
|
52
199
|
});
|
|
53
|
-
|
|
54
|
-
if (commentToDelete !== null) {
|
|
55
|
-
deleteComment();
|
|
56
|
-
setCommentToDelete(null);
|
|
57
|
-
}
|
|
58
|
-
}, [commentToDelete, deleteComment]);
|
|
200
|
+
commentsRef.current = eligibleComments;
|
|
59
201
|
const handleRemoveComment = React.useCallback((commentId) => {
|
|
60
|
-
|
|
61
|
-
|
|
202
|
+
const replyIds = comments.filter((c) => c.replyToId === commentId).map((c) => c.id);
|
|
203
|
+
void deleteComments({ ids: [commentId, ...replyIds] });
|
|
204
|
+
}, [comments, deleteComments]);
|
|
205
|
+
const handleSelectComment = React.useCallback((commentId) => {
|
|
206
|
+
menusDispatch({ type: "SET_CURRENT_COMMENT_ID", payload: { commentId } });
|
|
207
|
+
}, [menusDispatch]);
|
|
208
|
+
const handleFocusComment = React.useCallback((commentId) => {
|
|
209
|
+
menusDispatch({ type: "SET_CURRENT_COMMENT_ID", payload: { commentId } });
|
|
210
|
+
menusDispatch({ type: "SET_FOCUSED_COMMENT_ID", payload: { commentId } });
|
|
211
|
+
}, [menusDispatch]);
|
|
212
|
+
const requestSidebarAction = React.useCallback((commentId, action) => {
|
|
213
|
+
setIsSidebarOpen(true);
|
|
214
|
+
menusDispatch({ type: "SET_SIDEBAR_SELECTED_TAB", payload: { selectedTab: "communication" } });
|
|
215
|
+
menusDispatch({ type: "SET_CURRENT_COMMENT_ID", payload: { commentId } });
|
|
216
|
+
menusDispatch({ type: "REQUEST_COMMENT_ACTION", payload: { commentId, action } });
|
|
217
|
+
}, [menusDispatch, setIsSidebarOpen]);
|
|
218
|
+
const handleEditComment = React.useCallback((commentId) => {
|
|
219
|
+
requestSidebarAction(commentId, "edit");
|
|
220
|
+
}, [requestSidebarAction]);
|
|
221
|
+
const handleReplyComment = React.useCallback((commentId) => {
|
|
222
|
+
requestSidebarAction(commentId, "reply");
|
|
223
|
+
}, [requestSidebarAction]);
|
|
62
224
|
const [pendingComments, setPendingComments] = React.useState([]);
|
|
63
225
|
const addPendingComment = React.useCallback((position) => {
|
|
64
226
|
const id = -Date.now();
|
|
@@ -68,49 +230,68 @@ function useCommentMarkers(world, buildingId) {
|
|
|
68
230
|
const removePendingComment = React.useCallback((id) => {
|
|
69
231
|
setPendingComments((prev) => prev.filter((p) => p.id !== id));
|
|
70
232
|
}, []);
|
|
233
|
+
const isVisible = (_d = commentsVisibleInViewer == null ? void 0 : commentsVisibleInViewer.includes(ViewerNames.bim)) != null ? _d : false;
|
|
234
|
+
stateRef.current = {
|
|
235
|
+
world,
|
|
236
|
+
items: eligibleComments.map((c) => __spreadProps(__spreadValues({}, c), { isPending: false })),
|
|
237
|
+
pending: pendingComments.map((p) => ({
|
|
238
|
+
id: p.id,
|
|
239
|
+
x: p.x,
|
|
240
|
+
y: p.y,
|
|
241
|
+
z: p.z,
|
|
242
|
+
authorName: "Loading...",
|
|
243
|
+
imageFileId: null,
|
|
244
|
+
image: "",
|
|
245
|
+
text: "Creating comment...",
|
|
246
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
247
|
+
buildingId,
|
|
248
|
+
isPending: true
|
|
249
|
+
})),
|
|
250
|
+
isVisible,
|
|
251
|
+
currentCommentId,
|
|
252
|
+
focusedCommentId,
|
|
253
|
+
currentUserId,
|
|
254
|
+
coreHooks,
|
|
255
|
+
onRemove: handleRemoveComment,
|
|
256
|
+
onSelect: handleSelectComment,
|
|
257
|
+
onFocus: handleFocusComment,
|
|
258
|
+
onEdit: handleEditComment,
|
|
259
|
+
onReply: handleReplyComment
|
|
260
|
+
};
|
|
71
261
|
React.useEffect(() => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
isPending: comment.isPending || false,
|
|
106
|
-
highlight: currentCommentId === comment.id
|
|
107
|
-
};
|
|
108
|
-
},
|
|
109
|
-
sphereColor: "white",
|
|
110
|
-
isVisible,
|
|
111
|
-
onRemove: handleRemoveComment
|
|
112
|
-
});
|
|
113
|
-
}, [world, eligibleComments, pendingComments, handleRemoveComment, commentsVisibleInViewer, buildingId, currentCommentId, coreHooks]);
|
|
262
|
+
if (!world) return;
|
|
263
|
+
let raf = 0;
|
|
264
|
+
let frame = 0;
|
|
265
|
+
const loop = () => {
|
|
266
|
+
if ((frame++ & 1) === 0 && stateRef.current) {
|
|
267
|
+
renderMarkers(stateRef.current, singleRegistry, clusterRegistry, lastSignatureRef);
|
|
268
|
+
}
|
|
269
|
+
raf = requestAnimationFrame(loop);
|
|
270
|
+
};
|
|
271
|
+
raf = requestAnimationFrame(loop);
|
|
272
|
+
return () => {
|
|
273
|
+
cancelAnimationFrame(raf);
|
|
274
|
+
clearClusters(world, clusterRegistry);
|
|
275
|
+
clearSingles(world, singleRegistry);
|
|
276
|
+
lastSignatureRef.current = "";
|
|
277
|
+
};
|
|
278
|
+
}, [world]);
|
|
279
|
+
React.useEffect(() => {
|
|
280
|
+
var _a2;
|
|
281
|
+
if (focusedCommentId == null || !world) return;
|
|
282
|
+
const target = commentsRef.current.find((c) => c.id === focusedCommentId);
|
|
283
|
+
if (!target || target.x == null || target.y == null || target.z == null) return;
|
|
284
|
+
const controls = (_a2 = world.camera) == null ? void 0 : _a2.controls;
|
|
285
|
+
if (!controls) return;
|
|
286
|
+
const camPos = controls.getPosition(new THREE.Vector3());
|
|
287
|
+
const camTarget = controls.getTarget(new THREE.Vector3());
|
|
288
|
+
const lookAt = computeCommentLookAt(
|
|
289
|
+
{ x: camPos.x, y: camPos.y, z: camPos.z },
|
|
290
|
+
{ x: camTarget.x, y: camTarget.y, z: camTarget.z },
|
|
291
|
+
{ x: target.x, y: target.y, z: target.z }
|
|
292
|
+
);
|
|
293
|
+
void controls.setLookAt(lookAt.camX, lookAt.camY, lookAt.camZ, lookAt.tarX, lookAt.tarY, lookAt.tarZ, true);
|
|
294
|
+
}, [focusRequestId, world]);
|
|
114
295
|
const commentCount = comments.filter(
|
|
115
296
|
(c) => c.viewer === ViewerNames.bim && (!buildingId || buildingId === -1 || c.buildingId === buildingId)
|
|
116
297
|
).length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/bim/src/tools/AddToBim/src/useCommentMarkers.ts"],"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 { useComments, useComment } from \"../../../../../../../hooks/comments/comments\"\r\nimport { useCoreHooks } from \"../../../../../../../hooks/provider\"\r\nimport { useUsers } from \"../../../../../../../hooks/users/users\"\r\nimport { MenusContext } from \"../../../../../../../store\"\r\nimport { ViewerNames } from \"../../../../../../../types/dbTypes\"\r\n\r\nimport BimComment from \"./BimComment\"\r\nimport { renderCSS2DMarkers, type MarkerRef } from \"./renderCSS2DMarkers\"\r\n\r\nexport function useCommentMarkers(world: any, buildingId: number) {\r\n const { state: menusState } = React.useContext(MenusContext)\r\n const { commentsVisibleInViewer, currentCommentId } = menusState.menus\r\n\r\n const registry = React.useRef<Map<string, MarkerRef>>(new Map())\r\n\r\n const { comments } = useComments()\r\n const { users } = useUsers()\r\n const coreHooks = useCoreHooks()\r\n\r\n const [commentToDelete, setCommentToDelete] = React.useState<number | null>(null)\r\n const { deleteComment } = useComment(commentToDelete)\r\n\r\n const eligibleComments = comments\r\n .filter((comment) => {\r\n const { x, y, z, viewer } = comment\r\n if (x == null || y == null || z == null) return false\r\n if (viewer !== ViewerNames.bim) return false\r\n if (buildingId !== -1 && comment.buildingId !== buildingId) return false\r\n return true\r\n })\r\n .map((comment) => {\r\n const user = users.find(u => u.id === comment.authorId)\r\n return {\r\n ...comment,\r\n authorName: user?.name ?? \"Unknown User\",\r\n imageFileId: user?.imageFileId ?? null,\r\n image: user?.imageFileId ?? null,\r\n }\r\n })\r\n\r\n React.useEffect(() => {\r\n if (commentToDelete !== null) {\r\n deleteComment()\r\n setCommentToDelete(null)\r\n }\r\n }, [commentToDelete, deleteComment])\r\n\r\n const handleRemoveComment = React.useCallback((commentId: number) => {\r\n setCommentToDelete(commentId)\r\n }, [])\r\n\r\n // Pending markers for loading indicators while comment is being created\r\n const [pendingComments, setPendingComments] = React.useState<Array<{ id: number; x: number; y: number; z: number }>>([])\r\n\r\n const addPendingComment = React.useCallback((position: { x: number; y: number; z: number }) => {\r\n const id = -Date.now()\r\n setPendingComments(prev => [...prev, { id, ...position }])\r\n return id\r\n }, [])\r\n\r\n const removePendingComment = React.useCallback((id: number) => {\r\n setPendingComments(prev => prev.filter(p => p.id !== id))\r\n }, [])\r\n\r\n // Render comment markers (including pending)\r\n React.useEffect(() => {\r\n const isVisible = commentsVisibleInViewer?.includes(ViewerNames.bim) ?? false\r\n\r\n const allComments = [\r\n ...eligibleComments.map(c => ({ ...c, isPending: false })),\r\n ...pendingComments.map(p => ({\r\n id: p.id,\r\n x: p.x,\r\n y: p.y,\r\n z: p.z,\r\n authorName: \"Loading...\",\r\n imageFileId: null,\r\n image: \"\",\r\n text: \"Creating comment...\",\r\n createdAt: new Date().toISOString(),\r\n buildingId,\r\n isPending: true,\r\n })),\r\n ]\r\n\r\n renderCSS2DMarkers(world, {\r\n items: allComments,\r\n markerIdKey: \"commentId\",\r\n registry,\r\n component: BimComment,\r\n hooksContextValue: coreHooks,\r\n propsMapper: (comment) => ({\r\n userName: comment.authorName,\r\n userImageFileId: comment.imageFileId ?? null,\r\n userImage: comment.imageFileId ?? null,\r\n buildingId: comment.buildingId,\r\n timestamp: new Date(comment.createdAt),\r\n text: comment.text,\r\n isPending: comment.isPending || false,\r\n highlight: currentCommentId === comment.id,\r\n }),\r\n sphereColor: \"white\",\r\n isVisible,\r\n onRemove: handleRemoveComment,\r\n })\r\n }, [world, eligibleComments, pendingComments, handleRemoveComment, commentsVisibleInViewer, buildingId, currentCommentId, coreHooks])\r\n\r\n const commentCount = comments.filter(\r\n c => c.viewer === ViewerNames.bim && (!buildingId || buildingId === -1 || c.buildingId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C;AAAA,UACzB,UAAU,QAAQ;AAAA,UAClB,kBAAiBA,MAAA,QAAQ,gBAAR,OAAAA,MAAuB;AAAA,UACxC,YAAW,aAAQ,gBAAR,YAAuB;AAAA,UAClC,YAAY,QAAQ;AAAA,UACpB,WAAW,IAAI,KAAK,QAAQ,SAAS;AAAA,UACrC,MAAM,QAAQ;AAAA,UACd,WAAW,QAAQ,aAAa;AAAA,UAChC,WAAW,qBAAqB,QAAQ;AAAA,QAC1C;AAAA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA,UAAU;AAAA,IACZ,CAAC;AAAA,EACH,GAAG,CAAC,OAAO,kBAAkB,iBAAiB,qBAAqB,yBAAyB,YAAY,kBAAkB,SAAS,CAAC;AAEpI,QAAM,eAAe,SAAS;AAAA,IAC5B,OAAK,EAAE,WAAW,YAAY,QAAQ,CAAC,cAAc,eAAe,MAAM,EAAE,eAAe;AAAA,EAC7F,EAAE;AAEF,SAAO,EAAE,mBAAmB,sBAAsB,aAAa;AACjE;","names":["_a"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/core/components/viewers/bim/src/tools/AddToBim/src/useCommentMarkers.ts"],"sourcesContent":["\"use client\"\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { useSession } from \"next-auth/react\"\nimport * as React from \"react\"\nimport { createRoot } from \"react-dom/client\"\nimport * as THREE from \"three\"\nimport { CSS2DObject } from \"three/addons/renderers/CSS2DRenderer.js\"\n\nimport { useComments, useDeleteComments } from \"../../../../../../../hooks/comments/comments\"\nimport { HooksCtx, useCoreHooks, type HooksBag } from \"../../../../../../../hooks/provider\"\nimport { useUsers } from \"../../../../../../../hooks/users/users\"\nimport { MenusContext } from \"../../../../../../../store\"\nimport { ViewerNames } from \"../../../../../../../types/dbTypes\"\n\nimport BimComment from \"./BimComment\"\nimport BimCommentCluster from \"./BimCommentCluster\"\nimport { clusterMarkersByScreenSpace } from \"./clusterMarkersByScreenSpace\"\nimport { computeCommentLookAt } from \"./commentCameraUtils\"\nimport { renderCSS2DMarkers, type MarkerRef } from \"./renderCSS2DMarkers\"\n\ntype ClusterMarkerRef = { root: ReturnType<typeof createRoot>; css2dObject: CSS2DObject }\n\ninterface RenderState {\n world: any\n /** Non-pending BIM comments eligible for clustering. */\n items: any[]\n /** Pending (being-created) markers — always rendered as singles. */\n pending: any[]\n isVisible: boolean\n currentCommentId: number | null\n focusedCommentId: number | null\n currentUserId: string | null\n coreHooks: HooksBag | null\n onRemove: (id: number) => void\n onSelect: (id: number) => void\n onFocus: (id: number) => void\n onEdit: (id: number) => void\n onReply: (id: number) => void\n}\n\n/** Builds the per-comment props for the shared `Comment` card, gating edit/delete by author. */\nfunction makeCommentPropsMapper(state: RenderState) {\n const { currentCommentId, focusedCommentId, currentUserId, onSelect, onFocus, onEdit, onReply, onRemove } = state\n return (comment: any) => {\n const base = {\n userName: comment.authorName,\n userImageFileId: comment.imageFileId ?? null,\n userImage: comment.imageFileId ?? null,\n buildingId: comment.buildingId,\n timestamp: new Date(comment.createdAt),\n text: comment.text,\n isPending: comment.isPending || false,\n highlight: currentCommentId === comment.id,\n focused: focusedCommentId === comment.id,\n }\n if (comment.isPending) return base\n\n const isAuthor = currentUserId != null && String(comment.authorId) === currentUserId\n return {\n ...base,\n showActions: true,\n canEdit: isAuthor,\n canDelete: isAuthor,\n onSelect: () => onSelect(comment.id),\n onFocus: () => onFocus(comment.id),\n onReply: () => onReply(comment.id),\n onEdit: isAuthor ? () => onEdit(comment.id) : undefined,\n onRemove: isAuthor ? () => onRemove(comment.id) : undefined,\n }\n }\n}\n\nfunction clearSingles(world: any, registry: React.MutableRefObject<Map<string, MarkerRef>>) {\n renderCSS2DMarkers(world, {\n items: [],\n markerIdKey: \"commentId\",\n registry,\n component: BimComment,\n propsMapper: () => ({}),\n sphereColor: \"white\",\n isVisible: false,\n onRemove: () => {},\n })\n}\n\nfunction clearClusters(world: any, registry: React.MutableRefObject<Map<string, ClusterMarkerRef>>) {\n registry.current.forEach(({ root, css2dObject }) => {\n world.scene.three.remove(css2dObject)\n const el = css2dObject.element as HTMLElement | undefined\n el?.remove()\n root.unmount()\n })\n registry.current.clear()\n}\n\n/**\n * Imperative render driven by a rAF loop. Recomputes screen-space clustering\n * from the current camera and only rebuilds DOM when the layout/data signature\n * changes (individual CSS2DObjects already track the camera every frame).\n */\nfunction renderMarkers(\n state: RenderState,\n singleRegistry: React.MutableRefObject<Map<string, MarkerRef>>,\n clusterRegistry: React.MutableRefObject<Map<string, ClusterMarkerRef>>,\n lastSignatureRef: React.MutableRefObject<string>,\n) {\n const { world, items, pending, isVisible, currentCommentId, focusedCommentId, coreHooks, onRemove, onSelect, onFocus } = state\n if (!world) return\n\n if (!isVisible) {\n if (lastSignatureRef.current === \"hidden\") return\n clearSingles(world, singleRegistry)\n clearClusters(world, clusterRegistry)\n lastSignatureRef.current = \"hidden\"\n return\n }\n\n const camera = world.camera?.three\n const dom = world.renderer?.three?.domElement\n if (!camera || !dom) return\n\n const width = dom.clientWidth || dom.width || 0\n const height = dom.clientHeight || dom.height || 0\n if (!width || !height) return\n\n const { clusters, singles } = clusterMarkersByScreenSpace(items, camera, width, height, 44)\n const singleItems = [...singles, ...pending]\n\n const clusterKeys = clusters.map((c) => c.key)\n const dataHash = [...items, ...pending]\n .map((c) => `${c.id}:${c.text ?? \"\"}:${c.isPending ? 1 : 0}`)\n .join(\";\")\n const signature =\n `v2|${currentCommentId}|${focusedCommentId}|C:${clusterKeys.join(\",\")}` +\n `|S:${singleItems.map((s) => s.id).join(\",\")}|D:${dataHash}`\n if (signature === lastSignatureRef.current) return\n lastSignatureRef.current = signature\n\n // Singles (including pending) via the shared per-marker renderer\n renderCSS2DMarkers(world, {\n items: singleItems,\n markerIdKey: \"commentId\",\n registry: singleRegistry,\n component: BimComment,\n hooksContextValue: coreHooks,\n propsMapper: makeCommentPropsMapper(state),\n sphereColor: \"white\",\n isVisible: true,\n onRemove,\n })\n\n // Float the highlighted/focused marker above overlapping ones. The CSS2D renderer sorts by\n // renderOrder first (then camera distance), so this makes a selected comment that sits behind\n // nearer markers come to the front — visible and clickable instead of buried.\n singleRegistry.current.forEach((ref, id) => {\n const nid = Number(id)\n ref.css2dObject.renderOrder = nid === currentCommentId || nid === focusedCommentId ? 1 : 0\n })\n\n // Cluster bubbles, managed imperatively\n const reg = clusterRegistry.current\n const wanted = new Set(clusterKeys)\n for (const [key, ref] of reg) {\n if (!wanted.has(key)) {\n world.scene.three.remove(ref.css2dObject)\n const el = ref.css2dObject.element as HTMLElement | undefined\n el?.remove()\n ref.root.unmount()\n reg.delete(key)\n }\n }\n\n for (const cluster of clusters) {\n const members = cluster.members.map((m) => ({\n id: m.id,\n userName: m.authorName,\n imageFileId: m.imageFileId ?? null,\n }))\n const highlight = currentCommentId != null && members.some((m) => m.id === currentCommentId)\n const element = React.createElement(BimCommentCluster, { members, highlight, onSelect, onFocus })\n const wrapped = coreHooks\n ? React.createElement(HooksCtx.Provider, { value: coreHooks }, element)\n : element\n\n const existing = reg.get(cluster.key)\n if (existing) {\n existing.root.render(wrapped)\n existing.css2dObject.position.set(cluster.worldCenter.x, cluster.worldCenter.y + 0.2, cluster.worldCenter.z)\n existing.css2dObject.renderOrder = highlight ? 1 : 0\n continue\n }\n\n const labelDiv = document.createElement(\"div\")\n labelDiv.style.pointerEvents = \"auto\"\n const root = createRoot(labelDiv)\n root.render(wrapped)\n\n const css2dObject = new CSS2DObject(labelDiv)\n css2dObject.position.set(cluster.worldCenter.x, cluster.worldCenter.y + 0.2, cluster.worldCenter.z)\n css2dObject.element.style.pointerEvents = \"auto\"\n css2dObject.renderOrder = highlight ? 1 : 0\n world.scene.three.add(css2dObject)\n\n reg.set(cluster.key, { root, css2dObject })\n }\n}\n\nexport function useCommentMarkers(world: any, buildingId: number) {\n const { state: menusState, dispatch: menusDispatch, setIsSidebarOpen } = React.useContext(MenusContext)\n const { commentsVisibleInViewer, currentCommentId, focusedCommentId, focusRequestId } = menusState.menus\n\n const singleRegistry = React.useRef<Map<string, MarkerRef>>(new Map())\n const clusterRegistry = React.useRef<Map<string, ClusterMarkerRef>>(new Map())\n const lastSignatureRef = React.useRef<string>(\"\")\n const stateRef = React.useRef<RenderState | null>(null)\n const commentsRef = React.useRef<any[]>([])\n\n const { comments } = useComments()\n const { users } = useUsers()\n const coreHooks = useCoreHooks()\n const currentUserId = useSession().data?.user?.id ?? null\n const { deleteComments } = useDeleteComments()\n\n const eligibleComments = comments\n .filter((comment) => {\n const { x, y, z, viewer } = comment\n if (x == null || y == null || z == null) return false\n if (viewer !== ViewerNames.bim) return false\n if (buildingId !== -1 && comment.buildingId !== buildingId) return false\n return true\n })\n .map((comment) => {\n const user = users.find((u) => u.id === comment.authorId)\n return {\n ...comment,\n authorName: user?.name ?? \"Unknown User\",\n imageFileId: user?.imageFileId ?? null,\n image: user?.imageFileId ?? null,\n }\n })\n\n commentsRef.current = eligibleComments\n\n const handleRemoveComment = React.useCallback((commentId: number) => {\n // Cascade: remove the comment and any replies (the DB self-relation does not cascade).\n const replyIds = comments.filter((c) => c.replyToId === commentId).map((c) => c.id)\n void deleteComments({ ids: [commentId, ...replyIds] })\n }, [comments, deleteComments])\n\n const handleSelectComment = React.useCallback((commentId: number) => {\n menusDispatch({ type: \"SET_CURRENT_COMMENT_ID\", payload: { commentId } })\n }, [menusDispatch])\n\n const handleFocusComment = React.useCallback((commentId: number) => {\n menusDispatch({ type: \"SET_CURRENT_COMMENT_ID\", payload: { commentId } })\n menusDispatch({ type: \"SET_FOCUSED_COMMENT_ID\", payload: { commentId } })\n }, [menusDispatch])\n\n // Edit/reply on the 3D card open the comment's editor/reply box in the sidebar.\n const requestSidebarAction = React.useCallback((commentId: number, action: 'edit' | 'reply') => {\n setIsSidebarOpen(true)\n menusDispatch({ type: \"SET_SIDEBAR_SELECTED_TAB\", payload: { selectedTab: 'communication' } })\n menusDispatch({ type: \"SET_CURRENT_COMMENT_ID\", payload: { commentId } })\n menusDispatch({ type: \"REQUEST_COMMENT_ACTION\", payload: { commentId, action } })\n }, [menusDispatch, setIsSidebarOpen])\n\n const handleEditComment = React.useCallback((commentId: number) => {\n requestSidebarAction(commentId, 'edit')\n }, [requestSidebarAction])\n\n const handleReplyComment = React.useCallback((commentId: number) => {\n requestSidebarAction(commentId, 'reply')\n }, [requestSidebarAction])\n\n // Pending markers for loading indicators while comment is being created\n const [pendingComments, setPendingComments] = React.useState<Array<{ id: number; x: number; y: number; z: number }>>([])\n\n const addPendingComment = React.useCallback((position: { x: number; y: number; z: number }) => {\n const id = -Date.now()\n setPendingComments((prev) => [...prev, { id, ...position }])\n return id\n }, [])\n\n const removePendingComment = React.useCallback((id: number) => {\n setPendingComments((prev) => prev.filter((p) => p.id !== id))\n }, [])\n\n const isVisible = commentsVisibleInViewer?.includes(ViewerNames.bim) ?? false\n\n // Keep the latest inputs available to the rAF render loop (avoids stale closures)\n stateRef.current = {\n world,\n items: eligibleComments.map((c) => ({ ...c, isPending: false })),\n pending: pendingComments.map((p) => ({\n id: p.id,\n x: p.x,\n y: p.y,\n z: p.z,\n authorName: \"Loading...\",\n imageFileId: null,\n image: \"\",\n text: \"Creating comment...\",\n createdAt: new Date().toISOString(),\n buildingId,\n isPending: true,\n })),\n isVisible,\n currentCommentId,\n focusedCommentId,\n currentUserId,\n coreHooks,\n onRemove: handleRemoveComment,\n onSelect: handleSelectComment,\n onFocus: handleFocusComment,\n onEdit: handleEditComment,\n onReply: handleReplyComment,\n }\n\n React.useEffect(() => {\n if (!world) return\n let raf = 0\n let frame = 0\n const loop = () => {\n // Recompute at most every other frame; renderMarkers no-ops unless the\n // cluster layout or data actually changed.\n if ((frame++ & 1) === 0 && stateRef.current) {\n renderMarkers(stateRef.current, singleRegistry, clusterRegistry, lastSignatureRef)\n }\n raf = requestAnimationFrame(loop)\n }\n raf = requestAnimationFrame(loop)\n\n return () => {\n cancelAnimationFrame(raf)\n clearClusters(world, clusterRegistry)\n clearSingles(world, singleRegistry)\n lastSignatureRef.current = \"\"\n }\n }, [world])\n\n // Zoom to a comment when it is focused (double-clicked here or in the sidebar).\n React.useEffect(() => {\n if (focusedCommentId == null || !world) return\n const target = commentsRef.current.find((c) => c.id === focusedCommentId)\n if (!target || target.x == null || target.y == null || target.z == null) return\n const controls = world.camera?.controls\n if (!controls) return\n\n const camPos = controls.getPosition(new THREE.Vector3())\n const camTarget = controls.getTarget(new THREE.Vector3())\n const lookAt = computeCommentLookAt(\n { x: camPos.x, y: camPos.y, z: camPos.z },\n { x: camTarget.x, y: camTarget.y, z: camTarget.z },\n { x: target.x, y: target.y, z: target.z },\n )\n void controls.setLookAt(lookAt.camX, lookAt.camY, lookAt.camZ, lookAt.tarX, lookAt.tarY, lookAt.tarZ, true)\n }, [focusRequestId, world])\n\n const commentCount = comments.filter(\n (c) => c.viewer === ViewerNames.bim && (!buildingId || buildingId === -1 || c.buildingId === buildingId),\n ).length\n\n return { addPendingComment, removePendingComment, commentCount }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKA,SAAS,kBAAkB;AAC3B,YAAY,WAAW;AACvB,SAAS,kBAAkB;AAC3B,YAAY,WAAW;AACvB,SAAS,mBAAmB;AAE5B,SAAS,aAAa,yBAAyB;AAC/C,SAAS,UAAU,oBAAmC;AACtD,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAE5B,OAAO,gBAAgB;AACvB,OAAO,uBAAuB;AAC9B,SAAS,mCAAmC;AAC5C,SAAS,4BAA4B;AACrC,SAAS,0BAA0C;AAuBnD,SAAS,uBAAuB,OAAoB;AAClD,QAAM,EAAE,kBAAkB,kBAAkB,eAAe,UAAU,SAAS,QAAQ,SAAS,SAAS,IAAI;AAC5G,SAAO,CAAC,YAAiB;AA9C3B;AA+CI,UAAM,OAAO;AAAA,MACX,UAAU,QAAQ;AAAA,MAClB,kBAAiB,aAAQ,gBAAR,YAAuB;AAAA,MACxC,YAAW,aAAQ,gBAAR,YAAuB;AAAA,MAClC,YAAY,QA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S,UAAU,OAAO,MAAM,OAAO,MAAM,OAAO,MAAM,OAAO,MAAM,OAAO,MAAM,OAAO,MAAM,IAAI;AAAA,EAC5G,GAAG,CAAC,gBAAgB,KAAK,CAAC;AAE1B,QAAM,eAAe,SAAS;AAAA,IAC5B,CAAC,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC,cAAc,eAAe,MAAM,EAAE,eAAe;AAAA,EAC/F,EAAE;AAEF,SAAO,EAAE,mBAAmB,sBAAsB,aAAa;AACjE;","names":["_a","_b","_c"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClippingTool.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,OAAO,KAAK,EAAE,IAAI,EAAmB,MAAM,+BAA+B,CAAA;AAI1E,UAAU,iBAAiB;IACzB,IAAI,EAAE,IAAI,CAAA;CACX;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ClippingTool.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,OAAO,KAAK,EAAE,IAAI,EAAmB,MAAM,+BAA+B,CAAA;AAI1E,UAAU,iBAAiB;IACzB,IAAI,EAAE,IAAI,CAAA;CACX;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA+JpD,CAAA"}
|
|
@@ -40,7 +40,6 @@ const ClippingTool = ({ tool }) => {
|
|
|
40
40
|
};
|
|
41
41
|
const removeAllClippingPlanes = React.useCallback(() => {
|
|
42
42
|
if (!world || !bimComponents) return;
|
|
43
|
-
console.log("Remove all clipping planes");
|
|
44
43
|
bimComponents.get(OBC.Clipper).deleteAll();
|
|
45
44
|
}, [world, bimComponents]);
|
|
46
45
|
const handleCreateClippingPlane = React.useCallback(async () => {
|
|
@@ -89,10 +88,7 @@ const ClippingTool = ({ tool }) => {
|
|
|
89
88
|
items: { All: { style: "Black" } }
|
|
90
89
|
});
|
|
91
90
|
});
|
|
92
|
-
|
|
93
|
-
if (result) {
|
|
94
|
-
console.log(result);
|
|
95
|
-
}
|
|
91
|
+
await clipper.create(world);
|
|
96
92
|
}, [world, bimComponents]);
|
|
97
93
|
React.useEffect(() => {
|
|
98
94
|
keydownRef.current = (event) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.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\n// Dependencies\r\nimport * as OBC from '@thatopen/components'\r\nimport * as OBF from \"@thatopen/components-front\"\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from \"react\";\r\nimport * as THREE from \"three\";\r\nimport { LineMaterial } from \"three/examples/jsm/lines/LineMaterial.js\";\r\n\r\n// Utilities\r\nimport { MenusContext, ToolsContext } from '../../../../../../store'\r\nimport { BimContext } from '../../../../../../store'\r\n\r\n\r\n// Shadcn components\r\nimport { ToolbarSubmenu, SubmenuContext } from '../../../../../ToolbarSubmenu'\r\nimport { Button } from '../../../../../ui/Button'\r\nimport { Card, CardContent, CardHeader, CardTitle } from '../../../../../ui/Card'\r\nimport { DropdownMenuItem } from '../../../../../ui/DropdownMenu'\r\n\r\n// Icons\r\nimport { Cursor } from '../../Cursor'\r\n\r\nimport type { CursorType } from '../../../../../../types/global'\r\nimport type { Tool, ToolbarToolType } from '../../../../../../types/tools'\r\n\r\n// Submenu wrapper\r\n\r\ninterface ClippingToolProps {\r\n tool: Tool\r\n}\r\n\r\nexport const ClippingTool: React.FC<ClippingToolProps> = ({ tool }) => {\r\n const { dispatch: toolsDispatch, state: toolsState } = React.useContext(ToolsContext)\r\n const { dispatch: menusDispatch } = React.useContext(MenusContext)\r\n const { state: bimState } = React.useContext(BimContext)\r\n const { bimComponents, world } = bimState.bim\r\n\r\n const [active, setActive] = React.useState(false)\r\n const keydownRef = React.useRef<(e: KeyboardEvent) => void>(() => {})\r\n\r\n const setCursor = (cursor: CursorType) => {\r\n if (!bimComponents) return\r\n const currentCursor = bimComponents.get(Cursor)\r\n if (!currentCursor) return\r\n currentCursor.cursor = cursor\r\n }\r\n\r\n const setTools = (currentToolId: ToolbarToolType) => {\r\n toolsDispatch({\r\n type: 'SET-TOOL',\r\n payload: { currentToolId },\r\n })\r\n }\r\n\r\n const flipAddingPlaneState = async () => {\r\n const _active = !active\r\n\r\n setActive(_active)\r\n setTools(_active ? tool.id : null)\r\n setCursor(_active ? 'crosshair' : '')\r\n }\r\n\r\n const removeAllClippingPlanes = React.useCallback(() => {\r\n if (!world || !bimComponents) return\r\n console.log(\"Remove all clipping planes\")\r\n bimComponents.get(OBC.Clipper).deleteAll()\r\n }, [world, bimComponents])\r\n\r\n //use effect to handle controlling the state of adding clipping plane\r\n const handleCreateClippingPlane = React.useCallback(async () => {\r\n if (!world || !bimComponents) return\r\n // set up\r\n const casters = bimComponents.get(OBC.Raycasters)\r\n casters.get(world)\r\n\r\n //styling\r\n const clipStyler = bimComponents.get(OBF.ClipStyler)\r\n clipStyler.world = world;\r\n clipStyler.styles.set(\"Black\", {\r\n linesMaterial: new LineMaterial({\r\n color: \"black\",\r\n linewidth: 2, // thick, screen-space lines\r\n }),\r\n fillsMaterial: new THREE.MeshBasicMaterial({\r\n color: 0x000000,\r\n side: THREE.DoubleSide, // see the cap from both sides\r\n // transparent: true, // enable opacity blending\r\n // opacity: 0.2, // soft see-through cap\r\n // depthWrite: false, // reduce sorting issues with transparency\r\n // polygonOffset: true, // nudge to prevent z-fighting\r\n // polygonOffsetFactor: -2,\r\n // polygonOffsetUnits: 1,\r\n }),\r\n });\r\n\r\n //set up items to be filled\r\n const finder = bimComponents.get(OBC.ItemsFinder);\r\n finder.create(\"Walls\", [{ categories: [/WALL/] }]);\r\n finder.create(\"Slabs\", [{ categories: [/SLAB/] }]);\r\n finder.create(\"Columns\", [{ categories: [/COLUMN/] }]);\r\n finder.create(\"Doors\", [{ categories: [/DOOR/] }]);\r\n finder.create(\"Curtains\", [{ categories: [/PLATE/, /MEMBER/] }]);\r\n finder.create(\"Windows\", [{ categories: [/WINDOW/] }]);\r\n\r\n const classifier = bimComponents.get(OBC.Classifier);\r\n const classificationName = \"ClipperGroups\";\r\n classifier.setGroupQuery(classificationName, \"Walls\", { name: \"Walls\" });\r\n classifier.setGroupQuery(classificationName, \"Slabs\", { name: \"Slabs\" });\r\n classifier.setGroupQuery(classificationName, \"Columns\", { name: \"Columns\" });\r\n classifier.setGroupQuery(classificationName, \"Doors\", { name: \"Doors\" });\r\n classifier.setGroupQuery(classificationName, \"Curtains\", { name: \"Curtains\" });\r\n classifier.setGroupQuery(classificationName, \"Windows\", { name: \"Windows\" });\r\n\r\n //Create clipper\r\n const clipper = bimComponents.get(OBC.Clipper)\r\n clipper.enabled = true\r\n\r\n //Apply styling\r\n clipper.list.onItemSet.add(({ key }) => {\r\n clipStyler.createFromClipping(key, {\r\n items: { All: { style: \"Black\" } },\r\n });\r\n });\r\n\r\n const result = await clipper.create(world)\r\n\r\n if (result) {\r\n console.log(result)\r\n }\r\n }, [world, bimComponents])\r\n\r\n React.useEffect(() => {\r\n keydownRef.current = (event: KeyboardEvent) => {\r\n if (event.key === 'Backspace') {\r\n // Remove the clipping plane under the cursor\r\n if (!world || !bimComponents) return\r\n bimComponents.get(OBC.Clipper).delete(world, undefined)\r\n }\r\n }\r\n }, [world, bimComponents])\r\n\r\n const handleKeyDown = React.useCallback((e: KeyboardEvent) => {\r\n keydownRef.current?.(e)\r\n }, [])\r\n\r\n // Handle deleting plane using Backspace\r\n React.useEffect(() => {\r\n if (!active) {\r\n window.removeEventListener('keydown', handleKeyDown)\r\n return\r\n }\r\n window.addEventListener('keydown', handleKeyDown)\r\n return () => {\r\n window.removeEventListener('keydown', handleKeyDown)\r\n }\r\n }, [active, handleKeyDown])\r\n\r\n React.useEffect (() => {\r\n if (!world || !bimComponents) return\r\n\r\n const container = world.renderer.three.domElement\r\n\r\n if (active) {\r\n container.addEventListener(\"dblclick\", handleCreateClippingPlane)\r\n }\r\n else {\r\n container.removeEventListener(\"dblclick\", handleCreateClippingPlane)\r\n }\r\n\r\n }, [active, world, bimComponents])\r\n\r\n return (\r\n <div>\r\n <ToolbarSubmenu tool={tool}>\r\n <DropdownMenuItem onClick={flipAddingPlaneState}>\r\n <LR.PlusSquare />\r\n <span>{active? 'Cancel add' : 'Add'} clipping Plane</span>\r\n </DropdownMenuItem>\r\n\r\n <DropdownMenuItem onClick={() => removeAllClippingPlanes()}>\r\n <LR.Trash2/>\r\n <span> Delete all clipping planes</span>\r\n </DropdownMenuItem>\r\n </ToolbarSubmenu>\r\n\r\n {active &&\r\n <Card className=\"p-3 absolute bottom-10 left-0 bg-background shadow-md z-10 w-full\">\r\n <span className=\"text-muted-foreground text-xs\">\r\n Double click on the model to add a clipping plane. Press Backspace to remove the clipping plane.\r\n </span>\r\n </Card>\r\n }\r\n </div>\r\n\r\n )\r\n}"],"mappings":";AAqLU,cACA,YADA;AA/KV,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,YAAY,QAAQ;AAEpB,YAAY,WAAW;AACvB,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAG7B,SAAS,cAAc,oBAAoB;AAC3C,SAAS,kBAAkB;AAI3B,SAAS,sBAAsC;AAE/C,SAAS,YAAgD;AACzD,SAAS,wBAAwB;AAGjC,SAAS,cAAc;AAWhB,MAAM,eAA4C,CAAC,EAAE,KAAK,MAAM;AACrE,QAAM,EAAE,UAAU,eAAe,OAAO,WAAW,IAAI,MAAM,WAAW,YAAY;AACpF,QAAM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oBAAiB,SAAS,MAAM,wBAAwB,GACvD;AAAA,4BAAC,GAAG,QAAH,EAAS;AAAA,QACV,oBAAC,UAAK,yCAA2B;AAAA,SACnC;AAAA,OACF;AAAA,IAEC,UACA,oBAAC,QAAK,WAAU,qEACX,8BAAC,UAAK,WAAU,iCAAgC,8GAEhD,GACJ;AAAA,KAEJ;AAGJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.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\n// Dependencies\r\nimport * as OBC from '@thatopen/components'\r\nimport * as OBF from \"@thatopen/components-front\"\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from \"react\";\r\nimport * as THREE from \"three\";\r\nimport { LineMaterial } from \"three/examples/jsm/lines/LineMaterial.js\";\r\n\r\n// Utilities\r\nimport { MenusContext, ToolsContext } from '../../../../../../store'\r\nimport { BimContext } from '../../../../../../store'\r\n\r\n\r\n// Shadcn components\r\nimport { ToolbarSubmenu, SubmenuContext } from '../../../../../ToolbarSubmenu'\r\nimport { Button } from '../../../../../ui/Button'\r\nimport { Card, CardContent, CardHeader, CardTitle } from '../../../../../ui/Card'\r\nimport { DropdownMenuItem } from '../../../../../ui/DropdownMenu'\r\n\r\n// Icons\r\nimport { Cursor } from '../../Cursor'\r\n\r\nimport type { CursorType } from '../../../../../../types/global'\r\nimport type { Tool, ToolbarToolType } from '../../../../../../types/tools'\r\n\r\n// Submenu wrapper\r\n\r\ninterface ClippingToolProps {\r\n tool: Tool\r\n}\r\n\r\nexport const ClippingTool: React.FC<ClippingToolProps> = ({ tool }) => {\r\n const { dispatch: toolsDispatch, state: toolsState } = React.useContext(ToolsContext)\r\n const { dispatch: menusDispatch } = React.useContext(MenusContext)\r\n const { state: bimState } = React.useContext(BimContext)\r\n const { bimComponents, world } = bimState.bim\r\n\r\n const [active, setActive] = React.useState(false)\r\n const keydownRef = React.useRef<(e: KeyboardEvent) => void>(() => {})\r\n\r\n const setCursor = (cursor: CursorType) => {\r\n if (!bimComponents) return\r\n const currentCursor = bimComponents.get(Cursor)\r\n if (!currentCursor) return\r\n currentCursor.cursor = cursor\r\n }\r\n\r\n const setTools = (currentToolId: ToolbarToolType) => {\r\n toolsDispatch({\r\n type: 'SET-TOOL',\r\n payload: { currentToolId },\r\n })\r\n }\r\n\r\n const flipAddingPlaneState = async () => {\r\n const _active = !active\r\n\r\n setActive(_active)\r\n setTools(_active ? tool.id : null)\r\n setCursor(_active ? 'crosshair' : '')\r\n }\r\n\r\n const removeAllClippingPlanes = React.useCallback(() => {\r\n if (!world || !bimComponents) return\r\n bimComponents.get(OBC.Clipper).deleteAll()\r\n }, [world, bimComponents])\r\n\r\n //use effect to handle controlling the state of adding clipping plane\r\n const handleCreateClippingPlane = React.useCallback(async () => {\r\n if (!world || !bimComponents) return\r\n // set up\r\n const casters = bimComponents.get(OBC.Raycasters)\r\n casters.get(world)\r\n\r\n //styling\r\n const clipStyler = bimComponents.get(OBF.ClipStyler)\r\n clipStyler.world = world;\r\n clipStyler.styles.set(\"Black\", {\r\n linesMaterial: new LineMaterial({\r\n color: \"black\",\r\n linewidth: 2, // thick, screen-space lines\r\n }),\r\n fillsMaterial: new THREE.MeshBasicMaterial({\r\n color: 0x000000,\r\n side: THREE.DoubleSide, // see the cap from both sides\r\n // transparent: true, // enable opacity blending\r\n // opacity: 0.2, // soft see-through cap\r\n // depthWrite: false, // reduce sorting issues with transparency\r\n // polygonOffset: true, // nudge to prevent z-fighting\r\n // polygonOffsetFactor: -2,\r\n // polygonOffsetUnits: 1,\r\n }),\r\n });\r\n\r\n //set up items to be filled\r\n const finder = bimComponents.get(OBC.ItemsFinder);\r\n finder.create(\"Walls\", [{ categories: [/WALL/] }]);\r\n finder.create(\"Slabs\", [{ categories: [/SLAB/] }]);\r\n finder.create(\"Columns\", [{ categories: [/COLUMN/] }]);\r\n finder.create(\"Doors\", [{ categories: [/DOOR/] }]);\r\n finder.create(\"Curtains\", [{ categories: [/PLATE/, /MEMBER/] }]);\r\n finder.create(\"Windows\", [{ categories: [/WINDOW/] }]);\r\n\r\n const classifier = bimComponents.get(OBC.Classifier);\r\n const classificationName = \"ClipperGroups\";\r\n classifier.setGroupQuery(classificationName, \"Walls\", { name: \"Walls\" });\r\n classifier.setGroupQuery(classificationName, \"Slabs\", { name: \"Slabs\" });\r\n classifier.setGroupQuery(classificationName, \"Columns\", { name: \"Columns\" });\r\n classifier.setGroupQuery(classificationName, \"Doors\", { name: \"Doors\" });\r\n classifier.setGroupQuery(classificationName, \"Curtains\", { name: \"Curtains\" });\r\n classifier.setGroupQuery(classificationName, \"Windows\", { name: \"Windows\" });\r\n\r\n //Create clipper\r\n const clipper = bimComponents.get(OBC.Clipper)\r\n clipper.enabled = true\r\n\r\n //Apply styling\r\n clipper.list.onItemSet.add(({ key }) => {\r\n clipStyler.createFromClipping(key, {\r\n items: { All: { style: \"Black\" } },\r\n });\r\n });\r\n\r\n await clipper.create(world)\r\n }, [world, bimComponents])\r\n\r\n React.useEffect(() => {\r\n keydownRef.current = (event: KeyboardEvent) => {\r\n if (event.key === 'Backspace') {\r\n // Remove the clipping plane under the cursor\r\n if (!world || !bimComponents) return\r\n bimComponents.get(OBC.Clipper).delete(world, undefined)\r\n }\r\n }\r\n }, [world, bimComponents])\r\n\r\n const handleKeyDown = React.useCallback((e: KeyboardEvent) => {\r\n keydownRef.current?.(e)\r\n }, [])\r\n\r\n // Handle deleting plane using Backspace\r\n React.useEffect(() => {\r\n if (!active) {\r\n window.removeEventListener('keydown', handleKeyDown)\r\n return\r\n }\r\n window.addEventListener('keydown', handleKeyDown)\r\n return () => {\r\n window.removeEventListener('keydown', handleKeyDown)\r\n }\r\n }, [active, handleKeyDown])\r\n\r\n React.useEffect (() => {\r\n if (!world || !bimComponents) return\r\n\r\n const container = world.renderer.three.domElement\r\n\r\n if (active) {\r\n container.addEventListener(\"dblclick\", handleCreateClippingPlane)\r\n }\r\n else {\r\n container.removeEventListener(\"dblclick\", handleCreateClippingPlane)\r\n }\r\n\r\n }, [active, world, bimComponents])\r\n\r\n return (\r\n <div>\r\n <ToolbarSubmenu tool={tool}>\r\n <DropdownMenuItem onClick={flipAddingPlaneState}>\r\n <LR.PlusSquare />\r\n <span>{active? 'Cancel add' : 'Add'} clipping Plane</span>\r\n </DropdownMenuItem>\r\n\r\n <DropdownMenuItem onClick={() => removeAllClippingPlanes()}>\r\n <LR.Trash2/>\r\n <span> Delete all clipping planes</span>\r\n </DropdownMenuItem>\r\n </ToolbarSubmenu>\r\n\r\n {active &&\r\n <Card className=\"p-3 absolute bottom-10 left-0 bg-background shadow-md z-10 w-full\">\r\n <span className=\"text-muted-foreground text-xs\">\r\n Double click on the model to add a clipping plane. Press Backspace to remove the clipping plane.\r\n </span>\r\n </Card>\r\n }\r\n </div>\r\n\r\n )\r\n}"],"mappings":";AAgLU,cACA,YADA;AA1KV,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,YAAY,QAAQ;AAEpB,YAAY,WAAW;AACvB,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAG7B,SAAS,cAAc,oBAAoB;AAC3C,SAAS,kBAAkB;AAI3B,SAAS,sBAAsC;AAE/C,SAAS,YAAgD;AACzD,SAAS,wBAAwB;AAGjC,SAAS,cAAc;AAWhB,MAAM,eAA4C,CAAC,EAAE,KAAK,MAAM;AACrE,QAAM,EAAE,UAAU,eAAe,OAAO,WAAW,IAAI,MAAM,WAAW,YAAY;AACpF,QAAM,EAAE,UAAU,cAAc,IAAI,MAAM,WAAW,YAAY;AACjE,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,WAAW,UAAU;AACvD,QAAM,EAAE,eAAe,MAAM,IAAI,SAAS;AAE1C,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,KAAK;AAChD,QAAM,aAAa,MAAM,OAA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../../../../../src/core/components/viewers/bim/src/tools/ExplodeByLevelTool.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAOtD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,IAAI,CAAA;CACX;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ExplodeByLevelTool.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/bim/src/tools/ExplodeByLevelTool.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAOtD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,IAAI,CAAA;CACX;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA8B5D,CAAA"}
|
|
@@ -12,7 +12,6 @@ const ExplodeByLevelTool = ({ tool }) => {
|
|
|
12
12
|
const handleExplodeByLevel = async () => {
|
|
13
13
|
if (!bimComponents) return;
|
|
14
14
|
try {
|
|
15
|
-
console.log("Explode by level functionality not implemented yet");
|
|
16
15
|
} catch (error) {
|
|
17
16
|
console.error("Error exploding by level:", error);
|
|
18
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/bim/src/tools/ExplodeByLevelTool.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\n// Use this tutorial https://docs.thatopen.com/Tutorials/Fragments/Fragments/FragmentsModels/EditApi\r\n\r\n// Dependencies\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from \"react\";\r\n\r\n// Utilities\r\nimport { BimContext } from '../../../../../store/BIM/context'\r\nimport { Button } from '../../../../ui/Button'\r\n\r\nimport type { Tool } from '../../../../../types/tools'\r\n\r\n// Shadcn components\r\n\r\n// Icons\r\n\r\n\r\ninterface ExplodeByLevelProps {\r\n tool: Tool\r\n}\r\n\r\nexport const ExplodeByLevelTool: React.FC<ExplodeByLevelProps> = ({ tool }) => {\r\n // Translation\r\n const t = useTranslations('ExplodeByLevelTool')\r\n\r\n const { state: bimState } = React.useContext(BimContext)\r\n const { bimComponents } = bimState.bim\r\n\r\n const handleExplodeByLevel = async () => {\r\n if (!bimComponents) return\r\n\r\n try {\r\n //
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/bim/src/tools/ExplodeByLevelTool.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\n// Use this tutorial https://docs.thatopen.com/Tutorials/Fragments/Fragments/FragmentsModels/EditApi\r\n\r\n// Dependencies\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from \"react\";\r\n\r\n// Utilities\r\nimport { BimContext } from '../../../../../store/BIM/context'\r\nimport { Button } from '../../../../ui/Button'\r\n\r\nimport type { Tool } from '../../../../../types/tools'\r\n\r\n// Shadcn components\r\n\r\n// Icons\r\n\r\n\r\ninterface ExplodeByLevelProps {\r\n tool: Tool\r\n}\r\n\r\nexport const ExplodeByLevelTool: React.FC<ExplodeByLevelProps> = ({ tool }) => {\r\n // Translation\r\n const t = useTranslations('ExplodeByLevelTool')\r\n\r\n const { state: bimState } = React.useContext(BimContext)\r\n const { bimComponents } = bimState.bim\r\n\r\n const handleExplodeByLevel = async () => {\r\n if (!bimComponents) return\r\n\r\n try {\r\n // ⚠️ Explode-by-level functionality not implemented\r\n }\r\n catch (error) {\r\n console.error('Error exploding by level:', error)\r\n }\r\n }\r\n\r\n return (\r\n <Button\r\n size=\"icon\"\r\n variant=\"ghost\"\r\n className=\"flex justify-center items-center h-9 w-9 pointer-events-auto opacity-50\"\r\n onClick={handleExplodeByLevel}\r\n title={`${tool.title} (${t('comingSoon')})`}\r\n disabled={true}\r\n >\r\n <LR.Layers3 />\r\n </Button>\r\n )\r\n}"],"mappings":";AAsDM;AA9CN,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAGvB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAahB,MAAM,qBAAoD,CAAC,EAAE,KAAK,MAAM;AAE7E,QAAM,IAAI,gBAAgB,oBAAoB;AAE9C,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,WAAW,UAAU;AACvD,QAAM,EAAE,cAAc,IAAI,SAAS;AAEnC,QAAM,uBAAuB,YAAY;AACvC,QAAI,CAAC,cAAe;AAEpB,QAAI;AAAA,IAEJ,SACO,OAAO;AACZ,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,WAAU;AAAA,MACV,SAAS;AAAA,MACT,OAAO,GAAG,KAAK,KAAK,KAAK,EAAE,YAAY,CAAC;AAAA,MACxC,UAAU;AAAA,MAEV,8BAAC,GAAG,SAAH,EAAW;AAAA;AAAA,EACd;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measureBimTool.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/bim/src/tools/measureBimTool.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,OAAO,KAAK,EAAE,IAAI,EAAC,MAAM,4BAA4B,CAAC;AACtD,UAAU,gBAAgB;IACxB,IAAI,EAAE,IAAI,CAAA;CACX;AAID,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"measureBimTool.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/components/viewers/bim/src/tools/measureBimTool.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,OAAO,KAAK,EAAE,IAAI,EAAC,MAAM,4BAA4B,CAAC;AACtD,UAAU,gBAAgB;IACxB,IAAI,EAAE,IAAI,CAAA;CACX;AAID,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAgHrD,CAAA"}
|
|
@@ -45,8 +45,7 @@ const MeasureBimTool = ({ tool }) => {
|
|
|
45
45
|
}, [currentToolId, toolId, lengthMeasurement]);
|
|
46
46
|
React.useEffect(() => {
|
|
47
47
|
if (!lengthMeasurement) return;
|
|
48
|
-
const handleMeasurementCreated = (
|
|
49
|
-
console.log("Measurement created:", data.length);
|
|
48
|
+
const handleMeasurementCreated = () => {
|
|
50
49
|
};
|
|
51
50
|
lengthMeasurement.onDimensionCreate.add(handleMeasurementCreated);
|
|
52
51
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/core/components/viewers/bim/src/tools/measureBimTool.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\n// Dependencies\r\nimport * as OBF from \"@thatopen/components-front\"\r\n\r\n// Utilities\r\n\r\n// Shadcn components\r\n\r\n// Icons\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from \"react\";\r\n\r\nimport { ToolsContext } from '../../../../../store'\r\nimport { BimContext } from '../../../../../store/BIM/context'\r\nimport { type ToolbarToolType } from '../../../../../types/tools'\r\nimport { ToolbarSubmenu } from '../../../../ToolbarSubmenu'\r\nimport {\r\n DropdownMenuItem,\r\n} from '../../../../ui/DropdownMenu'\r\nimport { LengthMeasurement } from '../BimMeasurements/LenghtMeasurement'\r\nimport { Cursor } from '../Cursor'\r\n\r\nimport type { CursorType } from '../../../../../types/global'\r\nimport type { Tool} from '../../../../../types/tools';\r\ninterface MeasureToolProps {\r\n tool: Tool\r\n}\r\n\r\ntype MeasureType = 'free' | 'edge' | 'area' | 'volume'\r\n\r\nexport const MeasureBimTool: React.FC<MeasureToolProps> = ({ tool }) => {\r\n // Translation\r\n const t = useTranslations('MeasureBimTool')\r\n\r\n const { dispatch: toolsDispatch, state: toolsState } = React.useContext(ToolsContext)\r\n const { state: bimState } = React.useContext(BimContext)\r\n const [active, setActive] = React.useState(false)\r\n\r\n const { bimComponents } = bimState.bim\r\n const lengthMeasurement = bimComponents?.get(LengthMeasurement)\r\n const hoverHandler = bimComponents?.get(OBF.Hoverer)\r\n\r\n const setCursor = (cursor: CursorType) => {\r\n if (!bimComponents) return\r\n const currentCursor = bimComponents.get(Cursor)\r\n if (!currentCursor) return\r\n currentCursor.cursor = cursor\r\n }\r\n\r\n const toolId = tool.id\r\n const { currentToolId } = toolsState.tools\r\n const setTools = (currentToolId: ToolbarToolType) => {\r\n toolsDispatch({\r\n type: 'SET-TOOL',\r\n payload: { currentToolId },\r\n })\r\n }\r\n\r\n // When current tool changes\r\n React.useEffect(() => {\r\n setActive(currentToolId === toolId)\r\n\r\n // Disable measurement when tool is deactivated\r\n if (currentToolId !== toolId && lengthMeasurement) {\r\n lengthMeasurement.enabled = false\r\n if (hoverHandler) {\r\n hoverHandler.enabled = true\r\n }\r\n }\r\n }, [currentToolId, toolId, lengthMeasurement])\r\n\r\n // Optional: Listen to measurement creation events\r\n React.useEffect(() => {\r\n if (!lengthMeasurement) return\r\n\r\n const handleMeasurementCreated = (
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/core/components/viewers/bim/src/tools/measureBimTool.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\n// Dependencies\r\nimport * as OBF from \"@thatopen/components-front\"\r\n\r\n// Utilities\r\n\r\n// Shadcn components\r\n\r\n// Icons\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from \"react\";\r\n\r\nimport { ToolsContext } from '../../../../../store'\r\nimport { BimContext } from '../../../../../store/BIM/context'\r\nimport { type ToolbarToolType } from '../../../../../types/tools'\r\nimport { ToolbarSubmenu } from '../../../../ToolbarSubmenu'\r\nimport {\r\n DropdownMenuItem,\r\n} from '../../../../ui/DropdownMenu'\r\nimport { LengthMeasurement } from '../BimMeasurements/LenghtMeasurement'\r\nimport { Cursor } from '../Cursor'\r\n\r\nimport type { CursorType } from '../../../../../types/global'\r\nimport type { Tool} from '../../../../../types/tools';\r\ninterface MeasureToolProps {\r\n tool: Tool\r\n}\r\n\r\ntype MeasureType = 'free' | 'edge' | 'area' | 'volume'\r\n\r\nexport const MeasureBimTool: React.FC<MeasureToolProps> = ({ tool }) => {\r\n // Translation\r\n const t = useTranslations('MeasureBimTool')\r\n\r\n const { dispatch: toolsDispatch, state: toolsState } = React.useContext(ToolsContext)\r\n const { state: bimState } = React.useContext(BimContext)\r\n const [active, setActive] = React.useState(false)\r\n\r\n const { bimComponents } = bimState.bim\r\n const lengthMeasurement = bimComponents?.get(LengthMeasurement)\r\n const hoverHandler = bimComponents?.get(OBF.Hoverer)\r\n\r\n const setCursor = (cursor: CursorType) => {\r\n if (!bimComponents) return\r\n const currentCursor = bimComponents.get(Cursor)\r\n if (!currentCursor) return\r\n currentCursor.cursor = cursor\r\n }\r\n\r\n const toolId = tool.id\r\n const { currentToolId } = toolsState.tools\r\n const setTools = (currentToolId: ToolbarToolType) => {\r\n toolsDispatch({\r\n type: 'SET-TOOL',\r\n payload: { currentToolId },\r\n })\r\n }\r\n\r\n // When current tool changes\r\n React.useEffect(() => {\r\n setActive(currentToolId === toolId)\r\n\r\n // Disable measurement when tool is deactivated\r\n if (currentToolId !== toolId && lengthMeasurement) {\r\n lengthMeasurement.enabled = false\r\n if (hoverHandler) {\r\n hoverHandler.enabled = true\r\n }\r\n }\r\n }, [currentToolId, toolId, lengthMeasurement])\r\n\r\n // Optional: Listen to measurement creation events\r\n React.useEffect(() => {\r\n if (!lengthMeasurement) return\r\n\r\n const handleMeasurementCreated = () => {\r\n // You can add custom logic here when a measurement is created\r\n }\r\n\r\n lengthMeasurement.onDimensionCreate.add(handleMeasurementCreated)\r\n\r\n return () => {\r\n lengthMeasurement.onDimensionCreate.remove(handleMeasurementCreated)\r\n }\r\n }, [lengthMeasurement])\r\n\r\n const handleMeasureTypeChange = (type: MeasureType) => {\r\n if (!lengthMeasurement) return\r\n\r\n // Set the tool as active\r\n setTools(toolId)\r\n if (hoverHandler) {\r\n hoverHandler.enabled = false\r\n }\r\n\r\n // Enable the measurement component and set measurement mode\r\n if (type === 'free') {\r\n lengthMeasurement.createFreeMeasurements()\r\n }\r\n if (type === 'edge') {\r\n lengthMeasurement.createEdgeMeasurements()\r\n }\r\n\r\n setCursor('crosshair')\r\n }\r\n\r\n // Clear measurements function\r\n const clearMeasurements = () => {\r\n if (lengthMeasurement) {\r\n lengthMeasurement.deleteAll()\r\n lengthMeasurement.enabled = false\r\n }\r\n if (hoverHandler) {\r\n hoverHandler.enabled = true\r\n }\r\n setCursor('')\r\n }\r\n\r\n return (\r\n <ToolbarSubmenu tool={tool}>\r\n <DropdownMenuItem onClick={() => handleMeasureTypeChange('free')} >\r\n <LR.Ruler />\r\n <span>{t('free')}</span>\r\n </DropdownMenuItem>\r\n <DropdownMenuItem onClick={() => handleMeasureTypeChange('edge')} >\r\n <LR.RulerDimensionLine />\r\n <span>{t('edge')}</span>\r\n </DropdownMenuItem>\r\n <DropdownMenuItem onClick={() => handleMeasureTypeChange('area')} disabled={true}>\r\n <LR.SquareDashed />\r\n <span>{t('area')}</span>\r\n </DropdownMenuItem>\r\n <DropdownMenuItem onClick={() => handleMeasureTypeChange('volume')} disabled={true}>\r\n <LR.Box />\r\n <span>{t('volume')}</span>\r\n </DropdownMenuItem>\r\n <Dropd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,oBAAiB,SAAS,MAAM,wBAAwB,QAAQ,GAAG,UAAU,MAC5E;AAAA,0BAAC,GAAG,KAAH,EAAO;AAAA,MACR,oBAAC,UAAM,YAAE,QAAQ,GAAE;AAAA,OACrB;AAAA,IACA,qBAAC,oBAAiB,SAAS,mBACzB;AAAA,0BAAC,GAAG,GAAH,EAAK;AAAA,MACN,oBAAC,UAAM,YAAE,OAAO,GAAE;AAAA,OACpB;AAAA,KACF;AAEJ;","names":["currentToolId"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapViewer.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/viewers/map/MapViewer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAkBzB,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,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,SAAS,CAAC,EAAE,KAAc,EAAE,MAAe,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"MapViewer.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/viewers/map/MapViewer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAA;AAkBzB,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,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,SAAS,CAAC,EAAE,KAAc,EAAE,MAAe,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,KAAK,qBAuL5G"}
|