@openglobus/og 0.21.0 → 0.22.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 (130) hide show
  1. package/lib/@openglobus/js/Globe.d.ts +4 -0
  2. package/lib/@openglobus/js/Object3d.d.ts +7 -2
  3. package/lib/@openglobus/js/camera/Camera.d.ts +2 -0
  4. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +58 -0
  5. package/lib/@openglobus/js/ellipsoid/Ellipsoid.d.ts +1 -1
  6. package/lib/@openglobus/js/ellipsoid/index.d.ts +4 -3
  7. package/lib/@openglobus/js/ellipsoid/mars.d.ts +6 -0
  8. package/lib/@openglobus/js/ellipsoid/moon.d.ts +6 -0
  9. package/lib/@openglobus/js/entity/Entity.d.ts +4 -2
  10. package/lib/@openglobus/js/entity/EntityCollection.d.ts +3 -2
  11. package/lib/@openglobus/js/entity/GeoObject.d.ts +6 -1
  12. package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +4 -0
  13. package/lib/@openglobus/js/entity/Label.d.ts +14 -0
  14. package/lib/@openglobus/js/entity/LabelHandler.d.ts +1 -1
  15. package/lib/@openglobus/js/index.d.ts +3 -3
  16. package/lib/@openglobus/js/layer/Vector.d.ts +12 -29
  17. package/lib/@openglobus/js/proj/equi.d.ts +9 -0
  18. package/lib/@openglobus/js/quadTree/{EPSG4326QuadTreeStrategy.d.ts → EPSG4326/EPSG4326QuadTreeStrategy.d.ts} +2 -2
  19. package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +5 -13
  20. package/lib/@openglobus/js/quadTree/EntityCollectionsTreeStrategy.d.ts +25 -0
  21. package/lib/@openglobus/js/quadTree/QuadTreeStrategy.d.ts +11 -0
  22. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +18 -0
  23. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.d.ts +19 -0
  24. package/lib/@openglobus/js/quadTree/earth/EarthQuadTreeStrategy.d.ts +29 -0
  25. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +17 -0
  26. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.d.ts +17 -0
  27. package/lib/@openglobus/js/quadTree/equi/EquiQuadTreeStrategy.d.ts +19 -0
  28. package/lib/@openglobus/js/quadTree/index.d.ts +6 -6
  29. package/lib/{js/quadTree → @openglobus/js/quadTree/wgs84}/Wgs84QuadTreeStrategy.d.ts +2 -2
  30. package/lib/@openglobus/js/renderer/Renderer.d.ts +2 -0
  31. package/lib/@openglobus/js/scene/Planet.d.ts +0 -27
  32. package/lib/@openglobus/js/segment/Segment.d.ts +0 -1
  33. package/lib/@openglobus/js/segment/SegmentLonLat.d.ts +0 -4
  34. package/lib/@openglobus/js/segment/{SegmentLonLatWgs84.d.ts → SegmentLonLatEqui.d.ts} +1 -1
  35. package/lib/@openglobus/js/terrain/RgbTerrain.d.ts +11 -0
  36. package/lib/@openglobus/og.esm.js +1 -1
  37. package/lib/@openglobus/og.esm.js.map +1 -1
  38. package/lib/@openglobus/og.umd.js +1 -1
  39. package/lib/@openglobus/og.umd.js.map +1 -1
  40. package/lib/@openglobus/res/fonts/Ephesis-Regular.json +4648 -0
  41. package/lib/@openglobus/res/fonts/Ephesis-Regular.ttf.cfg +1282 -0
  42. package/lib/@openglobus/res/fonts/Ephesis-Regular.ttf.png +0 -0
  43. package/lib/js/Globe.d.ts +4 -0
  44. package/lib/js/Globe.js +6 -2
  45. package/lib/js/Object3d.d.ts +7 -2
  46. package/lib/js/Object3d.js +46 -6
  47. package/lib/js/camera/Camera.d.ts +2 -0
  48. package/lib/js/camera/Camera.js +8 -0
  49. package/lib/js/control/elevationProfile/ElevationProfileScene.js +2 -0
  50. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +58 -0
  51. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +105 -0
  52. package/lib/js/ellipsoid/Ellipsoid.d.ts +1 -1
  53. package/lib/js/ellipsoid/Ellipsoid.js +1 -1
  54. package/lib/js/ellipsoid/index.d.ts +4 -3
  55. package/lib/js/ellipsoid/index.js +4 -3
  56. package/lib/js/ellipsoid/mars.d.ts +6 -0
  57. package/lib/js/ellipsoid/mars.js +6 -0
  58. package/lib/js/ellipsoid/moon.d.ts +6 -0
  59. package/lib/js/ellipsoid/moon.js +6 -0
  60. package/lib/js/entity/Entity.d.ts +4 -2
  61. package/lib/js/entity/Entity.js +4 -1
  62. package/lib/js/entity/EntityCollection.d.ts +3 -2
  63. package/lib/js/entity/EntityCollection.js +26 -2
  64. package/lib/js/entity/GeoObject.d.ts +6 -1
  65. package/lib/js/entity/GeoObject.js +9 -0
  66. package/lib/js/entity/GeoObjectHandler.d.ts +4 -0
  67. package/lib/js/entity/GeoObjectHandler.js +32 -1
  68. package/lib/js/entity/GeometryHandler.js +16 -14
  69. package/lib/js/entity/Label.d.ts +14 -0
  70. package/lib/js/entity/Label.js +24 -4
  71. package/lib/js/entity/LabelHandler.d.ts +1 -1
  72. package/lib/js/entity/LabelHandler.js +4 -4
  73. package/lib/js/entity/Polyline.js +1 -1
  74. package/lib/js/index.d.ts +3 -3
  75. package/lib/js/index.js +3 -3
  76. package/lib/js/layer/Layer.js +7 -4
  77. package/lib/js/layer/Vector.d.ts +12 -29
  78. package/lib/js/layer/Vector.js +36 -161
  79. package/lib/js/layer/XYZ.js +1 -1
  80. package/lib/js/proj/equi.d.ts +9 -0
  81. package/lib/js/proj/equi.js +9 -0
  82. package/lib/js/quadTree/{EPSG4326QuadTreeStrategy.d.ts → EPSG4326/EPSG4326QuadTreeStrategy.d.ts} +2 -2
  83. package/lib/js/quadTree/EPSG4326/EPSG4326QuadTreeStrategy.js +16 -0
  84. package/lib/js/quadTree/EntityCollectionNode.d.ts +5 -13
  85. package/lib/js/quadTree/EntityCollectionNode.js +18 -83
  86. package/lib/js/quadTree/EntityCollectionsTreeStrategy.d.ts +25 -0
  87. package/lib/js/quadTree/EntityCollectionsTreeStrategy.js +49 -0
  88. package/lib/js/quadTree/Node.js +6 -12
  89. package/lib/js/quadTree/QuadTreeStrategy.d.ts +11 -0
  90. package/lib/js/quadTree/QuadTreeStrategy.js +12 -0
  91. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +18 -0
  92. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +74 -0
  93. package/lib/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.d.ts +19 -0
  94. package/lib/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.js +103 -0
  95. package/lib/js/quadTree/earth/EarthQuadTreeStrategy.d.ts +29 -0
  96. package/lib/js/quadTree/{EarthQuadTreeStrategy.js → earth/EarthQuadTreeStrategy.js} +29 -6
  97. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +17 -0
  98. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +70 -0
  99. package/lib/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.d.ts +17 -0
  100. package/lib/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.js +75 -0
  101. package/lib/js/quadTree/equi/EquiQuadTreeStrategy.d.ts +19 -0
  102. package/lib/js/quadTree/equi/EquiQuadTreeStrategy.js +62 -0
  103. package/lib/js/quadTree/index.d.ts +6 -6
  104. package/lib/js/quadTree/index.js +6 -6
  105. package/lib/{@openglobus/js/quadTree → js/quadTree/wgs84}/Wgs84QuadTreeStrategy.d.ts +2 -2
  106. package/lib/js/quadTree/wgs84/Wgs84QuadTreeStrategy.js +15 -0
  107. package/lib/js/renderer/Renderer.d.ts +2 -0
  108. package/lib/js/renderer/Renderer.js +2 -2
  109. package/lib/js/scene/Planet.d.ts +0 -27
  110. package/lib/js/scene/Planet.js +2 -9
  111. package/lib/js/segment/Segment.d.ts +0 -1
  112. package/lib/js/segment/Segment.js +0 -3
  113. package/lib/js/segment/SegmentLonLat.d.ts +0 -4
  114. package/lib/js/segment/SegmentLonLat.js +0 -11
  115. package/lib/js/segment/{SegmentLonLatWgs84.d.ts → SegmentLonLatEqui.d.ts} +1 -1
  116. package/lib/js/segment/{SegmentLonLatWgs84.js → SegmentLonLatEqui.js} +3 -1
  117. package/lib/js/shaders/geoObject.js +10 -5
  118. package/lib/js/shaders/polyline.js +8 -6
  119. package/lib/js/terrain/RgbTerrain.d.ts +11 -0
  120. package/lib/js/terrain/RgbTerrain.js +12 -1
  121. package/lib/js/utils/PlainSegmentWorker.js +3 -1
  122. package/lib/js/webgl/Handler.js +1 -1
  123. package/package.json +2 -2
  124. package/lib/@openglobus/js/quadTree/EarthQuadTreeStrategy.d.ts +0 -9
  125. package/lib/@openglobus/js/quadTree/MarsQuadTreeStrategy.d.ts +0 -11
  126. package/lib/js/quadTree/EPSG4326QuadTreeStrategy.js +0 -16
  127. package/lib/js/quadTree/EarthQuadTreeStrategy.d.ts +0 -9
  128. package/lib/js/quadTree/MarsQuadTreeStrategy.d.ts +0 -11
  129. package/lib/js/quadTree/MarsQuadTreeStrategy.js +0 -43
  130. package/lib/js/quadTree/Wgs84QuadTreeStrategy.js +0 -15
