@geode/opengeodeweb-front 10.4.0 → 10.4.1-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 (38) hide show
  1. package/.oxlintrc.json +72 -7
  2. package/app/components/Viewer/BreadCrumb.vue +1 -1
  3. package/app/components/Viewer/ContextMenu.vue +1 -9
  4. package/app/stores/data.js +9 -7
  5. package/app/stores/data_style.js +2 -2
  6. package/app/stores/menu.js +4 -0
  7. package/internal/stores/data_style/model/blocks/color.js +64 -0
  8. package/internal/stores/data_style/model/blocks/common.js +21 -0
  9. package/internal/stores/data_style/model/blocks/index.js +35 -0
  10. package/internal/stores/data_style/model/blocks/visibility.js +63 -0
  11. package/internal/stores/data_style/model/corners/color.js +63 -0
  12. package/internal/stores/data_style/model/corners/common.js +21 -0
  13. package/internal/stores/data_style/model/corners/index.js +36 -0
  14. package/internal/stores/data_style/model/corners/visibility.js +64 -0
  15. package/internal/stores/data_style/model/edges/common.js +13 -0
  16. package/internal/stores/data_style/model/edges/index.js +21 -0
  17. package/internal/stores/data_style/model/{edges.js → edges/visibility.js} +5 -14
  18. package/internal/stores/data_style/model/index.js +3 -3
  19. package/internal/stores/data_style/model/lines/color.js +63 -0
  20. package/internal/stores/data_style/model/lines/common.js +21 -0
  21. package/internal/stores/data_style/model/lines/index.js +35 -0
  22. package/internal/stores/data_style/model/lines/visibility.js +63 -0
  23. package/internal/stores/data_style/model/points/common.js +13 -0
  24. package/internal/stores/data_style/model/points/index.js +25 -0
  25. package/internal/stores/data_style/model/points/size.js +36 -0
  26. package/internal/stores/data_style/model/points/visibility.js +40 -0
  27. package/internal/stores/data_style/model/surfaces/color.js +62 -0
  28. package/internal/stores/data_style/model/surfaces/common.js +21 -0
  29. package/internal/stores/data_style/model/surfaces/index.js +39 -0
  30. package/internal/stores/data_style/model/surfaces/visibility.js +62 -0
  31. package/package.json +3 -3
  32. package/tests/integration/microservices/back/requirements.txt +1 -1
  33. package/tests/integration/microservices/viewer/requirements.txt +1 -1
  34. package/internal/stores/data_style/model/blocks.js +0 -126
  35. package/internal/stores/data_style/model/corners.js +0 -127
  36. package/internal/stores/data_style/model/lines.js +0 -124
  37. package/internal/stores/data_style/model/points.js +0 -69
  38. package/internal/stores/data_style/model/surfaces.js +0 -123
@@ -171,9 +171,9 @@ export default function useModelStyle() {
171
171
  return Promise.all(promise_array)
172
172
  }
173
173
 
