@geode/opengeodeweb-front 10.28.1-rc.4 → 10.29.0-rc.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.
Files changed (57) hide show
  1. package/app/components/Viewer/ContextMenu/InfoCard.vue +56 -21
  2. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +21 -0
  3. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +21 -0
  4. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +80 -0
  5. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +10 -0
  6. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +81 -0
  7. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +20 -0
  8. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +36 -0
  9. package/app/components/Viewer/Generic/Model/CornersOptions.vue +18 -0
  10. package/app/components/Viewer/Generic/Model/LinesOptions.vue +36 -0
  11. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +36 -0
  12. package/app/components/Viewer/Options/AttributeSelector.vue +47 -38
  13. package/app/components/Viewer/Options/ColoringTypeSelector.vue +26 -22
  14. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +10 -0
  15. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +20 -0
  16. package/app/components/Viewer/Surface/PolygonsOptions.vue +20 -0
  17. package/internal/stores/data_style/mesh/cells/cell.js +94 -60
  18. package/internal/stores/data_style/mesh/cells/index.js +21 -22
  19. package/internal/stores/data_style/mesh/cells/vertex.js +83 -64
  20. package/internal/stores/data_style/mesh/edges/edge.js +83 -67
  21. package/internal/stores/data_style/mesh/edges/index.js +22 -19
  22. package/internal/stores/data_style/mesh/edges/vertex.js +87 -65
  23. package/internal/stores/data_style/mesh/points/index.js +9 -9
  24. package/internal/stores/data_style/mesh/points/vertex.js +96 -99
  25. package/internal/stores/data_style/mesh/polygons/index.js +26 -16
  26. package/internal/stores/data_style/mesh/polygons/polygon.js +88 -66
  27. package/internal/stores/data_style/mesh/polygons/vertex.js +88 -66
  28. package/internal/stores/data_style/mesh/polyhedra/index.js +33 -22
  29. package/internal/stores/data_style/mesh/polyhedra/polyhedron.js +101 -103
  30. package/internal/stores/data_style/mesh/polyhedra/vertex.js +101 -103
  31. package/internal/stores/data_style/model/blocks/color.js +27 -28
  32. package/internal/stores/data_style/model/blocks/index.js +140 -72
  33. package/internal/stores/data_style/model/blocks/polyhedron.js +114 -58
  34. package/internal/stores/data_style/model/blocks/vertex.js +107 -57
  35. package/internal/stores/data_style/model/common.js +6 -6
  36. package/internal/stores/data_style/model/corners/color.js +12 -16
  37. package/internal/stores/data_style/model/corners/index.js +95 -63
  38. package/internal/stores/data_style/model/corners/vertex.js +108 -58
  39. package/internal/stores/data_style/model/lines/color.js +18 -23
  40. package/internal/stores/data_style/model/lines/edge.js +106 -54
  41. package/internal/stores/data_style/model/lines/index.js +132 -71
  42. package/internal/stores/data_style/model/lines/vertex.js +107 -54
  43. package/internal/stores/data_style/model/surfaces/color.js +24 -32
  44. package/internal/stores/data_style/model/surfaces/index.js +142 -74
  45. package/internal/stores/data_style/model/surfaces/polygon.js +114 -58
  46. package/internal/stores/data_style/model/surfaces/vertex.js +114 -58
  47. package/internal/stores/data_style/state.js +105 -94
  48. package/package.json +1 -1
  49. package/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +200 -24
  50. package/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +132 -34
  51. package/tests/integration/stores/data_style/mesh/points.nuxt.test.js +60 -11
  52. package/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +116 -22
  53. package/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +145 -34
  54. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +206 -33
  55. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +94 -15
  56. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +187 -30
  57. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +379 -31
@@ -10,12 +10,39 @@ import { useViewerStore } from "@ogw_front/stores/viewer";
10
10
  const meshPolyhedraVertexAttributeSchemas =
11
11
  viewer_schemas.opengeodeweb_viewer.mesh.polyhedra.attribute.vertex;
12
12
 
13
+ function isMeshPolyhedraVertexAttributeValid({ name, item, minimum, maximum, colorMap }) {
14
+ return (
15
+ name !== undefined &&
16
+ item !== undefined &&
17
+ minimum !== undefined &&
18
+ maximum !== undefined &&
19
+ colorMap !== undefined
20
+ );
21
+ }
22
+
13
23
  // oxlint-disable-next-line max-lines-per-function
