@openglobus/og 0.17.2 → 0.18.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 (490) hide show
  1. package/README.md +75 -46
  2. package/dist/@openglobus/og.esm.js +1 -20
  3. package/dist/@openglobus/og.esm.js.map +1 -1
  4. package/dist/@openglobus/og.umd.js +1 -20
  5. package/dist/@openglobus/og.umd.js.map +1 -1
  6. package/dist/@openglobus/res/fonts/Karla-Bold.json +5252 -0
  7. package/dist/@openglobus/res/fonts/Karla-Bold.ttf.cfg +920 -0
  8. package/dist/@openglobus/res/fonts/Karla-Bold.ttf.png +0 -0
  9. package/dist/@openglobus/res/fonts/Karla-Light.json +5252 -0
  10. package/dist/@openglobus/res/fonts/Karla-Light.ttf.cfg +830 -0
  11. package/dist/@openglobus/res/fonts/Karla-Light.ttf.png +0 -0
  12. package/dist/@openglobus/res/fonts/Karla-Medium.json +5252 -0
  13. package/dist/@openglobus/res/fonts/Karla-Medium.ttf.cfg +1196 -0
  14. package/dist/@openglobus/res/fonts/Karla-Medium.ttf.png +0 -0
  15. package/dist/@openglobus/res/fonts/NotoSansArabic-Regular.json +3332 -0
  16. package/dist/@openglobus/res/fonts/NotoSansArabic-Regular.ttf.cfg +1370 -0
  17. package/dist/@openglobus/res/fonts/NotoSansArabic-Regular.ttf.png +0 -0
  18. package/dist/@openglobus/res/fonts/Roboto-Regular.json +37147 -0
  19. package/dist/@openglobus/res/fonts/Roboto-Regular.ttf.cfg +1340 -0
  20. package/dist/@openglobus/res/fonts/Roboto-Regular.ttf.png +0 -0
  21. package/dist/@openglobus/res/fonts/arial.json +4321 -0
  22. package/dist/@openglobus/res/fonts/arial.ttf.cfg +1570 -0
  23. package/dist/@openglobus/res/fonts/arial.ttf.png +0 -0
  24. package/dist/@openglobus/res/night-4326.png +0 -0
  25. package/dist/@openglobus/res/night.png +0 -0
  26. package/dist/@openglobus/res/spec.png +0 -0
  27. package/package.json +25 -23
  28. package/src/{og/Clock.js → Clock.ts} +100 -78
  29. package/src/Deferred.ts +17 -0
  30. package/src/Events.ts +200 -0
  31. package/src/{og/Extent.js → Extent.ts} +324 -352
  32. package/src/Globe.ts +363 -0
  33. package/src/{og/ImageCanvas.js → ImageCanvas.ts} +244 -236
  34. package/src/Lock.ts +41 -0
  35. package/src/{og/LonLat.js → LonLat.ts} +50 -47
  36. package/src/{og/Object3d.js → Object3d.ts} +89 -55
  37. package/src/Popup.ts +228 -0
  38. package/src/{og/QueueArray.js → QueueArray.ts} +76 -75
  39. package/src/{og/Rectangle.js → Rectangle.ts} +115 -111
  40. package/src/Stack.ts +58 -0
  41. package/src/{og/astro/astro.js → astro/astro.ts} +49 -51
  42. package/src/{og/astro/earth.js → astro/earth.ts} +8 -9
  43. package/src/{og/astro/jd.js → astro/jd.ts} +92 -111
  44. package/src/{og/astro/orbit.js → astro/orbit.ts} +35 -37
  45. package/src/{og/astro/rotation.js → astro/rotation.ts} +4 -6
  46. package/src/{og/bv/Box.js → bv/Box.ts} +21 -17
  47. package/src/{og/bv/Sphere.js → bv/Sphere.ts} +21 -19
  48. package/src/bv/index.ts +4 -0
  49. package/src/{og/camera/Camera.js → camera/Camera.ts} +254 -197
  50. package/src/{og/camera/Frustum.js → camera/Frustum.ts} +137 -111
  51. package/src/{og/camera/PlanetCamera.js → camera/PlanetCamera.ts} +246 -182
  52. package/src/camera/index.ts +4 -0
  53. package/src/{og/cons.js → cons.ts} +14 -18
  54. package/src/{og/control/Atmosphere.js → control/Atmosphere.ts} +50 -50
  55. package/src/{og/control/CompassButton.js → control/CompassButton.ts} +27 -30
  56. package/src/{og/control/Control.js → control/Control.ts} +76 -70
  57. package/src/{og/control/DebugInfo.js → control/DebugInfo.ts} +130 -62
  58. package/src/{og/control/DrawingSwitcher.js → control/DrawingSwitcher.ts} +16 -22
  59. package/src/control/EarthCoordinates.ts +222 -0
  60. package/src/control/EarthNavigation.ts +293 -0
  61. package/src/{og/control/GeoImageDragControl.js → control/GeoImageDragControl.ts} +37 -29
  62. package/src/control/KeyboardNavigation.ts +168 -0
  63. package/src/{og/control/LayerAnimation.js → control/LayerAnimation.ts} +74 -90
  64. package/src/control/LayerSwitcher.ts +76 -0
  65. package/src/{og/control/Lighting.js → control/Lighting.ts} +158 -120
  66. package/src/control/MouseNavigation.ts +468 -0
  67. package/src/control/MouseWheelZoomControl.ts +269 -0
  68. package/src/{og/control/RulerSwitcher.js → control/RulerSwitcher.ts} +18 -20
  69. package/src/control/ScaleControl.ts +131 -0
  70. package/src/control/SegmentBoundVisualization.ts +50 -0
  71. package/src/control/ShowFps.ts +28 -0
  72. package/src/control/SimpleNavigation.ts +118 -0
  73. package/src/{og/control/SimpleSkyBackground.js → control/SimpleSkyBackground.ts} +36 -38
  74. package/src/{og/control/Sun.js → control/Sun.ts} +56 -64
  75. package/src/control/ToggleWireframe.ts +35 -0
  76. package/src/control/TouchNavigation.ts +368 -0
  77. package/src/control/ZoomControl.ts +111 -0
  78. package/src/control/drawing/DrawingControl.ts +45 -0
  79. package/src/{og/control/drawing/LineStringDrawingScene.js → control/drawing/LineStringDrawingScene.ts} +28 -35
  80. package/src/{og/control/drawing/PolygonDrawingScene.js → control/drawing/PolygonDrawingScene.ts} +148 -201
  81. package/src/{og/control/elevationProfile/ElevationProfile.js → control/elevationProfile/ElevationProfile.ts} +70 -36
  82. package/src/control/heightRuler/HeightRuler.ts +16 -0
  83. package/src/{og/control/heightRuler/HeightRulerScene.js → control/heightRuler/HeightRulerScene.ts} +92 -87
  84. package/src/{og/control/heightRuler/HeightRulerSwitcher.js → control/heightRuler/HeightRulerSwitcher.ts} +3 -3
  85. package/src/control/index.ts +45 -0
  86. package/src/control/ruler/Ruler.ts +35 -0
  87. package/src/{og/control/ruler/RulerScene.js → control/ruler/RulerScene.ts} +163 -121
  88. package/src/{og/control/selection/Selection.js → control/selection/Selection.ts} +23 -21
  89. package/src/{og/control/selection/SelectionScene.js → control/selection/SelectionScene.ts} +64 -50
  90. package/src/{og/control/timeline/TimelineControl.js → control/timeline/TimelineControl.ts} +37 -28
  91. package/src/{og/control/timeline/TimelineModel.js → control/timeline/TimelineModel.ts} +50 -35
  92. package/src/{og/control/timeline/TimelineView.js → control/timeline/TimelineView.ts} +162 -113
  93. package/src/{og/control/timeline/timelineUtils.js → control/timeline/timelineUtils.ts} +11 -10
  94. package/src/{og/control → control}/visibleExtent/Segment.js +5 -5
  95. package/src/{og/control → control}/visibleExtent/VisibleExtent.js +8 -15
  96. package/src/{og/control/visibleExtent/drawnode.js → control/visibleExtent/drawnode.ts} +1 -3
  97. package/src/{og/ellipsoid/Ellipsoid.js → ellipsoid/Ellipsoid.ts} +113 -59
  98. package/src/ellipsoid/index.ts +4 -0
  99. package/src/{og/ellipsoid/wgs84.js → ellipsoid/wgs84.ts} +1 -3
  100. package/src/{og/entity/BaseBillboard.js → entity/BaseBillboard.ts} +128 -102
  101. package/src/entity/BaseBillboardHandler.ts +772 -0
  102. package/src/{og/entity/Billboard.js → entity/Billboard.ts} +77 -47
  103. package/src/entity/BillboardHandler.ts +135 -0
  104. package/src/{og/entity/Entity.js → entity/Entity.ts} +285 -226
  105. package/src/{og/entity/EntityCollection.js → entity/EntityCollection.ts} +340 -247
  106. package/src/{og/entity/GeoObject.js → entity/GeoObject.ts} +122 -67
  107. package/src/{og/entity/GeoObjectHandler.js → entity/GeoObjectHandler.ts} +273 -198
  108. package/src/entity/Geometry.ts +486 -0
  109. package/src/{og/entity/GeometryHandler.js → entity/GeometryHandler.ts} +383 -541
  110. package/src/{og/entity/Label.js → entity/Label.ts} +131 -83
  111. package/src/{og/entity/LabelHandler.js → entity/LabelHandler.ts} +289 -255
  112. package/src/{og/entity/LabelWorker.js → entity/LabelWorker.ts} +26 -36
  113. package/src/{og/entity/PointCloud.js → entity/PointCloud.ts} +200 -164
  114. package/src/entity/PointCloudHandler.ts +125 -0
  115. package/src/{og/entity/Polyline.js → entity/Polyline.ts} +517 -539
  116. package/src/{og/entity/PolylineHandler.js → entity/PolylineHandler.ts} +29 -31
  117. package/src/{og/entity/Ray.js → entity/Ray.ts} +89 -60
  118. package/src/{og/entity/RayHandler.js → entity/RayHandler.ts} +201 -306
  119. package/src/{og/entity/Strip.js → entity/Strip.ts} +143 -100
  120. package/src/{og/entity/StripHandler.js → entity/StripHandler.ts} +76 -72
  121. package/src/entity/index.ts +12 -0
  122. package/src/index.ts +173 -0
  123. package/src/input/KeyboardHandler.ts +196 -0
  124. package/src/{og/input/MouseHandler.js → input/MouseHandler.ts} +46 -35
  125. package/src/input/TouchHandler.ts +54 -0
  126. package/src/{og/input/input.js → input/input.ts} +1 -3
  127. package/src/{og/layer/BaseGeoImage.js → layer/BaseGeoImage.ts} +174 -107
  128. package/src/{og/layer/CanvasTiles.js → layer/CanvasTiles.ts} +139 -105
  129. package/src/{og/layer/GeoImage.js → layer/GeoImage.ts} +62 -52
  130. package/src/layer/GeoTexture2d.ts +56 -0
  131. package/src/{og/layer/GeoVideo.js → layer/GeoVideo.ts} +53 -53
  132. package/src/{og/layer/KML.js → layer/KML.ts} +63 -74
  133. package/src/{og/layer/Layer.js → layer/Layer.ts} +399 -223
  134. package/src/{og/layer/Material.js → layer/Material.ts} +40 -35
  135. package/src/{og/layer/Vector.js → layer/Vector.ts} +319 -267
  136. package/src/{og/layer/WMS.js → layer/WMS.ts} +76 -64
  137. package/src/{og/layer/XYZ.js → layer/XYZ.ts} +123 -98
  138. package/src/layer/index.ts +12 -0
  139. package/src/{og/light/LightSource.js → light/LightSource.ts} +132 -93
  140. package/src/{og/math/Line2.js → math/Line2.ts} +11 -8
  141. package/src/{og/math/Line3.js → math/Line3.ts} +49 -27
  142. package/src/{og/math/Mat3.js → math/Mat3.ts} +43 -27
  143. package/src/{og/math/Mat4.js → math/Mat4.ts} +110 -77
  144. package/src/{og/math/Plane.js → math/Plane.ts} +28 -23
  145. package/src/{og/math/Quat.js → math/Quat.ts} +238 -222
  146. package/src/{og/math/Ray.js → math/Ray.ts} +59 -63
  147. package/src/{og/math/Vec2.js → math/Vec2.ts} +85 -76
  148. package/src/{og/math/Vec3.js → math/Vec3.ts} +141 -140
  149. package/src/{og/math/Vec4.js → math/Vec4.ts} +64 -53
  150. package/src/{og/math/coder.js → math/coder.ts} +30 -27
  151. package/src/math/index.ts +26 -0
  152. package/src/{og/math.js → math.ts} +46 -49
  153. package/src/{og/mercator.js → mercator.ts} +143 -149
  154. package/src/{og/proj/EPSG3857.js → proj/EPSG3857.ts} +1 -3
  155. package/src/{og/proj/EPSG4326.js → proj/EPSG4326.ts} +11 -13
  156. package/src/{og/proj/Proj.js → proj/Proj.ts} +27 -23
  157. package/src/{og/quadTree/EPSG4326QuadTreeStrategy.js → quadTree/EPSG4326QuadTreeStrategy.ts} +10 -13
  158. package/src/{og/quadTree/EarthQuadTreeStrategy.js → quadTree/EarthQuadTreeStrategy.ts} +11 -13
  159. package/src/quadTree/EntityCollectionNode.ts +395 -0
  160. package/src/{og/quadTree/MarsQuadTreeStrategy.js → quadTree/MarsQuadTreeStrategy.ts} +10 -13
  161. package/src/{og/quadTree/Node.js → quadTree/Node.ts} +283 -191
  162. package/src/{og/quadTree/QuadTreeStrategy.js → quadTree/QuadTreeStrategy.ts} +35 -29
  163. package/src/quadTree/Wgs84QuadTreeStrategy.ts +22 -0
  164. package/src/quadTree/index.ts +14 -0
  165. package/src/{og/quadTree/quadTree.js → quadTree/quadTree.ts} +75 -77
  166. package/src/{og/renderer/Renderer.js → renderer/Renderer.ts} +454 -298
  167. package/src/{og/renderer/RendererEvents.js → renderer/RendererEvents.ts} +347 -256
  168. package/src/{og/scene/Axes.js → scene/Axes.ts} +26 -22
  169. package/src/{og/scene/BaseNode.js → scene/BaseNode.ts} +53 -47
  170. package/src/{og/scene/Planet.js → scene/Planet.ts} +776 -592
  171. package/src/{og/scene/RenderNode.js → scene/RenderNode.ts} +105 -91
  172. package/src/{og/scene/SkyBox.js → scene/SkyBox.ts} +29 -25
  173. package/src/scene/index.ts +6 -0
  174. package/src/{og/segment/Segment.js → segment/Segment.ts} +497 -371
  175. package/src/{og/segment/SegmentLonLat.js → segment/SegmentLonLat.ts} +81 -87
  176. package/src/{og/segment/SegmentLonLatWgs84.js → segment/SegmentLonLatWgs84.ts} +9 -16
  177. package/src/{og/segment/Slice.js → segment/Slice.ts} +15 -9
  178. package/src/{og/segment/segmentHelper.js → segment/segmentHelper.ts} +57 -49
  179. package/src/{og/shaders/atmos.js → shaders/atmos.ts} +4 -6
  180. package/src/{og/shaders/billboard.js → shaders/billboard.ts} +3 -5
  181. package/src/{og/shaders/bloom.js → shaders/bloom.ts} +2 -4
  182. package/src/{og/shaders/blur.js → shaders/blur.ts} +4 -7
  183. package/src/{og/shaders/depth.js → shaders/depth.ts} +1 -3
  184. package/src/{og/shaders/drawnode.js → shaders/drawnode.ts} +19 -21
  185. package/src/{og/shaders/geoObject.js → shaders/geoObject.ts} +17 -19
  186. package/src/{og/shaders/label.js → shaders/label.ts} +4 -6
  187. package/src/{og/shaders/lumFilter.js → shaders/lumFilter.ts} +2 -4
  188. package/src/{og/shaders/pickingMask.js → shaders/pickingMask.ts} +2 -4
  189. package/src/{og/shaders/pointCloud.js → shaders/pointCloud.ts} +7 -10
  190. package/src/{og/shaders/polyline.js → shaders/polyline.ts} +3 -200
  191. package/src/{og/shaders/ray.js → shaders/ray.ts} +2 -4
  192. package/src/{og/shaders/screenFrame.js → shaders/screenFrame.ts} +2 -4
  193. package/src/{og/shaders/skybox.js → shaders/skybox.ts} +7 -9
  194. package/src/{og/shaders/toneMapping.js → shaders/toneMapping.ts} +2 -4
  195. package/src/{og/shaders/utils.js → shaders/utils.ts} +0 -2
  196. package/src/{og/terrain/BilTerrain.js → terrain/BilTerrain.ts} +38 -32
  197. package/src/terrain/EmptyTerrain.ts +230 -0
  198. package/src/{og/terrain/Geoid.js → terrain/Geoid.ts} +67 -41
  199. package/src/{og/terrain/GlobusTerrain.js → terrain/GlobusTerrain.ts} +159 -153
  200. package/src/{og/terrain/MapboxTerrain.js → terrain/MapboxTerrain.ts} +58 -61
  201. package/src/terrain/index.ts +6 -0
  202. package/src/ui/Button.ts +121 -0
  203. package/src/ui/ButtonGroup.ts +63 -0
  204. package/src/ui/Dialog.ts +244 -0
  205. package/src/ui/Slider.ts +188 -0
  206. package/src/ui/ToggleButton.ts +68 -0
  207. package/src/{og/ui/View.js → ui/View.ts} +66 -59
  208. package/src/utils/BaseWorker.ts +60 -0
  209. package/src/utils/FontAtlas.ts +356 -0
  210. package/src/{og/utils/GeoImageCreator.js → utils/GeoImageCreator.ts} +45 -29
  211. package/src/{og/utils/ImagesCacheManager.js → utils/ImagesCacheManager.ts} +85 -70
  212. package/src/utils/Loader.ts +247 -0
  213. package/src/{og/utils/NormalMapCreator.js → utils/NormalMapCreator.ts} +114 -77
  214. package/src/{og/utils/PlainSegmentWorker.js → utils/PlainSegmentWorker.ts} +41 -24
  215. package/src/{og/utils/TerrainWorker.js → utils/TerrainWorker.ts} +51 -36
  216. package/src/utils/TextureAtlas.ts +322 -0
  217. package/src/{og/utils/VectorTileCreator.js → utils/VectorTileCreator.ts} +67 -52
  218. package/src/{og/utils/colorTable.js → utils/colorTable.ts} +142 -144
  219. package/src/{og/utils/earcut.js → utils/earcut.ts} +664 -661
  220. package/src/{og/utils/objParser.js → utils/objParser.ts} +66 -37
  221. package/src/{og/utils/shared.js → utils/shared.ts} +267 -206
  222. package/src/utils/units.ts +78 -0
  223. package/src/webgl/BaseFramebuffer.ts +125 -0
  224. package/src/webgl/Framebuffer.ts +206 -0
  225. package/src/webgl/Handler.ts +1414 -0
  226. package/src/webgl/Multisample.ts +153 -0
  227. package/src/webgl/Program.ts +451 -0
  228. package/src/{og/webgl/ProgramController.js → webgl/ProgramController.ts} +44 -43
  229. package/src/webgl/index.ts +13 -0
  230. package/src/{og/webgl/types.js → webgl/types.ts} +29 -31
  231. package/src/webgl/variableHandlers.ts +114 -0
  232. package/src/og/Deferred.js +0 -11
  233. package/src/og/Events.js +0 -185
  234. package/src/og/Globe.js +0 -342
  235. package/src/og/Lock.js +0 -44
  236. package/src/og/Popup.js +0 -187
  237. package/src/og/Stack.js +0 -49
  238. package/src/og/bv/index.js +0 -4
  239. package/src/og/camera/index.js +0 -4
  240. package/src/og/control/EarthCoordinates.js +0 -214
  241. package/src/og/control/EarthNavigation.js +0 -258
  242. package/src/og/control/KeyboardNavigation.js +0 -172
  243. package/src/og/control/LayerSwitcher.js +0 -424
  244. package/src/og/control/MouseNavigation.js +0 -436
  245. package/src/og/control/MouseWheelZoomControl.js +0 -253
  246. package/src/og/control/ScaleControl.js +0 -119
  247. package/src/og/control/SegmentBoundVisualization.js +0 -54
  248. package/src/og/control/ShowFps.js +0 -40
  249. package/src/og/control/SimpleNavigation.js +0 -123
  250. package/src/og/control/ToggleWireframe.js +0 -35
  251. package/src/og/control/TouchNavigation.js +0 -350
  252. package/src/og/control/ZoomControl.js +0 -115
  253. package/src/og/control/drawing/DrawingControl.js +0 -51
  254. package/src/og/control/heightRuler/HeightRuler.js +0 -12
  255. package/src/og/control/index.js +0 -56
  256. package/src/og/control/ruler/Ruler.js +0 -39
  257. package/src/og/ellipsoid/index.js +0 -4
  258. package/src/og/entity/BillboardHandler.js +0 -883
  259. package/src/og/entity/Geometry.js +0 -320
  260. package/src/og/entity/PointCloudHandler.js +0 -122
  261. package/src/og/entity/index.js +0 -9
  262. package/src/og/index.js +0 -112
  263. package/src/og/input/KeyboardHandler.js +0 -195
  264. package/src/og/input/TouchHandler.js +0 -59
  265. package/src/og/layer/GeoTexture2d.js +0 -50
  266. package/src/og/layer/index.js +0 -11
  267. package/src/og/math/index.js +0 -23
  268. package/src/og/quadTree/EntityCollectionNode.js +0 -391
  269. package/src/og/quadTree/Wgs84QuadTreeStrategy.js +0 -27
  270. package/src/og/quadTree/index.js +0 -14
  271. package/src/og/res/images.js +0 -8
  272. package/src/og/scene/index.js +0 -5
  273. package/src/og/terrain/EmptyTerrain.js +0 -174
  274. package/src/og/terrain/index.js +0 -6
  275. package/src/og/ui/Button.js +0 -107
  276. package/src/og/ui/ButtonGroup.js +0 -57
  277. package/src/og/ui/Dialog.js +0 -239
  278. package/src/og/ui/Slider.js +0 -170
  279. package/src/og/ui/ToggleButton.js +0 -51
  280. package/src/og/ui/UIhelpers.js +0 -155
  281. package/src/og/utils/BaseWorker.js +0 -46
  282. package/src/og/utils/FontAtlas.js +0 -218
  283. package/src/og/utils/Loader.js +0 -188
  284. package/src/og/utils/TextureAtlas.js +0 -291
  285. package/src/og/utils/functionComposition.js +0 -13
  286. package/src/og/utils/units.js +0 -78
  287. package/src/og/webgl/Framebuffer.js +0 -311
  288. package/src/og/webgl/Handler.js +0 -1170
  289. package/src/og/webgl/Multisample.js +0 -275
  290. package/src/og/webgl/Program.js +0 -407
  291. package/src/og/webgl/callbacks.js +0 -98
  292. package/src/og/webgl/index.js +0 -13
  293. package/src/og.jsdoc +0 -3
  294. package/types/Clock.d.ts +0 -99
  295. package/types/Deferred.d.ts +0 -6
  296. package/types/Events.d.ts +0 -78
  297. package/types/Extent.d.ts +0 -166
  298. package/types/Globe.d.ts +0 -108
  299. package/types/ImageCanvas.d.ts +0 -128
  300. package/types/Lock.d.ts +0 -12
  301. package/types/LonLat.d.ts +0 -127
  302. package/types/Object3d.d.ts +0 -35
  303. package/types/Popup.d.ts +0 -29
  304. package/types/QueueArray.d.ts +0 -19
  305. package/types/Rectangle.d.ts +0 -80
  306. package/types/Stack.d.ts +0 -19
  307. package/types/arial.d.ts +0 -49
  308. package/types/astro/astro.d.ts +0 -38
  309. package/types/astro/earth.d.ts +0 -7
  310. package/types/astro/jd.d.ts +0 -254
  311. package/types/bv/Box.d.ts +0 -30
  312. package/types/bv/Sphere.d.ts +0 -38
  313. package/types/bv/index.d.ts +0 -3
  314. package/types/camera/Camera.d.ts +0 -314
  315. package/types/camera/Frustum.d.ts +0 -133
  316. package/types/camera/PlanetCamera.d.ts +0 -219
  317. package/types/camera/index.d.ts +0 -3
  318. package/types/cons.d.ts +0 -40
  319. package/types/control/Atmosphere.d.ts +0 -15
  320. package/types/control/CompassButton.d.ts +0 -16
  321. package/types/control/Control.d.ts +0 -104
  322. package/types/control/DebugInfo.d.ts +0 -19
  323. package/types/control/DrawingSwitcher.d.ts +0 -13
  324. package/types/control/EarthCoordinates.d.ts +0 -44
  325. package/types/control/EarthNavigation.d.ts +0 -43
  326. package/types/control/GeoImageDragControl.d.ts +0 -14
  327. package/types/control/KeyboardNavigation.d.ts +0 -24
  328. package/types/control/LayerAnimation.d.ts +0 -73
  329. package/types/control/LayerSwitcher.d.ts +0 -64
  330. package/types/control/Lighting.d.ts +0 -41
  331. package/types/control/MouseNavigation.d.ts +0 -49
  332. package/types/control/MouseWheelZoomControl.d.ts +0 -46
  333. package/types/control/ScaleControl.d.ts +0 -23
  334. package/types/control/ShowFps.d.ts +0 -11
  335. package/types/control/SimpleNavigation.d.ts +0 -26
  336. package/types/control/SimpleSkyBackground.d.ts +0 -15
  337. package/types/control/Sun.d.ts +0 -53
  338. package/types/control/ToggleWireframe.d.ts +0 -12
  339. package/types/control/TouchNavigation.d.ts +0 -54
  340. package/types/control/ZoomControl.d.ts +0 -26
  341. package/types/control/drawing/DrawingControl.d.ts +0 -14
  342. package/types/control/drawing/LineStringDrawingScene.d.ts +0 -5
  343. package/types/control/drawing/PolygonDrawingScene.d.ts +0 -99
  344. package/types/control/heightRuler/HeightRuler.d.ts +0 -6
  345. package/types/control/heightRuler/HeightRulerScene.d.ts +0 -23
  346. package/types/control/index.d.ts +0 -27
  347. package/types/control/ruler/Ruler.d.ts +0 -13
  348. package/types/control/ruler/RulerScene.d.ts +0 -51
  349. package/types/control/selection/Selection.d.ts +0 -49
  350. package/types/control/selection/SelectionScene.d.ts +0 -32
  351. package/types/control/timeline/TimelineControl.d.ts +0 -10
  352. package/types/control/timeline/TimelineModel.d.ts +0 -33
  353. package/types/control/timeline/TimelineView.d.ts +0 -57
  354. package/types/control/timeline/timelineUtils.d.ts +0 -9
  355. package/types/ellipsoid/Ellipsoid.d.ts +0 -170
  356. package/types/ellipsoid/index.d.ts +0 -3
  357. package/types/ellipsoid/wgs84.d.ts +0 -6
  358. package/types/entity/BaseBillboard.d.ts +0 -215
  359. package/types/entity/Billboard.d.ts +0 -94
  360. package/types/entity/BillboardHandler.d.ts +0 -75
  361. package/types/entity/Entity.d.ts +0 -340
  362. package/types/entity/EntityCollection.d.ts +0 -303
  363. package/types/entity/GeoObject.d.ts +0 -117
  364. package/types/entity/GeoObjectHandler.d.ts +0 -41
  365. package/types/entity/Geometry.d.ts +0 -79
  366. package/types/entity/GeometryHandler.d.ts +0 -76
  367. package/types/entity/Label.d.ts +0 -190
  368. package/types/entity/LabelHandler.d.ts +0 -31
  369. package/types/entity/LabelWorker.d.ts +0 -9
  370. package/types/entity/PointCloud.d.ts +0 -174
  371. package/types/entity/PointCloudHandler.d.ts +0 -38
  372. package/types/entity/Polyline.d.ts +0 -307
  373. package/types/entity/PolylineHandler.d.ts +0 -18
  374. package/types/entity/Ray.d.ts +0 -122
  375. package/types/entity/RayHandler.d.ts +0 -63
  376. package/types/entity/Strip.d.ts +0 -119
  377. package/types/entity/StripHandler.d.ts +0 -38
  378. package/types/entity/index.d.ts +0 -8
  379. package/types/index.d.ts +0 -53
  380. package/types/input/KeyboardHandler.d.ts +0 -17
  381. package/types/input/MouseHandler.d.ts +0 -5
  382. package/types/input/TouchHandler.d.ts +0 -5
  383. package/types/input/input.d.ts +0 -42
  384. package/types/layer/BaseGeoImage.d.ts +0 -116
  385. package/types/layer/CanvasTiles.d.ts +0 -73
  386. package/types/layer/GeoImage.d.ts +0 -51
  387. package/types/layer/GeoTexture2d.d.ts +0 -7
  388. package/types/layer/GeoVideo.d.ts +0 -47
  389. package/types/layer/KML.d.ts +0 -93
  390. package/types/layer/Layer.d.ts +0 -320
  391. package/types/layer/Material.d.ts +0 -45
  392. package/types/layer/Vector.d.ts +0 -211
  393. package/types/layer/WMS.d.ts +0 -66
  394. package/types/layer/XYZ.d.ts +0 -122
  395. package/types/layer/index.d.ts +0 -10
  396. package/types/light/LightSource.d.ts +0 -178
  397. package/types/math/Line2.d.ts +0 -11
  398. package/types/math/Line3.d.ts +0 -10
  399. package/types/math/Mat3.d.ts +0 -65
  400. package/types/math/Mat4.d.ts +0 -176
  401. package/types/math/Plane.d.ts +0 -18
  402. package/types/math/Quat.d.ts +0 -379
  403. package/types/math/Ray.d.ts +0 -82
  404. package/types/math/Vec2.d.ts +0 -309
  405. package/types/math/Vec3.d.ts +0 -472
  406. package/types/math/Vec4.d.ts +0 -161
  407. package/types/math/coder.d.ts +0 -43
  408. package/types/math/index.d.ts +0 -11
  409. package/types/math.d.ts +0 -268
  410. package/types/mercator.d.ts +0 -92
  411. package/types/proj/EPSG3857.d.ts +0 -6
  412. package/types/proj/EPSG4326.d.ts +0 -6
  413. package/types/proj/Proj.d.ts +0 -42
  414. package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +0 -3
  415. package/types/quadTree/EarthQuadTreeStrategy.d.ts +0 -3
  416. package/types/quadTree/EntityCollectionNode.d.ts +0 -41
  417. package/types/quadTree/MarsQuadTreeStrategy.d.ts +0 -3
  418. package/types/quadTree/Node.d.ts +0 -58
  419. package/types/quadTree/QuadTreeStrategy.d.ts +0 -21
  420. package/types/quadTree/Wgs84QuadTreeStrategy.d.ts +0 -3
  421. package/types/quadTree/index.d.ts +0 -12
  422. package/types/quadTree/quadTree.d.ts +0 -40
  423. package/types/renderer/Renderer.d.ts +0 -291
  424. package/types/renderer/RendererEvents.d.ts +0 -241
  425. package/types/res/images.d.ts +0 -2
  426. package/types/scene/Axes.d.ts +0 -10
  427. package/types/scene/BaseNode.d.ts +0 -60
  428. package/types/scene/Planet.d.ts +0 -594
  429. package/types/scene/RenderNode.d.ts +0 -152
  430. package/types/scene/SkyBox.d.ts +0 -9
  431. package/types/scene/index.d.ts +0 -4
  432. package/types/segment/Segment.d.ts +0 -273
  433. package/types/segment/SegmentLonLat.d.ts +0 -22
  434. package/types/segment/SegmentLonLatWgs84.d.ts +0 -4
  435. package/types/segment/Slice.d.ts +0 -10
  436. package/types/segment/segmentHelper.d.ts +0 -13
  437. package/types/shaders/atmos.d.ts +0 -4
  438. package/types/shaders/billboard.d.ts +0 -3
  439. package/types/shaders/depth.d.ts +0 -2
  440. package/types/shaders/drawnode.d.ts +0 -8
  441. package/types/shaders/geoObject.d.ts +0 -3
  442. package/types/shaders/label.d.ts +0 -4
  443. package/types/shaders/pickingMask.d.ts +0 -2
  444. package/types/shaders/pointCloud.d.ts +0 -2
  445. package/types/shaders/polyline.d.ts +0 -3
  446. package/types/shaders/ray.d.ts +0 -2
  447. package/types/shaders/screenFrame.d.ts +0 -2
  448. package/types/shaders/skybox.d.ts +0 -2
  449. package/types/shaders/toneMapping.d.ts +0 -2
  450. package/types/shaders/utils.d.ts +0 -1
  451. package/types/terrain/BilTerrain.d.ts +0 -14
  452. package/types/terrain/EmptyTerrain.d.ts +0 -87
  453. package/types/terrain/Geoid.d.ts +0 -17
  454. package/types/terrain/GlobusTerrain.d.ts +0 -122
  455. package/types/terrain/MapboxTerrain.d.ts +0 -14
  456. package/types/terrain/index.d.ts +0 -5
  457. package/types/ui/Button.d.ts +0 -21
  458. package/types/ui/ButtonGroup.d.ts +0 -12
  459. package/types/ui/Dialog.d.ts +0 -41
  460. package/types/ui/Slider.d.ts +0 -33
  461. package/types/ui/ToggleButton.d.ts +0 -10
  462. package/types/ui/UIhelpers.d.ts +0 -13
  463. package/types/ui/View.d.ts +0 -33
  464. package/types/ui/icons.d.ts +0 -1
  465. package/types/utils/BaseWorker.d.ts +0 -14
  466. package/types/utils/FontAtlas.d.ts +0 -16
  467. package/types/utils/GeoImageCreator.d.ts +0 -30
  468. package/types/utils/ImagesCacheManager.d.ts +0 -10
  469. package/types/utils/Loader.d.ts +0 -31
  470. package/types/utils/NormalMapCreator.d.ts +0 -39
  471. package/types/utils/PlainSegmentWorker.d.ts +0 -8
  472. package/types/utils/TerrainWorker.d.ts +0 -7
  473. package/types/utils/TextureAtlas.d.ts +0 -113
  474. package/types/utils/VectorTileCreator.d.ts +0 -14
  475. package/types/utils/colorTable.d.ts +0 -143
  476. package/types/utils/earcut.d.ts +0 -6
  477. package/types/utils/functionComposition.d.ts +0 -5
  478. package/types/utils/objParser.d.ts +0 -8
  479. package/types/utils/shared.d.ts +0 -241
  480. package/types/utils/units.d.ts +0 -20
  481. package/types/webgl/Framebuffer.d.ts +0 -134
  482. package/types/webgl/Handler.d.ts +0 -403
  483. package/types/webgl/Multisample.d.ts +0 -91
  484. package/types/webgl/Program.d.ts +0 -163
  485. package/types/webgl/ProgramController.d.ts +0 -89
  486. package/types/webgl/callbacks.d.ts +0 -1
  487. package/types/webgl/index.d.ts +0 -6
  488. package/types/webgl/types.d.ts +0 -2
  489. /package/{src/og → dist/@openglobus/res/fonts}/arial.js +0 -0
  490. /package/src/{og/ui/icons.js → ui/icons.ts} +0 -0
