@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.
Files changed (125) hide show
  1. package/lib/cjs/index.js +9 -9
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
  4. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  5. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +43 -45
  6. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  7. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +241 -271
  8. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  9. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
  10. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  11. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
  12. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  13. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +876 -1188
  14. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  15. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +173 -163
  16. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  17. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
  18. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
  19. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
  20. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  21. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
  22. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
  23. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +546 -620
  24. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  25. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +155 -160
  26. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  27. package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
  28. package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
  29. package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
  30. package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
  31. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
  32. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
  33. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +832 -1060
  34. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +33 -50
  36. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +18 -36
  38. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  39. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
  40. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
  41. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
  42. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
  43. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +428 -556
  44. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  45. package/lib/cjs/react/MetaAtlasMap.js +127 -0
  46. package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
  47. package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
  48. package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
  49. package/lib/cjs/react/hooks/useFocus/index.js +48 -55
  50. package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
  51. package/lib/cjs/react/hooks/useMapEvents/index.js +40 -50
  52. package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
  53. package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
  54. package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
  55. package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
  56. package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
  57. package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
  58. package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
  59. package/lib/cjs/react/hooks/useRouting/index.js +21 -20
  60. package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
  61. package/lib/cjs/react/hooks/useSearch/index.js +35 -34
  62. package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
  63. package/lib/cjs/react/hooks/useStampRally/index.js +30 -29
  64. package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
  65. package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
  66. package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
  67. package/lib/cjs/react/index.js +31 -31
  68. package/lib/cjs/react/index.js.map +1 -1
  69. package/lib/cjs/react/stores/useMapDataStore.js +53 -64
  70. package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
  71. package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
  72. package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
  73. package/lib/esm/index.js +3 -7
  74. package/lib/esm/index.js.map +1 -1
  75. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -1
  76. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  77. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +10 -9
  78. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  79. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +2 -2
  80. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  81. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  82. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  83. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
  84. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  85. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +22 -14
  86. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  87. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +8 -8
  88. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  89. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
  90. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  91. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +18 -11
  92. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  93. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +4 -3
  94. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  95. package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
  96. package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
  97. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +80 -61
  98. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  99. package/lib/esm/meta-atlas-sdk/utils/helpers.js +3 -1
  100. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  101. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +19 -15
  102. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  103. package/lib/esm/react/MetaAtlasMap.js +120 -0
  104. package/lib/esm/react/MetaAtlasMap.js.map +1 -0
  105. package/lib/esm/react/hooks/useDrawing/index.js +2 -2
  106. package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
  107. package/lib/esm/react/hooks/useFocus/index.js +4 -3
  108. package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
  109. package/lib/esm/react/hooks/useMapEvents/index.js +3 -3
  110. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  111. package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
  112. package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
  113. package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
  114. package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
  115. package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
  116. package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
  117. package/lib/esm/react/hooks/useRouting/index.js +2 -2
  118. package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
  119. package/lib/esm/react/hooks/useSearch/index.js +2 -2
  120. package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
  121. package/lib/esm/react/hooks/useStampRally/index.js +8 -7
  122. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  123. package/lib/esm/react/index.js +11 -15
  124. package/lib/esm/react/index.js.map +1 -1
  125. package/package.json +9 -6
