@geode/opengeodeweb-front 10.43.2 → 10.44.0-rc.10
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/.build/server/utils/cleanup.js +7 -2
- package/.build/server/utils/microservices.js +9 -81
- package/.build/server/utils/microservices_process.js +85 -0
- package/.build/server/utils/scripts.js +34 -23
- package/.build/server/utils/typed_handler.js +5 -1
- package/.build/server/utils/ws_client.js +7 -2
- package/.build/shared/utils/fetch_raw.js +2 -2
- package/.build/shared/utils/parse_boolean.js +2 -1
- package/app/assets/geode_objects.ts +1 -0
- package/app/components/BasemapAttribution.vue +28 -0
- package/app/components/ClippingPlanes.vue +22 -78
- package/app/components/CrsSelector.vue +53 -46
- package/app/components/DragAndDrop.vue +16 -79
- package/app/components/FeedBack/Snackers.vue +27 -0
- package/app/components/FileSelector.vue +9 -6
- package/app/components/HybridViewerTooltip.vue +8 -2
- package/app/components/MissingFilesSelector.vue +40 -23
- package/app/components/ObjectSelector.vue +34 -20
- package/app/components/ProjectCrs.vue +37 -0
- package/app/components/Screenshot.vue +17 -59
- package/app/components/ThresholdCard.vue +205 -0
- package/app/components/ThresholdFilter.vue +81 -216
- package/app/components/ViewToolbar.vue +15 -231
- package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
- package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
- package/app/components/Viewer/ContextMenu/CircularItems.vue +1 -2
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +11 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -7
- package/app/components/Viewer/ContextMenu/InfoCard.vue +30 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
- package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
- package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +227 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
- package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +14 -12
- package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
- package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +15 -294
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
- package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +15 -427
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
- package/app/components/Viewer/Generic/Model/ModelCardTabs.vue +35 -0
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +17 -5
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +16 -12
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +71 -1
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +55 -10
- package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
- package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
- package/app/components/Viewer/Options/ColorPicker.vue +4 -1
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +48 -74
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
- package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
- package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
- package/app/components/Viewer/Scene/BackgroundOptions.vue +37 -0
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +48 -0
- package/app/components/Viewer/Scene/TextOptions.vue +63 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
- package/app/components/Viewer/Surface/PolygonsColoring.vue +224 -0
- package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
- package/app/components/Viewer/Ui.vue +9 -0
- package/app/components/csv-preview/CsvPreviewer.vue +4 -1
- package/app/composables/attribute_coloring_style.ts +8 -2
- package/app/composables/attribute_selector.ts +126 -0
- package/app/composables/batch_style_model.ts +34 -0
- package/app/composables/clipping_slices.ts +166 -0
- package/app/composables/global_attribute_style.ts +4 -3
- package/app/composables/hover_highlight.ts +19 -18
- package/app/composables/live_data_item.ts +39 -0
- package/app/composables/model_tabs.ts +86 -0
- package/app/composables/overlapping_picker_menu.ts +43 -0
- package/app/composables/project_manager.ts +5 -81
- package/app/composables/project_manager_helpers/reset.ts +34 -0
- package/app/composables/project_manager_helpers/restore.ts +67 -0
- package/app/composables/project_manager_helpers/types.ts +24 -0
- package/app/composables/project_manager_helpers/viewer_session.ts +25 -0
- package/app/composables/stepper_tree.ts +10 -2
- package/app/composables/tree_filter.ts +11 -2
- package/app/composables/tree_keyboard_nav.ts +4 -2
- package/app/composables/use_overlapping_picker.ts +30 -42
- package/app/composables/view_toolbar_options.ts +126 -0
- package/app/composables/view_toolbar_tool_options.ts +115 -0
- package/app/composables/view_toolbar_tools.ts +108 -0
- package/app/composables/viewer_context_menu.ts +19 -1
- package/app/composables/virtual_tree.ts +20 -131
- package/app/composables/virtual_tree_flatten.ts +109 -0
- package/app/composables/virtual_tree_types.ts +81 -0
- package/app/stores/app.ts +8 -55
- package/app/stores/app_helpers/extension.ts +90 -51
- package/app/stores/app_helpers/registry.ts +69 -0
- package/app/stores/basemap.ts +52 -0
- package/app/stores/basemap_detail.ts +51 -0
- package/app/stores/basemap_helpers/builds.ts +158 -0
- package/app/stores/basemap_helpers/detail_layers.ts +72 -0
- package/app/stores/basemap_helpers/detail_map.ts +62 -0
- package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
- package/app/stores/basemap_helpers/detail_view.ts +94 -0
- package/app/stores/basemap_helpers/extent.ts +40 -0
- package/app/stores/basemap_helpers/georeferenced.ts +50 -0
- package/app/stores/basemap_helpers/layers.ts +66 -0
- package/app/stores/basemap_helpers/settings.ts +87 -0
- package/app/stores/basemap_helpers/viewer.ts +114 -0
- package/app/stores/crs.ts +136 -0
- package/app/stores/data.ts +24 -1
- package/app/stores/data_style.ts +8 -0
- package/app/stores/feedback.ts +12 -2
- package/app/stores/hybrid_viewer.ts +1 -1
- package/app/stores/infra.ts +26 -21
- package/app/stores/menu.ts +8 -124
- package/app/stores/menu_helpers/basemap.ts +10 -0
- package/app/stores/menu_helpers/menus_data.ts +27 -0
- package/app/stores/menu_helpers/mesh/edged_curve.ts +12 -0
- package/app/stores/menu_helpers/mesh/grid.ts +24 -0
- package/app/stores/menu_helpers/mesh/point_set.ts +11 -0
- package/app/stores/menu_helpers/mesh/solid.ts +29 -0
- package/app/stores/menu_helpers/mesh/surface.ts +22 -0
- package/app/stores/menu_helpers/model.ts +25 -0
- package/app/stores/menu_helpers/scene.ts +10 -0
- package/app/stores/menu_helpers/types.ts +5 -0
- package/app/stores/treeview.ts +17 -10
- package/app/stores/viewer.ts +17 -79
- package/app/stores/viewer_helpers/actions.ts +68 -0
- package/app/stores/viewer_helpers/request.ts +61 -0
- package/app/utils/basemap_tree.ts +76 -0
- package/app/utils/clipping_planes.ts +4 -131
- package/app/utils/clipping_planes_scene.ts +131 -0
- package/app/utils/color_picker.ts +18 -15
- package/app/utils/coloring_styles.ts +101 -0
- package/app/utils/crs.ts +38 -0
- package/app/utils/default_styles/constants.ts +10 -0
- package/app/utils/default_styles/index.ts +17 -1
- package/app/utils/default_styles/mesh_components.ts +168 -0
- package/app/utils/default_styles/meshes.ts +13 -153
- package/app/utils/default_styles/model_components.ts +170 -0
- package/app/utils/default_styles/models.ts +16 -153
- package/app/utils/drag_and_drop.ts +80 -0
- package/app/utils/extension.ts +1 -1
- package/app/utils/import_workflow.ts +26 -11
- package/app/utils/model_component_coloring.ts +46 -0
- package/app/utils/threshold.ts +33 -0
- package/app/utils/threshold_sources.ts +51 -0
- package/app/utils/treeview.ts +12 -1
- package/app/utils/upload_path.ts +15 -9
- package/app/utils/visible_map_area.ts +129 -0
- package/internal/database/base_database.ts +2 -0
- package/internal/database/database.ts +47 -29
- package/internal/database/tables/scene_style.ts +6 -0
- package/internal/stores/data_style/mesh/base_style.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
- package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
- package/internal/stores/data_style/mesh/cells/color.ts +3 -1
- package/internal/stores/data_style/mesh/cells/index.ts +17 -1
- package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/color.ts +3 -1
- package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
- package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/index.ts +17 -1
- package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/index.ts +2 -57
- package/internal/stores/data_style/mesh/points/color.ts +3 -1
- package/internal/stores/data_style/mesh/points/index.ts +17 -1
- package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
- package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
- package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
- package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
- package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
- package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
- package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
- package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
- package/internal/stores/data_style/model/blocks/color.ts +58 -57
- package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/blocks/index.ts +12 -140
- package/internal/stores/data_style/model/blocks/polyhedron.ts +102 -54
- package/internal/stores/data_style/model/blocks/vertex.ts +102 -54
- package/internal/stores/data_style/model/color.ts +25 -26
- package/internal/stores/data_style/model/common.ts +10 -119
- package/internal/stores/data_style/model/common_mutations.ts +184 -0
- package/internal/stores/data_style/model/corners/index.ts +85 -78
- package/internal/stores/data_style/model/corners/vertex.ts +97 -49
- package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
- package/internal/stores/data_style/model/lines/color.ts +53 -40
- package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/lines/edge.ts +102 -54
- package/internal/stores/data_style/model/lines/index.ts +10 -134
- package/internal/stores/data_style/model/lines/vertex.ts +102 -54
- package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
- package/internal/stores/data_style/model/surfaces/color.ts +68 -56
- package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/surfaces/index.ts +16 -160
- package/internal/stores/data_style/model/surfaces/polygon.ts +94 -46
- package/internal/stores/data_style/model/surfaces/vertex.ts +94 -46
- package/internal/stores/data_style/model/visibility.ts +3 -156
- package/internal/stores/data_style/model/visibility_dispatch.ts +110 -0
- package/internal/stores/data_style/scene.ts +118 -0
- package/internal/stores/data_style/state.ts +5 -181
- package/internal/stores/data_style/state_shared.ts +199 -0
- package/internal/stores/data_style/types.ts +24 -1
- package/internal/stores/hybrid_viewer/brightness.ts +8 -2
- package/internal/stores/hybrid_viewer/camera.ts +7 -161
- package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
- package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
- package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
- package/internal/stores/hybrid_viewer/filters.ts +54 -11
- package/internal/stores/hybrid_viewer/highlight.ts +80 -63
- package/internal/stores/hybrid_viewer/ruler.ts +4 -3
- package/internal/stores/hybrid_viewer/scene.ts +34 -26
- package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
- package/internal/utils/ws_client.ts +8 -1
- package/package.json +5 -5
- package/server/api/local/extensions/run.post.ts +6 -4
- package/server/api/local/extensions/upload.put.ts +47 -20
- package/server/utils/cleanup.ts +12 -2
- package/server/utils/microservices.ts +10 -102
- package/server/utils/microservices_process.ts +127 -0
- package/server/utils/scripts.ts +35 -30
- package/server/utils/typed_handler.ts +8 -1
- package/server/utils/ws_client.ts +15 -2
- package/shared/utils/fetch_raw.ts +2 -2
- package/shared/utils/parse_boolean.ts +4 -1
- package/app/components/Viewer/Options/OptionsSection.vue +0 -76
|
@@ -118,12 +118,28 @@ interface UseModelSurfacesPolygonAttributeReturn {
|
|
|
118
118
|
) => Promise<void>;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
type ModelSurfacesPolygonAttributeGetters = Pick<
|
|
122
|
+
UseModelSurfacesPolygonAttributeReturn,
|
|
123
|
+
| "modelSurfacesPolygonAttributeStoredConfig"
|
|
124
|
+
| "modelSurfacesPolygonAttributeName"
|
|
125
|
+
| "modelSurfacesPolygonAttributeItem"
|
|
126
|
+
| "modelSurfacesPolygonAttributeRange"
|
|
127
|
+
| "modelSurfacesPolygonAttributeColorMap"
|
|
128
|
+
| "modelSurfacesPolygonAttributeNoDataColor"
|
|
129
|
+
| "modelSurfacesPolygonAttributeTimeStep"
|
|
130
|
+
> & {
|
|
131
|
+
modelSurfacesPolygonAttributeLastItem: (
|
|
132
|
+
modelId: string,
|
|
133
|
+
componentId: string | undefined,
|
|
134
|
+
name: string | undefined,
|
|
135
|
+
) => number;
|
|
136
|
+
};
|
|
137
|
+
|
|
121
138
|
// oxlint-disable-next-line max-lines-per-function
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
const viewerStore = useViewerStore();
|
|
139
|
+
function useModelSurfacesPolygonAttributeGetters(
|
|
140
|
+
modelSurfacesCommonStyle: ReturnType<typeof useModelSurfacesCommonStyle>,
|
|
141
|
+
): ModelSurfacesPolygonAttributeGetters {
|
|
142
|
+
const { attributeTimeStep } = useAttributeTimeStepStyle();
|
|
127
143
|
function modelSurfacesPolygonAttribute(modelId: string, surfaceId?: string): AttributeState {
|
|
128
144
|
return (
|
|
129
145
|
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring.polygon shape is defined by the data style schema.
|
|
@@ -149,37 +165,6 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
149
165
|
no_data_color: DEFAULT_NO_DATA_COLOR,
|
|
150
166
|
};
|
|
151
167
|
}
|
|
152
|
-
async function mutateModelSurfacesPolygonStyle(
|
|
153
|
-
modelId: string,
|
|
154
|
-
surfaceIds: string[],
|
|
155
|
-
values: Record<string, unknown>,
|
|
156
|
-
): Promise<void> {
|
|
157
|
-
const tasks: Promise<void>[] = [
|
|
158
|
-
modelSurfacesCommonStyle.mutateModelSurfacesColoring(modelId, surfaceIds, {
|
|
159
|
-
polygon: values,
|
|
160
|
-
}),
|
|
161
|
-
];
|
|
162
|
-
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
163
|
-
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
164
|
-
tasks.push(
|
|
165
|
-
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
166
|
-
polygon: values,
|
|
167
|
-
}),
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
await Promise.all(tasks);
|
|
171
|
-
}
|
|
172
|
-
async function setModelSurfacesPolygonAttributeStoredConfig(
|
|
173
|
-
modelId: string,
|
|
174
|
-
surfaceIds: string[],
|
|
175
|
-
name: string | undefined,
|
|
176
|
-
item: number | undefined,
|
|
177
|
-
config: Partial<AttributeStoredConfig>,
|
|
178
|
-
): Promise<void> {
|
|
179
|
-
await mutateModelSurfacesPolygonStyle(modelId, surfaceIds, {
|
|
180
|
-
storedConfigs: { [name ?? ""]: { lastItem: item, [item ?? 0]: config } },
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
168
|
function modelSurfacesPolygonAttributeName(
|
|
184
169
|
modelId: string,
|
|
185
170
|
surfaceId?: string,
|
|
@@ -243,6 +228,65 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
243
228
|
modelSurfacesPolygonAttribute(modelId, surfaceId).name,
|
|
244
229
|
);
|
|
245
230
|
}
|
|
231
|
+
return {
|
|
232
|
+
modelSurfacesPolygonAttributeStoredConfig,
|
|
233
|
+
modelSurfacesPolygonAttributeName,
|
|
234
|
+
modelSurfacesPolygonAttributeLastItem,
|
|
235
|
+
modelSurfacesPolygonAttributeItem,
|
|
236
|
+
modelSurfacesPolygonAttributeRange,
|
|
237
|
+
modelSurfacesPolygonAttributeColorMap,
|
|
238
|
+
modelSurfacesPolygonAttributeNoDataColor,
|
|
239
|
+
modelSurfacesPolygonAttributeTimeStep,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
244
|
+
function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeReturn {
|
|
245
|
+
const { setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
|
|
246
|
+
const dataStore = useDataStore();
|
|
247
|
+
const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
|
|
248
|
+
const {
|
|
249
|
+
modelSurfacesPolygonAttributeStoredConfig,
|
|
250
|
+
modelSurfacesPolygonAttributeName,
|
|
251
|
+
modelSurfacesPolygonAttributeLastItem,
|
|
252
|
+
modelSurfacesPolygonAttributeItem,
|
|
253
|
+
modelSurfacesPolygonAttributeRange,
|
|
254
|
+
modelSurfacesPolygonAttributeColorMap,
|
|
255
|
+
modelSurfacesPolygonAttributeNoDataColor,
|
|
256
|
+
modelSurfacesPolygonAttributeTimeStep,
|
|
257
|
+
} = useModelSurfacesPolygonAttributeGetters(modelSurfacesCommonStyle);
|
|
258
|
+
const viewerStore = useViewerStore();
|
|
259
|
+
async function mutateModelSurfacesPolygonStyle(
|
|
260
|
+
modelId: string,
|
|
261
|
+
surfaceIds: string[],
|
|
262
|
+
values: Record<string, unknown>,
|
|
263
|
+
): Promise<void> {
|
|
264
|
+
const tasks: Promise<void>[] = [
|
|
265
|
+
modelSurfacesCommonStyle.mutateModelSurfacesColoring(modelId, surfaceIds, {
|
|
266
|
+
polygon: values,
|
|
267
|
+
}),
|
|
268
|
+
];
|
|
269
|
+
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
270
|
+
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
271
|
+
tasks.push(
|
|
272
|
+
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
273
|
+
polygon: values,
|
|
274
|
+
}),
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
await Promise.all(tasks);
|
|
278
|
+
}
|
|
279
|
+
async function setModelSurfacesPolygonAttributeStoredConfig(
|
|
280
|
+
modelId: string,
|
|
281
|
+
surfaceIds: string[],
|
|
282
|
+
name: string | undefined,
|
|
283
|
+
item: number | undefined,
|
|
284
|
+
config: Partial<AttributeStoredConfig>,
|
|
285
|
+
): Promise<void> {
|
|
286
|
+
await mutateModelSurfacesPolygonStyle(modelId, surfaceIds, {
|
|
287
|
+
storedConfigs: { [name ?? ""]: { lastItem: item, [item ?? 0]: config } },
|
|
288
|
+
});
|
|
289
|
+
}
|
|
246
290
|
async function setModelSurfacesPolygonAttribute(
|
|
247
291
|
modelId: string,
|
|
248
292
|
surfaceIds: string[],
|
|
@@ -333,16 +377,20 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
333
377
|
reapplySameSeries(
|
|
334
378
|
await dataStore.getSurfacesGeodeIds(modelId),
|
|
335
379
|
surfaceIds,
|
|
336
|
-
(id) =>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
380
|
+
(id) => {
|
|
381
|
+
if (
|
|
382
|
+
modelSurfacesCommonStyle.modelSurfaceColoring(modelId, id).active === "polygon" &&
|
|
383
|
+
modelSurfacesPolygonAttributeName(modelId, id) === name
|
|
384
|
+
) {
|
|
385
|
+
return [
|
|
386
|
+
modelSurfacesPolygonAttributeItem(modelId, id),
|
|
387
|
+
modelSurfacesPolygonAttributeRange(modelId, id),
|
|
388
|
+
modelSurfacesPolygonAttributeColorMap(modelId, id),
|
|
389
|
+
JSON.stringify(modelSurfacesPolygonAttributeNoDataColor(modelId, id)),
|
|
390
|
+
].join("|");
|
|
391
|
+
}
|
|
392
|
+
return undefined;
|
|
393
|
+
},
|
|
346
394
|
async (ids) => {
|
|
347
395
|
await applyPolygonAttribute(modelId, ids);
|
|
348
396
|
},
|
|
@@ -112,12 +112,28 @@ interface UseModelSurfacesVertexAttributeReturn {
|
|
|
112
112
|
) => Promise<unknown>;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
type ModelSurfacesVertexAttributeGetters = Pick<
|
|
116
|
+
UseModelSurfacesVertexAttributeReturn,
|
|
117
|
+
| "modelSurfacesVertexAttributeStoredConfig"
|
|
118
|
+
| "modelSurfacesVertexAttributeName"
|
|
119
|
+
| "modelSurfacesVertexAttributeItem"
|
|
120
|
+
| "modelSurfacesVertexAttributeRange"
|
|
121
|
+
| "modelSurfacesVertexAttributeColorMap"
|
|
122
|
+
| "modelSurfacesVertexAttributeNoDataColor"
|
|
123
|
+
| "modelSurfacesVertexAttributeTimeStep"
|
|
124
|
+
> & {
|
|
125
|
+
modelSurfacesVertexAttributeLastItem: (
|
|
126
|
+
modelId: string,
|
|
127
|
+
componentId: string | undefined,
|
|
128
|
+
name: string | undefined,
|
|
129
|
+
) => number;
|
|
130
|
+
};
|
|
131
|
+
|
|
115
132
|
// oxlint-disable-next-line max-lines-per-function
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
const viewerStore = useViewerStore();
|
|
133
|
+
function useModelSurfacesVertexAttributeGetters(
|
|
134
|
+
modelSurfacesCommonStyle: ReturnType<typeof useModelSurfacesCommonStyle>,
|
|
135
|
+
): ModelSurfacesVertexAttributeGetters {
|
|
136
|
+
const { attributeTimeStep } = useAttributeTimeStepStyle();
|
|
121
137
|
function modelSurfacesVertexAttribute(modelId: string, surfaceId?: string): AttributeState {
|
|
122
138
|
return (
|
|
123
139
|
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring.vertex shape is defined by the data style schema.
|
|
@@ -143,37 +159,6 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
143
159
|
no_data_color: DEFAULT_NO_DATA_COLOR,
|
|
144
160
|
};
|
|
145
161
|
}
|
|
146
|
-
async function mutateModelSurfacesVertexStyle(
|
|
147
|
-
modelId: string,
|
|
148
|
-
surfaceIds: string[],
|
|
149
|
-
values: Record<string, unknown>,
|
|
150
|
-
): Promise<void> {
|
|
151
|
-
const tasks: Promise<void>[] = [
|
|
152
|
-
modelSurfacesCommonStyle.mutateModelSurfacesColoring(modelId, surfaceIds, {
|
|
153
|
-
vertex: values,
|
|
154
|
-
}),
|
|
155
|
-
];
|
|
156
|
-
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
157
|
-
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
158
|
-
tasks.push(
|
|
159
|
-
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
160
|
-
vertex: values,
|
|
161
|
-
}),
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
await Promise.all(tasks);
|
|
165
|
-
}
|
|
166
|
-
async function setModelSurfacesVertexAttributeStoredConfig(
|
|
167
|
-
modelId: string,
|
|
168
|
-
surfaceIds: string[],
|
|
169
|
-
name: string | undefined,
|
|
170
|
-
item: number | undefined,
|
|
171
|
-
config: Partial<AttributeStoredConfig>,
|
|
172
|
-
): Promise<void> {
|
|
173
|
-
await mutateModelSurfacesVertexStyle(modelId, surfaceIds, {
|
|
174
|
-
storedConfigs: { [name ?? ""]: { lastItem: item, [item ?? 0]: config } },
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
162
|
function modelSurfacesVertexAttributeName(
|
|
178
163
|
modelId: string,
|
|
179
164
|
surfaceId?: string,
|
|
@@ -234,6 +219,65 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
234
219
|
modelSurfacesVertexAttribute(modelId, surfaceId).name,
|
|
235
220
|
);
|
|
236
221
|
}
|
|
222
|
+
return {
|
|
223
|
+
modelSurfacesVertexAttributeStoredConfig,
|
|
224
|
+
modelSurfacesVertexAttributeName,
|
|
225
|
+
modelSurfacesVertexAttributeLastItem,
|
|
226
|
+
modelSurfacesVertexAttributeItem,
|
|
227
|
+
modelSurfacesVertexAttributeRange,
|
|
228
|
+
modelSurfacesVertexAttributeColorMap,
|
|
229
|
+
modelSurfacesVertexAttributeNoDataColor,
|
|
230
|
+
modelSurfacesVertexAttributeTimeStep,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
235
|
+
function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeReturn {
|
|
236
|
+
const { setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
|
|
237
|
+
const dataStore = useDataStore();
|
|
238
|
+
const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
|
|
239
|
+
const {
|
|
240
|
+
modelSurfacesVertexAttributeStoredConfig,
|
|
241
|
+
modelSurfacesVertexAttributeName,
|
|
242
|
+
modelSurfacesVertexAttributeLastItem,
|
|
243
|
+
modelSurfacesVertexAttributeItem,
|
|
244
|
+
modelSurfacesVertexAttributeRange,
|
|
245
|
+
modelSurfacesVertexAttributeColorMap,
|
|
246
|
+
modelSurfacesVertexAttributeNoDataColor,
|
|
247
|
+
modelSurfacesVertexAttributeTimeStep,
|
|
248
|
+
} = useModelSurfacesVertexAttributeGetters(modelSurfacesCommonStyle);
|
|
249
|
+
const viewerStore = useViewerStore();
|
|
250
|
+
async function mutateModelSurfacesVertexStyle(
|
|
251
|
+
modelId: string,
|
|
252
|
+
surfaceIds: string[],
|
|
253
|
+
values: Record<string, unknown>,
|
|
254
|
+
): Promise<void> {
|
|
255
|
+
const tasks: Promise<void>[] = [
|
|
256
|
+
modelSurfacesCommonStyle.mutateModelSurfacesColoring(modelId, surfaceIds, {
|
|
257
|
+
vertex: values,
|
|
258
|
+
}),
|
|
259
|
+
];
|
|
260
|
+
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
261
|
+
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
262
|
+
tasks.push(
|
|
263
|
+
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
264
|
+
vertex: values,
|
|
265
|
+
}),
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
await Promise.all(tasks);
|
|
269
|
+
}
|
|
270
|
+
async function setModelSurfacesVertexAttributeStoredConfig(
|
|
271
|
+
modelId: string,
|
|
272
|
+
surfaceIds: string[],
|
|
273
|
+
name: string | undefined,
|
|
274
|
+
item: number | undefined,
|
|
275
|
+
config: Partial<AttributeStoredConfig>,
|
|
276
|
+
): Promise<void> {
|
|
277
|
+
await mutateModelSurfacesVertexStyle(modelId, surfaceIds, {
|
|
278
|
+
storedConfigs: { [name ?? ""]: { lastItem: item, [item ?? 0]: config } },
|
|
279
|
+
});
|
|
280
|
+
}
|
|
237
281
|
async function setModelSurfacesVertexAttribute(
|
|
238
282
|
modelId: string,
|
|
239
283
|
surfaceIds: string[],
|
|
@@ -328,16 +372,20 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
328
372
|
reapplySameSeries(
|
|
329
373
|
await dataStore.getSurfacesGeodeIds(modelId),
|
|
330
374
|
surfaceIds,
|
|
331
|
-
(id) =>
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
375
|
+
(id) => {
|
|
376
|
+
if (
|
|
377
|
+
modelSurfacesCommonStyle.modelSurfaceColoring(modelId, id).active === "vertex" &&
|
|
378
|
+
modelSurfacesVertexAttributeName(modelId, id) === name
|
|
379
|
+
) {
|
|
380
|
+
return [
|
|
381
|
+
modelSurfacesVertexAttributeItem(modelId, id),
|
|
382
|
+
modelSurfacesVertexAttributeRange(modelId, id),
|
|
383
|
+
modelSurfacesVertexAttributeColorMap(modelId, id),
|
|
384
|
+
JSON.stringify(modelSurfacesVertexAttributeNoDataColor(modelId, id)),
|
|
385
|
+
].join("|");
|
|
386
|
+
}
|
|
387
|
+
return undefined;
|
|
388
|
+
},
|
|
341
389
|
async (ids) => {
|
|
342
390
|
await applyVertexAttribute(modelId, ids);
|
|
343
391
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ComponentStyleFunctions, dispatchToComponentTypes } from "./visibility_dispatch";
|
|
1
2
|
import { MESH_COMPONENT_TYPES } from "@ogw_front/utils/default_styles";
|
|
2
3
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
3
4
|
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
@@ -7,162 +8,7 @@ import { useModelSelection } from "./selection";
|
|
|
7
8
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
8
9
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
9
10
|
|
|
10
|
-
// The four per-component-type style composables (Surface/Line/Block/Corner) each expose a different, large set of methods (color, visibility, per-attribute-kind getters/setters...). This module only cares about looking a handful of them up dynamically by name, so a precise structural type for componentStyleFunctions isn't worth modelling here; `any` keeps the dynamic dispatch table honest about that.
|
|
11
|
-
// oxlint-disable-next-line no-explicit-any
|
|
12
|
-
type ComponentStyleFunctions = Record<"Surface" | "Line" | "Block" | "Corner", any>;
|
|
13
|
-
|
|
14
|
-
interface ModelComponent {
|
|
15
|
-
geode_id: string;
|
|
16
|
-
type: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function callComponentStyleFunction(
|
|
20
|
-
// oxlint-disable-next-line no-explicit-any
|
|
21
|
-
target: any,
|
|
22
|
-
method: string,
|
|
23
|
-
...args: unknown[]
|
|
24
|
-
): Promise<unknown> {
|
|
25
|
-
// oxlint-disable-next-line no-unsafe-call, no-unsafe-member-access, no-unsafe-argument, no-unsafe-assignment -- ComponentStyleFunctions is deliberately dynamically typed; see comment above.
|
|
26
|
-
const result = await target[method](...args);
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
11
|
const model_schemas = viewer_schemas.opengeodeweb_viewer.model;
|
|
31
|
-
async function getModelComponentsMap(
|
|
32
|
-
modelId: string,
|
|
33
|
-
): Promise<{ allComponents: ModelComponent[]; componentsMap: Record<string, ModelComponent> }> {
|
|
34
|
-
const dataStore = useDataStore();
|
|
35
|
-
const results = await Promise.all(
|
|
36
|
-
MESH_COMPONENT_TYPES.map(async (type) => {
|
|
37
|
-
const geodeIds = await dataStore.getMeshComponentGeodeIds(modelId, type);
|
|
38
|
-
return geodeIds.map((geode_id): ModelComponent => ({
|
|
39
|
-
geode_id,
|
|
40
|
-
type,
|
|
41
|
-
}));
|
|
42
|
-
}),
|
|
43
|
-
);
|
|
44
|
-
const allComponents = results.flat();
|
|
45
|
-
return {
|
|
46
|
-
allComponents,
|
|
47
|
-
componentsMap: Object.fromEntries(
|
|
48
|
-
allComponents.map((component): [string, ModelComponent] => [component.geode_id, component]),
|
|
49
|
-
),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async function dispatchToComponentTypes(
|
|
53
|
-
modelId: string,
|
|
54
|
-
componentIds: string[],
|
|
55
|
-
action: string,
|
|
56
|
-
{ componentStyleFunctions }: { componentStyleFunctions: ComponentStyleFunctions },
|
|
57
|
-
...args: unknown[]
|
|
58
|
-
): Promise<unknown[]> {
|
|
59
|
-
const { componentsMap } = await getModelComponentsMap(modelId);
|
|
60
|
-
const idsByComponent: { Block: string[]; Surface: string[]; Line: string[]; Corner: string[] } = {
|
|
61
|
-
Block: [],
|
|
62
|
-
Surface: [],
|
|
63
|
-
Line: [],
|
|
64
|
-
Corner: [],
|
|
65
|
-
};
|
|
66
|
-
for (const id of componentIds) {
|
|
67
|
-
const type = componentsMap[id]?.type;
|
|
68
|
-
if (type !== undefined && type in idsByComponent) {
|
|
69
|
-
(idsByComponent as Record<string, string[]>)[type]?.push(id);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const promises: Promise<unknown>[] = [];
|
|
73
|
-
if (action === "Visibility") {
|
|
74
|
-
if (idsByComponent.Block.length > 0) {
|
|
75
|
-
promises.push(
|
|
76
|
-
callComponentStyleFunction(
|
|
77
|
-
componentStyleFunctions.Block,
|
|
78
|
-
"setModelBlocksVisibility",
|
|
79
|
-
modelId,
|
|
80
|
-
idsByComponent.Block,
|
|
81
|
-
...args,
|
|
82
|
-
),
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
if (idsByComponent.Surface.length > 0) {
|
|
86
|
-
promises.push(
|
|
87
|
-
callComponentStyleFunction(
|
|
88
|
-
componentStyleFunctions.Surface,
|
|
89
|
-
"setModelSurfacesVisibility",
|
|
90
|
-
modelId,
|
|
91
|
-
idsByComponent.Surface,
|
|
92
|
-
...args,
|
|
93
|
-
),
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
if (idsByComponent.Line.length > 0) {
|
|
97
|
-
promises.push(
|
|
98
|
-
callComponentStyleFunction(
|
|
99
|
-
componentStyleFunctions.Line,
|
|
100
|
-
"setModelLinesVisibility",
|
|
101
|
-
modelId,
|
|
102
|
-
idsByComponent.Line,
|
|
103
|
-
...args,
|
|
104
|
-
),
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
if (idsByComponent.Corner.length > 0) {
|
|
108
|
-
promises.push(
|
|
109
|
-
callComponentStyleFunction(
|
|
110
|
-
componentStyleFunctions.Corner,
|
|
111
|
-
"setModelCornersVisibility",
|
|
112
|
-
modelId,
|
|
113
|
-
idsByComponent.Corner,
|
|
114
|
-
...args,
|
|
115
|
-
),
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
} else if (action === "Color") {
|
|
119
|
-
if (idsByComponent.Block.length > 0) {
|
|
120
|
-
promises.push(
|
|
121
|
-
callComponentStyleFunction(
|
|
122
|
-
componentStyleFunctions.Block,
|
|
123
|
-
"setModelBlocksColor",
|
|
124
|
-
modelId,
|
|
125
|
-
idsByComponent.Block,
|
|
126
|
-
...args,
|
|
127
|
-
),
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
if (idsByComponent.Surface.length > 0) {
|
|
131
|
-
promises.push(
|
|
132
|
-
callComponentStyleFunction(
|
|
133
|
-
componentStyleFunctions.Surface,
|
|
134
|
-
"setModelSurfacesColor",
|
|
135
|
-
modelId,
|
|
136
|
-
idsByComponent.Surface,
|
|
137
|
-
...args,
|
|
138
|
-
),
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
if (idsByComponent.Line.length > 0) {
|
|
142
|
-
promises.push(
|
|
143
|
-
callComponentStyleFunction(
|
|
144
|
-
componentStyleFunctions.Line,
|
|
145
|
-
"setModelLinesColor",
|
|
146
|
-
modelId,
|
|
147
|
-
idsByComponent.Line,
|
|
148
|
-
...args,
|
|
149
|
-
),
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
if (idsByComponent.Corner.length > 0) {
|
|
153
|
-
promises.push(
|
|
154
|
-
callComponentStyleFunction(
|
|
155
|
-
componentStyleFunctions.Corner,
|
|
156
|
-
"setModelCornersColor",
|
|
157
|
-
modelId,
|
|
158
|
-
idsByComponent.Corner,
|
|
159
|
-
...args,
|
|
160
|
-
),
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return Promise.all(promises);
|
|
165
|
-
}
|
|
166
12
|
interface UseModelVisibilityStyleReturn {
|
|
167
13
|
modelVisibility: (modelId: string) => boolean | undefined;
|
|
168
14
|
setModelVisibility: (modelId: string, visibility: boolean) => Promise<unknown>;
|
|
@@ -284,4 +130,5 @@ function useModelVisibilityStyle(
|
|
|
284
130
|
modelComponentTypeVisibility,
|
|
285
131
|
};
|
|
286
132
|
}
|
|
287
|
-
export {
|
|
133
|
+
export { useModelVisibilityStyle };
|
|
134
|
+
export { getModelComponentsMap, dispatchToComponentTypes } from "./visibility_dispatch";
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { MESH_COMPONENT_TYPES } from "@ogw_front/utils/default_styles";
|
|
2
|
+
import { useDataStore } from "@ogw_front/stores/data";
|
|
3
|
+
|
|
4
|
+
// The four per-component-type style composables (Surface/Line/Block/Corner) each expose a different, large set of methods (color, visibility, per-attribute-kind getters/setters...). This module only cares about looking a handful of them up dynamically by name, so a precise structural type for componentStyleFunctions isn't worth modelling here; `any` keeps the dynamic dispatch table honest about that.
|
|
5
|
+
// oxlint-disable-next-line no-explicit-any
|
|
6
|
+
type ComponentStyleFunctions = Record<"Surface" | "Line" | "Block" | "Corner", any>;
|
|
7
|
+
|
|
8
|
+
interface ModelComponent {
|
|
9
|
+
geode_id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function callComponentStyleFunction(
|
|
14
|
+
// oxlint-disable-next-line no-explicit-any
|
|
15
|
+
target: any,
|
|
16
|
+
method: string,
|
|
17
|
+
...args: unknown[]
|
|
18
|
+
): Promise<unknown> {
|
|
19
|
+
// oxlint-disable-next-line no-unsafe-call, no-unsafe-member-access, no-unsafe-argument, no-unsafe-assignment -- ComponentStyleFunctions is deliberately dynamically typed; see comment above.
|
|
20
|
+
const result = await target[method](...args);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function getModelComponentsMap(
|
|
25
|
+
modelId: string,
|
|
26
|
+
): Promise<{ allComponents: ModelComponent[]; componentsMap: Record<string, ModelComponent> }> {
|
|
27
|
+
const dataStore = useDataStore();
|
|
28
|
+
const results = await Promise.all(
|
|
29
|
+
MESH_COMPONENT_TYPES.map(async (type) => {
|
|
30
|
+
const geodeIds = await dataStore.getMeshComponentGeodeIds(modelId, type);
|
|
31
|
+
return geodeIds.map((geode_id): ModelComponent => ({
|
|
32
|
+
geode_id,
|
|
33
|
+
type,
|
|
34
|
+
}));
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
const allComponents = results.flat();
|
|
38
|
+
return {
|
|
39
|
+
allComponents,
|
|
40
|
+
componentsMap: Object.fromEntries(
|
|
41
|
+
allComponents.map((component): [string, ModelComponent] => [component.geode_id, component]),
|
|
42
|
+
),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const COMPONENT_TYPE_NAMES = ["Block", "Surface", "Line", "Corner"] as const;
|
|
46
|
+
type ComponentTypeName = (typeof COMPONENT_TYPE_NAMES)[number];
|
|
47
|
+
|
|
48
|
+
const DISPATCH_METHODS: Partial<Record<string, Record<ComponentTypeName, string>>> = {
|
|
49
|
+
Visibility: {
|
|
50
|
+
Block: "setModelBlocksVisibility",
|
|
51
|
+
Surface: "setModelSurfacesVisibility",
|
|
52
|
+
Line: "setModelLinesVisibility",
|
|
53
|
+
Corner: "setModelCornersVisibility",
|
|
54
|
+
},
|
|
55
|
+
Color: {
|
|
56
|
+
Block: "setModelBlocksColor",
|
|
57
|
+
Surface: "setModelSurfacesColor",
|
|
58
|
+
Line: "setModelLinesColor",
|
|
59
|
+
Corner: "setModelCornersColor",
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function groupIdsByComponentType(
|
|
64
|
+
componentIds: string[],
|
|
65
|
+
componentsMap: Record<string, ModelComponent>,
|
|
66
|
+
): Record<ComponentTypeName, string[]> {
|
|
67
|
+
const idsByComponent: Record<ComponentTypeName, string[]> = {
|
|
68
|
+
Block: [],
|
|
69
|
+
Surface: [],
|
|
70
|
+
Line: [],
|
|
71
|
+
Corner: [],
|
|
72
|
+
};
|
|
73
|
+
for (const id of componentIds) {
|
|
74
|
+
const type = componentsMap[id]?.type;
|
|
75
|
+
if (type !== undefined && type in idsByComponent) {
|
|
76
|
+
(idsByComponent as Record<string, string[]>)[type]?.push(id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return idsByComponent;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function dispatchToComponentTypes(
|
|
83
|
+
modelId: string,
|
|
84
|
+
componentIds: string[],
|
|
85
|
+
action: string,
|
|
86
|
+
{ componentStyleFunctions }: { componentStyleFunctions: ComponentStyleFunctions },
|
|
87
|
+
...args: unknown[]
|
|
88
|
+
): Promise<unknown[]> {
|
|
89
|
+
const { componentsMap } = await getModelComponentsMap(modelId);
|
|
90
|
+
const idsByComponent = groupIdsByComponentType(componentIds, componentsMap);
|
|
91
|
+
const methods = DISPATCH_METHODS[action];
|
|
92
|
+
if (methods === undefined) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
const promises = COMPONENT_TYPE_NAMES.filter((type) => idsByComponent[type].length > 0).map(
|
|
96
|
+
async (type) => {
|
|
97
|
+
const result = await callComponentStyleFunction(
|
|
98
|
+
componentStyleFunctions[type],
|
|
99
|
+
methods[type],
|
|
100
|
+
modelId,
|
|
101
|
+
idsByComponent[type],
|
|
102
|
+
...args,
|
|
103
|
+
);
|
|
104
|
+
return result;
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
return Promise.all(promises);
|
|
108
|
+
}
|
|
109
|
+
export { getModelComponentsMap, dispatchToComponentTypes };
|
|
110
|
+
export type { ComponentStyleFunctions };
|