174
- function setModelMeshComponentsDefaultStyle(id) {
175
- const item = dataStore.getItem(id)
176
- const { mesh_components } = item.value
174
+ async function setModelMeshComponentsDefaultStyle(id) {
175
+ const item = await dataStore.item(id)
176
+ const { mesh_components } = item
177
177
  const promise_array = []
178
178
  if ("Corner" in mesh_components) {
179
179
  promise_array.push(modelCornersStyleStore.setModelCornersDefaultStyle(id))
@@ -0,0 +1,63 @@
1
+ // Third party imports
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local imports
5
+ import { useModelLinesCommonStyle } from "./common"
6
+ import { useDataStore } from "@ogw_front/stores/data"
7
+ import { useViewerStore } from "@ogw_front/stores/viewer"
8
+
9
+ // Local constants
10
+ const model_lines_schemas = viewer_schemas.opengeodeweb_viewer.model.lines
11
+
12
+ export function useModelLinesColorStyle() {
13
+ const dataStore = useDataStore()
14
+ const viewerStore = useViewerStore()
15
+ const modelLinesCommonStyle = useModelLinesCommonStyle()
16
+
17
+ function modelLineColor(id, line_id) {
18
+ return modelLinesCommonStyle.modelLineStyle(id, line_id).color
19
+ }
20
+
21
+ function saveModelLineColor(id, line_id, color) {
22
+ modelLinesCommonStyle.modelLineStyle(id, line_id).color = color
23
+ }
24
+
25
+ async function setModelLinesColor(id, line_ids, color) {
26
+ if (!line_ids || line_ids.length === 0) {
27
+ return
28
+ }
29
+ const line_viewer_ids = await dataStore.getMeshComponentsViewerIds(
30
+ id,
31
+ line_ids,
32
+ )
33
+ if (!line_viewer_ids || line_viewer_ids.length === 0) {
34
+ console.warn(
35
+ "[setModelLinesColor] No viewer IDs found, skipping color request",
36
+ { id, line_ids },
37
+ )
38
+ return
39
+ }
40
+ return viewerStore.request(
41
+ model_lines_schemas.color,
42
+ { id, block_ids: line_viewer_ids, color },
43
+ {
44
+ response_function: () => {
45
+ for (const line_id of line_ids) {
46
+ saveModelLineColor(id, line_id, color)
47
+ }
48
+ console.log(
49
+ setModelLinesColor.name,
50
+ { id },
51
+ { line_ids },
52
+ JSON.stringify(modelLineColor(id, line_ids[0])),
53
+ )
54
+ },
55
+ },
56
+ )
57
+ }
58
+
59
+ return {
60
+ modelLineColor,
61
+ setModelLinesColor,
62
+ }
63
+ }
@@ -0,0 +1,21 @@
1
+ import { useDataStyleStateStore } from "../../state"
2
+
3
+ export function useModelLinesCommonStyle() {
4
+ const dataStyleStateStore = useDataStyleStateStore()
5
+
6
+ function modelLinesStyle(id) {
7
+ return dataStyleStateStore.getStyle(id).lines
8
+ }
9
+
10
+ function modelLineStyle(id, line_id) {
11
+ if (!modelLinesStyle(id)[line_id]) {
12
+ modelLinesStyle(id)[line_id] = {}
13
+ }
14
+ return modelLinesStyle(id)[line_id]
15
+ }
16
+
17
+ return {
18
+ modelLinesStyle,
19
+ modelLineStyle,
20
+ }
21
+ }
@@ -0,0 +1,35 @@
1
+ // Local imports
2
+ import { useModelLinesColorStyle } from "./color"
3
+ import { useModelLinesCommonStyle } from "./common"
4
+ import { useModelLinesVisibilityStyle } from "./visibility"
5
+ import { useDataStore } from "@ogw_front/stores/data"
6
+
7
+ export function useModelLinesStyle() {
8
+ const dataStore = useDataStore()
9
+ const modelLinesCommonStyle = useModelLinesCommonStyle()
10
+ const modelLinesVisibilityStyle = useModelLinesVisibilityStyle()
11
+ const modelLinesColorStyle = useModelLinesColorStyle()
12
+
13
+ async function applyModelLinesStyle(id) {
14
+ const style = modelLinesCommonStyle.modelLinesStyle(id)
15
+ const line_ids = await dataStore.getLinesGeodeIds(id)
16
+ return Promise.all([
17
+ modelLinesVisibilityStyle.setModelLinesVisibility(
18
+ id,
19
+ line_ids,
20
+ style.visibility,
21
+ ),
22
+ modelLinesColorStyle.setModelLinesColor(id, line_ids, style.color),
23
+ ])
24
+ }
25
+
26
+ async function setModelLinesDefaultStyle(id) {}
27
+
28
+ return {
29
+ applyModelLinesStyle,
30
+ setModelLinesDefaultStyle,
31
+ ...modelLinesCommonStyle,
32
+ ...modelLinesVisibilityStyle,
33
+ ...modelLinesColorStyle,
34
+ }
35
+ }
@@ -0,0 +1,63 @@
1
+ // Third party imports
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local imports
5
+ import { useModelLinesCommonStyle } from "./common"
6
+ import { useDataStore } from "@ogw_front/stores/data"
7
+ import { useViewerStore } from "@ogw_front/stores/viewer"
8
+
9
+ // Local constants
10
+ const model_lines_schemas = viewer_schemas.opengeodeweb_viewer.model.lines
11
+
12
+ export function useModelLinesVisibilityStyle() {
13
+ const dataStore = useDataStore()
14
+ const viewerStore = useViewerStore()
15
+ const modelLinesCommonStyle = useModelLinesCommonStyle()
16
+
17
+ function modelLineVisibility(id, line_id) {
18
+ return modelLinesCommonStyle.modelLineStyle(id, line_id).visibility
19
+ }
20
+
21
+ function saveModelLineVisibility(id, line_id, visibility) {
22
+ modelLinesCommonStyle.modelLineStyle(id, line_id).visibility = visibility
23
+ }
24
+
25
+ async function setModelLinesVisibility(id, line_ids, visibility) {
26
+ if (!line_ids || line_ids.length === 0) {
27
+ return
28
+ }
29
+ const line_viewer_ids = await dataStore.getMeshComponentsViewerIds(
30
+ id,
31
+ line_ids,
32
+ )
33
+ if (!line_viewer_ids || line_viewer_ids.length === 0) {
34
+ console.warn(
35
+ "[setModelLinesVisibility] No viewer IDs found, skipping visibility request",
36
+ { id, line_ids },
37
+ )
38
+ return
39
+ }
40
+ return viewerStore.request(
41
+ model_lines_schemas.visibility,
42
+ { id, block_ids: line_viewer_ids, visibility },
43
+ {
44
+ response_function: () => {
45
+ for (const line_id of line_ids) {
46
+ saveModelLineVisibility(id, line_id, visibility)
47
+ }
48
+ console.log(
49
+ setModelLinesVisibility.name,
50
+ { id },
51
+ { line_ids },
52
+ modelLineVisibility(id, line_ids[0]),
53
+ )
54
+ },
55
+ },
56
+ )
57
+ }
58
+
59
+ return {
60
+ modelLineVisibility,
61
+ setModelLinesVisibility,
62
+ }
63
+ }
@@ -0,0 +1,13 @@
1
+ import { useDataStyleStateStore } from "../../state"
2
+
3
+ export function useModelPointsCommonStyle() {
4
+ const dataStyleStateStore = useDataStyleStateStore()
5
+
6
+ function modelPointsStyle(id) {
7
+ return dataStyleStateStore.getStyle(id).points
8
+ }
9
+
10
+ return {
11
+ modelPointsStyle,
12
+ }
13
+ }
@@ -0,0 +1,25 @@
1
+ // Local imports
2
+ import { useModelPointsCommonStyle } from "./common"
3
+ import { useModelPointsSizeStyle } from "./size"
4
+ import { useModelPointsVisibilityStyle } from "./visibility"
5
+
6
+ export function useModelPointsStyle() {
7
+ const modelPointsCommonStyle = useModelPointsCommonStyle()
8
+ const modelPointsVisibilityStyle = useModelPointsVisibilityStyle()
9
+ const modelPointsSizeStyle = useModelPointsSizeStyle()
10
+
11
+ function applyModelPointsStyle(id) {
12
+ const style = modelPointsCommonStyle.modelPointsStyle(id)
13
+ return Promise.all([
14
+ modelPointsVisibilityStyle.setModelPointsVisibility(id, style.visibility),
15
+ modelPointsSizeStyle.setModelPointsSize(id, style.size),
16
+ ])
17
+ }
18
+
19
+ return {
20
+ applyModelPointsStyle,
21
+ ...modelPointsCommonStyle,
22
+ ...modelPointsVisibilityStyle,
23
+ ...modelPointsSizeStyle,
24
+ }
25
+ }
@@ -0,0 +1,36 @@
1
+ // Third party imports
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local imports
5
+ import { useModelPointsCommonStyle } from "./common"
6
+ import { useViewerStore } from "@ogw_front/stores/viewer"
7
+
8
+ // Local constants
9
+ const model_points_schemas = viewer_schemas.opengeodeweb_viewer.model.points
10
+
11
+ export function useModelPointsSizeStyle() {
12
+ const viewerStore = useViewerStore()
13
+ const modelPointsCommonStyle = useModelPointsCommonStyle()
14
+
15
+ function modelPointsSize(id) {
16
+ return modelPointsCommonStyle.modelPointsStyle(id).size
17
+ }
18
+
19
+ function setModelPointsSize(id, size) {
20
+ return viewerStore.request(
21
+ model_points_schemas.size,
22
+ { id, size },
23
+ {
24
+ response_function: () => {
25
+ modelPointsCommonStyle.modelPointsStyle(id).size = size
26
+ console.log(setModelPointsSize.name, { id }, modelPointsSize(id))
27
+ },
28
+ },
29
+ )
30
+ }
31
+
32
+ return {
33
+ modelPointsSize,
34
+ setModelPointsSize,
35
+ }
36
+ }
@@ -0,0 +1,40 @@
1
+ // Third party imports
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local imports
5
+ import { useModelPointsCommonStyle } from "./common"
6
+ import { useViewerStore } from "@ogw_front/stores/viewer"
7
+
8
+ // Local constants
9
+ const model_points_schemas = viewer_schemas.opengeodeweb_viewer.model.points
10
+
11
+ export function useModelPointsVisibilityStyle() {
12
+ const viewerStore = useViewerStore()
13
+ const modelPointsCommonStyle = useModelPointsCommonStyle()
14
+
15
+ function modelPointsVisibility(id) {
16
+ return modelPointsCommonStyle.modelPointsStyle(id).visibility
17
+ }
18
+
19
+ function setModelPointsVisibility(id, visibility) {
20
+ return viewerStore.request(
21
+ model_points_schemas.visibility,
22
+ { id, visibility },
23
+ {
24
+ response_function: () => {
25
+ modelPointsCommonStyle.modelPointsStyle(id).visibility = visibility
26
+ console.log(
27
+ setModelPointsVisibility.name,
28
+ { id },
29
+ modelPointsVisibility(id),
30
+ )
31
+ },
32
+ },
33
+ )
34
+ }
35
+
36
+ return {
37
+ modelPointsVisibility,
38
+ setModelPointsVisibility,
39
+ }
40
+ }
@@ -0,0 +1,62 @@
1
+ // Third party imports
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local imports
5
+ import { useModelSurfacesCommonStyle } from "./common"
6
+ import { useDataStore } from "@ogw_front/stores/data"
7
+ import { useViewerStore } from "@ogw_front/stores/viewer"
8
+
9
+ // Local constants
10
+ const model_surfaces_schemas = viewer_schemas.opengeodeweb_viewer.model.surfaces
11
+
12
+ export function useModelSurfacesColorStyle() {
13
+ const dataStore = useDataStore()
14
+ const viewerStore = useViewerStore()
15
+ const modelSurfacesCommonStyle = useModelSurfacesCommonStyle()
16
+
17
+ function modelSurfaceColor(id, surface_id) {
18
+ return modelSurfacesCommonStyle.modelSurfaceStyle(id, surface_id).color
19
+ }
20
+ function saveModelSurfaceColor(id, surface_id, color) {
21
+ modelSurfacesCommonStyle.modelSurfaceStyle(id, surface_id).color = color
22
+ }
23
+
24
+ async function setModelSurfacesColor(id, surface_ids, color) {
25
+ if (!surface_ids || surface_ids.length === 0) {
26
+ return
27
+ }
28
+ const surface_viewer_ids = await dataStore.getMeshComponentsViewerIds(
29
+ id,
30
+ surface_ids,
31
+ )
32
+ if (!surface_viewer_ids || surface_viewer_ids.length === 0) {
33
+ console.warn(
34
+ "[setModelSurfacesColor] No viewer IDs found, skipping color request",
35
+ { id, surface_ids },
36
+ )
37
+ return
38
+ }
39
+ return viewerStore.request(
40
+ model_surfaces_schemas.color,
41
+ { id, block_ids: surface_viewer_ids, color },
42
+ {
43
+ response_function: () => {
44
+ for (const surface_id of surface_ids) {
45
+ saveModelSurfaceColor(id, surface_id, color)
46
+ }
47
+ console.log(
48
+ setModelSurfacesColor.name,
49
+ { id },
50
+ { surface_ids },
51
+ JSON.stringify(modelSurfaceColor(id, surface_ids[0])),
52
+ )
53
+ },
54
+ },
55
+ )
56
+ }
57
+
58
+ return {
59
+ modelSurfaceColor,
60
+ setModelSurfacesColor,
61
+ }
62
+ }
@@ -0,0 +1,21 @@
1
+ import { useDataStyleStateStore } from "../../state"
2
+
3
+ export function useModelSurfacesCommonStyle() {
4
+ const dataStyleStateStore = useDataStyleStateStore()
5
+
6
+ function modelSurfacesStyle(id) {
7
+ return dataStyleStateStore.getStyle(id).surfaces
8
+ }
9
+
10
+ function modelSurfaceStyle(id, surface_id) {
11
+ if (!modelSurfacesStyle(id)[surface_id]) {
12
+ modelSurfacesStyle(id)[surface_id] = {}
13
+ }
14
+ return modelSurfacesStyle(id)[surface_id]
15
+ }
16
+
17
+ return {
18
+ modelSurfacesStyle,
19
+ modelSurfaceStyle,
20
+ }
21
+ }
@@ -0,0 +1,39 @@
1
+ // Local imports
2
+ import { useModelSurfacesColorStyle } from "./color"
3
+ import { useModelSurfacesCommonStyle } from "./common"
4
+ import { useModelSurfacesVisibilityStyle } from "./visibility"
5
+ import { useDataStore } from "@ogw_front/stores/data"
6
+
7
+ export function useModelSurfacesStyle() {
8
+ const dataStore = useDataStore()
9
+ const modelSurfacesCommonStyle = useModelSurfacesCommonStyle()
10
+ const modelSurfacesVisibilityStyle = useModelSurfacesVisibilityStyle()
11
+ const modelSurfacesColorStyle = useModelSurfacesColorStyle()
12
+
13
+ async function applyModelSurfacesStyle(id) {
14
+ const style = modelSurfacesCommonStyle.modelSurfacesStyle(id)
15
+ const surface_ids = await dataStore.getSurfacesGeodeIds(id)
16
+ return Promise.all([
17
+ modelSurfacesVisibilityStyle.setModelSurfacesVisibility(
18
+ id,
19
+ surface_ids,
20
+ style.visibility,
21
+ ),
22
+ modelSurfacesColorStyle.setModelSurfacesColor(
23
+ id,
24
+ surface_ids,
25
+ style.color,
26
+ ),
27
+ ])
28
+ }
29
+
30
+ async function setModelSurfacesDefaultStyle(id) {}
31
+
32
+ return {
33
+ applyModelSurfacesStyle,
34
+ setModelSurfacesDefaultStyle,
35
+ ...modelSurfacesCommonStyle,
36
+ ...modelSurfacesVisibilityStyle,
37
+ ...modelSurfacesColorStyle,
38
+ }
39
+ }
@@ -0,0 +1,62 @@
1
+ // Third party imports
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local imports
5
+ import { useModelSurfacesCommonStyle } from "./common"
6
+ import { useDataStore } from "@ogw_front/stores/data"
7
+ import { useViewerStore } from "@ogw_front/stores/viewer"
8
+
9
+ // Local constants
10
+ const model_surfaces_schemas = viewer_schemas.opengeodeweb_viewer.model.surfaces
11
+
12
+ export function useModelSurfacesVisibilityStyle() {
13
+ const dataStore = useDataStore()
14
+ const viewerStore = useViewerStore()
15
+ const modelSurfacesCommonStyle = useModelSurfacesCommonStyle()
16
+
17
+ function modelSurfaceVisibility(id, surface_id) {
18
+ return modelSurfacesCommonStyle.modelSurfaceStyle(id, surface_id).visibility
19
+ }
20
+ function saveModelSurfaceVisibility(id, surface_id, visibility) {
21
+ modelSurfacesCommonStyle.modelSurfaceStyle(id, surface_id).visibility =
22
+ visibility
23
+ }
24
+ async function setModelSurfacesVisibility(id, surface_ids, visibility) {
25
+ if (!surface_ids || surface_ids.length === 0) {
26
+ return
27
+ }
28
+ const surface_viewer_ids = await dataStore.getMeshComponentsViewerIds(
29
+ id,
30
+ surface_ids,
31
+ )
32
+ if (!surface_viewer_ids || surface_viewer_ids.length === 0) {
33
+ console.warn(
34
+ "[setModelSurfacesVisibility] No viewer IDs found, skipping visibility request",
35
+ { id, surface_ids },
36
+ )
37
+ return
38
+ }
39
+ return viewerStore.request(
40
+ model_surfaces_schemas.visibility,
41
+ { id, block_ids: surface_viewer_ids, visibility },
42
+ {
43
+ response_function: () => {
44
+ for (const surface_id of surface_ids) {
45
+ saveModelSurfaceVisibility(id, surface_id, visibility)
46
+ }
47
+ console.log(
48
+ setModelSurfacesVisibility.name,
49
+ { id },
50
+ { surface_ids },
51
+ modelSurfaceVisibility(id, surface_ids[0]),
52
+ )
53
+ },
54
+ },
55
+ )
56
+ }
57
+
58
+ return {
59
+ modelSurfaceVisibility,
60
+ setModelSurfacesVisibility,
61
+ }
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.4.0",
3
+ "version": "10.4.1-rc.2",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {
@@ -31,8 +31,8 @@
31
31
  "build": ""
32
32
  },
33
33
  "dependencies": {
34
- "@geode/opengeodeweb-back": "latest",
35
- "@geode/opengeodeweb-viewer": "latest",
34
+ "@geode/opengeodeweb-back": "next",
35
+ "@geode/opengeodeweb-viewer": "next",
36
36
  "@kitware/vtk.js": "33.3.0",
37
37
  "@mdi/font": "7.4.47",
38
38
  "@pinia/nuxt": "0.11.3",
@@ -5,4 +5,4 @@
5
5
  # pip-compile --output-file=tests/integration/microservices/back/requirements.txt tests/integration/microservices/back/requirements.in
6
6
  #
7
7
 
8
- opengeodeweb-back==6.*,>=6.2.0rc2
8
+ opengeodeweb-back==6.*,>=6.3.1rc1
@@ -5,4 +5,4 @@
5
5
  # pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements.in
6
6
  #
7
7
 
8
- opengeodeweb-viewer==1.*,>=1.15.4rc1
8
+ opengeodeweb-viewer==1.*,>=1.15.5rc1
@@ -1,126 +0,0 @@
1
- // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
-
4
- // Local imports
5
- import { useDataStore } from "@ogw_front/stores/data"
6
- import { useDataStyleStateStore } from "../state"
7
- import { useViewerStore } from "@ogw_front/stores/viewer"
8
-
9
- // Local constants
10
- const model_blocks_schemas = viewer_schemas.opengeodeweb_viewer.model.blocks
11
-
12
- export function useModelBlocksStyle() {
13
- const dataStyleStateStore = useDataStyleStateStore()
14
- const dataStore = useDataStore()
15
- const viewerStore = useViewerStore()
16
-
17
- function modelBlocksStyle(id) {
18
- return dataStyleStateStore.getStyle(id).blocks
19
- }
20
- function modelBlockStyle(id, block_id) {
21
- if (!modelBlocksStyle(id)[block_id]) {
22
- modelBlocksStyle(id)[block_id] = {}
23
- }
24
- return modelBlocksStyle(id)[block_id]
25
- }
26
-
27
- function modelBlockVisibility(id, block_id) {
28
- return modelBlockStyle(id, block_id).visibility
29
- }
30
-
31
- function saveModelBlockVisibility(id, block_id, visibility) {
32
- modelBlockStyle(id, block_id).visibility = visibility
33
- }
34
- async function setModelBlocksVisibility(id, block_ids, visibility) {
35
- if (!block_ids || block_ids.length === 0) {
36
- return
37
- }
38
- const blocks_viewer_ids = await dataStore.getMeshComponentsViewerIds(
39
- id,
40
- block_ids,
41
- )
42
- if (!blocks_viewer_ids || blocks_viewer_ids.length === 0) {
43
- console.warn(
44
- "[setModelBlocksVisibility] No viewer IDs found, skipping visibility request",
45
- { id, block_ids },
46
- )
47
- return
48
- }
49
- return viewerStore.request(
50
- model_blocks_schemas.visibility,
51
- { id, block_ids: blocks_viewer_ids, visibility },
52
- {
53
- response_function: () => {
54
- for (const block_id of block_ids) {
55
- saveModelBlockVisibility(id, block_id, visibility)
56
- }
57
- console.log(
58
- setModelBlocksVisibility.name,
59
- { id },
60
- { block_ids },
61
- modelBlockVisibility(id, block_ids[0]),
62
- )
63
- },
64
- },
65
- )
66
- }
67
- function modelBlockColor(id, block_id) {
68
- return modelBlockStyle(id, block_id).color
69
- }
70
-
71
- function saveModelBlockColor(id, block_id, color) {
72
- modelBlockStyle(id, block_id).color = color
73
- }
74
-
75
- async function setModelBlocksColor(id, block_ids, color) {
76
- if (!block_ids || block_ids.length === 0) {
77
- return
78
- }
79
- const blocks_viewer_ids = await dataStore.getMeshComponentsViewerIds(
80
- id,
81
- block_ids,
82
- )
83
- if (!blocks_viewer_ids || blocks_viewer_ids.length === 0) {
84
- console.warn(
85
- "[setModelBlocksColor] No viewer IDs found, skipping color request",
86
- { id, block_ids },
87
- )
88
- return
89
- }
90
- return viewerStore.request(
91
- model_blocks_schemas.color,
92
- { id, block_ids: blocks_viewer_ids, color },
93
- {
94
- response_function: () => {
95
- for (const block_id of block_ids) {
96
- saveModelBlockColor(id, block_id, color)
97
- }
98
-
99
- console.log(
100
- setModelBlocksColor.name,
101
- { id },
102
- { block_ids },
103
- JSON.stringify(modelBlockColor(id, block_ids[0])),
104
- )
105
- },
106
- },
107
- )
108
- }
109
-
110
- async function applyModelBlocksStyle(id) {
111
- const style = modelBlocksStyle(id)
112
- const blocks_ids = await dataStore.getBlocksGeodeIds(id)
113
- return Promise.all([
114
- setModelBlocksVisibility(id, blocks_ids, style.visibility),
115
- setModelBlocksColor(id, blocks_ids, style.color),
116
- ])
117
- }
118
-
119
- return {
120
- modelBlockVisibility,
121
- modelBlockColor,
122
- setModelBlocksVisibility,
123
- setModelBlocksColor,
124
- applyModelBlocksStyle,
125
- }
126
- }