@geode/opengeodeweb-front 10.2.1 → 10.3.0

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 (83) hide show
  1. package/.github/workflows/manual_release.yml +11 -0
  2. package/app/components/Step.vue +2 -2
  3. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +63 -19
  4. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +65 -18
  5. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +8 -15
  6. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +8 -9
  7. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +8 -8
  8. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +6 -6
  9. package/app/components/Viewer/Generic/Model/EdgesOptions.vue +2 -2
  10. package/app/components/Viewer/Generic/Model/PointsOptions.vue +4 -4
  11. package/app/components/Viewer/Options/AttributeColorBar.vue +58 -0
  12. package/app/components/Viewer/Options/CellAttributeSelector.vue +51 -19
  13. package/app/components/Viewer/Options/ColorMapList.vue +216 -0
  14. package/app/components/Viewer/Options/ColorMapPicker.vue +168 -0
  15. package/app/components/Viewer/Options/ColoringTypeSelector.vue +46 -24
  16. package/app/components/Viewer/Options/EdgeAttributeSelector.vue +53 -41
  17. package/app/components/Viewer/Options/PolygonAttributeSelector.vue +52 -19
  18. package/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +57 -20
  19. package/app/components/Viewer/Options/VertexAttributeSelector.vue +47 -15
  20. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +38 -14
  21. package/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue +74 -18
  22. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +75 -17
  23. package/app/components/Viewer/TreeComponent.vue +26 -76
  24. package/app/stores/data_style.js +3 -3
  25. package/app/utils/colormap.js +5 -0
  26. package/app/utils/default_styles.js +36 -9
  27. package/internal/stores/data_style/mesh/cells/cell.js +153 -0
  28. package/internal/stores/data_style/mesh/cells/color.js +40 -0
  29. package/internal/stores/data_style/mesh/cells/common.js +23 -0
  30. package/internal/stores/data_style/mesh/cells/index.js +84 -0
  31. package/internal/stores/data_style/mesh/cells/textures.js +36 -0
  32. package/internal/stores/data_style/mesh/cells/vertex.js +153 -0
  33. package/internal/stores/data_style/mesh/cells/visibility.js +40 -0
  34. package/internal/stores/data_style/mesh/edges/color.js +40 -0
  35. package/internal/stores/data_style/mesh/edges/common.js +23 -0
  36. package/internal/stores/data_style/mesh/edges/edge.js +141 -0
  37. package/internal/stores/data_style/mesh/edges/index.js +88 -0
  38. package/internal/stores/data_style/mesh/edges/vertex.js +153 -0
  39. package/internal/stores/data_style/mesh/edges/visibility.js +40 -0
  40. package/internal/stores/data_style/mesh/edges/width.js +40 -0
  41. package/internal/stores/{mesh → data_style/mesh}/index.js +25 -23
  42. package/internal/stores/data_style/mesh/points/color.js +40 -0
  43. package/internal/stores/data_style/mesh/points/common.js +23 -0
  44. package/internal/stores/data_style/mesh/points/index.js +89 -0
  45. package/internal/stores/data_style/mesh/points/size.js +40 -0
  46. package/internal/stores/data_style/mesh/points/vertex.js +153 -0
  47. package/internal/stores/data_style/mesh/points/visibility.js +40 -0
  48. package/internal/stores/data_style/mesh/polygons/color.js +40 -0
  49. package/internal/stores/data_style/mesh/polygons/common.js +23 -0
  50. package/internal/stores/data_style/mesh/polygons/index.js +89 -0
  51. package/internal/stores/data_style/mesh/polygons/polygon.js +145 -0
  52. package/internal/stores/data_style/mesh/polygons/textures.js +40 -0
  53. package/internal/stores/data_style/mesh/polygons/vertex.js +153 -0
  54. package/internal/stores/data_style/mesh/polygons/visibility.js +40 -0
  55. package/internal/stores/data_style/mesh/polyhedra/color.js +40 -0
  56. package/internal/stores/data_style/mesh/polyhedra/common.js +23 -0
  57. package/internal/stores/data_style/mesh/polyhedra/index.js +83 -0
  58. package/internal/stores/data_style/mesh/polyhedra/polyhedron.js +139 -0
  59. package/internal/stores/data_style/mesh/polyhedra/vertex.js +153 -0
  60. package/internal/stores/data_style/mesh/polyhedra/visibility.js +41 -0
  61. package/internal/stores/{model → data_style/model}/blocks.js +1 -1
  62. package/internal/stores/{model → data_style/model}/corners.js +1 -1
  63. package/internal/stores/{model → data_style/model}/edges.js +1 -1
  64. package/internal/stores/{model → data_style/model}/index.js +3 -3
  65. package/internal/stores/{model → data_style/model}/lines.js +1 -1
  66. package/internal/stores/{model → data_style/model}/points.js +1 -1
  67. package/internal/stores/{model → data_style/model}/surfaces.js +1 -1
  68. package/internal/stores/{data_style_state.js → data_style/state.js} +6 -3
  69. package/package.json +1 -1
  70. package/tests/integration/microservices/back/requirements.txt +1 -1
  71. package/tests/integration/microservices/viewer/requirements.txt +1 -1
  72. package/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +18 -18
  73. package/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +22 -16
  74. package/tests/integration/stores/data_style/mesh/index.nuxt.test.js +1 -1
  75. package/tests/integration/stores/data_style/mesh/points.nuxt.test.js +14 -12
  76. package/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +16 -19
  77. package/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +16 -19
  78. package/tests/vitest.config.js +3 -0
  79. package/internal/stores/mesh/cells.js +0 -175
  80. package/internal/stores/mesh/edges.js +0 -171
  81. package/internal/stores/mesh/points.js +0 -142
  82. package/internal/stores/mesh/polygons.js +0 -181
  83. package/internal/stores/mesh/polyhedra.js +0 -151