@@ -3,295 +3,265 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
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 _interopRequireWildcard(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 (var _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
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
17
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
18
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
19
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
20
- 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; }
21
- 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; }
22
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
23
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
24
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
25
- 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; }
26
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
27
- 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); }
28
- var MainMap = exports["default"] = /*#__PURE__*/function () {
29
- function MainMap(metaAtlasCore) {
30
- var _this = this;
31
- _classCallCheck(this, MainMap);
32
- _defineProperty(this, "getAllPolygonCoordinates", function () {
33
- var map = _this.map;
34
- if (!map) return [];
35
- var polygonFeatures = [];
36
- var source = map.getSource('custom');
37
- if (source) {
38
- var features = map.querySourceFeatures('custom', {
39
- sourceLayer: 'geojson',
40
- filter: ['==', ['geometry-type'], 'Polygon']
41
- });
42
- if (features && features.length > 0) {
43
- features.forEach(function (feature) {
44
- if ((feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') && feature.properties.dimension_what === 'what.booth') {
45
- var _feature$properties;
46
- polygonFeatures.push({
47
- id: feature.properties.mapObjectId,
48
- name: ((_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.title) || 'Unnamed Polygon',
49
- coordinates: feature.geometry.coordinates,
50
- properties: _objectSpread(_objectSpread({}, feature.properties), {}, {
51
- hasImage: !!Math.round(Math.random())
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
- _defineProperty(this, "updatePolygons", function (features) {
61
- features.map(/*#__PURE__*/function () {
62
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(feature) {
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
- // Set properties to configure:
98
- myText.text = text;
99
- myText.textHeight = 100;
100
- // myText.textHeight = 1;
101
- // myText.backgroundColor = '';
102
- textPosition = (0, _utils.projectToWorld)(centroid);
103
- myText.rotation.x = Math.PI;
104
- myText.rotation.y = Math.PI;
105
- myText.scale.set(0.1, 0.1, 0.01);
106
- myText.position.set(textPosition.x, textPosition.y,
107
- // feature.properties.height > 0 ? 0.4 : 0.25
108
- 0.1);
109
- _this.threebox.add(myText);
110
- } else {
111
- // Load Texture
112
- // const textureLoader = new THREE.TextureLoader();
113
- // textureLoader.load('/sk.png', (texture: THREE.Texture) => {
114
- // // Create a plane geometry and material with the loaded texture
115
- // const geometry = new THREE.PlaneGeometry(
116
- // texture.image.width,
117
- // texture.image.height
118
- // );
119
- // geometry.computeBoundingBox();
120
- // const material = new THREE.MeshStandardMaterial({
121
- // map: texture,
122
- // transparent: true, // Enable transparency
123
- // opacity: 1,
124
- // });
125
- // const plane = new THREE.Mesh(geometry, material);
126
- // const group = new THREE.Group();
127
- // const childContainer = new THREE.Group();
128
- // childContainer.add(plane);
129
- // childContainer.rotateZ(Math.PI / 2);
130
- // childContainer.rotateZ(1);
131
- // childContainer.updateMatrixWorld();
132
- // group.add(childContainer);
133
- // const geojsonbbox = turf.bbox(polygon);
134
- // const bbox1 = new THREE.Box3(
135
- // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),
136
- // projectToWorld([geojsonbbox[0], geojsonbbox[1]])
137
- // );
138
- // const bbox2 = new THREE.Box3().setFromObject(plane);
139
- // const size1 = new THREE.Vector3();
140
- // bbox1.getSize(size1);
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
- // Define rectangle dimensions
172
- var width = 4;
173
- var height = 0;
174
- var depth = 2;
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
- // Create a box geometry instead of cylinder
177
- var geometry = new THREE.BoxGeometry(width, height, depth);
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
- // Create materials: [right, left, top, bottom, front, back]
180
- var sideMaterial = new THREE.MeshBasicMaterial({
181
- color: new THREE.Color(0xffffff)
182
- });
183
- var topMaterial = new THREE.MeshStandardMaterial({
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
- // Create an array of materials for each face of the box
190
- var materials = [sideMaterial,
191
- // right
192
- sideMaterial,
193
- // left
194
- topMaterial,
195
- // top (with logo texture)
196
- sideMaterial,
197
- // bottom
198
- sideMaterial,
199
- // front
200
- sideMaterial // back
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
- // Create the mesh with geometry and materials
204
- var logoMesh = new THREE.Mesh(geometry, materials);
199
+ // Define rectangle dimensions
200
+ const width = 4;
201
+ const height = 0;
202
+ const depth = 2;
205
203
 
206
- // Adjust rotation to match your previous orientation
207
- logoMesh.rotation.x = Math.PI / 2;
208
- logoMesh.rotation.y = -Math.PI / 1.45;
209
- logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);
210
- _this.threebox.add(logoMesh);
211
- return logoMesh;
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
- // Configure text properties
219
- textMesh.text = title;
220
- textMesh.fontSize = 0.2;
221
- textMesh.color = 0x000000;
222
- textMesh.anchorX = '50%';
223
- textMesh.anchorY = 'bottom-baseline';
224
- textMesh.fontWeight = 'bold';
225
- textMesh.textAlign = 'center';
226
- textMesh.position.set(position.x, position.y, position.z);
227
- textMesh.rotation.z = -Math.PI / 1.45;
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
- // Add text to the scene
230
- _this.threebox.add(textMesh);
231
+ // Create the mesh with geometry and materials
232
+ const logoMesh = new THREE.Mesh(geometry, materials);
231
233
 
232
- // Update the text rendering
233
- textMesh.sync();
234
- return textMesh;
235
- });
236
- if (MainMap.mainInstance) {
237
- return MainMap.mainInstance;
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
- * Creates a Threebox instance of the class.
251
- * @param map Maplibre instance to initialize threebox
252
- * @returns Threebox class instance created
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
- map.addLayer({
267
- id: '3d-model-layer',
268
- type: 'custom',
269
- renderingMode: '3d',
270
- onAdd: function onAdd() {
271
- console.log('onAdd _initThreebox');
272
- },
273
- render: function render() {
274
- wrapper.update();
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
- * Get the threebox instance for 3D model operations
283
- */
284
- }, {
285
- key: "getThreebox",
286
- value: function getThreebox() {
287
- return this.threebox;
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