@twinmatrix/spatialverse-sdk-web 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -2
  2. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  3. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js +293 -0
  4. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js.map +1 -0
  5. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js +35 -0
  6. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js.map +1 -0
  7. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js +33 -0
  8. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js.map +1 -0
  9. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js +307 -0
  10. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js.map +1 -0
  11. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +4 -3
  12. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  13. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +202 -198
  14. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  15. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  16. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  17. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/focustree.json +121 -0
  18. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +32 -29
  19. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  20. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +10 -13
  21. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  22. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +55 -68
  23. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  24. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +12 -12
  25. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  26. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/whatTaxonomies.json +170 -0
  27. package/lib/cjs/meta-atlas-sdk/combined_style.json +2313 -0
  28. package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js +166 -0
  29. package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js.map +1 -0
  30. package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js +229 -0
  31. package/lib/cjs/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js.map +1 -0
  32. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +73 -69
  33. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  34. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  36. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +6 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  38. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +103 -103
  39. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  40. package/lib/cjs/react/MetaAtlasMap.js +4 -4
  41. package/lib/cjs/react/MetaAtlasMap.js.map +1 -1
  42. package/lib/cjs/react/hooks/useMapEvents/index.js +6 -3
  43. package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
  44. package/lib/cjs/react/hooks/useStampRally/index.js +7 -5
  45. package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
  46. package/lib/cjs/react/hooks/useStampRally/utils.js +1 -1
  47. package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
  48. package/lib/cjs/react/stores/useMapDataStore.js +17 -21
  49. package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
  50. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -2
  51. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  52. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js +286 -0
  53. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.js.map +1 -0
  54. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js +27 -0
  55. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.js.map +1 -0
  56. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js +27 -0
  57. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.js.map +1 -0
  58. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js +305 -0
  59. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.js.map +1 -0
  60. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +4 -3
  61. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  62. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +202 -198
  63. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  64. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  65. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  66. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/focustree.json +121 -0
  67. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +32 -29
  68. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  69. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +10 -8
  70. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  71. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +55 -68
  72. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  73. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +12 -12
  74. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  75. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/whatTaxonomies.json +170 -0
  76. package/lib/esm/meta-atlas-sdk/combined_style.json +2313 -0
  77. package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js +158 -0
  78. package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.js.map +1 -0
  79. package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js +221 -0
  80. package/lib/esm/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.js.map +1 -0
  81. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +73 -68
  82. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  83. package/lib/esm/meta-atlas-sdk/utils/helpers.js +1 -1
  84. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  85. package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
  86. package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  87. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +103 -101
  88. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  89. package/lib/esm/react/MetaAtlasMap.js +4 -4
  90. package/lib/esm/react/MetaAtlasMap.js.map +1 -1
  91. package/lib/esm/react/hooks/useMapEvents/index.js +6 -3
  92. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  93. package/lib/esm/react/hooks/useStampRally/index.js +7 -5
  94. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  95. package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
  96. package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
  97. package/lib/esm/react/stores/useMapDataStore.js +17 -21
  98. package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
  99. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
  100. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
  101. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
  102. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
  103. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
  104. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
  105. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
  106. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
  107. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
  108. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
  109. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
  110. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
  111. package/package.json +4 -4
@@ -31,12 +31,12 @@ function useStampRally() {
31
31
  if (map.hasImage(id)) return resolve();
32
32
  map.loadImage(url, (error, image) => {
33
33
  if (error || !image) {
34
- console.error(`Error loading image '${id}' from ${url}:`, error);
34
+ console.error("Error loading image '".concat(id, "' from ").concat(url, ":"), error);
35
35
  reject(error);
36
36
  return;
37
37
  }
38
38
  map.addImage(id, image);
39
- console.log(`Loaded image: ${id}`);
39
+ console.log("Loaded image: ".concat(id));
40
40
  resolve();
41
41
  });
42
42
  });
@@ -46,7 +46,7 @@ function useStampRally() {
46
46
  name,
47
47
  url
48
48
  } = _ref;
49
- const imgName = name == 'stamp_locked' ? name : `stamp-${name}`;
49
+ const imgName = name == 'stamp_locked' ? name : "stamp-".concat(name);
50
50
  return loadImageAsync(map, imgName, url);
