@geode/opengeodeweb-front 10.22.1 → 10.23.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 (39) hide show
  1. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +256 -0
  2. package/app/components/Viewer/Generic/Model/CornersOptions.vue +187 -0
  3. package/app/components/Viewer/Generic/Model/LinesOptions.vue +252 -0
  4. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +72 -132
  5. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +260 -0
  6. package/app/components/Viewer/Options/AttributeSelector.vue +15 -2
  7. package/app/components/Viewer/Options/ColoringTypeSelector.vue +53 -11
  8. package/app/stores/app.js +1 -0
  9. package/app/stores/hybrid_viewer.js +21 -2
  10. package/app/utils/default_styles/constants.js +57 -0
  11. package/app/utils/default_styles/index.js +54 -0
  12. package/app/utils/default_styles/meshes.js +185 -0
  13. package/app/utils/default_styles/models.js +192 -0
  14. package/internal/stores/data_style/model/blocks/color.js +6 -1
  15. package/internal/stores/data_style/model/blocks/index.js +60 -4
  16. package/internal/stores/data_style/model/blocks/polyhedron.js +144 -0
  17. package/internal/stores/data_style/model/blocks/vertex.js +141 -0
  18. package/internal/stores/data_style/model/color.js +119 -12
  19. package/internal/stores/data_style/model/common.js +18 -21
  20. package/internal/stores/data_style/model/corners/color.js +6 -1
  21. package/internal/stores/data_style/model/corners/index.js +48 -4
  22. package/internal/stores/data_style/model/corners/vertex.js +144 -0
  23. package/internal/stores/data_style/model/lines/color.js +6 -1
  24. package/internal/stores/data_style/model/lines/edge.js +138 -0
  25. package/internal/stores/data_style/model/lines/index.js +58 -4
  26. package/internal/stores/data_style/model/lines/vertex.js +138 -0
  27. package/internal/stores/data_style/model/selection.js +50 -29
  28. package/internal/stores/data_style/model/surfaces/color.js +11 -1
  29. package/internal/stores/data_style/model/surfaces/index.js +60 -4
  30. package/internal/stores/data_style/model/surfaces/polygon.js +144 -0
  31. package/internal/stores/data_style/model/surfaces/vertex.js +144 -0
  32. package/internal/stores/data_style/model/visibility.js +17 -4
  33. package/internal/stores/data_style/state.js +101 -21
  34. package/package.json +3 -3
  35. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +118 -0
  36. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +64 -0
  37. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +112 -0
  38. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +118 -0
  39. package/app/utils/default_styles.js +0 -327
package/app/stores/app.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { api_fetch } from "@ogw_internal/utils/api_fetch.js";
3
3
  import { upload_file } from "@ogw_internal/utils/upload_file.js";
4
4
 
5
+ // oxlint-disable-next-line max-lines-per-function, max-statements
5
6
  export const useAppStore = defineStore("app", () => {
6
7
  const stores = [];
7
8
 
@@ -184,9 +184,28 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
184
184
  });
185
185
  }
186
186
 
187
+ let renderPromise = undefined;
188
+ let renderPending = false;
189
+
187
190
  function remoteRender() {
188
- const schema = viewer_schemas.opengeodeweb_viewer.viewer.render;
189
- return viewerStore.request({ schema });
191
+ if (renderPromise) {
192
+ renderPending = true;
193
+ return renderPromise;
194
+ }
195
+
196
+ renderPromise = (async () => {
197
+ try {
198
+ const schema = viewer_schemas.opengeodeweb_viewer.viewer.render;
199
+ await viewerStore.request({ schema });
200
+ } finally {
201
+ renderPromise = undefined;
202
+ if (renderPending) {
203
+ renderPending = false;
204
+ await remoteRender();
205
+ }
206
+ }
207
+ })();
208
+ return renderPromise;
190
209
  }
191
210
 
192
211
  const hoverTimeoutRef = ref(undefined);
