@geode/opengeodeweb-front 10.44.0-rc.7 → 10.44.0-rc.9

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.
Files changed (32) hide show
  1. package/.build/server/utils/scripts.js +34 -23
  2. package/app/components/MissingFilesSelector.vue +30 -17
  3. package/app/components/ObjectSelector.vue +34 -23
  4. package/app/composables/hover_highlight.ts +13 -13
  5. package/app/composables/overlapping_picker_menu.ts +43 -0
  6. package/app/composables/project_manager_helpers/restore.ts +20 -11
  7. package/app/composables/use_overlapping_picker.ts +23 -37
  8. package/app/composables/virtual_tree_flatten.ts +66 -43
  9. package/app/stores/app_helpers/extension.ts +90 -51
  10. package/app/stores/infra.ts +26 -21
  11. package/app/utils/color_picker.ts +18 -15
  12. package/internal/database/database.ts +47 -32
  13. package/internal/stores/data_style/mesh/base_style.ts +74 -0
  14. package/internal/stores/data_style/mesh/index.ts +2 -57
  15. package/internal/stores/data_style/model/blocks/color.ts +58 -57
  16. package/internal/stores/data_style/model/blocks/polyhedron.ts +88 -44
  17. package/internal/stores/data_style/model/blocks/vertex.ts +88 -44
  18. package/internal/stores/data_style/model/color.ts +25 -26
  19. package/internal/stores/data_style/model/corners/index.ts +85 -78
  20. package/internal/stores/data_style/model/corners/vertex.ts +83 -39
  21. package/internal/stores/data_style/model/lines/color.ts +53 -40
  22. package/internal/stores/data_style/model/lines/edge.ts +88 -44
  23. package/internal/stores/data_style/model/lines/vertex.ts +88 -44
  24. package/internal/stores/data_style/model/surfaces/color.ts +68 -56
  25. package/internal/stores/data_style/model/surfaces/polygon.ts +80 -36
  26. package/internal/stores/data_style/model/surfaces/vertex.ts +80 -36
  27. package/internal/stores/data_style/model/visibility_dispatch.ts +49 -99
  28. package/internal/stores/hybrid_viewer/highlight.ts +70 -54
  29. package/internal/stores/hybrid_viewer/scene.ts +31 -25
  30. package/package.json +1 -1
  31. package/server/api/local/extensions/upload.put.ts +47 -20
  32. package/server/utils/scripts.ts +35 -30
@@ -114,12 +114,28 @@ interface UseModelBlocksPolyhedronAttributeReturn {
114
114
  ) => Promise<boolean>;
115
115
  }
116
116
 
117
+ type ModelBlocksPolyhedronAttributeGetters = Pick<
118
+ UseModelBlocksPolyhedronAttributeReturn,
119
+ | "modelBlocksPolyhedronAttributeStoredConfig"
120
+ | "modelBlocksPolyhedronAttributeName"
121
+ | "modelBlocksPolyhedronAttributeItem"
122
+ | "modelBlocksPolyhedronAttributeRange"
123
+ | "modelBlocksPolyhedronAttributeColorMap"
124
+ | "modelBlocksPolyhedronAttributeNoDataColor"
125
+ | "modelBlocksPolyhedronAttributeTimeStep"
126
+ > & {
127
+ modelBlocksPolyhedronAttributeLastItem: (
128
+ modelId: string,
129
+ componentId: string | undefined,
130
+ name: string | undefined,
131
+ ) => number;
132
+ };
133
+
117
134
  // oxlint-disable-next-line max-lines-per-function
