@twinmatrix/spatialverse-sdk-web 0.0.2 → 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.
Files changed (143) 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 +40 -41
  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 +170 -196
  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 +861 -1170
  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 +166 -159
  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 +523 -610
  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 +149 -154
  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 +809 -1033
  34. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +32 -49
  36. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +21 -34
  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 +363 -491
  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 -47
  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 +26 -23
  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 +47 -62
  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 +4 -3
  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 +14 -12
  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 +204 -200
  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 +6 -6
  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 +53 -42
  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 +18 -16
  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 +73 -79
  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 +16 -15
  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 +148 -124
  98. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  99. package/lib/esm/meta-atlas-sdk/utils/helpers.js +4 -2
  100. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  101. package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
  102. package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  103. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +115 -109
  104. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  105. package/lib/esm/react/MetaAtlasMap.js +120 -0
  106. package/lib/esm/react/MetaAtlasMap.js.map +1 -0
  107. package/lib/esm/react/hooks/useDrawing/index.js +2 -2
  108. package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
  109. package/lib/esm/react/hooks/useFocus/index.js +4 -3
  110. package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
  111. package/lib/esm/react/hooks/useMapEvents/index.js +9 -6
  112. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  113. package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
  114. package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
  115. package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
  116. package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
  117. package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
  118. package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
  119. package/lib/esm/react/hooks/useRouting/index.js +2 -2
  120. package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
  121. package/lib/esm/react/hooks/useSearch/index.js +2 -2
  122. package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
  123. package/lib/esm/react/hooks/useStampRally/index.js +15 -12
  124. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  125. package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
  126. package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
  127. package/lib/esm/react/index.js +11 -15
  128. package/lib/esm/react/index.js.map +1 -1
  129. package/lib/esm/react/stores/useMapDataStore.js +17 -21
  130. package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
  131. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
  132. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
  133. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
  134. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
  135. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
  136. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
  137. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
  138. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
  139. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
  140. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
  141. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
  142. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
  143. package/package.json +10 -7
package/lib/cjs/index.js CHANGED
@@ -8,32 +8,32 @@ var _exportNames = {
8
8
  };
