@twinmatrix/spatialverse-sdk-web 0.0.3 → 0.0.5

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 (111) hide show
  1. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -2
  2. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  3. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js +293 -0
  4. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js.map +1 -0
  5. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js +35 -0
  6. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js.map +1 -0
  7. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js +33 -0
  8. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js.map +1 -0
  9. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js +307 -0
  10. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js.map +1 -0
  11. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +4 -3
  12. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  13. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +202 -198
  14. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  15. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  16. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  17. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/focustree.json +121 -0
  18. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +32 -29
  19. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  20. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +10 -13
  21. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  22. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +55 -68
  23. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  24. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +12 -12
  25. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  26. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/whatTaxonomies.json +170 -0
  27. package/lib/cjs/meta-atlas-sdk/combined_style.json +2313 -0
  28. package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js +166 -0
  29. package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js.map +1 -0
  30. package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js +229 -0
  31. package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js.map +1 -0
  32. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +73 -69
  33. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  34. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  36. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +6 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  38. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +103 -103
  39. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  40. package/lib/cjs/react/MetaAtlasMap.js +4 -4
  41. package/lib/cjs/react/MetaAtlasMap.js.map +1 -1
  42. package/lib/cjs/react/hooks/useMapEvents/index.js +6 -3
  43. package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
  44. package/lib/cjs/react/hooks/useStampRally/index.js +7 -5
  45. package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
  46. package/lib/cjs/react/hooks/useStampRally/utils.js +1 -1
  47. package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
  48. package/lib/cjs/react/stores/useMapDataStore.js +17 -21
  49. package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
  50. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -2
  51. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  52. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js +286 -0
  53. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js.map +1 -0
  54. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js +27 -0
  55. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js.map +1 -0
  56. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js +27 -0
  57. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js.map +1 -0
  58. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js +305 -0
  59. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js.map +1 -0
  60. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +4 -3
  61. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  62. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +202 -198
  63. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  64. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  65. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  66. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/focustree.json +121 -0
  67. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +32 -29
  68. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  69. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +10 -8
  70. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  71. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +55 -68
  72. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  73. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +12 -12
  74. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  75. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/whatTaxonomies.json +170 -0
  76. package/lib/esm/meta-atlas-sdk/combined_style.json +2313 -0
  77. package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js +158 -0
  78. package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js.map +1 -0
  79. package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js +221 -0
  80. package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js.map +1 -0
  81. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +73 -68
  82. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  83. package/lib/esm/meta-atlas-sdk/utils/helpers.js +1 -1
  84. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  85. package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
  86. package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  87. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +103 -101
  88. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  89. package/lib/esm/react/MetaAtlasMap.js +4 -4
  90. package/lib/esm/react/MetaAtlasMap.js.map +1 -1
  91. package/lib/esm/react/hooks/useMapEvents/index.js +6 -3
  92. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  93. package/lib/esm/react/hooks/useStampRally/index.js +7 -5
  94. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  95. package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
  96. package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
  97. package/lib/esm/react/stores/useMapDataStore.js +17 -21
  98. package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
  99. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
  100. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
  101. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
  102. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
  103. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
  104. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
  105. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
  106. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
  107. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
  108. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
  109. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
  110. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
  111. package/package.json +4 -4
@@ -12,9 +12,209 @@ var _utils = require("./CustomThreeJsWrapper/utility/utils.js");
12
12
  var _threeSpritetext = _interopRequireDefault(require("three-spritetext"));
