@mapxus/mapxus-visual-jp 1.8.1 → 1.9.0

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 (425) hide show
  1. package/bitbucket-pipelines.yml +50 -0
  2. package/config/rollup.js +33 -0
  3. package/config/rollup.serve.config.js +3 -0
  4. package/debug/circlemarker.html +444 -0
  5. package/debug/create_tags.html +474 -0
  6. package/debug/distance.html +220 -0
  7. package/debug/index.html +92 -0
  8. package/debug/integration.html +1084 -0
  9. package/debug/leaflet.html +54 -0
  10. package/debug/markers.html +115 -0
  11. package/debug/multi_monitor_sync.html +377 -0
  12. package/debug/outdoor.html +1026 -0
  13. package/debug/rect_tags.html +147 -0
  14. package/debug/rotate.html +236 -0
  15. package/debug/sample.html +324 -0
  16. package/debug/sequence.html +75 -0
  17. package/debug/tags.html +218 -0
  18. package/package.json +34 -10
  19. package/rollup.config.js +39 -0
  20. package/server.js +35 -0
  21. package/spec/api/APIv3.spec.ts +86 -0
  22. package/spec/component/Component.spec.ts +68 -0
  23. package/spec/component/StatsComponent.spec.ts +33 -0
  24. package/spec/component/direction/DirectionComponent.spec.ts +163 -0
  25. package/spec/component/direction/DirectionDOMRenderer.spec.ts +233 -0
  26. package/spec/component/keyboard/KeyZoomHandler.spec.ts +236 -0
  27. package/spec/component/marker/Marker.spec.ts +104 -0
  28. package/spec/component/marker/MarkerComponent.spec.ts +88 -0
  29. package/spec/component/marker/MarkerScene.spec.ts +223 -0
  30. package/spec/component/marker/MarkerSet.spec.ts +453 -0
  31. package/spec/component/mouse/DoubleClickZoomHandler.spec.ts +211 -0
  32. package/spec/component/popup/Popup.spec.ts +479 -0
  33. package/spec/component/popup/PopupComponent.spec.ts +414 -0
  34. package/spec/component/tag/CreateHandlerBase.spec.ts +83 -0
  35. package/spec/component/tag/CreatePointHandler.spec.ts +190 -0
  36. package/spec/component/tag/OutlineRenderTag.spec.ts +91 -0
  37. package/spec/component/tag/PointGeometry.spec.ts +131 -0
  38. package/spec/component/tag/PolygonGeometry.spec.ts +497 -0
  39. package/spec/component/tag/RectGeometry.spec.ts +1157 -0
  40. package/spec/component/tag/TagComponent.spec.ts +513 -0
  41. package/spec/component/tag/TagScene.spec.ts +346 -0
  42. package/spec/component/tag/TagSet.spec.ts +241 -0
  43. package/spec/component/utils/HandlerBase.spec.ts +203 -0
  44. package/spec/geo/Camera.spec.ts +250 -0
  45. package/spec/geo/GeoCoords.spec.ts +364 -0
  46. package/spec/geo/Spatial.spec.ts +711 -0
  47. package/spec/geo/Transform.spec.ts +850 -0
  48. package/spec/geo/ViewportCoords.spec.ts +534 -0
  49. package/spec/graph/FilterCreator.spec.ts +892 -0
  50. package/spec/graph/Graph.spec.ts +2078 -0
  51. package/spec/graph/GraphCalculator.spec.ts +263 -0
  52. package/spec/graph/GraphService.spec.ts +663 -0
  53. package/spec/graph/Node.spec.ts +373 -0
  54. package/spec/graph/NodeCache.spec.ts +206 -0
  55. package/spec/graph/Sequence.spec.ts +37 -0
  56. package/spec/graph/edge/EdgeCalculator.Pano.spec.ts +963 -0
  57. package/spec/graph/edge/EdgeCalculator.Sequence.spec.ts +108 -0
  58. package/spec/graph/edge/EdgeCalculator.Similar.spec.ts +272 -0
  59. package/spec/graph/edge/EdgeCalculator.Step.spec.ts +383 -0
  60. package/spec/graph/edge/EdgeCalculator.Turn.spec.ts +278 -0
  61. package/spec/graph/edge/EdgeCalculator.spec.ts +747 -0
  62. package/spec/helper/ContainerMockCreator.spec.ts +33 -0
  63. package/spec/helper/DOMRendererMockCreator.spec.ts +22 -0
  64. package/spec/helper/EdgeCalculatorHelper.spec.ts +96 -0
  65. package/spec/helper/EventHelper.spec.ts +92 -0
  66. package/spec/helper/GLRendererMockCreator.spec.ts +23 -0
  67. package/spec/helper/GeoHelper.spec.ts +16 -0
  68. package/spec/helper/ImageLoadingServiceMockCreator.spec.ts +24 -0
  69. package/spec/helper/KeyboardServiceMockCreator.spec.ts +21 -0
  70. package/spec/helper/LoadingServiceMockCreator.spec.ts +21 -0
  71. package/spec/helper/MockCreator.spec.ts +18 -0
  72. package/spec/helper/MockCreatorBase.spec.ts +17 -0
  73. package/spec/helper/MouseServiceMockCreator.spec.ts +38 -0
  74. package/spec/helper/NavigatorMockCreator.spec.ts +28 -0
  75. package/spec/helper/NodeHelper.spec.ts +77 -0
  76. package/spec/helper/NodeMockCreator.spec.ts +19 -0
  77. package/spec/helper/RenderServiceMockCreator.spec.ts +25 -0
  78. package/spec/helper/SpriteServiceMockCreator.spec.ts +22 -0
  79. package/spec/helper/StateServiceMockCreator.spec.ts +33 -0
  80. package/spec/helper/TouchServiceMockCreator.spec.ts +29 -0
  81. package/spec/helper/TransformHelper.spec.ts +17 -0
  82. package/spec/render/DOMRenderer.spec.ts +112 -0
  83. package/spec/render/GLRenderer.spec.ts +453 -0
  84. package/spec/render/RenderCamera.spec.ts +535 -0
  85. package/spec/render/RenderService.spec.ts +531 -0
  86. package/spec/state/StateBase.spec.ts +369 -0
  87. package/spec/state/StateService.spec.ts +9 -0
  88. package/spec/state/TraversingState.spec.ts +262 -0
  89. package/spec/state/WaitingState.spec.ts +319 -0
  90. package/spec/tiles/TextureProvider.spec.ts +653 -0
  91. package/spec/utils/EventEmitter.spec.ts +71 -0
  92. package/spec/utils/Support.spec.ts +54 -0
  93. package/spec/viewer/CacheService.spec.ts +160 -0
  94. package/spec/viewer/ComponentController.spec.ts +310 -0
  95. package/spec/viewer/LoadingService.spec.ts +19 -0
  96. package/spec/viewer/MouseService.spec.ts +1344 -0
  97. package/spec/viewer/Navigator.spec.ts +970 -0
  98. package/spec/viewer/Observer.spec.ts +96 -0
  99. package/spec/viewer/SpriteService.spec.ts +224 -0
  100. package/src/API.ts +3 -0
  101. package/src/Component.ts +77 -0
  102. package/src/Edge.ts +6 -0
  103. package/src/Error.ts +3 -0
  104. package/src/FilterRender.ts +27 -0
  105. package/src/Geo.ts +7 -0
  106. package/src/Graph.ts +19 -0
  107. package/src/MapxusVisual.ts +66 -0
  108. package/src/Render.ts +7 -0
  109. package/src/State.ts +8 -0
  110. package/src/Support.ts +35 -0
  111. package/src/Tiles.ts +5 -0
  112. package/src/Utils.ts +6 -0
  113. package/src/Viewer.ts +16 -0
  114. package/src/api/API.ts +396 -0
  115. package/src/api/Auth.ts +76 -0
  116. package/src/api/AuthStore.ts +11 -0
  117. package/src/api/GraphQLCreator.ts +100 -0
  118. package/src/api/interfaces/IAuth.ts +7 -0
  119. package/src/api/interfaces/IBuildingBase.ts +7 -0
  120. package/src/api/interfaces/IBuildingInfo.ts +19 -0
  121. package/src/api/interfaces/ICoreNode.ts +28 -0
  122. package/src/api/interfaces/IFillNode.ts +96 -0
  123. package/src/api/interfaces/IFloorInfo.ts +10 -0
  124. package/src/api/interfaces/IFullNode.ts +10 -0
  125. package/src/api/interfaces/IGPano.ts +38 -0
  126. package/src/api/interfaces/IImageTagInfo.ts +14 -0
  127. package/src/api/interfaces/IKey.ts +13 -0
  128. package/src/api/interfaces/ILatLon.ts +19 -0
  129. package/src/api/interfaces/IOutdoor.ts +14 -0
  130. package/src/api/interfaces/IPathNode.ts +37 -0
  131. package/src/api/interfaces/IProject.ts +8 -0
  132. package/src/api/interfaces/IQueryBuilding.ts +37 -0
  133. package/src/api/interfaces/IResponse.ts +7 -0
  134. package/src/api/interfaces/ISequence.ts +16 -0
  135. package/src/api/interfaces/IUser.ts +13 -0
  136. package/src/api/interfaces/interfaces.ts +17 -0
  137. package/src/component/AttributionComponent.ts +48 -0
  138. package/src/component/BackgroundComponent.ts +39 -0
  139. package/src/component/BearingComponent.ts +282 -0
  140. package/src/component/CacheComponent.ts +295 -0
  141. package/src/component/Component.ts +130 -0
  142. package/src/component/ComponentService.ts +150 -0
  143. package/src/component/CoverComponent.ts +132 -0
  144. package/src/component/DebugComponent.ts +157 -0
  145. package/src/component/ImageComponent.ts +96 -0
  146. package/src/component/LoadingComponent.ts +85 -0
  147. package/src/component/NavigationComponent.ts +233 -0
  148. package/src/component/RouteComponent.ts +354 -0
  149. package/src/component/StatsComponent.ts +100 -0
  150. package/src/component/direction/DirectionComponent.ts +254 -0
  151. package/src/component/direction/DirectionDOMCalculator.ts +243 -0
  152. package/src/component/direction/DirectionDOMRenderer.ts +631 -0
  153. package/src/component/imageplane/ImagePlaneComponent.ts +497 -0
  154. package/src/component/imageplane/ImagePlaneFactory.ts +314 -0
  155. package/src/component/imageplane/ImagePlaneGLRenderer.ts +247 -0
  156. package/src/component/imageplane/ImagePlaneScene.ts +87 -0
  157. package/src/component/imageplane/ImagePlaneShaders.ts +16 -0
  158. package/src/component/imageplane/SliderComponent.ts +697 -0
  159. package/src/component/imageplane/interfaces/IBBoxShaderMaterial.ts +10 -0
  160. package/src/component/imageplane/interfaces/IShaderMaterial.ts +9 -0
  161. package/src/component/imageplane/interfaces/interfaces.ts +2 -0
  162. package/src/component/imageplane/shaders/equirectangular.fragment.glsl.ts +26 -0
  163. package/src/component/imageplane/shaders/equirectangular.vertex.glsl.ts +15 -0
  164. package/src/component/imageplane/shaders/perspective.fragment.glsl.ts +27 -0
  165. package/src/component/imageplane/shaders/perspective.vertex.glsl.ts +15 -0
  166. package/src/component/interfaces/ICacheConfiguration.ts +72 -0
  167. package/src/component/interfaces/IComponentConfiguration.ts +5 -0
  168. package/src/component/interfaces/ICoverConfiguration.ts +15 -0
  169. package/src/component/interfaces/IDirectionConfiguration.ts +63 -0
  170. package/src/component/interfaces/IImagePlaneConfiguration.ts +17 -0
  171. package/src/component/interfaces/IKeyboardConfiguration.ts +44 -0
  172. package/src/component/interfaces/IMarkerConfiguration.ts +31 -0
  173. package/src/component/interfaces/IMouseConfiguration.ts +52 -0
  174. package/src/component/interfaces/INavigationConfiguration.ts +35 -0
  175. package/src/component/interfaces/IRouteConfiguration.ts +20 -0
  176. package/src/component/interfaces/ISequenceConfiguration.ts +72 -0
  177. package/src/component/interfaces/IShader.ts +6 -0
  178. package/src/component/interfaces/ISliderConfiguration.ts +61 -0
  179. package/src/component/interfaces/ITagConfiguration.ts +40 -0
  180. package/src/component/interfaces/interfaces.ts +17 -0
  181. package/src/component/keyboard/KeySequenceNavigationHandler.ts +86 -0
  182. package/src/component/keyboard/KeySpatialNavigationHandler.ts +216 -0
  183. package/src/component/keyboard/KeyZoomHandler.ts +106 -0
  184. package/src/component/keyboard/KeyboardComponent.ts +125 -0
  185. package/src/component/marker/Marker.ts +5 -0
  186. package/src/component/marker/MarkerComponent.ts +856 -0
  187. package/src/component/marker/MarkerScene.ts +145 -0
  188. package/src/component/marker/MarkerSet.ts +142 -0
  189. package/src/component/marker/interfaces/IArrowMarkerOptions.ts +41 -0
  190. package/src/component/marker/interfaces/ICircleMarkerOptions.ts +30 -0
  191. package/src/component/marker/interfaces/IDotMarkerOptions.ts +18 -0
  192. package/src/component/marker/interfaces/IMarkerEvent.ts +28 -0
  193. package/src/component/marker/interfaces/ISimpleMarkerOptions.ts +54 -0
  194. package/src/component/marker/interfaces/interfaces.ts +5 -0
  195. package/src/component/marker/marker/ArrowMarker.ts +84 -0
  196. package/src/component/marker/marker/CircleMarker.ts +82 -0
  197. package/src/component/marker/marker/DotMarker.ts +68 -0
  198. package/src/component/marker/marker/ImageMarker.ts +45 -0
  199. package/src/component/marker/marker/Marker.ts +99 -0
  200. package/src/component/marker/marker/SimpleMarker.ts +187 -0
  201. package/src/component/mouse/BounceHandler.ts +148 -0
  202. package/src/component/mouse/DoubleClickZoomHandler.ts +106 -0
  203. package/src/component/mouse/DragPanHandler.ts +489 -0
  204. package/src/component/mouse/HandlerTypes.ts +13 -0
  205. package/src/component/mouse/MouseComponent.ts +170 -0
  206. package/src/component/mouse/ScrollZoomHandler.ts +137 -0
  207. package/src/component/mouse/TouchZoomHandler.ts +136 -0
  208. package/src/component/path/PathComponent.ts +75 -0
  209. package/src/component/path/PathEvent.ts +245 -0
  210. package/src/component/path/PathMarker.ts +42 -0
  211. package/src/component/path/PathRender.ts +163 -0
  212. package/src/component/popup/Popup.ts +2 -0
  213. package/src/component/popup/PopupComponent.ts +244 -0
  214. package/src/component/popup/interfaces/IPopupOffset.ts +37 -0
  215. package/src/component/popup/interfaces/IPopupOptions.ts +81 -0
  216. package/src/component/popup/popup/Popup.ts +594 -0
  217. package/src/component/popup/popup/PopupAlignment.ts +3 -0
  218. package/src/component/sequence/SequenceComponent.ts +500 -0
  219. package/src/component/sequence/SequenceDOMInteraction.ts +23 -0
  220. package/src/component/sequence/SequenceDOMRenderer.ts +179 -0
  221. package/src/component/tag/Tag.ts +9 -0
  222. package/src/component/tag/TagComponent.ts +787 -0
  223. package/src/component/tag/TagCreator.ts +138 -0
  224. package/src/component/tag/TagDOMRenderer.ts +35 -0
  225. package/src/component/tag/TagMode.ts +37 -0
  226. package/src/component/tag/TagOperation.ts +7 -0
  227. package/src/component/tag/TagScene.ts +216 -0
  228. package/src/component/tag/TagSet.ts +186 -0
  229. package/src/component/tag/error/GeometryTagError.ts +11 -0
  230. package/src/component/tag/geometry/Geometry.ts +62 -0
  231. package/src/component/tag/geometry/PointGeometry.ts +89 -0
  232. package/src/component/tag/geometry/PolygonGeometry.ts +349 -0
  233. package/src/component/tag/geometry/RectGeometry.ts +759 -0
  234. package/src/component/tag/geometry/VertexGeometry.ts +185 -0
  235. package/src/component/tag/handlers/CreateHandlerBase.ts +81 -0
  236. package/src/component/tag/handlers/CreatePointHandler.ts +35 -0
  237. package/src/component/tag/handlers/CreatePolygonHandler.ts +33 -0
  238. package/src/component/tag/handlers/CreateRectDragHandler.ts +199 -0
  239. package/src/component/tag/handlers/CreateRectHandler.ts +57 -0
  240. package/src/component/tag/handlers/CreateVertexHandler.ts +165 -0
  241. package/src/component/tag/handlers/EditVertexHandler.ts +275 -0
  242. package/src/component/tag/handlers/TagHandlerBase.ts +57 -0
  243. package/src/component/tag/interfaces/IInteraction.ts +14 -0
  244. package/src/component/tag/interfaces/IOutlineCreateTagOptions.ts +15 -0
  245. package/src/component/tag/interfaces/IOutlineTagOptions.ts +89 -0
  246. package/src/component/tag/interfaces/ISpotTagOptions.ts +37 -0
  247. package/src/component/tag/interfaces/interfaces.ts +4 -0
  248. package/src/component/tag/tag/OutlineCreateTag.ts +330 -0
  249. package/src/component/tag/tag/OutlineRenderTag.ts +569 -0
  250. package/src/component/tag/tag/OutlineTag.ts +380 -0
  251. package/src/component/tag/tag/RenderTag.ts +50 -0
  252. package/src/component/tag/tag/SpotRenderTag.ts +160 -0
  253. package/src/component/tag/tag/SpotTag.ts +170 -0
  254. package/src/component/tag/tag/Tag.ts +103 -0
  255. package/src/component/utils/HandlerBase.ts +71 -0
  256. package/src/error/ArgumentBeeviewError.ts +11 -0
  257. package/src/error/BeeviewError.ts +9 -0
  258. package/src/error/GraphBeeviewError.ts +11 -0
  259. package/src/geo/Camera.ts +149 -0
  260. package/src/geo/GeoCoords.ts +280 -0
  261. package/src/geo/GeoRBush.ts +25 -0
  262. package/src/geo/Spatial.ts +259 -0
  263. package/src/geo/Transform.ts +543 -0
  264. package/src/geo/ViewportCoords.ts +518 -0
  265. package/src/geo/interfaces/ILatLonAlt.ts +7 -0
  266. package/src/geo/interfaces/interfaces.ts +1 -0
  267. package/src/graph/FilterCreator.ts +106 -0
  268. package/src/graph/FilterExpression.ts +16 -0
  269. package/src/graph/Graph.ts +1516 -0
  270. package/src/graph/GraphCalculator.ts +197 -0
  271. package/src/graph/GraphService.ts +516 -0
  272. package/src/graph/ImageLoadingService.ts +44 -0
  273. package/src/graph/MeshReader.ts +19 -0
  274. package/src/graph/Node.ts +622 -0
  275. package/src/graph/NodeCache.ts +548 -0
  276. package/src/graph/Sequence.ts +117 -0
  277. package/src/graph/edge/EdgeCalculator.ts +919 -0
  278. package/src/graph/edge/EdgeCalculatorCoefficients.ts +43 -0
  279. package/src/graph/edge/EdgeCalculatorDirections.ts +80 -0
  280. package/src/graph/edge/EdgeCalculatorSettings.ts +61 -0
  281. package/src/graph/edge/EdgeDirection.ts +63 -0
  282. package/src/graph/edge/interfaces/IEdge.ts +26 -0
  283. package/src/graph/edge/interfaces/IEdgeData.ts +22 -0
  284. package/src/graph/edge/interfaces/IPano.ts +8 -0
  285. package/src/graph/edge/interfaces/IPotentialEdge.ts +106 -0
  286. package/src/graph/edge/interfaces/IStep.ts +7 -0
  287. package/src/graph/edge/interfaces/ITurn.ts +7 -0
  288. package/src/graph/edge/interfaces/interfaces.ts +6 -0
  289. package/src/graph/interfaces/IEdgeStatus.ts +25 -0
  290. package/src/graph/interfaces/IGraphConfiguration.ts +26 -0
  291. package/src/graph/interfaces/ILoadStatus.ts +18 -0
  292. package/src/graph/interfaces/ILoadStatusObject.ts +8 -0
  293. package/src/graph/interfaces/IMesh.ts +20 -0
  294. package/src/graph/interfaces/interfaces.ts +5 -0
  295. package/src/render/DOMRenderer.ts +288 -0
  296. package/src/render/GLRenderStage.ts +6 -0
  297. package/src/render/GLRenderer.ts +436 -0
  298. package/src/render/RenderCamera.ts +212 -0
  299. package/src/render/RenderMode.ts +34 -0
  300. package/src/render/RenderService.ts +264 -0
  301. package/src/render/interfaces/IGLRender.ts +10 -0
  302. package/src/render/interfaces/IGLRenderFunction.ts +10 -0
  303. package/src/render/interfaces/IGLRenderHash.ts +8 -0
  304. package/src/render/interfaces/ISize.ts +6 -0
  305. package/src/render/interfaces/IVNodeHash.ts +8 -0
  306. package/src/render/interfaces/interfaces.ts +5 -0
  307. package/src/state/FrameGenerator.ts +36 -0
  308. package/src/state/State.ts +6 -0
  309. package/src/state/StateContext.ts +180 -0
  310. package/src/state/StateService.ts +600 -0
  311. package/src/state/StateTransitionMatrix.ts +58 -0
  312. package/src/state/interfaces/ICurrentState.ts +21 -0
  313. package/src/state/interfaces/IFrame.ts +9 -0
  314. package/src/state/interfaces/IRotation.ts +6 -0
  315. package/src/state/interfaces/IState.ts +11 -0
  316. package/src/state/interfaces/IStateContext.ts +31 -0
  317. package/src/state/interfaces/interfaces.ts +5 -0
  318. package/src/state/states/StateBase.ts +425 -0
  319. package/src/state/states/TraversingState.ts +861 -0
  320. package/src/state/states/WaitingState.ts +109 -0
  321. package/src/tiles/ImageTileLoader.ts +121 -0
  322. package/src/tiles/ImageTileStore.ts +70 -0
  323. package/src/tiles/RegionOfInterestCalculator.ts +158 -0
  324. package/src/tiles/TextureProvider.ts +609 -0
  325. package/src/tiles/interfaces/IBoundingBox.ts +28 -0
  326. package/src/tiles/interfaces/IRegionOfInterest.ts +25 -0
  327. package/src/tiles/interfaces/interfaces.ts +2 -0
  328. package/src/utils/DOM.ts +28 -0
  329. package/src/utils/EventEmitter.ts +61 -0
  330. package/src/utils/Func.ts +3 -0
  331. package/src/utils/Settings.ts +39 -0
  332. package/src/utils/Support.ts +70 -0
  333. package/src/utils/Urls.ts +43 -0
  334. package/src/viewer/Alignment.ts +53 -0
  335. package/src/viewer/CacheService.ts +75 -0
  336. package/src/viewer/ComponentController.ts +237 -0
  337. package/src/viewer/Container.ts +100 -0
  338. package/src/viewer/EventNames.ts +192 -0
  339. package/src/viewer/ImageSize.ts +28 -0
  340. package/src/viewer/KeyboardService.ts +15 -0
  341. package/src/viewer/LoadingService.ts +66 -0
  342. package/src/viewer/MouseService.ts +541 -0
  343. package/src/viewer/Navigator.ts +362 -0
  344. package/src/viewer/Observer.ts +441 -0
  345. package/src/viewer/Projection.ts +162 -0
  346. package/src/viewer/SpriteService.ts +281 -0
  347. package/src/viewer/TouchService.ts +336 -0
  348. package/src/viewer/Viewer.ts +1132 -0
  349. package/src/viewer/interfaces/IComponentOptions.ts +176 -0
  350. package/src/viewer/interfaces/IMouseClaim.ts +6 -0
  351. package/src/viewer/interfaces/IMouseDeferPixels.ts +6 -0
  352. package/src/viewer/interfaces/IPinch.ts +81 -0
  353. package/src/viewer/interfaces/ISpriteAtlas.ts +12 -0
  354. package/src/viewer/interfaces/IUnprojection.ts +9 -0
  355. package/src/viewer/interfaces/IViewerMouseEvent.ts +56 -0
  356. package/src/viewer/interfaces/IViewerOptions.ts +88 -0
  357. package/src/viewer/interfaces/PointOfView.ts +19 -0
  358. package/src/viewer/interfaces/interfaces.ts +9 -0
  359. package/styles/AttributionComponent.css +26 -0
  360. package/styles/BackgroundComponent.css +21 -0
  361. package/styles/BearingComponent.css +48 -0
  362. package/styles/CoverComponent.css +169 -0
  363. package/styles/DebugComponent.css +28 -0
  364. package/styles/DirectionComponent.css +154 -0
  365. package/styles/LoadingComponent.css +14 -0
  366. package/styles/NavigationComponent.css +64 -0
  367. package/styles/NorthBg.png +0 -0
  368. package/styles/PopupComponent.css +188 -0
  369. package/styles/RouteComponent.css +21 -0
  370. package/styles/SequenceComponent.css +120 -0
  371. package/styles/SliderComponent.css +82 -0
  372. package/styles/TagComponent.css +105 -0
  373. package/styles/cover-logo.png +0 -0
  374. package/styles/mapillary-js.css +29 -0
  375. package/styles/pano-indicator.svg +3 -0
  376. package/styles/pano.svg +20 -0
  377. package/styles/pointer-wheat.svg +3 -0
  378. package/styles/pointer-white.svg +3 -0
  379. package/styles/spinner.svg +1 -0
  380. package/styles/stepper-left.svg +1 -0
  381. package/styles/stepper-play.svg +1 -0
  382. package/styles/stepper-right.svg +1 -0
  383. package/styles/stepper-stop.svg +1 -0
  384. package/styles/turn-around.svg +3 -0
  385. package/styles/turn.svg +3 -0
  386. package/tsconfig.json +28 -0
  387. package/tslint.json +81 -0
  388. package/types/graphql/index.d.ts +28 -0
  389. package/types/graphql/language/ast/index.d.ts +7 -0
  390. package/types/images/index.d.ts +7 -0
  391. package/types/pbf/index.d.ts +16 -0
  392. package/types/rbush/index.d.ts +28 -0
  393. package/version/beeview-0.1.0.css +2 -0
  394. package/version/beeview-0.1.0.js +1 -0
  395. package/version/beeview-0.1.1.css +2 -0
  396. package/version/beeview-0.1.1.js +1 -0
  397. package/version/beeview-0.1.2.css +2 -0
  398. package/version/beeview-0.1.2.js +1 -0
  399. package/version/beeview-0.2.0.css +2 -0
  400. package/version/beeview-0.2.0.js +1 -0
  401. package/version/beeview-0.2.1.css +2 -0
  402. package/version/beeview-0.2.1.js +1 -0
  403. package/version/beeview-0.3.0.css +2 -0
  404. package/version/beeview-0.3.0.js +1 -0
  405. package/version/beeview-0.4.0.css +2 -0
  406. package/version/beeview-0.4.0.js +1 -0
  407. package/version/beeview-0.4.1.css +2 -0
  408. package/version/beeview-0.4.1.js +1 -0
  409. package/version/mapxus-visual-1.0.0.css +2 -0
  410. package/version/mapxus-visual-1.0.0.js +1 -0
  411. package/version/mapxus-visual-1.1.0.css +2 -0
  412. package/version/mapxus-visual-1.1.0.js +1 -0
  413. package/version/mapxus-visual-1.1.1.css +2 -0
  414. package/version/mapxus-visual-1.1.1.js +1 -0
  415. package/version/mapxus-visual-1.1.2.css +2 -0
  416. package/version/mapxus-visual-1.1.2.js +1 -0
  417. package/version/mapxus-visual-1.2.0.css +2 -0
  418. package/version/mapxus-visual-1.2.0.js +1 -0
  419. package/version/mapxus-visual-1.3.0.css +2 -0
  420. package/version/mapxus-visual-1.3.0.js +1 -0
  421. package/LICENSE +0 -11
  422. package/README.md +0 -28
  423. package/index.css +0 -2
  424. package/index.d.ts +0 -163
  425. package/index.js +0 -1
