@openglobus/og 0.21.0 → 0.22.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.
- package/LICENSE.md +2 -2
- package/lib/@openglobus/js/Globe.d.ts +4 -0
- package/lib/@openglobus/js/Object3d.d.ts +7 -2
- package/lib/@openglobus/js/camera/Camera.d.ts +2 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +58 -0
- package/lib/@openglobus/js/ellipsoid/Ellipsoid.d.ts +2 -1
- package/lib/@openglobus/js/ellipsoid/index.d.ts +4 -3
- package/lib/@openglobus/js/ellipsoid/mars.d.ts +6 -0
- package/lib/@openglobus/js/ellipsoid/moon.d.ts +6 -0
- package/lib/@openglobus/js/entity/Entity.d.ts +4 -2
- package/lib/@openglobus/js/entity/EntityCollection.d.ts +3 -2
- package/lib/@openglobus/js/entity/GeoObject.d.ts +6 -1
- package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +4 -0
- package/lib/@openglobus/js/entity/Label.d.ts +14 -0
- package/lib/@openglobus/js/entity/LabelHandler.d.ts +1 -1
- package/lib/@openglobus/js/index.d.ts +3 -3
- package/lib/@openglobus/js/layer/Vector.d.ts +12 -29
- package/lib/@openglobus/js/proj/equi.d.ts +9 -0
- package/lib/@openglobus/js/quadTree/{EPSG4326QuadTreeStrategy.d.ts → EPSG4326/EPSG4326QuadTreeStrategy.d.ts} +2 -2
- package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +5 -13
- package/lib/@openglobus/js/quadTree/EntityCollectionsTreeStrategy.d.ts +25 -0
- package/lib/@openglobus/js/quadTree/QuadTreeStrategy.d.ts +11 -0
- package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +18 -0
- package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.d.ts +19 -0
- package/lib/@openglobus/js/quadTree/earth/EarthQuadTreeStrategy.d.ts +29 -0
- package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +17 -0
- package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.d.ts +17 -0
- package/lib/@openglobus/js/quadTree/equi/EquiQuadTreeStrategy.d.ts +19 -0
- package/lib/@openglobus/js/quadTree/index.d.ts +6 -6
- package/lib/{js/quadTree → @openglobus/js/quadTree/wgs84}/Wgs84QuadTreeStrategy.d.ts +2 -2
- package/lib/@openglobus/js/renderer/Renderer.d.ts +2 -0
- package/lib/@openglobus/js/scene/Planet.d.ts +0 -27
- package/lib/@openglobus/js/segment/Segment.d.ts +0 -1
- package/lib/@openglobus/js/segment/SegmentLonLat.d.ts +0 -4
- package/lib/@openglobus/js/segment/{SegmentLonLatWgs84.d.ts → SegmentLonLatEqui.d.ts} +4 -1
- package/lib/@openglobus/js/terrain/RgbTerrain.d.ts +11 -0
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/@openglobus/res/fonts/Ephesis-Regular.json +4648 -0
- package/lib/@openglobus/res/fonts/Ephesis-Regular.ttf.cfg +1282 -0
- package/lib/@openglobus/res/fonts/Ephesis-Regular.ttf.png +0 -0
- package/lib/js/Globe.d.ts +4 -0
- package/lib/js/Globe.js +8 -4
- package/lib/js/Object3d.d.ts +7 -2
- package/lib/js/Object3d.js +46 -6
- package/lib/js/camera/Camera.d.ts +2 -0
- package/lib/js/camera/Camera.js +8 -0
- package/lib/js/control/elevationProfile/ElevationProfileScene.js +2 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +58 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +105 -0
- package/lib/js/ellipsoid/Ellipsoid.d.ts +2 -1
- package/lib/js/ellipsoid/Ellipsoid.js +17 -1
- package/lib/js/ellipsoid/index.d.ts +4 -3
- package/lib/js/ellipsoid/index.js +4 -3
- package/lib/js/ellipsoid/mars.d.ts +6 -0
- package/lib/js/ellipsoid/mars.js +6 -0
- package/lib/js/ellipsoid/moon.d.ts +6 -0
- package/lib/js/ellipsoid/moon.js +6 -0
- package/lib/js/entity/Entity.d.ts +4 -2
- package/lib/js/entity/Entity.js +4 -1
- package/lib/js/entity/EntityCollection.d.ts +3 -2
- package/lib/js/entity/EntityCollection.js +26 -2
- package/lib/js/entity/GeoObject.d.ts +6 -1
- package/lib/js/entity/GeoObject.js +9 -0
- package/lib/js/entity/GeoObjectHandler.d.ts +4 -0
- package/lib/js/entity/GeoObjectHandler.js +32 -1
- package/lib/js/entity/GeometryHandler.js +16 -14
- package/lib/js/entity/Label.d.ts +14 -0
- package/lib/js/entity/Label.js +24 -4
- package/lib/js/entity/LabelHandler.d.ts +1 -1
- package/lib/js/entity/LabelHandler.js +4 -4
- package/lib/js/entity/Polyline.js +1 -1
- package/lib/js/index.d.ts +3 -3
- package/lib/js/index.js +3 -3
- package/lib/js/layer/CanvasTiles.js +1 -11
- package/lib/js/layer/Layer.js +9 -28
- package/lib/js/layer/Vector.d.ts +12 -29
- package/lib/js/layer/Vector.js +45 -160
- package/lib/js/layer/XYZ.js +10 -10
- package/lib/js/proj/equi.d.ts +9 -0
- package/lib/js/proj/equi.js +9 -0
- package/lib/js/quadTree/{EPSG4326QuadTreeStrategy.d.ts → EPSG4326/EPSG4326QuadTreeStrategy.d.ts} +2 -2
- package/lib/js/quadTree/EPSG4326/EPSG4326QuadTreeStrategy.js +16 -0
- package/lib/js/quadTree/EntityCollectionNode.d.ts +5 -13
- package/lib/js/quadTree/EntityCollectionNode.js +18 -83
- package/lib/js/quadTree/EntityCollectionsTreeStrategy.d.ts +25 -0
- package/lib/js/quadTree/EntityCollectionsTreeStrategy.js +49 -0
- package/lib/js/quadTree/Node.js +6 -12
- package/lib/js/quadTree/QuadTreeStrategy.d.ts +11 -0
- package/lib/js/quadTree/QuadTreeStrategy.js +12 -0
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +18 -0
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +74 -0
- package/lib/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.d.ts +19 -0
- package/lib/js/quadTree/earth/EarthEntityCollectionsTreeStrategy.js +103 -0
- package/lib/js/quadTree/earth/EarthQuadTreeStrategy.d.ts +29 -0
- package/lib/js/quadTree/{EarthQuadTreeStrategy.js → earth/EarthQuadTreeStrategy.js} +29 -6
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +17 -0
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +70 -0
- package/lib/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.d.ts +17 -0
- package/lib/js/quadTree/equi/EquiEntityCollectionsTreeStrategy.js +75 -0
- package/lib/js/quadTree/equi/EquiQuadTreeStrategy.d.ts +19 -0
- package/lib/js/quadTree/equi/EquiQuadTreeStrategy.js +62 -0
- package/lib/js/quadTree/index.d.ts +6 -6
- package/lib/js/quadTree/index.js +6 -6
- package/lib/{@openglobus/js/quadTree → js/quadTree/wgs84}/Wgs84QuadTreeStrategy.d.ts +2 -2
- package/lib/js/quadTree/wgs84/Wgs84QuadTreeStrategy.js +15 -0
- package/lib/js/renderer/Renderer.d.ts +2 -0
- package/lib/js/renderer/Renderer.js +2 -2
- package/lib/js/scene/Planet.d.ts +0 -27
- package/lib/js/scene/Planet.js +2 -9
- package/lib/js/segment/Segment.d.ts +0 -1
- package/lib/js/segment/Segment.js +0 -3
- package/lib/js/segment/SegmentLonLat.d.ts +0 -4
- package/lib/js/segment/SegmentLonLat.js +0 -11
- package/lib/js/segment/{SegmentLonLatWgs84.d.ts → SegmentLonLatEqui.d.ts} +4 -1
- package/lib/js/segment/SegmentLonLatEqui.js +46 -0
- package/lib/js/shaders/geoObject.js +10 -5
- package/lib/js/shaders/polyline.js +8 -6
- package/lib/js/terrain/RgbTerrain.d.ts +11 -0
- package/lib/js/terrain/RgbTerrain.js +12 -1
- package/lib/js/utils/PlainSegmentWorker.js +3 -1
- package/lib/js/webgl/Handler.js +1 -1
- package/package.json +4 -4
- package/lib/@openglobus/js/quadTree/EarthQuadTreeStrategy.d.ts +0 -9
- package/lib/@openglobus/js/quadTree/MarsQuadTreeStrategy.d.ts +0 -11
- package/lib/js/quadTree/EPSG4326QuadTreeStrategy.js +0 -16
- package/lib/js/quadTree/EarthQuadTreeStrategy.d.ts +0 -9
- package/lib/js/quadTree/MarsQuadTreeStrategy.d.ts +0 -11
- package/lib/js/quadTree/MarsQuadTreeStrategy.js +0 -43
- package/lib/js/quadTree/Wgs84QuadTreeStrategy.js +0 -15
- package/lib/js/segment/SegmentLonLatWgs84.js +0 -25
package/lib/js/layer/Vector.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
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
|
|
7
|
+
import * as mercator from "../mercator";
|
|
12
8
|
/**
|
|
13
9
|
* Creates entity instance array.
|
|
14
10
|
* @param {Entity[] | IEntityParams[]} entities - Entity array.
|
|
@@ -69,11 +65,23 @@ class Vector extends Layer {
|
|
|
69
65
|
this._hasImageryTiles = false;
|
|
70
66
|
this.scaleByDistance = options.scaleByDistance || [math.MAX32, math.MAX32, math.MAX32];
|
|
71
67
|
this._useLighting = options.useLighting !== undefined ? options.useLighting : true;
|
|
72
|
-
|
|
68
|
+
let pickingScale = new Float32Array([1.0, 1.0, 1.0]);
|
|
69
|
+
if (options.pickingScale !== undefined) {
|
|
70
|
+
if (options.pickingScale instanceof Array) {
|
|
71
|
+
pickingScale[0] = options.pickingScale[0] || pickingScale[0];
|
|
72
|
+
pickingScale[1] = options.pickingScale[1] || pickingScale[1];
|
|
73
|
+
pickingScale[2] = options.pickingScale[2] || pickingScale[2];
|
|
74
|
+
}
|
|
75
|
+
else if (typeof options.pickingScale === 'number') {
|
|
76
|
+
pickingScale[0] = options.pickingScale;
|
|
77
|
+
pickingScale[1] = options.pickingScale;
|
|
78
|
+
pickingScale[2] = options.pickingScale;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.pickingScale = pickingScale;
|
|
73
82
|
this.async = options.async !== undefined ? options.async : true;
|
|
74
83
|
this.clampToGround = options.clampToGround || false;
|
|
75
84
|
this.relativeToGround = options.relativeToGround || false;
|
|
76
|
-
this._nodeCapacity = options.nodeCapacity || 30;
|
|
77
85
|
this._entities = _entitiesConstructor(options.entities || []);
|
|
78
86
|
this._labelMaxLetters = options.labelMaxLetters || 24;
|
|
79
87
|
this._stripEntityCollection = new EntityCollection({
|
|
@@ -90,19 +98,11 @@ class Vector extends Layer {
|
|
|
90
98
|
});
|
|
91
99
|
this._bindEventsDefault(this._geoObjectEntityCollection);
|
|
92
100
|
this._geometryHandler = new GeometryHandler(this);
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
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 = [];
|
|
101
|
+
this._nodeCapacity = options.nodeCapacity || 60;
|
|
102
|
+
this._entityCollectionsTreeStrategy = null;
|
|
102
103
|
this.setEntities(this._entities);
|
|
103
104
|
this.polygonOffsetUnits = options.polygonOffsetUnits != undefined ? options.polygonOffsetUnits : 0.0;
|
|
104
105
|
this.pickingEnabled = this._pickingEnabled;
|
|
105
|
-
this._secondPASS = [];
|
|
106
106
|
}
|
|
107
107
|
get useLighting() {
|
|
108
108
|
return this._useLighting;
|
|
@@ -153,31 +153,6 @@ class Vector extends Layer {
|
|
|
153
153
|
getEntities() {
|
|
154
154
|
return [].concat(this._entities);
|
|
155
155
|
}
|
|
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
156
|
/**
|
|
182
157
|
* Adds entity to the layer.
|
|
183
158
|
* @public
|
|
@@ -218,13 +193,14 @@ class Vector extends Layer {
|
|
|
218
193
|
}
|
|
219
194
|
_proceedEntity(entity, rightNow = false) {
|
|
220
195
|
let temp = this._hasImageryTiles;
|
|
196
|
+
let isEmpty = !(entity.strip || entity.polyline || entity.ray || entity.geoObject || entity.geometry);
|
|
221
197
|
if (entity.strip) {
|
|
222
198
|
this._stripEntityCollection.add(entity);
|
|
223
199
|
}
|
|
224
200
|
if (entity.polyline || entity.ray) {
|
|
225
201
|
this._polylineEntityCollection.add(entity);
|
|
226
202
|
}
|
|
227
|
-
if (entity.geoObject) {
|
|
203
|
+
if (entity.geoObject || isEmpty) {
|
|
228
204
|
this._geoObjectEntityCollection.add(entity);
|
|
229
205
|
}
|
|
230
206
|
if (entity.geometry) {
|
|
@@ -234,28 +210,25 @@ class Vector extends Layer {
|
|
|
234
210
|
this._geometryHandler.add(entity.geometry);
|
|
235
211
|
}
|
|
236
212
|
}
|
|
237
|
-
if (
|
|
238
|
-
if (
|
|
213
|
+
if (this._planet) {
|
|
214
|
+
if (entity.billboard || entity.label || entity.geoObject || isEmpty) {
|
|
239
215
|
if (entity._cartesian.isZero() && !entity._lonLat.isZero()) {
|
|
240
216
|
entity._setCartesian3vSilent(this._planet.ellipsoid.lonLatToCartesian(entity._lonLat));
|
|
241
217
|
}
|
|
242
218
|
else {
|
|
243
219
|
entity._lonLat = this._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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);
|
|
220
|
+
// IT's important event for degrees proj strategies
|
|
221
|
+
if (Math.abs(entity._lonLat.lat) < mercator.MAX_LAT) {
|
|
222
|
+
entity._lonLatMerc = entity._lonLat.forwardMercator();
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
entity._lonLatMerc.lon = entity._lonLatMerc.lat = entity._lonLatMerc.height = 0;
|
|
226
|
+
}
|
|
257
227
|
}
|
|
258
228
|
}
|
|
229
|
+
if (entity.billboard || entity.label) {
|
|
230
|
+
this._entityCollectionsTreeStrategy?.insertEntity(entity);
|
|
231
|
+
}
|
|
259
232
|
}
|
|
260
233
|
if (this._planet && this._hasImageryTiles !== temp) {
|
|
261
234
|
this._planet.updateVisibleLayers();
|
|
@@ -320,11 +293,9 @@ class Vector extends Layer {
|
|
|
320
293
|
}
|
|
321
294
|
}
|
|
322
295
|
}
|
|
323
|
-
if (entity.geometry) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
this._planet.renderer.clearPickingColor(entity);
|
|
327
|
-
}
|
|
296
|
+
if (this._planet && entity.geometry) {
|
|
297
|
+
this._geometryHandler.remove(entity.geometry);
|
|
298
|
+
this._planet.renderer.clearPickingColor(entity);
|
|
328
299
|
}
|
|
329
300
|
entity._nodePtr = undefined;
|
|
330
301
|
this.events.dispatch(this.events.entityremove, entity);
|
|
@@ -341,18 +312,7 @@ class Vector extends Layer {
|
|
|
341
312
|
this._stripEntityCollection.setPickingEnabled(picking);
|
|
342
313
|
this._polylineEntityCollection.setPickingEnabled(picking);
|
|
343
314
|
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
|
-
});
|
|
315
|
+
this._entityCollectionsTreeStrategy?.setPickingEnabled(picking);
|
|
356
316
|
}
|
|
357
317
|
/**
|
|
358
318
|
* Refresh collected entities indexes from startIndex entities collection array position.
|
|
@@ -378,13 +338,8 @@ class Vector extends Layer {
|
|
|
378
338
|
}
|
|
379
339
|
return this;
|
|
380
340
|
}
|
|
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
341
|
/**
|
|
387
|
-
*
|
|
342
|
+
* Clear the layer.
|
|
388
343
|
* @public
|
|
389
344
|
*/
|
|
390
345
|
clear() {
|
|
@@ -402,9 +357,8 @@ class Vector extends Layer {
|
|
|
402
357
|
for (let i = 0; i < temp.length; i++) {
|
|
403
358
|
this._entities[i] = temp[i];
|
|
404
359
|
}
|
|
405
|
-
this.
|
|
406
|
-
this.
|
|
407
|
-
this._entityCollectionsTreeSouth = null;
|
|
360
|
+
this._entityCollectionsTreeStrategy?.dispose();
|
|
361
|
+
this._entityCollectionsTreeStrategy = null;
|
|
408
362
|
this._geometryHandler.clear();
|
|
409
363
|
}
|
|
410
364
|
/**
|
|
@@ -437,13 +391,14 @@ class Vector extends Layer {
|
|
|
437
391
|
let ei = temp[i];
|
|
438
392
|
ei._layer = this;
|
|
439
393
|
ei._layerIndex = i;
|
|
394
|
+
let isEmpty = !(ei.strip || ei.polyline || ei.ray || ei.geoObject || ei.billboard || ei.label);
|
|
440
395
|
if (ei.strip) {
|
|
441
396
|
this._stripEntityCollection.add(ei);
|
|
442
397
|
}
|
|
443
398
|
else if (ei.polyline || ei.ray) {
|
|
444
399
|
this._polylineEntityCollection.add(ei);
|
|
445
400
|
}
|
|
446
|
-
else if (ei.geoObject) {
|
|
401
|
+
else if (ei.geoObject || isEmpty) {
|
|
447
402
|
this._geoObjectEntityCollection.add(ei);
|
|
448
403
|
}
|
|
449
404
|
else if (ei.billboard || ei.label) {
|
|
@@ -461,35 +416,14 @@ class Vector extends Layer {
|
|
|
461
416
|
this._createEntityCollectionsTree(entitiesForTree);
|
|
462
417
|
return this;
|
|
463
418
|
}
|
|
464
|
-
/**
|
|
465
|
-
* @todo: replace to a strategy node collecting algorithm
|
|
466
|
-
*/
|
|
467
419
|
_createEntityCollectionsTree(entitiesForTree) {
|
|
468
420
|
if (this._planet) {
|
|
469
|
-
this.
|
|
470
|
-
this.
|
|
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);
|
|
421
|
+
this._entityCollectionsTreeStrategy = this._planet.quadTreeStrategy.createEntitiCollectionsTreeStrategy(this, this._nodeCapacity);
|
|
422
|
+
this._entityCollectionsTreeStrategy.insertEntities(entitiesForTree);
|
|
489
423
|
}
|
|
490
424
|
}
|
|
491
425
|
/**
|
|
492
|
-
* @todo (refactoring) could be used in
|
|
426
|
+
* @todo (refactoring) could be used in something like bindEntityCollectionQuad(...)
|
|
493
427
|
* @param entityCollection
|
|
494
428
|
*/
|
|
495
429
|
_bindEventsDefault(entityCollection) {
|
|
@@ -682,64 +616,15 @@ class Vector extends Layer {
|
|
|
682
616
|
let p = this._planet;
|
|
683
617
|
if ((this._fading && this._fadingOpacity > 0.0) ||
|
|
684
618
|
(this.minZoom <= p.maxCurrZoom && this.maxZoom >= p.maxCurrZoom)) {
|
|
685
|
-
this._renderingNodes = {};
|
|
686
|
-
this._renderingNodesNorth = {};
|
|
687
|
-
this._renderingNodesSouth = {};
|
|
688
619
|
// Common collections first
|
|
689
620
|
this._collectStripCollectionPASS(outArr);
|
|
690
621
|
this._collectPolylineCollectionPASS(outArr);
|
|
691
622
|
this._collectGeoObjectCollectionPASS(outArr);
|
|
692
|
-
|
|
693
|
-
|
|
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);
|
|
623
|
+
if (this._entityCollectionsTreeStrategy) {
|
|
624
|
+
this._entityCollectionsTreeStrategy.collectVisibleEntityCollections(outArr);
|
|
712
625
|
}
|
|
713
626
|
}
|
|
714
627
|
}
|
|
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
628
|
/**
|
|
744
629
|
* Start to load tile material.
|
|
745
630
|
* @public
|
package/lib/js/layer/XYZ.js
CHANGED
|
@@ -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;
|
|
97
|
+
return segment._projection.id === this._planet.quadTreeStrategy.projection.id;
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Start to load tile material.
|
|
@@ -142,9 +142,7 @@ export class XYZ extends Layer {
|
|
|
142
142
|
material.textureNotExists();
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
}
|
|
146
|
-
//,this.__id
|
|
147
|
-
);
|
|
145
|
+
});
|
|
148
146
|
}
|
|
149
147
|
else {
|
|
150
148
|
material.textureNotExists();
|
|
@@ -277,12 +275,14 @@ export class XYZ extends Layer {
|
|
|
277
275
|
if (e.southWest.lon === -180.0) {
|
|
278
276
|
em.southWest.lon = -ENLARGE_MERCATOR_LON;
|
|
279
277
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
278
|
+
// WHY!???
|
|
279
|
+
// if (e.northEast.lat >= mercator.MAX_LAT) {
|
|
280
|
+
// e.northEast.lat = mercator.MAX_LAT;
|
|
281
|
+
// }
|
|
282
|
+
//
|
|
283
|
+
// if (e.northEast.lat <= mercator.MIN_LAT) {
|
|
284
|
+
// e.northEast.lat = mercator.MIN_LAT;
|
|
285
|
+
// }
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
const XYZ_EVENTS = [
|
package/lib/js/quadTree/{EPSG4326QuadTreeStrategy.d.ts → EPSG4326/EPSG4326QuadTreeStrategy.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Planet } from "
|
|
2
|
-
import { QuadTreeStrategy } from "
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
13
|
-
this.
|
|
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
|
|
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(
|
|
134
|
-
nd[NE] = new EntityCollectionNode(
|
|
135
|
-
nd[SW] = new EntityCollectionNode(
|
|
136
|
-
nd[SE] = new EntityCollectionNode(
|
|
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.
|
|
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.
|
|
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
|
|
196
|
-
|
|
196
|
+
const s = this.strategy;
|
|
197
|
+
s._renderingNodes[this.nodeId] = true;
|
|
197
198
|
if (this.deferredEntities.length && !this._inTheQueue) {
|
|
198
|
-
if (
|
|
199
|
-
|
|
199
|
+
if (this.layer.async) {
|
|
200
|
+
s._queueDeferredNode(this);
|
|
200
201
|
}
|
|
201
202
|
else {
|
|
202
203
|
this.applyCollection();
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
|
-
|
|
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.
|
|
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
|
|
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
|
+
}
|