118
- function useModelBlocksPolyhedronAttribute(): UseModelBlocksPolyhedronAttributeReturn {
119
- const { attributeTimeStep, setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
120
- const dataStore = useDataStore();
121
- const modelBlocksCommonStyle = useModelBlocksCommonStyle();
122
- const viewerStore = useViewerStore();
135
+ function useModelBlocksPolyhedronAttributeGetters(
136
+ modelBlocksCommonStyle: ReturnType<typeof useModelBlocksCommonStyle>,
137
+ ): ModelBlocksPolyhedronAttributeGetters {
138
+ const { attributeTimeStep } = useAttributeTimeStepStyle();
123
139
  function modelBlocksPolyhedronAttribute(modelId: string, blockId?: string): AttributeState {
124
140
  // oxlint-disable-next-line no-unsafe-type-assertion -- coloring.polyhedron shape is defined by the data style schema.
125
141
  return modelBlocksCommonStyle.modelBlockColoring(modelId, blockId).polyhedron as AttributeState;
@@ -143,45 +159,6 @@ function useModelBlocksPolyhedronAttribute(): UseModelBlocksPolyhedronAttributeR
143
159
  no_data_color: DEFAULT_NO_DATA_COLOR,
144
160
  };
145
161
  }
146
- async function mutateModelBlocksPolyhedronStyle(
147
- modelId: string,
148
- blockIds: string[],
149
- values: Record<string, unknown>,
150
- ): Promise<void> {
151
- const tasks: Promise<void>[] = [
152
- modelBlocksCommonStyle.mutateModelBlocksColoring(modelId, blockIds, {
153
- polyhedron: values,
154
- }),
155
- ];
156
- const totalBlockIds = await dataStore.getBlocksGeodeIds(modelId);
157
- if (blockIds.length === totalBlockIds.length) {
158
- tasks.push(
159
- modelBlocksCommonStyle.mutateModelBlocksTypeColoring(modelId, {
160
- polyhedron: values,
161
- }),
162
- );
163
- }
164
- await Promise.all(tasks);
165
- }
166
- async function setModelBlocksPolyhedronAttributeStoredConfig(
167
- modelId: string,
168
- blockIds: string[],
169
- name: string | undefined,
170
- item: number | undefined,
171
- config: Partial<AttributeStoredConfig>,
172
- ): Promise<void> {
173
- if (name === undefined || item === undefined) {
174
- return;
175
- }
176
- await mutateModelBlocksPolyhedronStyle(modelId, blockIds, {
177
- storedConfigs: {
178
- [name]: {
179
- lastItem: item,
180
- [item]: config,
181
- },
182
- },
183
- });
184
- }
185
162
  function modelBlocksPolyhedronAttributeName(
186
163
  modelId: string,
187
164
  blockId?: string,
@@ -242,6 +219,73 @@ function useModelBlocksPolyhedronAttribute(): UseModelBlocksPolyhedronAttributeR
242
219
  modelBlocksPolyhedronAttribute(modelId, blockId).name,
243
220
  );
244
221
  }
222
+ return {
223
+ modelBlocksPolyhedronAttributeStoredConfig,
224
+ modelBlocksPolyhedronAttributeName,
225
+ modelBlocksPolyhedronAttributeLastItem,
226
+ modelBlocksPolyhedronAttributeItem,
227
+ modelBlocksPolyhedronAttributeRange,
228
+ modelBlocksPolyhedronAttributeColorMap,
229
+ modelBlocksPolyhedronAttributeNoDataColor,
230
+ modelBlocksPolyhedronAttributeTimeStep,
231
+ };
232
+ }
233
+
234
+ // oxlint-disable-next-line max-lines-per-function
235
+ function useModelBlocksPolyhedronAttribute(): UseModelBlocksPolyhedronAttributeReturn {
236
+ const { setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
237
+ const dataStore = useDataStore();
238
+ const modelBlocksCommonStyle = useModelBlocksCommonStyle();
239
+ const {
240
+ modelBlocksPolyhedronAttributeStoredConfig,
241
+ modelBlocksPolyhedronAttributeName,
242
+ modelBlocksPolyhedronAttributeLastItem,
243
+ modelBlocksPolyhedronAttributeItem,
244
+ modelBlocksPolyhedronAttributeRange,
245
+ modelBlocksPolyhedronAttributeColorMap,
246
+ modelBlocksPolyhedronAttributeNoDataColor,
247
+ modelBlocksPolyhedronAttributeTimeStep,
248
+ } = useModelBlocksPolyhedronAttributeGetters(modelBlocksCommonStyle);
249
+ const viewerStore = useViewerStore();
250
+ async function mutateModelBlocksPolyhedronStyle(
251
+ modelId: string,
252
+ blockIds: string[],
253
+ values: Record<string, unknown>,
254
+ ): Promise<void> {
255
+ const tasks: Promise<void>[] = [
256
+ modelBlocksCommonStyle.mutateModelBlocksColoring(modelId, blockIds, {
257
+ polyhedron: values,
258
+ }),
259
+ ];
260
+ const totalBlockIds = await dataStore.getBlocksGeodeIds(modelId);
261
+ if (blockIds.length === totalBlockIds.length) {
262
+ tasks.push(
263
+ modelBlocksCommonStyle.mutateModelBlocksTypeColoring(modelId, {
264
+ polyhedron: values,
265
+ }),
266
+ );
267
+ }
268
+ await Promise.all(tasks);
269
+ }
270
+ async function setModelBlocksPolyhedronAttributeStoredConfig(
271
+ modelId: string,
272
+ blockIds: string[],
273
+ name: string | undefined,
274
+ item: number | undefined,
275
+ config: Partial<AttributeStoredConfig>,
276
+ ): Promise<void> {
277
+ if (name === undefined || item === undefined) {
278
+ return;
279
+ }
280
+ await mutateModelBlocksPolyhedronStyle(modelId, blockIds, {
281
+ storedConfigs: {
282
+ [name]: {
283
+ lastItem: item,
284
+ [item]: config,
285
+ },
286
+ },
287
+ });
288
+ }
245
289
  async function setModelBlocksPolyhedronAttribute(
246
290
  modelId: string,
247
291
  blockIds: string[],
@@ -111,12 +111,28 @@ interface UseModelBlocksVertexAttributeReturn {
111
111
  ) => Promise<unknown>;
112
112
  }
113
113
 
114
+ type ModelBlocksVertexAttributeGetters = Pick<
115
+ UseModelBlocksVertexAttributeReturn,
116
+ | "modelBlocksVertexAttributeStoredConfig"
117
+ | "modelBlocksVertexAttributeName"
118
+ | "modelBlocksVertexAttributeItem"
119
+ | "modelBlocksVertexAttributeRange"
120
+ | "modelBlocksVertexAttributeColorMap"
121
+ | "modelBlocksVertexAttributeNoDataColor"
122
+ | "modelBlocksVertexAttributeTimeStep"
123
+ > & {
124
+ modelBlocksVertexAttributeLastItem: (
125
+ modelId: string,
126
+ componentId: string | undefined,
127
+ name: string | undefined,
128
+ ) => number;
129
+ };
130
+
114
131
  // oxlint-disable-next-line max-lines-per-function
115
- function useModelBlocksVertexAttribute(): UseModelBlocksVertexAttributeReturn {
116
- const { attributeTimeStep, setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
117
- const dataStore = useDataStore();
118
- const modelBlocksCommonStyle = useModelBlocksCommonStyle();
119
- const viewerStore = useViewerStore();
132
+ function useModelBlocksVertexAttributeGetters(
133
+ modelBlocksCommonStyle: ReturnType<typeof useModelBlocksCommonStyle>,
134
+ ): ModelBlocksVertexAttributeGetters {
135
+ const { attributeTimeStep } = useAttributeTimeStepStyle();
120
136
  function modelBlocksVertexAttribute(modelId: string, blockId?: string): AttributeState {
121
137
  // oxlint-disable-next-line no-unsafe-type-assertion -- coloring.vertex shape is defined by the data style schema.
122
138
  return modelBlocksCommonStyle.modelBlockColoring(modelId, blockId).vertex as AttributeState;
@@ -140,45 +156,6 @@ function useModelBlocksVertexAttribute(): UseModelBlocksVertexAttributeReturn {
140
156
  no_data_color: DEFAULT_NO_DATA_COLOR,
141
157
  };
142
158
  }
143
- async function mutateModelBlocksVertexStyle(
144
- modelId: string,
145
- blockIds: string[],
146
- values: Record<string, unknown>,
147
- ): Promise<void> {
148
- const tasks: Promise<void>[] = [
149
- modelBlocksCommonStyle.mutateModelBlocksColoring(modelId, blockIds, {
150
- vertex: values,
151
- }),
152
- ];
153
- const totalBlockIds = await dataStore.getBlocksGeodeIds(modelId);
154
- if (blockIds.length === totalBlockIds.length) {
155
- tasks.push(
156
- modelBlocksCommonStyle.mutateModelBlocksTypeColoring(modelId, {
157
- vertex: values,
158
- }),
159
- );
160
- }
161
- await Promise.all(tasks);
162
- }
163
- async function setModelBlocksVertexAttributeStoredConfig(
164
- modelId: string,
165
- blockIds: string[],
166
- name: string | undefined,
167
- item: number | undefined,
168
- config: Partial<AttributeStoredConfig>,
169
- ): Promise<void> {
170
- if (name === undefined || item === undefined) {
171
- return;
172
- }
173
- await mutateModelBlocksVertexStyle(modelId, blockIds, {
174
- storedConfigs: {
175
- [name]: {
176
- lastItem: item,
177
- [item]: config,
178
- },
179
- },
180
- });
181
- }
182
159
  function modelBlocksVertexAttributeName(modelId: string, blockId?: string): string | undefined {
183
160
  return modelBlocksVertexAttribute(modelId, blockId).name;
184
161
  }
@@ -236,6 +213,73 @@ function useModelBlocksVertexAttribute(): UseModelBlocksVertexAttributeReturn {
236
213
  modelBlocksVertexAttribute(modelId, blockId).name,
237
214
  );
238
215
  }
216
+ return {
217
+ modelBlocksVertexAttributeStoredConfig,
218
+ modelBlocksVertexAttributeName,
219
+ modelBlocksVertexAttributeLastItem,
220
+ modelBlocksVertexAttributeItem,
221
+ modelBlocksVertexAttributeRange,
222
+ modelBlocksVertexAttributeColorMap,
223
+ modelBlocksVertexAttributeNoDataColor,
224
+ modelBlocksVertexAttributeTimeStep,
225
+ };
226
+ }
227
+
228
+ // oxlint-disable-next-line max-lines-per-function
229
+ function useModelBlocksVertexAttribute(): UseModelBlocksVertexAttributeReturn {
230
+ const { setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
231
+ const dataStore = useDataStore();
232
+ const modelBlocksCommonStyle = useModelBlocksCommonStyle();
233
+ const {
234
+ modelBlocksVertexAttributeStoredConfig,
235
+ modelBlocksVertexAttributeName,
236
+ modelBlocksVertexAttributeLastItem,
237
+ modelBlocksVertexAttributeItem,
238
+ modelBlocksVertexAttributeRange,
239
+ modelBlocksVertexAttributeColorMap,
240
+ modelBlocksVertexAttributeNoDataColor,
241
+ modelBlocksVertexAttributeTimeStep,
242
+ } = useModelBlocksVertexAttributeGetters(modelBlocksCommonStyle);
243
+ const viewerStore = useViewerStore();
244
+ async function mutateModelBlocksVertexStyle(
245
+ modelId: string,
246
+ blockIds: string[],
247
+ values: Record<string, unknown>,
248
+ ): Promise<void> {
249
+ const tasks: Promise<void>[] = [
250
+ modelBlocksCommonStyle.mutateModelBlocksColoring(modelId, blockIds, {
251
+ vertex: values,
252
+ }),
253
+ ];
254
+ const totalBlockIds = await dataStore.getBlocksGeodeIds(modelId);
255
+ if (blockIds.length === totalBlockIds.length) {
256
+ tasks.push(
257
+ modelBlocksCommonStyle.mutateModelBlocksTypeColoring(modelId, {
258
+ vertex: values,
259
+ }),
260
+ );
261
+ }
262
+ await Promise.all(tasks);
263
+ }
264
+ async function setModelBlocksVertexAttributeStoredConfig(
265
+ modelId: string,
266
+ blockIds: string[],
267
+ name: string | undefined,
268
+ item: number | undefined,
269
+ config: Partial<AttributeStoredConfig>,
270
+ ): Promise<void> {
271
+ if (name === undefined || item === undefined) {
272
+ return;
273
+ }
274
+ await mutateModelBlocksVertexStyle(modelId, blockIds, {
275
+ storedConfigs: {
276
+ [name]: {
277
+ lastItem: item,
278
+ [item]: config,
279
+ },
280
+ },
281
+ });
282
+ }
239
283
  async function setModelBlocksVertexAttribute(
240
284
  modelId: string,
241
285
  blockIds: string[],
@@ -46,6 +46,29 @@ function attributeFn<Signature>(method: unknown): Signature {
46
46
  return method as Signature;
47
47
  }
48
48
 
49
+ // Re-applies the attribute name, range and color map of `firstId` to every id in `componentIds`
50
+ async function applyAttributeAccessors(
51
+ modelId: string,
52
+ componentIds: string[],
53
+ firstId: string,
54
+ accessors: AttributeAccessors,
55
+ ): Promise<void> {
56
+ const { getName, setName, getRange, setRange, getColorMap, setColorMap } = accessors;
57
+ const name = getName(modelId, firstId);
58
+ if (name === undefined || name === "") {
59
+ return;
60
+ }
61
+ await setName(modelId, componentIds, name);
62
+ const [minimum, maximum] = getRange(modelId, firstId);
63
+ if (minimum !== undefined && maximum !== undefined) {
64
+ await setRange(modelId, componentIds, minimum, maximum);
65
+ }
66
+ const colorMap = getColorMap(modelId, firstId);
67
+ if (colorMap !== undefined && colorMap !== "") {
68
+ await setColorMap(modelId, componentIds, colorMap);
69
+ }
70
+ }
71
+
49
72
  // oxlint-disable-next-line max-lines-per-function
50
73
  function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions): {
51
74
  getModelColor: (modelId: string) => RGBAColor | undefined;
@@ -270,23 +293,11 @@ function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions): {
270
293
  if (attributeFunctions === undefined) {
271
294
  return;
272
295
  }
273
- const { getName, setName, getRange, setRange, getColorMap, setColorMap } = attributeFunctions;
274
296
  const [firstId] = idsForType;
275
297
  if (firstId === undefined) {
276
298
  return;
277
299
  }
278
- const name = getName(modelId, firstId);
279
- if (name !== undefined && name !== "") {
280
- await setName(modelId, idsForType, name);
281
- const [minimum, maximum] = getRange(modelId, firstId);
282
- if (minimum !== undefined && maximum !== undefined) {
283
- await setRange(modelId, idsForType, minimum, maximum);
284
- }
285
- const colorMap = getColorMap(modelId, firstId);
286
- if (colorMap !== undefined && colorMap !== "") {
287
- await setColorMap(modelId, idsForType, colorMap);
288
- }
289
- }
300
+ await applyAttributeAccessors(modelId, idsForType, firstId, attributeFunctions);
290
301
  }
291
302
  async function setModelComponentActiveColoring(
292
303
  modelId: string,
@@ -310,19 +321,7 @@ function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions): {
310
321
  if (attributeFunctions === undefined) {
311
322
  return;
312
323
  }
313
- const { getName, setName, getRange, setRange, getColorMap, setColorMap } = attributeFunctions;
314
- const name = getName(modelId, componentId);
315
- if (name !== undefined && name !== "") {
316
- await setName(modelId, [componentId], name);
317
- const [minimum, maximum] = getRange(modelId, componentId);
318
- if (minimum !== undefined && maximum !== undefined) {
319
- await setRange(modelId, [componentId], minimum, maximum);
320
- }
321
- const colorMap = getColorMap(modelId, componentId);
322
- if (colorMap !== undefined && colorMap !== "") {
323
- await setColorMap(modelId, [componentId], colorMap);
324
- }
325
- }
324
+ await applyAttributeAccessors(modelId, [componentId], componentId, attributeFunctions);
326
325
  }
327
326
  function getModelColor(modelId: string): RGBAColor | undefined {
328
327
  // oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
@@ -63,102 +63,109 @@ export function useModelCornersStyle(): ModelCornersStyleApi {
63
63
  return results;
64
64
  }
65
65
 
66
- async function applyModelCornersColoringStyle(
66
+ function groupCornersByActiveColoring(
67
67
  modelId: string,
68
68
  corners_ids: string[],
69
- ): Promise<unknown[]> {
69
+ ): Record<string, string[]> {
70
70
  const activeColoringGroups: Record<string, string[]> = {};
71
71
  for (const corner_id of corners_ids) {
72
72
  const activeColoring = String(modelColorStyle.modelCornerActiveColoring(modelId, corner_id));
73
73
  activeColoringGroups[activeColoring] ??= [];
74
74
  activeColoringGroups[activeColoring].push(corner_id);
75
75
  }
76
+ return activeColoringGroups;
77
+ }
76
78
 
77
- const coloringPromises: Promise<unknown>[] = [];
79
+ function applyConstantColoring(modelId: string, corners_ids: string[]): Promise<unknown>[] {
80
+ const colorGroups: Record<string, ColorGroup> = {};
81
+ for (const corner_id of corners_ids) {
82
+ const color = modelColorStyle.modelCornerColor(modelId, corner_id);
83
+ const color_key = JSON.stringify(color);
84
+ colorGroups[color_key] ??= { color, corners_ids: [] };
85
+ colorGroups[color_key].corners_ids.push(corner_id);
86
+ }
87
+ return Object.values(colorGroups).map(async ({ color, corners_ids: ids }) => {
88
+ const result = await modelColorStyle.setModelCornersColor(modelId, ids, color, "constant");
89
+ return result;
90
+ });
91
+ }
78
92
 
79
- for (const [type, type_corners_ids] of Object.entries(activeColoringGroups)) {
80
- if (type === "constant") {
81
- const colorGroups: Record<string, ColorGroup> = {};
82
- for (const corner_id of type_corners_ids) {
83
- const color = modelColorStyle.modelCornerColor(modelId, corner_id);
84
- const color_key = JSON.stringify(color);
85
- colorGroups[color_key] ??= { color, corners_ids: [] };
86
- colorGroups[color_key].corners_ids.push(corner_id);
87
- }
88
- coloringPromises.push(
89
- ...Object.values(colorGroups).map(async ({ color, corners_ids: ids }) => {
90
- const result = await modelColorStyle.setModelCornersColor(
91
- modelId,
92
- ids,
93
- color,
94
- "constant",
95
- );
96
- return result;
97
- }),
98
- );
99
- } else if (type === "random") {
100
- coloringPromises.push(
101
- modelColorStyle.setModelCornersColor(modelId, type_corners_ids, undefined, "random"),
102
- );
103
- } else if (type === "vertex") {
104
- const vertexGroups: Record<string, AttributeGroup> = {};
105
- for (const corner_id of type_corners_ids) {
106
- const name = modelCornersVertexAttribute.modelCornersVertexAttributeName(
107
- modelId,
108
- corner_id,
109
- );
110
- const item = modelCornersVertexAttribute.modelCornersVertexAttributeItem(
111
- modelId,
112
- corner_id,
113
- );
114
- const [minimum, maximum] = modelCornersVertexAttribute.modelCornersVertexAttributeRange(
115
- modelId,
116
- corner_id,
117
- );
118
- const colorMap = modelCornersVertexAttribute.modelCornersVertexAttributeColorMap(
119
- modelId,
120
- corner_id,
121
- );
122
- const no_data_color = modelCornersVertexAttribute.modelCornersVertexAttributeNoDataColor(
123
- modelId,
124
- corner_id,
125
- );
126
- const attribute = {
93
+ function groupCornersByVertexAttribute(
94
+ modelId: string,
95
+ corners_ids: string[],
96
+ ): Record<string, AttributeGroup> {
97
+ const vertexGroups: Record<string, AttributeGroup> = {};
98
+ for (const corner_id of corners_ids) {
99
+ const name = modelCornersVertexAttribute.modelCornersVertexAttributeName(modelId, corner_id);
100
+ const item = modelCornersVertexAttribute.modelCornersVertexAttributeItem(modelId, corner_id);
101
+ const [minimum, maximum] = modelCornersVertexAttribute.modelCornersVertexAttributeRange(
102
+ modelId,
103
+ corner_id,
104
+ );
105
+ const colorMap = modelCornersVertexAttribute.modelCornersVertexAttributeColorMap(
106
+ modelId,
107
+ corner_id,
108
+ );
109
+ const no_data_color = modelCornersVertexAttribute.modelCornersVertexAttributeNoDataColor(
110
+ modelId,
111
+ corner_id,
112
+ );
113
+ const attribute = {
114
+ name,
115
+ item,
116
+ minimum,
117
+ maximum,
118
+ colorMap,
119
+ no_data_color,
120
+ };
121
+ if (!isModelCornersVertexAttributeValid(attribute)) {
122
+ continue;
123
+ }
124
+ const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join("_");
125
+ vertexGroups[key] ??= { ...attribute, corners_ids: [] };
126
+ vertexGroups[key].corners_ids.push(corner_id);
127
+ }
128
+ return vertexGroups;
129
+ }
130
+
131
+ function applyVertexColoring(modelId: string, corners_ids: string[]): Promise<unknown>[] {
132
+ const vertexGroups = groupCornersByVertexAttribute(modelId, corners_ids);
133
+ return Object.values(vertexGroups).map(
134
+ async ({ name, item, minimum, maximum, colorMap, no_data_color, corners_ids: ids }) => {
135
+ const result = await modelCornersVertexAttribute.setModelCornersVertexAttribute(
136
+ modelId,
137
+ ids,
138
+ {
127
139
  name,
128
140
  item,
129
141
  minimum,
130
142
  maximum,
131
143
  colorMap,
132
144
  no_data_color,
133
- };
134
- if (!isModelCornersVertexAttributeValid(attribute)) {
135
- continue;
136
- }
137
- const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join(
138
- "_",
139
- );
140
- vertexGroups[key] ??= { ...attribute, corners_ids: [] };
141
- vertexGroups[key].corners_ids.push(corner_id);
142
- }
145
+ },
146
+ );
147
+ return result;
148
+ },
149
+ );
150
+ }
151
+
152
+ async function applyModelCornersColoringStyle(
153
+ modelId: string,
154
+ corners_ids: string[],
155
+ ): Promise<unknown[]> {
156
+ const activeColoringGroups = groupCornersByActiveColoring(modelId, corners_ids);
157
+
158
+ const coloringPromises: Promise<unknown>[] = [];
159
+
160
+ for (const [type, type_corners_ids] of Object.entries(activeColoringGroups)) {
161
+ if (type === "constant") {
162
+ coloringPromises.push(...applyConstantColoring(modelId, type_corners_ids));
163
+ } else if (type === "random") {
143
164
  coloringPromises.push(
144
- ...Object.values(vertexGroups).map(
145
- async ({ name, item, minimum, maximum, colorMap, no_data_color, corners_ids: ids }) => {
146
- const result = await modelCornersVertexAttribute.setModelCornersVertexAttribute(
147
- modelId,
148
- ids,
149
- {
150
- name,
151
- item,
152
- minimum,
153
- maximum,
154
- colorMap,
155
- no_data_color,
156
- },
157
- );
158
- return result;
159
- },
160
- ),
165
+ modelColorStyle.setModelCornersColor(modelId, type_corners_ids, undefined, "random"),
161
166
  );
167
+ } else if (type === "vertex") {
168
+ coloringPromises.push(...applyVertexColoring(modelId, type_corners_ids));
162
169
  }
163
170
  }
164
171