@openglobus/og 0.15.5 → 0.16.1

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 (126) hide show
  1. package/README.md +1 -1
  2. package/css/og.css +1 -1
  3. package/dist/@openglobus/og.css +1 -1
  4. package/dist/@openglobus/og.esm.js +2 -2
  5. package/dist/@openglobus/og.esm.js.map +1 -1
  6. package/dist/@openglobus/og.umd.js +2 -2
  7. package/dist/@openglobus/og.umd.js.map +1 -1
  8. package/package.json +13 -15
  9. package/src/og/Globe.js +5 -2
  10. package/src/og/LonLat.js +18 -1
  11. package/src/og/Object3d.js +21 -2
  12. package/src/og/bv/index.js +2 -2
  13. package/src/og/camera/PlanetCamera.js +4 -10
  14. package/src/og/control/LayerSwitcher.js +4 -3
  15. package/src/og/control/RulerSwitcher.js +2 -2
  16. package/src/og/control/ZoomControl.js +2 -2
  17. package/src/og/control/heightRuler/HeightRulerScene.js +6 -2
  18. package/src/og/control/index.js +5 -2
  19. package/src/og/control/ruler/RulerScene.js +11 -8
  20. package/src/og/control/timeline/TimelineControl.js +5 -3
  21. package/src/og/control/timeline/TimelineModel.js +4 -0
  22. package/src/og/control/timeline/TimelineView.js +10 -3
  23. package/src/og/control/visibleExtent/Segment.js +36 -42
  24. package/src/og/ellipsoid/Ellipsoid.js +23 -10
  25. package/src/og/entity/Entity.js +3 -3
  26. package/src/og/entity/EntityCollection.js +2 -2
  27. package/src/og/entity/Label.js +1 -1
  28. package/src/og/entity/Polyline.js +4 -2
  29. package/src/og/index.js +4 -7
  30. package/src/og/layer/CanvasTiles.js +70 -23
  31. package/src/og/layer/GeoImage.js +40 -18
  32. package/src/og/layer/Vector.js +14 -11
  33. package/src/og/layer/WMS.js +2 -2
  34. package/src/og/math.js +2 -1
  35. package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +26 -0
  36. package/src/og/quadTree/Node.js +44 -50
  37. package/src/og/quadTree/index.js +2 -0
  38. package/src/og/renderer/Renderer.js +13 -1
  39. package/src/og/scene/Planet.js +4 -4
  40. package/src/og/scene/index.js +3 -3
  41. package/src/og/segment/Segment.js +88 -76
  42. package/src/og/shaders/drawnode.js +138 -89
  43. package/src/og/shaders/geoObject.js +57 -46
  44. package/src/og/shaders/ray.js +15 -21
  45. package/src/og/terrain/EmptyTerrain.js +19 -7
  46. package/src/og/terrain/GlobusTerrain.js +23 -18
  47. package/src/og/terrain/MapboxTerrain.js +7 -8
  48. package/src/og/terrain/index.js +4 -4
  49. package/src/og/utils/objParser.js +227 -0
  50. package/src/og/utils/shared.js +9 -0
  51. package/src/og/webgl/Handler.js +1 -3
  52. package/types/Globe.d.ts +2 -0
  53. package/types/LonLat.d.ts +12 -1
  54. package/types/Object3d.d.ts +2 -0
  55. package/types/Popup.d.ts +1 -1
  56. package/types/bv/index.d.ts +2 -2
  57. package/types/camera/PlanetCamera.d.ts +0 -7
  58. package/types/camera/index.d.ts +2 -2
  59. package/types/control/GeoImageDragControl.d.ts +1 -1
  60. package/types/control/LayerAnimation.d.ts +1 -1
  61. package/types/control/Lighting.d.ts +2 -2
  62. package/types/control/heightRuler/HeightRulerScene.d.ts +1 -1
  63. package/types/control/index.d.ts +3 -2
  64. package/types/control/ruler/RulerScene.d.ts +5 -4
  65. package/types/control/selection/SelectionScene.d.ts +3 -3
  66. package/types/control/timeline/TimelineControl.d.ts +10 -0
  67. package/types/control/timeline/TimelineModel.d.ts +33 -0
  68. package/types/control/timeline/TimelineView.d.ts +57 -0
  69. package/types/control/timeline/timelineUtils.d.ts +9 -0
  70. package/types/ellipsoid/Ellipsoid.d.ts +16 -9
  71. package/types/ellipsoid/index.d.ts +2 -2
  72. package/types/entity/Entity.d.ts +3 -3
  73. package/types/entity/EntityCollection.d.ts +2 -2
  74. package/types/entity/Label.d.ts +1 -1
  75. package/types/entity/Polyline.d.ts +1 -0
  76. package/types/index.d.ts +45 -46
  77. package/types/layer/CanvasTiles.d.ts +2 -1
  78. package/types/layer/GeoImage.d.ts +7 -1
  79. package/types/layer/GeoTexture2d.d.ts +1 -1
  80. package/types/layer/Vector.d.ts +3 -3
  81. package/types/layer/index.d.ts +9 -9
  82. package/types/math/Line2.d.ts +1 -1
  83. package/types/math/Line3.d.ts +1 -1
  84. package/types/math/index.d.ts +10 -10
  85. package/types/mercator.d.ts +1 -1
  86. package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +3 -0
  87. package/types/quadTree/EntityCollectionNode.d.ts +1 -1
  88. package/types/quadTree/index.d.ts +2 -0
  89. package/types/renderer/Renderer.d.ts +2 -2
  90. package/types/scene/Axes.d.ts +1 -1
  91. package/types/scene/SkyBox.d.ts +1 -1
  92. package/types/scene/index.d.ts +3 -3
  93. package/types/segment/Segment.d.ts +9 -11
  94. package/types/shaders/atmos.d.ts +1 -1
  95. package/types/shaders/billboard.d.ts +1 -1
  96. package/types/shaders/depth.d.ts +1 -1
  97. package/types/shaders/label.d.ts +1 -1
  98. package/types/shaders/pickingMask.d.ts +1 -1
  99. package/types/shaders/pointCloud.d.ts +1 -1
  100. package/types/shaders/polyline.d.ts +1 -1
  101. package/types/shaders/ray.d.ts +1 -1
  102. package/types/shaders/screenFrame.d.ts +1 -1
  103. package/types/shaders/skybox.d.ts +1 -1
  104. package/types/shaders/toneMapping.d.ts +1 -1
  105. package/types/terrain/BilTerrain.d.ts +1 -0
  106. package/types/terrain/EmptyTerrain.d.ts +13 -2
  107. package/types/terrain/GlobusTerrain.d.ts +2 -1
  108. package/types/terrain/MapboxTerrain.d.ts +1 -3
  109. package/types/terrain/index.d.ts +4 -4
  110. package/types/ui/Button.d.ts +1 -1
  111. package/types/ui/ButtonGroup.d.ts +12 -0
  112. package/types/ui/Dialog.d.ts +2 -2
  113. package/types/ui/Slider.d.ts +1 -1
  114. package/types/ui/ToggleButton.d.ts +1 -1
  115. package/types/ui/View.d.ts +1 -1
  116. package/types/utils/GeoImageCreator.d.ts +2 -2
  117. package/types/utils/ImagesCacheManager.d.ts +1 -1
  118. package/types/utils/Loader.d.ts +1 -1
  119. package/types/utils/VectorTileCreator.d.ts +1 -1
  120. package/types/utils/objParser.d.ts +8 -0
  121. package/types/utils/shared.d.ts +6 -0
  122. package/types/webgl/Handler.d.ts +2 -2
  123. package/src/og/index.core.js +0 -116
  124. package/src/og/index.webgl.js +0 -17
  125. package/types/index.core.d.ts +0 -65
  126. package/types/index.webgl.d.ts +0 -7
