@twinmatrix/spatialverse-sdk-web 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) 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/utils.js +4 -3
  4. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  5. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +202 -198
  6. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  7. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  8. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  9. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +32 -29
  10. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  11. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +10 -13
  12. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  13. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +55 -68
  14. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  15. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +12 -12
  16. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  17. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +73 -69
  18. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  19. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +1 -1
  20. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  21. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +6 -1
  22. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  23. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +103 -103
  24. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  25. package/lib/cjs/react/MetaAtlasMap.js +4 -4
  26. package/lib/cjs/react/MetaAtlasMap.js.map +1 -1
  27. package/lib/cjs/react/hooks/useMapEvents/index.js +6 -3
  28. package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
  29. package/lib/cjs/react/hooks/useStampRally/index.js +7 -5
  30. package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
  31. package/lib/cjs/react/hooks/useStampRally/utils.js +1 -1
  32. package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
  33. package/lib/cjs/react/stores/useMapDataStore.js +17 -21
  34. package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
  35. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -2
  36. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  37. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +4 -3
  38. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  39. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +202 -198
  40. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  41. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  42. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  43. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +34 -31
  44. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  45. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +10 -8
  46. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  47. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +55 -68
  48. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  49. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +12 -12
  50. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  51. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +73 -68
  52. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  53. package/lib/esm/meta-atlas-sdk/utils/helpers.js +1 -1
  54. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  55. package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
  56. package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  57. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +103 -101
  58. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  59. package/lib/esm/react/MetaAtlasMap.js +4 -4
  60. package/lib/esm/react/MetaAtlasMap.js.map +1 -1
  61. package/lib/esm/react/hooks/useMapEvents/index.js +6 -3
  62. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  63. package/lib/esm/react/hooks/useStampRally/index.js +7 -5
  64. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  65. package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
  66. package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
  67. package/lib/esm/react/stores/useMapDataStore.js +17 -21
  68. package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
  69. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
  70. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
  71. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
  72. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
  73. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
  74. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
  75. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
  76. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
  77. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
  78. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
  79. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
  80. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
  81. package/package.json +4 -4