@@ -1,25 +1,33 @@
1
- "use strict";
2
-
3
- import { Box } from "../bv/Box.js";
4
- import { Sphere } from "../bv/Sphere.js";
5
- import { Extent } from "../Extent.js";
6
- import { Layer } from "../layer/Layer.js";
7
- import { LonLat } from "../LonLat.js";
8
- import { Ray } from "../math/Ray.js";
9
- import { Vec3 } from "../math/Vec3.js";
10
- import * as mercator from "../mercator.js";
11
- import { EPSG3857 } from "../proj/EPSG3857.js";
12
- import { E, N, NOTRENDERING, OPSIDE, S, W } from "../quadTree/quadTree.js";
13
- import * as segmentHelper from "../segment/segmentHelper.js";
14
- import { getMatrixSubArray } from "../utils/shared.js";
15
- import { Slice } from "./Slice.js";
1
+ import * as mercator from "../mercator";
2
+ import * as segmentHelper from "../segment/segmentHelper";
3
+ import {Box} from "../bv/Box";
4
+ import {Extent} from "../Extent";
5
+ import {Entity} from "../entity/Entity";
6
+ import {EPSG3857} from "../proj/EPSG3857";
7
+ import {E, N, NOTRENDERING, OPSIDE, S, W} from "../quadTree/quadTree";
8
+ import {getMatrixSubArray64, TypedArray} from "../utils/shared";
9
+ import {Handler, WebGLBufferExt, WebGLTextureExt} from "../webgl/Handler";
10
+ import {ITerrainWorkerData} from "../utils/TerrainWorker";
11
+ import {Layer} from "../layer/Layer";
12
+ import {LonLat} from "../LonLat";
13
+ import {Material} from "../layer/Material";
14
+ import {Node} from "../quadTree/Node";
15
+ import {Planet} from "../scene/Planet";
16
+ import {PlanetCamera} from "../camera/PlanetCamera";
17
+ import {Program} from "../webgl/Program";
18
+ import {Proj} from "../proj/Proj";
19
+ import {NumberArray6, Sphere} from "../bv/Sphere";
20
+ import {Slice} from "./Slice";
21
+ import {Ray} from "../math/Ray";
22
+ import {Vec3} from "../math/Vec3";
23
+ import {IPlainSegmentWorkerData} from "../utils/PlainSegmentWorker";
16
24
 