@@ -86,28 +86,22 @@ describe("Mesh polyhedra", () => {
86
86
  {
87
87
  name: "vertex",
88
88
  function: () =>
89
- dataStyleStore.setMeshPolyhedraVertexAttribute(
89
+ dataStyleStore.setMeshPolyhedraVertexAttributeName(
90
90
  id,
91
- vertex_attribute,
91
+ vertex_attribute.name,
92
92
  ),
93
93
  },
94
94
  {
95
95
  name: "polyhedron",
96
96
  function: () =>
97
- dataStyleStore.setMeshPolyhedraPolyhedronAttribute(
97
+ dataStyleStore.setMeshPolyhedraPolyhedronAttributeName(
98
98
  id,
99
- polyhedron_attribute,
99
+ polyhedron_attribute.name,
100
100
  ),
101
101
  },
102
102
  ]
103
103
  for (let i = 0; i < coloringTypes.length; i++) {
104
104
  if (coloringTypes[i].function) {
105
- expect(() =>
106
- dataStyleStore.setMeshPolyhedraActiveColoring(
107
- id,
108
- coloringTypes[i].name,
109
- ),
110
- ).toThrowError()
111
105
  await coloringTypes[i].function()
112
106
  }
113
107
  const result = dataStyleStore.setMeshPolyhedraActiveColoring(
@@ -129,16 +123,19 @@ describe("Mesh polyhedra", () => {
129
123
  const viewerStore = useViewerStore()
130
124
 
131
125
  const spy = vi.spyOn(viewerStore, "request")
132
- await dataStyleStore.setMeshPolyhedraVertexAttribute(id, vertex_attribute)
126
+ await dataStyleStore.setMeshPolyhedraVertexAttributeName(
127
+ id,
128
+ vertex_attribute.name,
129
+ )
133
130
  expect(spy).toHaveBeenCalledWith(
134
- mesh_polyhedra_schemas.vertex_attribute,
131
+ mesh_polyhedra_schemas.attribute.vertex.name,
135
132
  { id, ...vertex_attribute },
136
133
  {
137
134
  response_function: expect.any(Function),
138
135
  },
139
136
  )
140
- expect(dataStyleStore.meshPolyhedraVertexAttribute(id)).toStrictEqual(
141
- vertex_attribute,
137
+ expect(dataStyleStore.meshPolyhedraVertexAttributeName(id)).toBe(
138
+ vertex_attribute.name,
142
139
  )
143
140
  expect(viewerStore.status).toBe(Status.CONNECTED)
144
141
  })
@@ -148,19 +145,19 @@ describe("Mesh polyhedra", () => {
148
145
  const viewerStore = useViewerStore()
149
146
 
150
147
  const spy = vi.spyOn(viewerStore, "request")
151
- await dataStyleStore.setMeshPolyhedraPolyhedronAttribute(
148
+ await dataStyleStore.setMeshPolyhedraPolyhedronAttributeName(
152
149
  id,
153
- polyhedron_attribute,
150
+ polyhedron_attribute.name,
154
151
  )
155
152
  expect(spy).toHaveBeenCalledWith(
156
- mesh_polyhedra_schemas.polyhedron_attribute,
153
+ mesh_polyhedra_schemas.attribute.polyhedron.name,
157
154
  { id, ...polyhedron_attribute },
158
155
  {
159
156
  response_function: expect.any(Function),
160
157
  },
161
158
  )
162
- expect(dataStyleStore.meshPolyhedraPolyhedronAttribute(id)).toStrictEqual(
163
- polyhedron_attribute,
159
+ expect(dataStyleStore.meshPolyhedraPolyhedronAttributeName(id)).toBe(
160
+ polyhedron_attribute.name,
164
161
  )
165
162
  expect(viewerStore.status).toBe(Status.CONNECTED)
166
163
  })
@@ -6,11 +6,13 @@ const globalRetry = process.env.CI ? 3 : 0
6
6
 
7
7
  export default defineConfig({
8
8
  test: {
9
+ globals: true,
9
10
  setupFiles: [path.resolve(__dirname, "./setup_indexeddb.js")],
10
11
  projects: [
11
12
  await defineVitestProject({
12
13
  test: {
13
14
  name: "unit",
15
+ globals: true,
14
16
  include: ["tests/unit/**/*.test.js"],
15
17
  environment: "nuxt",
16
18
  setupFiles: [path.resolve(__dirname, "./setup_indexeddb.js")],
@@ -25,6 +27,7 @@ export default defineConfig({
25
27
  await defineVitestProject({
26
28
  test: {
27
29
  name: "integration",
30
+ globals: true,
28
31
  include: ["tests/integration/**/*.test.js"],
29
32
  environment: "nuxt",
30
33
  fileParallelism: false,
@@ -1,175 +0,0 @@
1
- // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
-
4
- import { useDataStyleStateStore } from "../data_style_state"
5
- import { useViewerStore } from "@ogw_front/stores/viewer"
6
-
7
- // Local constants
8
- const mesh_cells_schemas = viewer_schemas.opengeodeweb_viewer.mesh.cells
9
- export function useMeshCellsStyle() {
10
- const dataStyleStateStore = useDataStyleStateStore()
11
- const viewerStore = useViewerStore()
12
-
13
- function meshCellsStyle(id) {
14
- return dataStyleStateStore.getStyle(id).cells
15
- }
16
-
17
- function meshCellsVisibility(id) {
18
- return meshCellsStyle(id).visibility
19
- }
20
- function setMeshCellsVisibility(id, visibility) {
21
- const cells_style = meshCellsStyle(id)
22
- return viewerStore.request(
23
- mesh_cells_schemas.visibility,
24
- { id, visibility },
25
- {
26
- response_function: () => {
27
- cells_style.visibility = visibility
28
- console.log(
29
- setMeshCellsVisibility.name,
30
- { id },
31
- meshCellsVisibility(id),
32
- )
33
- },
34
- },
35
- )
36
- }
37
-
38
- function meshCellsColor(id) {
39
- return meshCellsStyle(id).coloring.color
40
- }
41
- function setMeshCellsColor(id, color) {
42
- const coloring_style = meshCellsStyle(id).coloring
43
- return viewerStore.request(
44
- mesh_cells_schemas.color,
45
- { id, color },
46
- {
47
- response_function: () => {
48
- coloring_style.color = color
49
- console.log(
50
- setMeshCellsColor.name,
51
- { id },
52
- JSON.stringify(meshCellsColor(id)),
53
- )
54
- },
55
- },
56
- )
57
- }
58
-
59
- function meshCellsTextures(id) {
60
- return meshCellsStyle(id).coloring.textures
61
- }
62
- function setMeshCellsTextures(id, textures) {
63
- const coloring_style = meshCellsStyle(id).coloring
64
- return viewerStore.request(
65
- mesh_cells_schemas.apply_textures,
66
- { id, textures },
67
- {
68
- response_function: () => {
69
- coloring_style.textures = textures
70
- console.log(setMeshCellsTextures.name, { id }, meshCellsTextures(id))
71
- },
72
- },
73
- )
74
- }
75
-
76
- function meshCellsVertexAttribute(id) {
77
- return meshCellsStyle(id).coloring.vertex
78
- }
79
-
80
- function setMeshCellsVertexAttribute(id, vertex_attribute) {
81
- const coloring_style = meshCellsStyle(id).coloring
82
- return viewerStore.request(
83
- mesh_cells_schemas.vertex_attribute,
84
- { id, ...vertex_attribute },
85
- {
86
- response_function: () => {
87
- coloring_style.vertex = vertex_attribute
88
- console.log(
89
- setMeshCellsVertexAttribute.name,
90
- { id },
91
- meshCellsVertexAttribute(id),
92
- )
93
- },
94
- },
95
- )
96
- }
97
-
98
- function meshCellsCellAttribute(id) {
99
- return meshCellsStyle(id).coloring.cell
100
- }
101
- function setMeshCellsCellAttribute(id, cell_attribute) {
102
- const coloring_style = meshCellsStyle(id).coloring
103
- return viewerStore.request(
104
- mesh_cells_schemas.cell_attribute,
105
- { id, ...cell_attribute },
106
- {
107
- response_function: () => {
108
- coloring_style.cell = cell_attribute
109
- console.log(
110
- setMeshCellsCellAttribute.name,
111
- { id },
112
- meshCellsCellAttribute(id),
113
- )
114
- },
115
- },
116
- )
117
- }
118
-
119
- function meshCellsActiveColoring(id) {
120
- return meshCellsStyle(id).coloring.active
121
- }
122
- function setMeshCellsActiveColoring(id, type) {
123
- const coloring = meshCellsStyle(id).coloring
124
- coloring.active = type
125
- console.log(
126
- setMeshCellsActiveColoring.name,
127
- { id },
128
- meshCellsActiveColoring(id),
129
- )
130
- if (type === "color") {
131
- return setMeshCellsColor(id, coloring.color)
132
- } else if (type === "textures") {
133
- if (coloring.textures === null) {
134
- throw new Error("Textures not set")
135
- }
136
- return setMeshCellsTextures(id, coloring.textures)
137
- } else if (type === "vertex") {
138
- if (coloring.vertex === null) {
139
- throw new Error("Vertex attribute not set")
140
- }
141
- return setMeshCellsVertexAttribute(id, coloring.vertex)
142
- } else if (type === "cell") {
143
- if (coloring.cell === null) {
144
- throw new Error("Cell attribute not set")
145
- }
146
- return setMeshCellsCellAttribute(id, coloring.cell)
147
- } else {
148
- throw new Error("Unknown mesh cells coloring type: " + type)
149
- }
150
- }
151
-
152
- function applyMeshCellsStyle(id) {
153
- const style = meshCellsStyle(id)
154
- return Promise.all([
155
- setMeshCellsVisibility(id, style.visibility),
156
- setMeshCellsActiveColoring(id, style.coloring.active),
157
- ])
158
- }
159
-
160
- return {
161
- meshCellsVisibility,
162
- meshCellsActiveColoring,
163
- meshCellsColor,
164
- meshCellsTextures,
165
- meshCellsCellAttribute,
166
- meshCellsVertexAttribute,
167
- setMeshCellsVisibility,
168
- setMeshCellsActiveColoring,
169
- setMeshCellsColor,
170
- setMeshCellsTextures,
171
- setMeshCellsVertexAttribute,
172
- setMeshCellsCellAttribute,
173
- applyMeshCellsStyle,
174
- }
175
- }
@@ -1,171 +0,0 @@
1
- // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
-
4
- // Local imports
5
- import { useDataStyleStateStore } from "../data_style_state"
6
- import { useViewerStore } from "@ogw_front/stores/viewer"
7
-
8
- // Local constants
9
- const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
10
-
11
- export function useMeshEdgesStyle() {
12
- const dataStyleStateStore = useDataStyleStateStore()
13
- const viewerStore = useViewerStore()
14
-
15
- function meshEdgesStyle(id) {
16
- return dataStyleStateStore.getStyle(id).edges
17
- }
18
-
19
- function meshEdgesVisibility(id) {
20
- return meshEdgesStyle(id).visibility
21
- }
22
- function setMeshEdgesVisibility(id, visibility) {
23
- return viewerStore.request(
24
- mesh_edges_schemas.visibility,
25
- { id, visibility },
26
- {
27
- response_function: () => {
28
- meshEdgesStyle(id).visibility = visibility
29
- console.log(
30
- setMeshEdgesVisibility.name,
31
- { id },
32
- meshEdgesVisibility(id),
33
- )
34
- },
35
- },
36
- )
37
- }
38
-
39
- function meshEdgesActiveColoring(id) {
40
- return meshEdgesStyle(id).coloring.active
41
- }
42
- function setMeshEdgesActiveColoring(id, type) {
43
- const coloring = meshEdgesStyle(id).coloring
44
- coloring.active = type
45
- console.log(
46
- setMeshEdgesActiveColoring.name,
47
- { id },
48
- meshEdgesActiveColoring(id),
49
- )
50
- if (type === "color") {
51
- return setMeshEdgesColor(id, coloring.color)
52
- } else if (type === "vertex") {
53
- if (coloring.vertex === null) {
54
- throw new Error("Vertex attribute not set")
55
- }
56
- return setMeshEdgesVertexAttribute(id, coloring.vertex)
57
- } else if (type === "edge") {
58
- if (coloring.edge === null) {
59
- throw new Error("Edge attribute not set")
60
- }
61
- return setMeshEdgesEdgeAttribute(id, coloring.edge)
62
- } else {
63
- throw new Error("Unknown mesh edges coloring type: " + type)
64
- }
65
- }
66
-
67
- function meshEdgesColor(id) {
68
- return meshEdgesStyle(id).coloring.color
69
- }
70
- function setMeshEdgesColor(id, color) {
71
- const coloring_style = meshEdgesStyle(id).coloring
72
- return viewerStore.request(
73
- mesh_edges_schemas.color,
74
- { id, color },
75
- {
76
- response_function: () => {
77
- coloring_style.color = color
78
- console.log(
79
- setMeshEdgesColor.name,
80
- { id },
81
- JSON.stringify(meshEdgesColor(id)),
82
- )
83
- },
84
- },
85
- )
86
- }
87
-
88
- function meshEdgesWidth(id) {
89
- return meshEdgesStyle(id).width
90
- }
91
- function setMeshEdgesWidth(id, width) {
92
- const edges_style = meshEdgesStyle(id)
93
- return viewerStore.request(
94
- mesh_edges_schemas.width,
95
- { id, width },
96
- {
97
- response_function: () => {
98
- edges_style.width = width
99
- console.log(setMeshEdgesWidth.name, { id }, meshEdgesWidth(id))
100
- },
101
- },
102
- )
103
- }
104
-
105
- function meshEdgesVertexAttribute(id) {
106
- return meshEdgesStyle(id).coloring.vertex
107
- }
108
- function setMeshEdgesVertexAttribute(id, vertex_attribute) {
109
- const coloring_style = meshEdgesStyle(id).coloring
110
- return viewerStore.request(
111
- mesh_edges_schemas.vertex_attribute,
112
- { id, ...vertex_attribute },
113
- {
114
- response_function: () => {
115
- coloring_style.vertex = vertex_attribute
116
- console.log(
117
- setMeshEdgesVertexAttribute.name,
118
- { id },
119
- meshEdgesVertexAttribute(id),
120
- )
121
- },
122
- },
123
- )
124
- }
125
-
126
- function meshEdgesEdgeAttribute(id) {
127
- return meshEdgesStyle(id).coloring.edge
128
- }
129
- function setMeshEdgesEdgeAttribute(id, edge_attribute) {
130
- const coloring_style = meshEdgesStyle(id).coloring
131
- return viewerStore.request(
132
- mesh_edges_schemas.edge_attribute,
133
- { id, ...edge_attribute },
134
- {
135
- response_function: () => {
136
- coloring_style.edge = edge_attribute
137
- console.log(
138
- setMeshEdgesEdgeAttribute.name,
139
- { id },
140
- meshEdgesEdgeAttribute(id),
141
- )
142
- },
143
- },
144
- )
145
- }
146
-
147
- function applyMeshEdgesStyle(id) {
148
- const style = meshEdgesStyle(id)
149
- return Promise.all([
150
- setMeshEdgesVisibility(id, style.visibility),
151
- setMeshEdgesActiveColoring(id, style.coloring.active),
152
- setMeshEdgesWidth(id, style.width),
153
- ])
154
- }
155
-
156
- return {
157
- applyMeshEdgesStyle,
158
- meshEdgesActiveColoring,
159
- meshEdgesColor,
160
- meshEdgesVisibility,
161
- meshEdgesWidth,
162
- meshEdgesVertexAttribute,
163
- meshEdgesEdgeAttribute,
164
- setMeshEdgesActiveColoring,
165
- setMeshEdgesColor,
166
- setMeshEdgesVisibility,
167
- setMeshEdgesWidth,
168
- setMeshEdgesVertexAttribute,
169
- setMeshEdgesEdgeAttribute,
170
- }
171
- }
@@ -1,142 +0,0 @@
1
- // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
-
4
- // Local imports
5
- import { useDataStyleStateStore } from "../data_style_state"
6
- import { useViewerStore } from "@ogw_front/stores/viewer"
7
-
8
- // Local constants
9
- const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points
10
-
11
- export function useMeshPointsStyle() {
12
- const dataStyleStateStore = useDataStyleStateStore()
13
- const viewerStore = useViewerStore()
14
-
15
- function meshPointsStyle(id) {
16
- return dataStyleStateStore.getStyle(id).points
17
- }
18
-
19
- function meshPointsVisibility(id) {
20
- return meshPointsStyle(id).visibility
21
- }
22
- function setMeshPointsVisibility(id, visibility) {
23
- const points_style = meshPointsStyle(id)
24
- return viewerStore.request(
25
- mesh_points_schemas.visibility,
26
- { id, visibility },
27
- {
28
- response_function: () => {
29
- points_style.visibility = visibility
30
- console.log(
31
- setMeshPointsVisibility.name,
32
- { id },
33
- meshPointsVisibility(id),
34
- )
35
- },
36
- },
37
- )
38
- }
39
-
40
- function meshPointsActiveColoring(id) {
41
- return meshPointsStyle(id).coloring.active
42
- }
43
- function setMeshPointsActiveColoring(id, type) {
44
- const coloring = meshPointsStyle(id).coloring
45
- coloring.active = type
46
- console.log(
47
- setMeshPointsActiveColoring.name,
48
- { id },
49
- meshPointsActiveColoring(id),
50
- )
51
- if (type === "color") {
52
- return setMeshPointsColor(id, coloring.color)
53
- } else if (type === "vertex") {
54
- if (coloring.vertex === null) {
55
- throw new Error("Vertex attribute not set")
56
- }
57
- return setMeshPointsVertexAttribute(id, coloring.vertex)
58
- } else {
59
- throw new Error("Unknown mesh points coloring type: " + type)
60
- }
61
- }
62
-
63
- function meshPointsColor(id) {
64
- return meshPointsStyle(id).coloring.color
65
- }
66
- function setMeshPointsColor(id, color) {
67
- const coloring_style = meshPointsStyle(id).coloring
68
- return viewerStore.request(
69
- mesh_points_schemas.color,
70
- { id, color },
71
- {
72
- response_function: () => {
73
- coloring_style.color = color
74
- console.log(
75
- setMeshPointsColor.name,
76
- { id },
77
- JSON.stringify(meshPointsColor(id)),
78
- )
79
- },
80
- },
81
- )
82
- }
83
- function meshPointsVertexAttribute(id) {
84
- return meshPointsStyle(id).coloring.vertex
85
- }
86
- function setMeshPointsVertexAttribute(id, vertex_attribute) {
87
- const coloring_style = meshPointsStyle(id).coloring
88
- return viewerStore.request(
89
- mesh_points_schemas.vertex_attribute,
90
- { id, ...vertex_attribute },
91
- {
92
- response_function: () => {
93
- coloring_style.vertex = vertex_attribute
94
- console.log(
95
- setMeshPointsVertexAttribute.name,
96
- { id },
97
- meshPointsVertexAttribute(id),
98
- )
99
- },
100
- },
101
- )
102
- }
103
-
104
- function meshPointsSize(id) {
105
- return meshPointsStyle(id).size
106
- }
107
- function setMeshPointsSize(id, size) {
108
- return viewerStore.request(
109
- mesh_points_schemas.size,
110
- { id, size },
111
- {
112
- response_function: () => {
113
- meshPointsStyle(id).size = size
114
- console.log(setMeshPointsSize.name, { id }, meshPointsSize(id))
115
- },
116
- },
117
- )
118
- }
119
-
120
- function applyMeshPointsStyle(id) {
121
- const style = meshPointsStyle(id)
122
- return Promise.all([
123
- setMeshPointsVisibility(id, style.visibility),
124
- setMeshPointsActiveColoring(id, style.coloring.active),
125
- setMeshPointsSize(id, style.size),
126
- ])
127
- }
128
-
129
- return {
130
- meshPointsVisibility,
131
- meshPointsActiveColoring,
132
- meshPointsColor,
133
- meshPointsVertexAttribute,
134
- meshPointsSize,
135
- setMeshPointsVisibility,
136
- setMeshPointsActiveColoring,
137
- setMeshPointsColor,
138
- setMeshPointsVertexAttribute,
139
- setMeshPointsSize,
140
- applyMeshPointsStyle,
141
- }
142
- }