@twinmatrix/spatialverse-sdk-web 0.0.3 → 0.0.4
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.
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -2
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +4 -3
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +202 -198
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +32 -29
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +10 -13
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +55 -68
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +12 -12
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +73 -69
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +6 -1
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +103 -103
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/cjs/react/MetaAtlasMap.js +4 -4
- package/lib/cjs/react/MetaAtlasMap.js.map +1 -1
- package/lib/cjs/react/hooks/useMapEvents/index.js +6 -3
- package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/index.js +7 -5
- package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/utils.js +1 -1
- package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/cjs/react/stores/useMapDataStore.js +17 -21
- package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -2
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +4 -3
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +202 -198
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +34 -31
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +10 -8
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +55 -68
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +12 -12
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +73 -68
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js +1 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +103 -101
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/esm/react/MetaAtlasMap.js +4 -4
- package/lib/esm/react/MetaAtlasMap.js.map +1 -1
- package/lib/esm/react/hooks/useMapEvents/index.js +6 -3
- package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/index.js +7 -5
- package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/esm/react/stores/useMapDataStore.js +17 -21
- package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
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); }
|
|
1
6
|
import CustomThreeJSWrapper from "./CustomThreeJsWrapper/CustomThreeJsWrapper.js";
|
|
2
7
|
import { Text } from 'troika-three-text';
|
|
3
8
|
import * as turf from '@turf/turf';
|
|
@@ -5,8 +10,203 @@ import * as THREE from 'three';
|
|
|
5
10
|
import { projectToWorld } from "./CustomThreeJsWrapper/utility/utils.js";
|
|
6
11
|
import SpriteText from 'three-spritetext';
|
|
7
12
|
export default class MainMap {
|
|
8
|
-
static mainInstance = null;
|
|
9
13
|
constructor(metaAtlasCore) {
|
|
14
|
+
_defineProperty(this, "getAllPolygonCoordinates", () => {
|
|
15
|
+
const map = this.map;
|
|
16
|
+
if (!map) return [];
|
|
17
|
+
const polygonFeatures = [];
|
|
18
|
+
const source = map.getSource('custom');
|
|
19
|
+
if (source) {
|
|
20
|
+
const features = map.querySourceFeatures('custom', {
|
|
21
|
+
sourceLayer: 'geojson',
|
|
22
|
+
filter: ['==', ['geometry-type'], 'Polygon']
|
|
23
|
+
});
|
|
24
|
+
if (features && features.length > 0) {
|
|
25
|
+
features.forEach(feature => {
|
|
26
|
+
if ((feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') && feature.properties.dimension_what === 'what.booth') {
|
|
27
|
+
var _feature$properties;
|
|
28
|
+
polygonFeatures.push({
|
|
29
|
+
id: feature.properties.mapObjectId,
|
|
30
|
+
name: ((_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.title) || 'Unnamed Polygon',
|
|
31
|
+
coordinates: feature.geometry.coordinates,
|
|
32
|
+
properties: _objectSpread(_objectSpread({}, feature.properties), {}, {
|
|
33
|
+
hasImage: !!Math.round(Math.random())
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return polygonFeatures;
|
|
41
|
+
});
|
|
42
|
+
_defineProperty(this, "updatePolygons", features => {
|
|
43
|
+
features.map(async feature => {
|
|
44
|
+
const coordinates = feature.geometry.coordinates;
|
|
45
|
+
// const centroid = feature.properties.center;
|
|
46
|
+
const polygon = turf.polygon(coordinates);
|
|
47
|
+
const centroid = turf.centroid(polygon).geometry.coordinates;
|
|
48
|
+
// const modelPosition = projectToWorld(centroid);
|
|
49
|
+
|
|
50
|
+
// const vertex1 = projectToWorld(coordinates[0][0]);
|
|
51
|
+
// const vertex2 = projectToWorld(coordinates[0][1]);
|
|
52
|
+
// const angle = vertex1.angleTo(vertex2);
|
|
53
|
+
// console.log(angle);
|
|
54
|
+
|
|
55
|
+
// await modelLoader.loadModel({
|
|
56
|
+
// modelPath: feature.properties.modelPath,
|
|
57
|
+
// feature,
|
|
58
|
+
// wrapper: wrapper.current!,
|
|
59
|
+
// onProgress: (progress) => {
|
|
60
|
+
// setLoadingProgress((prev) => ({
|
|
61
|
+
// ...prev,
|
|
62
|
+
// [feature.properties.id]: progress,
|
|
63
|
+
// }));
|
|
64
|
+
// },
|
|
65
|
+
// onError: (error) => {
|
|
66
|
+
// console.error(
|
|
67
|
+
// `Failed to load model ${feature.properties.id}:`,
|
|
68
|
+
// error
|
|
69
|
+
// );
|
|
70
|
+
// },
|
|
71
|
+
// });
|
|
72
|
+
|
|
73
|
+
if (!feature.properties.hasImage && feature.properties.dimension_where && feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor') {
|
|
74
|
+
const myText = new SpriteText();
|
|
75
|
+
myText.color = 'black';
|
|
76
|
+
let text = feature.properties.title;
|
|
77
|
+
text = this.addNewLine(text);
|
|
78
|
+
|
|
79
|
+
// Set properties to configure:
|
|
80
|
+
myText.text = text;
|
|
81
|
+
myText.textHeight = 100;
|
|
82
|
+
// myText.textHeight = 1;
|
|
83
|
+
// myText.backgroundColor = '';
|
|
84
|
+
const textPosition = projectToWorld(centroid);
|
|
85
|
+
myText.rotation.x = Math.PI;
|
|
86
|
+
myText.rotation.y = Math.PI;
|
|
87
|
+
myText.scale.set(0.1, 0.1, 0.01);
|
|
88
|
+
myText.position.set(textPosition.x, textPosition.y,
|
|
89
|
+
// feature.properties.height > 0 ? 0.4 : 0.25
|
|
90
|
+
0.1);
|
|
91
|
+
this.threebox.add(myText);
|
|
92
|
+
} else {
|
|
93
|
+
// Load Texture
|
|
94
|
+
// const textureLoader = new THREE.TextureLoader();
|
|
95
|
+
// textureLoader.load('/sk.png', (texture: THREE.Texture) => {
|
|
96
|
+
// // Create a plane geometry and material with the loaded texture
|
|
97
|
+
// const geometry = new THREE.PlaneGeometry(
|
|
98
|
+
// texture.image.width,
|
|
99
|
+
// texture.image.height
|
|
100
|
+
// );
|
|
101
|
+
// geometry.computeBoundingBox();
|
|
102
|
+
// const material = new THREE.MeshStandardMaterial({
|
|
103
|
+
// map: texture,
|
|
104
|
+
// transparent: true, // Enable transparency
|
|
105
|
+
// opacity: 1,
|
|
106
|
+
// });
|
|
107
|
+
// const plane = new THREE.Mesh(geometry, material);
|
|
108
|
+
// const group = new THREE.Group();
|
|
109
|
+
// const childContainer = new THREE.Group();
|
|
110
|
+
// childContainer.add(plane);
|
|
111
|
+
// childContainer.rotateZ(Math.PI / 2);
|
|
112
|
+
// childContainer.rotateZ(1);
|
|
113
|
+
// childContainer.updateMatrixWorld();
|
|
114
|
+
// group.add(childContainer);
|
|
115
|
+
// const geojsonbbox = turf.bbox(polygon);
|
|
116
|
+
// const bbox1 = new THREE.Box3(
|
|
117
|
+
// projectToWorld([geojsonbbox[2], geojsonbbox[3]]),
|
|
118
|
+
// projectToWorld([geojsonbbox[0], geojsonbbox[1]])
|
|
119
|
+
// );
|
|
120
|
+
// const bbox2 = new THREE.Box3().setFromObject(plane);
|
|
121
|
+
// const size1 = new THREE.Vector3();
|
|
122
|
+
// bbox1.getSize(size1);
|
|
123
|
+
// size1.setZ(1);
|
|
124
|
+
// const size2 = new THREE.Vector3();
|
|
125
|
+
// bbox2.getSize(size2);
|
|
126
|
+
// size2.setZ(1);
|
|
127
|
+
// const ratio = size1.divide(size2);
|
|
128
|
+
// const ratioCopy = ratio.clone().multiplyScalar(0.85);
|
|
129
|
+
// plane.scale.set(
|
|
130
|
+
// plane.scale.x * ratioCopy.x,
|
|
131
|
+
// plane.scale.y * ratioCopy.y,
|
|
132
|
+
// plane.scale.z * ratioCopy.z
|
|
133
|
+
// );
|
|
134
|
+
// // // Set the position of the plane to the centroid
|
|
135
|
+
// group.position.set(modelPosition.x, modelPosition.y, 0.11);
|
|
136
|
+
// this.threebox.add(group);
|
|
137
|
+
// });
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
_defineProperty(this, "addLogo", (logo, position) => {
|
|
142
|
+
const textureLoader = new THREE.TextureLoader();
|
|
143
|
+
const texture = textureLoader.load(logo);
|
|
144
|
+
|
|
145
|
+
// Define rectangle dimensions
|
|
146
|
+
const width = 4;
|
|
147
|
+
const height = 0;
|
|
148
|
+
const depth = 2;
|
|
149
|
+
|
|
150
|
+
// Create a box geometry instead of cylinder
|
|
151
|
+
const geometry = new THREE.BoxGeometry(width, height, depth);
|
|
152
|
+
|
|
153
|
+
// Create materials: [right, left, top, bottom, front, back]
|
|
154
|
+
const sideMaterial = new THREE.MeshBasicMaterial({
|
|
155
|
+
color: new THREE.Color(0xffffff)
|
|
156
|
+
});
|
|
157
|
+
const topMaterial = new THREE.MeshStandardMaterial({
|
|
158
|
+
map: texture,
|
|
159
|
+
side: THREE.DoubleSide,
|
|
160
|
+
transparent: true
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// Create an array of materials for each face of the box
|
|
164
|
+
const materials = [sideMaterial,
|
|
165
|
+
// right
|
|
166
|
+
sideMaterial,
|
|
167
|
+
// left
|
|
168
|
+
topMaterial,
|
|
169
|
+
// top (with logo texture)
|
|
170
|
+
sideMaterial,
|
|
171
|
+
// bottom
|
|
172
|
+
sideMaterial,
|
|
173
|
+
// front
|
|
174
|
+
sideMaterial // back
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
// Create the mesh with geometry and materials
|
|
178
|
+
const logoMesh = new THREE.Mesh(geometry, materials);
|
|
179
|
+
|
|
180
|
+
// Adjust rotation to match your previous orientation
|
|
181
|
+
logoMesh.rotation.x = Math.PI / 2;
|
|
182
|
+
logoMesh.rotation.y = -Math.PI / 1.45;
|
|
183
|
+
logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);
|
|
184
|
+
this.threebox.add(logoMesh);
|
|
185
|
+
return logoMesh;
|
|
186
|
+
});
|
|
187
|
+
// Function to add text using Troika Text library at a specified position
|
|
188
|
+
_defineProperty(this, "addTitle", (title, position) => {
|
|
189
|
+
// Create a new Text instance
|
|
190
|
+
const textMesh = new Text();
|
|
191
|
+
|
|
192
|
+
// Configure text properties
|
|
193
|
+
textMesh.text = title;
|
|
194
|
+
textMesh.fontSize = 0.2;
|
|
195
|
+
textMesh.color = 0x000000;
|
|
196
|
+
textMesh.anchorX = '50%';
|
|
197
|
+
textMesh.anchorY = 'bottom-baseline';
|
|
198
|
+
textMesh.fontWeight = 'bold';
|
|
199
|
+
textMesh.textAlign = 'center';
|
|
200
|
+
textMesh.position.set(position.x, position.y, position.z);
|
|
201
|
+
textMesh.rotation.z = -Math.PI / 1.45;
|
|
202
|
+
|
|
203
|
+
// Add text to the scene
|
|
204
|
+
this.threebox.add(textMesh);
|
|
205
|
+
|
|
206
|
+
// Update the text rendering
|
|
207
|
+
textMesh.sync();
|
|
208
|
+
return textMesh;
|
|
209
|
+
});
|
|
10
210
|
if (MainMap.mainInstance) {
|
|
11
211
|
return MainMap.mainInstance;
|
|
12
212
|
}
|
|
@@ -54,205 +254,9 @@ export default class MainMap {
|
|
|
54
254
|
getThreebox() {
|
|
55
255
|
return this.threebox;
|
|
56
256
|
}
|
|
57
|
-
getAllPolygonCoordinates = () => {
|
|
58
|
-
const map = this.map;
|
|
59
|
-
if (!map) return [];
|
|
60
|
-
const polygonFeatures = [];
|
|
61
|
-
const source = map.getSource('custom');
|
|
62
|
-
if (source) {
|
|
63
|
-
const features = map.querySourceFeatures('custom', {
|
|
64
|
-
sourceLayer: 'geojson',
|
|
65
|
-
filter: ['==', ['geometry-type'], 'Polygon']
|
|
66
|
-
});
|
|
67
|
-
if (features && features.length > 0) {
|
|
68
|
-
features.forEach(feature => {
|
|
69
|
-
if ((feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') && feature.properties.dimension_what === 'what.booth') {
|
|
70
|
-
polygonFeatures.push({
|
|
71
|
-
id: feature.properties.mapObjectId,
|
|
72
|
-
name: feature.properties?.title || 'Unnamed Polygon',
|
|
73
|
-
coordinates: feature.geometry.coordinates,
|
|
74
|
-
properties: {
|
|
75
|
-
...feature.properties,
|
|
76
|
-
hasImage: !!Math.round(Math.random())
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return polygonFeatures;
|
|
84
|
-
};
|
|
85
257
|
addNewLine(input) {
|
|
86
258
|
return input.replace(/ /g, '\r\n');
|
|
87
259
|
}
|
|
88
|
-
updatePolygons = features => {
|
|
89
|
-
features.map(async feature => {
|
|
90
|
-
const coordinates = feature.geometry.coordinates;
|
|
91
|
-
// const centroid = feature.properties.center;
|
|
92
|
-
const polygon = turf.polygon(coordinates);
|
|
93
|
-
const centroid = turf.centroid(polygon).geometry.coordinates;
|
|
94
|
-
// const modelPosition = projectToWorld(centroid);
|
|
95
|
-
|
|
96
|
-
// const vertex1 = projectToWorld(coordinates[0][0]);
|
|
97
|
-
// const vertex2 = projectToWorld(coordinates[0][1]);
|
|
98
|
-
// const angle = vertex1.angleTo(vertex2);
|
|
99
|
-
// console.log(angle);
|
|
100
|
-
|
|
101
|
-
// await modelLoader.loadModel({
|
|
102
|
-
// modelPath: feature.properties.modelPath,
|
|
103
|
-
// feature,
|
|
104
|
-
// wrapper: wrapper.current!,
|
|
105
|
-
// onProgress: (progress) => {
|
|
106
|
-
// setLoadingProgress((prev) => ({
|
|
107
|
-
// ...prev,
|
|
108
|
-
// [feature.properties.id]: progress,
|
|
109
|
-
// }));
|
|
110
|
-
// },
|
|
111
|
-
// onError: (error) => {
|
|
112
|
-
// console.error(
|
|
113
|
-
// `Failed to load model ${feature.properties.id}:`,
|
|
114
|
-
// error
|
|
115
|
-
// );
|
|
116
|
-
// },
|
|
117
|
-
// });
|
|
118
|
-
|
|
119
|
-
if (!feature.properties.hasImage && feature.properties.dimension_where && feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor') {
|
|
120
|
-
const myText = new SpriteText();
|
|
121
|
-
myText.color = 'black';
|
|
122
|
-
let text = feature.properties.title;
|
|
123
|
-
text = this.addNewLine(text);
|
|
124
|
-
|
|
125
|
-
// Set properties to configure:
|
|
126
|
-
myText.text = text;
|
|
127
|
-
myText.textHeight = 100;
|
|
128
|
-
// myText.textHeight = 1;
|
|
129
|
-
// myText.backgroundColor = '';
|
|
130
|
-
const textPosition = projectToWorld(centroid);
|
|
131
|
-
myText.rotation.x = Math.PI;
|
|
132
|
-
myText.rotation.y = Math.PI;
|
|
133
|
-
myText.scale.set(0.1, 0.1, 0.01);
|
|
134
|
-
myText.position.set(textPosition.x, textPosition.y,
|
|
135
|
-
// feature.properties.height > 0 ? 0.4 : 0.25
|
|
136
|
-
0.1);
|
|
137
|
-
this.threebox.add(myText);
|
|
138
|
-
} else {
|
|
139
|
-
// Load Texture
|
|
140
|
-
// const textureLoader = new THREE.TextureLoader();
|
|
141
|
-
// textureLoader.load('/sk.png', (texture: THREE.Texture) => {
|
|
142
|
-
// // Create a plane geometry and material with the loaded texture
|
|
143
|
-
// const geometry = new THREE.PlaneGeometry(
|
|
144
|
-
// texture.image.width,
|
|
145
|
-
// texture.image.height
|
|
146
|
-
// );
|
|
147
|
-
// geometry.computeBoundingBox();
|
|
148
|
-
// const material = new THREE.MeshStandardMaterial({
|
|
149
|
-
// map: texture,
|
|
150
|
-
// transparent: true, // Enable transparency
|
|
151
|
-
// opacity: 1,
|
|
152
|
-
// });
|
|
153
|
-
// const plane = new THREE.Mesh(geometry, material);
|
|
154
|
-
// const group = new THREE.Group();
|
|
155
|
-
// const childContainer = new THREE.Group();
|
|
156
|
-
// childContainer.add(plane);
|
|
157
|
-
// childContainer.rotateZ(Math.PI / 2);
|
|
158
|
-
// childContainer.rotateZ(1);
|
|
159
|
-
// childContainer.updateMatrixWorld();
|
|
160
|
-
// group.add(childContainer);
|
|
161
|
-
// const geojsonbbox = turf.bbox(polygon);
|
|
162
|
-
// const bbox1 = new THREE.Box3(
|
|
163
|
-
// projectToWorld([geojsonbbox[2], geojsonbbox[3]]),
|
|
164
|
-
// projectToWorld([geojsonbbox[0], geojsonbbox[1]])
|
|
165
|
-
// );
|
|
166
|
-
// const bbox2 = new THREE.Box3().setFromObject(plane);
|
|
167
|
-
// const size1 = new THREE.Vector3();
|
|
168
|
-
// bbox1.getSize(size1);
|
|
169
|
-
// size1.setZ(1);
|
|
170
|
-
// const size2 = new THREE.Vector3();
|
|
171
|
-
// bbox2.getSize(size2);
|
|
172
|
-
// size2.setZ(1);
|
|
173
|
-
// const ratio = size1.divide(size2);
|
|
174
|
-
// const ratioCopy = ratio.clone().multiplyScalar(0.85);
|
|
175
|
-
// plane.scale.set(
|
|
176
|
-
// plane.scale.x * ratioCopy.x,
|
|
177
|
-
// plane.scale.y * ratioCopy.y,
|
|
178
|
-
// plane.scale.z * ratioCopy.z
|
|
179
|
-
// );
|
|
180
|
-
// // // Set the position of the plane to the centroid
|
|
181
|
-
// group.position.set(modelPosition.x, modelPosition.y, 0.11);
|
|
182
|
-
// this.threebox.add(group);
|
|
183
|
-
// });
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
addLogo = (logo, position) => {
|
|
188
|
-
const textureLoader = new THREE.TextureLoader();
|
|
189
|
-
const texture = textureLoader.load(logo);
|
|
190
|
-
|
|
191
|
-
// Define rectangle dimensions
|
|
192
|
-
const width = 4;
|
|
193
|
-
const height = 0;
|
|
194
|
-
const depth = 2;
|
|
195
|
-
|
|
196
|
-
// Create a box geometry instead of cylinder
|
|
197
|
-
const geometry = new THREE.BoxGeometry(width, height, depth);
|
|
198
|
-
|
|
199
|
-
// Create materials: [right, left, top, bottom, front, back]
|
|
200
|
-
const sideMaterial = new THREE.MeshBasicMaterial({
|
|
201
|
-
color: new THREE.Color(0xffffff)
|
|
202
|
-
});
|
|
203
|
-
const topMaterial = new THREE.MeshStandardMaterial({
|
|
204
|
-
map: texture,
|
|
205
|
-
side: THREE.DoubleSide,
|
|
206
|
-
transparent: true
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// Create an array of materials for each face of the box
|
|
210
|
-
const materials = [sideMaterial,
|
|
211
|
-
// right
|
|
212
|
-
sideMaterial,
|
|
213
|
-
// left
|
|
214
|
-
topMaterial,
|
|
215
|
-
// top (with logo texture)
|
|
216
|
-
sideMaterial,
|
|
217
|
-
// bottom
|
|
218
|
-
sideMaterial,
|
|
219
|
-
// front
|
|
220
|
-
sideMaterial // back
|
|
221
|
-
];
|
|
222
|
-
|
|
223
|
-
// Create the mesh with geometry and materials
|
|
224
|
-
const logoMesh = new THREE.Mesh(geometry, materials);
|
|
225
|
-
|
|
226
|
-
// Adjust rotation to match your previous orientation
|
|
227
|
-
logoMesh.rotation.x = Math.PI / 2;
|
|
228
|
-
logoMesh.rotation.y = -Math.PI / 1.45;
|
|
229
|
-
logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);
|
|
230
|
-
this.threebox.add(logoMesh);
|
|
231
|
-
return logoMesh;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
// Function to add text using Troika Text library at a specified position
|
|
235
|
-
addTitle = (title, position) => {
|
|
236
|
-
// Create a new Text instance
|
|
237
|
-
const textMesh = new Text();
|
|
238
|
-
|
|
239
|
-
// Configure text properties
|
|
240
|
-
textMesh.text = title;
|
|
241
|
-
textMesh.fontSize = 0.2;
|
|
242
|
-
textMesh.color = 0x000000;
|
|
243
|
-
textMesh.anchorX = '50%';
|
|
244
|
-
textMesh.anchorY = 'bottom-baseline';
|
|
245
|
-
textMesh.fontWeight = 'bold';
|
|
246
|
-
textMesh.textAlign = 'center';
|
|
247
|
-
textMesh.position.set(position.x, position.y, position.z);
|
|
248
|
-
textMesh.rotation.z = -Math.PI / 1.45;
|
|
249
|
-
|
|
250
|
-
// Add text to the scene
|
|
251
|
-
this.threebox.add(textMesh);
|
|
252
|
-
|
|
253
|
-
// Update the text rendering
|
|
254
|
-
textMesh.sync();
|
|
255
|
-
return textMesh;
|
|
256
|
-
};
|
|
257
260
|
}
|
|
261
|
+
_defineProperty(MainMap, "mainInstance", null);
|
|
258
262
|
//# sourceMappingURL=MainMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MainMap.js","names":["CustomThreeJSWrapper","Text","turf","THREE","projectToWorld","SpriteText","MainMap","mainInstance","constructor","metaAtlasCore","init","map2D","map","initThreebox","wrapper","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","color","text","textHeight","textPosition","rotation","x","PI","y","scale","set","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","fontSize","anchorX","anchorY","fontWeight","textAlign","sync"],"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":"OAEOA,oBAAoB;AAC3B,SAASC,IAAI,QAAQ,mBAAmB;AAIxC,OAAO,KAAKC,IAAI,MAAM,YAAY;AAClC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAAC,SACtBC,cAAc;AACvB,OAAOC,UAAU,MAAM,kBAAkB;AAGzC,eAAe,MAAMC,OAAO,CAAC;EAC3B,OAAcC,YAAY,GAAmB,IAAI;EAKjDC,WAAWA,CAACC,aAA4B,EAAE;IACxC,IAAIH,OAAO,CAACC,YAAY,EAAE;MACxB,OAAOD,OAAO,CAACC,YAAY;IAC7B;IAEAD,OAAO,CAACC,YAAY,GAAG,IAAI;IAE3B,IAAI,CAACE,aAAa,GAAGA,aAAa;EACpC;EAEOC,IAAIA,CAACC,KAAkB,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ACAG,QAAQ,GAAGA,CAAChD,KAAa,EAAEwB,QAAuB,KAAK;IACrD;IACA,MAAMyB,QAAQ,GAAG,IAAI5F,IAAI,CAAC,CAAC;;IAE3B;IACA4F,QAAQ,CAAClC,IAAI,GAAGf,KAAK;IACrBiD,QAAQ,CAACC,QAAQ,GAAG,GAAG;IACvBD,QAAQ,CAACnC,KAAK,GAAG,QAAQ;IACzBmC,QAAQ,CAACE,OAAO,GAAG,KAAK;IACxBF,QAAQ,CAACG,OAAO,GAAG,iBAAiB;IACpCH,QAAQ,CAACI,UAAU,GAAG,MAAM;IAC5BJ,QAAQ,CAACK,SAAS,GAAG,QAAQ;IAE7BL,QAAQ,CAACzB,QAAQ,CAACD,GAAG,CAACC,QAAQ,CAACL,CAAC,EAAEK,QAAQ,CAACH,CAAC,EAAEG,QAAQ,CAACuB,CAAC,CAAC;IACzDE,QAAQ,CAAC/B,QAAQ,CAAC6B,CAAC,GAAG,CAAC5C,IAAI,CAACiB,EAAE,GAAG,IAAI;;IAErC;IACA,IAAI,CAACvC,QAAQ,CAAC4C,GAAG,CAACwB,QAAQ,CAAC;;IAE3B;IACAA,QAAQ,CAACM,IAAI,CAAC,CAAC;IAEf,OAAON,QAAQ;EACjB,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MainMap.js","names":["CustomThreeJSWrapper","Text","turf","THREE","projectToWorld","SpriteText","MainMap","constructor","metaAtlasCore","_defineProperty","map","polygonFeatures","source","getSource","features","querySourceFeatures","sourceLayer","filter","length","forEach","feature","geometry","type","properties","dimension_what","_feature$properties","push","id","mapObjectId","name","title","coordinates","_objectSpread","hasImage","Math","round","random","polygon","centroid","dimension_where","myText","color","text","addNewLine","textHeight","textPosition","rotation","x","PI","y","scale","set","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","fontSize","anchorX","anchorY","fontWeight","textAlign","sync","mainInstance","init","map2D","initThreebox","wrapper","setEnvironment","addLayer","renderingMode","onAdd","console","log","render","update","getThreebox","input","replace"],"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":";;;;;OAEOA,oBAAoB;AAC3B,SAASC,IAAI,QAAQ,mBAAmB;AAIxC,OAAO,KAAKC,IAAI,MAAM,YAAY;AAClC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAAC,SACtBC,cAAc;AACvB,OAAOC,UAAU,MAAM,kBAAkB;AAGzC,eAAe,MAAMC,OAAO,CAAC;EAM3BC,WAAWA,CAACC,aAA4B,EAAE;IAAAC,eAAA,mCAqDf,MAAM;MAC/B,MAA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AO7E,OAAO,CAAC6E,YAAY;IAC7B;IAEA7E,OAAO,CAAC6E,YAAY,GAAG,IAAI;IAE3B,IAAI,CAAC3E,aAAa,GAAGA,aAAa;EACpC;EAEO4E,IAAIA,CAACC,KAAkB,EAAE;IAC9B,IAAI,CAAC3E,GAAG,GAAG2E,KAAK;IAChB,IAAI,CAACC,YAAY,CAAC,CAAC;EACrB;;EAEA;AACF;AACA;AACA;AACA;EACUA,YAAYA,CAAA,EAAG;IACrB,MAAM5E,GAAG,GAAG,IAAI,CAACA,GAAG;IACpB,MAAM6E,OAAO,GAAG,IAAIvF,oBAAoB,CAACU,GAAG,CAAC;IAC7C6E,OAAO,CAACC,cAAc,CAAC,CAAC;IACxB;IACA;IACA;IACA;IACA;;IAEA9E,GAAG,CAAC+E,QAAQ,CAAC;MACX9D,EAAE,EAAE,gBAAgB;MACpBL,IAAI,EAAE,QAAQ;MACdoE,aAAa,EAAE,IAAI;MACnBC,KAAK,EAAEA,CAAA,KAAM;QACXC,OAAO,CAACC,GAAG,CAAC,qBAAqB,CAAC;MACpC,CAAC;MACDC,MAAM,EAAEA,CAAA,KAAM;QACZP,OAAO,CAACQ,MAAM,CAAC,CAAC;MAClB;IACF,CAAC,CAAC;IAEF,IAAI,CAAC1C,QAAQ,GAAGkC,OAAO;IACvB,OAAOA,OAAO;EAChB;;EAEA;AACF;AACA;EACES,WAAWA,CAAA,EAAG;IACZ,OAAO,IAAI,CAAC3C,QAAQ;EACtB;EAsCAV,UAAUA,CAACsD,KAAa,EAAU;IAChC,OAAOA,KAAK,CAACC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;EACpC;AAkLF;AAACzF,eAAA,CAnRoBH,OAAO,kBACmB,IAAI","ignoreList":[]}
|
|
@@ -44,9 +44,9 @@ export async function getPublishedData(serverAPIInfo, localStorage) {
|
|
|
44
44
|
const currentVersion = localStorage.contains(localStorageVersionKey) ? localStorage.getString(localStorageVersionKey) : '0.0.0';
|
|
45
45
|
return new Promise((resolve, reject) => {
|
|
46
46
|
axios({
|
|
47
|
-
url:
|
|
47
|
+
url: "".concat(serverAPIInfo.URL, "/check-published-versions"),
|
|
48
48
|
headers: {
|
|
49
|
-
Authorization:
|
|
49
|
+
Authorization: "Bearer ".concat(serverAPIInfo.accessToken),
|
|
50
50
|
'Content-Type': 'application/json'
|
|
51
51
|
},
|
|
52
52
|
method: 'POST',
|
|
@@ -160,7 +160,7 @@ export async function getPublishedData(serverAPIInfo, localStorage) {
|
|
|
160
160
|
// This is the API call for getting map-objects.json
|
|
161
161
|
const response = await fetch(info.URL);
|
|
162
162
|
if (!response.ok) {
|
|
163
|
-
throw new Error(
|
|
163
|
+
throw new Error("HTTP error! Status: ".concat(response.status));
|
|
164
164
|
}
|
|
165
165
|
const responseData = await response.json();
|
|
166
166
|
// const responseData = JSON.parse(fileContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-published-json.js","names":["axios","decryptFile","useRouteDataStore","useMapObjectsDataStore","PublishedDataType","Status","getDataType","publishedDataType","Routing","MapObjects","getLocalStorageKey","param","valueOf","setRouteData","setState","setMapObjectsData","getRunTimeStore","getPublishedData","serverAPIInfo","localStorage","localStorageVersionKey","status","Awaiting","setRunTimeStoreData","fetchInfo","currentVersion","contains","getString","Promise","resolve","reject","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","e","loadFileFromStore","decryptedJson","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,OAAOA,KAAK,MAAM,OAAO;AAAC,SAGjBC,W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C,CAAC;UAC1C5C,MAAM,GAAGhB,MAAM,CAAC8D,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,GAAGhC,YAAY,CAACQ,SAAS,CAAC,eAAe,CAAC;MACnD;MACA,IAAI6C,IAAI,CAACnC,IAAI,IAAIc,GAAG,EAAE;QACpBG,OAAO,CAACC,GAAG,CAAC,mBAAmB,CAAC;QAChC,MAAMU,aAAa,GAAGhE,WAAW,CAACuE,IAAI,CAACnC,IAAI,EAAEc,GAAG,EAAEjC,aAAa,CAACgD,SAAS,CAAC;QAC1E3C,mBAAmB,CAAC;UAACc,IAAI,EAAE4B;QAAa,CAAC,CAAC;QAC1C5C,MAAM,GAAGhB,MAAM,CAAC8D,KAAK;MACvB,CAAC,MAAM;QACLC,OAAO,CAAC,CAAC;MACX;IACF;EACF,CAAC,CAAC,OAAOX,KAAK,EAAE;IACdW,OAAO,CAAC,CAAC;EACX;EAEA,OAAO/C,MAAM;AACf","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"fetch-published-json.js","names":["axios","decryptFile","useRouteDataStore","useMapObjectsDataStore","PublishedDataType","Status","getDataType","publishedDataType","Routing","MapObjects","getLocalStorageKey","param","valueOf","setRouteData","setState","setMapObjectsData","getRunTimeStore","getPublishedData","serverAPIInfo","localStorage","localStorageVersionKey","status","Awaiting","setRunTimeStoreData","fetchInfo","currentVersion","contains","getString","Promise","resolve","reject","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","e","loadFileFromStore","decryptedJson","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,OAAOA,KAAK,MAAM,OAAO;AAAC,SAGjBC,WAAW;AAAA,OACbC,iBAAiB;AAAA,OACjBC,sBAAsB;AAE7B,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAK7B,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAuBlB,SAASC,WAAWA,CAACC,iBAAoC,EAAE;EACzD,IAAIA,iBAAiB,KAAKH,iBAAiB,CAACI,OAAO,EAAE;IACnD,OAAO,8BAA8B;EACvC;EACA,IAAID,iBAAiB,KAAKH,iBAAiB,CAACK,UAAU,EAAE;IACtD,OAAO,+BAA+B;EACxC;AACF;AAEA,SAASC,kBAAkBA,CACzBC,KAAa,EACbJ,iBAAoC,EAC5B;EACR,OAAOA,iBAAiB,CAACK,OAAO,CAAC,CAAC,GAAGD,KAAK;AAC5C;AAEA,MAAME,YAAY,GAAGX,iBAAiB,CAACY,QAAQ;AAC/C,MAAMC,iBAAiB,GAAGZ,sBAAsB,CAACW,QAAQ;AAEzD,SAASE,eAAeA,CAACT,iBAAoC,EAAE;EAC7D,IAAIA,iBAAiB,KAAKH,iBAAiB,CAACI,OAAO,EAAE;IACnD,OAAOK,YAAY;EACrB;EACA,IAAIN,iBAAiB,KAAKH,iBAAiB,CAACK,UAAU,EAAE;IACtD,OAAOM,iBAAiB;EAC1B;AACF;AAEA,OAAO,eAAeE,gBAAgBA,CACpCC,aAA4B,EAC5BC,YAA0B,EAC1B;EACA,MAAMZ,iBAAiB,GAAGW,aAAa,CAACX,iBAAiB;EACzD,MAAMa,sB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