17
25
  export const TILEGROUP_COMMON = 0;
18
26
  export const TILEGROUP_NORTH = 1;
19
27
  export const TILEGROUP_SOUTH = 2;
20
28
 
21
- var _tempHigh = new Vec3();
22
- var _tempLow = new Vec3();
29
+ let _tempHigh = new Vec3();
30
+ let _tempLow = new Vec3();
23
31
 
24
32
  let _v0 = new Vec3(),
25
33
  _v1 = new Vec3(),
@@ -29,8 +37,6 @@ let _v0 = new Vec3(),
29
37
  let _ray = new Ray(),
30
38
  _rayEx = new Ray();
31
39
 
32
- window.ELLNORM = false;
33
-
34
40
  const _S = new Array(4);
35
41
  _S[N] = 0;
36
42
  _S[E] = 1;
@@ -44,57 +50,218 @@ _V[S] = false;
44
50
  _V[W] = true;
45
51
 
46
52
  /**
47
- * Planet segment Web Mercator tile class that stored and rendered with quad tree.
53
+ * Planet segment Web Mercator tile class that stored and rendered with a quad-tree.
48
54
  * @class
49
- * @param {quadTree.Node} node - Segment node.
50
- * @param {Planet} planet - Current planet scene.
51
- * @param {Number} tileZoom - Zoom index.
55
+ * @param {Node} node - Segment node.
56
+ * @param {Planet} planet - Planet scene.
57
+ * @param {number} tileZoom - Zoom index.
52
58
  * @param {Extent} extent - Segment extent.
53
59
  */