@@ -0,0 +1,57 @@
1
+ // Mesh
2
+ const POINTS_DEFAULT_VISIBILITY = true;
3
+ const POINTS_DEFAULT_SIZE = 10;
4
+ const POINTS_DEFAULT_COLOR = { red: 20, green: 20, blue: 20, alpha: 1 };
5
+ const EDGES_DEFAULT_VISIBILITY = true;
6
+ const EDGES_DEFAULT_WIDTH = 2;
7
+ const EDGES_DEFAULT_COLOR = { red: 20, green: 20, blue: 20, alpha: 1 };
8
+ const CELLS_DEFAULT_VISIBILITY = true;
9
+ const CELLS_DEFAULT_COLOR = { red: 255, green: 255, blue: 255, alpha: 1 };
10
+ const POLYGONS_DEFAULT_VISIBILITY = true;
11
+ const POLYGONS_DEFAULT_COLOR = { red: 255, green: 255, blue: 255, alpha: 1 };
12
+ const POLYHEDRA_DEFAULT_VISIBILITY = true;
13
+ const POLYHEDRA_DEFAULT_COLOR = { red: 255, green: 255, blue: 255, alpha: 1 };
14
+
15
+ // Model
16
+ const CORNERS_DEFAULT_VISIBILITY = true;
17
+ const CORNERS_DEFAULT_COLOR = { red: 20, green: 20, blue: 20, alpha: 1 };
18
+ const LINES_DEFAULT_VISIBILITY = true;
19
+ const LINES_DEFAULT_COLOR = { red: 20, green: 20, blue: 20, alpha: 1 };
20
+ const SURFACES_DEFAULT_VISIBILITY = true;
21
+ const SURFACES_DEFAULT_COLOR = { red: 255, green: 255, blue: 255, alpha: 1 };
22
+ const BLOCKS_DEFAULT_VISIBILITY = true;
23
+ const BLOCKS_DEFAULT_COLOR = { red: 255, green: 255, blue: 255, alpha: 1 };
24
+
25
+ const MESH_COMPONENT_TYPES = ["Corner", "Line", "Surface", "Block"];
26
+
27
+ const DEFAULT_MODEL_COMPONENT_TYPE_COLORS = {
28
+ Corner: CORNERS_DEFAULT_COLOR,
29
+ Line: LINES_DEFAULT_COLOR,
30
+ Surface: SURFACES_DEFAULT_COLOR,
31
+ Block: BLOCKS_DEFAULT_COLOR,
32
+ };
33
+
34
+ export {
35
+ POINTS_DEFAULT_VISIBILITY,
36
+ POINTS_DEFAULT_SIZE,
37
+ POINTS_DEFAULT_COLOR,
38
+ EDGES_DEFAULT_VISIBILITY,
39
+ EDGES_DEFAULT_WIDTH,
40
+ EDGES_DEFAULT_COLOR,
41
+ CELLS_DEFAULT_VISIBILITY,
42
+ CELLS_DEFAULT_COLOR,
43
+ POLYGONS_DEFAULT_VISIBILITY,
44
+ POLYGONS_DEFAULT_COLOR,
45
+ POLYHEDRA_DEFAULT_VISIBILITY,
46
+ POLYHEDRA_DEFAULT_COLOR,
47
+ CORNERS_DEFAULT_VISIBILITY,
48
+ CORNERS_DEFAULT_COLOR,
49
+ LINES_DEFAULT_VISIBILITY,
50
+ LINES_DEFAULT_COLOR,
51
+ SURFACES_DEFAULT_VISIBILITY,
52
+ SURFACES_DEFAULT_COLOR,
53
+ BLOCKS_DEFAULT_VISIBILITY,
54
+ BLOCKS_DEFAULT_COLOR,
55
+ MESH_COMPONENT_TYPES,
56
+ DEFAULT_MODEL_COMPONENT_TYPE_COLORS,
57
+ };
@@ -0,0 +1,54 @@
1
+ import {
2
+ brepDefaultStyle,
3
+ crossSectionDefaultStyle,
4
+ implicitCrossSectionDefaultStyle,
5
+ implicitStructuralModelDefaultStyle,
6
+ sectionDefaultStyle,
7
+ structuralModelDefaultStyle,
8
+ } from "./models";
9
+ import {
10
+ edgedCurveDefaultStyle,
11
+ grid2dDefaultStyle,
12
+ grid3dDefaultStyle,
13
+ pointSetDefaultStyle,
14
+ solidDefaultStyle,
15
+ surfaceDefaultStyle,
16
+ } from "./meshes";
17
+
18
+ function default_styles() {
19
+ return {
20
+ BRep: brepDefaultStyle(),
21
+ CrossSection: crossSectionDefaultStyle(),
22
+ EdgedCurve2D: edgedCurveDefaultStyle(),
23
+ EdgedCurve3D: edgedCurveDefaultStyle(),
24
+ Graph: {},
25
+ HybridSolid3D: solidDefaultStyle(),
26
+ ImplicitCrossSection: implicitCrossSectionDefaultStyle(),
27
+ ImplicitStructuralModel: implicitStructuralModelDefaultStyle(),
28
+ LightRegularGrid2D: grid2dDefaultStyle(),
29
+ LightRegularGrid3D: grid3dDefaultStyle(),
30
+ PointSet2D: pointSetDefaultStyle(),
31
+ PointSet3D: pointSetDefaultStyle(),
32
+ PolygonalSurface2D: surfaceDefaultStyle(),
33
+ PolygonalSurface3D: surfaceDefaultStyle(),
34
+ PolyhedralSolid3D: solidDefaultStyle(),
35
+ RasterImage2D: {},
36
+ RasterImage3D: {},
37
+ RegularGrid2D: grid2dDefaultStyle(),
38
+ RegularGrid3D: grid3dDefaultStyle(),
39
+ Section: sectionDefaultStyle(),
40
+ StructuralModel: structuralModelDefaultStyle(),
41
+ TetrahedralSolid3D: solidDefaultStyle(),
42
+ TriangulatedSurface2D: surfaceDefaultStyle(),
43
+ TriangulatedSurface3D: surfaceDefaultStyle(),
44
+ VertexSet: {},
45
+ };
46
+ }
47
+
48
+ function getDefaultStyle(type) {
49
+ return default_styles()[type];
50
+ }
51
+
52
+ export { DEFAULT_MODEL_COMPONENT_TYPE_STYLES } from "./models";
53
+ export { MESH_COMPONENT_TYPES, DEFAULT_MODEL_COMPONENT_TYPE_COLORS } from "./constants";
54
+ export { getDefaultStyle };
@@ -0,0 +1,185 @@
1
+ import {
2
+ CELLS_DEFAULT_COLOR,
3
+ CELLS_DEFAULT_VISIBILITY,
4
+ EDGES_DEFAULT_COLOR,
5
+ EDGES_DEFAULT_VISIBILITY,
6
+ EDGES_DEFAULT_WIDTH,
7
+ POINTS_DEFAULT_COLOR,
8
+ POINTS_DEFAULT_SIZE,
9
+ POINTS_DEFAULT_VISIBILITY,
10
+ POLYGONS_DEFAULT_COLOR,
11
+ POLYGONS_DEFAULT_VISIBILITY,
12
+ POLYHEDRA_DEFAULT_COLOR,
13
+ POLYHEDRA_DEFAULT_VISIBILITY,
14
+ } from "./constants";
15
+
16
+ function meshPointsDefaultStyle(
17
+ visibility = POINTS_DEFAULT_VISIBILITY,
18
+ size = POINTS_DEFAULT_SIZE,
19
+ color = POINTS_DEFAULT_COLOR,
20
+ ) {
21
+ return {
22
+ visibility,
23
+ coloring: {
24
+ active: "color",
25
+ color,
26
+ vertex: {
27
+ name: undefined,
28
+ storedConfigs: {},
29
+ },
30
+ },
31
+ size,
32
+ };
33
+ }
34
+
35
+ function meshEdgesDefaultStyle(
36
+ visibility = EDGES_DEFAULT_VISIBILITY,
37
+ width = EDGES_DEFAULT_WIDTH,
38
+ color = EDGES_DEFAULT_COLOR,
39
+ ) {
40
+ return {
41
+ visibility,
42
+ coloring: {
43
+ active: "color",
44
+ color,
45
+ edge: {
46
+ name: undefined,
47
+ storedConfigs: {},
48
+ },
49
+ vertex: {
50
+ name: undefined,
51
+ storedConfigs: {},
52
+ },
53
+ },
54
+ width,
55
+ };
56
+ }
57
+
58
+ function meshCellsDefaultStyle(visibility = CELLS_DEFAULT_VISIBILITY, color = CELLS_DEFAULT_COLOR) {
59
+ return {
60
+ visibility,
61
+ coloring: {
62
+ active: "color",
63
+ cell: {
64
+ name: undefined,
65
+ storedConfigs: {},
66
+ },
67
+ color,
68
+ textures: undefined,
69
+ vertex: {
70
+ name: undefined,
71
+ storedConfigs: {},
72
+ },
73
+ },
74
+ };
75
+ }
76
+
77
+ function meshPolygonsDefaultStyle(
78
+ visibility = POLYGONS_DEFAULT_VISIBILITY,
79
+ color = POLYGONS_DEFAULT_COLOR,
80
+ ) {
81
+ return {
82
+ visibility,
83
+ coloring: {
84
+ active: "color",
85
+ color,
86
+ textures: undefined,
87
+ polygon: {
88
+ name: undefined,
89
+ storedConfigs: {},
90
+ },
91
+ vertex: {
92
+ name: undefined,
93
+ storedConfigs: {},
94
+ },
95
+ },
96
+ };
97
+ }
98
+
99
+ function meshPolyhedraDefaultStyle(
100
+ visibility = POLYHEDRA_DEFAULT_VISIBILITY,
101
+ color = POLYHEDRA_DEFAULT_COLOR,
102
+ ) {
103
+ return {
104
+ visibility,
105
+ coloring: {
106
+ active: "color",
107
+ color,
108
+ polyhedron: {
109
+ name: undefined,
110
+ storedConfigs: {},
111
+ },
112
+ vertex: {
113
+ name: undefined,
114
+ storedConfigs: {},
115
+ },
116
+ },
117
+ };
118
+ }
119
+
120
+ function pointSetDefaultStyle() {
121
+ return {
122
+ visibility: true,
123
+ points: meshPointsDefaultStyle(),
124
+ };
125
+ }
126
+
127
+ function edgedCurveDefaultStyle() {
128
+ return {
129
+ visibility: true,
130
+ points: meshPointsDefaultStyle(),
131
+ edges: meshEdgesDefaultStyle(),
132
+ };
133
+ }
134
+
135
+ function grid2dDefaultStyle() {
136
+ return {
137
+ visibility: true,
138
+ points: meshPointsDefaultStyle(false),
139
+ edges: meshEdgesDefaultStyle(false),
140
+ cells: meshCellsDefaultStyle(),
141
+ };
142
+ }
143
+
144
+ function grid3dDefaultStyle() {
145
+ return {
146
+ visibility: true,
147
+ points: meshPointsDefaultStyle(false),
148
+ edges: meshEdgesDefaultStyle(false),
149
+ cells: meshCellsDefaultStyle(),
150
+ polyhedra: meshPolyhedraDefaultStyle(),
151
+ };
152
+ }
153
+
154
+ function surfaceDefaultStyle() {
155
+ return {
156
+ visibility: true,
157
+ points: meshPointsDefaultStyle(false),
158
+ edges: meshEdgesDefaultStyle(false),
159
+ polygons: meshPolygonsDefaultStyle(),
160
+ };
161
+ }
162
+
163
+ function solidDefaultStyle() {
164
+ return {
165
+ visibility: true,
166
+ points: meshPointsDefaultStyle(false),
167
+ edges: meshEdgesDefaultStyle(false),
168
+ polygons: meshPolygonsDefaultStyle(),
169
+ polyhedra: meshPolyhedraDefaultStyle(),
170
+ };
171
+ }
172
+
173
+ export {
174
+ meshPointsDefaultStyle,
175
+ meshEdgesDefaultStyle,
176
+ meshCellsDefaultStyle,
177
+ meshPolygonsDefaultStyle,
178
+ meshPolyhedraDefaultStyle,
179
+ pointSetDefaultStyle,
180
+ edgedCurveDefaultStyle,
181
+ grid2dDefaultStyle,
182
+ grid3dDefaultStyle,
183
+ surfaceDefaultStyle,
184
+ solidDefaultStyle,
185
+ };
@@ -0,0 +1,192 @@
1
+ import {
2
+ BLOCKS_DEFAULT_COLOR,
3
+ BLOCKS_DEFAULT_VISIBILITY,
4
+ CORNERS_DEFAULT_COLOR,
5
+ CORNERS_DEFAULT_VISIBILITY,
6
+ EDGES_DEFAULT_VISIBILITY,
7
+ EDGES_DEFAULT_WIDTH,
8
+ LINES_DEFAULT_COLOR,
9
+ LINES_DEFAULT_VISIBILITY,
10
+ POINTS_DEFAULT_SIZE,
11
+ POINTS_DEFAULT_VISIBILITY,
12
+ SURFACES_DEFAULT_COLOR,
13
+ SURFACES_DEFAULT_VISIBILITY,
14
+ } from "./constants";
15
+
16
+ function modelCornersDefaultStyle(
17
+ visibility = CORNERS_DEFAULT_VISIBILITY,
18
+ color = CORNERS_DEFAULT_COLOR,
19
+ ) {
20
+ return {
21
+ visibility,
22
+ color,
23
+ color_mode: "constant",
24
+ vertex_attribute: {
25
+ name: undefined,
26
+ storedConfigs: {},
27
+ },
28
+ };
29
+ }
30
+
31
+ function modelLinesDefaultStyle(
32
+ visibility = LINES_DEFAULT_VISIBILITY,
33
+ color = LINES_DEFAULT_COLOR,
34
+ ) {
35
+ return {
36
+ visibility,
37
+ color,
38
+ color_mode: "constant",
39
+ vertex_attribute: {
40
+ name: undefined,
41
+ storedConfigs: {},
42
+ },
43
+ edge_attribute: {
44
+ name: undefined,
45
+ storedConfigs: {},
46
+ },
47
+ };
48
+ }
49
+
50
+ function modelSurfacesDefaultStyle(
51
+ visibility = SURFACES_DEFAULT_VISIBILITY,
52
+ color = SURFACES_DEFAULT_COLOR,
53
+ ) {
54
+ return {
55
+ visibility,
56
+ color,
57
+ color_mode: "constant",
58
+ vertex_attribute: {
59
+ name: undefined,
60
+ storedConfigs: {},
61
+ },
62
+ polygon_attribute: {
63
+ name: undefined,
64
+ storedConfigs: {},
65
+ },
66
+ };
67
+ }
68
+
69
+ function modelBlocksDefaultStyle(
70
+ visibility = BLOCKS_DEFAULT_VISIBILITY,
71
+ color = BLOCKS_DEFAULT_COLOR,
72
+ ) {
73
+ return {
74
+ visibility,
75
+ color,
76
+ color_mode: "constant",
77
+ vertex_attribute: {
78
+ name: undefined,
79
+ storedConfigs: {},
80
+ },
81
+ polyhedron_attribute: {
82
+ name: undefined,
83
+ storedConfigs: {},
84
+ },
85
+ };
86
+ }
87
+
88
+ function modelPointsDefaultStyle(
89
+ visibility = POINTS_DEFAULT_VISIBILITY,
90
+ size = POINTS_DEFAULT_SIZE,
91
+ ) {
92
+ return { visibility, size };
93
+ }
94
+
95
+ function modelEdgesDefaultStyle(
96
+ visibility = EDGES_DEFAULT_VISIBILITY,
97
+ width = EDGES_DEFAULT_WIDTH,
98
+ ) {
99
+ return { visibility, width };
100
+ }
101
+
102
+ const DEFAULT_MODEL_COMPONENT_TYPE_STYLES = {
103
+ Corner: modelCornersDefaultStyle(),
104
+ Line: modelLinesDefaultStyle(),
105
+ Surface: modelSurfacesDefaultStyle(),
106
+ Block: modelBlocksDefaultStyle(),
107
+ };
108
+
109
+ function brepDefaultStyle() {
110
+ return {
111
+ visibility: true,
112
+ corners: modelCornersDefaultStyle(),
113
+ lines: modelLinesDefaultStyle(),
114
+ surfaces: modelSurfacesDefaultStyle(),
115
+ blocks: modelBlocksDefaultStyle(),
116
+ points: modelPointsDefaultStyle(false),
117
+ edges: modelEdgesDefaultStyle(false),
118
+ };
119
+ }
120
+
121
+ function crossSectionDefaultStyle() {
122
+ return {
123
+ visibility: true,
124
+ corners: modelCornersDefaultStyle(),
125
+ lines: modelLinesDefaultStyle(),
126
+ surfaces: modelSurfacesDefaultStyle(),
127
+ points: modelPointsDefaultStyle(false),
128
+ edges: modelEdgesDefaultStyle(false),
129
+ };
130
+ }
131
+
132
+ function structuralModelDefaultStyle() {
133
+ return {
134
+ visibility: true,
135
+ corners: modelCornersDefaultStyle(),
136
+ lines: modelLinesDefaultStyle(),
137
+ surfaces: modelSurfacesDefaultStyle(),
138
+ blocks: modelBlocksDefaultStyle(),
139
+ points: modelPointsDefaultStyle(false),
140
+ edges: modelEdgesDefaultStyle(false),
141
+ };
142
+ }
143
+
144
+ function sectionDefaultStyle() {
145
+ return {
146
+ visibility: true,
147
+ corners: modelCornersDefaultStyle(),
148
+ lines: modelLinesDefaultStyle(),
149
+ surfaces: modelSurfacesDefaultStyle(),
150
+ points: modelPointsDefaultStyle(false),
151
+ edges: modelEdgesDefaultStyle(false),
152
+ };
153
+ }
154
+
155
+ function implicitCrossSectionDefaultStyle() {
156
+ return {
157
+ visibility: true,
158
+ corners: modelCornersDefaultStyle(),
159
+ lines: modelLinesDefaultStyle(),
160
+ surfaces: modelSurfacesDefaultStyle(),
161
+ points: modelPointsDefaultStyle(false),
162
+ edges: modelEdgesDefaultStyle(false),
163
+ };
164
+ }
165
+
166
+ function implicitStructuralModelDefaultStyle() {
167
+ return {
168
+ visibility: true,
169
+ corners: modelCornersDefaultStyle(),
170
+ lines: modelLinesDefaultStyle(),
171
+ surfaces: modelSurfacesDefaultStyle(),
172
+ blocks: modelBlocksDefaultStyle(),
173
+ points: modelPointsDefaultStyle(false),
174
+ edges: modelEdgesDefaultStyle(false),
175
+ };
176
+ }
177
+
178
+ export {
179
+ modelCornersDefaultStyle,
180
+ modelLinesDefaultStyle,
181
+ modelSurfacesDefaultStyle,
182
+ modelBlocksDefaultStyle,
183
+ modelPointsDefaultStyle,
184
+ modelEdgesDefaultStyle,
185
+ DEFAULT_MODEL_COMPONENT_TYPE_STYLES,
186
+ brepDefaultStyle,
187
+ crossSectionDefaultStyle,
188
+ structuralModelDefaultStyle,
189
+ sectionDefaultStyle,
190
+ implicitCrossSectionDefaultStyle,
191
+ implicitStructuralModelDefaultStyle,
192
+ };
@@ -16,5 +16,10 @@ export function useModelBlocksColor() {
16
16
  return modelCommonStyle.setModelTypeColor(modelId, blocks_ids, color, schema, color_mode);
17
17
  }
