@openglobus/og 0.13.12 → 0.14.10
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/README.md +1 -4
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/og/Globe.js +14 -6
- package/src/og/control/Sun.js +3 -2
- package/src/og/entity/GeometryHandler.js +3 -3
- package/src/og/index.js +106 -95
- package/src/og/layer/GeoVideo.js +1 -0
- package/src/og/layer/Layer.js +13 -12
- package/src/og/layer/XYZ.js +4 -3
- package/src/og/quadTree/EarthQuadTreeStrategy.js +29 -0
- package/src/og/quadTree/MarsQuadTreeStrategy.js +27 -0
- package/src/og/quadTree/Node.js +53 -216
- package/src/og/quadTree/QuadTreeStrategy.js +93 -0
- package/src/og/quadTree/Wgs84QuadTreeStrategy.js +26 -0
- package/src/og/scene/Planet.js +20 -156
- package/src/og/segment/Segment.js +18 -25
- package/src/og/segment/SegmentLonLat.js +34 -31
- package/src/og/segment/SegmentLonLatWgs84.js +41 -0
- package/src/og/utils/quadTreeType.js +11 -0
- package/types/Globe.d.ts +7 -0
- package/types/control/Sun.d.ts +2 -1
- package/types/index.d.ts +6 -1
- package/types/quadTree/EarthQuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/MarsQuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/Node.d.ts +0 -1
- package/types/quadTree/QuadTreeStrategy.d.ts +21 -0
- package/types/quadTree/Wgs84QuadTreeStrategy.d.ts +3 -0
- package/types/scene/Planet.d.ts +2 -24
- package/types/segment/Segment.d.ts +4 -4
- package/types/segment/SegmentLonLat.d.ts +6 -2
- package/types/segment/SegmentLonLatWgs84.d.ts +4 -0
- package/types/utils/quadTreeType.d.ts +8 -0
package/src/og/scene/Planet.js
CHANGED
|
@@ -8,7 +8,6 @@ import * as utils from "../utils/shared.js";
|
|
|
8
8
|
import * as shaders from "../shaders/drawnode.js";
|
|
9
9
|
import * as math from "../math.js";
|
|
10
10
|
import * as mercator from "../mercator.js";
|
|
11
|
-
import * as quadTree from "../quadTree/quadTree.js";
|
|
12
11
|
import * as segmentHelper from "../segment/segmentHelper.js";
|
|
13
12
|
import { decodeFloatFromRGBAArr } from "../math/coder.js";
|
|
14
13
|
import { Extent } from "../Extent.js";
|
|
@@ -33,6 +32,7 @@ import { NIGHT, SPECULAR } from "../res/images.js";
|
|
|
33
32
|
import { Geoid } from "../terrain/Geoid.js";
|
|
34
33
|
import { isUndef } from "../utils/shared.js";
|
|
35
34
|
import { MAX_RENDERED_NODES } from "../quadTree/quadTree.js";
|
|
35
|
+
import { EarthQuadTreeStrategy } from "../quadTree/EarthQuadTreeStrategy.js";
|
|
36
36
|
|
|
37
37
|
const CUR_LOD_SIZE = 250; //px
|
|
38
38
|
const MIN_LOD_SIZE = 312; //px
|
|
@@ -262,13 +262,6 @@ export class Planet extends RenderNode {
|
|
|
262
262
|
this._renderedNodes = [];
|
|
263
263
|
this._renderedNodesInFrustum = [];
|
|
264
264
|
|
|
265
|
-
/**
|
|
266
|
-
* Created nodes cache
|
|
267
|
-
* @protected
|
|
268
|
-
* @type {quadTree.Node}
|
|
269
|
-
*/
|
|
270
|
-
this._quadTreeNodesCacheMerc = {};
|
|
271
|
-
|
|
272
265
|
/**
|
|
273
266
|
* Current visible mercator segments tree nodes array.
|
|
274
267
|
* @protected
|
|
@@ -340,26 +333,7 @@ export class Planet extends RenderNode {
|
|
|
340
333
|
*/
|
|
341
334
|
this._heightPickingFramebuffer = null;
|
|
342
335
|
|
|
343
|
-
|
|
344
|
-
* Mercator grid tree.
|
|
345
|
-
* @protected
|
|
346
|
-
* @type {quadTree.Node}
|
|
347
|
-
*/
|
|
348
|
-
this._quadTree = null;
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* North grid tree.
|
|
352
|
-
* @protected
|
|
353
|
-
* @type {quadTree.Node}
|
|
354
|
-
*/
|
|
355
|
-
this._quadTreeNorth = null;
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* South grid tree.
|
|
359
|
-
* @protected
|
|
360
|
-
* @type {quadTree.Node}
|
|
361
|
-
*/
|
|
362
|
-
this._quadTreeSouth = null;
|
|
336
|
+
this.quadTreeStrategy = options.quadTreeStrategyPrototype ? new options.quadTreeStrategyPrototype({ planet: this }) : new EarthQuadTreeStrategy({ planet: this });
|
|
363
337
|
|
|
364
338
|
/**
|
|
365
339
|
* Night glowing gl texture.
|
|
@@ -439,7 +413,7 @@ export class Planet extends RenderNode {
|
|
|
439
413
|
|
|
440
414
|
this._plainSegmentWorker = new PlainSegmentWorker(3);
|
|
441
415
|
|
|
442
|
-
this._tileLoader = new Loader(options.
|
|
416
|
+
this._tileLoader = new Loader(options.maxLoadingRequests || 12);
|
|
443
417
|
|
|
444
418
|
this._memKey = new Key();
|
|
445
419
|
|
|
@@ -466,6 +440,10 @@ export class Planet extends RenderNode {
|
|
|
466
440
|
return Quat.getLookRotation(t, n);
|
|
467
441
|
}
|
|
468
442
|
|
|
443
|
+
get normalMapCreator() {
|
|
444
|
+
return this._normalMapCreator;
|
|
445
|
+
}
|
|
446
|
+
|
|
469
447
|
get layers() {
|
|
470
448
|
return [...this._layers];
|
|
471
449
|
}
|
|
@@ -560,33 +538,7 @@ export class Planet extends RenderNode {
|
|
|
560
538
|
* @param {Layer} layer - Material layer.
|
|
561
539
|
*/
|
|
562
540
|
_clearLayerMaterial(layer) {
|
|
563
|
-
|
|
564
|
-
this._quadTree.traverseTree(function (node) {
|
|
565
|
-
var mats = node.segment.materials;
|
|
566
|
-
if (mats[lid]) {
|
|
567
|
-
mats[lid].clear();
|
|
568
|
-
mats[lid] = null;
|
|
569
|
-
delete mats[lid];
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
this._quadTreeNorth.traverseTree(function (node) {
|
|
574
|
-
var mats = node.segment.materials;
|
|
575
|
-
if (mats[lid]) {
|
|
576
|
-
mats[lid].clear();
|
|
577
|
-
mats[lid] = null;
|
|
578
|
-
delete mats[lid];
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
this._quadTreeSouth.traverseTree(function (node) {
|
|
583
|
-
var mats = node.segment.materials;
|
|
584
|
-
if (mats[lid]) {
|
|
585
|
-
mats[lid].clear();
|
|
586
|
-
mats[lid] = null;
|
|
587
|
-
delete mats[lid];
|
|
588
|
-
}
|
|
589
|
-
});
|
|
541
|
+
this.quadTreeStrategy.clearLayerMaterial(layer);
|
|
590
542
|
}
|
|
591
543
|
|
|
592
544
|
|
|
@@ -629,7 +581,7 @@ export class Planet extends RenderNode {
|
|
|
629
581
|
|
|
630
582
|
if (this._heightFactor !== factor) {
|
|
631
583
|
this._heightFactor = factor;
|
|
632
|
-
this.
|
|
584
|
+
this.quadTreeStrategy.destroyBranches();
|
|
633
585
|
}
|
|
634
586
|
}
|
|
635
587
|
|
|
@@ -663,13 +615,7 @@ export class Planet extends RenderNode {
|
|
|
663
615
|
this.terrain = terrain;
|
|
664
616
|
this.terrain._planet = this;
|
|
665
617
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
if (this._quadTree) {
|
|
669
|
-
this._quadTree.destroyBranches();
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
//if (terrain._geoid) {
|
|
618
|
+
this.quadTreeStrategy.destroyBranches();
|
|
673
619
|
|
|
674
620
|
if (terrain._geoid.model) {
|
|
675
621
|
this._plainSegmentWorker.setGeoid(terrain.getGeoid());
|
|
@@ -685,20 +631,6 @@ export class Planet extends RenderNode {
|
|
|
685
631
|
console.log(err);
|
|
686
632
|
});
|
|
687
633
|
}
|
|
688
|
-
|
|
689
|
-
// if (!terrain._geoid.model) {
|
|
690
|
-
// Geoid.loadModel(terrain._geoid.src)
|
|
691
|
-
// .then((m) => {
|
|
692
|
-
// terrain.getGeoid().setModel(m);
|
|
693
|
-
// this._plainSegmentWorker.setGeoid(terrain.getGeoid());
|
|
694
|
-
// })
|
|
695
|
-
// .catch((err) => {
|
|
696
|
-
// console.log(err);
|
|
697
|
-
// });
|
|
698
|
-
// } else {
|
|
699
|
-
// this._plainSegmentWorker.setGeoid(terrain.getGeoid());
|
|
700
|
-
// }
|
|
701
|
-
//}
|
|
702
634
|
}
|
|
703
635
|
|
|
704
636
|
/**
|
|
@@ -829,16 +761,9 @@ export class Planet extends RenderNode {
|
|
|
829
761
|
this._renderedNodesInFrustum[i] = [];
|
|
830
762
|
}
|
|
831
763
|
|
|
764
|
+
|
|
832
765
|
// Creating quad trees nodes
|
|
833
|
-
this.
|
|
834
|
-
Extent.createFromArray([-20037508.34, -20037508.34, 20037508.34, 20037508.34])
|
|
835
|
-
);
|
|
836
|
-
this._quadTreeNorth = new Node(SegmentLonLat, this, quadTree.NW, null, 0, 0,
|
|
837
|
-
Extent.createFromArray([-180, mercator.MAX_LAT, 180, 90])
|
|
838
|
-
);
|
|
839
|
-
this._quadTreeSouth = new Node(SegmentLonLat, this, quadTree.NW, null, 0, 0,
|
|
840
|
-
Extent.createFromArray([-180, -90, 180, mercator.MIN_LAT])
|
|
841
|
-
);
|
|
766
|
+
this.quadTreeStrategy.init();
|
|
842
767
|
|
|
843
768
|
this.drawMode = this.renderer.handler.gl.TRIANGLE_STRIP;
|
|
844
769
|
|
|
@@ -897,29 +822,7 @@ export class Planet extends RenderNode {
|
|
|
897
822
|
}
|
|
898
823
|
|
|
899
824
|
_preRender() {
|
|
900
|
-
|
|
901
|
-
this._quadTree.createChildrenNodes();
|
|
902
|
-
this._quadTree.segment.createPlainSegment();
|
|
903
|
-
|
|
904
|
-
// Zoom 1
|
|
905
|
-
for (let i = 0; i < this._quadTree.nodes.length; i++) {
|
|
906
|
-
this._quadTree.nodes[i].segment.createPlainSegment();
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
// same for poles
|
|
910
|
-
this._quadTreeNorth.createChildrenNodes();
|
|
911
|
-
this._quadTreeNorth.segment.createPlainSegment();
|
|
912
|
-
|
|
913
|
-
for (let i = 0; i < this._quadTreeNorth.nodes.length; i++) {
|
|
914
|
-
this._quadTreeNorth.nodes[i].segment.createPlainSegment();
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
this._quadTreeSouth.createChildrenNodes();
|
|
918
|
-
this._quadTreeSouth.segment.createPlainSegment();
|
|
919
|
-
|
|
920
|
-
for (let i = 0; i < this._quadTreeSouth.nodes.length; i++) {
|
|
921
|
-
this._quadTreeSouth.nodes[i].segment.createPlainSegment();
|
|
922
|
-
}
|
|
825
|
+
this.quadTreeStrategy.preRender();
|
|
923
826
|
|
|
924
827
|
this._preLoad();
|
|
925
828
|
}
|
|
@@ -929,38 +832,7 @@ export class Planet extends RenderNode {
|
|
|
929
832
|
|
|
930
833
|
this._skipPreRender = false;
|
|
931
834
|
|
|
932
|
-
|
|
933
|
-
this._quadTreeNorth.segment.passReady = true;
|
|
934
|
-
this._quadTreeNorth.renderNode(true);
|
|
935
|
-
this._normalMapCreator.drawSingle(this._quadTreeNorth.segment);
|
|
936
|
-
|
|
937
|
-
for (let i = 0; i < this._quadTreeNorth.nodes.length; i++) {
|
|
938
|
-
this._quadTreeNorth.nodes[i].segment.passReady = true;
|
|
939
|
-
this._quadTreeNorth.nodes[i].renderNode(true);
|
|
940
|
-
this._normalMapCreator.drawSingle(this._quadTreeNorth.nodes[i].segment);
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
this._quadTreeSouth.segment.passReady = true;
|
|
944
|
-
this._quadTreeSouth.renderNode(true);
|
|
945
|
-
this._normalMapCreator.drawSingle(this._quadTreeSouth.segment);
|
|
946
|
-
|
|
947
|
-
for (let i = 0; i < this._quadTreeSouth.nodes.length; i++) {
|
|
948
|
-
this._quadTreeSouth.nodes[i].segment.passReady = true;
|
|
949
|
-
this._quadTreeSouth.nodes[i].renderNode(true);
|
|
950
|
-
this._normalMapCreator.drawSingle(this._quadTreeSouth.nodes[i].segment);
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
// Zoom 1
|
|
954
|
-
for (let i = 0; i < this._quadTree.nodes.length; i++) {
|
|
955
|
-
this._quadTree.nodes[i].segment.passReady = true;
|
|
956
|
-
this._quadTree.nodes[i].renderNode(true);
|
|
957
|
-
this._normalMapCreator.drawSingle(this._quadTree.nodes[i].segment);
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
// Zoom 0
|
|
961
|
-
this._quadTree.segment.passReady = true;
|
|
962
|
-
this._quadTree.renderNode(true);
|
|
963
|
-
this._normalMapCreator.drawSingle(this._quadTree.segment);
|
|
835
|
+
this.quadTreeStrategy.preLoad();
|
|
964
836
|
}
|
|
965
837
|
|
|
966
838
|
/**
|
|
@@ -1136,8 +1008,6 @@ export class Planet extends RenderNode {
|
|
|
1136
1008
|
this.minCurrZoom = math.MAX;
|
|
1137
1009
|
this.maxCurrZoom = math.MIN;
|
|
1138
1010
|
|
|
1139
|
-
this._quadTree.renderTree(cam, 0, null);
|
|
1140
|
-
|
|
1141
1011
|
if (cam.slope > this.minEqualZoomCameraSlope &&
|
|
1142
1012
|
cam._lonLat.height < this.maxEqualZoomAltitude &&
|
|
1143
1013
|
cam._lonLat.height > this.minEqualZoomAltitude
|
|
@@ -1181,8 +1051,7 @@ export class Planet extends RenderNode {
|
|
|
1181
1051
|
}
|
|
1182
1052
|
}
|
|
1183
1053
|
|
|
1184
|
-
this.
|
|
1185
|
-
this._quadTreeSouth.renderTree(cam, 0, null);
|
|
1054
|
+
this.quadTreeStrategy.collectRenderNodes();
|
|
1186
1055
|
}
|
|
1187
1056
|
|
|
1188
1057
|
_globalPreDraw() {
|
|
@@ -1537,16 +1406,11 @@ export class Planet extends RenderNode {
|
|
|
1537
1406
|
this.terrain.abortLoading();
|
|
1538
1407
|
this._tileLoader.abortAll();
|
|
1539
1408
|
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
that.layerLock.free(that._memKey);
|
|
1547
|
-
that.terrainLock.free(that._memKey);
|
|
1548
|
-
that._normalMapCreator.free(that._memKey);
|
|
1549
|
-
// }, 0);
|
|
1409
|
+
|
|
1410
|
+
this.quadTreeStrategy.clear();
|
|
1411
|
+
this.layerLock.free(this._memKey);
|
|
1412
|
+
this.terrainLock.free(this._memKey);
|
|
1413
|
+
this._normalMapCreator.free(this._memKey);
|
|
1550
1414
|
|
|
1551
1415
|
this._createdNodesCount = 0;
|
|
1552
1416
|
}
|
|
@@ -14,6 +14,10 @@ import * as segmentHelper from "../segment/segmentHelper.js";
|
|
|
14
14
|
import { getMatrixSubArray } from "../utils/shared.js";
|
|
15
15
|
import { Slice } from "./Slice.js";
|
|
16
16
|
|
|
17
|
+
export const TILEGROUP_COMMON = 0;
|
|
18
|
+
export const TILEGROUP_NORTH = 1;
|
|
19
|
+
export const TILEGROUP_SOUTH = 2;
|
|
20
|
+
|
|
17
21
|
var _tempHigh = new Vec3();
|
|
18
22
|
var _tempLow = new Vec3();
|
|
19
23
|
|
|
@@ -57,7 +61,7 @@ class Segment {
|
|
|
57
61
|
constructor(node, planet, tileZoom, extent) {
|
|
58
62
|
this.isPole = false;
|
|
59
63
|
|
|
60
|
-
this._tileGroup =
|
|
64
|
+
this._tileGroup = TILEGROUP_COMMON;
|
|
61
65
|
|
|
62
66
|
this._projection = EPSG3857;
|
|
63
67
|
|
|
@@ -246,6 +250,10 @@ class Segment {
|
|
|
246
250
|
this.plainProcessing = false;
|
|
247
251
|
}
|
|
248
252
|
|
|
253
|
+
checkZoom() {
|
|
254
|
+
return this.tileZoom < this.planet.terrain._maxNodeZoom;
|
|
255
|
+
}
|
|
256
|
+
|
|
249
257
|
/**
|
|
250
258
|
* Returns entity terrain point.
|
|
251
259
|
* @public
|
|
@@ -890,19 +898,10 @@ class Segment {
|
|
|
890
898
|
this.deleteElevations();
|
|
891
899
|
}
|
|
892
900
|
|
|
893
|
-
/**
|
|
894
|
-
* Removes cache records.
|
|
895
|
-
*/
|
|
896
|
-
_freeCache() {
|
|
897
|
-
this.planet._quadTreeNodesCacheMerc[this.tileIndex] = null;
|
|
898
|
-
delete this.planet._quadTreeNodesCacheMerc[this.tileIndex];
|
|
899
|
-
}
|
|
900
|
-
|
|
901
901
|
/**
|
|
902
902
|
* Clear and destroy all segment data.
|
|
903
903
|
*/
|
|
904
904
|
destroySegment() {
|
|
905
|
-
this._freeCache();
|
|
906
905
|
|
|
907
906
|
this.clearSegment();
|
|
908
907
|
|
|
@@ -1206,7 +1205,9 @@ class Segment {
|
|
|
1206
1205
|
}
|
|
1207
1206
|
|
|
1208
1207
|
_assignTileIndexes() {
|
|
1209
|
-
|
|
1208
|
+
|
|
1209
|
+
this._tileGroup = TILEGROUP_COMMON;
|
|
1210
|
+
|
|
1210
1211
|
var tileZoom = this.tileZoom;
|
|
1211
1212
|
var extent = this._extent;
|
|
1212
1213
|
var pole = mercator.POLE;
|
|
@@ -1224,25 +1225,17 @@ class Segment {
|
|
|
1224
1225
|
this.tileYS = this.tileY + 1;
|
|
1225
1226
|
|
|
1226
1227
|
this.tileIndex = Layer.getTileIndex(this.tileX, this.tileY, tileZoom);
|
|
1227
|
-
this.planet._quadTreeNodesCacheMerc[this.tileIndex] = this.node;
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
1230
|
initialize() {
|
|
1231
1231
|
var p = this.planet;
|
|
1232
1232
|
var n = this.node;
|
|
1233
1233
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
n.sideSize[2] =
|
|
1237
|
-
n.sideSize[3] =
|
|
1238
|
-
this.gridSize =
|
|
1239
|
-
p.terrain.gridSizeByZoom[this.tileZoom] || p.terrain.plainGridSize;
|
|
1234
|
+
this.gridSize =
|
|
1235
|
+
p.terrain.gridSizeByZoom[this.tileZoom] || p.terrain.plainGridSize;
|
|
1240
1236
|
|
|
1241
|
-
n.sideSizeLog2[0] =
|
|
1242
|
-
|
|
1243
|
-
n.sideSizeLog2[2] =
|
|
1244
|
-
n.sideSizeLog2[3] =
|
|
1245
|
-
Math.log2(p.terrain.gridSizeByZoom[this.tileZoom] || p.terrain.plainGridSize);
|
|
1237
|
+
n.sideSizeLog2[0] = n.sideSizeLog2[1] = n.sideSizeLog2[2] = n.sideSizeLog2[3] =
|
|
1238
|
+
Math.log2(this.gridSize);
|
|
1246
1239
|
|
|
1247
1240
|
if (this.tileZoom <= p.terrain.maxZoom) {
|
|
1248
1241
|
var nmc = this.planet._normalMapCreator;
|
|
@@ -1628,8 +1621,8 @@ class Segment {
|
|
|
1628
1621
|
}
|
|
1629
1622
|
|
|
1630
1623
|
_getIndexBuffer() {
|
|
1631
|
-
|
|
1632
|
-
|
|
1624
|
+
let s = this.node.sideSizeLog2;
|
|
1625
|
+
let cache = this.planet._indexesCache[Math.log2(this.gridSize)][s[0]][s[1]][s[2]][s[3]];
|
|
1633
1626
|
if (!cache.buffer) {
|
|
1634
1627
|
let indexes = segmentHelper.getInstance().createSegmentIndexes(Math.log2(this.gridSize), [s[0], s[1], s[2], s[3]]);
|
|
1635
1628
|
cache.buffer = this.planet.renderer.handler.createElementArrayBuffer(indexes, 1);
|
|
@@ -7,11 +7,10 @@ import { Vec3 } from "../math/Vec3.js";
|
|
|
7
7
|
import * as mercator from "../mercator.js";
|
|
8
8
|
import { EPSG4326 } from "../proj/EPSG4326.js";
|
|
9
9
|
import * as quadTree from "../quadTree/quadTree.js";
|
|
10
|
-
import { Segment } from "./Segment.js";
|
|
10
|
+
import { Segment, TILEGROUP_NORTH, TILEGROUP_SOUTH } from "./Segment.js";
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const _pieceSize = _heightLat / Math.pow(2, _maxPoleZoom);
|
|
12
|
+
const MAX_POLE_ZOOM = 7;
|
|
13
|
+
export const POLE_PIECE_SIZE = (90.0 - mercator.MAX_LAT) / Math.pow(2, MAX_POLE_ZOOM);
|
|
15
14
|
|
|
16
15
|
let _tempHigh = new Vec3(),
|
|
17
16
|
_tempLow = new Vec3();
|
|
@@ -35,16 +34,19 @@ class SegmentLonLat extends Segment {
|
|
|
35
34
|
constructor(node, planet, tileZoom, extent) {
|
|
36
35
|
super(node, planet, tileZoom, extent);
|
|
37
36
|
|
|
38
|
-
// TODO:
|
|
39
|
-
// be carefull with functions in constructor _assignTileIndexes
|
|
40
|
-
// this._isNorth = false;
|
|
41
|
-
|
|
42
37
|
this._projection = EPSG4326;
|
|
43
38
|
|
|
44
39
|
this._extentMerc = new Extent(
|
|
45
40
|
extent.southWest.forwardMercatorEPS01(),
|
|
46
41
|
extent.northEast.forwardMercatorEPS01()
|
|
47
42
|
);
|
|
43
|
+
|
|
44
|
+
if (this._extent.northEast.lat > 0) {
|
|
45
|
+
this._isNorth = true;
|
|
46
|
+
} else {
|
|
47
|
+
this._isNorth = false;
|
|
48
|
+
}
|
|
49
|
+
|
|
48
50
|
this.isPole = true;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -64,56 +66,56 @@ class SegmentLonLat extends Segment {
|
|
|
64
66
|
return xyz.length() - res.length();
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var lat = this._extent.northEast.lat;
|
|
69
|
+
_getMaxZoom() {
|
|
70
|
+
let maxPoleZoom = 0;
|
|
70
71
|
if (this._isNorth) {
|
|
71
72
|
//north pole limits
|
|
72
|
-
let Yz = Math.floor((90.0 - lat) /
|
|
73
|
+
let Yz = Math.floor((90.0 - this._extent.northEast.lat) / POLE_PIECE_SIZE);
|
|
73
74
|
maxPoleZoom = Math.floor(Yz / 16) + 7;
|
|
74
75
|
} else {
|
|
75
76
|
//south pole limits
|
|
76
|
-
let Yz = Math.floor((mercator.MIN_LAT - lat) /
|
|
77
|
+
let Yz = Math.floor((mercator.MIN_LAT - this._extent.northEast.lat) / POLE_PIECE_SIZE);
|
|
77
78
|
maxPoleZoom = 12 - Math.floor(Yz / 16);
|
|
78
79
|
}
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
return maxPoleZoom;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
checkZoom() {
|
|
84
|
+
return super.checkZoom() && this.tileZoom <= this._getMaxZoom();
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
_assignTileIndexes() {
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
this._assignTileXIndexes(this._extent);
|
|
89
|
+
this._assignTileYIndexes(this._extent);
|
|
90
|
+
this.tileIndex = Layer.getTileIndex(this.tileX, this.tileY, this.tileZoom);
|
|
91
|
+
}
|
|
87
92
|
|
|
93
|
+
_assignTileXIndexes(extent) {
|
|
88
94
|
this.tileX = Math.round(
|
|
89
95
|
Math.abs(-180.0 - extent.southWest.lon) / (extent.northEast.lon - extent.southWest.lon)
|
|
90
96
|
);
|
|
91
97
|
|
|
92
|
-
|
|
98
|
+
let p2 = 1 << this.tileZoom;
|
|
99
|
+
this.tileXE = (this.tileX + 1) % p2;
|
|
100
|
+
this.tileXW = (p2 + this.tileX - 1) % p2;
|
|
101
|
+
}
|
|
93
102
|
|
|
103
|
+
_assignTileYIndexes(extent) {
|
|
104
|
+
var lat = extent.northEast.lat;
|
|
94
105
|
if (lat > 0) {
|
|
95
|
-
|
|
96
|
-
this._isNorth = true;
|
|
97
|
-
this._tileGroup = 1;
|
|
106
|
+
this._tileGroup = TILEGROUP_NORTH;
|
|
98
107
|
this.tileY = Math.round((90.0 - lat) / (extent.northEast.lat - extent.southWest.lat));
|
|
99
108
|
} else {
|
|
100
|
-
|
|
101
|
-
this._tileGroup = 2;
|
|
109
|
+
this._tileGroup = TILEGROUP_SOUTH;
|
|
102
110
|
this.tileY = Math.round(
|
|
103
111
|
(mercator.MIN_LAT - lat) / (extent.northEast.lat - extent.southWest.lat)
|
|
104
112
|
);
|
|
105
113
|
}
|
|
106
|
-
|
|
107
|
-
var p2 = 1 << tileZoom;
|
|
108
|
-
this.tileXE = (this.tileX + 1) % p2;
|
|
109
|
-
this.tileXW = (p2 + this.tileX - 1) % p2;
|
|
110
|
-
|
|
111
114
|
this.tileYN = this.tileY - 1;
|
|
112
115
|
this.tileYS = this.tileY + 1;
|
|
113
|
-
|
|
114
|
-
this.tileIndex = Layer.getTileIndex(this.tileX, this.tileY, tileZoom);
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
|
|
117
119
|
_createPlainVertices() {
|
|
118
120
|
var gridSize = this.planet.terrain.gridSizeByZoom[this.tileZoom];
|
|
119
121
|
|
|
@@ -292,4 +294,5 @@ class SegmentLonLat extends Segment {
|
|
|
292
294
|
//empty for a time
|
|
293
295
|
}
|
|
294
296
|
}
|
|
297
|
+
|
|
295
298
|
export { SegmentLonLat };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { POLE_PIECE_SIZE, SegmentLonLat } from "./SegmentLonLat.js";
|
|
4
|
+
import { Segment, TILEGROUP_COMMON } from "./Segment.js";
|
|
5
|
+
import * as mercator from "../mercator.js";
|
|
6
|
+
|
|
7
|
+
export class SegmentLonLatWgs84 extends SegmentLonLat {
|
|
8
|
+
constructor(node, planet, tileZoom, extent) {
|
|
9
|
+
super(node, planet, tileZoom, extent);
|
|
10
|
+
this.isPole = false;
|
|
11
|
+
this._tileGroup = TILEGROUP_COMMON;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
_getMaxZoom() {
|
|
15
|
+
return 150;
|
|
16
|
+
// let lat = 0;
|
|
17
|
+
// if (this._isNorth) {
|
|
18
|
+
// lat = this._extent.northEast.lat;
|
|
19
|
+
// } else {
|
|
20
|
+
// lat = Math.abs(this._extent.southWest.lat);
|
|
21
|
+
// }
|
|
22
|
+
// let Yz = Math.floor((90 - lat) / POLE_PIECE_SIZE);
|
|
23
|
+
// return Math.floor(Yz / 16) + 7;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_assignTileYIndexes(extent) {
|
|
27
|
+
this.tileY = Math.round((90.0 - extent.northEast.lat) / (extent.northEast.lat - extent.southWest.lat));
|
|
28
|
+
this.tileYN = this.tileY - 1;
|
|
29
|
+
this.tileYS = this.tileY + 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_assignTileXIndexes(extent) {
|
|
33
|
+
this.tileX = Math.round(
|
|
34
|
+
Math.abs(-180.0 - extent.southWest.lon) / (extent.northEast.lon - extent.southWest.lon)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
let p2 = (1 << this.tileZoom) * 2;
|
|
38
|
+
this.tileXE = (this.tileX + 1) % p2;
|
|
39
|
+
this.tileXW = (p2 + this.tileX - 1) % p2;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { EarthQuadTreeStrategy } from "../quadTree/EarthQuadTreeStrategy.js";
|
|
4
|
+
import { MarsQuadTreeStrategy } from "../quadTree/MarsQuadTreeStrategy.js";
|
|
5
|
+
import { Wgs84QuadTreeStrategy } from "../quadTree/Wgs84QuadTreeStrategy.js";
|
|
6
|
+
|
|
7
|
+
export const quadTreeStrategyType = {
|
|
8
|
+
earth: EarthQuadTreeStrategy,
|
|
9
|
+
mars: MarsQuadTreeStrategy,
|
|
10
|
+
wgs84: Wgs84QuadTreeStrategy
|
|
11
|
+
}
|
package/types/Globe.d.ts
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
* @param {Number} [options.minEqualZoomAltitude=10000.0] - Minimal altitude since segments on the screen bacame the same zoom level
|
|
43
43
|
* @param {Number} [options.minEqualZoomCameraSlope=0.8] - Minimal camera slope above te globe where segments on the screen bacame the same zoom level
|
|
44
44
|
* @param {Number} [options.loadingBatchSize=12] -
|
|
45
|
+
* @param {Number} [options.quadTreeStrategyPrototype] - Prototype of quadTree. QuadTreeStrategy for Earth is default.
|
|
45
46
|
*/
|
|
46
47
|
export class Globe {
|
|
47
48
|
static set _staticCounter(arg: any);
|
|
@@ -64,6 +65,12 @@ export class Globe {
|
|
|
64
65
|
* @type {String}
|
|
65
66
|
*/
|
|
66
67
|
private _planetName;
|
|
68
|
+
/**
|
|
69
|
+
* quad tree type.
|
|
70
|
+
* @private
|
|
71
|
+
* @type {Number}
|
|
72
|
+
*/
|
|
73
|
+
private _quadTreeType;
|
|
67
74
|
planet: Planet;
|
|
68
75
|
sun: any;
|
|
69
76
|
_opacityCounter: number;
|
package/types/control/Sun.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -42,4 +42,9 @@ import * as entity from "./entity/index.js";
|
|
|
42
42
|
export const Entity: typeof entity.Entity;
|
|
43
43
|
import { Geoid } from "./terrain/Geoid.js";
|
|
44
44
|
import { Popup } from "./Popup.js";
|
|
45
|
-
|
|
45
|
+
import { QuadTreeStrategy } from "./quadTree/QuadTreeStrategy.js";
|
|
46
|
+
import { MarsQuadTreeStrategy } from "./quadTree/MarsQuadTreeStrategy.js";
|
|
47
|
+
import { EarthQuadTreeStrategy } from "./quadTree/EarthQuadTreeStrategy.js";
|
|
48
|
+
import { Wgs84QuadTreeStrategy } from "./quadTree/Wgs84QuadTreeStrategy.js";
|
|
49
|
+
import { quadTreeStrategyType } from "./utils/quadTreeType.js";
|
|
50
|
+
export { bv, jd, math, mercator, utils, input, layer, terrain, control, webgl, wgs84, Camera, Ellipsoid, PlanetCamera, Globe, LightSource, Renderer, Clock, Events, Extent, LonLat, scene, RenderNode, Line2, Line3, Mat3, Mat4, Plane, Quat, Ray, Vec2, Vec3, Vec4, entity, Geoid, Popup, QuadTreeStrategy, MarsQuadTreeStrategy, EarthQuadTreeStrategy, Wgs84QuadTreeStrategy, quadTreeStrategyType };
|
package/types/quadTree/Node.d.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class QuadTreeStrategy {
|
|
2
|
+
constructor(options?: {});
|
|
3
|
+
name: string;
|
|
4
|
+
_planet: any;
|
|
5
|
+
projection: import("../proj/Proj.js").Proj;
|
|
6
|
+
/**
|
|
7
|
+
* grid tree list.
|
|
8
|
+
* @protected
|
|
9
|
+
* @type {quadTree.Node[]}
|
|
10
|
+
*/
|
|
11
|
+
protected _quadTreeList: quadTree.Node[];
|
|
12
|
+
destroyBranches(): void;
|
|
13
|
+
clearLayerMaterial(layer: any): void;
|
|
14
|
+
get planet(): any;
|
|
15
|
+
init(): void;
|
|
16
|
+
preRender(): void;
|
|
17
|
+
preLoad(): void;
|
|
18
|
+
collectRenderNodes(): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
get quadTreeList(): quadTree.Node[];
|
|
21
|
+
}
|