51
51
  })).then(() => {
52
52
  if (map.getSource('Stamp Rally')) return;
@@ -79,12 +79,13 @@ function useStampRally() {
79
79
  * @param stamps - Array of stamps.
80
80
  */
81
81
  const showStamps = stamps => {
82
+ var _map$getSource;
82
83
  if (!map) {
83
84
  console.error('Map instance not available for displaying stamps');
84
85
  return;
85
86
  }
86
87
  const pointFeatures = (0, _utils.getStampFeatures)(stamps);
87
- map.getSource('Stamp Rally')?.setData({
88
+ (_map$getSource = map.getSource('Stamp Rally')) === null || _map$getSource === void 0 || _map$getSource.setData({
88
89
  type: 'FeatureCollection',
89
90
  features: pointFeatures
90
91
  });
@@ -94,11 +95,12 @@ function useStampRally() {
94
95
  * Hide stamp rally from the map.
95
96
  */
96
97
  const hideStamps = () => {
98
+ var _map$getSource2;
97
99
  if (!map) {
98
100
  console.error('Map instance not available for displaying stamps');
99
101
  return;
100
102
  }
101
- map.getSource('Stamp Rally')?.setData({
103
+ (_map$getSource2 = map.getSource('Stamp Rally')) === null || _map$getSource2 === void 0 || _map$getSource2.setData({
102
104
  type: 'FeatureCollection',
103
105
  features: []
104
106
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useStampRally","map","useMetaAtlas","servicesReady","useServicesReady","setUpStampRally","logos","Promise","resolve","console","error","loadImageAsync","id","url","reject","hasImage","loadImage","image","addImage","log","all","_ref","name","imgName","then","getSource","addSource","type","data","features","addLayer","source","layout","undefined","catch","showStamps","stamps","pointFeatures","getStampFeatures","setData","hideStamps","isReady"],"sources":["../../../../../src/react/hooks/useStampRally/index.ts"],"sourcesContent":["import { useMetaAtlas } from '../useMetaAtlas';\nimport { useServicesReady } from '../../stores/useMetaAtlasStore';\nimport { Stamp, UseStampRallyReturn } from './types';\nimport { getStampFeatures } from './utils';\n\nexport function useStampRally(): UseStampRallyReturn {\n const { map } = useMetaAtlas()\n \n const servicesReady = useServicesReady();\n\n /**\n * Set up stamp rally source, layer and load the logo images and add them to the map.\n * Remember to also load an image with name stamp_locked which is used to show the icon when stamp has not been unlocked yet.\n * Other images name should correspond with the stamp's exhibitorName.\n * @param logos - Array of image names and url-s to be added.\n * @returns Promise that resolves to a boolean indicating success or error.\n */\n const setUpStampRally = (logos: {name: string, url: string}[]): Promise<boolean> => {\n return new Promise((resolve) => {\n if (!map) {\n console.error(\n 'Map instance not available for loading stamp rally logos'\n );\n return;\n }\n\n const loadImageAsync = (\n map: maplibregl.Map,\n id: string,\n url: string\n ) => {\n return new Promise<void>((resolve, reject) => {\n if (map.hasImage(id)) return resolve();\n\n map.loadImage(url, (error, image) => {\n if (error || !image) {\n console.error(\n `Error loading image '${id}' from ${url}:`,\n error\n );\n reject(error);\n return;\n }\n\n map.addImage(id, image);\n console.log(`Loaded image: ${id}`);\n resolve();\n });\n });\n };\n\n Promise.all(\n logos.map(({ name, url }) => {\n const imgName = name == 'stamp_locked' ? name : `stamp-${name}`;\n return loadImageAsync(map, imgName, url);\n })\n ).then(() => {\n if (map.getSource('Stamp Rally')) return;\n\n map.addSource('Stamp Rally', {\n type: 'geojson',\n data: {\n type: 'FeatureCollection',\n features: [],\n },\n });\n\n map.addLayer(\n {\n id: 'stamps-layer',\n type: 'symbol',\n source: 'Stamp Rally',\n layout: {\n 'icon-image': ['get', 'icon'],\n 'icon-size': 0.05,\n 'icon-allow-overlap': true,\n },\n },\n undefined\n );\n resolve(true);\n }).catch(() => { resolve(false); });\n });\n };\n\n /**\n * Show stamp rally stamps on the map, locked and unlocked respectively.\n * @param stamps - Array of stamps.\n */\n const showStamps = (stamps: Stamp[]) => {\n if (!map) {\n console.error('Map instance not available for displaying stamps');\n return;\n }\n\n const pointFeatures = getStampFeatures(stamps);\n\n (map.getSource('Stamp Rally') as any)?.setData({\n type: 'FeatureCollection',\n features: pointFeatures as any,\n });\n };\n\n /**\n * Hide stamp rally from the map.\n */\n const hideStamps = () => {\n if (!map) {\n console.error('Map instance not available for displaying stamps');\n return;\n }\n \n (map.getSource('Stamp Rally') as any)?.setData({\n type: 'FeatureCollection',\n features: []\n });\n };\n\n return {\n isReady: servicesReady,\n setUpStampRally,\n showStamps,\n hideStamps\n };\n}\n\n"],"mappings":";;;;;;;;;AAKO,SAASA,aAAaA,CAAA,EAAwB;EACnD,MAAM;IAAEC;EAAI,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EAE9B,MAAMC,aAAa,GAAG,IAAAC,mCAAgB,EAAC,CAAC;;EAExC;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,eAAe,GAAIC,KAAoC,IAAuB;IAClF,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;MAC9B,IAAI,CAACP,GAAG,EAAE;QACRQ,OAAO,CAACC,KAAK,CACX,0DACF,CAAC;QACD;MACF;MAEA,MAAMC,cAAc,GAAGA,CACrBV,GAAmB,EACnBW,EAAU,EACVC,GAAW,KACR;QACH,OAAO,IAAIN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;YACN,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;YAC7B,WAAW,EAAE,IAAI;YACjB,oBAAoB,EAAE;UACxB;QACF,CAAC,EACDC,SACF,CAAC;QACDzB,OAAO,CAAC,IAAI,CAAC;MACf,CAAC,CAAC,CAAC0B,KAAK,CAAC,MAAM;QAAE1B,OAAO,CAAC,KAAK,CAAC;MAAE,CAAC,CAAC;IACrC,CAAC,CAAC;EACJ,CAAC;;EAED;AACF;AACA;AACA;EACE,MAAM2B,UAAU,GAAIC,MAAe,IAAK;IACtC,IAAI,CAACnC,GAAG,EAAE;MACRQ,OAAO,CAACC,KAAK,CAAC,kDAAkD,CAAC;MACjE;IACF;IAEA,MAAM2B,aAAa,GAAG,IAAAC,uBAAgB,EAACF,MAAM,CAAC;IAE7CnC,GAAG,CAACwB,SAAS,CAAC,aAAa,CAAC,EAAUc,OAAO,CAAC;MAC7CZ,IAAI,EAAE,mBAAmB;MACzBE,QAAQ,EAAEQ;IACZ,CAAC,CAAC;EACJ,CAAC;;EAED;AACF;AACA;EACI,MAAMG,UAAU,GAAGA,CAAA,KAAM;IACvB,IAAI,CAACvC,GAAG,EAAE;MACRQ,OAAO,CAACC,KAAK,CAAC,kDAAkD,CAAC;MACjE;IACF;IAECT,GAAG,CAACwB,SAAS,CAAC,aAAa,CAAC,EAAUc,OAAO,CAAC;MAC7CZ,IAAI,EAAE,mBAAmB;MACzBE,QAAQ,EAAE;IACZ,CAAC,CAAC;EACJ,CAAC;EAEH,OAAO;IACLY,OAAO,EAAEtC,aAAa;IACtBE,eAAe;IACf8B,UAAU;IACVK;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useStampRally","map","useMetaAtlas","servicesReady","useServicesReady","setUpStampRally","logos","Promise","resolve","console","error","loadImageAsync","id","url","reject","hasImage","loadImage","image","concat","addImage","log","all","_ref","name","imgName","then","getSource","addSource","type","data","features","addLayer","source","layout","undefined","catch","showStamps","stamps","_map$getSource","pointFeatures","getStampFeatures","setData","hideStamps","_map$getSource2","isReady"],"sources":["../../../../../src/react/hooks/useStampRally/index.ts"],"sourcesContent":["import { useMetaAtlas } from '../useMetaAtlas';\nimport { useServicesReady } from '../../stores/useMetaAtlasStore';\nimport { Stamp, UseStampRallyReturn } from './types';\nimport { getStampFeatures } from './utils';\n\nexport function useStampRally(): UseStampRallyReturn {\n const { map } = useMetaAtlas()\n \n const servicesReady = useServicesReady();\n\n /**\n * Set up stamp rally source, layer and load the logo images and add them to the map.\n * Remember to also load an image with name stamp_locked which is used to show the icon when stamp has not been unlocked yet.\n * Other images name should correspond with the stamp's exhibitorName.\n * @param logos - Array of image names and url-s to be added.\n * @returns Promise that resolves to a boolean indicating success or error.\n */\n const setUpStampRally = (logos: {name: string, url: string}[]): Promise<boolean> => {\n return new Promise((resolve) => {\n if (!map) {\n console.error(\n 'Map instance not available for loading stamp rally logos'\n );\n return;\n }\n\n const loadImageAsync = (\n map: maplibregl.Map,\n id: string,\n url: string\n ) => {\n return new Promise<void>((resolve, reject) => {\n if (map.hasImage(id)) return resolve();\n\n map.loadImage(url, (error, image) => {\n if (error || !image) {\n console.error(\n `Error loading image '${id}' from ${url}:`,\n error\n );\n reject(error);\n return;\n }\n\n map.addImage(id, image);\n console.log(`Loaded image: ${id}`);\n resolve();\n });\n });\n };\n\n Promise.all(\n logos.map(({ name, url }) => {\n const imgName = name == 'stamp_locked' ? name : `stamp-${name}`;\n return loadImageAsync(map, imgName, url);\n })\n ).then(() => {\n if (map.getSource('Stamp Rally')) return;\n\n map.addSource('Stamp Rally', {\n type: 'geojson',\n data: {\n type: 'FeatureCollection',\n features: [],\n },\n });\n\n map.addLayer(\n {\n id: 'stamps-layer',\n type: 'symbol',\n source: 'Stamp Rally',\n layout: {\n 'icon-image': ['get', 'icon'],\n 'icon-size': 0.05,\n 'icon-allow-overlap': true,\n },\n },\n undefined\n );\n resolve(true);\n }).catch(() => { resolve(false); });\n });\n };\n\n /**\n * Show stamp rally stamps on the map, locked and unlocked respectively.\n * @param stamps - Array of stamps.\n */\n const showStamps = (stamps: Stamp[]) => {\n if (!map) {\n console.error('Map instance not available for displaying stamps');\n return;\n }\n\n const pointFeatures = getStampFeatures(stamps);\n\n (map.getSource('Stamp Rally') as any)?.setData({\n type: 'FeatureCollection',\n features: pointFeatures as any,\n });\n };\n\n /**\n * Hide stamp rally from the map.\n */\n const hideStamps = () => {\n if (!map) {\n console.error('Map instance not available for displaying stamps');\n return;\n }\n \n (map.getSource('Stamp Rally') as any)?.setData({\n type: 'FeatureCollection',\n features: []\n });\n };\n\n return {\n isReady: servicesReady,\n setUpStampRally,\n showStamps,\n hideStamps\n };\n}\n\n"],"mappings":";;;;;;;;;AAKO,SAASA,aAAaA,CAAA,EAAwB;EACnD,MAAM;IAAEC;EAAI,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EAE9B,MAAMC,aAAa,GAAG,IAAAC,mCAAgB,EAAC,CAAC;;EAExC;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,eAAe,GAAIC,KAAoC,IAAuB;IAClF,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;MAC9B,IAAI,CAACP,GAAG,EAAE;QACRQ,OAAO,CAACC,KAAK,CACX,0DACF,CAAC;QACD;MACF;MAEA,MAAMC,cAAc,GAAGA,CACrBV,GAAmB,EACnBW,EAAU,EACVC,GAAW,KACR;QACH,OAAO,IAAIN,OAAO,CAAO,CAACC,OAAO,EAAEM,MAAM,KAAK;UAC5C,IAAIb,GAAG,CAACc,QAAQ,CAACH,EAAE,CAAC,EAAE,OAAOJ,OAAO,CAAC,CAAC;UAEtCP,GAAG,CAACe,SAAS,CAACH,GAAG,EAAE,CAACH,KAAK,EAAEO,KAAK,KAAK;YACnC,IAAIP,KAAK,IAAI,CAACO,KAAK,EAAE;cACnBR,OAAO,CAACC,KAAK,yBAAAQ,MAAA,CACaN,EAAE,aAAAM,MAAA,CAAUL,GAAG,QACvCH,KACF,CAAC;cACDI,MAAM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GAAIC,MAAe,IAAK;IAAA,IAAAC,cAAA;IACtC,IAAI,CAACrC,GAAG,EAAE;MACRQ,OAAO,CAACC,KAAK,CAAC,kDAAkD,CAAC;MACjE;IACF;IAEA,MAAM6B,aAAa,GAAG,IAAAC,uBAAgB,EAACH,MAAM,CAAC;IAE9C,CAAAC,cAAA,GAACrC,GAAG,CAACyB,SAAS,CAAC,aAAa,CAAC,cAAAY,cAAA,eAA7BA,cAAA,CAAuCG,OAAO,CAAC;MAC7Cb,IAAI,EAAE,mBAAmB;MACzBE,QAAQ,EAAES;IACZ,CAAC,CAAC;EACJ,CAAC;;EAED;AACF;AACA;EACI,MAAMG,UAAU,GAAGA,CAAA,KAAM;IAAA,IAAAC,eAAA;IACvB,IAAI,CAAC1C,GAAG,EAAE;MACRQ,OAAO,CAACC,KAAK,CAAC,kDAAkD,CAAC;MACjE;IACF;IAEA,CAAAiC,eAAA,GAAC1C,GAAG,CAACyB,SAAS,CAAC,aAAa,CAAC,cAAAiB,eAAA,eAA7BA,eAAA,CAAuCF,OAAO,CAAC;MAC7Cb,IAAI,EAAE,mBAAmB;MACzBE,QAAQ,EAAE;IACZ,CAAC,CAAC;EACJ,CAAC;EAEH,OAAO;IACLc,OAAO,EAAEzC,aAAa;IACtBE,eAAe;IACf+B,UAAU;IACVM;EACF,CAAC;AACH","ignoreList":[]}
@@ -7,7 +7,7 @@ exports.getStampFeatures = getStampFeatures;
7
7
  function getStampFeatures(stamps) {
8
8
  return stamps.map(stamp => {
9
9
  if (stamp.geojson) {
10
- const imageName = `stamp-${stamp.exhibitorName}`;
10
+ const imageName = "stamp-".concat(stamp.exhibitorName);
11
11
  if (stamp.isCollected()) stamp.geojson.properties.icon = imageName;else stamp.geojson.properties.icon = 'stamp_locked';
12
12
  }
13
13
  return stamp.geojson;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["getStampFeatures","stamps","map","stamp","geojson","imageName","exhibitorName","isCollected","properties","icon"],"sources":["../../../../../src/react/hooks/useStampRally/utils.ts"],"sourcesContent":["import { Stamp } from \"./types\";\n\nexport function getStampFeatures(stamps: Stamp[]) {\n return stamps.map((stamp: Stamp) => {\n if (stamp.geojson) {\n const imageName = `stamp-${stamp.exhibitorName}`;\n if (stamp.isCollected()) stamp.geojson.properties.icon = imageName;\n else stamp.geojson.properties.icon = 'stamp_locked';\n }\n return stamp.geojson;\n });\n}"],"mappings":";;;;;;AAEO,SAASA,gBAAgBA,CAACC,MAAe,EAAE;EAChD,OAAOA,MAAM,CAACC,GAAG,CAAEC,KAAY,IAAK;IAClC,IAAIA,KAAK,CAACC,OAAO,EAAE;MACjB,MAAMC,SAAS,GAAG,SAASF,KAAK,CAACG,aAAa,EAAE;MAChD,IAAIH,KAAK,CAACI,WAAW,CAAC,CAAC,EAAEJ,KAAK,CAACC,OAAO,CAACI,UAAU,CAACC,IAAI,GAAGJ,SAAS,CAAC,KAC9DF,KAAK,CAACC,OAAO,CAACI,UAAU,CAACC,IAAI,GAAG,cAAc;IACrD;IACA,OAAON,KAAK,CAACC,OAAO;EACtB,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"utils.js","names":["getStampFeatures","stamps","map","stamp","geojson","imageName","concat","exhibitorName","isCollected","properties","icon"],"sources":["../../../../../src/react/hooks/useStampRally/utils.ts"],"sourcesContent":["import { Stamp } from \"./types\";\n\nexport function getStampFeatures(stamps: Stamp[]) {\n return stamps.map((stamp: Stamp) => {\n if (stamp.geojson) {\n const imageName = `stamp-${stamp.exhibitorName}`;\n if (stamp.isCollected()) stamp.geojson.properties.icon = imageName;\n else stamp.geojson.properties.icon = 'stamp_locked';\n }\n return stamp.geojson;\n });\n}"],"mappings":";;;;;;AAEO,SAASA,gBAAgBA,CAACC,MAAe,EAAE;EAChD,OAAOA,MAAM,CAACC,GAAG,CAAEC,KAAY,IAAK;IAClC,IAAIA,KAAK,CAACC,OAAO,EAAE;MACjB,MAAMC,SAAS,YAAAC,MAAA,CAAYH,KAAK,CAACI,aAAa,CAAE;MAChD,IAAIJ,KAAK,CAACK,WAAW,CAAC,CAAC,EAAEL,KAAK,CAACC,OAAO,CAACK,UAAU,CAACC,IAAI,GAAGL,SAAS,CAAC,KAC9DF,KAAK,CAACC,OAAO,CAACK,UAAU,CAACC,IAAI,GAAG,cAAc;IACrD;IACA,OAAOP,KAAK,CAACC,OAAO;EACtB,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -5,6 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useMapDataStore = void 0;
7
7
  var _zustand = require("zustand");
8
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
12
+ 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); }
8
13
  // can add others like assets, events, etc.
9
14
 
10
15
  /**
@@ -25,45 +30,36 @@ const useMapDataStore = exports.useMapDataStore = (0, _zustand.create)(set => ({
25
30
  loading: false,
26
31
  error: null
27
32
  },
28
- setData: (key, data) => set(state => ({
29
- ...state,
30
- [key]: {
31
- ...state[key],
33
+ setData: (key, data) => set(state => _objectSpread(_objectSpread({}, state), {}, {
34
+ [key]: _objectSpread(_objectSpread({}, state[key]), {}, {
32
35
  data
33
- }
36
+ })
34
37
  })),
35
- setLoading: (key, loading) => set(state => ({
36
- ...state,
37
- [key]: {
38
- ...state[key],
38
+ setLoading: (key, loading) => set(state => _objectSpread(_objectSpread({}, state), {}, {
39
+ [key]: _objectSpread(_objectSpread({}, state[key]), {}, {
39
40
  loading
40
- }
41
+ })
41
42
  })),
42
- setError: (key, error) => set(state => ({
43
- ...state,
44
- [key]: {
45
- ...state[key],
43
+ setError: (key, error) => set(state => _objectSpread(_objectSpread({}, state), {}, {
44
+ [key]: _objectSpread(_objectSpread({}, state[key]), {}, {
46
45
  error
47
- }
46
+ })
48
47
  })),
49
48
  activeObject: null,
50
49
  setActiveObject: f => {
51
- set(state => ({
52
- ...state,
50
+ set(state => _objectSpread(_objectSpread({}, state), {}, {
53
51
  activeObject: f
54
52
  }));
55
53
  },
56
54
  marker: null,
57
55
  setMarker: m => {
58
- set(state => ({
59
- ...state,
56
+ set(state => _objectSpread(_objectSpread({}, state), {}, {
60
57
  marker: m
61
58
  }));
62
59
  },
63
60
  popup: null,
64
61
  setPopup: p => {
65
- set(state => ({
66
- ...state,
62
+ set(state => _objectSpread(_objectSpread({}, state), {}, {
67
63
  popup: p
68
64
  }));
69
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useMapDataStore.js","names":["_zustand","require","useMapDataStore","exports","create","set","booths","data","loading","error","allMetaFeatures","setData","key","state","setLoading","setError","activeObject","setActiveObject","f","marker","setMarker","m","popup","setPopup","p"],"sources":["../../../../src/react/stores/useMapDataStore.ts"],"sourcesContent":["import { create } from 'zustand';\nimport { metaFeature } from '../../meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core';\nimport { Marker, Popup } from 'maplibre-gl';\n\ntype Slices = 'booths' | 'allMetaFeatures'; // can add others like assets, events, etc.\n\n\nexport interface DataSlice<T> {\n data: T | null;\n loading: boolean;\n error: string | null;\n}\n\ninterface MapDataStore {\n booths: DataSlice<metaFeature[]>;\n allMetaFeatures: DataSlice<metaFeature[]>;\n // Add other slices as needed\n\n setData: <S extends Slices>(key: S, data: MapDataStore[S]['data']) => void;\n setLoading: (key: Slices, loading: boolean) => void;\n setError: (key: Slices, error: string | null) => void;\n\n /**\n * The currently active object on the map.\n * Note: activeObject can differ from SDK's lastClickedFeature as activeObject can be updated programmatically\n * (e.g., from search results, navigation, etc.) and may not always reflect the last map click.\n */\n activeObject: metaFeature | null;\n setActiveObject: (f: metaFeature | null) => void;\n\n marker: Marker | null;\n setMarker: (m: Marker | null) => void;\n\n popup: Popup | null;\n setPopup: (m: Popup | null) => void;\n}\n\n\n/**\n * MapData Store - Map Data State Management\n * \n * Zustand store as a global singleton for Map state.\n * Used to access all cached data that need to be used among the components.\n */\n\nexport const useMapDataStore = create<MapDataStore>((set) => ({\n booths: { data: null, loading: false, error: null },\n allMetaFeatures: { data: null, loading: false, error: null },\n\n setData: (key, data) => set((state) => ({ ...state, [key]: { ...state[key], data } })),\n setLoading: (key, loading) => set((state) => ({ ...state, [key]: { ...state[key], loading } })),\n setError: (key, error) => set((state) => ({ ...state, [key]: { ...state[key], error } })),\n\n activeObject: null,\n setActiveObject: (f) => {\n set((state) => ({...state, activeObject: f}))\n },\n\n marker: null,\n setMarker: (m) => {\n set((state) => ({...state, marker: m}))\n },\n\n popup: null,\n setPopup: (p) => {\n set((state) => ({...state, popup: p}))\n }\n}));\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAI4C;;AAkC5C;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,IAAAE,eAAM,EAAgBC,GAAG,KAAM;EAC5DC,MAAM,EAAE;IAAEC,IAAI,EAAE,IAAI;IAAEC,OAAO,E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C;EACxC;AACF,CAAC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useMapDataStore.js","names":["_zustand","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","useMapDataStore","exports","create","set","booths","data","loading","error","allMetaFeatures","setData","key","state","setLoading","setError","activeObject","setActiveObject","f","marker","setMarker","m","popup","setPopup","p"],"sources":["../../../../src/react/stores/useMapDataStore.ts"],"sourcesContent":["import { create } from 'zustand';\nimport { metaFeature } from '../../meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core';\nimport { Marker, Popup } from 'maplibre-gl';\n\ntype Slices = 'booths' | 'allMetaFeatures'; // can add others like assets, events, etc.\n\n\nexport interface DataSlice<T> {\n data: T | null;\n loading: boolean;\n error: string | null;\n}\n\ninterface MapDataStore {\n booths: DataSlice<metaFeature[]>;\n allMetaFeatures: DataSlice<metaFeature[]>;\n // Add other slices as needed\n\n setData: <S extends Slices>(key: S, data: MapDataStore[S]['data']) => void;\n setLoading: (key: Slices, loading: boolean) => void;\n setError: (key: Slices, error: string | null) => void;\n\n /**\n * The currently active object on the map.\n * Note: activeObject can differ from SDK's lastClickedFeature as activeObject can be updated programmatically\n * (e.g., from search results, navigation, etc.) and may not always reflect the last map click.\n */\n activeObject: metaFeature | null;\n setActiveObject: (f: metaFeature | null) => void;\n\n marker: Marker | null;\n setMarker: (m: Marker | null) => void;\n\n popup: Popup | null;\n setPopup: (m: Popup | null) => void;\n}\n\n\n/**\n * MapData Store - Map Data State Management\n * \n * Zustand store as a global singleton for Map state.\n * Used to access all cached data that need to be used among the components.\n */\n\nexport const useMapDataStore = create<MapDataStore>((set) => ({\n booths: { data: null, loading: false, error: null },\n allMetaFeatures: { data: null, loading: false, error: null },\n\n setData: (key, data) => set((state) => ({ ...state, [key]: { ...state[key], data } })),\n setLoading: (key, loading) => set((state) => ({ ...state, [key]: { ...state[key], loading } })),\n setError: (key, error) => set((state) => ({ ...state, [key]: { ...state[key], error } })),\n\n activeObject: null,\n setActiveObject: (f) => {\n set((state) => ({...state, activeObject: f}))\n },\n\n marker: null,\n setMarker: (m) => {\n set((state) => ({...state, marker: m}))\n },\n\n popup: null,\n setPopup: (p) => {\n set((state) => ({...state, popup: p}))\n }\n}));\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAiC,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI,MAAA,CAAAD,CAAA,GAAAa,OAAA,WAAAd,CAAA,I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{
6
6
  constructor(map) {
7
7
  this.scene = new Scene();
8
8
  this.map = map;
9
- const c = map?.getCanvas();
10
- const gl = c?.getContext('webgl') || c?.getContext('webgl2');
9
+ const c = map === null || map === void 0 ? void 0 : map.getCanvas();
10
+ const gl = (c === null || c === void 0 ? void 0 : c.getContext('webgl')) || (c === null || c === void 0 ? void 0 : c.getContext('webgl2'));
11
11
  if (!gl && !this.isWebglSupported()) {
12
12
  console.error(map.getCanvas(), 'WebGL 2 is not supported in this environment');
13
13
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"CustomThreeJsWrapper.js","names":["ACESFilmicToneMapping","AmbientLight","DirectionalLight","HemisphereLight","Mesh","Object3D","PerspectiveCamera","Scene","WebGLRenderer","Vector2","Vector3","Shape","Path","ExtrudeGeometry","Box3","SRGBColorSpace","constants","CameraSync","projectToWorld","toDecimal","CustomThreeJSWrapper","constructor","map","scene","c","getCanvas","gl","getContext","isWebglSupported","console","error","renderer","alpha","antialias","preserveDrawingBuffer","canvas","context","setPixelRatio","window","devicePixelRatio","setSize","clientWidth","clientHeight","autoClear","toneMapping","outputColorSpace","fov","FOV_DEGREES","h","w","camera","cameraSync","resize","aspect","updateProjectionMatrix","WebGLRenderingContext","document","createElement","getParameter","e","repaint","clear","layerId","arguments","length","undefined","Promise","resolve","reject","objects","children","forEach","object","push","i","obj","layers","remove","clearMeshes","type","log","filter3DObjects","whatTaxonomies","Array","isArray","visible","includes","userData","whatDimension","add","setEnvironment","dirLight","position","set","castShadow","hemiLight","ambientLight","buildPoints","coords","initCoords","points","init","pos","x","y","buildGeometry","shape","settings","geometry","computeBoundingBox","buildShape","holes","extrusion","opt","coordinates","geometryOptions","mesh","materials","centerMesh","bbox","copy","boundingBox","applyMatrix4","matrixWorld","center","getCenter","dummy","localToWorld","diff","clone","sub","translate","dispose","target","material","_isDisposed","removeFromParent","disposeObject","traverse","child","disposeMaterial","disposeGeometry","disposeTexture","requestAnimationFrame","parent","texture","update","updateMatrixWorld","resetState","render"],"sources":["../../../../../src/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.ts"],"sourcesContent":["import { Map } from 'maplibre-gl';\nimport {\n ACESFilmicToneMapping,\n AmbientLight,\n DataTexture,\n DirectionalLight,\n HemisphereLight,\n Mesh,\n Object3D,\n PerspectiveCamera,\n Scene,\n WebGLRenderer,\n Vector2,\n Vector3,\n Shape,\n Path,\n ExtrudeGeometry,\n Box3,\n BoxGeometry,\n MeshBasicMaterial,\n SRGBColorSpace\n} from 'three';\nimport constants from './utility/constants.js';\nimport CameraSync from './utility/CameraSync.js';\nimport { projectToWorld, toDecimal } from './utility/utils.js';\n\nclass CustomThreeJSWrapper {\n map;\n scene;\n camera;\n renderer;\n cameraSync;\n fov;\n\n constructor(map) {\n this.scene = new Scene();\n this.map = map;\n\n const c = map?.getCanvas() as HTMLCanvasElement;\n const gl = c?.getContext('webgl') || c?.getContext('webgl2');\n\n if (!gl && !this.isWebglSupported()) {\n console.error(map.getCanvas(), 'WebGL 2 is not supported in this environment');\n return;\n }\n\n // Initialize the WebGLRenderer without explicitly passing the WebGL 1 context\n this.renderer = new WebGLRenderer({\n alpha: true,\n antialias: true,\n preserveDrawingBuffer: false,\n canvas: map.getCanvas(),\n context: gl\n });\n\n this.renderer.setPixelRatio(window.devicePixelRatio);\n this.renderer.setSize(this.map.getCanvas().clientWidth, this.map.getCanvas().clientHeight);\n this.renderer.autoClear = false;\n this.renderer.toneMapping = ACESFilmicToneMapping;\n this.renderer.outputColorSpace = SRGBColorSpace;\n this.fov = constants.FOV_DEGREES;\n\n const h = this.map.getCanvas().clientHeight;\n const w = this.map.getCanvas().clientWidth;\n\n this.camera = new PerspectiveCamera(this.fov, w / h, 0.1, 1000);\n\n this.cameraSync = new CameraSync(map, this.camera, this.scene);\n }\n\n resize() {\n const w = this.map.getCanvas().clientWidth;\n const h = this.map.getCanvas().clientHeight;\n this.camera.aspect = w / h;\n this.camera.updateProjectionMatrix();\n this.renderer.setSize(w, h);\n }\n\n isWebglSupported() {\n if (window.WebGLRenderingContext) {\n const canvas = document.createElement('canvas');\n try {\n // Note that { failIfMajorPerformanceCaveat: true } can be passed as a second argument\n // to canvas.getContext(), causing the check to fail if hardware rendering is not available. See\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext\n // for more details.\n const context = canvas.getContext('webgl2') || canvas.getContext('webgl');\n if (context && typeof context.getParameter == 'function') {\n return true;\n }\n } catch (e) {\n // WebGL is supported, but disabled\n }\n return false;\n }\n // WebGL not supported\n return false;\n }\n\n repaint() {\n this.map.repaint = true;\n }\n\n async clear(layerId = null) {\n return new Promise((resolve, reject) => {\n const objects = [];\n this.scene.children.forEach(function (object) {\n objects.push(object);\n });\n for (let i = 0; i < objects.length; i++) {\n const obj = objects[i];\n //if layerId, check the layer to remove, otherwise always remove\n if (obj.layers === layerId || !layerId) {\n this.remove(obj);\n }\n }\n\n resolve('clear');\n });\n }\n\n async clearMeshes() {\n return new Promise((resolve, reject) => {\n const objects = [];\n this.scene.children.forEach(function (object) {\n if (object.type === 'Mesh') objects.push(object);\n });\n console.log('Mesh Objects:', objects);\n for (let i = 0; i < objects.length; i++) {\n this.remove(objects[i]);\n }\n\n resolve('clear');\n });\n }\n\n filter3DObjects(whatTaxonomies: string[]) {\n if (!Array.isArray(whatTaxonomies)) return;\n if (whatTaxonomies.length === 0) {\n this.scene.children.forEach(function (object) {\n object.visible = true;\n });\n } else {\n this.scene.children.forEach(function (object) {\n if (object.type === 'Mesh') {\n if (whatTaxonomies.includes(object.userData.whatDimension)) {\n object.visible = false;\n } else {\n object.visible = true;\n }\n }\n });\n }\n }\n\n add(object) {\n this.scene.add(object);\n }\n\n setEnvironment() {\n const dirLight = new DirectionalLight(0xffffff, 2);\n dirLight.position.set(10, 10, 10);\n dirLight.castShadow = true;\n const hemiLight = new HemisphereLight('white', 'white', 1.5);\n const ambientLight = new AmbientLight('white', 1);\n this.scene.add(dirLight);\n this.scene.add(hemiLight);\n this.scene.add(ambientLight);\n }\n\n buildPoints(coords, initCoords) {\n const points = [];\n const init = projectToWorld([initCoords[0][0], initCoords[0][1], 0]);\n for (let i = 0; i < coords.length; i++) {\n const pos = projectToWorld([coords[i][0], coords[i][1], 0]);\n points.push(new Vector2(toDecimal(pos.x - init.x, 9), toDecimal(pos.y - init.y, 9)));\n }\n return points;\n }\n\n buildGeometry(shape, settings) {\n const geometry = new ExtrudeGeometry(shape, settings);\n geometry.computeBoundingBox();\n return geometry;\n }\n\n buildShape(coords: any) {\n if (coords[0] instanceof (Vector2 || Vector3)) return new Shape(coords);\n let shape = new Shape();\n for (let i = 0; i < coords.length; i++) {\n if (i === 0) {\n shape = new Shape(this.buildPoints(coords[0], coords[0]));\n } else {\n shape.holes.push(new Path(this.buildPoints(coords[i], coords[0])));\n }\n }\n return shape;\n }\n\n extrusion(opt: any) {\n const shape = this.buildShape(opt.coordinates);\n const geometry = this.buildGeometry(shape, opt.geometryOptions);\n const mesh = new Mesh(geometry, opt.materials);\n\n if (!opt.visible) mesh.visible = false;\n\n return mesh;\n }\n\n centerMesh(mesh) {\n // Compute the bounding box\n const bbox = new Box3();\n mesh.geometry.computeBoundingBox();\n bbox.copy(mesh.geometry.boundingBox).applyMatrix4(mesh.matrixWorld);\n\n // Get the center of the bounding box\n let center = new Vector3();\n bbox.getCenter(center);\n\n // Create a dummy object\n const dummy = new Object3D();\n\n // Attach mesh to dummy\n dummy.add(mesh);\n\n center = mesh.localToWorld(center);\n // const geometry = new BoxGeometry( 0.25, 0.25, 0.25 );\n // const material = new MeshBasicMaterial( {color: 0xff0000} );\n // const cube = new Mesh( geometry, material );\n // cube.position.set(center.x, center.y, center.z);\n // this.add( cube );\n // // Move the mesh within the dummy\n const diff = mesh.position.clone().sub(center);\n mesh.geometry.translate(diff.x, diff.y, 0);\n\n return dummy; // Return the new parent object\n }\n\n dispose(target) {\n if (target instanceof Mesh) {\n // If the target is a Mesh\n // Dispose materials and geometry of the mesh\n if (target.material) {\n if (typeof target.material.dispose === 'function' && !target.material._isDisposed) {\n target.material.dispose();\n target.material._isDisposed = true;\n }\n target.material = null;\n }\n if (target.geometry) {\n if (typeof target.geometry.dispose === 'function' && !target.geometry._isDisposed) {\n target.geometry.dispose();\n target.geometry._isDisposed = true;\n }\n target.geometry = null;\n }\n } else if (target instanceof Object3D) {\n // If the target is an Object3D\n target.removeFromParent();\n this.disposeObject(target);\n }\n }\n\n disposeObject(object) {\n object.traverse(child => {\n if (child instanceof Mesh && child.material) {\n if (Array.isArray(child.material)) {\n child.material.forEach(material => {\n this.disposeMaterial(material);\n });\n } else {\n this.disposeMaterial(child.material);\n }\n }\n if (child instanceof Mesh && child.geometry) {\n this.disposeGeometry(child.geometry);\n }\n if (child instanceof Mesh && child.material && child.material.map) {\n this.disposeTexture(child.material.map);\n }\n requestAnimationFrame(() => (child.children.length = 0));\n });\n\n if (object.parent) {\n object.parent.remove(object);\n }\n }\n\n disposeMaterial(material) {\n if (material.dispose) {\n material.dispose();\n }\n }\n\n // to dispose of a texture\n disposeTexture(texture) {\n if (texture.dispose) {\n texture.dispose();\n }\n }\n\n // to dispose of a geometry\n disposeGeometry(geometry) {\n if (geometry.dispose) {\n geometry.dispose();\n }\n }\n\n remove(object) {\n this.scene.remove(object);\n object = null;\n }\n\n update() {\n if (this.map.repaint) this.map.repaint = false;\n this.scene.updateMatrixWorld(true);\n\n // Render the scene and repaint the map\n this.renderer.resetState(); //update threejs r126\n this.renderer.render(this.scene, this.camera);\n }\n}\n\nexport default CustomThreeJSWrapper;\n"],"mappings":"AACA,SACEA,qBAAqB,EACrBC,YAAY,EAEZC,gBAAgB,EAChBC,eAAe,EACfC,IAAI,EACJC,QAAQ,EACRC,iBAAiB,EACjBC,KAAK,EACLC,aAAa,EACbC,OAAO,EACPC,OAAO,EACPC,KAAK,EACLC,IAAI,EACJC,eAAe,EACfC,IAAI,EAGJC,cAAc,QACT,OAAO;AACd,OAAOC,SAAS,MAAM,wBAAwB;AAC9C,OAAOC,UAAU,MAAM,yB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AACN,QAAQ,EAAE;IACxB,IAAIA,QAAQ,CAACF,OAAO,EAAE;MACpBE,QAAQ,CAACF,OAAO,CAAC,CAAC;IACpB;EACF;;EAEA;EACAU,cAAcA,CAACG,OAAO,EAAE;IACtB,IAAIA,OAAO,CAACb,OAAO,EAAE;MACnBa,OAAO,CAACb,OAAO,CAAC,CAAC;IACnB;EACF;;EAEA;EACAS,eAAeA,CAACjC,QAAQ,EAAE;IACxB,IAAIA,QAAQ,CAACwB,OAAO,EAAE;MACpBxB,QAAQ,CAACwB,OAAO,CAAC,CAAC;IACpB;EACF;EAEAvD,MAAMA,CAACL,MAAM,EAAE;IACb,IAAI,CAACjD,KAAK,CAACsD,MAAM,CAACL,MAAM,CAAC;IACzBA,MAAM,GAAG,IAAI;EACf;EAEA0E,MAAMA,CAAA,EAAG;IACP,IAAI,IAAI,CAAC5H,GAAG,CAACsC,OAAO,EAAE,IAAI,CAACtC,GAAG,CAACsC,OAAO,GAAG,KAAK;IAC9C,IAAI,CAACrC,KAAK,CAAC4H,iBAAiB,CAAC,IAAI,CAAC;;IAElC;IACA,IAAI,CAACpH,QAAQ,CAACqH,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAACrH,QAAQ,CAACsH,MAAM,CAAC,IAAI,CAAC9H,KAAK,EAAE,IAAI,CAAC2B,MAAM,CAAC;EAC/C;AACF;AAEA,eAAe9B,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"CustomThreeJsWrapper.js","names":["ACESFilmicToneMapping","AmbientLight","DirectionalLight","HemisphereLight","Mesh","Object3D","PerspectiveCamera","Scene","WebGLRenderer","Vector2","Vector3","Shape","Path","ExtrudeGeometry","Box3","SRGBColorSpace","constants","CameraSync","projectToWorld","toDecimal","CustomThreeJSWrapper","constructor","map","scene","c","getCanvas","gl","getContext","isWebglSupported","console","error","renderer","alpha","antialias","preserveDrawingBuffer","canvas","context","setPixelRatio","window","devicePixelRatio","setSize","clientWidth","clientHeight","autoClear","toneMapping","outputColorSpace","fov","FOV_DEGREES","h","w","camera","cameraSync","resize","aspect","updateProjectionMatrix","WebGLRenderingContext","document","createElement","getParameter","e","repaint","clear","layerId","arguments","length","undefined","Promise","resolve","reject","objects","children","forEach","object","push","i","obj","layers","remove","clearMeshes","type","log","filter3DObjects","whatTaxonomies","Array","isArray","visible","includes","userData","whatDimension","add","setEnvironment","dirLight","position","set","castShadow","hemiLight","ambientLight","buildPoints","coords","initCoords","points","init","pos","x","y","buildGeometry","shape","settings","geometry","computeBoundingBox","buildShape","holes","extrusion","opt","coordinates","geometryOptions","mesh","materials","centerMesh","bbox","copy","boundingBox","applyMatrix4","matrixWorld","center","getCenter","dummy","localToWorld","diff","clone","sub","translate","dispose","target","material","_isDisposed","removeFromParent","disposeObject","traverse","child","disposeMaterial","disposeGeometry","disposeTexture","requestAnimationFrame","parent","texture","update","updateMatrixWorld","resetState","render"],"sources":["../../../../../src/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.ts"],"sourcesContent":["import { Map } from 'maplibre-gl';\nimport {\n ACESFilmicToneMapping,\n AmbientLight,\n DataTexture,\n DirectionalLight,\n HemisphereLight,\n Mesh,\n Object3D,\n PerspectiveCamera,\n Scene,\n WebGLRenderer,\n Vector2,\n Vector3,\n Shape,\n Path,\n ExtrudeGeometry,\n Box3,\n BoxGeometry,\n MeshBasicMaterial,\n SRGBColorSpace\n} from 'three';\nimport constants from './utility/constants.js';\nimport CameraSync from './utility/CameraSync.js';\nimport { projectToWorld, toDecimal } from './utility/utils.js';\n\nclass CustomThreeJSWrapper {\n map;\n scene;\n camera;\n renderer;\n cameraSync;\n fov;\n\n constructor(map) {\n this.scene = new Scene();\n this.map = map;\n\n const c = map?.getCanvas() as HTMLCanvasElement;\n const gl = c?.getContext('webgl') || c?.getContext('webgl2');\n\n if (!gl && !this.isWebglSupported()) {\n console.error(map.getCanvas(), 'WebGL 2 is not supported in this environment');\n return;\n }\n\n // Initialize the WebGLRenderer without explicitly passing the WebGL 1 context\n this.renderer = new WebGLRenderer({\n alpha: true,\n antialias: true,\n preserveDrawingBuffer: false,\n canvas: map.getCanvas(),\n context: gl\n });\n\n this.renderer.setPixelRatio(window.devicePixelRatio);\n this.renderer.setSize(this.map.getCanvas().clientWidth, this.map.getCanvas().clientHeight);\n this.renderer.autoClear = false;\n this.renderer.toneMapping = ACESFilmicToneMapping;\n this.renderer.outputColorSpace = SRGBColorSpace;\n this.fov = constants.FOV_DEGREES;\n\n const h = this.map.getCanvas().clientHeight;\n const w = this.map.getCanvas().clientWidth;\n\n this.camera = new PerspectiveCamera(this.fov, w / h, 0.1, 1000);\n\n this.cameraSync = new CameraSync(map, this.camera, this.scene);\n }\n\n resize() {\n const w = this.map.getCanvas().clientWidth;\n const h = this.map.getCanvas().clientHeight;\n this.camera.aspect = w / h;\n this.camera.updateProjectionMatrix();\n this.renderer.setSize(w, h);\n }\n\n isWebglSupported() {\n if (window.WebGLRenderingContext) {\n const canvas = document.createElement('canvas');\n try {\n // Note that { failIfMajorPerformanceCaveat: true } can be passed as a second argument\n // to canvas.getContext(), causing the check to fail if hardware rendering is not available. See\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext\n // for more details.\n const context = canvas.getContext('webgl2') || canvas.getContext('webgl');\n if (context && typeof context.getParameter == 'function') {\n return true;\n }\n } catch (e) {\n // WebGL is supported, but disabled\n }\n return false;\n }\n // WebGL not supported\n return false;\n }\n\n repaint() {\n this.map.repaint = true;\n }\n\n async clear(layerId = null) {\n return new Promise((resolve, reject) => {\n const objects = [];\n this.scene.children.forEach(function (object) {\n objects.push(object);\n });\n for (let i = 0; i < objects.length; i++) {\n const obj = objects[i];\n //if layerId, check the layer to remove, otherwise always remove\n if (obj.layers === layerId || !layerId) {\n this.remove(obj);\n }\n }\n\n resolve('clear');\n });\n }\n\n async clearMeshes() {\n return new Promise((resolve, reject) => {\n const objects = [];\n this.scene.children.forEach(function (object) {\n if (object.type === 'Mesh') objects.push(object);\n });\n console.log('Mesh Objects:', objects);\n for (let i = 0; i < objects.length; i++) {\n this.remove(objects[i]);\n }\n\n resolve('clear');\n });\n }\n\n filter3DObjects(whatTaxonomies: string[]) {\n if (!Array.isArray(whatTaxonomies)) return;\n if (whatTaxonomies.length === 0) {\n this.scene.children.forEach(function (object) {\n object.visible = true;\n });\n } else {\n this.scene.children.forEach(function (object) {\n if (object.type === 'Mesh') {\n if (whatTaxonomies.includes(object.userData.whatDimension)) {\n object.visible = false;\n } else {\n object.visible = true;\n }\n }\n });\n }\n }\n\n add(object) {\n this.scene.add(object);\n }\n\n setEnvironment() {\n const dirLight = new DirectionalLight(0xffffff, 2);\n dirLight.position.set(10, 10, 10);\n dirLight.castShadow = true;\n const hemiLight = new HemisphereLight('white', 'white', 1.5);\n const ambientLight = new AmbientLight('white', 1);\n this.scene.add(dirLight);\n this.scene.add(hemiLight);\n this.scene.add(ambientLight);\n }\n\n buildPoints(coords, initCoords) {\n const points = [];\n const init = projectToWorld([initCoords[0][0], initCoords[0][1], 0]);\n for (let i = 0; i < coords.length; i++) {\n const pos = projectToWorld([coords[i][0], coords[i][1], 0]);\n points.push(new Vector2(toDecimal(pos.x - init.x, 9), toDecimal(pos.y - init.y, 9)));\n }\n return points;\n }\n\n buildGeometry(shape, settings) {\n const geometry = new ExtrudeGeometry(shape, settings);\n geometry.computeBoundingBox();\n return geometry;\n }\n\n buildShape(coords: any) {\n if (coords[0] instanceof (Vector2 || Vector3)) return new Shape(coords);\n let shape = new Shape();\n for (let i = 0; i < coords.length; i++) {\n if (i === 0) {\n shape = new Shape(this.buildPoints(coords[0], coords[0]));\n } else {\n shape.holes.push(new Path(this.buildPoints(coords[i], coords[0])));\n }\n }\n return shape;\n }\n\n extrusion(opt: any) {\n const shape = this.buildShape(opt.coordinates);\n const geometry = this.buildGeometry(shape, opt.geometryOptions);\n const mesh = new Mesh(geometry, opt.materials);\n\n if (!opt.visible) mesh.visible = false;\n\n return mesh;\n }\n\n centerMesh(mesh) {\n // Compute the bounding box\n const bbox = new Box3();\n mesh.geometry.computeBoundingBox();\n bbox.copy(mesh.geometry.boundingBox).applyMatrix4(mesh.matrixWorld);\n\n // Get the center of the bounding box\n let center = new Vector3();\n bbox.getCenter(center);\n\n // Create a dummy object\n const dummy = new Object3D();\n\n // Attach mesh to dummy\n dummy.add(mesh);\n\n center = mesh.localToWorld(center);\n // const geometry = new BoxGeometry( 0.25, 0.25, 0.25 );\n // const material = new MeshBasicMaterial( {color: 0xff0000} );\n // const cube = new Mesh( geometry, material );\n // cube.position.set(center.x, center.y, center.z);\n // this.add( cube );\n // // Move the mesh within the dummy\n const diff = mesh.position.clone().sub(center);\n mesh.geometry.translate(diff.x, diff.y, 0);\n\n return dummy; // Return the new parent object\n }\n\n dispose(target) {\n if (target instanceof Mesh) {\n // If the target is a Mesh\n // Dispose materials and geometry of the mesh\n if (target.material) {\n if (typeof target.material.dispose === 'function' && !target.material._isDisposed) {\n target.material.dispose();\n target.material._isDisposed = true;\n }\n target.material = null;\n }\n if (target.geometry) {\n if (typeof target.geometry.dispose === 'function' && !target.geometry._isDisposed) {\n target.geometry.dispose();\n target.geometry._isDisposed = true;\n }\n target.geometry = null;\n }\n } else if (target instanceof Object3D) {\n // If the target is an Object3D\n target.removeFromParent();\n this.disposeObject(target);\n }\n }\n\n disposeObject(object) {\n object.traverse(child => {\n if (child instanceof Mesh && child.material) {\n if (Array.isArray(child.material)) {\n child.material.forEach(material => {\n this.disposeMaterial(material);\n });\n } else {\n this.disposeMaterial(child.material);\n }\n }\n if (child instanceof Mesh && child.geometry) {\n this.disposeGeometry(child.geometry);\n }\n if (child instanceof Mesh && child.material && child.material.map) {\n this.disposeTexture(child.material.map);\n }\n requestAnimationFrame(() => (child.children.length = 0));\n });\n\n if (object.parent) {\n object.parent.remove(object);\n }\n }\n\n disposeMaterial(material) {\n if (material.dispose) {\n material.dispose();\n }\n }\n\n // to dispose of a texture\n disposeTexture(texture) {\n if (texture.dispose) {\n texture.dispose();\n }\n }\n\n // to dispose of a geometry\n disposeGeometry(geometry) {\n if (geometry.dispose) {\n geometry.dispose();\n }\n }\n\n remove(object) {\n this.scene.remove(object);\n object = null;\n }\n\n update() {\n if (this.map.repaint) this.map.repaint = false;\n this.scene.updateMatrixWorld(true);\n\n // Render the scene and repaint the map\n this.renderer.resetState(); //update threejs r126\n this.renderer.render(this.scene, this.camera);\n }\n}\n\nexport default CustomThreeJSWrapper;\n"],"mappings":"AACA,SACEA,qBAAqB,EACrBC,YAAY,EAEZC,gBAAgB,EAChBC,eAAe,EACfC,IAAI,EACJC,QAAQ,EACRC,iBAAiB,EACjBC,KAAK,EACLC,aAAa,EACbC,OAAO,EACPC,OAAO,EACPC,KAAK,EACLC,IAAI,EACJC,eAAe,EACfC,IAAI,EAGJC,cAAc,QACT,OAAO;AACd,OAAOC,SAAS,MAAM,wBAAwB;AAC9C,OAAOC,UAAU,MAAM,yBAAyB;AAChD,SAASC,cAAc,EAAEC,SAAS,QAAQ,oBAAoB;AAE9D,MAAMC,oBAAoB,CAAC;EAQzBC,WAAWA,CAACC,GAAG,EAAE;IACf,IAAI,CAACC,KAAK,GAAG,IAAIhB,KAAK,CAAC,CAAC;IACxB,IAAI,CAACe,GAAG,GAAGA,GAAG;IAEd,MAAME,CAAC,GAAGF,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEG,SAAS,CAAC,CAAsB;IAC/C,MAAMC,EAAE,GAAG,CAAAF,CAAC,aAADA,CAAC,uBAADA,CAAC,CAAEG,UAAU,CAAC,OAAO,CAAC,MAAIH,CAAC,aAADA,CAAC,uBAADA,CAAC,CAAEG,UAAU,CAAC,QAAQ,CAAC;IAE5D,IAAI,CAACD,EAAE,IAAI,CAAC,IAAI,CAACE,gBAAgB,CAAC,CAAC,EAAE;MACnCC,OAAO,CAACC,KAAK,CAACR,GAAG,CAACG,SAAS,CAAC,CAAC,EAAE,8CAA8C,CAAC;MAC9E;IACF;;IAEA;IACA,IAAI,CAACM,QAAQ,GAAG,IAAIvB,aAA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G,KAAK;IAC9C,IAAI,CAACrC,KAAK,CAAC4H,iBAAiB,CAAC,IAAI,CAAC;;IAElC;IACA,IAAI,CAACpH,QAAQ,CAACqH,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAACrH,QAAQ,CAACsH,MAAM,CAAC,IAAI,CAAC9H,KAAK,EAAE,IAAI,CAAC2B,MAAM,CAAC;EAC/C;AACF;AAEA,eAAe9B,oBAAoB","ignoreList":[]}
@@ -0,0 +1,286 @@
1
+ /**
2
+ * @author peterqliu / https://github.com/peterqliu
3
+ * @author jscastro / https://github.com/jscastro76
4
+ *
5
+ * This code file is based on the CameraSync module from the ThreeBox project.
6
+ * Source: https://github.com/jscastro76/threebox/blob/master/src/camera/CameraSync.js
7
+ */
8
+
9
+ import { Group, Matrix4, Vector3, OrthographicCamera, Quaternion } from "three";
10
+ import constants from './constants.js';
11
+ class CameraSync {
12
+ constructor(map, camera, world) {
13
+ this.map = map;
14
+ this.camera = camera;
15
+ this.active = true;
16
+ this.camera.matrixAutoUpdate = false; // We're in charge of the camera now!
17
+
18
+ // Postion and configure the world group so we can scale it appropriately when the camera zooms
19
+ this.world = world || new Group();
20
+ this.world.position.x = this.world.position.y = constants.WORLD_SIZE / 2;
21
+ this.world.matrixAutoUpdate = false;
22
+
23
+ // set up basic camera state
24
+ this.state = {
25
+ translateCenter: new Matrix4().makeTranslation(constants.WORLD_SIZE / 2, -constants.WORLD_SIZE / 2, 0),
26
+ worldSizeRatio: constants.TILE_SIZE / constants.WORLD_SIZE,
27
+ worldSize: constants.TILE_SIZE * this.map.transform.scale
28
+ };
29
+
30
+ // Listen for move events from the map and update the Three.js camera
31
+ let _this = this; // keep the function on _this
32
+ this.map.on('move', function () {
33
+ _this.updateCamera();
34
+ });
35
+ this.map.on('resize', function () {
36
+ _this.setupCamera();
37
+ });
38
+ this.setupCamera();
39
+ }
40
+ setupCamera() {
41
+ const t = this.map.transform;
42
+ this.camera.aspect = t.width / t.height; //bug fixed, if aspect is not reset raycast will fail on map resize
43
+ this.halfFov = t._fov / 2;
44
+ this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height;
45
+ const maxPitch = t._maxPitch * Math.PI / 180;
46
+ this.acuteAngle = Math.PI / 2 - maxPitch;
47
+ this.updateCamera();
48
+ }
49
+ updateCamera(ev) {
50
+ if (!this.camera) {
51
+ return;
52
+ }
53
+ const t = this.map.transform;
54
+ this.camera.aspect = t.width / t.height; //bug fixed, if aspect is not reset raycast will fail on map resize
55
+ const offset = t.centerOffset || new Vector3(); //{ x: t.width / 2, y: t.height / 2 };
56
+ let farZ = 0;
57
+ let furthestDistance = 0;
58
+ this.halfFov = t._fov / 2;
59
+ const groundAngle = Math.PI / 2 + t._pitch;
60
+ const pitchAngle = Math.cos(Math.PI / 2 - t._pitch); //pitch seems to influence heavily the depth calculation and cannot be more than 60 = PI/3 < v1 and 85 > v2
61
+ this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height;
62
+ // let pixelsPerMeter = 1;
63
+ const worldSize = this.worldSize();
64
+
65
+ // if (this.map.tb.mapboxVersion >= 2.0) {
66
+ // mapbox version >= 2.0
67
+ // pixelsPerMeter = this.mercatorZfromAltitude(1, t.center.lat) * worldSize;
68
+ // const fovAboveCenter = t._fov * (0.5 + t.centerOffset.y / t.height);
69
+ // // Adjust distance to MSL by the minimum possible elevation visible on screen,
70
+ // // this way the far plane is pushed further in the case of negative elevation.
71
+ // const minElevationInPixels = t.elevation ? t.elevation.getMinElevationBelowMSL() * pixelsPerMeter : 0;
72
+ // const cameraToSeaLevelDistance = ((t._camera.position[2] * worldSize) - minElevationInPixels) / Math.cos(t._pitch);
73
+ // const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * cameraToSeaLevelDistance / Math.sin(clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));
74
+ // // Calculate z distance of the farthest fragment that should be rendered.
75
+ // furthestDistance = pitchAngle * topHalfSurfaceDistance + cameraToSeaLevelDistance;
76
+ // // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`
77
+ // const horizonDistance = cameraToSeaLevelDistance * (1 / t._horizonShift);
78
+ // farZ = Math.min(furthestDistance * 1.01, horizonDistance);
79
+ // } else {
80
+ // // mapbox version < 2.0 or azure maps
81
+ // Furthest distance optimized by @jscastro76
82
+ const topHalfSurfaceDistance = Math.sin(this.halfFov) * this.cameraToCenterDistance / Math.sin(Math.PI - groundAngle - this.halfFov);
83
+
84
+ // Calculate z distance of the farthest fragment that should be rendered.
85
+ furthestDistance = pitchAngle * topHalfSurfaceDistance + this.cameraToCenterDistance;
86
+
87
+ // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`
88
+ farZ = furthestDistance * 1.01;
89
+ // }
90
+ this.cameraTranslateZ = new Matrix4().makeTranslation(0, 0, this.cameraToCenterDistance);
91
+
92
+ // someday @ansis set further near plane to fix precision for deckgl,so we should fix it to use mapbox-gl v1.3+ correctly
93
+ // https://github.com/mapbox/mapbox-gl-js/commit/5cf6e5f523611bea61dae155db19a7cb19eb825c#diff-5dddfe9d7b5b4413ee54284bc1f7966d
94
+ const nz = t.height / 50; //min near z as coded by @ansis
95
+ const nearZ = Math.max(nz * pitchAngle, nz); //on changes in the pitch nz could be too low
96
+
97
+ const h = t.height;
98
+ const w = t.width;
99
+ if (this.camera instanceof OrthographicCamera) {
100
+ this.camera.projectionMatrix = makeOrthographicMatrix(w / -2, w / 2, h / 2, h / -2, nearZ, farZ);
101
+ } else {
102
+ this.camera.projectionMatrix = makePerspectiveMatrix(t._fov, w / h, nearZ, farZ);
103
+ }
104
+ this.camera.projectionMatrix.elements[8] = -offset.x * 2 / t.width;
105
+ this.camera.projectionMatrix.elements[9] = offset.y * 2 / t.height;
106
+
107
+ // Unlike the Mapbox GL JS camera, separate camera translation and rotation out into its world matrix
108
+ // If this is applied directly to the projection matrix, it will work OK but break raycasting
109
+ let cameraWorldMatrix = this.calcCameraMatrix(t._pitch, t.angle);
110
+ // When terrain layers are included, height of 3D layers must be modified from t_camera.z * worldSize
111
+ if (t.elevation) cameraWorldMatrix.elements[14] = t._camera.position[2] * worldSize;
112
+ //this.camera.matrixWorld.elements is equivalent to t._camera._transform
113
+ this.camera.matrixWorld.copy(cameraWorldMatrix);
114
+ let zoomPow = t.scale * this.state.worldSizeRatio;
115
+ // Handle scaling and translation of objects in the map in the world's matrix transform, not the camera
116
+ let scale = new Matrix4();
117
+ let translateMap = new Matrix4();
118
+ let rotateMap = new Matrix4();
119
+ scale.makeScale(zoomPow, zoomPow, zoomPow);
120
+ let x = t.x || t.point.x;
121
+ let y = t.y || t.point.y;
122
+ translateMap.makeTranslation(-x, y, 0);
123
+ rotateMap.makeRotationZ(Math.PI);
124
+ this.world.matrix = new Matrix4().premultiply(rotateMap).premultiply(this.state.translateCenter).premultiply(scale).premultiply(translateMap);
125
+
126
+ // utils.prettyPrintMatrix(this.camera.projectionMatrix.elements);
127
+ this.map.fire('CameraSynced', {
128
+ detail: {
129
+ nearZ: nearZ,
130
+ farZ: farZ,
131
+ pitch: t._pitch,
132
+ angle: t.angle,
133
+ furthestDistance: furthestDistance,
134
+ cameraToCenterDistance: this.cameraToCenterDistance,
135
+ t: this.map.transform,
136
+ tbProjMatrix: this.camera.projectionMatrix.elements,
137
+ tbWorldMatrix: this.world.matrix.elements,
138
+ cameraSyn: CameraSync
139
+ }
140
+ });
141
+ }
142
+ worldSize() {
143
+ let t = this.map.transform;
144
+ return t.tileSize * t.scale;
145
+ }
146
+ worldSizeFromZoom() {
147
+ let t = this.map.transform;
148
+ return Math.pow(2.0, t.zoom) * t.tileSize;
149
+ }
150
+ mercatorZfromAltitude(altitude, lat) {
151
+ return altitude / this.circumferenceAtLatitude(lat);
152
+ }
153
+ mercatorZfromZoom() {
154
+ return this.cameraToCenterDistance / this.worldSizeFromZoom();
155
+ }
156
+ circumferenceAtLatitude(latitude) {
157
+ return constants.EARTH_CIRCUMFERENCE * Math.cos(latitude * Math.PI / 180);
158
+ }
159
+ calcCameraMatrix(pitch, angle, trz) {
160
+ const t = this.map.transform;
161
+ const _pitch = pitch === undefined ? t._pitch : pitch;
162
+ const _angle = angle === undefined ? t.angle : angle;
163
+ const _trz = trz === undefined ? this.cameraTranslateZ : trz;
164
+ return new Matrix4().premultiply(_trz).premultiply(new Matrix4().makeRotationX(_pitch)).premultiply(new Matrix4().makeRotationZ(_angle));
165
+ }
166
+ updateCameraState() {
167
+ let t = this.map.transform;
168
+ if (!t.height) return;
169
+
170
+ // Set camera orientation and move it to a proper distance from the map
171
+ // t._camera.setPitchBearing(t._pitch, t.angle);
172
+ const dir = t._camera.forward();
173
+ const distance = t.cameraToCenterDistance;
174
+ const center = t.point;
175
+
176
+ // Use camera zoom (if terrain is enabled) to maintain constant altitude to sea level
177
+ const altitude = this.mercatorZfromZoom(t);
178
+ const height = altitude - this.mercatorZfromAltitude(t._centerAltitude, t.center.lat);
179
+
180
+ // simplified version of: this._worldSizeFromZoom(this._zoomFromMercatorZ(height))
181
+ const updatedWorldSize = t.cameraToCenterDistance / height;
182
+ return [center.x / this.worldSize() - dir[0] * distance / updatedWorldSize, center.y / this.worldSize() - dir[1] * distance / updatedWorldSize, this.mercatorZfromAltitude(t._centerAltitude, t._center.lat) + -dir[2] * distance / updatedWorldSize];
183
+ }
184
+ getWorldToCamera(worldSize, pixelsPerMeter) {
185
+ // transformation chain from world space to camera space:
186
+ // 1. Height value (z) of renderables is in meters. Scale z coordinate by pixelsPerMeter
187
+ // 2. Transform from pixel coordinates to camera space with cameraMatrix^-1
188
+ // 3. flip Y if required
189
+ // worldToCamera: flip * cam^-1 * zScale
190
+ // cameraToWorld: (flip * cam^-1 * zScale)^-1 => (zScale^-1 * cam * flip^-1)
191
+ let t = this.map.transform;
192
+ const matrix = new Matrix4();
193
+ const matrixT = new Matrix4();
194
+
195
+ // Compute inverse of camera matrix and post-multiply negated translation
196
+ const o = t._camera._orientation;
197
+ const p = t._camera.position;
198
+ const invPosition = new Vector3(p[0], p[1], p[2]);
199
+ const quat = new Quaternion();
200
+ quat.set(o[0], o[1], o[2], o[3]);
201
+ const invOrientation = quat.conjugate();
202
+ invPosition.multiplyScalar(-worldSize);
203
+ matrixT.makeTranslation(invPosition.x, invPosition.y, invPosition.z);
204
+ matrix.makeRotationFromQuaternion(invOrientation).premultiply(matrixT);
205
+ //this would make the matrix exact to getWorldToCamera but breaks
206
+ //this.translate(matrix.elements, matrix.elements, invPosition);
207
+ // Pre-multiply y (2nd row)
208
+ matrix.elements[1] *= -1.0;
209
+ matrix.elements[5] *= -1.0;
210
+ matrix.elements[9] *= -1.0;
211
+ matrix.elements[13] *= -1.0;
212
+
213
+ // Post-multiply z (3rd column)
214
+ matrix.elements[8] *= pixelsPerMeter;
215
+ matrix.elements[9] *= pixelsPerMeter;
216
+ matrix.elements[10] *= pixelsPerMeter;
217
+ matrix.elements[11] *= pixelsPerMeter;
218
+ return matrix;
219
+ }
220
+ translate(out, a, v) {
221
+ let x = v[0] || v.x,
222
+ y = v[1] || v.y,
223
+ z = v[2] || v.z;
224
+ let a00, a01, a02, a03;
225
+ let a10, a11, a12, a13;
226
+ let a20, a21, a22, a23;
227
+ if (a === out) {
228
+ out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
229
+ out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
230
+ out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
231
+ out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
232
+ } else {
233
+ a00 = a[0];
234
+ a01 = a[1];
235
+ a02 = a[2];
236
+ a03 = a[3];
237
+ a10 = a[4];
238
+ a11 = a[5];
239
+ a12 = a[6];
240
+ a13 = a[7];
241
+ a20 = a[8];
242
+ a21 = a[9];
243
+ a22 = a[10];
244
+ a23 = a[11];
245
+ out[0] = a00;
246
+ out[1] = a01;
247
+ out[2] = a02;
248
+ out[3] = a03;
249
+ out[4] = a10;
250
+ out[5] = a11;
251
+ out[6] = a12;
252
+ out[7] = a13;
253
+ out[8] = a20;
254
+ out[9] = a21;
255
+ out[10] = a22;
256
+ out[11] = a23;
257
+ out[12] = a00 * x + a10 * y + a20 * z + a[12];
258
+ out[13] = a01 * x + a11 * y + a21 * z + a[13];
259
+ out[14] = a02 * x + a12 * y + a22 * z + a[14];
260
+ out[15] = a03 * x + a13 * y + a23 * z + a[15];
261
+ }
262
+ return out;
263
+ }
264
+ }
265
+ function makeOrthographicMatrix(left, right, top, bottom, near, far) {
266
+ var out = new Matrix4();
267
+ const w = 1.0 / (right - left);
268
+ const h = 1.0 / (top - bottom);
269
+ const p = 1.0 / (far - near);
270
+ const x = (right + left) * w;
271
+ const y = (top + bottom) * h;
272
+ const z = near * p;
273
+ var newMatrix = [2 * w, 0, 0, 0, 0, 2 * h, 0, 0, 0, 0, -1 * p, 0, -x, -y, -z, 1];
274
+ out.elements = newMatrix;
275
+ return out;
276
+ }
277
+ function makePerspectiveMatrix(fovy, aspect, near, far) {
278
+ var out = new Matrix4();
279
+ var f = 1.0 / Math.tan(fovy / 2),
280
+ nf = 1 / (near - far);
281
+ var newMatrix = [f / aspect, 0, 0, 0, 0, f, 0, 0, 0, 0, (far + near) * nf, -1, 0, 0, 2 * far * near * nf, 0];
282
+ out.elements = newMatrix;
283
+ return out;
284
+ }
285
+ export default CameraSync;
286
+ //# sourceMappingURL=CameraSync.js.map