18
18
 
19
- return { setModelBlocksColor, modelBlockColor };
19
+ function modelBlockColorMode(id, block_id) {
20
+ const mode = modelBlocksCommonStyle.modelBlockStyle(id, block_id).color_mode || "constant";
21
+ return mode === "constant" ? "color" : mode;
22
+ }
23
+
24
+ return { setModelBlocksColor, modelBlockColor, modelBlockColorMode };
20
25
  }
@@ -1,6 +1,8 @@
1
1
  import { useDataStore } from "@ogw_front/stores/data";
2
2
  import { useModelBlocksColor } from "./color";
3
3
  import { useModelBlocksCommonStyle } from "./common";
4
+ import { useModelBlocksPolyhedronAttribute } from "./polyhedron";
5
+ import { useModelBlocksVertexAttribute } from "./vertex";
4
6
  import { useModelBlocksVisibility } from "./visibility";
5
7
 
6
8
  async function setModelBlocksDefaultStyle(_id) {
@@ -12,6 +14,8 @@ export function useModelBlocksStyle() {
12
14
  const modelCommonStyle = useModelBlocksCommonStyle();
13
15
  const modelVisibilityStyle = useModelBlocksVisibility();
14
16
  const modelColorStyle = useModelBlocksColor();
17
+ const modelBlocksVertexAttribute = useModelBlocksVertexAttribute();
18
+ const modelBlocksPolyhedronAttribute = useModelBlocksPolyhedronAttribute();
15
19
 
16
20
  async function applyModelBlocksStyle(modelId) {
17
21
  const blocks_ids = await dataStore.getBlocksGeodeIds(modelId);
@@ -21,6 +25,7 @@ export function useModelBlocksStyle() {
21
25
 
22
26
  const visibilityGroups = {};
23
27
  const colorGroups = {};
28
+ const attributeGroups = {};
24
29
 
25
30
  for (const block_id of blocks_ids) {
26
31
  const style = modelCommonStyle.modelBlockStyle(modelId, block_id);
@@ -32,11 +37,34 @@ export function useModelBlocksStyle() {
32
37
  visibilityGroups[visibility].push(block_id);
33
38
 
34
39
  const color_mode = style.color_mode || "constant";
35
- const color_key = color_mode === "random" ? "random" : JSON.stringify(style.color);
36
- if (!colorGroups[color_key]) {
37
- colorGroups[color_key] = { color_mode, color: style.color, blocks_ids: [] };
40
+ if (color_mode === "constant" || color_mode === "random") {
41
+ const color_key = color_mode === "random" ? "random" : JSON.stringify(style.color);
42
+ if (!colorGroups[color_key]) {
43
+ colorGroups[color_key] = { color_mode, color: style.color, blocks_ids: [] };
44
+ }
45
+ colorGroups[color_key].blocks_ids.push(block_id);
46
+ } else {
47
+ const attributeTypeKey = `${color_mode}_attribute`;
48
+ const attributeStyle = style[attributeTypeKey] || {};
49
+ const { name } = attributeStyle;
50
+ if (name) {
51
+ const storedConfig =
52
+ (attributeStyle.storedConfigs && attributeStyle.storedConfigs[name]) || {};
53
+ const { minimum, maximum, colorMap } = storedConfig;
54
+ const attributeGroupKey = `${color_mode}_${name}_${colorMap}_${minimum}_${maximum}`;
55
+ if (!attributeGroups[attributeGroupKey]) {
56
+ attributeGroups[attributeGroupKey] = {
57
+ color_mode,
58
+ name,
59
+ minimum,
60
+ maximum,
61
+ colorMap,
62
+ blocks_ids: [],
63
+ };
64
+ }
65
+ attributeGroups[attributeGroupKey].blocks_ids.push(block_id);
66
+ }
38
67
  }
39
- colorGroups[color_key].blocks_ids.push(block_id);
40
68
  }
41
69
 
42
70
  const promises = [
@@ -46,6 +74,32 @@ export function useModelBlocksStyle() {
46
74
  ...Object.values(colorGroups).map(({ color_mode, color, blocks_ids: ids }) =>
47
75
  modelColorStyle.setModelBlocksColor(modelId, ids, color, color_mode),
48
76
  ),
77
+ ...Object.values(attributeGroups).flatMap(
78
+ ({ color_mode, name, minimum, maximum, colorMap, blocks_ids: ids }) => {
79
+ const isVertex = color_mode === "vertex";
80
+ const attributeStyle = isVertex
81
+ ? modelBlocksVertexAttribute
82
+ : modelBlocksPolyhedronAttribute;
83
+ const setAttributeName = isVertex
84
+ ? attributeStyle.setModelBlocksVertexAttributeName
85
+ : attributeStyle.setModelBlocksPolyhedronAttributeName;
86
+ const setAttributeRange = isVertex
87
+ ? attributeStyle.setModelBlocksVertexAttributeRange
88
+ : attributeStyle.setModelBlocksPolyhedronAttributeRange;
89
+ const setAttributeColorMap = isVertex
90
+ ? attributeStyle.setModelBlocksVertexAttributeColorMap
91
+ : attributeStyle.setModelBlocksPolyhedronAttributeColorMap;
92
+
93
+ const list = [setAttributeName(modelId, ids, name)];
94
+ if (minimum !== undefined && maximum !== undefined) {
95
+ list.push(setAttributeRange(modelId, ids, minimum, maximum));
96
+ }
97
+ if (colorMap) {
98
+ list.push(setAttributeColorMap(modelId, ids, colorMap));
99
+ }
100
+ return list;
101
+ },
102
+ ),
49
103
  ];
50
104
 
51
105
  return Promise.all(promises);
@@ -57,5 +111,7 @@ export function useModelBlocksStyle() {
57
111
  ...modelCommonStyle,
58
112
  ...modelVisibilityStyle,
59
113
  ...modelColorStyle,
114
+ ...modelBlocksVertexAttribute,
115
+ ...modelBlocksPolyhedronAttribute,
60
116
  };
61
117
  }