@@ -1,14 +1,9 @@
1
1
  import * as math from "../math";
2
- import * as mercator from "../mercator";
3
- import * as quadTree from "../quadTree/quadTree";
4
2
  import { Entity } from "../entity/Entity";
5
3
  import { EntityCollection } from "../entity/EntityCollection";
6
- import { EntityCollectionNode, EntityCollectionNodeWGS84 } from "../quadTree/EntityCollectionNode";
7
- import { Extent } from "../Extent";
8
4
  import { GeometryHandler } from "../entity/GeometryHandler";
9
5
  import { Layer } from "./Layer";
10
6
  import { Vec3 } from "../math/Vec3";
11
- import { QueueArray } from "../QueueArray";
12
7
  /**
13
8
  * Creates entity instance array.
14
9
  * @param {Entity[] | IEntityParams[]} entities - Entity array.
@@ -69,11 +64,23 @@ class Vector extends Layer {
69
64
  this._hasImageryTiles = false;
70
65
  this.scaleByDistance = options.scaleByDistance || [math.MAX32, math.MAX32, math.MAX32];
71
66
  this._useLighting = options.useLighting !== undefined ? options.useLighting : true;
72
- this.pickingScale = options.pickingScale || 1;
67
+ let pickingScale = new Float32Array([1.0, 1.0, 1.0]);
68
+ if (options.pickingScale !== undefined) {
69
+ if (options.pickingScale instanceof Array) {
70
+ pickingScale[0] = options.pickingScale[0] || pickingScale[0];
71
+ pickingScale[1] = options.pickingScale[1] || pickingScale[1];
72
+ pickingScale[2] = options.pickingScale[2] || pickingScale[2];
73
+ }
74
+ else if (typeof options.pickingScale === 'number') {
75
+ pickingScale[0] = options.pickingScale;
76
+ pickingScale[1] = options.pickingScale;
77
+ pickingScale[2] = options.pickingScale;
78
+ }
79
+ }
80
+ this.pickingScale = pickingScale;
73
81
  this.async = options.async !== undefined ? options.async : true;
74
82
  this.clampToGround = options.clampToGround || false;
75
83
  this.relativeToGround = options.relativeToGround || false;
76
- this._nodeCapacity = options.nodeCapacity || 30;
77
84
  this._entities = _entitiesConstructor(options.entities || []);
78
85
  this._labelMaxLetters = options.labelMaxLetters || 24;
79
86
  this._stripEntityCollection = new EntityCollection({
@@ -90,19 +97,11 @@ class Vector extends Layer {
90
97
  });
91
98
  this._bindEventsDefault(this._geoObjectEntityCollection);
92
99
  this._geometryHandler = new GeometryHandler(this);
93
- this._entityCollectionsTree = null;
94
- this._entityCollectionsTreeNorth = null;
95
- this._entityCollectionsTreeSouth = null;
96
- this._renderingNodes = {};
97
- this._renderingNodesNorth = {};
98
- this._renderingNodesSouth = {};
99
- this._counter = 0;
100
- this._deferredEntitiesPendingQueue = new QueueArray();
101
- this._pendingsQueue = [];
100
+ this._nodeCapacity = options.nodeCapacity || 60;
101
+ this._entityCollectionsTreeStrategy = null;
102
102
  this.setEntities(this._entities);
103
103
  this.polygonOffsetUnits = options.polygonOffsetUnits != undefined ? options.polygonOffsetUnits : 0.0;
104
104
  this.pickingEnabled = this._pickingEnabled;
105
- this._secondPASS = [];
106
105
  }
107
106
  get useLighting() {
108
107
  return this._useLighting;
@@ -153,31 +152,6 @@ class Vector extends Layer {
153
152
  getEntities() {
154
153
  return [].concat(this._entities);
155
154
  }
156
- //_fitExtent(entity) {
157
- // var ee = entity.getExtent(),
158
- // e = this._extent,
159
- // maxLon = -180, maxLat = -90,
160
- // minLon = 180, minLat = 90;
161
- // if (this._entities.length !== 0) {
162
- // maxLon = e.southWest.lon;
163
- // minLon = e.northEast.lon;
164
- // maxLat = e.northEast.lat;
165
- // minLat = e.southWest.lat;
166
- // }
167
- // if (ee.southWest.lon < minLon) {
168
- // e.southWest.lon = ee.southWest.lon;
169
- // }
170
- // if (ee.southWest.lat < minLat) {
171
- // e.southWest.lat = ee.southWest.lat;
172
- // }
173
- // if (ee.northEast.lon > maxLon) {
174
- // e.northEast.lon = ee.northEast.lon;
175
- // }
176
- // if (ee.northEast.lat > maxLat) {
177
- // e.northEast.lat = ee.northEast.lat;
178
- // }
179
- // this.setExtent(this._extent);
180
- //}
181
155
  /**
182
156
  * Adds entity to the layer.
183
157
  * @public
@@ -218,13 +192,14 @@ class Vector extends Layer {
218
192
  }
219
193
  _proceedEntity(entity, rightNow = false) {
220
194
  let temp = this._hasImageryTiles;
195
+ let isEmpty = !(entity.strip || entity.polyline || entity.ray || entity.geoObject || entity.geometry);
221
196
  if (entity.strip) {
222
197
  this._stripEntityCollection.add(entity);
223
198
  }
224
199
  if (entity.polyline || entity.ray) {
225
200
  this._polylineEntityCollection.add(entity);
226
201
  }
227
- if (entity.geoObject) {
202
+ if (entity.geoObject || isEmpty) {
228
203
  this._geoObjectEntityCollection.add(entity);
229
204
  }
230
205
  if (entity.geometry) {
@@ -234,27 +209,17 @@ class Vector extends Layer {
234
209
  this._geometryHandler.add(entity.geometry);
235
210
  }
236
211
  }
237
- if (entity.billboard || entity.label || entity.geoObject) {
238
- if (this._planet) {
212
+ if (this._planet) {
213
+ if (entity.billboard || entity.label || entity.geoObject || isEmpty) {
239
214
  if (entity._cartesian.isZero() && !entity._lonLat.isZero()) {
240
215
  entity._setCartesian3vSilent(this._planet.ellipsoid.lonLatToCartesian(entity._lonLat));
241
216
  }
242
217
  else {
243
218
  entity._lonLat = this._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
244
219
  }
245
- // north tree
246
- if (entity._lonLat.lat > mercator.MAX_LAT) {
247
- this._entityCollectionsTreeNorth.__setLonLat__(entity);
248
- this._entityCollectionsTreeNorth.insertEntity(entity, rightNow);
249
- }
250
- else if (entity._lonLat.lat < mercator.MIN_LAT) {
251
- this._entityCollectionsTreeSouth.__setLonLat__(entity);
252
- this._entityCollectionsTreeSouth.insertEntity(entity, rightNow);
253
- }
254
- else {
255
- this._entityCollectionsTree.__setLonLat__(entity);
256
- this._entityCollectionsTree.insertEntity(entity, rightNow);
257
- }
220
+ }
221
+ if (entity.billboard || entity.label) {
222
+ this._entityCollectionsTreeStrategy?.insertEntity(entity);
258
223
  }
259
224
  }
260
225
  if (this._planet && this._hasImageryTiles !== temp) {
@@ -320,11 +285,9 @@ class Vector extends Layer {
320
285
  }
321
286
  }
322
287
  }
323
- if (entity.geometry) {
324
- if (this._planet) {
325
- this._geometryHandler.remove(entity.geometry);
326
- this._planet.renderer.clearPickingColor(entity);
327
- }
288
+ if (this._planet && entity.geometry) {
289
+ this._geometryHandler.remove(entity.geometry);
290
+ this._planet.renderer.clearPickingColor(entity);
328
291
  }
329
292
  entity._nodePtr = undefined;
330
293
  this.events.dispatch(this.events.entityremove, entity);
@@ -341,18 +304,7 @@ class Vector extends Layer {
341
304
  this._stripEntityCollection.setPickingEnabled(picking);
342
305
  this._polylineEntityCollection.setPickingEnabled(picking);
343
306
  this._geoObjectEntityCollection.setPickingEnabled(picking);
344
- /**
345
- * todo: it must be in the quadtree strategy
346
- */
347
- this._entityCollectionsTree && this._entityCollectionsTree.traverseTree((node) => {
348
- node.entityCollection.setPickingEnabled(picking);
349
- });
350
- this._entityCollectionsTreeNorth && this._entityCollectionsTreeNorth.traverseTree((node) => {
351
- node.entityCollection.setPickingEnabled(picking);
352
- });
353
- this._entityCollectionsTreeSouth && this._entityCollectionsTreeSouth.traverseTree((node) => {
354
- node.entityCollection.setPickingEnabled(picking);
355
- });
307
+ this._entityCollectionsTreeStrategy?.setPickingEnabled(picking);
356
308
  }