@@ -177,26 +177,21 @@ class Node {
177
177
  this.neighbors[2] = [];
178
178
  this.neighbors[3] = [];
179
179
 
180
- let seg = this.segment, planet = this.planet;
180
+ let seg = this.segment,
181
+ planet = this.planet;
181
182
 
182
183
  this._cameraInside = false;
183
184
 
184
- let insideLonLat = null;
185
-
186
185
  // Search a node which the camera is flying over.
187
186
  if (!this.parentNode || this.parentNode._cameraInside) {
188
187
  let inside;
189
188
  if (Math.abs(cam._lonLat.lat) <= MAX_LAT && seg._projection.id === EPSG3857.id) {
190
189
  inside = seg._extent.isInside(cam._lonLatMerc);
191
- insideLonLat = cam._lonLatMerc;
192
190
  } else if (seg._projection.id === EPSG4326.id) {
193
191
  inside = seg._extent.isInside(cam._lonLat);
194
- insideLonLat = cam._lonLat;
195
192
  }
196
193
 
197
194
  if (inside) {
198
- cam._insideSegmentPosition.lon = insideLonLat.lon;
199
- cam._insideSegmentPosition.lat = insideLonLat.lat;
200
195
  cam._insideSegment = seg;
201
196
  this._cameraInside = true;
202
197
  }
@@ -247,7 +242,7 @@ class Node {
247
242
  seg._collectVisibleNodes();
248
243
  }
249
244
 
250
- if (seg.tileZoom < 2 && seg.normalMapReady) {
245
+ if (seg.tileZoom < 2) {
251
246
  this.traverseNodes(cam, maxZoom, terrainReadySegment, stopLoading);
252
247
  } else if (seg.terrainReady && (!maxZoom && cam.projectedSize(seg.bsphere.center, seg._plainRadius) < planet._lodSize || maxZoom && ((seg.tileZoom === maxZoom) || !altVis))) {
253
248
 
@@ -285,7 +280,7 @@ class Node {
285
280
  }
286
281
 
287
282
  renderNode(inFrustum, onlyTerrain, terrainReadySegment, stopLoading) {
288
- var seg = this.segment;
283
+ let seg = this.segment;
289
284
 
290
285
  // Create and load terrain data
291
286
  if (!seg.terrainReady) {
@@ -305,7 +300,7 @@ class Node {
305
300
  }
306
301
 
307
302
  // Create normal map texture
308
- if (seg.planet.lightEnabled && !seg.normalMapReady /*&& !seg.parentNormalMapReady*/) {
303
+ if (seg.planet.lightEnabled && !seg.normalMapReady) {
309
304
  this.whileNormalMapCreating();
310
305
  }
311
306
 
@@ -487,36 +482,28 @@ class Node {
487
482
  }
488
483
 
489
484
  whileNormalMapCreating() {
490
- var seg = this.segment;
491
- var maxZ = this.planet.terrain.maxZoom;
492
485
 
493
- if (seg.tileZoom <= maxZ && !seg.terrainIsLoading && seg.terrainReady && !seg._inTheQueue) {
486
+ let seg = this.segment;
487
+
488
+ if (/*seg.tileZoom <= seg.planet.terrain.maxNativeZoom && */!seg.terrainIsLoading && seg.terrainExists && !seg._inTheQueue) {
494
489
  seg.planet._normalMapCreator.queue(seg);
495
490
  }
496
491
 
497
- var pn = this;
498
-
492
+ let pn = this;
499
493
  while (pn.parentNode && !pn.segment.normalMapReady) {
500
494
  pn = pn.parentNode;
501
495
  }
502
496
 
503
- var dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1);
497
+ let dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1);
504
498
 
505
499
  seg.normalMapTexture = pn.segment.normalMapTexture;
506
500
  seg.normalMapTextureBias[0] = seg.tileX - pn.segment.tileX * dZ2;
507
501
  seg.normalMapTextureBias[1] = seg.tileY - pn.segment.tileY * dZ2;
508
502
  seg.normalMapTextureBias[2] = 1.0 / dZ2;
509
-
510
- if (seg.tileZoom > maxZ) {
511
- if (pn.segment.tileZoom === maxZ) {
512
- seg.parentNormalMapReady = true;
513
- }
514
- }
515
503
  }
516
504
 
517
505
  whileTerrainLoading(terrainReadySegment, stopLoading) {
518
506
  const seg = this.segment;
519
- const terrain = this.planet.terrain;
520
507
 
521
508
  let pn = this;
522
509
 
@@ -529,18 +516,23 @@ class Node {
529
516
  }
530
517
 
531
518
  if (pn.segment.terrainReady && this.appliedTerrainNodeId !== pn.nodeId) {
532
- let dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1), offsetX = seg.tileX - pn.segment.tileX * dZ2,
519
+ let dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1),
520
+ offsetX = seg.tileX - pn.segment.tileX * dZ2,
533
521
  offsetY = seg.tileY - pn.segment.tileY * dZ2;
534
522
 
535
523
  let pseg = pn.segment;
536
524
 
537
- let tempVertices, tempVerticesHigh, tempVerticesLow, noDataVertices;
525
+ let tempVertices,
526
+ tempVerticesHigh,
527
+ tempVerticesLow,
528
+ noDataVertices;
538
529
 
539
530
  this.appliedTerrainNodeId = pn.nodeId;
540
531
  this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] = this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
541
532
 
542
533
 
543
- let gridSize = pn.segment.gridSize / dZ2, gridSizeExt = pn.segment.fileGridSize / dZ2;
534
+ let gridSize = pn.segment.gridSize / dZ2,
535
+ gridSizeExt = pn.segment.fileGridSize / dZ2;
544
536
 
545
537
  BOUNDS.xmin = MAX;
546
538
  BOUNDS.xmax = MIN;
@@ -562,7 +554,7 @@ class Node {
562
554
  }
563
555
 
564
556
  getMatrixSubArrayBoundsExt(pseg.terrainVertices, pseg.terrainVerticesHigh, pseg.terrainVerticesLow, pseg.noDataVertices, pseg.gridSize, gridSize * offsetY, gridSize * offsetX, gridSize, tempVertices, tempVerticesHigh, tempVerticesLow, BOUNDS, noDataVertices);
565
- } else if (gridSizeExt >= 1) {
557
+ } else if (gridSizeExt >= 1 && pn.segment.terrainExists) {
566
558
  seg.gridSize = gridSizeExt;
567
559
 
568
560
  let len = (gridSizeExt + 1) * (gridSizeExt + 1) * 3;
@@ -658,9 +650,9 @@ class Node {
658
650
 
659
651
  seg.setBoundingVolume(BOUNDS.xmin, BOUNDS.ymin, BOUNDS.zmin, BOUNDS.xmax, BOUNDS.ymax, BOUNDS.zmax);
660
652
 
661
- if (seg.tileZoom > terrain.maxZoom) {
662
- if (pn.segment.tileZoom >= terrain.maxZoom) {
663
- //TODO: find better place for this
653
+ if (seg.tileZoom > seg.planet.terrain.maxZoom) {
654
+ if (pn.segment.tileZoom >= seg.planet.terrain.maxZoom) {
655
+
664
656
  seg._plainRadius = pn.segment._plainRadius / dZ2;
665
657
 
666
658
  seg.terrainReady = true;
@@ -670,11 +662,12 @@ class Node {
670
662
  seg.terrainVerticesHigh = tempVerticesHigh;
671
663
  seg.terrainVerticesLow = tempVerticesLow;
672
664
 
665
+ seg.passReady = true;
666
+
673
667
  this.appliedTerrainNodeId = this.nodeId;
674
668
  this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] = this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
675
669
 
676
670
  if (pn.segment.terrainExists) {
677
- seg.terrainExists = true;
678
671
  seg.normalMapVertices = tempVertices;
679
672
  seg.fileGridSize = Math.sqrt(tempVertices.length / 3) - 1;
680
673
 
@@ -687,26 +680,27 @@ class Node {
687
680
  seg.normalMapNormals = pseg.normalMapNormals;
688
681
  }
689
682
  }
690
- } else {
691
- pn = this;
692
- while (pn.parentNode && pn.segment.tileZoom !== terrain.maxZoom) {
693
- pn = pn.parentNode;
694
- }
695
-
696
- let pns = pn.segment;
697
-
698
- if (!pns.initialized) {
699
- pns.initialize();
700
- }
701
-
702
- if (!pns.plainProcessing) {
703
- pn.segment.createPlainSegmentAsync();
704
- }
705
-
706
- if (pns.plainReady && !stopLoading) {
707
- pns.loadTerrain(true);
708
- }
709
683
  }
684
+ // else {
685
+ // pn = this;
686
+ // while (pn.parentNode && pn.segment.tileZoom !== seg.planet.terrain.maxZoom) {
687
+ // pn = pn.parentNode;
688
+ // }
689
+ //
690
+ // let pns = pn.segment;
691
+ //
692
+ // if (!pns.initialized) {
693
+ // pns.initialize();
694
+ // }
695
+ //
696
+ // if (!pns.plainProcessing) {
697
+ // pn.segment.createPlainSegmentAsync();
698
+ // }
699
+ //
700
+ // if (pns.plainReady && !stopLoading) {
701
+ // pns.loadTerrain(true);
702
+ // }
703
+ // }
710
704
  }
711
705
  }
712
706
  }
@@ -1,9 +1,11 @@
1
1
  import { EarthQuadTreeStrategy } from "./EarthQuadTreeStrategy.js";
2
2
  import { MarsQuadTreeStrategy } from "./MarsQuadTreeStrategy.js";
3
+ import { EPSG4326QuadTreeStrategy } from "./EPSG4326QuadTreeStrategy.js";
3
4
  import { QuadTreeStrategy } from "./QuadTreeStrategy.js";
4
5
  import { Wgs84QuadTreeStrategy } from "./Wgs84QuadTreeStrategy.js";
5
6
 
6
7
  const quadTreeStrategyType = {
8
+ epsg4326: EPSG4326QuadTreeStrategy,
7
9
  earth: EarthQuadTreeStrategy,
8
10
  mars: MarsQuadTreeStrategy,
9
11
  wgs84: Wgs84QuadTreeStrategy
@@ -24,6 +24,8 @@ let __depthCallbackCounter__ = 0;
24
24
 
25
25
  let __distanceCallbackCounter__ = 0;
26
26
 
27
+ const MSAA_DEFAULT = 0;
28
+
27
29
  /**
28
30
  * Represents high level WebGL context interface that starts WebGL handler working in real time.
29
31
  * @class
@@ -177,7 +179,13 @@ class Renderer {
177
179
  this.depthFramebuffer = null;
178
180
 
179
181
  let urlParams = new URLSearchParams(location.search);
180
- this._msaa = Number(urlParams.get('og_msaa') || params.msaa || 4);
182
+ let msaaParam = urlParams.get('og_msaa');
183
+ if (msaaParam) {
184
+ this._msaa = Number(urlParams.get('og_msaa'));
185
+ } else {
186
+ this._msaa = params.msaa != undefined ? params.msaa : MSAA_DEFAULT;
187
+ }
188
+
181
189
  this._internalFormat = "RGBA16F";
182
190
  this._format = "RGBA";
183
191
  this._type = "FLOAT";
@@ -797,6 +805,10 @@ class Renderer {
797
805
 
798
806
  i = rn.length;
799
807
  while (i--) {
808
+ gl.enable(gl.BLEND);
809
+ gl.blendEquation(gl.FUNC_ADD);
810
+ gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
811
+
800
812
  rn[i].drawNode();
801
813
  }
802
814
 
@@ -354,7 +354,7 @@ export class Planet extends RenderNode {
354
354
  */
355
355
  this._useSpecularTexture = isUndef(options.useSpecularTexture) ? true : options.useSpecularTexture;
356
356
 
357
- this._maxGridSize = Math.log2(options.maxGridSize || 128);
357
+ this._maxGridSize = Math.log2(options.maxGridSize || 256);
358
358
 
359
359
  /**
360
360
  * Segment multiple textures size.(4 - convinient value for the most devices)
@@ -1142,7 +1142,7 @@ export class Planet extends RenderNode {
1142
1142
  }
1143
1143
 
1144
1144
  if (this.camera.isFirstPass) {
1145
- this.camera.updateGeodeticPosition();
1145
+ this.camera.update();
1146
1146
  this._firstPASS();
1147
1147
  this.camera.checkTerrainCollision();
1148
1148
  this.camera.update();
@@ -1231,7 +1231,7 @@ export class Planet extends RenderNode {
1231
1231
 
1232
1232
  gl.enable(gl.BLEND);
1233
1233
  gl.blendEquation(gl.FUNC_ADD);
1234
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
1234
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
1235
1235
 
1236
1236
  if (this.lightEnabled) {
1237
1237
  h.programs.drawnode_screen_wl.activate();
@@ -1341,7 +1341,7 @@ export class Planet extends RenderNode {
1341
1341
 
1342
1342
  gl.enable(gl.BLEND);
1343
1343
  gl.blendEquation(gl.FUNC_ADD);
1344
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
1344
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
1345
1345
 
1346
1346
  if (this.lightEnabled) {
1347
1347
  h.programs.drawnode_screen_wl.activate();
@@ -1,5 +1,5 @@
1
- import { Axes } from "./Axes";
2
- import { Planet } from "./Planet";
3
- import { SkyBox } from "./SkyBox";
1
+ import { Axes } from "./Axes.js";
2
+ import { Planet } from "./Planet.js";
3
+ import { SkyBox } from "./SkyBox.js";
4
4
 
5
5
  export { Planet, Axes, SkyBox };
@@ -174,12 +174,6 @@ class Segment {
174
174
  */
175
175
  this.normalMapReady = false;
176
176
 
177
- /**
178
- * Parent normal map is made allready(optimization parameter).
179
- * @type {boolean}
180
- */
181
- this.parentNormalMapReady = false;
182
-
183
177
  /**
184
178
  * Terrain is allready applied flag.
185
179
  * @type {boolean}
@@ -360,7 +354,7 @@ class Segment {
360
354
  * @param {boolean} forceLoading
361
355
  */
362
356
  loadTerrain(forceLoading) {
363
- if (this.tileZoom < this.planet.terrain.minZoom) {
357
+ if (this.tileZoom < this.planet.terrain.minZoom || this.planet.terrain.isEmpty) {
364
358
  this.terrainIsLoading = true;
365
359
 
366
360
  this.elevationsNotExists();
@@ -374,6 +368,9 @@ class Segment {
374
368
  } else if (!this.terrainIsLoading && !this.terrainReady) {
375
369
  this.planet.terrain.loadTerrain(this, forceLoading);
376
370
  }
371
+ // if (!this.terrainIsLoading && !this.terrainReady) {
372
+ // this.planet.terrain.loadTerrain(this, forceLoading);
373
+ // }
377
374
  }
378
375
  }
379
376
 
@@ -382,9 +379,8 @@ class Segment {
382
379
  * @param {Float32Array} elevations - Elevation data.
383
380
  */
384
381
  elevationsExists(elevations) {
385
- const segment = this;
386
382
  if (this.plainReady && this.terrainIsLoading) {
387
- this.planet._terrainWorker.make(segment, elevations);
383
+ this.planet._terrainWorker.make(this, elevations);
388
384
 
389
385
  this.plainVerticesHigh = null;
390
386
  this.plainVerticesLow = null;
@@ -399,6 +395,63 @@ class Segment {
399
395
  }
400
396
  }
401
397
 
398
+ /**
399
+ * Keep plain elevation segment for rendering
400
+ *
401
+ * 'this.tileZoom <= this.planet.terrain.maxZoom' it means, that the segment is plain
402
+ *
403
+ */
404
+ elevationsNotExists() {
405
+ if (this.planet && this.tileZoom <= this.planet.terrain.maxNativeZoom) {
406
+ if (this.plainReady && this.terrainIsLoading) {
407
+ this.terrainIsLoading = false;
408
+
409
+ let n = this.node;
410
+ n.appliedTerrainNodeId = this.node.nodeId;
411
+ n.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[S] =
412
+ n.equalizedSideWithNodeId[W] = n.appliedTerrainNodeId;
413
+
414
+ if (this.planet.lightEnabled && !this._inTheQueue) {
415
+ this.planet._normalMapCreator.queue(this);
416
+ }
417
+
418
+ this.readyToEngage = true;
419
+ }
420
+
421
+ // plain terrain only
422
+ this.terrainVertices = this.plainVertices;
423
+ this.terrainVerticesHigh = this.plainVerticesHigh;
424
+ this.terrainVerticesLow = this.plainVerticesLow;
425
+
426
+ this.tempVertices = this.terrainVertices;
427
+ this.tempVerticesHigh = this.terrainVerticesHigh;
428
+ this.tempVerticesLow = this.terrainVerticesLow;
429
+
430
+ this.noDataVertices = null;
431
+
432
+ this.fileGridSize = Math.sqrt(this.terrainVertices.length / 3) - 1;
433
+ this.gridSize = this.fileGridSize;
434
+ this.terrainReady = true;
435
+ this.terrainExists = false;
436
+ } else {
437
+
438
+ if (this.plainReady && this.terrainIsLoading) {
439
+ this.terrainIsLoading = false;
440
+
441
+ let n = this.node;
442
+ n.appliedTerrainNodeId = this.node.nodeId;
443
+ n.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[S] =
444
+ n.equalizedSideWithNodeId[W] = n.appliedTerrainNodeId;
445
+
446
+ this.readyToEngage = true;
447
+ this.terrainReady = true;
448
+ this.passReady = true;
449
+
450
+ this.terrainExists = false;
451
+ }
452
+ }
453
+ }
454
+
402
455
  _checkEqualization(neighborSide, neigborNode) {
403
456
  return neigborNode && this.tileZoom >= neigborNode.segment.tileZoom &&
404
457
  this.node.equalizedSideWithNodeId[neighborSide] !== neigborNode.equalizedSideWithNodeId[OPSIDE[neighborSide]];
@@ -582,33 +635,6 @@ class Segment {
582
635
  this.createCoordsBuffers(this.tempVerticesHigh, this.tempVerticesLow, this.gridSize);
583
636
  }
584
637
 
585
- _plainSegmentWorkerCallback(data) {
586
- this.plainProcessing = false;
587
-
588
- if (this.initialized && !this.terrainReady) {
589
- this.plainVertices = data.plainVertices;
590
- this.plainVerticesHigh = data.plainVerticesHigh;
591
- this.plainVerticesLow = data.plainVerticesLow;
592
-
593
- this.plainNormals = data.plainNormals;
594
-
595
- this.normalMapNormals = data.normalMapNormals;
596
- this.normalMapVertices = data.normalMapVertices;
597
- this.normalMapVerticesHigh = data.normalMapVerticesHigh;
598
- this.normalMapVerticesLow = data.normalMapVerticesLow;
599
-
600
- this.terrainVertices = this.plainVertices;
601
- this.terrainVerticesHigh = this.plainVerticesHigh;
602
- this.terrainVerticesLow = this.plainVerticesLow;
603
-
604
- this.fileGridSize = Math.sqrt(data.normalMapVertices.length / 3) - 1;
605
-
606
- this._plainRadius = data.plainRadius;
607
-
608
- this.plainReady = true;
609
- }
610
- }
611
-
612
638
  _terrainWorkerCallback(data) {
613
639
  if (this.plainReady) {
614
640
  this.readyToEngage = true;
@@ -654,7 +680,6 @@ class Segment {
654
680
 
655
681
  this.terrainReady = true;
656
682
  this.terrainIsLoading = false;
657
- this.parentNormalMapReady = true;
658
683
  this.terrainExists = true;
659
684
 
660
685
  if (!this.normalMapTexturePtr) {
@@ -671,43 +696,6 @@ class Segment {
671
696
  }
672
697
  }
673
698
 
674
- /**
675
- * Terrain is not obtained or not exists on the server.
676
- */
677
- elevationsNotExists() {
678
- if (this.planet && this.tileZoom <= this.planet.terrain.maxZoom) {
679
- if (this.plainReady && this.terrainIsLoading) {
680
- this.terrainIsLoading = false;
681
-
682
- let n = this.node;
683
- n.appliedTerrainNodeId = this.node.nodeId;
684
- n.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[S] =
685
- n.equalizedSideWithNodeId[W] = n.appliedTerrainNodeId;
686
-
687
- if (this.planet.lightEnabled && !this._inTheQueue) {
688
- this.planet._normalMapCreator.queue(this);
689
- }
690
-
691
- this.readyToEngage = true;
692
- }
693
-
694
- this.terrainVertices = this.plainVertices;
695
- this.terrainVerticesHigh = this.plainVerticesHigh;
696
- this.terrainVerticesLow = this.plainVerticesLow;
697
-
698
- this.tempVertices = this.terrainVertices;
699
- this.tempVerticesHigh = this.terrainVerticesHigh;
700
- this.tempVerticesLow = this.terrainVerticesLow;
701
-
702
- this.noDataVertices = null;
703
-
704
- this.fileGridSize = Math.sqrt(this.terrainVertices.length / 3) - 1;
705
- this.gridSize = this.fileGridSize;
706
- this.terrainReady = true;
707
- this.terrainExists = false;
708
- }
709
- }
710
-
711
699
  _normalMapEdgeEqualize(side) {
712
700
  let nn = this.node.neighbors;
713
701
  let n = nn[side][0];
@@ -867,7 +855,6 @@ class Segment {
867
855
  this.handler.gl.deleteTexture(this.normalMapTexture);
868
856
  }
869
857
  this.normalMapReady = false;
870
- this.parentNormalMapReady = false;
871
858
  this._appliedNeighborsZoom = [0, 0, 0, 0];
872
859
  this.normalMapTextureBias[0] = 0;
873
860
  this.normalMapTextureBias[1] = 0;
@@ -1256,12 +1243,37 @@ class Segment {
1256
1243
  let p = this.planet,
1257
1244
  t = p.terrain;
1258
1245
 
1259
- if (t.isReady() && this.tileZoom <= t.maxZoom && !this.plainReady) {
1246
+ if (t.isReady() && !this.plainReady && this.tileZoom <= t.maxZoom) {
1260
1247
  this.plainProcessing = true;
1261
1248
  p._plainSegmentWorker.make(this);
1262
1249
  }
1263
1250
  }
1264
1251
 
1252
+ _plainSegmentWorkerCallback(data) {
1253
+ this.plainProcessing = false;
1254
+
1255
+ if (this.initialized && !this.terrainReady) {
1256
+ this.plainReady = true;
1257
+
1258
+ this.plainVertices = data.plainVertices;
1259
+ this.plainVerticesHigh = data.plainVerticesHigh;
1260
+ this.plainVerticesLow = data.plainVerticesLow;
1261
+ this.plainNormals = data.plainNormals;
1262
+ this._plainRadius = data.plainRadius;
1263
+
1264
+ this.normalMapNormals = data.normalMapNormals;
1265
+ this.normalMapVertices = data.normalMapVertices;
1266
+ this.normalMapVerticesHigh = data.normalMapVerticesHigh;
1267
+ this.normalMapVerticesLow = data.normalMapVerticesLow;
1268
+
1269
+ //this.terrainVertices = this.plainVertices;
1270
+ //this.terrainVerticesHigh = this.plainVerticesHigh;
1271
+ //this.terrainVerticesLow = this.plainVerticesLow;
1272
+
1273
+ this.fileGridSize = Math.sqrt(data.normalMapVertices.length / 3) - 1;
1274
+ }
1275
+ }
1276
+
1265
1277
  createPlainSegment() {
1266
1278
  this.initialize();
1267
1279
  this._createPlainVertices();