@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.3
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/index.js +9 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +43 -45
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +241 -271
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +876 -1188
- 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 +173 -163
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +546 -620
- 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 +155 -160
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
- package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
- package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +832 -1060
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js +33 -50
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +18 -36
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +428 -556
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/cjs/react/MetaAtlasMap.js +127 -0
- package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
- package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
- package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/cjs/react/hooks/useFocus/index.js +48 -55
- package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapEvents/index.js +40 -50
- package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
- package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
- package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
- package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/cjs/react/hooks/useRouting/index.js +21 -20
- package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
- package/lib/cjs/react/hooks/useSearch/index.js +35 -34
- package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/index.js +30 -29
- package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
- package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/cjs/react/index.js +31 -31
- package/lib/cjs/react/index.js.map +1 -1
- package/lib/cjs/react/stores/useMapDataStore.js +53 -64
- package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
- package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
- package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
- package/lib/esm/index.js +3 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +10 -9
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +2 -2
- 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/fetchMapObjectsData.js +4 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +22 -14
- 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 +8 -8
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +18 -11
- 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 +4 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +80 -61
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js +3 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +19 -15
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/esm/react/MetaAtlasMap.js +120 -0
- package/lib/esm/react/MetaAtlasMap.js.map +1 -0
- package/lib/esm/react/hooks/useDrawing/index.js +2 -2
- package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/esm/react/hooks/useFocus/index.js +4 -3
- package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapEvents/index.js +3 -3
- package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
- package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/esm/react/hooks/useRouting/index.js +2 -2
- package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
- package/lib/esm/react/hooks/useSearch/index.js +2 -2
- package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/index.js +8 -7
- package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/esm/react/index.js +11 -15
- package/lib/esm/react/index.js.map +1 -1
- package/package.json +9 -6
|
@@ -3,295 +3,265 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
var _CustomThreeJsWrapper = _interopRequireDefault(require("./CustomThreeJsWrapper/CustomThreeJsWrapper"));
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _CustomThreeJsWrapper = _interopRequireDefault(require("./CustomThreeJsWrapper/CustomThreeJsWrapper.js"));
|
|
8
8
|
var _troikaThreeText = require("troika-three-text");
|
|
9
9
|
var turf = _interopRequireWildcard(require("@turf/turf"));
|
|
10
10
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
-
var _utils = require("./CustomThreeJsWrapper/utility/utils");
|
|
11
|
+
var _utils = require("./CustomThreeJsWrapper/utility/utils.js");
|
|
12
12
|
var _threeSpritetext = _interopRequireDefault(require("three-spritetext"));
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
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
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
class MainMap {
|
|
16
|
+
static mainInstance = null;
|
|
17
|
+
constructor(metaAtlasCore) {
|
|
18
|
+
if (MainMap.mainInstance) {
|
|
19
|
+
return MainMap.mainInstance;
|
|
20
|
+
}
|
|
21
|
+
MainMap.mainInstance = this;
|
|
22
|
+
this.metaAtlasCore = metaAtlasCore;
|
|
23
|
+
}
|
|
24
|
+
init(map2D) {
|
|
25
|
+
this.map = map2D;
|
|
26
|
+
this.initThreebox();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates a Threebox instance of the class.
|
|
31
|
+
* @param map Maplibre instance to initialize threebox
|
|
32
|
+
* @returns Threebox class instance created
|
|
33
|
+
*/
|
|
34
|
+
initThreebox() {
|
|
35
|
+
const map = this.map;
|
|
36
|
+
const wrapper = new _CustomThreeJsWrapper.default(map);
|
|
37
|
+
wrapper.setEnvironment();
|
|
38
|
+
// const hdrLoader = new HDRLoader();
|
|
39
|
+
// hdrLoader.load('./golden_gate_hills_1k.hdr', texture => {
|
|
40
|
+
// texture.mapping = EquirectangularReflectionMapping;
|
|
41
|
+
// wrapper.scene.environment = texture;
|
|
42
|
+
// });
|
|
43
|
+
|
|
44
|
+
map.addLayer({
|
|
45
|
+
id: '3d-model-layer',
|
|
46
|
+
type: 'custom',
|
|
47
|
+
renderingMode: '3d',
|
|
48
|
+
onAdd: () => {
|
|
49
|
+
console.log('onAdd _initThreebox');
|
|
50
|
+
},
|
|
51
|
+
render: () => {
|
|
52
|
+
wrapper.update();
|
|
57
53
|
}
|
|
58
|
-
return polygonFeatures;
|
|
59
54
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var coordinates, polygon, centroid, myText, text, textPosition;
|
|
64
|
-
return _regenerator().w(function (_context) {
|
|
65
|
-
while (1) switch (_context.n) {
|
|
66
|
-
case 0:
|
|
67
|
-
coordinates = feature.geometry.coordinates; // const centroid = feature.properties.center;
|
|
68
|
-
polygon = turf.polygon(coordinates);
|
|
69
|
-
centroid = turf.centroid(polygon).geometry.coordinates; // const modelPosition = projectToWorld(centroid);
|
|
70
|
-
// const vertex1 = projectToWorld(coordinates[0][0]);
|
|
71
|
-
// const vertex2 = projectToWorld(coordinates[0][1]);
|
|
72
|
-
// const angle = vertex1.angleTo(vertex2);
|
|
73
|
-
// console.log(angle);
|
|
74
|
-
// await modelLoader.loadModel({
|
|
75
|
-
// modelPath: feature.properties.modelPath,
|
|
76
|
-
// feature,
|
|
77
|
-
// wrapper: wrapper.current!,
|
|
78
|
-
// onProgress: (progress) => {
|
|
79
|
-
// setLoadingProgress((prev) => ({
|
|
80
|
-
// ...prev,
|
|
81
|
-
// [feature.properties.id]: progress,
|
|
82
|
-
// }));
|
|
83
|
-
// },
|
|
84
|
-
// onError: (error) => {
|
|
85
|
-
// console.error(
|
|
86
|
-
// `Failed to load model ${feature.properties.id}:`,
|
|
87
|
-
// error
|
|
88
|
-
// );
|
|
89
|
-
// },
|
|
90
|
-
// });
|
|
91
|
-
if (!feature.properties.hasImage && feature.properties.dimension_where && feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor') {
|
|
92
|
-
myText = new _threeSpritetext["default"]();
|
|
93
|
-
myText.color = 'black';
|
|
94
|
-
text = feature.properties.title;
|
|
95
|
-
text = _this.addNewLine(text);
|
|
55
|
+
this.threebox = wrapper;
|
|
56
|
+
return wrapper;
|
|
57
|
+
}
|
|
96
58
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// size1.setZ(1);
|
|
142
|
-
// const size2 = new THREE.Vector3();
|
|
143
|
-
// bbox2.getSize(size2);
|
|
144
|
-
// size2.setZ(1);
|
|
145
|
-
// const ratio = size1.divide(size2);
|
|
146
|
-
// const ratioCopy = ratio.clone().multiplyScalar(0.85);
|
|
147
|
-
// plane.scale.set(
|
|
148
|
-
// plane.scale.x * ratioCopy.x,
|
|
149
|
-
// plane.scale.y * ratioCopy.y,
|
|
150
|
-
// plane.scale.z * ratioCopy.z
|
|
151
|
-
// );
|
|
152
|
-
// // // Set the position of the plane to the centroid
|
|
153
|
-
// group.position.set(modelPosition.x, modelPosition.y, 0.11);
|
|
154
|
-
// this.threebox.add(group);
|
|
155
|
-
// });
|
|
156
|
-
}
|
|
157
|
-
case 1:
|
|
158
|
-
return _context.a(2);
|
|
159
|
-
}
|
|
160
|
-
}, _callee);
|
|
161
|
-
}));
|
|
162
|
-
return function (_x) {
|
|
163
|
-
return _ref.apply(this, arguments);
|
|
164
|
-
};
|
|
165
|
-
}());
|
|
166
|
-
});
|
|
167
|
-
_defineProperty(this, "addLogo", function (logo, position) {
|
|
168
|
-
var textureLoader = new THREE.TextureLoader();
|
|
169
|
-
var texture = textureLoader.load(logo);
|
|
59
|
+
/**
|
|
60
|
+
* Get the threebox instance for 3D model operations
|
|
61
|
+
*/
|
|
62
|
+
getThreebox() {
|
|
63
|
+
return this.threebox;
|
|
64
|
+
}
|
|
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
|
+
addNewLine(input) {
|
|
94
|
+
return input.replace(/ /g, '\r\n');
|
|
95
|
+
}
|
|
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);
|
|
170
103
|
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
104
|
+
// const vertex1 = projectToWorld(coordinates[0][0]);
|
|
105
|
+
// const vertex2 = projectToWorld(coordinates[0][1]);
|
|
106
|
+
// const angle = vertex1.angleTo(vertex2);
|
|
107
|
+
// console.log(angle);
|
|
175
108
|
|
|
176
|
-
//
|
|
177
|
-
|
|
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
|
+
// });
|
|
178
126
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
color
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
map: texture,
|
|
185
|
-
side: THREE.DoubleSide,
|
|
186
|
-
transparent: true
|
|
187
|
-
});
|
|
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);
|
|
188
132
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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);
|
|
202
198
|
|
|
203
|
-
|
|
204
|
-
|
|
199
|
+
// Define rectangle dimensions
|
|
200
|
+
const width = 4;
|
|
201
|
+
const height = 0;
|
|
202
|
+
const depth = 2;
|
|
205
203
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
|
212
215
|
});
|
|
213
|
-
// Function to add text using Troika Text library at a specified position
|
|
214
|
-
_defineProperty(this, "addTitle", function (title, position) {
|
|
215
|
-
// Create a new Text instance
|
|
216
|
-
var textMesh = new _troikaThreeText.Text();
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
+
];
|
|
228
230
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
// Create the mesh with geometry and materials
|
|
232
|
+
const logoMesh = new THREE.Mesh(geometry, materials);
|
|
231
233
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
MainMap.mainInstance = this;
|
|
240
|
-
this.metaAtlasCore = metaAtlasCore;
|
|
241
|
-
}
|
|
242
|
-
return _createClass(MainMap, [{
|
|
243
|
-
key: "init",
|
|
244
|
-
value: function init(map2D) {
|
|
245
|
-
this.map = map2D;
|
|
246
|
-
this.initThreebox();
|
|
247
|
-
}
|
|
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
|
+
};
|
|
248
241
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
*/
|
|
254
|
-
}, {
|
|
255
|
-
key: "initThreebox",
|
|
256
|
-
value: function initThreebox() {
|
|
257
|
-
var map = this.map;
|
|
258
|
-
var wrapper = new _CustomThreeJsWrapper["default"](map);
|
|
259
|
-
wrapper.setEnvironment();
|
|
260
|
-
// const hdrLoader = new HDRLoader();
|
|
261
|
-
// hdrLoader.load('./golden_gate_hills_1k.hdr', texture => {
|
|
262
|
-
// texture.mapping = EquirectangularReflectionMapping;
|
|
263
|
-
// wrapper.scene.environment = texture;
|
|
264
|
-
// });
|
|
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();
|
|
265
246
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
});
|
|
277
|
-
this.threebox = wrapper;
|
|
278
|
-
return wrapper;
|
|
279
|
-
}
|
|
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;
|
|
280
257
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
key: "addNewLine",
|
|
291
|
-
value: function addNewLine(input) {
|
|
292
|
-
return input.replace(/ /g, '\r\n');
|
|
293
|
-
}
|
|
294
|
-
}]);
|
|
295
|
-
}();
|
|
296
|
-
_defineProperty(MainMap, "mainInstance", null);
|
|
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
|
+
}
|
|
266
|
+
exports.default = MainMap;
|
|
297
267
|
//# sourceMappingURL=MainMap.js.map
|