357
309
  /**
358
310
  * Refresh collected entities indexes from startIndex entities collection array position.
@@ -378,13 +330,8 @@ class Vector extends Layer {
378
330
  }
379
331
  return this;
380
332
  }
381
- // public setScaleByDistance(near, far, farInvisible) {
382
- // this.scaleByDistance[0] = near;
383
- // this.scaleByDistance[1] = far;
384
- // this.scaleByDistance[2] = farInvisible || math.MAX32;
385
- // }
386
333
  /**
387
- * TODO: Clear the layer.
334
+ * Clear the layer.
388
335
  * @public
389
336
  */
390
337
  clear() {
@@ -402,9 +349,8 @@ class Vector extends Layer {
402
349
  for (let i = 0; i < temp.length; i++) {
403
350
  this._entities[i] = temp[i];
404
351
  }
405
- this._entityCollectionsTree = null;
406
- this._entityCollectionsTreeNorth = null;
407
- this._entityCollectionsTreeSouth = null;
352
+ this._entityCollectionsTreeStrategy?.dispose();
353
+ this._entityCollectionsTreeStrategy = null;
408
354
  this._geometryHandler.clear();
409
355
  }
410
356
  /**
@@ -437,13 +383,14 @@ class Vector extends Layer {
437
383
  let ei = temp[i];
438
384
  ei._layer = this;
439
385
  ei._layerIndex = i;
386
+ let isEmpty = !(ei.strip || ei.polyline || ei.ray || ei.geoObject || ei.billboard || ei.label);
440
387
  if (ei.strip) {
441
388
  this._stripEntityCollection.add(ei);
442
389
  }
443
390
  else if (ei.polyline || ei.ray) {
444
391
  this._polylineEntityCollection.add(ei);
445
392
  }
446
- else if (ei.geoObject) {
393
+ else if (ei.geoObject || isEmpty) {
447
394
  this._geoObjectEntityCollection.add(ei);
448
395
  }
449
396
  else if (ei.billboard || ei.label) {
@@ -461,35 +408,14 @@ class Vector extends Layer {
461
408
  this._createEntityCollectionsTree(entitiesForTree);
462
409
  return this;
463
410
  }
464
- /**
465
- * @todo: replace to a strategy node collecting algorithm
466
- */
467
411
  _createEntityCollectionsTree(entitiesForTree) {
468
412
  if (this._planet) {
469
- this._entityCollectionsTree = new EntityCollectionNode(this, quadTree.NW, null, Extent.createFromArray([-20037508.34, -20037508.34, 20037508.34, 20037508.34]), this._planet, 0);
470
- this._entityCollectionsTreeNorth = new EntityCollectionNodeWGS84(this, quadTree.NW, null, Extent.createFromArray([-180, mercator.MAX_LAT, 180, 90]), this._planet, 0);
471
- this._entityCollectionsTreeSouth = new EntityCollectionNodeWGS84(this, quadTree.NW, null, Extent.createFromArray([-180, -90, 180, mercator.MIN_LAT]), this._planet, 0);
472
- for (let i = 0, len = entitiesForTree.length; i < len; i++) {
473
- let entity = entitiesForTree[i];
474
- // north tree
475
- if (entity._lonLat.lat > mercator.MAX_LAT) {
476
- this._entityCollectionsTreeNorth.__setLonLat__(entity);
477
- }
478
- else if (entity._lonLat.lat < mercator.MIN_LAT) {
479
- // south tree
480
- this._entityCollectionsTreeSouth.__setLonLat__(entity);
481
- }
482
- else {
483
- this._entityCollectionsTree.__setLonLat__(entity);
484
- }
485
- }
486
- this._entityCollectionsTree.buildTree(entitiesForTree);
487
- this._entityCollectionsTreeNorth.buildTree(entitiesForTree);
488
- this._entityCollectionsTreeSouth.buildTree(entitiesForTree);
413
+ this._entityCollectionsTreeStrategy = this._planet.quadTreeStrategy.createEntitiCollectionsTreeStrategy(this, this._nodeCapacity);
414
+ this._entityCollectionsTreeStrategy.insertEntities(entitiesForTree);
489
415
  }
490
416
  }
491
417
  /**
492
- * @todo (refactoring) could be used in somethig like bindEntityCollectionQuad(...)
418
+ * @todo (refactoring) could be used in something like bindEntityCollectionQuad(...)
493
419
  * @param entityCollection
494
420
  */
495
421
  _bindEventsDefault(entityCollection) {
@@ -682,64 +608,13 @@ class Vector extends Layer {
682
608
  let p = this._planet;
683
609
  if ((this._fading && this._fadingOpacity > 0.0) ||
684
610
  (this.minZoom <= p.maxCurrZoom && this.maxZoom >= p.maxCurrZoom)) {
685
- this._renderingNodes = {};
686
- this._renderingNodesNorth = {};
687
- this._renderingNodesSouth = {};
688
611
  // Common collections first
689
612
  this._collectStripCollectionPASS(outArr);
690
613
  this._collectPolylineCollectionPASS(outArr);
691
614
  this._collectGeoObjectCollectionPASS(outArr);
692
- // Merc nodes
693
- this._secondPASS = [];
694
- this._entityCollectionsTree && this._entityCollectionsTree.collectRenderCollectionsPASS1(p._visibleNodes, outArr);
695
- let i = this._secondPASS.length;
696
- while (i--) {
697
- this._secondPASS[i].collectRenderCollectionsPASS2(p._visibleNodes, outArr, this._secondPASS[i].nodeId);
698
- }
699
- // North nodes
700
- this._secondPASS = [];
701
- this._entityCollectionsTreeNorth && this._entityCollectionsTreeNorth.collectRenderCollectionsPASS1(p._visibleNodesNorth, outArr);
702
- i = this._secondPASS.length;
703
- while (i--) {
704
- this._secondPASS[i].collectRenderCollectionsPASS2(p._visibleNodesNorth, outArr, this._secondPASS[i].nodeId);
705
- }
706
- // South nodes
707
- this._secondPASS = [];
708
- this._entityCollectionsTreeSouth && this._entityCollectionsTreeSouth.collectRenderCollectionsPASS1(p._visibleNodesSouth, outArr);
709
- i = this._secondPASS.length;
710
- while (i--) {
711
- this._secondPASS[i].collectRenderCollectionsPASS2(p._visibleNodesSouth, outArr, this._secondPASS[i].nodeId);
712
- }
615
+ this._entityCollectionsTreeStrategy.collectVisibleEntityCollections(outArr);
713
616
  }
714
617
  }
715
- _queueDeferredNode(node) {
716
- if (this._visibility) {
717
- node._inTheQueue = true;
718
- if (this._counter >= 1) {
719
- this._deferredEntitiesPendingQueue.push(node);
720
- }
721
- else {
722
- this._execDeferredNode(node);
723
- }
724
- }
725
- }
726
- _execDeferredNode(node) {
727
- this._counter++;
728
- requestAnimationFrame(() => {
729
- node.applyCollection();
730
- this._counter--;
731
- if (this._deferredEntitiesPendingQueue.length && this._counter < 1) {
732
- while (this._deferredEntitiesPendingQueue.length) {
733
- let n = this._deferredEntitiesPendingQueue.pop();
734
- n._inTheQueue = false;
735
- if (n.isVisible()) {
736
- this._execDeferredNode(n);
737
- return;
738
- }
739
- }
740
- }
741
- });
742
- }
743
618
  /**
744
619
  * Start to load tile material.
745
620
  * @public
@@ -94,7 +94,7 @@ export class XYZ extends Layer {
94
94
  this.url = url;
95
95
  }
96
96
  _checkSegment(segment) {
97
- return segment._projection.id === this._planet.quadTreeStrategy.projection.id; // EPSG4326.id;// EPSG3857.id;
97
+ return segment._projection.id === this._planet.quadTreeStrategy.projection.id;
98
98
  }
99
99
  /**
100
100
  * Start to load tile material.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @module og/proj/equi
3
+ */
4
+ import { Proj } from "./Proj";
5
+ /**
6
+ * Any equrectangualr projection object.
7
+ * @type {Proj}
8
+ */
9
+ export declare const equi: Proj;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @module og/proj/equi
3
+ */
4
+ import { Proj, Units } from "./Proj";
5
+ /**
6
+ * Any equrectangualr projection object.
7
+ * @type {Proj}
8
+ */
9
+ export const equi = new Proj({ code: "equi", units: Units.DEGREES });
@@ -1,5 +1,5 @@
1
- import { Planet } from "../scene/Planet";
2
- import { QuadTreeStrategy } from "./QuadTreeStrategy";
1
+ import { Planet } from "../../scene/Planet";
2
+ import { QuadTreeStrategy } from "../QuadTreeStrategy";
3
3
  export declare class EPSG4326QuadTreeStrategy extends QuadTreeStrategy {
4
4
  constructor(planet: Planet);
5
5
  init(): void;
@@ -0,0 +1,16 @@
1
+ import { Extent } from "../../Extent";
2
+ import { EPSG4326 } from "../../proj/EPSG4326";
3
+ import { Node } from "../Node";
4
+ import { QuadTreeStrategy } from "../QuadTreeStrategy";
5
+ import { SegmentLonLatEqui } from "../../segment/SegmentLonLatEqui";
6
+ export class EPSG4326QuadTreeStrategy extends QuadTreeStrategy {
7
+ constructor(planet) {
8
+ super(planet, "EPSG4326", EPSG4326);
9
+ }
10
+ init() {
11
+ this._quadTreeList = [
12
+ new Node(SegmentLonLatEqui, this.planet, 0, null, 0, Extent.createFromArray([-180, -90, 0, 90])),
13
+ new Node(SegmentLonLatEqui, this.planet, 0, null, 0, Extent.createFromArray([0, -90, 180, 90]))
14
+ ];
15
+ }
16
+ }
@@ -7,12 +7,14 @@ import { Sphere } from '../bv/Sphere';
7
7
  import { Segment } from "../segment/Segment";
8
8
  import { Vector } from "../layer/Vector";
9
9
  import { Entity } from "../entity/Entity";
10
- type NodesDict = Record<number, Node>;
10
+ import { EntityCollectionsTreeStrategy } from "./EntityCollectionsTreeStrategy";
11
+ export type NodesDict = Record<number, Node>;
11
12
  /**
12
13
  * @todo: remove planet parameter. It's already available in the layer.
13
14
  */
14
15
  declare class EntityCollectionNode {
15
16
  layer: Vector;
17
+ strategy: EntityCollectionsTreeStrategy;
16
18
  parentNode: EntityCollectionNode | null;
17
19
  childrenNodes: EntityCollectionNode[];
18
20
  partId: number;
@@ -25,7 +27,7 @@ declare class EntityCollectionNode {
25
27
  zoom: number;
26
28
  bsphere: Sphere;
27
29
  _inTheQueue: boolean;
28
- constructor(layer: Vector, partId: number, parent: EntityCollectionNode | null, extent: Extent, planet: Planet, zoom: number);
30
+ constructor(strategy: EntityCollectionsTreeStrategy, partId: number, parent: EntityCollectionNode | null, extent: Extent, planet: Planet, zoom: number);
29
31
  insertEntity(entity: Entity, rightNow?: boolean): void;
30
32
  protected _addEntitiesToCollection(entities: Entity[], rightNow?: boolean): void;
31
33
  protected _setExtentBounds(): void;
@@ -41,14 +43,4 @@ declare class EntityCollectionNode {
41
43
  alignEntityToTheGround(entity: Entity, segment: Segment): void;
42
44
  isVisible(): boolean;
43
45
  }
44
- declare class EntityCollectionNodeWGS84 extends EntityCollectionNode {
45
- isNorth: boolean;
46
- constructor(layer: Vector, partId: number, parent: EntityCollectionNodeWGS84 | null, extent: Extent, planet: Planet, zoom: number);
47
- createChildrenNodes(): void;
48
- protected _setExtentBounds(): void;
49
- __setLonLat__(entity: Entity): LonLat;
50
- isVisible(): boolean;
51
- isInside(entity: Entity): boolean;
52
- renderCollection(outArr: EntityCollection[], visibleNodes: NodesDict, renderingNode: number): void;
53
- }
54
- export { EntityCollectionNode, EntityCollectionNodeWGS84 };
46
+ export { EntityCollectionNode };
@@ -9,8 +9,9 @@ import { Vec3 } from '../math/Vec3';
9
9
  * @todo: remove planet parameter. It's already available in the layer.
10
10
  */
11
11
  class EntityCollectionNode {
12
- constructor(layer, partId, parent, extent, planet, zoom) {
13
- this.layer = layer;
12
+ constructor(strategy, partId, parent, extent, planet, zoom) {
13
+ this.strategy = strategy;
14
+ this.layer = strategy._layer;
14
15
  this.parentNode = parent;
15
16
  this.childrenNodes = [];
16
17
  this.partId = partId;
@@ -120,7 +121,7 @@ class EntityCollectionNode {
120
121
  }
121
122
  }
122
123
  createChildrenNodes() {
123
- const l = this.layer;
124
+ const s = this.strategy;
124
125
  const ext = this.extent;
125
126
  const size_x = ext.getWidth() * 0.5;
126
127
  const size_y = ext.getHeight() * 0.5;
@@ -130,10 +131,10 @@ class EntityCollectionNode {
130
131
  const nd = this.childrenNodes;
131
132
  const p = this.layer._planet;
132
133
  const z = this.zoom + 1;
133
- nd[NW] = new EntityCollectionNode(l, NW, this, new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
134
- nd[NE] = new EntityCollectionNode(l, NE, this, new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
135
- nd[SW] = new EntityCollectionNode(l, SW, this, new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
136
- nd[SE] = new EntityCollectionNode(l, SE, this, new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
134
+ nd[NW] = new EntityCollectionNode(s, NW, this, new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
135
+ nd[NE] = new EntityCollectionNode(s, NE, this, new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
136
+ nd[SW] = new EntityCollectionNode(s, SW, this, new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
137
+ nd[SE] = new EntityCollectionNode(s, SE, this, new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
137
138
  }
138
139
  collectRenderCollectionsPASS1(visibleNodes, outArr) {
139
140
  const n = visibleNodes[this.nodeId];
@@ -144,7 +145,7 @@ class EntityCollectionNode {
144
145
  }
145
146
  else if (cn.length) {
146
147
  if (n.state === RENDERING) {
147
- this.layer._secondPASS.push(this);
148
+ this.strategy._secondPASS.push(this);
148
149
  }
149
150
  else {
150
151
  cn[NW].collectRenderCollectionsPASS1(visibleNodes, outArr);
@@ -160,7 +161,7 @@ class EntityCollectionNode {
160
161
  const cam = p.camera;
161
162
  const altVis = (cam.eye.distance(this.bsphere.center) - this.bsphere.radius <
162
163
  VISIBLE_DISTANCE * Math.sqrt(cam._lonLat.height)) || cam._lonLat.height > 10000;
163
- if (this.count > 0 && altVis && cam.frustum.containsSphere(this.bsphere)) {
164
+ if (this.count > 0 && altVis && cam.containsSphere(this.bsphere)) {
164
165
  const cn = this.childrenNodes;
165
166
  if (this.entityCollection) {
166
167
  this.renderCollection(outArr, visibleNodes, renderingNodeId);
@@ -192,17 +193,18 @@ class EntityCollectionNode {
192
193
  }
193
194
  }
194
195
  renderCollection(outArr, visibleNodes, renderingNodeId) {
195
- const l = this.layer;
196
- l._renderingNodes[this.nodeId] = true;
196
+ const s = this.strategy;
197
+ s._renderingNodes[this.nodeId] = true;
197
198
  if (this.deferredEntities.length && !this._inTheQueue) {
198
- if (l.async) {
199
- l._queueDeferredNode(this);
199
+ if (this.layer.async) {
200
+ s._queueDeferredNode(this);
200
201
  }
201
202
  else {
202
203
  this.applyCollection();
203
204
  }
204
205
  }
205
- const ec = this.entityCollection;
206
+ let ec = this.entityCollection;
207
+ let l = this.layer;
206
208
  ec._fadingOpacity = l._fadingOpacity;
207
209
  ec.scaleByDistance = l.scaleByDistance;
208
210
  ec.pickingScale = l.pickingScale;
@@ -251,77 +253,10 @@ class EntityCollectionNode {
251
253
  }
252
254
  }
253
255
  isVisible() {
254
- if (this.layer._renderingNodes[this.nodeId]) {
255
- return true;
256
- }
257
- return false;
258
- }
259
- }
260
- class EntityCollectionNodeWGS84 extends EntityCollectionNode {
261
- constructor(layer, partId, parent, extent, planet, zoom) {
262
- super(layer, partId, parent, extent, planet, zoom);
263
- this.isNorth = false;
264
- }
265
- createChildrenNodes() {
266
- const l = this.layer;
267
- const ext = this.extent;
268
- const size_x = ext.getWidth() * 0.5;
269
- const size_y = ext.getHeight() * 0.5;
270
- const ne = ext.northEast;
271
- const sw = ext.southWest;
272
- const c = new LonLat(sw.lon + size_x, sw.lat + size_y);
273
- const nd = this.childrenNodes;
274
- const p = this.layer._planet;
275
- const z = this.zoom + 1;
276
- nd[NW] = new EntityCollectionNodeWGS84(l, NW, this, new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
277
- nd[NE] = new EntityCollectionNodeWGS84(l, NE, this, new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
278
- nd[SW] = new EntityCollectionNodeWGS84(l, SW, this, new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
279
- nd[SE] = new EntityCollectionNodeWGS84(l, SE, this, new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
280
- }
281
- _setExtentBounds() {
282
- if (this.extent.northEast.lat > 0) {
283
- this.isNorth = true;
284
- }
285
- this.bsphere.setFromExtent(this.layer._planet.ellipsoid, this.extent);
286
- }
287
- __setLonLat__(entity) {
288
- if (entity._lonLat.isZero()) {
289
- entity._lonLat = this.layer._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
290
- }
291
- return entity._lonLat;
292
- }
293
- isVisible() {
294
- if (this.isNorth && this.layer._renderingNodesNorth[this.nodeId]) {
295
- return true;
296
- }
297
- else if (this.layer._renderingNodesSouth[this.nodeId]) {
256
+ if (this.strategy._renderingNodes[this.nodeId]) {
298
257
  return true;
299
258
  }
300
259
  return false;
301
260
  }
302
- isInside(entity) {
303
- return this.extent.isInside(entity._lonLat);
304
- }
305
- renderCollection(outArr, visibleNodes, renderingNode) {
306
- if (this.isNorth) {
307
- this.layer._renderingNodesNorth[this.nodeId] = true;
308
- }
309
- else {
310
- this.layer._renderingNodesSouth[this.nodeId] = true;
311
- }
312
- if (this.deferredEntities.length && !this._inTheQueue) {
313
- if (this.layer.async) {
314
- this.layer._queueDeferredNode(this);
315
- }
316
- else {
317
- this.applyCollection();
318
- }
319
- }
320
- const ec = this.entityCollection;
321
- ec._fadingOpacity = this.layer._fadingOpacity;
322
- ec.scaleByDistance = this.layer.scaleByDistance;
323
- ec.pickingScale = this.layer.pickingScale;
324
- outArr.push(ec);
325
- }
326
261
  }
327
- export { EntityCollectionNode, EntityCollectionNodeWGS84 };
262
+ export { EntityCollectionNode };
@@ -0,0 +1,25 @@
1
+ import { Vector } from "../layer/Vector";
2
+ import { EntityCollectionNode } from "./EntityCollectionNode";
3
+ import { Entity } from "../entity/Entity";
4
+ import { EntityCollection } from "../entity/EntityCollection";
5
+ import { QueueArray } from "../QueueArray";
6
+ export declare class EntityCollectionsTreeStrategy {
7
+ _layer: Vector;
8
+ /**
9
+ * Maximum entities quantity in the tree node.
10
+ * @public
11
+ */
12
+ _nodeCapacity: number;
13
+ _secondPASS: EntityCollectionNode[];
14
+ protected _counter: number;
15
+ protected _deferredEntitiesPendingQueue: QueueArray<EntityCollectionNode>;
16
+ _renderingNodes: Record<number, boolean>;
17
+ constructor(layer: Vector, nodeCapacity: number);
18
+ insertEntity(entity: Entity, rightNow?: boolean): void;
19
+ setPickingEnabled(pickingEnabled: boolean): void;
20
+ dispose(): void;
21
+ insertEntities(entitiesForTree: Entity[]): void;
22
+ collectVisibleEntityCollections(outArr: EntityCollection[]): void;
23
+ _queueDeferredNode(node: EntityCollectionNode): void;
24
+ protected _execDeferredNode(node: EntityCollectionNode): void;
25
+ }
@@ -0,0 +1,49 @@
1
+ import { QueueArray } from "../QueueArray";
2
+ export class EntityCollectionsTreeStrategy {
3
+ constructor(layer, nodeCapacity) {
4
+ this._layer = layer;
5
+ this._nodeCapacity = nodeCapacity;
6
+ this._secondPASS = [];
7
+ this._counter = 0;
8
+ this._deferredEntitiesPendingQueue = new QueueArray();
9
+ this._renderingNodes = {};
10
+ }
11
+ insertEntity(entity, rightNow = false) {
12
+ }
13
+ setPickingEnabled(pickingEnabled) {
14
+ }
15
+ dispose() {
16
+ }
17
+ insertEntities(entitiesForTree) {
18
+ }
19
+ collectVisibleEntityCollections(outArr) {
20
+ }
21
+ _queueDeferredNode(node) {
22
+ if (this._layer.getVisibility()) {
23
+ node._inTheQueue = true;
24
+ if (this._counter >= 1) {
25
+ this._deferredEntitiesPendingQueue.push(node);
26
+ }
27
+ else {
28
+ this._execDeferredNode(node);
29
+ }
30
+ }
31
+ }
32
+ _execDeferredNode(node) {
33
+ this._counter++;
34
+ requestAnimationFrame(() => {
35
+ node.applyCollection();
36
+ this._counter--;
37
+ if (this._deferredEntitiesPendingQueue.length && this._counter < 1) {
38
+ while (this._deferredEntitiesPendingQueue.length) {
39
+ let n = this._deferredEntitiesPendingQueue.pop();
40
+ n._inTheQueue = false;
41
+ if (n.isVisible()) {
42
+ this._execDeferredNode(n);
43
+ return;
44
+ }
45
+ }
46
+ }
47
+ });
48
+ }
49
+ }