14
- function useMeshPolyhedraVertexAttributeConfig() {
24
+ function useMeshPolyhedraVertexAttributeStyle() {
25
+ const viewerStore = useViewerStore();
15
26
  const meshPolyhedraCommonStyle = useMeshPolyhedraCommonStyle();
16
27
 
28
+ function meshPolyhedraColoring(id) {
29
+ return meshPolyhedraCommonStyle.meshPolyhedraStyle(id).coloring;
30
+ }
31
+
17
32
  function meshPolyhedraVertexAttribute(id) {
18
- return meshPolyhedraCommonStyle.meshPolyhedraColoring(id).vertex;
33
+ return meshPolyhedraColoring(id).vertex;
34
+ }
35
+
36
+ function meshPolyhedraVertexAttributeStoredConfig(id, name, item) {
37
+ const { storedConfigs } = meshPolyhedraVertexAttribute(id);
38
+ if (storedConfigs && name in storedConfigs && item in storedConfigs[name]) {
39
+ return storedConfigs[name][item];
40
+ }
41
+ return {
42
+ minimum: undefined,
43
+ maximum: undefined,
44
+ colorMap: undefined,
45
+ };
19
46
  }
20
47
 
21
48
  function mutateMeshPolyhedraVertexStyle(id, values) {
@@ -26,139 +53,110 @@ function useMeshPolyhedraVertexAttributeConfig() {
26
53
  });
27
54
  }
28
55
 
29
- function setMeshPolyhedraVertexAttributeStoredConfig(id, name, config) {
56
+ function setMeshPolyhedraVertexAttributeStoredConfig(id, name, item, config) {
30
57
  return mutateMeshPolyhedraVertexStyle(id, {
31
58
  storedConfigs: {
32
- [name]: config,
59
+ [name]: {
60
+ lastItem: item,
61
+ [item]: config,
62
+ },
33
63
  },
34
64
  });
35
65
  }
36
66
 
37
- function meshPolyhedraVertexAttributeStoredConfig(id, name) {
38
- const { storedConfigs } = meshPolyhedraVertexAttribute(id);
39
- if (name in storedConfigs) {
40
- return storedConfigs[name];
67
+ function applyVertexAttribute(id) {
68
+ const name = meshPolyhedraVertexAttributeName(id);
69
+ const item = meshPolyhedraVertexAttributeItem(id);
70
+ const storedConfig = meshPolyhedraVertexAttributeStoredConfig(id, name, item);
71
+ const attribute = {
72
+ name,
73
+ item,
74
+ minimum: storedConfig.minimum,
75
+ maximum: storedConfig.maximum,
76
+ colorMap: storedConfig.colorMap,
77
+ };
78
+ if (isMeshPolyhedraVertexAttributeValid(attribute)) {
79
+ return setMeshPolyhedraVertexAttribute(id, attribute);
41
80
  }
42
- return setMeshPolyhedraVertexAttributeStoredConfig(id, name, {
43
- minimum: undefined,
44
- maximum: undefined,
45
- colorMap: undefined,
46
- });
47
81
  }
48
82
 
49
83
  function meshPolyhedraVertexAttributeName(id) {
50
84
  return meshPolyhedraVertexAttribute(id).name;
51
85
  }
52
86
 
53
- function meshPolyhedraVertexAttributeRange(id) {
54
- const name = meshPolyhedraVertexAttributeName(id);
55
- const storedConfig = meshPolyhedraVertexAttributeStoredConfig(id, name);
56
- const { minimum, maximum } = storedConfig;
57
- return [minimum, maximum];
87
+ function setMeshPolyhedraVertexAttributeName(id, name) {
88
+ const item = meshPolyhedraVertexAttributeLastItem(id, name);
89
+ mutateMeshPolyhedraVertexStyle(id, { name, item });
90
+ return applyVertexAttribute(id);
58
91
  }
59
92
 
60
- function meshPolyhedraVertexAttributeColorMap(id) {
61
- const name = meshPolyhedraVertexAttributeName(id);
62
- const storedConfig = meshPolyhedraVertexAttributeStoredConfig(id, name);
63
- const { colorMap } = storedConfig;
64
- return colorMap;
93
+ function meshPolyhedraVertexAttributeItem(id) {
94
+ const { item, name } = meshPolyhedraVertexAttribute(id);
95
+ return item ?? meshPolyhedraVertexAttributeLastItem(id, name);
65
96
  }
66
97
 
67
- return {
68
- meshPolyhedraVertexAttribute,
69
- meshPolyhedraVertexAttributeStoredConfig,
70
- setMeshPolyhedraVertexAttributeStoredConfig,
71
- mutateMeshPolyhedraVertexStyle,
72
- meshPolyhedraVertexAttributeName,
73
- meshPolyhedraVertexAttributeRange,
74
- meshPolyhedraVertexAttributeColorMap,
75
- };
76
- }
98
+ function setMeshPolyhedraVertexAttributeItem(id, item) {
99
+ mutateMeshPolyhedraVertexStyle(id, { item });
100
+ return applyVertexAttribute(id);
101
+ }
77
102
 
78
- // oxlint-disable-next-line max-lines-per-function
79
- function useMeshPolyhedraVertexAttributeActions() {
80
- const viewerStore = useViewerStore();
81
- const config = useMeshPolyhedraVertexAttributeConfig();
103
+ function meshPolyhedraVertexAttributeLastItem(id, name) {
104
+ const { storedConfigs } = meshPolyhedraVertexAttribute(id);
105
+ if (storedConfigs && name in storedConfigs) {
106
+ return storedConfigs[name].lastItem;
107
+ }
108
+ return 0;
109
+ }
82
110
 
83
- function setMeshPolyhedraVertexAttributeName(id, name) {
84
- const schema = meshPolyhedraVertexAttributeSchemas.name;
85
- const params = { id, name };
86
- return viewerStore.request(
87
- {
88
- schema,
89
- params,
90
- },
91
- {
92
- response_function: () => {
93
- const updates = { name };
94
- const vertex = config.meshPolyhedraVertexAttribute(id);
95
- if (!(name in vertex.storedConfigs)) {
96
- updates.storedConfigs = {
97
- [name]: {
98
- minimum: undefined,
99
- maximum: undefined,
100
- colorMap: undefined,
101
- },
102
- };
103
- }
104
- return config.mutateMeshPolyhedraVertexStyle(id, updates);
105
- },
106
- },
107
- );
111
+ function meshPolyhedraVertexAttributeRange(id) {
112
+ const name = meshPolyhedraVertexAttributeName(id);
113
+ const item = meshPolyhedraVertexAttributeItem(id);
114
+ const storedConfig = meshPolyhedraVertexAttributeStoredConfig(id, name, item);
115
+ return [storedConfig.minimum, storedConfig.maximum];
108
116
  }
109
117
 
110
118
  function setMeshPolyhedraVertexAttributeRange(id, minimum, maximum) {
111
- const name = config.meshPolyhedraVertexAttributeName(id);
112
- const points = getRGBPointsFromPreset(config.meshPolyhedraVertexAttributeColorMap(id));
113
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
114
- const schema = meshPolyhedraVertexAttributeSchemas.color_map;
115
- const params = { id, points, minimum, maximum };
116
- return viewerStore.request(
117
- { schema, params },
118
- {
119
- response_function: () =>
120
- config.setMeshPolyhedraVertexAttributeStoredConfig(id, name, { minimum, maximum }),
121
- },
122
- );
123
- }
124
- return config.setMeshPolyhedraVertexAttributeStoredConfig(id, name, {
125
- minimum,
126
- maximum,
127
- });
119
+ const name = meshPolyhedraVertexAttributeName(id);
120
+ const item = meshPolyhedraVertexAttributeItem(id);
121
+ setMeshPolyhedraVertexAttributeStoredConfig(id, name, item, { minimum, maximum });
122
+ return applyVertexAttribute(id);
123
+ }
124
+
125
+ function meshPolyhedraVertexAttributeColorMap(id) {
126
+ const name = meshPolyhedraVertexAttributeName(id);
127
+ const item = meshPolyhedraVertexAttributeItem(id);
128
+ const storedConfig = meshPolyhedraVertexAttributeStoredConfig(id, name, item);
129
+ return storedConfig.colorMap;
128
130
  }
129
131
 
130
132
  function setMeshPolyhedraVertexAttributeColorMap(id, colorMap) {
131
- const name = config.meshPolyhedraVertexAttributeName(id);
132
- const storedConfig = config.meshPolyhedraVertexAttributeStoredConfig(id, name);
133
+ const name = meshPolyhedraVertexAttributeName(id);
134
+ const item = meshPolyhedraVertexAttributeItem(id);
135
+ setMeshPolyhedraVertexAttributeStoredConfig(id, name, item, { colorMap });
136
+ return applyVertexAttribute(id);
137
+ }
138
+
139
+ function setMeshPolyhedraVertexAttribute(id, { name, item, minimum, maximum, colorMap }) {
140
+ mutateMeshPolyhedraVertexStyle(id, { name, item });
141
+ setMeshPolyhedraVertexAttributeStoredConfig(id, name, item, { minimum, maximum, colorMap });
133
142
  const points = getRGBPointsFromPreset(colorMap);
134
- const { minimum, maximum } = storedConfig;
135
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
136
- const schema = meshPolyhedraVertexAttributeSchemas.color_map;
137
- const params = { id, points, minimum, maximum };
138
- return viewerStore.request(
139
- { schema, params },
140
- {
141
- response_function: () =>
142
- config.setMeshPolyhedraVertexAttributeStoredConfig(id, name, { colorMap }),
143
- },
144
- );
145
- }
146
- return config.setMeshPolyhedraVertexAttributeStoredConfig(id, name, { colorMap });
143
+ const schema = meshPolyhedraVertexAttributeSchemas.attribute;
144
+ const params = { id, name, item, points, minimum, maximum };
145
+ return viewerStore.request({ schema, params });
147
146
  }
148
147
 
149
148
  return {
149
+ meshPolyhedraVertexAttributeName,
150
+ meshPolyhedraVertexAttributeItem,
151
+ meshPolyhedraVertexAttributeRange,
152
+ meshPolyhedraVertexAttributeColorMap,
153
+ meshPolyhedraVertexAttributeStoredConfig,
154
+ setMeshPolyhedraVertexAttribute,
150
155
  setMeshPolyhedraVertexAttributeName,
156
+ setMeshPolyhedraVertexAttributeItem,
151
157
  setMeshPolyhedraVertexAttributeRange,
152
158
  setMeshPolyhedraVertexAttributeColorMap,
153
159
  };
154
160
  }
155
161
 
156
- export function useMeshPolyhedraVertexAttributeStyle() {
157
- const config = useMeshPolyhedraVertexAttributeConfig();
158
- const actions = useMeshPolyhedraVertexAttributeActions();
159
-
160
- return {
161
- ...config,
162
- ...actions,
163
- };
164
- }
162
+ export { isMeshPolyhedraVertexAttributeValid, useMeshPolyhedraVertexAttributeStyle };
@@ -1,6 +1,9 @@
1
+ import {
2
+ isModelBlocksPolyhedronAttributeValid,
3
+ useModelBlocksPolyhedronAttribute,
4
+ } from "./polyhedron";
5
+ import { isModelBlocksVertexAttributeValid, useModelBlocksVertexAttribute } from "./vertex";
1
6
  import { useModelBlocksCommonStyle } from "./common";
2
- import { useModelBlocksPolyhedronAttribute } from "./polyhedron";
3
- import { useModelBlocksVertexAttribute } from "./vertex";
4
7
  import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
5
8
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
6
9
 
@@ -42,55 +45,51 @@ export function useModelBlocksColor() {
42
45
  modelId,
43
46
  blocks_ids[0],
44
47
  );
45
- await modelBlocksVertexAttribute.setModelBlocksVertexAttributeName(modelId, blocks_ids, name);
46
- const [min, max] = modelBlocksVertexAttribute.modelBlocksVertexAttributeRange(
48
+ const item = modelBlocksVertexAttribute.modelBlocksVertexAttributeItem(
47
49
  modelId,
48
50
  blocks_ids[0],
49
51
  );
50
- await modelBlocksVertexAttribute.setModelBlocksVertexAttributeRange(
52
+ const [minimum, maximum] = modelBlocksVertexAttribute.modelBlocksVertexAttributeRange(
51
53
  modelId,
52
- blocks_ids,
53
- min,
54
- max,
54
+ blocks_ids[0],
55
55
  );
56
56
  const colorMap = modelBlocksVertexAttribute.modelBlocksVertexAttributeColorMap(
57
57
  modelId,
58
58
  blocks_ids[0],
59
59
  );
60
- await modelBlocksVertexAttribute.setModelBlocksVertexAttributeColorMap(
61
- modelId,
62
- blocks_ids,
63
- colorMap,
64
- );
60
+ const attribute = { name, item, minimum, maximum, colorMap };
61
+ if (isModelBlocksVertexAttributeValid(attribute)) {
62
+ return modelBlocksVertexAttribute.setModelBlocksVertexAttribute(
63
+ modelId,
64
+ blocks_ids,
65
+ attribute,
66
+ );
67
+ }
65
68
  } else if (activeColoring === "polyhedron") {
66
69
  const name = modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeName(
67
70
  modelId,
68
71
  blocks_ids[0],
69
72
  );
70
- await modelBlocksPolyhedronAttribute.setModelBlocksPolyhedronAttributeName(
71
- modelId,
72
- blocks_ids,
73
- name,
74
- );
75
- const [min, max] = modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeRange(
73
+ const item = modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeItem(
76
74
  modelId,
77
75
  blocks_ids[0],
78
76
  );
79
- await modelBlocksPolyhedronAttribute.setModelBlocksPolyhedronAttributeRange(
77
+ const [minimum, maximum] = modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeRange(
80
78
  modelId,
81
- blocks_ids,
82
- min,
83
- max,
79
+ blocks_ids[0],
84
80
  );
85
81
  const colorMap = modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeColorMap(
86
82
  modelId,
87
83
  blocks_ids[0],
88
84
  );
89
- await modelBlocksPolyhedronAttribute.setModelBlocksPolyhedronAttributeColorMap(
90
- modelId,
91
- blocks_ids,
92
- colorMap,
93
- );
85
+ const attribute = { name, item, minimum, maximum, colorMap };
86
+ if (isModelBlocksPolyhedronAttributeValid(attribute)) {
87
+ return modelBlocksPolyhedronAttribute.setModelBlocksPolyhedronAttribute(
88
+ modelId,
89
+ blocks_ids,
90
+ attribute,
91
+ );
92
+ }
94
93
  }
95
94
  }
96
95
 
@@ -1,8 +1,11 @@
1
+ import {
2
+ isModelBlocksPolyhedronAttributeValid,
3
+ useModelBlocksPolyhedronAttribute,
4
+ } from "./polyhedron";
5
+ import { isModelBlocksVertexAttributeValid, useModelBlocksVertexAttribute } from "./vertex";
1
6
  import { useDataStore } from "@ogw_front/stores/data";
2
7
  import { useModelBlocksColor } from "./color";
3
8
  import { useModelBlocksCommonStyle } from "./common";
4
- import { useModelBlocksPolyhedronAttribute } from "./polyhedron";
5
- import { useModelBlocksVertexAttribute } from "./vertex";
6
9
  import { useModelBlocksVisibility } from "./visibility";
7
10
 
8
11
  async function setModelBlocksDefaultStyle(_id) {
@@ -17,94 +20,159 @@ export function useModelBlocksStyle() {
17
20
  const modelBlocksVertexAttribute = useModelBlocksVertexAttribute();
18
21
  const modelBlocksPolyhedronAttribute = useModelBlocksPolyhedronAttribute();
19
22
 
20
- async function applyModelBlocksStyle(modelId) {
21
- const blocks_ids = await dataStore.getBlocksGeodeIds(modelId);
22
- if (!blocks_ids?.length) {
23
- return;
24
- }
25
-
23
+ function applyModelBlocksVisibilityStyle(modelId, blocks_ids) {
26
24
  const visibilityGroups = {};
27
- const colorGroups = {};
28
- const attributeGroups = {};
29
-
30
25
  for (const block_id of blocks_ids) {
31
26
  const style = modelCommonStyle.modelBlockStyle(modelId, block_id);
32
-
33
27
  const visibility = String(style.visibility);
34
28
  if (!visibilityGroups[visibility]) {
35
29
  visibilityGroups[visibility] = [];
36
30
  }
37
31
  visibilityGroups[visibility].push(block_id);
32
+ }
33
+ return Promise.all(
34
+ Object.entries(visibilityGroups).map(([visibility, ids]) =>
35
+ modelVisibilityStyle.setModelBlocksVisibility(modelId, ids, visibility === "true"),
36
+ ),
37
+ );
38
+ }
38
39
 
39
- const coloring = modelColorStyle.modelBlockColoring(modelId, block_id);
40
+ function applyModelBlocksColoringStyle(modelId, blocks_ids) {
41
+ const activeColoringGroups = {};
42
+ for (const block_id of blocks_ids) {
40
43
  const activeColoring = modelColorStyle.modelBlockActiveColoring(modelId, block_id);
41
- if (activeColoring === "constant") {
42
- const color = modelColorStyle.modelBlockColor(modelId, block_id);
43
- const color_key = JSON.stringify(color);
44
- if (!colorGroups[color_key]) {
45
- colorGroups[color_key] = { activeColoring, color, blocks_ids: [] };
44
+ if (!activeColoringGroups[activeColoring]) {
45
+ activeColoringGroups[activeColoring] = [];
46
+ }
47
+ activeColoringGroups[activeColoring].push(block_id);
48
+ }
49
+
50
+ const coloringPromises = [];
51
+
52
+ for (const [type, type_blocks_ids] of Object.entries(activeColoringGroups)) {
53
+ if (type === "constant") {
54
+ const colorGroups = {};
55
+ for (const block_id of type_blocks_ids) {
56
+ const color = modelColorStyle.modelBlockColor(modelId, block_id);
57
+ const color_key = JSON.stringify(color);
58
+ if (!colorGroups[color_key]) {
59
+ colorGroups[color_key] = { color, blocks_ids: [] };
60
+ }
61
+ colorGroups[color_key].blocks_ids.push(block_id);
46
62
  }
47
- colorGroups[color_key].blocks_ids.push(block_id);
48
- } else if (activeColoring === "random") {
49
- if (!colorGroups["random"]) {
50
- colorGroups["random"] = { activeColoring, color: undefined, blocks_ids: [] };
63
+ coloringPromises.push(
64
+ ...Object.values(colorGroups).map(({ color, blocks_ids: ids }) =>
65
+ modelColorStyle.setModelBlocksColor(modelId, ids, color, "constant"),
66
+ ),
67
+ );
68
+ } else if (type === "random") {
69
+ coloringPromises.push(
70
+ modelColorStyle.setModelBlocksColor(modelId, type_blocks_ids, undefined, "random"),
71
+ );
72
+ } else if (type === "vertex") {
73
+ const vertexGroups = {};
74
+ for (const block_id of type_blocks_ids) {
75
+ const name = modelBlocksVertexAttribute.modelBlocksVertexAttributeName(modelId, block_id);
76
+ const item = modelBlocksVertexAttribute.modelBlocksVertexAttributeItem(modelId, block_id);
77
+ const [minimum, maximum] = modelBlocksVertexAttribute.modelBlocksVertexAttributeRange(
78
+ modelId,
79
+ block_id,
80
+ );
81
+ const colorMap = modelBlocksVertexAttribute.modelBlocksVertexAttributeColorMap(
82
+ modelId,
83
+ block_id,
84
+ );
85
+ const attribute = { name, item, minimum, maximum, colorMap };
86
+ if (!isModelBlocksVertexAttributeValid(attribute)) {
87
+ continue;
88
+ }
89
+ const key = `${name}_${item}_${colorMap}_${minimum}_${maximum}`;
90
+ if (!vertexGroups[key]) {
91
+ vertexGroups[key] = {
92
+ name,
93
+ item,
94
+ minimum,
95
+ maximum,
96
+ colorMap,
97
+ blocks_ids: [],
98
+ };
99
+ }
100
+ vertexGroups[key].blocks_ids.push(block_id);
51
101
  }
52
- colorGroups["random"].blocks_ids.push(block_id);
53
- } else {
54
- const attributeStyle = coloring[activeColoring];
55
- const { name } = attributeStyle;
56
- const { minimum, maximum, colorMap } = attributeStyle.storedConfigs[name];
57
- const attributeGroupKey = `${activeColoring}_${name}_${colorMap}_${minimum}_${maximum}`;
58
- if (!attributeGroups[attributeGroupKey]) {
59
- attributeGroups[attributeGroupKey] = {
60
- activeColoring,
61
- name,
62
- minimum,
63
- maximum,
64
- colorMap,
65
- blocks_ids: [],
66
- };
102
+ coloringPromises.push(
103
+ ...Object.values(vertexGroups).map(
104
+ ({ name, item, minimum, maximum, colorMap, blocks_ids: ids }) =>
105
+ modelBlocksVertexAttribute.setModelBlocksVertexAttribute(modelId, ids, {
106
+ name,
107
+ item,
108
+ minimum,
109
+ maximum,
110
+ colorMap,
111
+ }),
112
+ ),
113
+ );
114
+ } else if (type === "polyhedron") {
115
+ const polyhedronGroups = {};
116
+ for (const block_id of type_blocks_ids) {
117
+ const name = modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeName(
118
+ modelId,
119
+ block_id,
120
+ );
121
+ const item = modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeItem(
122
+ modelId,
123
+ block_id,
124
+ );
125
+ const [minimum, maximum] =
126
+ modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeRange(modelId, block_id);
127
+ const colorMap = modelBlocksPolyhedronAttribute.modelBlocksPolyhedronAttributeColorMap(
128
+ modelId,
129
+ block_id,
130
+ );
131
+ const attribute = { name, item, minimum, maximum, colorMap };
132
+ if (!isModelBlocksPolyhedronAttributeValid(attribute)) {
133
+ continue;
134
+ }
135
+ const key = `${name}_${item}_${colorMap}_${minimum}_${maximum}`;
136
+ if (!polyhedronGroups[key]) {
137
+ polyhedronGroups[key] = {
138
+ name,
139
+ item,
140
+ minimum,
141
+ maximum,
142
+ colorMap,
143
+ blocks_ids: [],
144
+ };
145
+ }
146
+ polyhedronGroups[key].blocks_ids.push(block_id);
67
147
  }
68
- attributeGroups[attributeGroupKey].blocks_ids.push(block_id);
148
+ coloringPromises.push(
149
+ ...Object.values(polyhedronGroups).map(
150
+ ({ name, item, minimum, maximum, colorMap, blocks_ids: ids }) =>
151
+ modelBlocksPolyhedronAttribute.setModelBlocksPolyhedronAttribute(modelId, ids, {
152
+ name,
153
+ item,
154
+ minimum,
155
+ maximum,
156
+ colorMap,
157
+ }),
158
+ ),
159
+ );
69
160
  }
70
161
  }
71
162
 
72
- const promises = [
73
- ...Object.entries(visibilityGroups).map(([visibility, ids]) =>
74
- modelVisibilityStyle.setModelBlocksVisibility(modelId, ids, visibility === "true"),
75
- ),
76
- ...Object.values(colorGroups).map(({ activeColoring, color, blocks_ids: ids }) =>
77
- modelColorStyle.setModelBlocksColor(modelId, ids, color, activeColoring),
78
- ),
79
- ...Object.values(attributeGroups).flatMap(
80
- ({ activeColoring, name, minimum, maximum, colorMap, blocks_ids: ids }) => {
81
- const isVertex = activeColoring === "vertex";
82
- const attributeStyle = isVertex
83
- ? modelBlocksVertexAttribute
84
- : modelBlocksPolyhedronAttribute;
85
- const setAttributeName = isVertex
86
- ? attributeStyle.setModelBlocksVertexAttributeName
87
- : attributeStyle.setModelBlocksPolyhedronAttributeName;
88
- const setAttributeRange = isVertex
89
- ? attributeStyle.setModelBlocksVertexAttributeRange
90
- : attributeStyle.setModelBlocksPolyhedronAttributeRange;
91
- const setAttributeColorMap = isVertex
92
- ? attributeStyle.setModelBlocksVertexAttributeColorMap
93
- : attributeStyle.setModelBlocksPolyhedronAttributeColorMap;
163
+ return Promise.all(coloringPromises);
164
+ }
94
165
 
95
- const list = [setAttributeName(modelId, ids, name)];
96
- if (minimum !== undefined && maximum !== undefined) {
97
- list.push(setAttributeRange(modelId, ids, minimum, maximum));
98
- }
99
- if (colorMap) {
100
- list.push(setAttributeColorMap(modelId, ids, colorMap));
101
- }
102
- return list;
103
- },
104
- ),
105
- ];
166
+ async function applyModelBlocksStyle(modelId) {
167
+ const blocks_ids = await dataStore.getBlocksGeodeIds(modelId);
168
+ if (blocks_ids.length === 0) {
169
+ return;
170
+ }
106
171
 
107
- return Promise.all(promises);
172
+ return Promise.all([
173
+ applyModelBlocksVisibilityStyle(modelId, blocks_ids),
174
+ applyModelBlocksColoringStyle(modelId, blocks_ids),
175
+ ]);
108
176
  }
109
177
 
110
178
  return {