13
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
19
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
20
  class MainMap {
16
- static mainInstance = null;
17
21
  constructor(metaAtlasCore) {
22
+ _defineProperty(this, "getAllPolygonCoordinates", () => {
23
+ const map = this.map;
24
+ if (!map) return [];
25
+ const polygonFeatures = [];
26
+ const source = map.getSource('custom');
27
+ if (source) {
28
+ const features = map.querySourceFeatures('custom', {
29
+ sourceLayer: 'geojson',
30
+ filter: ['==', ['geometry-type'], 'Polygon']
31
+ });
32
+ if (features && features.length > 0) {
33
+ features.forEach(feature => {
34
+ if ((feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') && feature.properties.dimension_what === 'what.booth') {
35
+ var _feature$properties;
36
+ polygonFeatures.push({
37
+ id: feature.properties.mapObjectId,
38
+ name: ((_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.title) || 'Unnamed Polygon',
39
+ coordinates: feature.geometry.coordinates,
40
+ properties: _objectSpread(_objectSpread({}, feature.properties), {}, {
41
+ hasImage: !!Math.round(Math.random())
42
+ })
43
+ });
44
+ }
45
+ });
46
+ }
47
+ }
48
+ return polygonFeatures;
49
+ });
50
+ _defineProperty(this, "updatePolygons", features => {
51
+ features.map(async feature => {
52
+ const coordinates = feature.geometry.coordinates;
53
+ // const centroid = feature.properties.center;
54
+ const polygon = turf.polygon(coordinates);
55
+ const centroid = turf.centroid(polygon).geometry.coordinates;
56
+ // const modelPosition = projectToWorld(centroid);
57
+
58
+ // const vertex1 = projectToWorld(coordinates[0][0]);
59
+ // const vertex2 = projectToWorld(coordinates[0][1]);
60
+ // const angle = vertex1.angleTo(vertex2);
61
+ // console.log(angle);
62
+
63
+ // await modelLoader.loadModel({
64
+ // modelPath: feature.properties.modelPath,
65
+ // feature,
66
+ // wrapper: wrapper.current!,
67
+ // onProgress: (progress) => {
68
+ // setLoadingProgress((prev) => ({
69
+ // ...prev,
70
+ // [feature.properties.id]: progress,
71
+ // }));
72
+ // },
73
+ // onError: (error) => {
74
+ // console.error(
75
+ // `Failed to load model ${feature.properties.id}:`,
76
+ // error
77
+ // );
78
+ // },
79
+ // });
80
+
81
+ if (!feature.properties.hasImage && feature.properties.dimension_where && feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor') {
82
+ const myText = new _threeSpritetext.default();
83
+ myText.color = 'black';
84
+ let text = feature.properties.title;
85
+ text = this.addNewLine(text);
86
+
87
+ // Set properties to configure:
88
+ myText.text = text;
89
+ myText.textHeight = 100;
90
+ // myText.textHeight = 1;
91
+ // myText.backgroundColor = '';
92
+ const textPosition = (0, _utils.projectToWorld)(centroid);
93
+ myText.rotation.x = Math.PI;
94
+ myText.rotation.y = Math.PI;
95
+ myText.scale.set(0.1, 0.1, 0.01);
96
+ myText.position.set(textPosition.x, textPosition.y,
97
+ // feature.properties.height > 0 ? 0.4 : 0.25
98
+ 0.1);
99
+ this.threebox.add(myText);
100
+ } else {
101
+ // Load Texture
102
+ // const textureLoader = new THREE.TextureLoader();
103
+ // textureLoader.load('/sk.png', (texture: THREE.Texture) => {
104
+ // // Create a plane geometry and material with the loaded texture
105
+ // const geometry = new THREE.PlaneGeometry(
106
+ // texture.image.width,
107
+ // texture.image.height
108
+ // );
109
+ // geometry.computeBoundingBox();
110
+ // const material = new THREE.MeshStandardMaterial({
111
+ // map: texture,
112
+ // transparent: true, // Enable transparency
113
+ // opacity: 1,
114
+ // });
115
+ // const plane = new THREE.Mesh(geometry, material);
116
+ // const group = new THREE.Group();
117
+ // const childContainer = new THREE.Group();
118
+ // childContainer.add(plane);
119
+ // childContainer.rotateZ(Math.PI / 2);
120
+ // childContainer.rotateZ(1);
121
+ // childContainer.updateMatrixWorld();
122
+ // group.add(childContainer);
123
+ // const geojsonbbox = turf.bbox(polygon);
124
+ // const bbox1 = new THREE.Box3(
125
+ // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),
126
+ // projectToWorld([geojsonbbox[0], geojsonbbox[1]])
127
+ // );
128
+ // const bbox2 = new THREE.Box3().setFromObject(plane);
129
+ // const size1 = new THREE.Vector3();
130
+ // bbox1.getSize(size1);
131
+ // size1.setZ(1);
132
+ // const size2 = new THREE.Vector3();
133
+ // bbox2.getSize(size2);
134
+ // size2.setZ(1);
135
+ // const ratio = size1.divide(size2);
136
+ // const ratioCopy = ratio.clone().multiplyScalar(0.85);
137
+ // plane.scale.set(
138
+ // plane.scale.x * ratioCopy.x,
139
+ // plane.scale.y * ratioCopy.y,
140
+ // plane.scale.z * ratioCopy.z
141
+ // );
142
+ // // // Set the position of the plane to the centroid
143
+ // group.position.set(modelPosition.x, modelPosition.y, 0.11);
144
+ // this.threebox.add(group);
145
+ // });
146
+ }
147
+ });
148
+ });
149
+ _defineProperty(this, "addLogo", (logo, position) => {
150
+ const textureLoader = new THREE.TextureLoader();
151
+ const texture = textureLoader.load(logo);
152
+
153
+ // Define rectangle dimensions
154
+ const width = 4;
155
+ const height = 0;
156
+ const depth = 2;
157
+
158
+ // Create a box geometry instead of cylinder
159
+ const geometry = new THREE.BoxGeometry(width, height, depth);
160
+
161
+ // Create materials: [right, left, top, bottom, front, back]
162
+ const sideMaterial = new THREE.MeshBasicMaterial({
163
+ color: new THREE.Color(0xffffff)
164
+ });
165
+ const topMaterial = new THREE.MeshStandardMaterial({
166
+ map: texture,
167
+ side: THREE.DoubleSide,
168
+ transparent: true
169
+ });
170
+
171
+ // Create an array of materials for each face of the box
172
+ const materials = [sideMaterial,
173
+ // right
174
+ sideMaterial,
175
+ // left
176
+ topMaterial,
177
+ // top (with logo texture)
178
+ sideMaterial,
179
+ // bottom
180
+ sideMaterial,
181
+ // front
182
+ sideMaterial // back
183
+ ];
184
+
185
+ // Create the mesh with geometry and materials
186
+ const logoMesh = new THREE.Mesh(geometry, materials);
187
+
188
+ // Adjust rotation to match your previous orientation
189
+ logoMesh.rotation.x = Math.PI / 2;
190
+ logoMesh.rotation.y = -Math.PI / 1.45;
191
+ logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);
192
+ this.threebox.add(logoMesh);
193
+ return logoMesh;
194
+ });
195
+ // Function to add text using Troika Text library at a specified position
196
+ _defineProperty(this, "addTitle", (title, position) => {
197
+ // Create a new Text instance
198
+ const textMesh = new _troikaThreeText.Text();
199
+
200
+ // Configure text properties
201
+ textMesh.text = title;
202
+ textMesh.fontSize = 0.2;
203
+ textMesh.color = 0x000000;
204
+ textMesh.anchorX = '50%';
205
+ textMesh.anchorY = 'bottom-baseline';
206
+ textMesh.fontWeight = 'bold';
207
+ textMesh.textAlign = 'center';
208
+ textMesh.position.set(position.x, position.y, position.z);
209
+ textMesh.rotation.z = -Math.PI / 1.45;
210
+
211
+ // Add text to the scene
212
+ this.threebox.add(textMesh);
213
+
214
+ // Update the text rendering
215
+ textMesh.sync();
216
+ return textMesh;
217
+ });
18
218
  if (MainMap.mainInstance) {
19
219
  return MainMap.mainInstance;
20
220
  }
@@ -62,206 +262,10 @@ class MainMap {
62
262
  getThreebox() {
63
263
  return this.threebox;
64
264
  }
65
- getAllPolygonCoordinates = () => {
66
- const map = this.map;
67
- if (!map) return [];
68
- const polygonFeatures = [];
69
- const source = map.getSource('custom');
70
- if (source) {
71
- const features = map.querySourceFeatures('custom', {
72
- sourceLayer: 'geojson',
73
- filter: ['==', ['geometry-type'], 'Polygon']
74
- });
75
- if (features && features.length > 0) {
76
- features.forEach(feature => {
77
- if ((feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') && feature.properties.dimension_what === 'what.booth') {
78
- polygonFeatures.push({
79
- id: feature.properties.mapObjectId,
80
- name: feature.properties?.title || 'Unnamed Polygon',
81
- coordinates: feature.geometry.coordinates,
82
- properties: {
83
- ...feature.properties,
84
- hasImage: !!Math.round(Math.random())
85
- }
86
- });
87
- }
88
- });
89
- }
90
- }
91
- return polygonFeatures;
92
- };
93
265
  addNewLine(input) {
94
266
  return input.replace(/ /g, '\r\n');
95
267
  }
96
- updatePolygons = features => {
97
- features.map(async feature => {
98
- const coordinates = feature.geometry.coordinates;
99
- // const centroid = feature.properties.center;
100
- const polygon = turf.polygon(coordinates);
101
- const centroid = turf.centroid(polygon).geometry.coordinates;
102
- // const modelPosition = projectToWorld(centroid);
103
-
104
- // const vertex1 = projectToWorld(coordinates[0][0]);
105
- // const vertex2 = projectToWorld(coordinates[0][1]);
106
- // const angle = vertex1.angleTo(vertex2);
107
- // console.log(angle);
108
-
109
- // await modelLoader.loadModel({
110
- // modelPath: feature.properties.modelPath,
111
- // feature,
112
- // wrapper: wrapper.current!,
113
- // onProgress: (progress) => {
114
- // setLoadingProgress((prev) => ({
115
- // ...prev,
116
- // [feature.properties.id]: progress,
117
- // }));
118
- // },
119
- // onError: (error) => {
120
- // console.error(
121
- // `Failed to load model ${feature.properties.id}:`,
122
- // error
123
- // );
124
- // },
125
- // });
126
-
127
- if (!feature.properties.hasImage && feature.properties.dimension_where && feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor') {
128
- const myText = new _threeSpritetext.default();
129
- myText.color = 'black';
130
- let text = feature.properties.title;
131
- text = this.addNewLine(text);
132
-
133
- // Set properties to configure:
134
- myText.text = text;
135
- myText.textHeight = 100;
136
- // myText.textHeight = 1;
137
- // myText.backgroundColor = '';
138
- const textPosition = (0, _utils.projectToWorld)(centroid);
139
- myText.rotation.x = Math.PI;
140
- myText.rotation.y = Math.PI;
141
- myText.scale.set(0.1, 0.1, 0.01);
142
- myText.position.set(textPosition.x, textPosition.y,
143
- // feature.properties.height > 0 ? 0.4 : 0.25
144
- 0.1);
145
- this.threebox.add(myText);
146
- } else {
147
- // Load Texture
148
- // const textureLoader = new THREE.TextureLoader();
149
- // textureLoader.load('/sk.png', (texture: THREE.Texture) => {
150
- // // Create a plane geometry and material with the loaded texture
151
- // const geometry = new THREE.PlaneGeometry(
152
- // texture.image.width,
153
- // texture.image.height
154
- // );
155
- // geometry.computeBoundingBox();
156
- // const material = new THREE.MeshStandardMaterial({
157
- // map: texture,
158
- // transparent: true, // Enable transparency
159
- // opacity: 1,
160
- // });
161
- // const plane = new THREE.Mesh(geometry, material);
162
- // const group = new THREE.Group();
163
- // const childContainer = new THREE.Group();
164
- // childContainer.add(plane);
165
- // childContainer.rotateZ(Math.PI / 2);
166
- // childContainer.rotateZ(1);
167
- // childContainer.updateMatrixWorld();
168
- // group.add(childContainer);
169
- // const geojsonbbox = turf.bbox(polygon);
170
- // const bbox1 = new THREE.Box3(
171
- // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),
172
- // projectToWorld([geojsonbbox[0], geojsonbbox[1]])
173
- // );
174
- // const bbox2 = new THREE.Box3().setFromObject(plane);
175
- // const size1 = new THREE.Vector3();
176
- // bbox1.getSize(size1);
177
- // size1.setZ(1);
178
- // const size2 = new THREE.Vector3();
179
- // bbox2.getSize(size2);
180
- // size2.setZ(1);
181
- // const ratio = size1.divide(size2);
182
- // const ratioCopy = ratio.clone().multiplyScalar(0.85);
183
- // plane.scale.set(
184
- // plane.scale.x * ratioCopy.x,
185
- // plane.scale.y * ratioCopy.y,
186
- // plane.scale.z * ratioCopy.z
187
- // );
188
- // // // Set the position of the plane to the centroid
189
- // group.position.set(modelPosition.x, modelPosition.y, 0.11);
190
- // this.threebox.add(group);
191
- // });
192
- }
193
- });
194
- };
195
- addLogo = (logo, position) => {
196
- const textureLoader = new THREE.TextureLoader();
197
- const texture = textureLoader.load(logo);
198
-
199
- // Define rectangle dimensions
200
- const width = 4;
201
- const height = 0;
202
- const depth = 2;
203
-
204
- // Create a box geometry instead of cylinder
205
- const geometry = new THREE.BoxGeometry(width, height, depth);
206
-
207
- // Create materials: [right, left, top, bottom, front, back]
208
- const sideMaterial = new THREE.MeshBasicMaterial({
209
- color: new THREE.Color(0xffffff)
210
- });
211
- const topMaterial = new THREE.MeshStandardMaterial({
212
- map: texture,
213
- side: THREE.DoubleSide,
214
- transparent: true
215
- });
216
-
217
- // Create an array of materials for each face of the box
218
- const materials = [sideMaterial,
219
- // right
220
- sideMaterial,
221
- // left
222
- topMaterial,
223
- // top (with logo texture)
224
- sideMaterial,
225
- // bottom
226
- sideMaterial,
227
- // front
228
- sideMaterial // back
229
- ];
230
-
231
- // Create the mesh with geometry and materials
232
- const logoMesh = new THREE.Mesh(geometry, materials);
233
-
234
- // Adjust rotation to match your previous orientation
235
- logoMesh.rotation.x = Math.PI / 2;
236
- logoMesh.rotation.y = -Math.PI / 1.45;
237
- logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);
238
- this.threebox.add(logoMesh);
239
- return logoMesh;
240
- };
241
-
242
- // Function to add text using Troika Text library at a specified position
243
- addTitle = (title, position) => {
244
- // Create a new Text instance
245
- const textMesh = new _troikaThreeText.Text();
246
-
247
- // Configure text properties
248
- textMesh.text = title;
249
- textMesh.fontSize = 0.2;
250
- textMesh.color = 0x000000;
251
- textMesh.anchorX = '50%';
252
- textMesh.anchorY = 'bottom-baseline';
253
- textMesh.fontWeight = 'bold';
254
- textMesh.textAlign = 'center';
255
- textMesh.position.set(position.x, position.y, position.z);
256
- textMesh.rotation.z = -Math.PI / 1.45;
257
-
258
- // Add text to the scene
259
- this.threebox.add(textMesh);
260
-
261
- // Update the text rendering
262
- textMesh.sync();
263
- return textMesh;
264
- };
265
268
  }
266
269
  exports.default = MainMap;
270
+ _defineProperty(MainMap, "mainInstance", null);
267
271
  //# sourceMappingURL=MainMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MainMap.js","names":["_troikaThreeText","require","turf","_interopRequireWildcard","THREE","_utils","_threeSpritetext","_interopRequireDefault","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MainMap","mainInstance","constructor","metaAtlasCore","init","map2D","map","initThreebox","wrapper","CustomThreeJSWrapper","setEnvironment","addLayer","id","type","renderingMode","onAdd","console","log","render","update","threebox","getThreebox","getAllPolygonCoordinates","polygonFeatures","source","getSource","features","querySourceFeatures","sourceLayer","filter","length","forEach","feature","geometry","properties","dimension_what","push","mapObjectId","name","title","coordinates","hasImage","Math","round","random","addNewLine","input","replace","updatePolygons","polygon","centroid","dimension_where","myText","SpriteText","color","text","textHeight","textPosition","projectToWorld","rotation","x","PI","y","scale","position","add","addLogo","logo","textureLoader","TextureLoader","texture","load","width","height","depth","BoxGeometry","sideMaterial","MeshBasicMaterial","Color","topMaterial","MeshStandardMaterial","side","DoubleSide","transparent","materials","logoMesh","Mesh","z","addTitle","textMesh","Text","fontSize","anchorX","anchorY","fontWeight","textAlign","sync","exports"],"sources":["../../../../src/meta-atlas-sdk/3DMap/MainMap.ts"],"sourcesContent":["import { Map as MaplibreMap } from 'maplibre-gl';\n\nimport CustomThreeJSWrapper from './CustomThreeJsWrapper/CustomThreeJsWrapper';\nimport { Text } from 'troika-three-text';\n\nimport { EquirectangularReflectionMapping } from 'three';\nimport { MetaAtlasCore } from '../MetaAtlasCore/meta-atlas-sdk-core';\nimport * as turf from '@turf/turf';\nimport * as THREE from 'three';\nimport { projectToWorld } from './CustomThreeJsWrapper/utility/utils';\nimport SpriteText from 'three-spritetext';\nimport { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader';\n\nexport default class MainMap {\n public static mainInstance: MainMap | null = null;\n public map!: MaplibreMap;\n public threebox!: CustomThreeJSWrapper;\n public metaAtlasCore!: MetaAtlasCore;\n\n constructor(metaAtlasCore: MetaAtlasCore) {\n if (MainMap.mainInstance) {\n return MainMap.mainInstance;\n }\n\n MainMap.mainInstance = this;\n\n this.metaAtlasCore = metaAtlasCore;\n }\n\n public init(map2D: MaplibreMap) {\n this.map = map2D;\n this.initThreebox();\n }\n\n /**\n * Creates a Threebox instance of the class.\n * @param map Maplibre instance to initialize threebox\n * @returns Threebox class instance created\n */\n private initThreebox() {\n const map = this.map;\n const wrapper = new CustomThreeJSWrapper(map);\n wrapper.setEnvironment();\n // const hdrLoader = new HDRLoader();\n // hdrLoader.load('./golden_gate_hills_1k.hdr', texture => {\n // texture.mapping = EquirectangularReflectionMapping;\n // wrapper.scene.environment = texture;\n // });\n\n map.addLayer({\n id: '3d-model-layer',\n type: 'custom',\n renderingMode: '3d',\n onAdd: () => {\n console.log('onAdd _initThreebox');\n },\n render: () => {\n wrapper.update();\n }\n });\n\n this.threebox = wrapper;\n return wrapper;\n }\n\n /**\n * Get the threebox instance for 3D model operations\n */\n getThreebox() {\n return this.threebox;\n }\n\n getAllPolygonCoordinates = () => {\n const map = this.map;\n\n if (!map) return [];\n\n const polygonFeatures: any[] = [];\n const source = map.getSource('custom');\n if (source) {\n const features = map.querySourceFeatures('custom', {\n sourceLayer: 'geojson',\n filter: ['==', ['geometry-type'], 'Polygon']\n });\n\n if (features && features.length > 0) {\n features.forEach(feature => {\n if (\n (feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') &&\n feature.properties.dimension_what === 'what.booth'\n ) {\n polygonFeatures.push({\n id: feature.properties.mapObjectId,\n name: feature.properties?.title || 'Unnamed Polygon',\n coordinates: feature.geometry.coordinates,\n properties: {\n ...feature.properties,\n hasImage: !!Math.round(Math.random())\n }\n });\n }\n });\n }\n }\n\n return polygonFeatures;\n };\n\n addNewLine(input: string): string {\n return input.replace(/ /g, '\\r\\n');\n }\n\n updatePolygons = (features: any[]) => {\n features.map(async (feature: any) => {\n const coordinates = feature.geometry.coordinates;\n // const centroid = feature.properties.center;\n const polygon = turf.polygon(coordinates);\n const centroid = turf.centroid(polygon).geometry.coordinates;\n // const modelPosition = projectToWorld(centroid);\n\n // const vertex1 = projectToWorld(coordinates[0][0]);\n // const vertex2 = projectToWorld(coordinates[0][1]);\n // const angle = vertex1.angleTo(vertex2);\n // console.log(angle);\n\n // await modelLoader.loadModel({\n // modelPath: feature.properties.modelPath,\n // feature,\n // wrapper: wrapper.current!,\n // onProgress: (progress) => {\n // setLoadingProgress((prev) => ({\n // ...prev,\n // [feature.properties.id]: progress,\n // }));\n // },\n // onError: (error) => {\n // console.error(\n // `Failed to load model ${feature.properties.id}:`,\n // error\n // );\n // },\n // });\n\n if (\n !feature.properties.hasImage &&\n feature.properties.dimension_where &&\n feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor'\n ) {\n const myText = new SpriteText();\n myText.color = 'black';\n let text = feature.properties.title;\n text = this.addNewLine(text);\n\n // Set properties to configure:\n myText.text = text;\n myText.textHeight = 100;\n // myText.textHeight = 1;\n // myText.backgroundColor = '';\n const textPosition = projectToWorld(centroid);\n myText.rotation.x = Math.PI;\n myText.rotation.y = Math.PI;\n myText.scale.set(0.1, 0.1, 0.01);\n\n myText.position.set(\n textPosition.x,\n textPosition.y,\n // feature.properties.height > 0 ? 0.4 : 0.25\n 0.1\n );\n this.threebox.add(myText);\n } else {\n // Load Texture\n // const textureLoader = new THREE.TextureLoader();\n // textureLoader.load('/sk.png', (texture: THREE.Texture) => {\n // // Create a plane geometry and material with the loaded texture\n // const geometry = new THREE.PlaneGeometry(\n // texture.image.width,\n // texture.image.height\n // );\n // geometry.computeBoundingBox();\n // const material = new THREE.MeshStandardMaterial({\n // map: texture,\n // transparent: true, // Enable transparency\n // opacity: 1,\n // });\n // const plane = new THREE.Mesh(geometry, material);\n // const group = new THREE.Group();\n // const childContainer = new THREE.Group();\n // childContainer.add(plane);\n // childContainer.rotateZ(Math.PI / 2);\n // childContainer.rotateZ(1);\n // childContainer.updateMatrixWorld();\n // group.add(childContainer);\n // const geojsonbbox = turf.bbox(polygon);\n // const bbox1 = new THREE.Box3(\n // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),\n // projectToWorld([geojsonbbox[0], geojsonbbox[1]])\n // );\n // const bbox2 = new THREE.Box3().setFromObject(plane);\n // const size1 = new THREE.Vector3();\n // bbox1.getSize(size1);\n // size1.setZ(1);\n // const size2 = new THREE.Vector3();\n // bbox2.getSize(size2);\n // size2.setZ(1);\n // const ratio = size1.divide(size2);\n // const ratioCopy = ratio.clone().multiplyScalar(0.85);\n // plane.scale.set(\n // plane.scale.x * ratioCopy.x,\n // plane.scale.y * ratioCopy.y,\n // plane.scale.z * ratioCopy.z\n // );\n // // // Set the position of the plane to the centroid\n // group.position.set(modelPosition.x, modelPosition.y, 0.11);\n // this.threebox.add(group);\n // });\n }\n });\n };\n\n addLogo = (logo: string, position: THREE.Vector3) => {\n const textureLoader = new THREE.TextureLoader();\n const texture = textureLoader.load(logo);\n\n // Define rectangle dimensions\n const width = 4;\n const height = 0;\n const depth = 2;\n\n // Create a box geometry instead of cylinder\n const geometry = new THREE.BoxGeometry(width, height, depth);\n\n // Create materials: [right, left, top, bottom, front, back]\n const sideMaterial = new THREE.MeshBasicMaterial({ color: new THREE.Color(0xffffff) });\n const topMaterial = new THREE.MeshStandardMaterial({\n map: texture,\n side: THREE.DoubleSide,\n transparent: true\n });\n\n // Create an array of materials for each face of the box\n const materials = [\n sideMaterial, // right\n sideMaterial, // left\n topMaterial, // top (with logo texture)\n sideMaterial, // bottom\n sideMaterial, // front\n sideMaterial // back\n ];\n\n // Create the mesh with geometry and materials\n const logoMesh = new THREE.Mesh(geometry, materials);\n\n // Adjust rotation to match your previous orientation\n logoMesh.rotation.x = Math.PI / 2;\n logoMesh.rotation.y = -Math.PI / 1.45;\n logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);\n\n this.threebox.add(logoMesh);\n\n return logoMesh;\n };\n\n // Function to add text using Troika Text library at a specified position\n addTitle = (title: string, position: THREE.Vector3) => {\n // Create a new Text instance\n const textMesh = new Text();\n\n // Configure text properties\n textMesh.text = title;\n textMesh.fontSize = 0.2;\n textMesh.color = 0x000000;\n textMesh.anchorX = '50%';\n textMesh.anchorY = 'bottom-baseline';\n textMesh.fontWeight = 'bold';\n textMesh.textAlign = 'center';\n\n textMesh.position.set(position.x, position.y, position.z);\n textMesh.rotation.z = -Math.PI / 1.45;\n\n // Add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AAAS,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"MainMap.js","names":["_troikaThreeText","require","turf","_interopRequireWildcard","THREE","_utils","_threeSpritetext","_interopRequireDefault","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","_toPropertyKey","value","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","MainMap","constructor","metaAtlasCore","map","polygonFeatures","source","getSource","features","querySourceFeatures","sourceLayer","feature","geometry","type","properties","dimension_what","_feature$properties","id","mapObjectId","name","title","coordinates","hasImage","Math","round","random","polygon","centroid","dimension_where","myText","SpriteText","color","text","addNewLine","textHeight","textPosition","projectToWorld","rotation","x","PI","y","scale","position","threebox","add","logo","textureLoader","TextureLoader","texture","load","width","height","depth","BoxGeometry","sideMaterial","MeshBasicMaterial","Color","topMaterial","MeshStandardMaterial","side","DoubleSide","transparent","materials","logoMesh","Mesh","z","textMesh","Text","fontSize","anchorX","anchorY","fontWeight","textAlign","sync","mainInstance","init","map2D","initThreebox","wrapper","CustomThreeJSWrapper","setEnvironment","addLayer","renderingMode","onAdd","console","log","render","update","getThreebox","input","replace","exports"],"sources":["../../../../src/meta-atlas-sdk/3DMap/MainMap.ts"],"sourcesContent":["import { Map as MaplibreMap } from 'maplibre-gl';\n\nimport CustomThreeJSWrapper from './CustomThreeJsWrapper/CustomThreeJsWrapper';\nimport { Text } from 'troika-three-text';\n\nimport { EquirectangularReflectionMapping } from 'three';\nimport { MetaAtlasCore } from '../MetaAtlasCore/meta-atlas-sdk-core';\nimport * as turf from '@turf/turf';\nimport * as THREE from 'three';\nimport { projectToWorld } from './CustomThreeJsWrapper/utility/utils';\nimport SpriteText from 'three-spritetext';\nimport { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader';\n\nexport default class MainMap {\n public static mainInstance: MainMap | null = null;\n public map!: MaplibreMap;\n public threebox!: CustomThreeJSWrapper;\n public metaAtlasCore!: MetaAtlasCore;\n\n constructor(metaAtlasCore: MetaAtlasCore) {\n if (MainMap.mainInstance) {\n return MainMap.mainInstance;\n }\n\n MainMap.mainInstance = this;\n\n this.metaAtlasCore = metaAtlasCore;\n }\n\n public init(map2D: MaplibreMap) {\n this.map = map2D;\n this.initThreebox();\n }\n\n /**\n * Creates a Threebox instance of the class.\n * @param map Maplibre instance to initialize threebox\n * @returns Threebox class instance created\n */\n private initThreebox() {\n const map = this.map;\n const wrapper = new CustomThreeJSWrapper(map);\n wrapper.setEnvironment();\n // const hdrLoader = new HDRLoader();\n // hdrLoader.load('./golden_gate_hills_1k.hdr', texture => {\n // texture.mapping = EquirectangularReflectionMapping;\n // wrapper.scene.environment = texture;\n // });\n\n map.addLayer({\n id: '3d-model-layer',\n type: 'custom',\n renderingMode: '3d',\n onAdd: () => {\n console.log('onAdd _initThreebox');\n },\n render: () => {\n wrapper.update();\n }\n });\n\n this.threebox = wrapper;\n return wrapper;\n }\n\n /**\n * Get the threebox instance for 3D model operations\n */\n getThreebox() {\n return this.threebox;\n }\n\n getAllPolygonCoordinates = () => {\n const map = this.map;\n\n if (!map) return [];\n\n const polygonFeatures: any[] = [];\n const source = map.getSource('custom');\n if (source) {\n const features = map.querySourceFeatures('custom', {\n sourceLayer: 'geojson',\n filter: ['==', ['geometry-type'], 'Polygon']\n });\n\n if (features && features.length > 0) {\n features.forEach(feature => {\n if (\n (feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') &&\n feature.properties.dimension_what === 'what.booth'\n ) {\n polygonFeatures.push({\n id: feature.properties.mapObjectId,\n name: feature.properties?.title || 'Unnamed Polygon',\n coordinates: feature.geometry.coordinates,\n properties: {\n ...feature.properties,\n hasImage: !!Math.round(Math.random())\n }\n });\n }\n });\n }\n }\n\n return polygonFeatures;\n };\n\n addNewLine(input: string): string {\n return input.replace(/ /g, '\\r\\n');\n }\n\n updatePolygons = (features: any[]) => {\n features.map(async (feature: any) => {\n const coordinates = feature.geometry.coordinates;\n // const centroid = feature.properties.center;\n const polygon = turf.polygon(coordinates);\n const centroid = turf.centroid(polygon).geometry.coordinates;\n // const modelPosition = projectToWorld(centroid);\n\n // const vertex1 = projectToWorld(coordinates[0][0]);\n // const vertex2 = projectToWorld(coordinates[0][1]);\n // const angle = vertex1.angleTo(vertex2);\n // console.log(angle);\n\n // await modelLoader.loadModel({\n // modelPath: feature.properties.modelPath,\n // feature,\n // wrapper: wrapper.current!,\n // onProgress: (progress) => {\n // setLoadingProgress((prev) => ({\n // ...prev,\n // [feature.properties.id]: progress,\n // }));\n // },\n // onError: (error) => {\n // console.error(\n // `Failed to load model ${feature.properties.id}:`,\n // error\n // );\n // },\n // });\n\n if (\n !feature.properties.hasImage &&\n feature.properties.dimension_where &&\n feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor'\n ) {\n const myText = new SpriteText();\n myText.color = 'black';\n let text = feature.properties.title;\n text = this.addNewLine(text);\n\n // Set properties to configure:\n myText.text = text;\n myText.textHeight = 100;\n // myText.textHeight = 1;\n // myText.backgroundColor = '';\n const textPosition = projectToWorld(centroid);\n myText.rotation.x = Math.PI;\n myText.rotation.y = Math.PI;\n myText.scale.set(0.1, 0.1, 0.01);\n\n myText.position.set(\n textPosition.x,\n textPosition.y,\n // feature.properties.height > 0 ? 0.4 : 0.25\n 0.1\n );\n this.threebox.add(myText);\n } else {\n // Load Texture\n // const textureLoader = new THREE.TextureLoader();\n // textureLoader.load('/sk.png', (texture: THREE.Texture) => {\n // // Create a plane geometry and material with the loaded texture\n // const geometry = new THREE.PlaneGeometry(\n // texture.image.width,\n // texture.image.height\n // );\n // geometry.computeBoundingBox();\n // const material = new THREE.MeshStandardMaterial({\n // map: texture,\n // transparent: true, // Enable transparency\n // opacity: 1,\n // });\n // const plane = new THREE.Mesh(geometry, material);\n // const group = new THREE.Group();\n // const childContainer = new THREE.Group();\n // childContainer.add(plane);\n // childContainer.rotateZ(Math.PI / 2);\n // childContainer.rotateZ(1);\n // childContainer.updateMatrixWorld();\n // group.add(childContainer);\n // const geojsonbbox = turf.bbox(polygon);\n // const bbox1 = new THREE.Box3(\n // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),\n // projectToWorld([geojsonbbox[0], geojsonbbox[1]])\n // );\n // const bbox2 = new THREE.Box3().setFromObject(plane);\n // const size1 = new THREE.Vector3();\n // bbox1.getSize(size1);\n // size1.setZ(1);\n // const size2 = new THREE.Vector3();\n // bbox2.getSize(size2);\n // size2.setZ(1);\n // const ratio = size1.divide(size2);\n // const ratioCopy = ratio.clone().multiplyScalar(0.85);\n // plane.scale.set(\n // plane.scale.x * ratioCopy.x,\n // plane.scale.y * ratioCopy.y,\n // plane.scale.z * ratioCopy.z\n // );\n // // // Set the position of the plane to the centroid\n // group.position.set(modelPosition.x, modelPosition.y, 0.11);\n // this.threebox.add(group);\n // });\n }\n });\n };\n\n addLogo = (logo: string, position: THREE.Vector3) => {\n const textureLoader = new THREE.TextureLoader();\n const texture = textureLoader.load(logo);\n\n // Define rectangle dimensions\n const width = 4;\n const height = 0;\n const depth = 2;\n\n // Create a box geometry instead of cylinder\n const geometry = new THREE.BoxGeometry(width, height, depth);\n\n // Create materials: [right, left, top, bottom, front, back]\n const sideMaterial = new THREE.MeshBasicMaterial({ color: new THREE.Color(0xffffff) });\n const topMaterial = new THREE.MeshStandardMaterial({\n map: texture,\n side: THREE.DoubleSide,\n transparent: true\n });\n\n // Create an array of materials for each face of the box\n const materials = [\n sideMaterial, // right\n sideMaterial, // left\n topMaterial, // top (with logo texture)\n sideMaterial, // bottom\n sideMaterial, // front\n sideMaterial // back\n ];\n\n // Create the mesh with geometry and materials\n const logoMesh = new THREE.Mesh(geometry, materials);\n\n // Adjust rotation to match your previous orientation\n logoMesh.rotation.x = Math.PI / 2;\n logoMesh.rotation.y = -Math.PI / 1.45;\n logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);\n\n this.threebox.add(logoMesh);\n\n return logoMesh;\n };\n\n // Function to add text using Troika Text library at a specified position\n addTitle = (title: string, position: THREE.Vector3) => {\n // Create a new Text instance\n const textMesh = new Text();\n\n // Configure text properties\n textMesh.text = title;\n textMesh.fontSize = 0.2;\n textMesh.color = 0x000000;\n textMesh.anchorX = '50%';\n textMesh.anchorY = 'bottom-baseline';\n textMesh.fontWeight = 'bold';\n textMesh.textAlign = 'center';\n\n textMesh.position.set(position.x, position.y, position.z);\n textMesh.rotation.z = -Math.PI / 1.45;\n\n // Add text to the scene\n this.threebox.add(textMesh);\n\n // Update the text rendering\n textMesh.sync();\n\n return textMesh;\n };\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAIA,IAAAC,IAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAD,uBAAA,CAAAF,OAAA;AAA+B,IAAAI,MAAA,GAAAJ,OAAA;AAE/B,IAAAK,gBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAA0C,SAAAE,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,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AAa,GAAGA,aAAa;EACpC;EAEOwE,IAAIA,CAACC,KAAkB,EAAE;IAC9B,IAAI,CAACxE,GAAG,GAAGwE,KAAK;IAChB,IAAI,CAACC,YAAY,CAAC,CAAC;EACrB;;EAEA;AACF;AACA;AACA;AACA;EACUA,YAAYA,CAAA,EAAG;IACrB,MAAMzE,GAAG,GAAG,IAAI,CAACA,GAAG;IACpB,MAAM0E,OAAO,GAAG,IAAIC,6BAAoB,CAAC3E,GAAG,CAAC;IAC7C0E,OAAO,CAACE,cAAc,CAAC,CAAC;IACxB;IACA;IACA;IACA;IACA;;IAEA5E,GAAG,CAAC6E,QAAQ,CAAC;MACXhE,EAAE,EAAE,gBAAgB;MACpBJ,IAAI,EAAE,QAAQ;MACdqE,aAAa,EAAE,IAAI;MACnBC,KAAK,EAAEA,CAAA,KAAM;QACXC,OAAO,CAACC,GAAG,CAAC,qBAAqB,CAAC;MACpC,CAAC;MACDC,MAAM,EAAEA,CAAA,KAAM;QACZR,OAAO,CAACS,MAAM,CAAC,CAAC;MAClB;IACF,CAAC,CAAC;IAEF,IAAI,CAAC5C,QAAQ,GAAGmC,OAAO;IACvB,OAAOA,OAAO;EAChB;;EAEA;AACF;AACA;EACEU,WAAWA,CAAA,EAAG;IACZ,OAAO,IAAI,CAAC7C,QAAQ;EACtB;EAsCAV,UAAUA,CAACwD,KAAa,EAAU;IAChC,OAAOA,KAAK,CAACC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;EACpC;AAkLF;AAACC,OAAA,CAAA3H,OAAA,GAAAiC,OAAA;AAAAb,eAAA,CAnRoBa,OAAO,kBACmB,IAAI","ignoreList":[]}
@@ -52,9 +52,9 @@ async function getPublishedData(serverAPIInfo, localStorage) {
52
52
  const currentVersion = localStorage.contains(localStorageVersionKey) ? localStorage.getString(localStorageVersionKey) : '0.0.0';
53
53
  return new Promise((resolve, reject) => {
54
54
  (0, _axios.default)({
55
- url: `${serverAPIInfo.URL}/check-published-versions`,
55
+ url: "".concat(serverAPIInfo.URL, "/check-published-versions"),
56
56
  headers: {
57
- Authorization: `Bearer ${serverAPIInfo.accessToken}`,
57
+ Authorization: "Bearer ".concat(serverAPIInfo.accessToken),
58
58
  'Content-Type': 'application/json'
59
59
  },
60
60
  method: 'POST',
@@ -168,7 +168,7 @@ async function getPublishedData(serverAPIInfo, localStorage) {
168
168
  // This is the API call for getting map-objects.json
169
169
  const response = await fetch(info.URL);
170
170
  if (!response.ok) {
171
- throw new Error(`HTTP error! Status: ${response.status}`);
171
+ throw new Error("HTTP error! Status: ".concat(response.status));
172
172
  }
173
173
  const responseData = await response.json();
174
174
  // const responseData = JSON.parse(fileContent);
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-published-json.js","names":["_axios","_interopRequireDefault","require","_helpers","_routingStore","_mapobjectsStore","e","__esModule","default","PublishedDataType","exports","Status","getDataType","publishedDataType","Routing","MapObjects","getLocalStorageKey","param","valueOf","setRouteData","useRouteDataStore","setState","setMapObjectsData","useMapObjectsDataStore","getRunTimeStore","getPublishedData","serverAPIInfo","localStorage","localStorageVersionKey","status","Awaiting","setRunTimeStoreData","fetchInfo","currentVersion","contains","getString","Promise","resolve","reject","axios","url","URL","headers","Authorization","accessToken","method","data","JSON","stringify","version","dataType","then","response","remoteData","publishedDataInfo","undefined","remoteVersion","localVersion","hasOwnProperty","currentData","tag","downloadUrl","DownloadingResources","console","log","catch","error","request","message","config","storeFileToLocalStorage","set","loadFileFromStore","decryptedJson","decryptFile","secretKey","Ready","onError","loaded","Unavailable","clearAll","info","fetch","ok","Error","responseData","json","storedSuccessfully"],"sources":["../../../../src/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.ts"],"sourcesContent":["import axios from 'axios';\n\nimport { LocalStorage } from '../utils/local-storage';\nimport { decryptFile } from '../utils/helpers';\nimport useRouteDataStore from '../utils/routing-store';\nimport useMapObjectsDataStore from '../utils/mapobjects-store';\n\nexport enum PublishedDataType {\n Routing = 'routing',\n MapObjects = 'mapObjects',\n}\n\nexport enum Status {\n Ready = 'Ready',\n Awaiting = 'Awaiting',\n DownloadingResources = 'DownloadingResources',\n Unavailable = 'Unavailable',\n}\n\nexport type StatusUpdateCallbackType = (loaded: boolean) => void;\n\nexport interface ServerAPIInfo {\n URL: string;\n accessToken: string;\n secretKey: string;\n publishedDataType: PublishedDataType;\n}\n\nexport interface PublishedDataInfo {\n currentVersion: string | undefined;\n remoteVersion: string | undefined;\n URL: string | undefined;\n data: string | undefined;\n}\n\nfunction getDataType(publishedDataType: PublishedDataType) {\n if (publishedDataType === PublishedDataType.Routing) {\n return 'generate-route-json-per-role';\n }\n if (publishedDataType === PublishedDataType.MapObjects) {\n return 'generate-map-objects-per-role';\n }\n}\n\nfunction getLocalStorageKey(\n param: string,\n publishedDataType: PublishedDataType,\n): string {\n return publishedDataType.valueOf() + param;\n}\n\nconst setRouteData = useRouteDataStore.setState;\nconst setMapObjectsData = useMapObjectsDataStore.setState;\n\nfunction getRunTimeStore(publishedDataType: PublishedDataType) {\n if (publishedDataType === PublishedDataType.Routing) {\n return setRouteData;\n }\n if (publishedDataType === PublishedDataType.MapObjects) {\n return setMapObjectsData;\n }\n}\n\nexport async function getPublishedData(\n serverAPIInfo: ServerAPIInfo,\n localStorage: LocalStorage,\n) {\n const publishedDataType = serverAPIInfo.publishedDataType;\n const localStorageVersionKey = getLocalStorageKey(\n 'version',\n publishedDataType,\n );\n let status: Status = Status.Awaiting;\n let setRunTimeStoreData = getRunTimeStore(publishedDataType);\n\n const fetchInfo = async () => {\n const currentVersion = localStorage.contains(localStorageVersionKey)\n ? localStorage.getString(localStorageVersionKey)\n : '0.0.0';\n return new Promise(\n (resolve: (routingInfo: PublishedDataInfo) => void, reject) => {\n axios({\n url: `${serverAPIInfo.URL}/check-published-versions`,\n headers: {\n Authorization: `Bearer ${serverAPIInfo.accessToken}`,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n data: JSON.stringify({\n version: currentVersion,\n dataType: getDataType(serverAPIInfo.publishedDataType),\n }),\n })\n .then(response => {\n const remoteData = response.data;\n\n const publishedDataInfo = {\n currentVersion: undefined,\n remoteVersion: undefined,\n URL: undefined,\n data: undefined,\n } as PublishedDataInfo;\n const localVersion = localStorage.getString(localStorageVersionKey);\n let remoteVersion = localVersion;\n if (remoteData.hasOwnProperty('version')) {\n remoteVersion = remoteData.version;\n }\n\n publishedDataInfo.currentVersion = localVersion;\n publishedDataInfo.remoteVersion = remoteVersion;\n if (localVersion) {\n const currentData = localStorage.getString(\n getLocalStorageKey('data', publishedDataType),\n );\n const tag = localStorage.getString(\n getLocalStorageKey('encryptionTag', publishedDataType),\n );\n\n // Check both because data is useless without tag\n if (tag && currentData) {\n publishedDataInfo.data = currentData;\n }\n }\n if (remoteVersion) {\n if (remoteData.hasOwnProperty('downloadUrl')) {\n publishedDataInfo.URL = remoteData.downloadUrl;\n }\n if (\n (localVersion && remoteVersion > localVersion) ||\n !localVersion ||\n !publishedDataInfo.data\n ) {\n status = publishedDataInfo.URL\n ? Status.DownloadingResources\n : status;\n }\n }\n\n console.log(\n 'final: ',\n publishedDataInfo.URL,\n publishedDataInfo.currentVersion,\n publishedDataInfo.remoteVersion,\n );\n resolve(publishedDataInfo);\n })\n .catch(function (error) {\n console.log('error while fetching published version: ');\n if (error.response) {\n // The request was made and the server responded with a status code\n // that falls out of the range of 2xx\n console.log(error.response.data);\n console.log(error.response.status);\n console.log(error.response.headers);\n } else if (error.request) {\n // The request was made but no response was received\n // `error.request` is an instance of XMLHttpRequest in the browser and an instance of\n // http.ClientRequest in node.js\n console.log(error.request);\n } else {\n // Something happened in setting up the request that triggered an Error\n console.log('Error', error.message);\n }\n console.log(error.config);\n reject(error);\n });\n },\n );\n };\n\n const storeFileToLocalStorage = (data: any, version: any, tag: any) => {\n try {\n localStorage.set(getLocalStorageKey('data', publishedDataType), data);\n localStorage.set(localStorageVersionKey, version);\n localStorage.set(\n getLocalStorageKey('encryptionTag', publishedDataType),\n tag,\n );\n return true;\n } catch (e) {\n console.log('error storing routing file from local storage', e);\n return false;\n }\n };\n\n const loadFileFromStore = () => {\n const currentData = localStorage.getString(\n getLocalStorageKey('data', publishedDataType),\n );\n const tag = localStorage.getString(\n getLocalStorageKey('encryptionTag', publishedDataType),\n );\n if (currentData && tag) {\n const decryptedJson = decryptFile(currentData, tag, serverAPIInfo.secretKey);\n // JSON.parse(storage.getString('routeData')\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n return true;\n } else {\n return false;\n }\n };\n\n const onError = () => {\n try {\n const loaded = loadFileFromStore();\n if (!loaded) {\n console.log('failed to load data');\n status = Status.Unavailable;\n }\n } catch (error) {\n console.log('erro while loading data');\n status = Status.Unavailable;\n localStorage.clearAll();\n }\n };\n\n try {\n const info = await fetchInfo();\n // @ts-ignore\n if (status === Status.DownloadingResources && info.URL) {\n // download\n console.log('downloading from server');\n try {\n // Fetch encrypted data from the server\n // This is the API call for getting map-objects.json\n const response = await fetch(info.URL);\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n const responseData = await response.json();\n // const responseData = JSON.parse(fileContent);\n const {data, tag} = responseData;\n\n const decryptedJson = await decryptFile(data, tag, serverAPIInfo.secretKey);\n const storedSuccessfully = storeFileToLocalStorage(\n data,\n info.remoteVersion,\n tag,\n );\n if (storedSuccessfully) {\n console.log('loaded file');\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n }\n } catch (error) {\n console.error('Error fetching and decrypting data:', error);\n onError();\n }\n } else {\n const tag = localStorage.getString('encryptionTag');\n // set to store\n if (info.data && tag) {\n console.log('loaded local file');\n const decryptedJson = decryptFile(info.data, tag, serverAPIInfo.secretKey);\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n } else {\n onError();\n }\n }\n } catch (error) {\n onError();\n }\n\n return status;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,IAAAC,QAAA,GAAAD,OAAA;AAAA,IAAAE,aAAA,GAAAH,sBA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GjB,uBAAuB,CAChDxB,IAAI,EACJmC,IAAI,CAACzB,aAAa,EAClBI,GACF,CAAC;QACD,IAAI2B,kBAAkB,EAAE;UACtBxB,OAAO,CAACC,GAAG,CAAC,aAAa,CAAC;UAC1BjC,mBAAmB,CAAC;YAACe,IAAI,EAAE2B;UAAa,CAAC,CAAC;UAC1C5C,MAAM,GAAGlB,MAAM,CAACiE,KAAK;QACvB;MACF,CAAC,CAAC,OAAOV,KAAK,EAAE;QACdH,OAAO,CAACG,KAAK,CAAC,qCAAqC,EAAEA,KAAK,CAAC;QAC3DW,OAAO,CAAC,CAAC;MACX;IACF,CAAC,MAAM;MACL,MAAMjB,GAAG,GAAGjC,YAAY,CAACQ,SAAS,CAAC,eAAe,CAAC;MACnD;MACA,IAAI8C,IAAI,CAACnC,IAAI,IAAIc,GAAG,EAAE;QACpBG,OAAO,CAACC,GAAG,CAAC,mBAAmB,CAAC;QAChC,MAAMS,aAAa,GAAG,IAAAC,oBAAW,EAACO,IAAI,CAACnC,IAAI,EAAEc,GAAG,EAAElC,aAAa,CAACiD,SAAS,CAAC;QAC1E5C,mBAAmB,CAAC;UAACe,IAAI,EAAE2B;QAAa,CAAC,CAAC;QAC1C5C,MAAM,GAAGlB,MAAM,CAACiE,KAAK;MACvB,CAAC,MAAM;QACLC,OAAO,CAAC,CAAC;MACX;IACF;EACF,CAAC,CAAC,OAAOX,KAAK,EAAE;IACdW,OAAO,CAAC,CAAC;EACX;EAEA,OAAOhD,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"fetch-published-json.js","names":["_axios","_interopRequireDefault","require","_helpers","_routingStore","_mapobjectsStore","e","__esModule","default","PublishedDataType","exports","Status","getDataType","publishedDataType","Routing","MapObjects","getLocalStorageKey","param","valueOf","setRouteData","useRouteDataStore","setState","setMapObjectsData","useMapObjectsDataStore","getRunTimeStore","getPublishedData","serverAPIInfo","localStorage","localStorageVersionKey","status","Awaiting","setRunTimeStoreData","fetchInfo","currentVersion","contains","getString","Promise","resolve","reject","axios","url","concat","URL","headers","Authorization","accessToken","method","data","JSON","stringify","version","dataType","then","response","remoteData","publishedDataInfo","undefined","remoteVersion","localVersion","hasOwnProperty","currentData","tag","downloadUrl","DownloadingResources","console","log","catch","error","request","message","config","storeFileToLocalStorage","set","loadFileFromStore","decryptedJson","decryptFile","secretKey","Ready","onError","loaded","Unavailable","clearAll","info","fetch","ok","Error","responseData","json","storedSuccessfully"],"sources":["../../../../src/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.ts"],"sourcesContent":["import axios from 'axios';\n\nimport { LocalStorage } from '../utils/local-storage';\nimport { decryptFile } from '../utils/helpers';\nimport useRouteDataStore from '../utils/routing-store';\nimport useMapObjectsDataStore from '../utils/mapobjects-store';\n\nexport enum PublishedDataType {\n Routing = 'routing',\n MapObjects = 'mapObjects',\n}\n\nexport enum Status {\n Ready = 'Ready',\n Awaiting = 'Awaiting',\n DownloadingResources = 'DownloadingResources',\n Unavailable = 'Unavailable',\n}\n\nexport type StatusUpdateCallbackType = (loaded: boolean) => void;\n\nexport interface ServerAPIInfo {\n URL: string;\n accessToken: string;\n secretKey: string;\n publishedDataType: PublishedDataType;\n}\n\nexport interface PublishedDataInfo {\n currentVersion: string | undefined;\n remoteVersion: string | undefined;\n URL: string | undefined;\n data: string | undefined;\n}\n\nfunction getDataType(publishedDataType: PublishedDataType) {\n if (publishedDataType === PublishedDataType.Routing) {\n return 'generate-route-json-per-role';\n }\n if (publishedDataType === PublishedDataType.MapObjects) {\n return 'generate-map-objects-per-role';\n }\n}\n\nfunction getLocalStorageKey(\n param: string,\n publishedDataType: PublishedDataType,\n): string {\n return publishedDataType.valueOf() + param;\n}\n\nconst setRouteData = useRouteDataStore.setState;\nconst setMapObjectsData = useMapObjectsDataStore.setState;\n\nfunction getRunTimeStore(publishedDataType: PublishedDataType) {\n if (publishedDataType === PublishedDataType.Routing) {\n return setRouteData;\n }\n if (publishedDataType === PublishedDataType.MapObjects) {\n return setMapObjectsData;\n }\n}\n\nexport async function getPublishedData(\n serverAPIInfo: ServerAPIInfo,\n localStorage: LocalStorage,\n) {\n const publishedDataType = serverAPIInfo.publishedDataType;\n const localStorageVersionKey = getLocalStorageKey(\n 'version',\n publishedDataType,\n );\n let status: Status = Status.Awaiting;\n let setRunTimeStoreData = getRunTimeStore(publishedDataType);\n\n const fetchInfo = async () => {\n const currentVersion = localStorage.contains(localStorageVersionKey)\n ? localStorage.getString(localStorageVersionKey)\n : '0.0.0';\n return new Promise(\n (resolve: (routingInfo: PublishedDataInfo) => void, reject) => {\n axios({\n url: `${serverAPIInfo.URL}/check-published-versions`,\n headers: {\n Authorization: `Bearer ${serverAPIInfo.accessToken}`,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n data: JSON.stringify({\n version: currentVersion,\n dataType: getDataType(serverAPIInfo.publishedDataType),\n }),\n })\n .then(response => {\n const remoteData = response.data;\n\n const publishedDataInfo = {\n currentVersion: undefined,\n remoteVersion: undefined,\n URL: undefined,\n data: undefined,\n } as PublishedDataInfo;\n const localVersion = localStorage.getString(localStorageVersionKey);\n let remoteVersion = localVersion;\n if (remoteData.hasOwnProperty('version')) {\n remoteVersion = remoteData.version;\n }\n\n publishedDataInfo.currentVersion = localVersion;\n publishedDataInfo.remoteVersion = remoteVersion;\n if (localVersion) {\n const currentData = localStorage.getString(\n getLocalStorageKey('data', publishedDataType),\n );\n const tag = localStorage.getString(\n getLocalStorageKey('encryptionTag', publishedDataType),\n );\n\n // Check both because data is useless without tag\n if (tag && currentData) {\n publishedDataInfo.data = currentData;\n }\n }\n if (remoteVersion) {\n if (remoteData.hasOwnProperty('downloadUrl')) {\n publishedDataInfo.URL = remoteData.downloadUrl;\n }\n if (\n (localVersion && remoteVersion > localVersion) ||\n !localVersion ||\n !publishedDataInfo.data\n ) {\n status = publishedDataInfo.URL\n ? Status.DownloadingResources\n : status;\n }\n }\n\n console.log(\n 'final: ',\n publishedDataInfo.URL,\n publishedDataInfo.currentVersion,\n publishedDataInfo.remoteVersion,\n );\n resolve(publishedDataInfo);\n })\n .catch(function (error) {\n console.log('error while fetching published version: ');\n if (error.response) {\n // The request was made and the server responded with a status code\n // that falls out of the range of 2xx\n console.log(error.response.data);\n console.log(error.response.status);\n console.log(error.response.headers);\n } else if (error.request) {\n // The request was made but no response was received\n // `error.request` is an instance of XMLHttpRequest in the browser and an instance of\n // http.ClientRequest in node.js\n console.log(error.request);\n } else {\n // Something happened in setting up the request that triggered an Error\n console.log('Error', error.message);\n }\n console.log(error.config);\n reject(error);\n });\n },\n );\n };\n\n const storeFileToLocalStorage = (data: any, version: any, tag: any) => {\n try {\n localStorage.set(getLocalStorageKey('data', publishedDataType), data);\n localStorage.set(localStorageVersionKey, version);\n localStorage.set(\n getLocalStorageKey('encryptionTag', publishedDataType),\n tag,\n );\n return true;\n } catch (e) {\n console.log('error storing routing file from local storage', e);\n return false;\n }\n };\n\n const loadFileFromStore = () => {\n const currentData = localStorage.getString(\n getLocalStorageKey('data', publishedDataType),\n );\n const tag = localStorage.getString(\n getLocalStorageKey('encryptionTag', publishedDataType),\n );\n if (currentData && tag) {\n const decryptedJson = decryptFile(currentData, tag, serverAPIInfo.secretKey);\n // JSON.parse(storage.getString('routeData')\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n return true;\n } else {\n return false;\n }\n };\n\n const onError = () => {\n try {\n const loaded = loadFileFromStore();\n if (!loaded) {\n console.log('failed to load data');\n status = Status.Unavailable;\n }\n } catch (error) {\n console.log('erro while loading data');\n status = Status.Unavailable;\n localStorage.clearAll();\n }\n };\n\n try {\n const info = await fetchInfo();\n // @ts-ignore\n if (status === Status.DownloadingResources && info.URL) {\n // download\n console.log('downloading from server');\n try {\n // Fetch encrypted data from the server\n // This is the API call for getting map-objects.json\n const response = await fetch(info.URL);\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n const responseData = await response.json();\n // const responseData = JSON.parse(fileContent);\n const {data, tag} = responseData;\n\n const decryptedJson = await decryptFile(data, tag, serverAPIInfo.secretKey);\n const storedSuccessfully = storeFileToLocalStorage(\n data,\n info.remoteVersion,\n tag,\n );\n if (storedSuccessfully) {\n console.log('loaded file');\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n }\n } catch (error) {\n console.error('Error fetching and decrypting data:', error);\n onError();\n }\n } else {\n const tag = localStorage.getString('encryptionTag');\n // set to store\n if (info.data && tag) {\n console.log('loaded local file');\n const decryptedJson = decryptFile(info.data, tag, serverAPIInfo.secretKey);\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n } else {\n onError();\n }\n }\n } catch (error) {\n onError();\n }\n\n return status;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,IAAAC,QAAA,GAAAD,OAAA;AAAA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAA,IAAAG,gBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAA,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAOdG,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAA,IAKjBE,MAAM,GAAAD,OAAA,CAAAC,MAAA,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAuBlB,SAASC,WAAWA,CAACC,iBAAoC,EAAE;EACzD,IAAIA,iBAAiB,KAAKJ,iBAAiB,CAACK,OAAO,EAAE;IACnD,OAAO,8BAA8B;EACvC;EACA,IAAID,iBAAiB,KAAKJ,iBAAiB,CAACM,UAAU,EAAE;IACtD,OAAO,+BAA+B;EACxC;AACF;AAEA,SAASC,kBAAkBA,CACzBC,KAAa,EACbJ,iBAAoC,EAC5B;EACR,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