@@ -13,8 +13,8 @@ class CustomThreeJSWrapper {
13
13
  constructor(map) {
14
14
  this.scene = new _three.Scene();
15
15
  this.map = map;
16
- const c = map?.getCanvas();
17
- const gl = c?.getContext('webgl') || 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'));
18
18
  if (!gl && !this.isWebglSupported()) {
19
19
  console.error(map.getCanvas(), 'WebGL 2 is not supported in this environment');
20
20
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"CustomThreeJsWrapper.js","names":["_three","require","_constants","_interopRequireDefault","_CameraSync","_utils","e","__esModule","default","CustomThreeJSWrapper","constructor","map","scene","Scene","c","getCanvas","gl","getContext","isWebglSupported","console","error","renderer","WebGLRenderer","alpha","antialias","preserveDrawingBuffer","canvas","context","setPixelRatio","window","devicePixelRatio","setSize","clientWidth","clientHeight","autoClear","toneMapping","ACESFilmicToneMapping","outputColorSpace","SRGBColorSpace","fov","constants","FOV_DEGREES","h","w","camera","PerspectiveCamera","cameraSync","CameraSync","resize","aspect","updateProjectionMatrix","WebGLRenderingContext","document","createElement","getParameter","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","DirectionalLight","position","set","castShadow","hemiLight","HemisphereLight","ambientLight","AmbientLight","buildPoints","coords","initCoords","points","init","projectToWorld","pos","Vector2","toDecimal","x","y","buildGeometry","shape","settings","geometry","ExtrudeGeometry","computeBoundingBox","buildShape","Vector3","Shape","holes","Path","extrusion","opt","coordinates","geometryOptions","mesh","Mesh","materials","centerMesh","bbox","Box3","copy","boundingBox","applyMatrix4","matrixWorld","center","getCenter","dummy","Object3D","localToWorld","diff","clone","sub","translate","dispose","target","material","_isDisposed","removeFromParent","disposeObject","traverse","child","disposeMaterial","disposeGeometry","disposeTexture","requestAnimationFrame","parent","texture","update","updateMatrixWorld","resetState","render","_default","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AAqBA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAA+D,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/D,MAAMG,oBAAoB,CAAC;EAQzBC,WAAWA,CAACC,GAAG,EAAE;IACf,IAAI,CAACC,KAAK,GAAG,IAAIC,YAAK,CAAC,CAAC;IACxB,IAAI,CAACF,GAAG,GAAGA,GAAG;IAEd,MAAMG,CAAC,GAAGH,GAAG,EAAEI,SAAS,CAAC,CAAsB;IAC/C,MAAMC,EAAE,GAAGF,CAAC,EAAEG,UAAU,CAAC,OAAO,CAAC,IAAIH,CAAC,EAAEG,UAAU,CAAC,QAAQ,CAAC;IAE5D,IAAI,CAACD,EAAE,IAA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KAAK,CAAC4D,MAAM,CAACL,MAAM,CAAC;IACzBA,MAAM,GAAG,IAAI;EACf;EAEAuF,MAAMA,CAAA,EAAG;IACP,IAAI,IAAI,CAAC/I,GAAG,CAAC4C,OAAO,EAAE,IAAI,CAAC5C,GAAG,CAAC4C,OAAO,GAAG,KAAK;IAC9C,IAAI,CAAC3C,KAAK,CAAC+I,iBAAiB,CAAC,IAAI,CAAC;;IAElC;IACA,IAAI,CAACtI,QAAQ,CAACuI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAACvI,QAAQ,CAACwI,MAAM,CAAC,IAAI,CAACjJ,KAAK,EAAE,IAAI,CAACgC,MAAM,CAAC;EAC/C;AACF;AAAC,IAAAkH,QAAA,GAAAC,OAAA,CAAAvJ,OAAA,GAEcC,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"CustomThreeJsWrapper.js","names":["_three","require","_constants","_interopRequireDefault","_CameraSync","_utils","e","__esModule","default","CustomThreeJSWrapper","constructor","map","scene","Scene","c","getCanvas","gl","getContext","isWebglSupported","console","error","renderer","WebGLRenderer","alpha","antialias","preserveDrawingBuffer","canvas","context","setPixelRatio","window","devicePixelRatio","setSize","clientWidth","clientHeight","autoClear","toneMapping","ACESFilmicToneMapping","outputColorSpace","SRGBColorSpace","fov","constants","FOV_DEGREES","h","w","camera","PerspectiveCamera","cameraSync","CameraSync","resize","aspect","updateProjectionMatrix","WebGLRenderingContext","document","createElement","getParameter","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","DirectionalLight","position","set","castShadow","hemiLight","HemisphereLight","ambientLight","AmbientLight","buildPoints","coords","initCoords","points","init","projectToWorld","pos","Vector2","toDecimal","x","y","buildGeometry","shape","settings","geometry","ExtrudeGeometry","computeBoundingBox","buildShape","Vector3","Shape","holes","Path","extrusion","opt","coordinates","geometryOptions","mesh","Mesh","materials","centerMesh","bbox","Box3","copy","boundingBox","applyMatrix4","matrixWorld","center","getCenter","dummy","Object3D","localToWorld","diff","clone","sub","translate","dispose","target","material","_isDisposed","removeFromParent","disposeObject","traverse","child","disposeMaterial","disposeGeometry","disposeTexture","requestAnimationFrame","parent","texture","update","updateMatrixWorld","resetState","render","_default","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AAqBA,IA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ded) {
59
59
  return new Promise((modelResolve, modelReject) => {
60
60
  const loader = new _GLTFLoader.GLTFLoader();
61
61
  loader.load(modelUrl, gltf => {
62
+ var _modelMap$get$visible, _modelMap$get;
62
63
  const model = gltf.scene;
63
64
  model.traverse(child => {
64
65
  if (child instanceof THREE.Mesh) {
@@ -78,12 +79,12 @@ function addModelsToMap(wrapper, map, models, modelMap, onModelsLoaded) {
78
79
  model.up.set(0, 0, 1);
79
80
  model.rotation.set(rotation[0], rotation[1], rotation[2]);
80
81
  model.scale.set(scale[0], scale[1], scale[2]);
81
- model.visible = modelMap.get(id)?.visible ?? true;
82
+ model.visible = (_modelMap$get$visible = (_modelMap$get = modelMap.get(id)) === null || _modelMap$get === void 0 ? void 0 : _modelMap$get.visible) !== null && _modelMap$get$visible !== void 0 ? _modelMap$get$visible : true;
82
83
  wrapper.add(model);
83
84
  modelMap.set(id, model);
84
85
  modelResolve(modelMap);
85
86
  }, undefined, error => {
86
- console.error(`Error loading model ${id}:`, error);
87
+ console.error("Error loading model ".concat(id, ":"), error);
87
88
  modelReject(error);
88
89
  });
89
90
  });
@@ -125,7 +126,7 @@ function toggleModelVisibility(modelMap, modelId, isVisible) {
125
126
  }
126
127
  });
127
128
  } else if (child.isMesh) {
128
- console.error(`GSAP Animation already running for child id ${id}!`);
129
+ console.error("GSAP Animation already running for child id ".concat(id, "!"));
129
130
  }
130
131
  }
131
132
  });
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["_three","_interopRequireWildcard","require","THREE","_constants","_interopRequireDefault","_gsap","_GLTFLoader","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","projectToWorld","coords","projected","constants","MERCATOR_A","DEG2RAD","PROJECTION_WORLD_SIZE","Math","log","tan","PI","push","pixelsPerMeter","projectedUnitsPerMeter","result","Vector3","latitude","abs","WORLD_SIZE","cos","EARTH_CIRCUMFERENCE","unprojectFromWorld","worldUnits","unprojected","x","atan","exp","y","height","z","toDecimal","d","Number","toFixed","addModelsToMap","wrapper","map","models","modelMap","onModelsLoaded","Promise","resolve","reject","modelLoadPromises","_ref","id","modelUrl","rotation","scale","instanced","modelResolve","modelReject","loader","GLTFLoader","load","gltf","model","scene","traverse","child","Mesh","Array","isArray","material","forEach","mat","side","DoubleSide","needsUpdate","worldPosition","position","up","visible","add","undefined","error","console","addLayer","type","renderingMode","onAdd","all","then","res","catch","render","toggleModelVisibility","modelId","isVisible","isAnimating","isMesh","transparent","gsap","to","opacity","duration","ease","onComplete","bearingToRotation","bearing","threeRotation","rotationToBearing","quaternion","euler","Euler","setFromQuaternion","objectDirectionToBearing","object","forward","getWorldDirection","atan2"],"sources":["../../../../../../src/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.ts"],"sourcesContent":["import * as THREE from 'three';\nimport {Quaternion, Euler, Vector3, InstancedMesh, Object3D} from 'three';\nimport constants from './constants';\nimport { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';\nimport { LngLatLike } from 'maplibre-gl';\nimport { Position } from 'geojson';\nimport gsap from 'gsap';\nimport { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';\nimport { AmbientLight, DirectionalLight } from 'three';\nimport CustomThreeJSWrapper from '../CustomThreeJsWrapper.js';\n\nexport function projectToWorld(coords: Position) {\n var projected = [\n -constants.MERCATOR_A *\n constants.DEG2RAD *\n coords[0] *\n constants.PROJECTION_WORLD_SIZE,\n -constants.MERCATOR_A *\n Math.log(Math.tan(Math.PI * 0.25 + 0.5 * constants.DEG2RAD * coords[1])) *\n constants.PROJECTION_WORLD_SIZE,\n ];\n\n if (!coords[2]) projected.push(0);\n else {\n var pixelsPerMeter = projectedUnitsPerMeter(coords[1]);\n projected.push(coords[2] * pixelsPerMeter);\n }\n\n var result = new Vector3(projected[0], projected[1], projected[2]);\n\n return result;\n}\n\nfunction projectedUnitsPerMeter(latitude: number) {\n return Math.abs(\n constants.WORLD_SIZE /\n Math.cos(constants.DEG2RAD * latitude) /\n constants.EARTH_CIRCUMFERENCE\n );\n}\n\nexport function unprojectFromWorld(worldUnits: Vector3) {\n var unprojected = [\n -worldUnits.x /\n (constants.MERCATOR_A *\n constants.DEG2RAD *\n constants.PROJECTION_WORLD_SIZE),\n (2 *\n (Math.atan(\n Math.exp(\n worldUnits.y /\n (constants.PROJECTION_WORLD_SIZE * -constants.MERCATOR_A)\n )\n ) -\n Math.PI / 4)) /\n constants.DEG2RAD,\n ];\n\n var pixelsPerMeter = projectedUnitsPerMeter(unprojected[1]);\n\n // z dimension\n var height = worldUnits.z || 0;\n unprojected.push(height / pixelsPerMeter);\n\n return unprojected as LngLatLike;\n}\n\nexport function toDecimal (n, d) {\n return Number(n.toFixed(d));\n}\n\n// RF: TO BE REMOVED. ModelLoader component can be used to load 3D models.\nexport function addModelsToMap(wrapper, map, models, modelMap, onModelsLoaded) {\n return new Promise((resolve, reject) => {\n try {\n const modelLoadPromises = models.map(({ id, modelUrl, coords, rotation, scale, instanced }) => {\n return new Promise((modelResolve, modelReject) => {\n const loader = new GLTFLoader();\n loader.load(\n modelUrl,\n (gltf) => {\n const model = gltf.scene;\n model.traverse((child) => {\n if (child instanceof THREE.Mesh) {\n if (Array.isArray(child.material)) {\n child.material.forEach((mat) => {\n mat.side = THREE.DoubleSide;\n mat.needsUpdate = true;\n });\n } else {\n child.material.side = THREE.DoubleSide;\n child.material.needsUpdate = true;\n }\n }\n });\n \n const worldPosition = projectToWorld(coords);\n model.position.set(worldPosition.x, worldPosition.y, 0);\n model.up.set(0, 0, 1);\n model.rotation.set(rotation[0], rotation[1], rotation[2]);\n model.scale.set(scale[0], scale[1], scale[2]);\n model.visible = modelMap.get(id)?.visible ?? true;\n wrapper.add(model);\n modelMap.set(id, model);\n modelResolve(modelMap);\n },\n undefined,\n (error) => {\n console.error(`Error loading model ${id}:`, error);\n modelReject(error);\n }\n );\n });\n });\n\n map.addLayer({\n id: '3d-model-layer2',\n type: 'custom',\n renderingMode: '3d',\n onAdd: () => Promise.all(modelLoadPromises).then((res)=>{\n resolve(res);\n onModelsLoaded(true);\n }).catch(reject),\n render: () => {},\n });\n } catch (error) {\n reject(error);\n }\n });\n}\n\nexport function toggleModelVisibility(modelMap, modelId, isVisible) {\n const model = modelMap.get(modelId);\n if (!model) return;\n console.log('toggleModelVisibility_model', model);\n const isAnimating = {}; // Object to track animations\n model.traverse((child) => {\n if (child.isMesh) {\n const id = child.id; // Use unique child.id as the key\n child.material.transparent = true;\n if (!isAnimating[id]) {\n isAnimating[id] = true; // Set animation flag\n gsap.to(child.material, {\n opacity: isVisible ? 1 : 0,\n duration: 0.5, // Smooth fade animation\n ease: 'power2.inOut',\n onComplete: () => {\n isAnimating[id] = false; // Reset animation flag\n model.visible = isVisible;\n },\n });\n } else if (child.isMesh) {\n console.error(`GSAP Animation already running for child id ${id}!`);\n }\n }\n });\n if (isVisible) {\n model.visible = true;\n }\n}\n\nexport function bearingToRotation(bearing: number) {\n // Mapbox bearing is clockwise from north, Three.js rotation is counterclockwise from east\n const threeRotation = -((bearing - 90) * Math.PI / 180);\n return threeRotation;\n}\n\nexport function rotationToBearing(quaternion: Quaternion) {\n const euler = new Euler().setFromQuaternion(quaternion);\n // Convert from radians to degrees and adjust coordinate systems\n const bearing = (360 - (euler.y * 180 / Math.PI - 90)) % 360;\n return bearing;\n}\n\nexport function objectDirectionToBearing(object) {\n const forward = new Vector3();\n object.getWorldDirection(forward);\n\n // Project onto the map's X-Z plane (ignore Y)\n const bearing = Math.atan2(forward.x, forward.z) * (180 / Math.PI);\n \n return bearing;\n}"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,IAAAC,KAAA,GAAAH,MAAA;AAAA,IAAAI,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAM/B,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAAmE,SAAAG,uBAAA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ireWildcard","require","THREE","_constants","_interopRequireDefault","_gsap","_GLTFLoader","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","projectToWorld","coords","projected","constants","MERCATOR_A","DEG2RAD","PROJECTION_WORLD_SIZE","Math","log","tan","PI","push","pixelsPerMeter","projectedUnitsPerMeter","result","Vector3","latitude","abs","WORLD_SIZE","cos","EARTH_CIRCUMFERENCE","unprojectFromWorld","worldUnits","unprojected","x","atan","exp","y","height","z","toDecimal","d","Number","toFixed","addModelsToMap","wrapper","map","models","modelMap","onModelsLoaded","Promise","resolve","reject","modelLoadPromises","_ref","id","modelUrl","rotation","scale","instanced","modelResolve","modelReject","loader","GLTFLoader","load","gltf","_modelMap$get$visible","_modelMap$get","model","scene","traverse","child","Mesh","Array","isArray","material","forEach","mat","side","DoubleSide","needsUpdate","worldPosition","position","up","visible","add","undefined","error","console","concat","addLayer","type","renderingMode","onAdd","all","then","res","catch","render","toggleModelVisibility","modelId","isVisible","isAnimating","isMesh","transparent","gsap","to","opacity","duration","ease","onComplete","bearingToRotation","bearing","threeRotation","rotationToBearing","quaternion","euler","Euler","setFromQuaternion","objectDirectionToBearing","object","forward","getWorldDirection","atan2"],"sources":["../../../../../../src/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.ts"],"sourcesContent":["import * as THREE from 'three';\nimport {Quaternion, Euler, Vector3, InstancedMesh, Object3D} from 'three';\nimport constants from './constants';\nimport { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';\nimport { LngLatLike } from 'maplibre-gl';\nimport { Position } from 'geojson';\nimport gsap from 'gsap';\nimport { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';\nimport { AmbientLight, DirectionalLight } from 'three';\nimport CustomThreeJSWrapper from '../CustomThreeJsWrapper.js';\n\nexport function projectToWorld(coords: Position) {\n var projected = [\n -constants.MERCATOR_A *\n constants.DEG2RAD *\n coords[0] *\n constants.PROJECTION_WORLD_SIZE,\n -constants.MERCATOR_A *\n Math.log(Math.tan(Math.PI * 0.25 + 0.5 * constants.DEG2RAD * coords[1])) *\n constants.PROJECTION_WORLD_SIZE,\n ];\n\n if (!coords[2]) projected.push(0);\n else {\n var pixelsPerMeter = projectedUnitsPerMeter(coords[1]);\n projected.push(coords[2] * pixelsPerMeter);\n }\n\n var result = new Vector3(projected[0], projected[1], projected[2]);\n\n return result;\n}\n\nfunction projectedUnitsPerMeter(latitude: number) {\n return Math.abs(\n constants.WORLD_SIZE /\n Math.cos(constants.DEG2RAD * latitude) /\n constants.EARTH_CIRCUMFERENCE\n );\n}\n\nexport function unprojectFromWorld(worldUnits: Vector3) {\n var unprojected = [\n -worldUnits.x /\n (constants.MERCATOR_A *\n constants.DEG2RAD *\n constants.PROJECTION_WORLD_SIZE),\n (2 *\n (Math.atan(\n Math.exp(\n worldUnits.y /\n (constants.PROJECTION_WORLD_SIZE * -constants.MERCATOR_A)\n )\n ) -\n Math.PI / 4)) /\n constants.DEG2RAD,\n ];\n\n var pixelsPerMeter = projectedUnitsPerMeter(unprojected[1]);\n\n // z dimension\n var height = worldUnits.z || 0;\n unprojected.push(height / pixelsPerMeter);\n\n return unprojected as LngLatLike;\n}\n\nexport function toDecimal (n, d) {\n return Number(n.toFixed(d));\n}\n\n// RF: TO BE REMOVED. ModelLoader component can be used to load 3D models.\nexport function addModelsToMap(wrapper, map, models, modelMap, onModelsLoaded) {\n return new Promise((resolve, reject) => {\n try {\n const modelLoadPromises = models.map(({ id, modelUrl, coords, rotation, scale, instanced }) => {\n return new Promise((modelResolve, modelReject) => {\n const loader = new GLTFLoader();\n loader.load(\n modelUrl,\n (gltf) => {\n const model = gltf.scene;\n model.traverse((child) => {\n if (child instanceof THREE.Mesh) {\n if (Array.isArray(child.material)) {\n child.material.forEach((mat) => {\n mat.side = THREE.DoubleSide;\n mat.needsUpdate = true;\n });\n } else {\n child.material.side = THREE.DoubleSide;\n child.material.needsUpdate = true;\n }\n }\n });\n \n const worldPosition = projectToWorld(coords);\n model.position.set(worldPosition.x, worldPosition.y, 0);\n model.up.set(0, 0, 1);\n model.rotation.set(rotation[0], rotation[1], rotation[2]);\n model.scale.set(scale[0], scale[1], scale[2]);\n model.visible = modelMap.get(id)?.visible ?? true;\n wrapper.add(model);\n modelMap.set(id, model);\n modelResolve(modelMap);\n },\n undefined,\n (error) => {\n console.error(`Error loading model ${id}:`, error);\n modelReject(error);\n }\n );\n });\n });\n\n map.addLayer({\n id: '3d-model-layer2',\n type: 'custom',\n renderingMode: '3d',\n onAdd: () => Promise.all(modelLoadPromises).then((res)=>{\n resolve(res);\n onModelsLoaded(true);\n }).catch(reject),\n render: () => {},\n });\n } catch (error) {\n reject(error);\n }\n });\n}\n\nexport function toggleModelVisibility(modelMap, modelId, isVisible) {\n const model = modelMap.get(modelId);\n if (!model) return;\n console.log('toggleModelVisibility_model', model);\n const isAnimating = {}; // Object to track animations\n model.traverse((child) => {\n if (child.isMesh) {\n const id = child.id; // Use unique child.id as the key\n child.material.transparent = true;\n if (!isAnimating[id]) {\n isAnimating[id] = true; // Set animation flag\n gsap.to(child.material, {\n opacity: isVisible ? 1 : 0,\n duration: 0.5, // Smooth fade animation\n ease: 'power2.inOut',\n onComplete: () => {\n isAnimating[id] = false; // Reset animation flag\n model.visible = isVisible;\n },\n });\n } else if (child.isMesh) {\n console.error(`GSAP Animation already running for child id ${id}!`);\n }\n }\n });\n if (isVisible) {\n model.visible = true;\n }\n}\n\nexport function bearingToRotation(bearing: number) {\n // Mapbox bearing is clockwise from north, Three.js rotation is counterclockwise from east\n const threeRotation = -((bearing - 90) * Math.PI / 180);\n return threeRotation;\n}\n\nexport function rotationToBearing(quaternion: Quaternion) {\n const euler = new Euler().setFromQuaternion(quaternion);\n // Convert from radians to degrees and adjust coordinate systems\n const bearing = (360 - (euler.y * 180 / Math.PI - 90)) % 360;\n return bearing;\n}\n\nexport function objectDirectionToBearing(object) {\n const forward = new Vector3();\n object.getWorldDirection(forward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,GAAG,GAAG,GAAGpB,IAAI,CAACG,EAAE,GAAG,EAAE,CAAC,IAAI,GAAG;EAC5D,OAAO4F,OAAO;AAChB;AAEO,SAASO,wBAAwBA,CAACC,MAAM,EAAE;EAC/C,MAAMC,OAAO,GAAG,IAAIhG,cAAO,CAAC,CAAC;EAC7B+F,MAAM,CAACE,iBAAiB,CAACD,OAAO,CAAC;;EAEjC;EACA,MAAMT,OAAO,GAAG/F,IAAI,CAAC0G,KAAK,CAACF,OAAO,CAACvF,CAAC,EAAEuF,OAAO,CAAClF,CAAC,CAAC,IAAI,GAAG,GAAGtB,IAAI,CAACG,EAAE,CAAC;EAElE,OAAO4F,OAAO;AAChB","ignoreList":[]}
@@ -12,9 +12,209 @@ var _utils = require("./CustomThreeJsWrapper/utility/utils.js");
12
12
  var _threeSpritetext = _interopRequireDefault(require("three-spritetext"));
13
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ 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; }
16
+ 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; }
17
+ 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; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
19
+ 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); }
15
20
  class MainMap {
16
- static mainInstance = null;
17
21
  constructor(metaAtlasCore) {
22
+ _defineProperty(this, "getAllPolygonCoordinates", () => {
23
+ const map = this.map;
24
+ if (!map) return [];
25
+ const polygonFeatures = [];
26
+ const source = map.getSource('custom');
27
+ if (source) {
28
+ const features = map.querySourceFeatures('custom', {
29
+ sourceLayer: 'geojson',
30
+ filter: ['==', ['geometry-type'], 'Polygon']
31
+ });
32
+ if (features && features.length > 0) {
33
+ features.forEach(feature => {
34
+ if ((feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') && feature.properties.dimension_what === 'what.booth') {
35
+ var _feature$properties;
36
+ polygonFeatures.push({
37
+ id: feature.properties.mapObjectId,
38
+ name: ((_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.title) || 'Unnamed Polygon',
39
+ coordinates: feature.geometry.coordinates,
40
+ properties: _objectSpread(_objectSpread({}, feature.properties), {}, {
41
+ hasImage: !!Math.round(Math.random())
42
+ })
43
+ });
44
+ }
45
+ });
46
+ }
47
+ }
48
+ return polygonFeatures;
49
+ });
50
+ _defineProperty(this, "updatePolygons", features => {
51
+ features.map(async feature => {
52
+ const coordinates = feature.geometry.coordinates;
53
+ // const centroid = feature.properties.center;
54
+ const polygon = turf.polygon(coordinates);
55
+ const centroid = turf.centroid(polygon).geometry.coordinates;
56
+ // const modelPosition = projectToWorld(centroid);
57
+
58
+ // const vertex1 = projectToWorld(coordinates[0][0]);
59
+ // const vertex2 = projectToWorld(coordinates[0][1]);
60
+ // const angle = vertex1.angleTo(vertex2);
61
+ // console.log(angle);
62
+
63
+ // await modelLoader.loadModel({
64
+ // modelPath: feature.properties.modelPath,
65
+ // feature,
66
+ // wrapper: wrapper.current!,
67
+ // onProgress: (progress) => {
68
+ // setLoadingProgress((prev) => ({
69
+ // ...prev,
70
+ // [feature.properties.id]: progress,
71
+ // }));
72
+ // },
73
+ // onError: (error) => {
74
+ // console.error(
75
+ // `Failed to load model ${feature.properties.id}:`,
76
+ // error
77
+ // );
78
+ // },
79
+ // });
80
+
81
+ if (!feature.properties.hasImage && feature.properties.dimension_where && feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor') {
82
+ const myText = new _threeSpritetext.default();
83
+ myText.color = 'black';
84
+ let text = feature.properties.title;
85
+ text = this.addNewLine(text);
86
+
87
+ // Set properties to configure:
88
+ myText.text = text;
89
+ myText.textHeight = 100;
90
+ // myText.textHeight = 1;
91
+ // myText.backgroundColor = '';
92
+ const textPosition = (0, _utils.projectToWorld)(centroid);
93
+ myText.rotation.x = Math.PI;
94
+ myText.rotation.y = Math.PI;
95
+ myText.scale.set(0.1, 0.1, 0.01);
96
+ myText.position.set(textPosition.x, textPosition.y,
97
+ // feature.properties.height > 0 ? 0.4 : 0.25
98
+ 0.1);
99
+ this.threebox.add(myText);
100
+ } else {
101
+ // Load Texture
102
+ // const textureLoader = new THREE.TextureLoader();
103
+ // textureLoader.load('/sk.png', (texture: THREE.Texture) => {
104
+ // // Create a plane geometry and material with the loaded texture
105
+ // const geometry = new THREE.PlaneGeometry(
106
+ // texture.image.width,
107
+ // texture.image.height
108
+ // );
109
+ // geometry.computeBoundingBox();
110
+ // const material = new THREE.MeshStandardMaterial({
111
+ // map: texture,
112
+ // transparent: true, // Enable transparency
113
+ // opacity: 1,
114
+ // });
115
+ // const plane = new THREE.Mesh(geometry, material);
116
+ // const group = new THREE.Group();
117
+ // const childContainer = new THREE.Group();
118
+ // childContainer.add(plane);
119
+ // childContainer.rotateZ(Math.PI / 2);
120
+ // childContainer.rotateZ(1);
121
+ // childContainer.updateMatrixWorld();
122
+ // group.add(childContainer);
123
+ // const geojsonbbox = turf.bbox(polygon);
124
+ // const bbox1 = new THREE.Box3(
125
+ // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),
126
+ // projectToWorld([geojsonbbox[0], geojsonbbox[1]])
127
+ // );
128
+ // const bbox2 = new THREE.Box3().setFromObject(plane);
129
+ // const size1 = new THREE.Vector3();
130
+ // bbox1.getSize(size1);
131
+ // size1.setZ(1);
132
+ // const size2 = new THREE.Vector3();
133
+ // bbox2.getSize(size2);
134
+ // size2.setZ(1);
135
+ // const ratio = size1.divide(size2);
136
+ // const ratioCopy = ratio.clone().multiplyScalar(0.85);
137
+ // plane.scale.set(
138
+ // plane.scale.x * ratioCopy.x,
139
+ // plane.scale.y * ratioCopy.y,
140
+ // plane.scale.z * ratioCopy.z
141
+ // );
142
+ // // // Set the position of the plane to the centroid
143
+ // group.position.set(modelPosition.x, modelPosition.y, 0.11);
144
+ // this.threebox.add(group);
145
+ // });
146
+ }
147
+ });
148
+ });
149
+ _defineProperty(this, "addLogo", (logo, position) => {
150
+ const textureLoader = new THREE.TextureLoader();
151
+ const texture = textureLoader.load(logo);
152
+
153
+ // Define rectangle dimensions
154
+ const width = 4;
155
+ const height = 0;
156
+ const depth = 2;
157
+
158
+ // Create a box geometry instead of cylinder
159
+ const geometry = new THREE.BoxGeometry(width, height, depth);
160
+
161
+ // Create materials: [right, left, top, bottom, front, back]
162
+ const sideMaterial = new THREE.MeshBasicMaterial({
163
+ color: new THREE.Color(0xffffff)
164
+ });
165
+ const topMaterial = new THREE.MeshStandardMaterial({
166
+ map: texture,
167
+ side: THREE.DoubleSide,
168
+ transparent: true
169
+ });
170
+
171
+ // Create an array of materials for each face of the box
172
+ const materials = [sideMaterial,
173
+ // right
174
+ sideMaterial,
175
+ // left
176
+ topMaterial,
177
+ // top (with logo texture)
178
+ sideMaterial,
179
+ // bottom
180
+ sideMaterial,
181
+ // front
182
+ sideMaterial // back
183
+ ];
184
+
185
+ // Create the mesh with geometry and materials
186
+ const logoMesh = new THREE.Mesh(geometry, materials);
187
+
188
+ // Adjust rotation to match your previous orientation
189
+ logoMesh.rotation.x = Math.PI / 2;
190
+ logoMesh.rotation.y = -Math.PI / 1.45;
191
+ logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);
192
+ this.threebox.add(logoMesh);
193
+ return logoMesh;
194
+ });
195
+ // Function to add text using Troika Text library at a specified position
196
+ _defineProperty(this, "addTitle", (title, position) => {
197
+ // Create a new Text instance
198
+ const textMesh = new _troikaThreeText.Text();
199
+
200
+ // Configure text properties
201
+ textMesh.text = title;
202
+ textMesh.fontSize = 0.2;
203
+ textMesh.color = 0x000000;
204
+ textMesh.anchorX = '50%';
205
+ textMesh.anchorY = 'bottom-baseline';
206
+ textMesh.fontWeight = 'bold';
207
+ textMesh.textAlign = 'center';
208
+ textMesh.position.set(position.x, position.y, position.z);
209
+ textMesh.rotation.z = -Math.PI / 1.45;
210
+
211
+ // Add text to the scene
212
+ this.threebox.add(textMesh);
213
+
214
+ // Update the text rendering
215
+ textMesh.sync();
216
+ return textMesh;
217
+ });
18
218
  if (MainMap.mainInstance) {
19
219
  return MainMap.mainInstance;
20
220
  }
@@ -62,206 +262,10 @@ class MainMap {
62
262
  getThreebox() {
63
263
  return this.threebox;
64
264
  }
65
- getAllPolygonCoordinates = () => {
66
- const map = this.map;
67
- if (!map) return [];
68
- const polygonFeatures = [];
69
- const source = map.getSource('custom');
70
- if (source) {
71
- const features = map.querySourceFeatures('custom', {
72
- sourceLayer: 'geojson',
73
- filter: ['==', ['geometry-type'], 'Polygon']
74
- });
75
- if (features && features.length > 0) {
76
- features.forEach(feature => {
77
- if ((feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') && feature.properties.dimension_what === 'what.booth') {
78
- polygonFeatures.push({
79
- id: feature.properties.mapObjectId,
80
- name: feature.properties?.title || 'Unnamed Polygon',
81
- coordinates: feature.geometry.coordinates,
82
- properties: {
83
- ...feature.properties,
84
- hasImage: !!Math.round(Math.random())
85
- }
86
- });
87
- }
88
- });
89
- }
90
- }
91
- return polygonFeatures;
92
- };
93
265
  addNewLine(input) {
94
266
  return input.replace(/ /g, '\r\n');
95
267
  }
96
- updatePolygons = features => {
97
- features.map(async feature => {
98
- const coordinates = feature.geometry.coordinates;
99
- // const centroid = feature.properties.center;
100
- const polygon = turf.polygon(coordinates);
101
- const centroid = turf.centroid(polygon).geometry.coordinates;
102
- // const modelPosition = projectToWorld(centroid);
103
-
104
- // const vertex1 = projectToWorld(coordinates[0][0]);
105
- // const vertex2 = projectToWorld(coordinates[0][1]);
106
- // const angle = vertex1.angleTo(vertex2);
107
- // console.log(angle);
108
-
109
- // await modelLoader.loadModel({
110
- // modelPath: feature.properties.modelPath,
111
- // feature,
112
- // wrapper: wrapper.current!,
113
- // onProgress: (progress) => {
114
- // setLoadingProgress((prev) => ({
115
- // ...prev,
116
- // [feature.properties.id]: progress,
117
- // }));
118
- // },
119
- // onError: (error) => {
120
- // console.error(
121
- // `Failed to load model ${feature.properties.id}:`,
122
- // error
123
- // );
124
- // },
125
- // });
126
-
127
- if (!feature.properties.hasImage && feature.properties.dimension_where && feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor') {
128
- const myText = new _threeSpritetext.default();
129
- myText.color = 'black';
130
- let text = feature.properties.title;
131
- text = this.addNewLine(text);
132
-
133
- // Set properties to configure:
134
- myText.text = text;
135
- myText.textHeight = 100;
136
- // myText.textHeight = 1;
137
- // myText.backgroundColor = '';
138
- const textPosition = (0, _utils.projectToWorld)(centroid);
139
- myText.rotation.x = Math.PI;
140
- myText.rotation.y = Math.PI;
141
- myText.scale.set(0.1, 0.1, 0.01);
142
- myText.position.set(textPosition.x, textPosition.y,
143
- // feature.properties.height > 0 ? 0.4 : 0.25
144
- 0.1);
145
- this.threebox.add(myText);
146
- } else {
147
- // Load Texture
148
- // const textureLoader = new THREE.TextureLoader();
149
- // textureLoader.load('/sk.png', (texture: THREE.Texture) => {
150
- // // Create a plane geometry and material with the loaded texture
151
- // const geometry = new THREE.PlaneGeometry(
152
- // texture.image.width,
153
- // texture.image.height
154
- // );
155
- // geometry.computeBoundingBox();
156
- // const material = new THREE.MeshStandardMaterial({
157
- // map: texture,
158
- // transparent: true, // Enable transparency
159
- // opacity: 1,
160
- // });
161
- // const plane = new THREE.Mesh(geometry, material);
162
- // const group = new THREE.Group();
163
- // const childContainer = new THREE.Group();
164
- // childContainer.add(plane);
165
- // childContainer.rotateZ(Math.PI / 2);
166
- // childContainer.rotateZ(1);
167
- // childContainer.updateMatrixWorld();
168
- // group.add(childContainer);
169
- // const geojsonbbox = turf.bbox(polygon);
170
- // const bbox1 = new THREE.Box3(
171
- // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),
172
- // projectToWorld([geojsonbbox[0], geojsonbbox[1]])
173
- // );
174
- // const bbox2 = new THREE.Box3().setFromObject(plane);
175
- // const size1 = new THREE.Vector3();
176
- // bbox1.getSize(size1);
177
- // size1.setZ(1);
178
- // const size2 = new THREE.Vector3();
179
- // bbox2.getSize(size2);
180
- // size2.setZ(1);
181
- // const ratio = size1.divide(size2);
182
- // const ratioCopy = ratio.clone().multiplyScalar(0.85);
183
- // plane.scale.set(
184
- // plane.scale.x * ratioCopy.x,
185
- // plane.scale.y * ratioCopy.y,
186
- // plane.scale.z * ratioCopy.z
187
- // );
188
- // // // Set the position of the plane to the centroid
189
- // group.position.set(modelPosition.x, modelPosition.y, 0.11);
190
- // this.threebox.add(group);
191
- // });
192
- }
193
- });
194
- };
195
- addLogo = (logo, position) => {
196
- const textureLoader = new THREE.TextureLoader();
197
- const texture = textureLoader.load(logo);
198
-
199
- // Define rectangle dimensions
200
- const width = 4;
201
- const height = 0;
202
- const depth = 2;
203
-
204
- // Create a box geometry instead of cylinder
205
- const geometry = new THREE.BoxGeometry(width, height, depth);
206
-
207
- // Create materials: [right, left, top, bottom, front, back]
208
- const sideMaterial = new THREE.MeshBasicMaterial({
209
- color: new THREE.Color(0xffffff)
210
- });
211
- const topMaterial = new THREE.MeshStandardMaterial({
212
- map: texture,
213
- side: THREE.DoubleSide,
214
- transparent: true
215
- });
216
-
217
- // Create an array of materials for each face of the box
218
- const materials = [sideMaterial,
219
- // right
220
- sideMaterial,
221
- // left
222
- topMaterial,
223
- // top (with logo texture)
224
- sideMaterial,
225
- // bottom
226
- sideMaterial,
227
- // front
228
- sideMaterial // back
229
- ];
230
-
231
- // Create the mesh with geometry and materials
232
- const logoMesh = new THREE.Mesh(geometry, materials);
233
-
234
- // Adjust rotation to match your previous orientation
235
- logoMesh.rotation.x = Math.PI / 2;
236
- logoMesh.rotation.y = -Math.PI / 1.45;
237
- logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);
238
- this.threebox.add(logoMesh);
239
- return logoMesh;
240
- };
241
-
242
- // Function to add text using Troika Text library at a specified position
243
- addTitle = (title, position) => {
244
- // Create a new Text instance
245
- const textMesh = new _troikaThreeText.Text();
246
-
247
- // Configure text properties
248
- textMesh.text = title;
249
- textMesh.fontSize = 0.2;
250
- textMesh.color = 0x000000;
251
- textMesh.anchorX = '50%';
252
- textMesh.anchorY = 'bottom-baseline';
253
- textMesh.fontWeight = 'bold';
254
- textMesh.textAlign = 'center';
255
- textMesh.position.set(position.x, position.y, position.z);
256
- textMesh.rotation.z = -Math.PI / 1.45;
257
-
258
- // Add text to the scene
259
- this.threebox.add(textMesh);
260
-
261
- // Update the text rendering
262
- textMesh.sync();
263
- return textMesh;
264
- };
265
268
  }
266
269
  exports.default = MainMap;
270
+ _defineProperty(MainMap, "mainInstance", null);
267
271
  //# sourceMappingURL=MainMap.js.map