@@ -0,0 +1,856 @@
1
+ import * as THREE from "three";
2
+ import {
3
+ Observable,
4
+ Subscription,
5
+ combineLatest,
6
+ of,
7
+ merge as observableMerge,
8
+ } from "rxjs";
9
+ import type { ILatLon } from "../../api/interfaces/interfaces";
10
+ import type { IMarkerEvent } from "./interfaces/interfaces";
11
+ import type { IMarkerConfiguration } from "../interfaces/interfaces";
12
+ import { Marker } from "./marker/Marker";
13
+ import { MarkerScene } from "./MarkerScene";
14
+ import { MarkerSet } from "./MarkerSet";
15
+ import { ComponentService } from "../ComponentService";
16
+ import { Component } from "../Component";
17
+ import type { IFrame } from "../../state/interfaces/interfaces";
18
+ import { Container } from "../../viewer/Container";
19
+ import { Navigator } from "../../viewer/Navigator";
20
+ import type { IGLRenderHash } from "../../render/interfaces/interfaces";
21
+ import { RenderCamera } from "../../render/RenderCamera";
22
+ import { GLRenderStage } from "../../render/GLRenderStage";
23
+ import { Node } from "../../graph/Node";
24
+ import { GraphCalculator } from "../../graph/GraphCalculator";
25
+ import type { ILatLonAlt } from "../../geo/interfaces/interfaces";
26
+ import { GeoCoords } from "../../geo/GeoCoords";
27
+ import { ViewportCoords } from "../../geo/ViewportCoords";
28
+ import {
29
+ first,
30
+ map,
31
+ refCount,
32
+ publishReplay,
33
+ distinctUntilChanged,
34
+ concat,
35
+ switchMap,
36
+ withLatestFrom,
37
+ skip,
38
+ startWith,
39
+ merge,
40
+ pairwise,
41
+ } from "rxjs/operators";
42
+
43
+ /**
44
+ * @class MarkerComponent
45
+ *
46
+ * @classdesc Component for showing and editing 3D marker objects.
47
+ *
48
+ * The `add` method is used for adding new markers or replacing
49
+ * markers already in the set.
50
+ *
51
+ * If a marker already in the set has the same
52
+ * id as one of the markers added, the old marker will be removed and
53
+ * the added marker will take its place.
54
+ *
55
+ * It is not possible to update markers in the set by updating any properties
56
+ * directly on the marker object. Markers need to be replaced by
57
+ * re-adding them for updates to geographic position or configuration
58
+ * to be reflected.
59
+ *
60
+ * Markers added to the marker component can be either interactive
61
+ * or non-interactive. Different marker types define their behavior.
62
+ * Markers with interaction support can be configured with options
63
+ * to respond to dragging inside the viewer and be detected when
64
+ * retrieving markers from pixel points with the `getMarkerIdAt` method.
65
+ *
66
+ * To retrive and use the marker component
67
+ *
68
+ * @example
69
+ * ```
70
+ * var viewer = new Beeview.Viewer(
71
+ * "<element-id>",
72
+ * "<client-id>",
73
+ * "<my key>",
74
+ * { component: { marker: true } });
75
+ *
76
+ * var markerComponent = viewer.getComponent("marker");
77
+ * ```
78
+ */
79
+ export class MarkerComponent extends Component<IMarkerConfiguration> {
80
+ public static componentName: string = "marker";
81
+
82
+ /**
83
+ * Fired when the position of a marker is changed.
84
+ * @event
85
+ * @type {IMarkerEvent} markerEvent - Marker event data.
86
+ * @example
87
+ * ```
88
+ * markerComponent.on("changed", function(e) {
89
+ * console.log(e.marker.id, e.marker.latLon);
90
+ * });
91
+ * ```
92
+ */
93
+ public static changed: string = "changed";
94
+
95
+ /**
96
+ * Fired when a marker drag interaction starts.
97
+ * @event
98
+ * @type {IMarkerEvent} markerEvent - Marker event data.
99
+ * @example
100
+ * ```
101
+ * markerComponent.on("dragstart", function(e) {
102
+ * console.log(e.marker.id, e.marker.latLon);
103
+ * });
104
+ * ```
105
+ */
106
+ public static dragstart: string = "dragstart";
107
+
108
+ /**
109
+ * Fired when a marker drag interaction ends.
110
+ * @event
111
+ * @type {IMarkerEvent} markerEvent - Marker event data.
112
+ * @example
113
+ * ```
114
+ * markerComponent.on("dragend", function(e) {
115
+ * console.log(e.marker.id, e.marker.latLon);
116
+ * });
117
+ * ```
118
+ */
119
+ public static dragend: string = "dragend";
120
+
121
+ private _relativeGroundAltitude: number;
122
+
123
+ private _geoCoords: GeoCoords;
124
+ private _graphCalculator: GraphCalculator;
125
+ private _markerScene: MarkerScene;
126
+ private _markerSet: MarkerSet;
127
+ private _viewportCoords: ViewportCoords;
128
+
129
+ private _adjustHeightSubscription: Subscription;
130
+ private _dragEventSubscription: Subscription;
131
+ private _markersUpdatedSubscription: Subscription;
132
+ private _mouseClaimSubscription: Subscription;
133
+ private _referenceSubscription: Subscription;
134
+ private _renderSubscription: Subscription;
135
+ private _setChangedSubscription: Subscription;
136
+ private _updateMarkerSubscription: Subscription;
137
+
138
+ private _mouseMove$: Observable<[MouseEvent, string]>;
139
+
140
+ constructor(name: string, container: Container, navigator: Navigator) {
141
+ super(name, container, navigator);
142
+
143
+ this._relativeGroundAltitude = -2;
144
+
145
+ this._geoCoords = new GeoCoords();
146
+ this._graphCalculator = new GraphCalculator();
147
+ this._markerScene = new MarkerScene();
148
+ this._markerSet = new MarkerSet();
149
+ this._viewportCoords = new ViewportCoords();
150
+ }
151
+
152
+ /**
153
+ * Marker hover event, mouse hover on the marker, return that id
154
+ *
155
+ * @returns {Observable<[MouseEvent, string]>}
156
+ */
157
+ public get mouseMove$(): Observable<[MouseEvent, string]> {
158
+ return this._mouseMove$;
159
+ }
160
+
161
+ /**
162
+ * Add markers to the marker set or replace markers in the marker set.
163
+ *
164
+ * @description If a marker already in the set has the same
165
+ * id as one of the markers added, the old marker will be removed
166
+ * the added marker will take its place.
167
+ *
168
+ * Any marker inside the visible bounding bbox
169
+ * will be initialized and placed in the viewer.
170
+ *
171
+ * @param {Array<Marker>} markers - Markers to add.
172
+ *
173
+ * @example ```markerComponent.add([marker1, marker2]);```
174
+ */
175
+ public add(markers: Marker[]): void {
176
+ this._markerSet.add(markers);
177
+ }
178
+
179
+ /**
180
+ * Returns the marker in the marker set with the specified id, or
181
+ * undefined if the id matches no marker.
182
+ *
183
+ * @param {string} markerId - Id of the marker.
184
+ *
185
+ * @example ```var marker = markerComponent.get("markerId");```
186
+ *
187
+ */
188
+ public get(markerId: string): Marker {
189
+ return this._markerSet.get(markerId);
190
+ }
191
+
192
+ /**
193
+ * Returns an array of all markers.
194
+ *
195
+ * @example ```var markers = markerComponent.getAll();```
196
+ */
197
+ public getAll(): Marker[] {
198
+ return this._markerSet.getAll();
199
+ }
200
+
201
+ /**
202
+ * Returns the id of the interactive marker closest to the current camera
203
+ * position at the specified point.
204
+ *
205
+ * @description Notice that the pixelPoint argument requires x, y
206
+ * coordinates from pixel space.
207
+ *
208
+ * With this function, you can use the coordinates provided by mouse
209
+ * events to get information out of the marker component.
210
+ *
211
+ * If no interactive geometry of an interactive marker exist at the pixel
212
+ * point, `null` will be returned.
213
+ *
214
+ * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
215
+ * @returns {string} Id of the interactive marker closest to the camera. If no
216
+ * interactive marker exist at the pixel point, `null` will be returned.
217
+ *
218
+ * @example
219
+ * ```
220
+ * markerComponent.getMarkerIdAt([100, 100])
221
+ * .then((markerId) => { console.log(markerId); });
222
+ * ```
223
+ */
224
+ public getMarkerIdAt(pixelPoint: number[]): Promise<string> {
225
+ return new Promise<string>(
226
+ (
227
+ resolve: (value: string) => void,
228
+ reject: (reason: Error) => void,
229
+ ): void => {
230
+ this._container.renderService.renderCamera$
231
+ .pipe(
232
+ first(),
233
+ map((render: RenderCamera): string => {
234
+ const viewport: number[] =
235
+ this._viewportCoords.canvasToViewport(
236
+ pixelPoint[0],
237
+ pixelPoint[1],
238
+ this._container.element,
239
+ );
240
+
241
+ const id: string =
242
+ this._markerScene.intersectObjects(
243
+ viewport,
244
+ render.perspective,
245
+ );
246
+
247
+ return id;
248
+ }),
249
+ )
250
+ .subscribe(
251
+ (id: string): void => {
252
+ resolve(id);
253
+ },
254
+ (error: Error): void => {
255
+ reject(error);
256
+ },
257
+ );
258
+ },
259
+ );
260
+ }
261
+
262
+ /**
263
+ * Check if a marker exist in the marker set.
264
+ *
265
+ * @param {string} markerId - Id of the marker.
266
+ *
267
+ * @example ```var markerExists = markerComponent.has("markerId");```
268
+ */
269
+ public has(markerId: string): boolean {
270
+ return this._markerSet.has(markerId);
271
+ }
272
+
273
+ /**
274
+ * Remove markers with the specified ids from the marker set.
275
+ *
276
+ * @param {Array<string>} markerIds - Ids for markers to remove.
277
+ *
278
+ * @example ```markerComponent.remove(["id-1", "id-2"]);```
279
+ */
280
+ public remove(markerIds: string[]): void {
281
+ this._markerSet.remove(markerIds);
282
+ }
283
+
284
+ /**
285
+ * Remove all markers from the marker set.
286
+ *
287
+ * @example ```markerComponent.removeAll();```
288
+ */
289
+ public removeAll(): void {
290
+ this._markerSet.removeAll();
291
+ }
292
+
293
+ protected _activate(): void {
294
+ const groundAltitude$: Observable<number> =
295
+ this._navigator.stateService.currentState$.pipe(
296
+ map((frame: IFrame): number => {
297
+ return (
298
+ frame.state.camera.position.z +
299
+ this._relativeGroundAltitude
300
+ );
301
+ }),
302
+ distinctUntilChanged((a1: number, a2: number): boolean => {
303
+ return Math.abs(a1 - a2) < 0.01;
304
+ }),
305
+ publishReplay(1),
306
+ refCount(),
307
+ );
308
+
309
+ const geoInitiated$: Observable<void> = combineLatest(
310
+ groundAltitude$,
311
+ this._navigator.stateService.reference$,
312
+ ).pipe(
313
+ first(),
314
+ map((): void => {
315
+ /* noop */
316
+ }),
317
+ publishReplay(1),
318
+ refCount(),
319
+ );
320
+
321
+ const clampedConfiguration$: Observable<IMarkerConfiguration> =
322
+ this._configuration$.pipe(
323
+ map(
324
+ (
325
+ configuration: IMarkerConfiguration,
326
+ ): IMarkerConfiguration => {
327
+ return {
328
+ visibleBBoxSize: Math.max(
329
+ 1,
330
+ Math.min(200, configuration.visibleBBoxSize),
331
+ ),
332
+ };
333
+ },
334
+ ),
335
+ );
336
+
337
+ const currentlatLon$: Observable<ILatLon> =
338
+ this._navigator.stateService.currentNode$.pipe(
339
+ map((node: Node): ILatLon => {
340
+ return node.latLon;
341
+ }),
342
+ publishReplay(1),
343
+ refCount(),
344
+ );
345
+
346
+ const visibleBBox$: Observable<[ILatLon, ILatLon]> = combineLatest(
347
+ clampedConfiguration$,
348
+ currentlatLon$,
349
+ ).pipe(
350
+ map(
351
+ ([configuration, latLon]: [IMarkerConfiguration, ILatLon]): [
352
+ ILatLon,
353
+ ILatLon,
354
+ ] => {
355
+ return this._graphCalculator.boundingBoxCorners(
356
+ latLon,
357
+ configuration.visibleBBoxSize / 2,
358
+ );
359
+ },
360
+ ),
361
+ publishReplay(1),
362
+ refCount(),
363
+ );
364
+
365
+ const visibleMarkers$: Observable<Marker[]> = combineLatest(
366
+ of<MarkerSet>(this._markerSet).pipe(
367
+ concat(this._markerSet.changed$),
368
+ ),
369
+ visibleBBox$,
370
+ ).pipe(
371
+ map(([set, bbox]: [MarkerSet, [ILatLon, ILatLon]]): Marker[] => {
372
+ return set.search(bbox);
373
+ }),
374
+ );
375
+
376
+ this._setChangedSubscription = geoInitiated$
377
+ .pipe(
378
+ switchMap((): Observable<[Marker[], ILatLonAlt, number]> => {
379
+ return visibleMarkers$.pipe(
380
+ withLatestFrom(
381
+ this._navigator.stateService.reference$,
382
+ groundAltitude$,
383
+ ),
384
+ );
385
+ }),
386
+ )
387
+ .subscribe(
388
+ ([markers, reference, alt]: [
389
+ Marker[],
390
+ ILatLonAlt,
391
+ number,
392
+ ]): void => {
393
+ const geoCoords: GeoCoords = this._geoCoords;
394
+ const markerScene: MarkerScene = this._markerScene;
395
+ const sceneMarkers: { [id: string]: Marker } =
396
+ markerScene.markers;
397
+ const markersToRemove: { [id: string]: Marker } =
398
+ Object.assign({}, sceneMarkers);
399
+
400
+ for (const marker of markers) {
401
+ if (marker.id in sceneMarkers) {
402
+ delete markersToRemove[marker.id];
403
+ } else {
404
+ const point3d: number[] = geoCoords.geodeticToEnu(
405
+ marker.latLon.lat,
406
+ marker.latLon.lon,
407
+ reference.alt + alt,
408
+ reference.lat,
409
+ reference.lon,
410
+ reference.alt,
411
+ );
412
+
413
+ markerScene.add(marker, point3d);
414
+ }
415
+ }
416
+
417
+ for (const id in markersToRemove) {
418
+ if (!markersToRemove.hasOwnProperty(id)) {
419
+ continue;
420
+ }
421
+
422
+ markerScene.remove(id);
423
+ }
424
+ },
425
+ );
426
+
427
+ this._markersUpdatedSubscription = geoInitiated$
428
+ .pipe(
429
+ switchMap(
430
+ (): Observable<
431
+ [Marker[], [ILatLon, ILatLon], ILatLonAlt, number]
432
+ > => {
433
+ return this._markerSet.updated$.pipe(
434
+ withLatestFrom(
435
+ visibleBBox$,
436
+ this._navigator.stateService.reference$,
437
+ groundAltitude$,
438
+ ),
439
+ );
440
+ },
441
+ ),
442
+ )
443
+ .subscribe(
444
+ ([markers, [sw, ne], reference, alt]: [
445
+ Marker[],
446
+ [ILatLon, ILatLon],
447
+ ILatLonAlt,
448
+ number,
449
+ ]): void => {
450
+ const geoCoords: GeoCoords = this._geoCoords;
451
+ const markerScene: MarkerScene = this._markerScene;
452
+
453
+ for (const marker of markers) {
454
+ const exists: boolean = markerScene.has(marker.id);
455
+ const visible: boolean =
456
+ marker.latLon.lat > sw.lat &&
457
+ marker.latLon.lat < ne.lat &&
458
+ marker.latLon.lon > sw.lon &&
459
+ marker.latLon.lon < ne.lon;
460
+
461
+ if (visible) {
462
+ const point3d: number[] = geoCoords.geodeticToEnu(
463
+ marker.latLon.lat,
464
+ marker.latLon.lon,
465
+ reference.alt + alt,
466
+ reference.lat,
467
+ reference.lon,
468
+ reference.alt,
469
+ );
470
+
471
+ markerScene.add(marker, point3d);
472
+ } else if (!visible && exists) {
473
+ markerScene.remove(marker.id);
474
+ }
475
+ }
476
+ },
477
+ );
478
+
479
+ this._referenceSubscription = this._navigator.stateService.reference$
480
+ .pipe(skip(1), withLatestFrom(groundAltitude$))
481
+ .subscribe(([reference, alt]: [ILatLonAlt, number]): void => {
482
+ const geoCoords: GeoCoords = this._geoCoords;
483
+ const markerScene: MarkerScene = this._markerScene;
484
+
485
+ for (const marker of markerScene.getAll()) {
486
+ const point3d: number[] = geoCoords.geodeticToEnu(
487
+ marker.latLon.lat,
488
+ marker.latLon.lon,
489
+ reference.alt + alt,
490
+ reference.lat,
491
+ reference.lon,
492
+ reference.alt,
493
+ );
494
+
495
+ markerScene.update(marker.id, point3d);
496
+ }
497
+ });
498
+
499
+ this._adjustHeightSubscription = groundAltitude$
500
+ .pipe(
501
+ skip(1),
502
+ withLatestFrom(
503
+ this._navigator.stateService.reference$,
504
+ currentlatLon$,
505
+ ),
506
+ )
507
+ .subscribe(
508
+ ([alt, reference, latLon]: [
509
+ number,
510
+ ILatLonAlt,
511
+ ILatLon,
512
+ ]): void => {
513
+ const geoCoords: GeoCoords = this._geoCoords;
514
+ const markerScene: MarkerScene = this._markerScene;
515
+
516
+ const position: number[] = geoCoords.geodeticToEnu(
517
+ latLon.lat,
518
+ latLon.lon,
519
+ reference.alt + alt,
520
+ reference.lat,
521
+ reference.lon,
522
+ reference.alt,
523
+ );
524
+
525
+ for (const marker of markerScene.getAll()) {
526
+ const point3d: number[] = geoCoords.geodeticToEnu(
527
+ marker.latLon.lat,
528
+ marker.latLon.lon,
529
+ reference.alt + alt,
530
+ reference.lat,
531
+ reference.lon,
532
+ reference.alt,
533
+ );
534
+
535
+ const distanceX: number = point3d[0] - position[0];
536
+ const distanceY: number = point3d[1] - position[1];
537
+
538
+ const groundDistance: number = Math.sqrt(
539
+ distanceX * distanceX + distanceY * distanceY,
540
+ );
541
+ if (groundDistance > 50) {
542
+ continue;
543
+ }
544
+
545
+ markerScene.lerpAltitude(
546
+ marker.id,
547
+ alt,
548
+ Math.min(
549
+ 1,
550
+ Math.max(0, 1.2 - (1.2 * groundDistance) / 50),
551
+ ),
552
+ );
553
+ }
554
+ },
555
+ );
556
+
557
+ this._renderSubscription = this._navigator.stateService.currentState$
558
+ .pipe(
559
+ map((frame: IFrame): IGLRenderHash => {
560
+ const scene: MarkerScene = this._markerScene;
561
+
562
+ return {
563
+ name: this._name,
564
+ render: {
565
+ frameId: frame.id,
566
+ needsRender: scene.needsRender,
567
+ render: scene.render.bind(scene),
568
+ stage: GLRenderStage.Foreground,
569
+ },
570
+ };
571
+ }),
572
+ )
573
+ .subscribe(this._container.glRenderer.render$);
574
+
575
+ this._mouseMove$ = combineLatest(
576
+ this._container.renderService.renderCamera$,
577
+ this._container.mouseService.mouseMove$,
578
+ ).pipe(
579
+ map(
580
+ ([render, event]: [RenderCamera, MouseEvent]): [
581
+ MouseEvent,
582
+ string,
583
+ ] => {
584
+ const element: HTMLElement = this._container.element;
585
+ const [canvasX, canvasY]: number[] =
586
+ this._viewportCoords.canvasPosition(event, element);
587
+ const viewport: number[] =
588
+ this._viewportCoords.canvasToViewport(
589
+ canvasX,
590
+ canvasY,
591
+ element,
592
+ );
593
+
594
+ const markerId: string = this._markerScene.intersectObjects(
595
+ viewport,
596
+ render.perspective,
597
+ );
598
+ return [event, markerId];
599
+ },
600
+ ),
601
+ publishReplay(1),
602
+ refCount(),
603
+ );
604
+
605
+ const hoveredMarkerId$: Observable<string> = this._mouseMove$.pipe(
606
+ map(([event, markerId]: [MouseEvent, string]): string => {
607
+ return markerId;
608
+ }),
609
+ publishReplay(1),
610
+ refCount(),
611
+ );
612
+
613
+ const draggingStarted$: Observable<boolean> =
614
+ this._container.mouseService
615
+ .filtered$(
616
+ this._name,
617
+ this._container.mouseService.mouseDragStart$,
618
+ )
619
+ .pipe(
620
+ map((event: MouseEvent): boolean => {
621
+ return true;
622
+ }),
623
+ );
624
+
625
+ const draggingStopped$: Observable<boolean> =
626
+ this._container.mouseService
627
+ .filtered$(
628
+ this._name,
629
+ this._container.mouseService.mouseDragEnd$,
630
+ )
631
+ .pipe(
632
+ map((event: Event): boolean => {
633
+ return false;
634
+ }),
635
+ );
636
+
637
+ const filteredDragging$: Observable<boolean> = observableMerge(
638
+ draggingStarted$,
639
+ draggingStopped$,
640
+ ).pipe(startWith(false));
641
+
642
+ this._dragEventSubscription = draggingStarted$
643
+ .pipe(
644
+ withLatestFrom(hoveredMarkerId$),
645
+ merge(combineLatest(draggingStopped$, of<string>(null))),
646
+ startWith([false, null]),
647
+ pairwise(),
648
+ )
649
+ .subscribe(
650
+ ([previous, current]: any | [boolean, string][]): void => {
651
+ const dragging: boolean = current[0];
652
+ const eventType: string = dragging
653
+ ? MarkerComponent.dragstart
654
+ : MarkerComponent.dragend;
655
+ const id: string = dragging ? current[1] : previous[1];
656
+ const marker: Marker = this._markerScene.get(id);
657
+ const markerEvent: IMarkerEvent = {
658
+ marker: marker,
659
+ target: this,
660
+ type: eventType,
661
+ };
662
+
663
+ this.fire(eventType, markerEvent);
664
+ },
665
+ );
666
+
667
+ const mouseDown$: Observable<boolean> = observableMerge(
668
+ this._container.mouseService.mouseDown$.pipe(
669
+ map((event: MouseEvent): boolean => {
670
+ return true;
671
+ }),
672
+ ),
673
+ this._container.mouseService.documentMouseUp$.pipe(
674
+ map((event: MouseEvent): boolean => {
675
+ return false;
676
+ }),
677
+ ),
678
+ ).pipe(startWith(false));
679
+
680
+ this._mouseClaimSubscription = combineLatest(
681
+ this._container.mouseService.active$,
682
+ hoveredMarkerId$.pipe(distinctUntilChanged()),
683
+ mouseDown$,
684
+ filteredDragging$,
685
+ )
686
+ .pipe(
687
+ map(
688
+ ([active, markerId, mouseDown, filteredDragging]: [
689
+ boolean,
690
+ string,
691
+ boolean,
692
+ boolean,
693
+ ]): boolean => {
694
+ return (
695
+ (!active && markerId != null && mouseDown) ||
696
+ filteredDragging
697
+ );
698
+ },
699
+ ),
700
+ distinctUntilChanged(),
701
+ )
702
+ .subscribe((claim: boolean): void => {
703
+ if (claim) {
704
+ this._container.mouseService.claimMouse(this._name, 1);
705
+ this._container.mouseService.claimWheel(this._name, 1);
706
+ } else {
707
+ this._container.mouseService.unclaimMouse(this._name);
708
+ this._container.mouseService.unclaimWheel(this._name);
709
+ }
710
+ });
711
+
712
+ const offset$: Observable<[Marker, number[], RenderCamera]> =
713
+ this._container.mouseService
714
+ .filtered$(
715
+ this._name,
716
+ this._container.mouseService.mouseDragStart$,
717
+ )
718
+ .pipe(
719
+ withLatestFrom(
720
+ hoveredMarkerId$,
721
+ this._container.renderService.renderCamera$,
722
+ ),
723
+ map(
724
+ ([e, id, r]: [MouseEvent, string, RenderCamera]): [
725
+ Marker,
726
+ number[],
727
+ RenderCamera,
728
+ ] => {
729
+ const marker: Marker = this._markerScene.get(id);
730
+ const element: HTMLElement =
731
+ this._container.element;
732
+ const [groundCanvasX, groundCanvasY]: number[] =
733
+ this._viewportCoords.projectToCanvas(
734
+ marker.geometry.position.toArray(),
735
+ element,
736
+ r.perspective,
737
+ );
738
+ const [canvasX, canvasY]: number[] =
739
+ this._viewportCoords.canvasPosition(e, element);
740
+ const offset: number[] = [
741
+ canvasX - groundCanvasX,
742
+ canvasY - groundCanvasY,
743
+ ];
744
+ return [marker, offset, r];
745
+ },
746
+ ),
747
+ publishReplay(1),
748
+ refCount(),
749
+ );
750
+
751
+ this._updateMarkerSubscription = this._container.mouseService
752
+ .filtered$(this._name, this._container.mouseService.mouseDrag$)
753
+ .pipe(
754
+ withLatestFrom(
755
+ offset$,
756
+ this._navigator.stateService.reference$,
757
+ clampedConfiguration$,
758
+ ),
759
+ )
760
+ .subscribe(
761
+ ([event, [marker, offset, render], reference, configuration]: [
762
+ MouseEvent,
763
+ [Marker, number[], RenderCamera],
764
+ ILatLonAlt,
765
+ IMarkerConfiguration,
766
+ ]): void => {
767
+ if (!this._markerScene.has(marker.id)) {
768
+ return;
769
+ }
770
+
771
+ const element: HTMLElement = this._container.element;
772
+ const [canvasX, canvasY]: number[] =
773
+ this._viewportCoords.canvasPosition(event, element);
774
+
775
+ const groundX: number = canvasX - offset[0];
776
+ const groundY: number = canvasY - offset[1];
777
+
778
+ const [viewportX, viewportY]: number[] =
779
+ this._viewportCoords.canvasToViewport(
780
+ groundX,
781
+ groundY,
782
+ element,
783
+ );
784
+
785
+ const direction: THREE.Vector3 = new THREE.Vector3(
786
+ viewportX,
787
+ viewportY,
788
+ 1,
789
+ )
790
+ .unproject(render.perspective)
791
+ .sub(render.perspective.position)
792
+ .normalize();
793
+
794
+ const distance: number = Math.min(
795
+ this._relativeGroundAltitude / direction.z,
796
+ configuration.visibleBBoxSize / 2 - 0.1,
797
+ );
798
+
799
+ if (distance < 0) {
800
+ return;
801
+ }
802
+
803
+ const intersection: THREE.Vector3 = direction
804
+ .clone()
805
+ .multiplyScalar(distance)
806
+ .add(render.perspective.position);
807
+
808
+ intersection.z =
809
+ render.perspective.position.z +
810
+ this._relativeGroundAltitude;
811
+
812
+ const [lat, lon]: number[] = this._geoCoords.enuToGeodetic(
813
+ intersection.x,
814
+ intersection.y,
815
+ intersection.z,
816
+ reference.lat,
817
+ reference.lon,
818
+ reference.alt,
819
+ );
820
+
821
+ this._markerScene.update(
822
+ marker.id,
823
+ intersection.toArray(),
824
+ { lat: lat, lon: lon },
825
+ );
826
+ this._markerSet.update(marker);
827
+
828
+ const markerEvent: IMarkerEvent = {
829
+ marker: marker,
830
+ target: this,
831
+ type: MarkerComponent.changed,
832
+ };
833
+ this.fire(MarkerComponent.changed, markerEvent);
834
+ },
835
+ );
836
+ }
837
+
838
+ protected _deactivate(): void {
839
+ this._adjustHeightSubscription.unsubscribe();
840
+ this._dragEventSubscription.unsubscribe();
841
+ this._markersUpdatedSubscription.unsubscribe();
842
+ this._mouseClaimSubscription.unsubscribe();
843
+ this._referenceSubscription.unsubscribe();
844
+ this._renderSubscription.unsubscribe();
845
+ this._setChangedSubscription.unsubscribe();
846
+ this._updateMarkerSubscription.unsubscribe();
847
+
848
+ this._markerScene.clear();
849
+ }
850
+
851
+ protected _getDefaultConfiguration(): IMarkerConfiguration {
852
+ return { visibleBBoxSize: 100 };
853
+ }
854
+ }
855
+
856
+ export default MarkerComponent;