54
60
  class Segment {
61
+
62
+ public _isNorth?: boolean;
63
+
64
+ public isPole: boolean;
65
+
66
+ public _tileGroup: number;
67
+
68
+ public _projection: Proj;
69
+
70
+ /**
71
+ * Quad tree node of the segment.
72
+ * @type {Node}
73
+ */
74
+ public node: Node;
75
+
76
+ /**
77
+ * Planet pointer.
78
+ * @type {Planet}
79
+ */
80
+ public planet: Planet;
81
+
82
+ /**
83
+ * WebGl handler pointer.
84
+ * @type {Handler}
85
+ */
86
+ public handler: Handler;
87
+
88
+ /**
89
+ * Segment bounding sphere
90
+ * @type {Sphere}
91
+ */
92
+ public bsphere: Sphere;
93
+
94
+ public _plainRadius: number;
95
+
96
+ /**
97
+ * Segment bounding box.
98
+ * @type {Box}
99
+ */
100
+ public bbox: Box;
101
+
102
+ public _sw: Vec3;
103
+ public _nw: Vec3;
104
+ public _se: Vec3;
105
+ public _ne: Vec3;
106
+
107
+ public centerNormal: Vec3;
108
+
55
109
  /**
56
- * @param {quadTree.Node} node - Segment node.
57
- * @param {Planet} planet - Current planet scene.
58
- * @param {number} tileZoom - Zoom index.
59
- * @param {Extent} extent - Segment extent.
110
+ * Geographical extent.
111
+ * @type {Extent}
60
112
  */
61
- constructor(node, planet, tileZoom, extent) {
113
+ public _extent: Extent;
114
+
115
+ public _extentMerc: Extent;
116
+
117
+ public _extentLonLat: Extent;
118
+
119
+ /**
120
+ * Vertices grid size.
121
+ * @type {number}
122
+ */
123
+ public gridSize: number;
124
+
125
+ public fileGridSize: number;
126
+
127
+ /**
128
+ * Tile zoom index.
129
+ * @type {number}
130
+ */
131
+ public tileZoom: number;
132
+
133
+ /**
134
+ * Horizontal tile index.
135
+ * @type {number}
136
+ */
137
+ public tileX: number;
138
+
139
+ public tileXE: number;
140
+
141
+ public tileXW: number;
142
+
143
+ public tileYN: number;
144
+
145
+ public tileYS: number;
146
+
147
+ /**
148
+ * Vertical tile index.
149
+ * @type {number}
150
+ */
151
+ public tileY: number;
152
+
153
+ public tileIndex: string;
154
+
155
+ /**
156
+ * Texture materials array.
157
+ * @type {Array.<Material>}
158
+ *
159
+ * @toso: Check it should be Map<number, Material> instead of array
160
+ *
161
+ */
162
+ public materials: Material[];
163
+
164
+ /**
165
+ * Plain segment vertices was created.
166
+ * @type {boolean}
167
+ */
168
+ public plainReady: boolean;
169
+
170
+ /**
171
+ * Segment is ready to create plain vertices.
172
+ * @type {boolean}
173
+ */
174
+ public initialized: boolean;
175
+
176
+ /**
177
+ * Normal map is allready made.
178
+ * @type {boolean}
179
+ */
180
+ public normalMapReady: boolean;
181
+
182
+ /**
183
+ * Terrain is allready applied flag.
184
+ * @type {boolean}
185
+ */
186
+ public terrainReady: boolean;
187
+
188
+ /**
189
+ * Terrain is loading now flag.
190
+ * @type {boolean}
191
+ */
192
+ public terrainIsLoading: boolean;
193
+
194
+ /**
195
+ * Terrain existing flag.
196
+ * @type {boolean}
197
+ */
198
+ public terrainExists: boolean;
199
+
200
+ /**
201
+ * Means that tree passage reach the segment, and the segment terrain is ready.
202
+ * @type {boolean}
203
+ */
204
+ public passReady: boolean;
205
+
206
+ public plainVertices: Float64Array | null;
207
+ public plainVerticesHigh: Float32Array | null;
208
+ public plainVerticesLow: Float32Array | null;
209
+
210
+ public plainNormals: Float32Array | null;
211
+
212
+ public terrainVertices: Float64Array | null;
213
+ public terrainVerticesHigh: Float32Array | null;
214
+ public terrainVerticesLow: Float32Array | null;
215
+ public noDataVertices: Uint8Array | null;
216
+
217
+ public tempVertices: Float64Array | null;
218
+ public tempVerticesHigh: Float32Array | null;
219
+ public tempVerticesLow: Float32Array | null;
220
+
221
+ public normalMapTexture: WebGLTextureExt | null;
222
+ public normalMapTextureBias: Float32Array;
223
+ public normalMapVertices: Float64Array | null;
224
+ public normalMapVerticesHigh: Float32Array | null;
225
+ public normalMapVerticesLow: Float32Array | null;
226
+ public normalMapNormals: Float32Array | null;
227
+
228
+ public vertexNormalBuffer: WebGLBufferExt | null;
229
+ public vertexPositionBuffer: WebGLBufferExt | null;
230
+ public vertexPositionBufferHigh: WebGLBufferExt | null;
231
+ public vertexPositionBufferLow: WebGLBufferExt | null;
232
+ public vertexTextureCoordBuffer: WebGLBufferExt | null;
233
+
234
+ public _globalTextureCoordinates: Float32Array;
235
+ public _inTheQueue: boolean;
236
+ public _appliedNeighborsZoom: [number, number, number, number];
237
+
238
+ public _slices: Slice[];
239
+
240
+ public _indexBuffer: WebGLBufferExt | null;
241
+
242
+ public readyToEngage: boolean;
243
+
244
+ public plainProcessing: boolean;
245
+
246
+ public normalMapTexturePtr: WebGLTextureExt | null;
247
+
248
+ constructor(node: Node, planet: Planet, tileZoom: number, extent: Extent) {
62
249
  this.isPole = false;
63
250
 
64
251
  this._tileGroup = TILEGROUP_COMMON;
65
252
 
66
253
  this._projection = EPSG3857;
67
254
 
68
- /**
69
- * Quad tree node of the segment.
70
- * @type {quadTree.Node}
71
- */
72
255
  this.node = node;
73
256
 
74
- /**
75
- * Planet pointer.
76
- * @type {Planet}
77
- */
78
257
  this.planet = planet;
79
258
 
80
- /**
81
- * WebGl handler pointer.
82
- * @type {Handler}
83
- */
84
- this.handler = planet.renderer.handler;
259
+ this.handler = planet.renderer!.handler;
85
260
 
86
- /**
87
- * Segment bounding sphere
88
- * @type {Sphere}
89
- */
90
261
  this.bsphere = new Sphere();
91
262
 
92
263
  this._plainRadius = 0;
93
264
 
94
- /**
95
- * Segment bounding box.
96
- * @type {Box}
97
- */
98
265
  this.bbox = new Box();
99
266
 
100
267
  this._sw = new Vec3();
@@ -104,32 +271,16 @@ class Segment {
104
271
 
105
272
  this.centerNormal = new Vec3();
106
273
 
107
- /**
108
- * Geographical extent.
109
- * @type {Extent}
110
- */
111
- this._extent = extent;
274
+ this._extent = this._extentMerc = extent;
112
275
 
113
- this._extentLonLat = null;
276
+ this._extentLonLat = new Extent();
114
277
 
115
- /**
116
- * Vertices grid size.
117
- * @type {number}
118
- */
119
- this.gridSize = planet.terrain.gridSizeByZoom[tileZoom];
278
+ this.gridSize = planet.terrain!.gridSizeByZoom[tileZoom];
120
279
 
121
280
  this.fileGridSize = 0;
122
281
 
123
- /**
124
- * Tile zoom index.
125
- * @type {number}
126
- */
127
282
  this.tileZoom = tileZoom;
128
283
 
129
- /**
130
- * Horizontal tile index.
131
- * @type {number}
132
- */
133
284
  this.tileX = 0;
134
285
 
135
286
  this.tileXE = 0;
@@ -140,10 +291,6 @@ class Segment {
140
291
 
141
292
  this.tileYS = 0;
142
293
 
143
- /**
144
- * Vertical tile index.
145
- * @type {number}
146
- */
147
294
  this.tileY = 0;
148
295
 
149
296
  this.tileIndex = "";
@@ -151,51 +298,22 @@ class Segment {
151
298
  this._assignTileIndexes();
152
299
 
153
300
  /**
154
- * Texture materials array.
155
- * @type {Array.<planetSegment.Material>}
301
+ * @toso: Check it should be Map<number, Material> instead of array
156
302
  */
157
303
  this.materials = [];
158
304
 
159
- /**
160
- * Plain segment vertices was created.
161
- * @type {boolean}
162
- */
163
305
  this.plainReady = false;
164
306
 
165
- /**
166
- * Segment is ready to create plain vertices.
167
- * @type {boolean}
168
- */
169
307
  this.initialized = false;
170
308
 
171
- /**
172
- * Normal map is allready made.
173
- * @type {boolean}
174
- */
175
309
  this.normalMapReady = false;
176
310
 
177
- /**
178
- * Terrain is allready applied flag.
179
- * @type {boolean}
180
- */
181
311
  this.terrainReady = false;
182
312
 
183
- /**
184
- * Terrain is loading now flag.
185
- * @type {boolean}
186
- */
187
313
  this.terrainIsLoading = false;
188
314
 
189
- /**
190
- * Terrain existing flag.
191
- * @type {boolean}
192
- */
193
315
  this.terrainExists = false;
194
316
 
195
- /**
196
- * Means that tree passage reach the segment, and the segment terrain is ready.
197
- * @type {boolean}
198
- */
199
317
  this.passReady = false;
200
318
 
201
319
  this.plainVertices = null;
@@ -237,10 +355,12 @@ class Segment {
237
355
  this.readyToEngage = false;
238
356
 
239
357
  this.plainProcessing = false;
358
+
359
+ this.normalMapTexturePtr = null;
240
360
  }
241
361
 
242
- checkZoom() {
243
- return this.tileZoom < this.planet.terrain._maxNodeZoom;
362
+ public checkZoom(): boolean {
363
+ return this.tileZoom < this.planet.terrain!._maxNodeZoom;
244
364
  }
245
365
 
246
366
  /**
@@ -250,16 +370,16 @@ class Segment {
250
370
  * @param {Vec3} res - Point coordinates.
251
371
  * @returns {Vec3} -
252
372
  */
253
- getEntityTerrainPoint(entity, res) {
373
+ public getEntityTerrainPoint(entity: Entity, res: Vec3): number {
254
374
  return this.getTerrainPoint(entity._cartesian, this.getInsideLonLat(entity), res);
255
375
  }
256
376
 
257
- getInsideLonLat(obj) {
377
+ public getInsideLonLat(obj: Entity | PlanetCamera): LonLat {
258
378
  return obj._lonLatMerc;
259
379
  }
260
380
 
261
- isEntityInside(entity) {
262
- return this._extentLonLat.isInside(entity._lonLat);
381
+ public isEntityInside(entity: Entity): boolean {
382
+ return this._extentLonLat!.isInside(entity._lonLat);
263
383
  }
264
384
 
265
385
  /**
@@ -268,10 +388,9 @@ class Segment {
268
388
  * @param {Vec3} xyz - Cartesian object position.
269
389
  * @param {LonLat} insideSegmentPosition - Geodetic object position.
270
390
  * @param {Vec3} [res] - Result cartesian coordinates on the terrain.
271
- * @param {Vec3} [normal] - Terrain point normal.
272
391
  * @returns {number} -
273
392
  */
274
- getTerrainPoint(xyz, insideSegmentPosition, res) {
393
+ public getTerrainPoint(xyz: Vec3, insideSegmentPosition: LonLat, res: Vec3): number {
275
394
  let verts = this.tempVertices;
276
395
 
277
396
  if (verts && verts.length) {
@@ -339,7 +458,7 @@ class Segment {
339
458
 
340
459
  return xyz.distance(res);
341
460
  } else {
342
- return xyz.distance(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
461
+ return xyz.distance(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction)!);
343
462
  }
344
463
  }
345
464
 
@@ -349,16 +468,12 @@ class Segment {
349
468
  * @param {LonLat} lonlat - Coordinates to project.
350
469
  * @returns {LonLat} -
351
470
  */
352
- projectNative(lonlat) {
471
+ public projectNative(lonlat: LonLat): LonLat {
353
472
  return lonlat.forwardMercator();
354
473
  }
355
474
 
356
- /**
357
- *
358
- * @param {boolean} forceLoading
359
- */
360
- loadTerrain(forceLoading) {
361
- if (this.tileZoom < this.planet.terrain.minZoom || this.planet.terrain.isEmpty) {
475
+ public loadTerrain(forceLoading: boolean = false) {
476
+ if (this.tileZoom < this.planet.terrain!.minZoom || this.planet.terrain!.isEmpty) {
362
477
  this.terrainIsLoading = true;
363
478
 
364
479
  this.elevationsNotExists();
@@ -367,10 +482,10 @@ class Segment {
367
482
  this.planet._normalMapCreator.queue(this);
368
483
  }
369
484
  } else {
370
- if (this.tileZoom > this.planet.terrain.maxZoom) {
485
+ if (this.tileZoom > this.planet.terrain!.maxZoom) {
371
486
  this.elevationsNotExists();
372
487
  } else if (!this.terrainIsLoading && !this.terrainReady) {
373
- this.planet.terrain.loadTerrain(this, forceLoading);
488
+ this.planet.terrain!.loadTerrain(this, forceLoading);
374
489
  }
375
490
  // if (!this.terrainIsLoading && !this.terrainReady) {
376
491
  // this.planet.terrain.loadTerrain(this, forceLoading);
@@ -382,9 +497,13 @@ class Segment {
382
497
  * Terrain obtained from server.
383
498
  * @param {Float32Array} elevations - Elevation data.
384
499
  */
385
- elevationsExists(elevations) {
500
+ public elevationsExists(elevations: number[] | TypedArray) {
386
501
  if (this.plainReady && this.terrainIsLoading) {
387
- this.planet._terrainWorker.make(this, elevations);
502
+
503
+ let _elevations = new Float32Array(elevations.length);
504
+ _elevations.set(elevations);
505
+
506
+ this.planet._terrainWorker.make({segment: this, elevations: _elevations});
388
507
 
389
508
  this.plainVerticesHigh = null;
390
509
  this.plainVerticesLow = null;
@@ -392,7 +511,7 @@ class Segment {
392
511
  this.normalMapVerticesHigh = null;
393
512
  this.normalMapVerticesLow = null;
394
513
 
395
- if (!this.planet.terrain.equalizeVertices) {
514
+ if (!this.planet.terrain!.equalizeVertices) {
396
515
  this.tempVerticesHigh = null;
397
516
  this.tempVerticesLow = null;
398
517
  }
@@ -405,8 +524,9 @@ class Segment {
405
524
  * 'this.tileZoom <= this.planet.terrain.maxZoom' it means, that the segment is plain
406
525
  *
407
526
  */
408
- elevationsNotExists() {
409
- if (this.planet && this.tileZoom <= this.planet.terrain.maxNativeZoom) {
527
+ public elevationsNotExists() {
528
+ if (this.planet && this.tileZoom <= this.planet.terrain!.maxNativeZoom) {
529
+
410
530
  if (this.plainReady && this.terrainIsLoading) {
411
531
  this.terrainIsLoading = false;
412
532
 
@@ -433,10 +553,11 @@ class Segment {
433
553
 
434
554
  this.noDataVertices = null;
435
555
 
436
- this.fileGridSize = Math.sqrt(this.terrainVertices.length / 3) - 1;
556
+ this.fileGridSize = Math.sqrt(this.terrainVertices!.length / 3) - 1;
437
557
  this.gridSize = this.fileGridSize;
438
558
  this.terrainReady = true;
439
559
  this.terrainExists = false;
560
+
440
561
  } else {
441
562
 
442
563
  if (this.plainReady && this.terrainIsLoading) {
@@ -456,21 +577,25 @@ class Segment {
456
577
  }
457
578
  }
458
579
 
459
- _checkEqualization(neighborSide, neigborNode) {
580
+ protected _checkEqualization(neighborSide: number, neigborNode: Node): boolean {
460
581
  return neigborNode && this.tileZoom >= neigborNode.segment.tileZoom &&
461
582
  this.node.equalizedSideWithNodeId[neighborSide] !== neigborNode.equalizedSideWithNodeId[OPSIDE[neighborSide]];
462
583
  }
463
584
 
464
- equalize() {
585
+ public equalize() {
586
+
465
587
  if (this.tileZoom < 8 || this.gridSize < 2) {
466
588
  return;
467
589
  }
468
590
 
469
591
  this.readyToEngage = true;
592
+
470
593
  let nn = this.node.neighbors;
471
- let v = this.tempVertices,
472
- vHigh = this.tempVerticesHigh,
473
- vLow = this.tempVerticesLow;
594
+
595
+ let v = this.tempVertices!,
596
+ vHigh = this.tempVerticesHigh!,
597
+ vLow = this.tempVerticesLow!;
598
+
474
599
  let gs = this.gridSize,
475
600
  gsOne = gs + 1;
476
601
 
@@ -483,9 +608,9 @@ class Segment {
483
608
 
484
609
  let offset = this.node.getOffsetOppositeNeighbourSide(n, N);
485
610
 
486
- let nv = n.segment.tempVertices,
487
- nvHigh = n.segment.tempVerticesHigh,
488
- nvLow = n.segment.tempVerticesLow;
611
+ let nv = n.segment.tempVertices!,
612
+ nvHigh = n.segment.tempVerticesHigh!,
613
+ nvLow = n.segment.tempVerticesLow!;
489
614
 
490
615
  let n_gs = n.segment.gridSize,
491
616
  n_gsOne = n_gs + 1;
@@ -523,9 +648,9 @@ class Segment {
523
648
 
524
649
  let offset = this.node.getOffsetOppositeNeighbourSide(n, E);
525
650
 
526
- let nv = n.segment.tempVertices,
527
- nvHigh = n.segment.tempVerticesHigh,
528
- nvLow = n.segment.tempVerticesLow;
651
+ let nv = n.segment.tempVertices!,
652
+ nvHigh = n.segment.tempVerticesHigh!,
653
+ nvLow = n.segment.tempVerticesLow!;
529
654
 
530
655
  let n_gs = n.segment.gridSize,
531
656
  n_gsOne = n_gs + 1;
@@ -563,9 +688,9 @@ class Segment {
563
688
 
564
689
  let offset = this.node.getOffsetOppositeNeighbourSide(n, S);
565
690
 
566
- let nv = n.segment.tempVertices,
567
- nvHigh = n.segment.tempVerticesHigh,
568
- nvLow = n.segment.tempVerticesLow;
691
+ let nv = n.segment.tempVertices!,
692
+ nvHigh = n.segment.tempVerticesHigh!,
693
+ nvLow = n.segment.tempVerticesLow!;
569
694
 
570
695
  let n_gs = n.segment.gridSize; // n_gsOne = n_gs + 1;
571
696
 
@@ -602,9 +727,9 @@ class Segment {
602
727
 
603
728
  let offset = this.node.getOffsetOppositeNeighbourSide(n, W);
604
729
 
605
- let nv = n.segment.tempVertices,
606
- nvHigh = n.segment.tempVerticesHigh,
607
- nvLow = n.segment.tempVerticesLow;
730
+ let nv = n.segment.tempVertices!,
731
+ nvHigh = n.segment.tempVerticesHigh!,
732
+ nvLow = n.segment.tempVerticesLow!;
608
733
 
609
734
  let n_gs = n.segment.gridSize,
610
735
  n_gsOne = n_gs + 1;
@@ -634,12 +759,12 @@ class Segment {
634
759
  }
635
760
  }
636
761
 
637
- engage() {
762
+ public engage() {
638
763
  this.readyToEngage = false;
639
- this.createCoordsBuffers(this.tempVerticesHigh, this.tempVerticesLow, this.gridSize);
764
+ this.createCoordsBuffers(this.tempVerticesHigh!, this.tempVerticesLow!, this.gridSize);
640
765
  }
641
766
 
642
- _terrainWorkerCallback(data) {
767
+ public _terrainWorkerCallback(data: ITerrainWorkerData) {
643
768
  if (this.plainReady) {
644
769
  this.readyToEngage = true;
645
770
 
@@ -675,7 +800,7 @@ class Segment {
675
800
 
676
801
  this.setBoundingVolumeArr(data.bounds);
677
802
 
678
- this.gridSize = Math.sqrt(this.terrainVertices.length / 3) - 1;
803
+ this.gridSize = Math.sqrt(this.terrainVertices!.length / 3) - 1;
679
804
 
680
805
  let n = this.node;
681
806
  n.appliedTerrainNodeId = n.nodeId;
@@ -687,11 +812,8 @@ class Segment {
687
812
  this.terrainExists = true;
688
813
 
689
814
  if (!this.normalMapTexturePtr) {
690
- var nmc = this.planet._normalMapCreator;
691
- this.normalMapTexturePtr = this.planet.renderer.handler.createEmptyTexture_l(
692
- nmc._width,
693
- nmc._height
694
- );
815
+ const nmc = this.planet._normalMapCreator;
816
+ this.normalMapTexturePtr = this.planet.renderer!.handler.createEmptyTexture_l(nmc.width, nmc.height);
695
817
  }
696
818
 
697
819
  if (this.planet.lightEnabled) {
@@ -700,10 +822,10 @@ class Segment {
700
822
  }
701
823
  }
702
824
 
703
- _normalMapEdgeEqualize(side) {
825
+ public _normalMapEdgeEqualize(side: number) {
704
826
  let nn = this.node.neighbors;
705
- let n = nn[side][0];
706
- let maxZ = this.planet.terrain.maxZoom;
827
+ let n: Node | undefined = nn[side][0];
828
+ let maxZ = this.planet.terrain!.maxZoom;
707
829
 
708
830
  if (this.tileZoom === maxZ) {
709
831
  if (!(nn[0].length || nn[1].length || nn[2].length || nn[3].length)) {
@@ -729,8 +851,8 @@ class Segment {
729
851
 
730
852
  if (!(seg_a && seg_b)) return;
731
853
 
732
- let seg_a_raw = s.normalMapNormals,
733
- seg_b_raw = b.normalMapNormals;
854
+ let seg_a_raw = s.normalMapNormals!,
855
+ seg_b_raw = b.normalMapNormals!;
734
856
 
735
857
  // let seg_a_verts = s.terrainVertices,
736
858
  // seg_b_verts = s.terrainVertices;
@@ -787,7 +909,7 @@ class Segment {
787
909
  }
788
910
  }
789
911
 
790
- applyTerrain(elevations) {
912
+ public applyTerrain(elevations?: number[] | TypedArray | null) {
791
913
  if (elevations) {
792
914
  this.elevationsExists(elevations);
793
915
  } else {
@@ -795,15 +917,14 @@ class Segment {
795
917
  }
796
918
  }
797
919
 
798
- /**
799
- * Delete segment gl buffers.
800
- */
801
- deleteBuffers() {
802
- var gl = this.handler.gl;
803
- gl.deleteBuffer(this.vertexNormalBuffer);
804
- gl.deleteBuffer(this.vertexPositionBuffer);
805
- gl.deleteBuffer(this.vertexPositionBufferHigh);
806
- gl.deleteBuffer(this.vertexPositionBufferLow);
920
+ public deleteBuffers() {
921
+
922
+ const gl = this.handler.gl!;
923
+
924
+ gl.deleteBuffer(this.vertexNormalBuffer!);
925
+ gl.deleteBuffer(this.vertexPositionBuffer!);
926
+ gl.deleteBuffer(this.vertexPositionBufferHigh!);
927
+ gl.deleteBuffer(this.vertexPositionBufferLow!);
807
928
 
808
929
  this.vertexNormalBuffer = null;
809
930
  this.vertexPositionBuffer = null;
@@ -812,13 +933,10 @@ class Segment {
812
933
  this.vertexTextureCoordBuffer = null;
813
934
  }
814
935
 
815
- /**
816
- * Delete materials.
817
- */
818
- deleteMaterials() {
819
- var m = this.materials;
936
+ public deleteMaterials() {
937
+ let m = this.materials;
820
938
  for (let i = 0; i < m.length; i++) {
821
- var mi = m[i];
939
+ let mi = m[i];
822
940
  if (mi) {
823
941
  mi.clear();
824
942
  }
@@ -826,10 +944,7 @@ class Segment {
826
944
  this.materials.length = 0;
827
945
  }
828
946
 
829
- /**
830
- * Delete elevation data.
831
- */
832
- deleteElevations() {
947
+ public deleteElevations() {
833
948
  this.terrainExists = false;
834
949
  this.terrainReady = false;
835
950
  this.terrainIsLoading = false;
@@ -837,7 +952,6 @@ class Segment {
837
952
  this.normalMapVertices = null;
838
953
  this.normalMapVerticesHigh = null;
839
954
  this.normalMapVerticesLow = null;
840
-
841
955
  this.normalMapNormals = null;
842
956
 
843
957
  this.tempVertices = null;
@@ -852,24 +966,23 @@ class Segment {
852
966
  this.plainVertices = null;
853
967
  this.plainVerticesHigh = null;
854
968
  this.plainVerticesLow = null;
855
-
856
969
  this.plainNormals = null;
857
970
 
858
971
  if (this.normalMapReady) {
859
- this.handler.gl.deleteTexture(this.normalMapTexture);
972
+ this.handler.gl!.deleteTexture(this.normalMapTexture!);
973
+ this.normalMapReady = false;
860
974
  }
861
- this.normalMapReady = false;
975
+
862
976
  this._appliedNeighborsZoom = [0, 0, 0, 0];
977
+
863
978
  this.normalMapTextureBias[0] = 0;
864
979
  this.normalMapTextureBias[1] = 0;
865
980
  this.normalMapTextureBias[2] = 1;
981
+
866
982
  this._inTheQueue = false;
867
983
  }
868
984
 
869
- /**
870
- * Clear but not destroy segment data.
871
- */
872
- clearSegment() {
985
+ public clearSegment() {
873
986
  this.plainReady = false;
874
987
  this.initialized = false;
875
988
  this.deleteBuffers();
@@ -877,28 +990,30 @@ class Segment {
877
990
  this.deleteElevations();
878
991
  }
879
992
 
880
- /**
881
- * Clear and destroy all segment data.
882
- */
883
- destroySegment() {
993
+ public destroySegment() {
884
994
 
885
995
  this.clearSegment();
886
996
 
887
- var i = this._slices.length;
997
+ let i = this._slices.length;
888
998
  while (i--) {
889
999
  this._slices[i].clear();
890
1000
  }
891
1001
 
1002
+ //@ts-ignore
892
1003
  this._slices = null;
893
-
1004
+ //@ts-ignore
894
1005
  this.node = null;
895
-
1006
+ //@ts-ignore
896
1007
  this.planet = null;
1008
+ //@ts-ignore
897
1009
  this.handler = null;
1010
+ //@ts-ignore
898
1011
  this.bbox = null;
1012
+ //@ts-ignore
899
1013
  this.bsphere = null;
1014
+ //@ts-ignore
900
1015
  this._extent = null;
901
-
1016
+ //@ts-ignore
902
1017
  this.materials = null;
903
1018
 
904
1019
  this.plainVertices = null;
@@ -915,8 +1030,9 @@ class Segment {
915
1030
  this.tempVerticesHigh = null;
916
1031
  this.tempVerticesLow = null;
917
1032
 
918
- this.normalMapTexture = null;
1033
+ //@ts-ignore
919
1034
  this.normalMapTextureBias = null;
1035
+ this.normalMapTexture = null;
920
1036
  this.normalMapVertices = null;
921
1037
  this.normalMapVerticesHigh = null;
922
1038
  this.normalMapVerticesLow = null;
@@ -928,31 +1044,34 @@ class Segment {
928
1044
  this.vertexPositionBufferLow = null;
929
1045
  this.vertexTextureCoordBuffer = null;
930
1046
 
1047
+ // @ts-ignore
931
1048
  this._projection = null;
1049
+ // @ts-ignore
932
1050
  this._appliedNeighborsZoom = null;
933
-
1051
+ // @ts-ignore
934
1052
  this._globalTextureCoordinates = null;
935
1053
  }
936
1054
 
937
- _setExtentLonLat() {
1055
+ /**
1056
+ * @todo: looks like it could be simplified in Segment contructor
1057
+ */
1058
+ public _setExtentLonLat() {
938
1059
  this._extentLonLat = this._extent.inverseMercator();
939
1060
  }
940
1061
 
941
- /**
942
- * Creates bound volumes by segment geographical extent.
943
- */
944
- createBoundsByExtent() {
945
- var ellipsoid = this.planet.ellipsoid,
946
- extent = this._extentLonLat;
1062
+ public createBoundsByExtent() {
1063
+ const ellipsoid = this.planet.ellipsoid;
1064
+ const extent = this._extentLonLat;
947
1065
 
948
- var coord_sw = ellipsoid.geodeticToCartesian(extent.southWest.lon, extent.southWest.lat);
949
- var coord_ne = ellipsoid.geodeticToCartesian(extent.northEast.lon, extent.northEast.lat);
1066
+ const coord_sw = ellipsoid.geodeticToCartesian(extent.southWest.lon, extent.southWest.lat);
1067
+ const coord_ne = ellipsoid.geodeticToCartesian(extent.northEast.lon, extent.northEast.lat);
950
1068
 
951
- var coord_nw = ellipsoid.geodeticToCartesian(
1069
+ const coord_nw = ellipsoid.geodeticToCartesian(
952
1070
  extent.southWest.lon,
953
1071
  extent.northEast.lat
954
1072
  );
955
- var coord_se = ellipsoid.geodeticToCartesian(
1073
+
1074
+ const coord_se = ellipsoid.geodeticToCartesian(
956
1075
  extent.northEast.lon,
957
1076
  extent.southWest.lat
958
1077
  );
@@ -965,7 +1084,7 @@ class Segment {
965
1084
  this.setBoundingVolume3v(coord_sw, coord_ne);
966
1085
  }
967
1086
 
968
- createBoundsByParent() {
1087
+ public createBoundsByParent() {
969
1088
  let pn = this.node;
970
1089
 
971
1090
  while (pn.parentNode && !pn.segment.terrainReady) {
@@ -977,7 +1096,7 @@ class Segment {
977
1096
  let offsetX = this.tileX - pn.segment.tileX * dZ2,
978
1097
  offsetY = this.tileY - pn.segment.tileY * dZ2;
979
1098
 
980
- if (pn.segment.terrainReady && pn.segment.tileZoom >= this.planet.terrain.minZoom) {
1099
+ if (pn.segment.terrainReady && pn.segment.tileZoom >= this.planet.terrain!.minZoom) {
981
1100
  let gridSize = pn.segment.gridSize / dZ2;
982
1101
 
983
1102
  if (gridSize >= 1.0) {
@@ -999,7 +1118,7 @@ class Segment {
999
1118
  ind_ne = 3 * (i0 * pnGsOne + j0 + gridSize),
1000
1119
  ind_se = 3 * ((i0 + gridSize) * pnGsOne + j0 + gridSize);
1001
1120
 
1002
- let pVerts = pn.segment.tempVertices;
1121
+ let pVerts = pn.segment.tempVertices!;
1003
1122
 
1004
1123
  let v_sw = new Vec3(pVerts[ind_sw], pVerts[ind_sw + 1], pVerts[ind_sw + 2]),
1005
1124
  v_ne = new Vec3(pVerts[ind_ne], pVerts[ind_ne + 1], pVerts[ind_ne + 2]);
@@ -1026,9 +1145,9 @@ class Segment {
1026
1145
 
1027
1146
  let bigOne;
1028
1147
  if (pseg.gridSize === 1) {
1029
- bigOne = pseg.tempVertices;
1148
+ bigOne = pseg.tempVertices!;
1030
1149
  } else {
1031
- bigOne = getMatrixSubArray(pseg.tempVertices, pseg.gridSize, i0, j0, 1);
1150
+ bigOne = getMatrixSubArray64(pseg.tempVertices!, pseg.gridSize, i0, j0, 1);
1032
1151
  }
1033
1152
 
1034
1153
  let v_lt = new Vec3(bigOne[0], bigOne[1], bigOne[2]),
@@ -1094,14 +1213,14 @@ class Segment {
1094
1213
  }
1095
1214
  }
1096
1215
 
1097
- setBoundingSphere(x, y, z, v) {
1216
+ public setBoundingSphere(x: number, y: number, z: number, v: Vec3) {
1098
1217
  this.bsphere.center.x = x;
1099
1218
  this.bsphere.center.y = y;
1100
1219
  this.bsphere.center.z = z;
1101
1220
  this.bsphere.radius = this.bsphere.center.distance(v);
1102
1221
  }
1103
1222
 
1104
- setBoundingVolume(xmin, ymin, zmin, xmax, ymax, zmax) {
1223
+ public setBoundingVolume(xmin: number, ymin: number, zmin: number, xmax: number, ymax: number, zmax: number) {
1105
1224
  this.bbox.setFromBoundsArr([xmin, ymin, zmin, xmax, ymax, zmax]);
1106
1225
 
1107
1226
  let x = xmin + (xmax - xmin) * 0.5,
@@ -1112,7 +1231,7 @@ class Segment {
1112
1231
  this.bsphere.radius = this.bsphere.center.distance(new Vec3(xmin, ymin, zmin));
1113
1232
  }
1114
1233
 
1115
- setBoundingVolume3v(vmin, vmax) {
1234
+ public setBoundingVolume3v(vmin: Vec3, vmax: Vec3) {
1116
1235
  this.bbox.setFromBoundsArr([vmin.x, vmin.y, vmin.z, vmax.x, vmax.y, vmax.z]);
1117
1236
 
1118
1237
  let x = vmin.x + (vmax.x - vmin.x) * 0.5,
@@ -1123,7 +1242,7 @@ class Segment {
1123
1242
  this.bsphere.radius = this.bsphere.center.distance(new Vec3(vmin.x, vmin.y, vmin.z));
1124
1243
  }
1125
1244
 
1126
- setBoundingVolumeArr(bounds) {
1245
+ public setBoundingVolumeArr(bounds: NumberArray6) {
1127
1246
  this.bbox.setFromBoundsArr(bounds);
1128
1247
 
1129
1248
  let x = bounds[0] + (bounds[3] - bounds[0]) * 0.5,
@@ -1136,20 +1255,20 @@ class Segment {
1136
1255
  );
1137
1256
  }
1138
1257
 
1139
- createCoordsBuffers(verticesHigh, verticesLow, gridSize) {
1140
- var gsgs = (gridSize + 1) * (gridSize + 1);
1141
- var h = this.handler;
1258
+ public createCoordsBuffers(verticesHigh: Float32Array, verticesLow: Float32Array, gridSize: number) {
1259
+ const gsgs = (gridSize + 1) * (gridSize + 1);
1260
+ const h = this.handler;
1142
1261
 
1143
1262
  if (this.vertexPositionBufferHigh && this.vertexPositionBufferHigh.numItems === gsgs) {
1144
- h.setStreamArrayBuffer(this.vertexPositionBufferHigh, verticesHigh);
1145
- h.setStreamArrayBuffer(this.vertexPositionBufferLow, verticesLow);
1263
+ h.setStreamArrayBuffer(this.vertexPositionBufferHigh!, verticesHigh);
1264
+ h.setStreamArrayBuffer(this.vertexPositionBufferLow!, verticesLow);
1146
1265
  } else {
1147
- h.gl.deleteBuffer(this.vertexPositionBufferHigh);
1148
- h.gl.deleteBuffer(this.vertexPositionBufferLow);
1266
+ h.gl!.deleteBuffer(this.vertexPositionBufferHigh!);
1267
+ h.gl!.deleteBuffer(this.vertexPositionBufferLow!);
1149
1268
 
1150
- this.vertexTextureCoordBuffer =
1151
- this.planet._textureCoordsBufferCache[Math.log2(gridSize)];
1269
+ this.vertexTextureCoordBuffer = this.planet._textureCoordsBufferCache[Math.log2(gridSize)];
1152
1270
 
1271
+ // @todo use it!
1153
1272
  //this.vertexPositionBufferHigh = h.createStreamArrayBuffer(3, gsgs);
1154
1273
  //h.setStreamArrayBuffer(this.vertexPositionBufferHigh, verticesHigh);
1155
1274
  //this.vertexPositionBufferLow = h.createStreamArrayBuffer(3, gsgs);
@@ -1161,10 +1280,10 @@ class Segment {
1161
1280
  }
1162
1281
  }
1163
1282
 
1164
- _addViewExtent() {
1165
- var ext = this._extentLonLat;
1283
+ public _addViewExtent() {
1284
+ const ext = this._extentLonLat;
1166
1285
 
1167
- var viewExt = this.planet._viewExtent;
1286
+ let viewExt = this.planet._viewExtent;
1168
1287
 
1169
1288
  if (ext.southWest.lon < viewExt.southWest.lon) {
1170
1289
  viewExt.southWest.lon = ext.southWest.lon;
@@ -1183,20 +1302,19 @@ class Segment {
1183
1302
  }
1184
1303
  }
1185
1304
 
1186
- _assignTileIndexes() {
1305
+ protected _assignTileIndexes() {
1187
1306
 
1188
1307
  this._tileGroup = TILEGROUP_COMMON;
1189
1308
 
1190
- var tileZoom = this.tileZoom;
1191
- var extent = this._extent;
1192
- var pole = mercator.POLE;
1193
- this.tileX = Math.round(
1194
- Math.abs(-pole - extent.southWest.lon) / (extent.northEast.lon - extent.southWest.lon)
1195
- );
1196
- this.tileY = Math.round(
1197
- Math.abs(pole - extent.northEast.lat) / (extent.northEast.lat - extent.southWest.lat)
1198
- );
1199
- var p2 = Math.pow(2, tileZoom);
1309
+ const tileZoom = this.tileZoom;
1310
+ const extent = this._extent;
1311
+ const pole = mercator.POLE;
1312
+
1313
+ this.tileX = Math.round(Math.abs(-pole - extent.southWest.lon) / (extent.northEast.lon - extent.southWest.lon));
1314
+ this.tileY = Math.round(Math.abs(pole - extent.northEast.lat) / (extent.northEast.lat - extent.southWest.lat));
1315
+
1316
+ const p2 = Math.pow(2, tileZoom);
1317
+
1200
1318
  this.tileXE = (this.tileX + 1) % p2;
1201
1319
  this.tileXW = (p2 + this.tileX - 1) % p2;
1202
1320
 
@@ -1206,22 +1324,17 @@ class Segment {
1206
1324
  this.tileIndex = Layer.getTileIndex(this.tileX, this.tileY, tileZoom);
1207
1325
  }
1208
1326
 
1209
- initialize() {
1210
- var p = this.planet;
1211
- var n = this.node;
1327
+ public initialize() {
1328
+ const p = this.planet;
1329
+ const n = this.node;
1212
1330
 
1213
- this.gridSize =
1214
- p.terrain.gridSizeByZoom[this.tileZoom] || p.terrain.plainGridSize;
1331
+ this.gridSize = p.terrain!.gridSizeByZoom[this.tileZoom] || p.terrain!.plainGridSize;
1215
1332
 
1216
- n.sideSizeLog2[0] = n.sideSizeLog2[1] = n.sideSizeLog2[2] = n.sideSizeLog2[3] =
1217
- Math.log2(this.gridSize);
1333
+ n.sideSizeLog2[0] = n.sideSizeLog2[1] = n.sideSizeLog2[2] = n.sideSizeLog2[3] = Math.log2(this.gridSize);
1218
1334
 
1219
- if (this.tileZoom <= p.terrain.maxZoom) {
1220
- var nmc = this.planet._normalMapCreator;
1221
- this.normalMapTexturePtr = p.renderer.handler.createEmptyTexture_l(
1222
- nmc._width,
1223
- nmc._height
1224
- );
1335
+ if (this.tileZoom <= p.terrain!.maxZoom) {
1336
+ const nmc = this.planet._normalMapCreator;
1337
+ this.normalMapTexturePtr = p.renderer!.handler.createEmptyTexture_l(nmc.width, nmc.height);
1225
1338
  }
1226
1339
 
1227
1340
  this.normalMapTexture = this.planet.transparentTexture;
@@ -1231,8 +1344,8 @@ class Segment {
1231
1344
  this.initialized = true;
1232
1345
  }
1233
1346
 
1234
- _assignGlobalTextureCoordinates() {
1235
- var e = this._extent;
1347
+ protected _assignGlobalTextureCoordinates() {
1348
+ const e = this._extent;
1236
1349
  this._globalTextureCoordinates[0] =
1237
1350
  (e.southWest.lon + mercator.POLE) * mercator.ONE_BY_POLE_DOUBLE;
1238
1351
  this._globalTextureCoordinates[1] =
@@ -1243,9 +1356,9 @@ class Segment {
1243
1356
  (mercator.POLE - e.southWest.lat) * mercator.ONE_BY_POLE_DOUBLE;
1244
1357
  }
1245
1358
 
1246
- createPlainSegmentAsync() {
1359
+ public createPlainSegmentAsync() {
1247
1360
  let p = this.planet,
1248
- t = p.terrain;
1361
+ t = p.terrain!;
1249
1362
 
1250
1363
  if (t.isReady() && !this.plainReady && this.tileZoom <= t.maxZoom) {
1251
1364
  this.plainProcessing = true;
@@ -1253,7 +1366,7 @@ class Segment {
1253
1366
  }
1254
1367
  }
1255
1368
 
1256
- _plainSegmentWorkerCallback(data) {
1369
+ public _plainSegmentWorkerCallback(data: IPlainSegmentWorkerData) {
1257
1370
  this.plainProcessing = false;
1258
1371
 
1259
1372
  if (this.initialized && !this.terrainReady) {
@@ -1274,33 +1387,32 @@ class Segment {
1274
1387
  //this.terrainVerticesHigh = this.plainVerticesHigh;
1275
1388
  //this.terrainVerticesLow = this.plainVerticesLow;
1276
1389
 
1277
- this.fileGridSize = Math.sqrt(data.normalMapVertices.length / 3) - 1;
1390
+ this.fileGridSize = Math.sqrt(data.normalMapVertices!.length / 3) - 1;
1278
1391
  }
1279
1392
  }
1280
1393
 
1281
- createPlainSegment() {
1394
+ public createPlainSegment() {
1282
1395
  this.initialize();
1283
1396
  this._createPlainVertices();
1284
1397
  this.readyToEngage = true;
1285
1398
  }
1286
1399
 
1287
- _createPlainVertices() {
1288
- var gridSize = this.planet.terrain.gridSizeByZoom[this.tileZoom];
1289
-
1290
- var e = this._extent,
1291
- fgs = this.planet.terrain.plainGridSize;
1292
- var lonSize = e.getWidth();
1293
- var llStep = lonSize / Math.max(fgs, gridSize);
1294
- var esw_lon = e.southWest.lon,
1295
- ene_lat = e.northEast.lat;
1296
- var dg = Math.max(fgs / gridSize, 1),
1297
- gs = Math.max(fgs, gridSize) + 1;
1298
- var r2 = this.planet.ellipsoid._invRadii2;
1299
- var ind = 0,
1300
- nmInd = 0;
1400
+ protected _createPlainVertices() {
1401
+ const gridSize = this.planet.terrain!.gridSizeByZoom[this.tileZoom];
1402
+ const e = this._extent;
1403
+ const fgs = this.planet.terrain!.plainGridSize;
1404
+ const lonSize = e.getWidth();
1405
+ const llStep = lonSize / Math.max(fgs, gridSize);
1406
+ const esw_lon = e.southWest.lon;
1407
+ const ene_lat = e.northEast.lat;
1408
+ const dg = Math.max(fgs / gridSize, 1);
1409
+ const gs = Math.max(fgs, gridSize) + 1;
1410
+ const r2 = this.planet.ellipsoid._invRadii2;
1301
1411
  const gsgs = gs * gs;
1412
+ const gridSize3 = (gridSize + 1) * (gridSize + 1) * 3;
1302
1413
 
1303
- var gridSize3 = (gridSize + 1) * (gridSize + 1) * 3;
1414
+ let ind = 0,
1415
+ nmInd = 0;
1304
1416
 
1305
1417
  this.plainNormals = new Float32Array(gridSize3);
1306
1418
  this.plainVertices = new Float64Array(gridSize3);
@@ -1312,7 +1424,7 @@ class Segment {
1312
1424
  this.normalMapVerticesHigh = new Float32Array(gsgs * 3);
1313
1425
  this.normalMapVerticesLow = new Float32Array(gsgs * 3);
1314
1426
 
1315
- var verts = this.plainVertices,
1427
+ let verts = this.plainVertices,
1316
1428
  vertsHigh = this.plainVerticesHigh,
1317
1429
  vertsLow = this.plainVerticesLow,
1318
1430
  norms = this.plainNormals,
@@ -1322,17 +1434,20 @@ class Segment {
1322
1434
  nmNorms = this.normalMapNormals;
1323
1435
 
1324
1436
  for (let k = 0; k < gsgs; k++) {
1325
- var j = k % gs,
1437
+ let j = k % gs,
1326
1438
  i = ~~(k / gs);
1327
1439
 
1328
- var v = this.planet.ellipsoid.lonLatToCartesian(
1440
+ let v = this.planet.ellipsoid.lonLatToCartesian(
1329
1441
  LonLat.inverseMercator(esw_lon + j * llStep, ene_lat - i * llStep)
1330
1442
  );
1331
- var nx = v.x * r2.x,
1443
+
1444
+ let nx = v.x * r2.x,
1332
1445
  ny = v.y * r2.y,
1333
1446
  nz = v.z * r2.z;
1334
- var l = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
1335
- var nxl = nx * l,
1447
+
1448
+ let l = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
1449
+
1450
+ let nxl = nx * l,
1336
1451
  nyl = ny * l,
1337
1452
  nzl = nz * l;
1338
1453
 
@@ -1382,33 +1497,41 @@ class Segment {
1382
1497
  * Gets specific layer material.
1383
1498
  * @public
1384
1499
  * @param {Layer} layer - Layer object.
1385
- * @returns {planetSegment.Material} - Segment material.
1500
+ * @returns {Material | undefined} - Segment material.
1386
1501
  */
1387
- getMaterialByLayer(layer) {
1388
- return this.materials[layer._id];
1502
+ public getMaterialByLayer(layer: Layer): Material | undefined {
1503
+ return this.materials[layer.__id];
1389
1504
  }
1390
1505
 
1391
- _getLayerExtentOffset(layer) {
1392
- var v0s = layer._extentMerc;
1393
- var v0t = this._extent;
1394
- var sSize_x = v0s.northEast.lon - v0s.southWest.lon;
1395
- var sSize_y = v0s.northEast.lat - v0s.southWest.lat;
1396
- var dV0s_x = (v0t.southWest.lon - v0s.southWest.lon) / sSize_x;
1397
- var dV0s_y = (v0s.northEast.lat - v0t.northEast.lat) / sSize_y;
1398
- var dSize_x = (v0t.northEast.lon - v0t.southWest.lon) / sSize_x;
1399
- var dSize_y = (v0t.northEast.lat - v0t.southWest.lat) / sSize_y;
1506
+ /**
1507
+ * @param layer
1508
+ * @protected
1509
+ *
1510
+ * @todo siplify layer._extentMerc in this.getLayerExtent(layer)
1511
+ *
1512
+ */
1513
+
1514
+ protected _getLayerExtentOffset(layer: Layer): [number, number, number, number] {
1515
+ const v0s = layer._extentMerc;
1516
+ const v0t = this._extent;
1517
+ const sSize_x = v0s.northEast.lon - v0s.southWest.lon;
1518
+ const sSize_y = v0s.northEast.lat - v0s.southWest.lat;
1519
+ const dV0s_x = (v0t.southWest.lon - v0s.southWest.lon) / sSize_x;
1520
+ const dV0s_y = (v0s.northEast.lat - v0t.northEast.lat) / sSize_y;
1521
+ const dSize_x = (v0t.northEast.lon - v0t.southWest.lon) / sSize_x;
1522
+ const dSize_y = (v0t.northEast.lat - v0t.southWest.lat) / sSize_y;
1400
1523
  return [dV0s_x, dV0s_y, dSize_x, dSize_y];
1401
1524
  }
1402
1525
 
1403
- screenRendering(sh, layerSlice, sliceIndex, defaultTexture, isOverlay) {
1404
- var gl = this.handler.gl;
1405
- var sha = sh.attributes,
1406
- shu = sh.uniforms;
1526
+ public screenRendering(sh: Program, layerSlice: Layer[], sliceIndex: number, defaultTexture?: WebGLTextureExt | null, isOverlay: boolean = false) {
1527
+ const gl = this.handler.gl!;
1528
+ const sha = sh.attributes;
1529
+ const shu = sh.uniforms;
1407
1530
 
1408
- var pm = this.materials,
1409
- p = this.planet;
1531
+ const pm = this.materials;
1532
+ const p = this.planet;
1410
1533
 
1411
- var currHeight, li;
1534
+ let currHeight, li;
1412
1535
  if (layerSlice && layerSlice.length) {
1413
1536
  li = layerSlice[0];
1414
1537
  currHeight = li._height;
@@ -1418,15 +1541,15 @@ class Segment {
1418
1541
 
1419
1542
  // First always draw whole planet base layer segment with solid texture.
1420
1543
  gl.activeTexture(gl.TEXTURE0 + p.SLICE_SIZE + 2);
1421
- gl.bindTexture(gl.TEXTURE_2D, defaultTexture || this.getDefaultTexture());
1544
+ gl.bindTexture(gl.TEXTURE_2D, (defaultTexture || this.getDefaultTexture())!);
1422
1545
  gl.uniform1i(shu.defaultTexture, p.SLICE_SIZE + 2);
1423
1546
 
1424
- var n = 0,
1547
+ let n = 0,
1425
1548
  i = 0;
1426
1549
 
1427
- var notEmpty = false;
1550
+ let notEmpty = false;
1428
1551
 
1429
- var slice = this._slices[sliceIndex];
1552
+ let slice = this._slices[sliceIndex];
1430
1553
 
1431
1554
  if (!slice) {
1432
1555
  slice = this._slices[sliceIndex] = new Slice(this);
@@ -1446,15 +1569,14 @@ class Segment {
1446
1569
  ) {
1447
1570
  notEmpty = true;
1448
1571
 
1449
- var m = pm[li._id];
1572
+ let m = pm[li.__id];
1450
1573
 
1451
1574
  if (!m) {
1452
- m = pm[li._id] = li.createMaterial(this);
1575
+ m = pm[li.__id] = li.createMaterial(this);
1453
1576
  }
1454
1577
 
1455
1578
  if (!m.isReady) {
1456
1579
  this.planet._renderCompleted = false;
1457
- this.planet._terrainReady = false;
1458
1580
  }
1459
1581
 
1460
1582
  slice.append(li, m);
@@ -1462,7 +1584,7 @@ class Segment {
1462
1584
  p._samplerArr[n] = n;
1463
1585
 
1464
1586
  gl.activeTexture(gl.TEXTURE0 + n);
1465
- gl.bindTexture(gl.TEXTURE_2D, m.texture || p.transparentTexture);
1587
+ gl.bindTexture(gl.TEXTURE_2D, (m.texture || p.transparentTexture)!);
1466
1588
 
1467
1589
  n++;
1468
1590
  }
@@ -1484,7 +1606,7 @@ class Segment {
1484
1606
  // bind normalmap texture
1485
1607
  if (p.lightEnabled) {
1486
1608
  gl.activeTexture(gl.TEXTURE0 + p.SLICE_SIZE + 3);
1487
- gl.bindTexture(gl.TEXTURE_2D, this.normalMapTexture || p.transparentTexture);
1609
+ gl.bindTexture(gl.TEXTURE_2D, (this.normalMapTexture || p.transparentTexture)!);
1488
1610
  gl.uniform1i(shu.uNormalMap, p.SLICE_SIZE + 3);
1489
1611
 
1490
1612
  gl.uniform3fv(shu.uNormalMapBias, this.normalMapTextureBias);
@@ -1493,12 +1615,12 @@ class Segment {
1493
1615
  gl.uniform4fv(shu.uGlobalTextureCoord, this._globalTextureCoordinates);
1494
1616
  }
1495
1617
 
1496
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
1497
- gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
1498
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
1499
- gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
1618
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh!);
1619
+ gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh!.itemSize, gl.FLOAT, false, 0, 0);
1620
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow!);
1621
+ gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow!.itemSize, gl.FLOAT, false, 0, 0);
1500
1622
 
1501
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexTextureCoordBuffer);
1623
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexTextureCoordBuffer!);
1502
1624
  gl.vertexAttribPointer(sha.aTextureCoord, 2, gl.UNSIGNED_SHORT, true, 0, 0);
1503
1625
 
1504
1626
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
@@ -1506,15 +1628,15 @@ class Segment {
1506
1628
  }
1507
1629
  }
1508
1630
 
1509
- heightPickingRendering(sh, layerSlice) {
1510
- var gl = this.handler.gl;
1511
- var sha = sh.attributes,
1512
- shu = sh.uniforms;
1631
+ public heightPickingRendering(sh: Program, layerSlice: Layer[]) {
1632
+ const gl = this.handler.gl!;
1633
+ const sha = sh.attributes;
1634
+ const shu = sh.uniforms;
1513
1635
 
1514
- var pm = this.materials,
1515
- p = this.planet;
1636
+ // var pm = this.materials,
1637
+ // p = this.planet;
1516
1638
 
1517
- var currHeight;
1639
+ let currHeight;
1518
1640
  if (layerSlice && layerSlice.length) {
1519
1641
  currHeight = layerSlice[0]._height;
1520
1642
  } else {
@@ -1523,55 +1645,55 @@ class Segment {
1523
1645
 
1524
1646
  gl.uniform1f(shu.height, currHeight);
1525
1647
 
1526
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
1527
- gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
1648
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh!);
1649
+ gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh!.itemSize, gl.FLOAT, false, 0, 0);
1528
1650
 
1529
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
1530
- gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
1651
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow!);
1652
+ gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow!.itemSize, gl.FLOAT, false, 0, 0);
1531
1653
 
1532
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
1533
- gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
1654
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer!);
1655
+ gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer!.numItems, gl.UNSIGNED_INT, 0);
1534
1656
  }
1535
1657
 
1536
- colorPickingRendering(sh, layerSlice, sliceIndex, defaultTexture, isOverlay) {
1537
- var gl = this.handler.gl;
1538
- var sha = sh.attributes,
1539
- shu = sh.uniforms;
1658
+ public colorPickingRendering(sh: Program, layerSlice: Layer[], sliceIndex: number, defaultTexture?: WebGLTextureExt | null, isOverlay: boolean = false) {
1659
+ const gl = this.handler.gl!;
1660
+ const sha = sh.attributes;
1661
+ const shu = sh.uniforms;
1540
1662
 
1541
- var pm = this.materials,
1663
+ let pm = this.materials,
1542
1664
  p = this.planet;
1543
1665
 
1544
- var currHeight;
1666
+ let currHeight;
1545
1667
  if (layerSlice && layerSlice.length) {
1546
1668
  currHeight = layerSlice[0]._height;
1547
1669
  } else {
1548
1670
  currHeight = 0;
1549
1671
  }
1550
1672
 
1551
- var notEmpty = false;
1673
+ let notEmpty = false;
1552
1674
 
1553
- var slice = this._slices[sliceIndex];
1675
+ let slice = this._slices[sliceIndex];
1554
1676
 
1555
1677
  let len = slice.layers.length;
1556
1678
 
1557
1679
  for (let n = 0; n < len; n++) {
1558
1680
  notEmpty = true;
1559
1681
 
1560
- var li = slice.layers[n];
1561
- var n4 = n * 4;
1682
+ let li = slice.layers[n];
1683
+ let n4 = n * 4;
1562
1684
 
1563
1685
  p._pickingColorArr[n4] = li._pickingColor.x / 255.0;
1564
1686
  p._pickingColorArr[n4 + 1] = li._pickingColor.y / 255.0;
1565
1687
  p._pickingColorArr[n4 + 2] = li._pickingColor.z / 255.0;
1566
- p._pickingColorArr[n4 + 3] = li._pickingEnabled;
1688
+ p._pickingColorArr[n4 + 3] = Number(li._pickingEnabled);
1567
1689
 
1568
1690
  p._samplerArr[n] = n;
1569
1691
  gl.activeTexture(gl.TEXTURE0 + n);
1570
- gl.bindTexture(gl.TEXTURE_2D, pm[li._id].texture || this.planet.transparentTexture);
1692
+ gl.bindTexture(gl.TEXTURE_2D, (pm[li.__id].texture || this.planet.transparentTexture)!);
1571
1693
 
1572
1694
  p._pickingMaskArr[n] = n + p.SLICE_SIZE;
1573
1695
  gl.activeTexture(gl.TEXTURE0 + n + p.SLICE_SIZE);
1574
- gl.bindTexture(gl.TEXTURE_2D, pm[li._id].pickingMask || this.planet.transparentTexture);
1696
+ gl.bindTexture(gl.TEXTURE_2D, (pm[li.__id].pickingMask || this.planet.transparentTexture)!);
1575
1697
  }
1576
1698
 
1577
1699
  if (notEmpty || !isOverlay) {
@@ -1587,23 +1709,23 @@ class Segment {
1587
1709
  gl.uniform1fv(shu.layerOpacityArr, slice.layerOpacityArr);
1588
1710
  //gl.uniform4fv(shu.visibleExtentOffsetArr, slice.visibleExtentOffsetArr);
1589
1711
 
1590
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
1591
- gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
1592
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
1593
- gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
1712
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh!);
1713
+ gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh!.itemSize, gl.FLOAT, false, 0, 0);
1714
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow!);
1715
+ gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow!.itemSize, gl.FLOAT, false, 0, 0);
1594
1716
 
1595
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexTextureCoordBuffer);
1717
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexTextureCoordBuffer!);
1596
1718
  gl.vertexAttribPointer(sha.aTextureCoord, 2, gl.UNSIGNED_SHORT, true, 0, 0);
1597
1719
 
1598
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
1599
- gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
1720
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer!);
1721
+ gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer!.numItems, gl.UNSIGNED_INT, 0);
1600
1722
  }
1601
1723
  }
1602
1724
 
1603
- depthRendering(sh, layerSlice) {
1604
- var gl = this.handler.gl;
1605
- var sha = sh.attributes,
1606
- shu = sh.uniforms;
1725
+ public depthRendering(sh: Program, layerSlice: Layer[]) {
1726
+ const gl = this.handler.gl!;
1727
+ const sha = sh.attributes;
1728
+ const shu = sh.uniforms;
1607
1729
 
1608
1730
  var currHeight;
1609
1731
  if (layerSlice && layerSlice.length) {
@@ -1614,58 +1736,63 @@ class Segment {
1614
1736
 
1615
1737
  gl.uniform1f(shu.height, currHeight);
1616
1738
 
1617
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh);
1618
- gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh.itemSize, gl.FLOAT, false, 0, 0);
1739
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferHigh!);
1740
+ gl.vertexAttribPointer(sha.aVertexPositionHigh, this.vertexPositionBufferHigh!.itemSize, gl.FLOAT, false, 0, 0);
1619
1741
 
1620
- gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow);
1621
- gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow.itemSize, gl.FLOAT, false, 0, 0);
1742
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBufferLow!);
1743
+ gl.vertexAttribPointer(sha.aVertexPositionLow, this.vertexPositionBufferLow!.itemSize, gl.FLOAT, false, 0, 0);
1622
1744
 
1623
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
1624
- gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
1745
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer!);
1746
+ gl.drawElements(gl.TRIANGLE_STRIP, this._indexBuffer!.numItems, gl.UNSIGNED_INT, 0);
1625
1747
  }
1626
1748
 
1627
- _getIndexBuffer() {
1628
- let s = this.node.sideSizeLog2;
1749
+ protected _getIndexBuffer(): WebGLBufferExt {
1750
+ const s = this.node.sideSizeLog2;
1629
1751
  let cache = this.planet._indexesCache[Math.log2(this.gridSize)][s[0]][s[1]][s[2]][s[3]];
1630
1752
  if (!cache.buffer) {
1631
1753
  let indexes = segmentHelper.getInstance().createSegmentIndexes(Math.log2(this.gridSize), [s[0], s[1], s[2], s[3]]);
1632
- cache.buffer = this.planet.renderer.handler.createElementArrayBuffer(indexes, 1);
1754
+ cache.buffer = this.planet.renderer!.handler.createElementArrayBuffer(indexes, 1);
1633
1755
  this.planet._indexesCacheToRemoveCounter++;
1634
- indexes = null;
1635
1756
  }
1636
1757
  return cache.buffer;
1637
1758
  }
1638
1759
 
1639
- _collectVisibleNodes() {
1760
+ /**
1761
+ * @todo: replace to the strategy
1762
+ */
1763
+ public _collectVisibleNodes() {
1640
1764
  this.planet._visibleNodes[this.node.nodeId] = this.node;
1641
1765
  }
1642
1766
 
1643
- layerOverlap(layer) {
1767
+ public layerOverlap(layer: Layer): boolean {
1644
1768
  return this._extent.overlaps(layer._extentMerc);
1645
1769
  }
1646
1770
 
1647
- getDefaultTexture() {
1771
+ public getDefaultTexture(): WebGLTextureExt | null {
1648
1772
  return this.planet.solidTextureOne;
1649
1773
  }
1650
1774
 
1651
- getExtentLonLat() {
1775
+ public getExtentLonLat(): Extent {
1652
1776
  return this._extentLonLat;
1653
1777
  }
1654
1778
 
1655
- getExtentMerc() {
1656
- return this._extent;
1779
+ public getExtentMerc(): Extent {
1780
+ return this._extentMerc;
1657
1781
  }
1658
1782
 
1659
- getExtent() {
1783
+ public getExtent(): Extent {
1660
1784
  return this._extent;
1661
1785
  }
1662
1786
 
1663
- getNodeState() {
1664
- var vn = this.planet._visibleNodes[this.node.nodeId];
1787
+ /**
1788
+ * @todo replace to the strategy
1789
+ */
1790
+ public getNodeState(): number {
1791
+ let vn = this.planet._visibleNodes[this.node.nodeId];
1665
1792
  return (vn && vn.state) || NOTRENDERING;
1666
1793
  }
1667
1794
 
1668
- getNeighborSide(b) {
1795
+ public getNeighborSide(b: Segment) {
1669
1796
  if (this.tileY === b.tileY) {
1670
1797
  if (this.tileX === b.tileXE) {
1671
1798
  return W;
@@ -1679,9 +1806,8 @@ class Segment {
1679
1806
  return S;
1680
1807
  }
1681
1808
  }
1682
-
1683
1809
  return -1;
1684
1810
  }
1685
1811
  }
1686
1812
 
1687
- export { Segment };
1813
+ export {Segment};