9
9
  Object.defineProperty(exports, "ManeuverType", {
10
10
  enumerable: true,
11
- get: function get() {
11
+ get: function () {
12
12
  return _routingHelpers.ManeuverType;
13
13
  }
14
14
  });
15
- var _metaAtlasSdk = require("./meta-atlas-sdk/meta-atlas-sdk");
15
+ var _metaAtlasSdk = require("./meta-atlas-sdk/meta-atlas-sdk.js");
16
16
  Object.keys(_metaAtlasSdk).forEach(function (key) {
17
17
  if (key === "default" || key === "__esModule") return;
18
18
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
19
  if (key in exports && exports[key] === _metaAtlasSdk[key]) return;
20
20
  Object.defineProperty(exports, key, {
21
21
  enumerable: true,
22
- get: function get() {
22
+ get: function () {
23
23
  return _metaAtlasSdk[key];
24
24
  }
25
25
  });
26
26
  });
27
- var _routingHelpers = require("./meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers");
28
- var _react = require("./react");
29
- Object.keys(_react).forEach(function (key) {
27
+ var _routingHelpers = require("./meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js");
28
+ var _index = require("./react/index.js");
29
+ Object.keys(_index).forEach(function (key) {
30
30
  if (key === "default" || key === "__esModule") return;
31
31
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
- if (key in exports && exports[key] === _react[key]) return;
32
+ if (key in exports && exports[key] === _index[key]) return;
33
33
  Object.defineProperty(exports, key, {
34
34
  enumerable: true,
35
- get: function get() {
36
- return _react[key];
35
+ get: function () {
36
+ return _index[key];
37
37
  }
38
38
  });
39
39
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_metaAtlasSdk","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_routingHelpers","_react"],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * `js` appendix has been added as the typesciript compilation does add it\n * when transpilling to JavaScript\n *\n * See https://stackoverflow.com/questions/44979976/typescript-compiler-is-forgetting-to-add-file-extensions-to-es6-module-imports\n * and https://github.com/microsoft/TypeScript/issues/40878\n *\n * Rollup\n * https://www.mixmax.com/engineering/rollup-externals\n * https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module\n */\n\n// Vanilla exports (existing)\nexport * from './meta-atlas-sdk/meta-atlas-sdk';\n\n// Core types that need to be re-exported\nexport type { metaFeature, clickedMetaFeature, MetaFeatureProperties } from './meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core';\n\n// Routing types\nexport { ManeuverType } from './meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers';\nexport type { Route, RouteSegment } from './meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers';\n\n// React exports (new)\nexport * from './react';\n"],"mappings":";;;;;;;;;;;;;;AAaA,IAAAA,aAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,aAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,aAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAb,aAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAMA,IAAAS,eAAA,GAAAb,OAAA;AAIA,IAAAc,MAAA,GAAAd,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAY,MAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,MAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,MAAA,CAAAV,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * `js` appendix has been added as the typesciript compilation does add it\n * when transpilling to JavaScript\n *\n * See https://stackoverflow.com/questions/44979976/typescript-compiler-is-forgetting-to-add-file-extensions-to-es6-module-imports\n * and https://github.com/microsoft/TypeScript/issues/40878\n *\n * Rollup\n * https://www.mixmax.com/engineering/rollup-externals\n * https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module\n */\n\n// Vanilla exports (existing)\nexport * from './meta-atlas-sdk/meta-atlas-sdk';\n\n// Core types that need to be re-exported\nexport type { metaFeature, clickedMetaFeature, MetaFeatureProperties } from './meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core';\n\n// Routing types\nexport { ManeuverType } from './meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers';\nexport type { Route, RouteSegment } from './meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers';\n\n// React exports (new)\nexport * from './react';\n"],"mappings":"","ignoreList":[]}
@@ -3,29 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.default = void 0;
7
7
  var _three = require("three");
8
8
  var _constants = _interopRequireDefault(require("./utility/constants.js"));
9
9
  var _CameraSync = _interopRequireDefault(require("./utility/CameraSync.js"));
10
10
  var _utils = require("./utility/utils.js");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
- 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); }
13
- 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 }; })(); }
14
- 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); }
15
- 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); }
16
- 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); }); }; }
17
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
18
- 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); } }
19
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
20
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
21
- 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); }
22
- var CustomThreeJSWrapper = /*#__PURE__*/function () {
23
- function CustomThreeJSWrapper(map) {
24
- _classCallCheck(this, CustomThreeJSWrapper);
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ class CustomThreeJSWrapper {
13
+ constructor(map) {
25
14
  this.scene = new _three.Scene();
26
15
  this.map = map;
27
- var c = map === null || map === void 0 ? void 0 : map.getCanvas();
28
- var gl = (c === null || c === void 0 ? void 0 : c.getContext('webgl')) || (c === null || c === void 0 ? void 0 : c.getContext('webgl2'));
16
+ const c = map === null || map === void 0 ? void 0 : map.getCanvas();
17
+ const gl = (c === null || c === void 0 ? void 0 : c.getContext('webgl')) || (c === null || c === void 0 ? void 0 : c.getContext('webgl2'));
29
18
  if (!gl && !this.isWebglSupported()) {
30
19
  console.error(map.getCanvas(), 'WebGL 2 is not supported in this environment');
31
20
  return;
@@ -44,310 +33,240 @@ var CustomThreeJSWrapper = /*#__PURE__*/function () {
44
33
  this.renderer.autoClear = false;
45
34
  this.renderer.toneMapping = _three.ACESFilmicToneMapping;
46
35
  this.renderer.outputColorSpace = _three.SRGBColorSpace;
47
- this.fov = _constants["default"].FOV_DEGREES;
48
- var h = this.map.getCanvas().clientHeight;
49
- var w = this.map.getCanvas().clientWidth;
36
+ this.fov = _constants.default.FOV_DEGREES;
37
+ const h = this.map.getCanvas().clientHeight;
38
+ const w = this.map.getCanvas().clientWidth;
50
39
  this.camera = new _three.PerspectiveCamera(this.fov, w / h, 0.1, 1000);
51
- this.cameraSync = new _CameraSync["default"](map, this.camera, this.scene);
40
+ this.cameraSync = new _CameraSync.default(map, this.camera, this.scene);
52
41
  }
53
- return _createClass(CustomThreeJSWrapper, [{
54
- key: "resize",
55
- value: function resize() {
56
- var w = this.map.getCanvas().clientWidth;
57
- var h = this.map.getCanvas().clientHeight;
58
- this.camera.aspect = w / h;
59
- this.camera.updateProjectionMatrix();
60
- this.renderer.setSize(w, h);
61
- }
62
- }, {
63
- key: "isWebglSupported",
64
- value: function isWebglSupported() {
65
- if (window.WebGLRenderingContext) {
66
- var canvas = document.createElement('canvas');
67
- try {
68
- // Note that { failIfMajorPerformanceCaveat: true } can be passed as a second argument
69
- // to canvas.getContext(), causing the check to fail if hardware rendering is not available. See
70
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
71
- // for more details.
72
- var context = canvas.getContext('webgl2') || canvas.getContext('webgl');
73
- if (context && typeof context.getParameter == 'function') {
74
- return true;
75
- }
76
- } catch (e) {
77
- // WebGL is supported, but disabled
42
+ resize() {
43
+ const w = this.map.getCanvas().clientWidth;
44
+ const h = this.map.getCanvas().clientHeight;
45
+ this.camera.aspect = w / h;
46
+ this.camera.updateProjectionMatrix();
47
+ this.renderer.setSize(w, h);
48
+ }
49
+ isWebglSupported() {
50
+ if (window.WebGLRenderingContext) {
51
+ const canvas = document.createElement('canvas');
52
+ try {
53
+ // Note that { failIfMajorPerformanceCaveat: true } can be passed as a second argument
54
+ // to canvas.getContext(), causing the check to fail if hardware rendering is not available. See
55
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
56
+ // for more details.
57
+ const context = canvas.getContext('webgl2') || canvas.getContext('webgl');
58
+ if (context && typeof context.getParameter == 'function') {
59
+ return true;
78
60
  }
79
- return false;
61
+ } catch (e) {
62
+ // WebGL is supported, but disabled
80
63
  }
81
- // WebGL not supported
82
64
  return false;
83
65
  }
84
- }, {
85
- key: "repaint",
86
- value: function repaint() {
87
- this.map.repaint = true;
88
- }
89
- }, {
90
- key: "clear",
91
- value: function () {
92
- var _clear = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
93
- var _this = this;
94
- var layerId,
95
- _args = arguments;
96
- return _regenerator().w(function (_context) {
97
- while (1) switch (_context.n) {
98
- case 0:
99
- layerId = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
100
- return _context.a(2, new Promise(function (resolve, reject) {
101
- var objects = [];
102
- _this.scene.children.forEach(function (object) {
103
- objects.push(object);
104
- });
105
- for (var i = 0; i < objects.length; i++) {
106
- var obj = objects[i];
107
- //if layerId, check the layer to remove, otherwise always remove
108
- if (obj.layers === layerId || !layerId) {
109
- _this.remove(obj);
110
- }
111
- }
112
- resolve('clear');
113
- }));
114
- }
115
- }, _callee);
116
- }));
117
- function clear() {
118
- return _clear.apply(this, arguments);
66
+ // WebGL not supported
67
+ return false;
68
+ }
69
+ repaint() {
70
+ this.map.repaint = true;
71
+ }
72
+ async clear() {
73
+ let layerId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
74
+ return new Promise((resolve, reject) => {
75
+ const objects = [];
76
+ this.scene.children.forEach(function (object) {
77
+ objects.push(object);
78
+ });
79
+ for (let i = 0; i < objects.length; i++) {
80
+ const obj = objects[i];
81
+ //if layerId, check the layer to remove, otherwise always remove
82
+ if (obj.layers === layerId || !layerId) {
83
+ this.remove(obj);
84
+ }
119
85
  }
120
- return clear;
121
- }()
122
- }, {
123
- key: "clearMeshes",
124
- value: function () {
125
- var _clearMeshes = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
126
- var _this2 = this;
127
- return _regenerator().w(function (_context2) {
128
- while (1) switch (_context2.n) {
129
- case 0:
130
- return _context2.a(2, new Promise(function (resolve, reject) {
131
- var objects = [];
132
- _this2.scene.children.forEach(function (object) {
133
- if (object.type === 'Mesh') objects.push(object);
134
- });
135
- console.log('Mesh Objects:', objects);
136
- for (var i = 0; i < objects.length; i++) {
137
- _this2.remove(objects[i]);
138
- }
139
- resolve('clear');
140
- }));
141
- }
142
- }, _callee2);
143
- }));
144
- function clearMeshes() {
145
- return _clearMeshes.apply(this, arguments);
86
+ resolve('clear');
87
+ });
88
+ }
89
+ async clearMeshes() {
90
+ return new Promise((resolve, reject) => {
91
+ const objects = [];
92
+ this.scene.children.forEach(function (object) {
93
+ if (object.type === 'Mesh') objects.push(object);
94
+ });
95
+ console.log('Mesh Objects:', objects);
96
+ for (let i = 0; i < objects.length; i++) {
97
+ this.remove(objects[i]);
146
98
  }
147
- return clearMeshes;
148
- }()
149
- }, {
150
- key: "filter3DObjects",
151
- value: function filter3DObjects(whatTaxonomies) {
152
- if (!Array.isArray(whatTaxonomies)) return;
153
- if (whatTaxonomies.length === 0) {
154
- this.scene.children.forEach(function (object) {
155
- object.visible = true;
156
- });
157
- } else {
158
- this.scene.children.forEach(function (object) {
159
- if (object.type === 'Mesh') {
160
- if (whatTaxonomies.includes(object.userData.whatDimension)) {
161
- object.visible = false;
162
- } else {
163
- object.visible = true;
164
- }
99
+ resolve('clear');
100
+ });
101
+ }
102
+ filter3DObjects(whatTaxonomies) {
103
+ if (!Array.isArray(whatTaxonomies)) return;
104
+ if (whatTaxonomies.length === 0) {
105
+ this.scene.children.forEach(function (object) {
106
+ object.visible = true;
107
+ });
108
+ } else {
109
+ this.scene.children.forEach(function (object) {
110
+ if (object.type === 'Mesh') {
111
+ if (whatTaxonomies.includes(object.userData.whatDimension)) {
112
+ object.visible = false;
113
+ } else {
114
+ object.visible = true;
165
115
  }
166
- });
167
- }
168
- }
169
- }, {
170
- key: "add",
171
- value: function add(object) {
172
- this.scene.add(object);
173
- }
174
- }, {
175
- key: "setEnvironment",
176
- value: function setEnvironment() {
177
- var dirLight = new _three.DirectionalLight(0xffffff, 2);
178
- dirLight.position.set(10, 10, 10);
179
- dirLight.castShadow = true;
180
- var hemiLight = new _three.HemisphereLight('white', 'white', 1.5);
181
- var ambientLight = new _three.AmbientLight('white', 1);
182
- this.scene.add(dirLight);
183
- this.scene.add(hemiLight);
184
- this.scene.add(ambientLight);
185
- }
186
- }, {
187
- key: "buildPoints",
188
- value: function buildPoints(coords, initCoords) {
189
- var points = [];
190
- var init = (0, _utils.projectToWorld)([initCoords[0][0], initCoords[0][1], 0]);
191
- for (var i = 0; i < coords.length; i++) {
192
- var pos = (0, _utils.projectToWorld)([coords[i][0], coords[i][1], 0]);
193
- points.push(new _three.Vector2((0, _utils.toDecimal)(pos.x - init.x, 9), (0, _utils.toDecimal)(pos.y - init.y, 9)));
194
- }
195
- return points;
116
+ }
117
+ });
196
118
  }
197
- }, {
198
- key: "buildGeometry",
199
- value: function buildGeometry(shape, settings) {
200
- var geometry = new _three.ExtrudeGeometry(shape, settings);
201
- geometry.computeBoundingBox();
202
- return geometry;
119
+ }
120
+ add(object) {
121
+ this.scene.add(object);
122
+ }
123
+ setEnvironment() {
124
+ const dirLight = new _three.DirectionalLight(0xffffff, 2);
125
+ dirLight.position.set(10, 10, 10);
126
+ dirLight.castShadow = true;
127
+ const hemiLight = new _three.HemisphereLight('white', 'white', 1.5);
128
+ const ambientLight = new _three.AmbientLight('white', 1);
129
+ this.scene.add(dirLight);
130
+ this.scene.add(hemiLight);
131
+ this.scene.add(ambientLight);
132
+ }
133
+ buildPoints(coords, initCoords) {
134
+ const points = [];
135
+ const init = (0, _utils.projectToWorld)([initCoords[0][0], initCoords[0][1], 0]);
136
+ for (let i = 0; i < coords.length; i++) {
137
+ const pos = (0, _utils.projectToWorld)([coords[i][0], coords[i][1], 0]);
138
+ points.push(new _three.Vector2((0, _utils.toDecimal)(pos.x - init.x, 9), (0, _utils.toDecimal)(pos.y - init.y, 9)));
203
139
  }
204
- }, {
205
- key: "buildShape",
206
- value: function buildShape(coords) {
207
- if (coords[0] instanceof (_three.Vector2 || _three.Vector3)) return new _three.Shape(coords);
208
- var shape = new _three.Shape();
209
- for (var i = 0; i < coords.length; i++) {
210
- if (i === 0) {
211
- shape = new _three.Shape(this.buildPoints(coords[0], coords[0]));
212
- } else {
213
- shape.holes.push(new _three.Path(this.buildPoints(coords[i], coords[0])));
214
- }
140
+ return points;
141
+ }
142
+ buildGeometry(shape, settings) {
143
+ const geometry = new _three.ExtrudeGeometry(shape, settings);
144
+ geometry.computeBoundingBox();
145
+ return geometry;
146
+ }
147
+ buildShape(coords) {
148
+ if (coords[0] instanceof (_three.Vector2 || _three.Vector3)) return new _three.Shape(coords);
149
+ let shape = new _three.Shape();
150
+ for (let i = 0; i < coords.length; i++) {
151
+ if (i === 0) {
152
+ shape = new _three.Shape(this.buildPoints(coords[0], coords[0]));
153
+ } else {
154
+ shape.holes.push(new _three.Path(this.buildPoints(coords[i], coords[0])));
215
155
  }
216
- return shape;
217
156
  }
218
- }, {
219
- key: "extrusion",
220
- value: function extrusion(opt) {
221
- var shape = this.buildShape(opt.coordinates);
222
- var geometry = this.buildGeometry(shape, opt.geometryOptions);
223
- var mesh = new _three.Mesh(geometry, opt.materials);
224
- if (!opt.visible) mesh.visible = false;
225
- return mesh;
226
- }
227
- }, {
228
- key: "centerMesh",
229
- value: function centerMesh(mesh) {
230
- // Compute the bounding box
231
- var bbox = new _three.Box3();
232
- mesh.geometry.computeBoundingBox();
233
- bbox.copy(mesh.geometry.boundingBox).applyMatrix4(mesh.matrixWorld);
157
+ return shape;
158
+ }
159
+ extrusion(opt) {
160
+ const shape = this.buildShape(opt.coordinates);
161
+ const geometry = this.buildGeometry(shape, opt.geometryOptions);
162
+ const mesh = new _three.Mesh(geometry, opt.materials);
163
+ if (!opt.visible) mesh.visible = false;
164
+ return mesh;
165
+ }
166
+ centerMesh(mesh) {
167
+ // Compute the bounding box
168
+ const bbox = new _three.Box3();
169
+ mesh.geometry.computeBoundingBox();
170
+ bbox.copy(mesh.geometry.boundingBox).applyMatrix4(mesh.matrixWorld);
234
171
 
235
- // Get the center of the bounding box
236
- var center = new _three.Vector3();
237
- bbox.getCenter(center);
172
+ // Get the center of the bounding box
173
+ let center = new _three.Vector3();
174
+ bbox.getCenter(center);
238
175
 
239
- // Create a dummy object
240
- var dummy = new _three.Object3D();
176
+ // Create a dummy object
177
+ const dummy = new _three.Object3D();
241
178
 
242
- // Attach mesh to dummy
243
- dummy.add(mesh);
244
- center = mesh.localToWorld(center);
245
- // const geometry = new BoxGeometry( 0.25, 0.25, 0.25 );
246
- // const material = new MeshBasicMaterial( {color: 0xff0000} );
247
- // const cube = new Mesh( geometry, material );
248
- // cube.position.set(center.x, center.y, center.z);
249
- // this.add( cube );
250
- // // Move the mesh within the dummy
251
- var diff = mesh.position.clone().sub(center);
252
- mesh.geometry.translate(diff.x, diff.y, 0);
253
- return dummy; // Return the new parent object
254
- }
255
- }, {
256
- key: "dispose",
257
- value: function dispose(target) {
258
- if (target instanceof _three.Mesh) {
259
- // If the target is a Mesh
260
- // Dispose materials and geometry of the mesh
261
- if (target.material) {
262
- if (typeof target.material.dispose === 'function' && !target.material._isDisposed) {
263
- target.material.dispose();
264
- target.material._isDisposed = true;
265
- }
266
- target.material = null;
179
+ // Attach mesh to dummy
180
+ dummy.add(mesh);
181
+ center = mesh.localToWorld(center);
182
+ // const geometry = new BoxGeometry( 0.25, 0.25, 0.25 );
183
+ // const material = new MeshBasicMaterial( {color: 0xff0000} );
184
+ // const cube = new Mesh( geometry, material );
185
+ // cube.position.set(center.x, center.y, center.z);
186
+ // this.add( cube );
187
+ // // Move the mesh within the dummy
188
+ const diff = mesh.position.clone().sub(center);
189
+ mesh.geometry.translate(diff.x, diff.y, 0);
190
+ return dummy; // Return the new parent object
191
+ }
192
+ dispose(target) {
193
+ if (target instanceof _three.Mesh) {
194
+ // If the target is a Mesh
195
+ // Dispose materials and geometry of the mesh
196
+ if (target.material) {
197
+ if (typeof target.material.dispose === 'function' && !target.material._isDisposed) {
198
+ target.material.dispose();
199
+ target.material._isDisposed = true;
267
200
  }
268
- if (target.geometry) {
269
- if (typeof target.geometry.dispose === 'function' && !target.geometry._isDisposed) {
270
- target.geometry.dispose();
271
- target.geometry._isDisposed = true;
272
- }
273
- target.geometry = null;
201
+ target.material = null;
202
+ }
203
+ if (target.geometry) {
204
+ if (typeof target.geometry.dispose === 'function' && !target.geometry._isDisposed) {
205
+ target.geometry.dispose();
206
+ target.geometry._isDisposed = true;
274
207
  }
275
- } else if (target instanceof _three.Object3D) {
276
- // If the target is an Object3D
277
- target.removeFromParent();
278
- this.disposeObject(target);
208
+ target.geometry = null;
279
209
  }
210
+ } else if (target instanceof _three.Object3D) {
211
+ // If the target is an Object3D
212
+ target.removeFromParent();
213
+ this.disposeObject(target);
280
214
  }
281
- }, {
282
- key: "disposeObject",
283
- value: function disposeObject(object) {
284
- var _this3 = this;
285
- object.traverse(function (child) {
286
- if (child instanceof _three.Mesh && child.material) {
287
- if (Array.isArray(child.material)) {
288
- child.material.forEach(function (material) {
289
- _this3.disposeMaterial(material);
290
- });
291
- } else {
292
- _this3.disposeMaterial(child.material);
293
- }
294
- }
295
- if (child instanceof _three.Mesh && child.geometry) {
296
- _this3.disposeGeometry(child.geometry);
297
- }
298
- if (child instanceof _three.Mesh && child.material && child.material.map) {
299
- _this3.disposeTexture(child.material.map);
215
+ }
216
+ disposeObject(object) {
217
+ object.traverse(child => {
218
+ if (child instanceof _three.Mesh && child.material) {
219
+ if (Array.isArray(child.material)) {
220
+ child.material.forEach(material => {
221
+ this.disposeMaterial(material);
222
+ });
223
+ } else {
224
+ this.disposeMaterial(child.material);
300
225
  }
301
- requestAnimationFrame(function () {
302
- return child.children.length = 0;
303
- });
304
- });
305
- if (object.parent) {
306
- object.parent.remove(object);
307
226
  }
308
- }
309
- }, {
310
- key: "disposeMaterial",
311
- value: function disposeMaterial(material) {
312
- if (material.dispose) {
313
- material.dispose();
227
+ if (child instanceof _three.Mesh && child.geometry) {
228
+ this.disposeGeometry(child.geometry);
314
229
  }
315
- }
316
-
317
- // to dispose of a texture
318
- }, {
319
- key: "disposeTexture",
320
- value: function disposeTexture(texture) {
321
- if (texture.dispose) {
322
- texture.dispose();
230
+ if (child instanceof _three.Mesh && child.material && child.material.map) {
231
+ this.disposeTexture(child.material.map);
323
232
  }
233
+ requestAnimationFrame(() => child.children.length = 0);
234
+ });
235
+ if (object.parent) {
236
+ object.parent.remove(object);
324
237
  }
325
-
326
- // to dispose of a geometry
327
- }, {
328
- key: "disposeGeometry",
329
- value: function disposeGeometry(geometry) {
330
- if (geometry.dispose) {
331
- geometry.dispose();
332
- }
238
+ }
239
+ disposeMaterial(material) {
240
+ if (material.dispose) {
241
+ material.dispose();
333
242
  }
334
- }, {
335
- key: "remove",
336
- value: function remove(object) {
337
- this.scene.remove(object);
338
- object = null;
243
+ }
244
+
245
+ // to dispose of a texture
246
+ disposeTexture(texture) {
247
+ if (texture.dispose) {
248
+ texture.dispose();
339
249
  }
340
- }, {
341
- key: "update",
342
- value: function update() {
343
- if (this.map.repaint) this.map.repaint = false;
344
- this.scene.updateMatrixWorld(true);
250
+ }
345
251
 
346
- // Render the scene and repaint the map
347
- this.renderer.resetState(); //update threejs r126
348
- this.renderer.render(this.scene, this.camera);
252
+ // to dispose of a geometry
253
+ disposeGeometry(geometry) {
254
+ if (geometry.dispose) {
255
+ geometry.dispose();
349
256
  }
350
- }]);
351
- }();
352
- var _default = exports["default"] = CustomThreeJSWrapper;
257
+ }
258
+ remove(object) {
259
+ this.scene.remove(object);
260
+ object = null;
261
+ }
262
+ update() {
263
+ if (this.map.repaint) this.map.repaint = false;
264
+ this.scene.updateMatrixWorld(true);
265
+
266
+ // Render the scene and repaint the map
267
+ this.renderer.resetState(); //update threejs r126
268
+ this.renderer.render(this.scene, this.camera);
269
+ }
270
+ }
271
+ var _default = exports.default = CustomThreeJSWrapper;
353
272
  //# sourceMappingURL=CustomThreeJsWrapper.js.map