@openglobus/og 0.13.8 → 0.13.12
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 -1
- package/css/og.css +388 -129
- package/dist/@openglobus/og.css +1 -1
- 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 +20 -19
- package/src/og/Globe.js +15 -16
- package/src/og/Object3d.js +33 -0
- package/src/og/control/GeoImageDragControl.js +102 -75
- package/src/og/control/LayerAnimation.js +306 -38
- package/src/og/control/LayerSwitcher.js +506 -159
- package/src/og/control/Lighting.js +27 -27
- package/src/og/control/RulerSwitcher.js +69 -0
- package/src/og/control/UIhelpers.js +146 -0
- package/src/og/control/index.js +3 -1
- package/src/og/control/ruler/RulerScene.js +6 -2
- package/src/og/control/visibleExtent/Segment.js +2 -1
- package/src/og/ellipsoid/wgs84.js +1 -1
- package/src/og/entity/LabelHandler.js +2 -2
- package/src/og/entity/LabelWorker.js +36 -54
- package/src/og/layer/BaseGeoImage.js +347 -312
- package/src/og/layer/CanvasTiles.js +312 -290
- package/src/og/layer/GeoImage.js +222 -214
- package/src/og/layer/GeoVideo.js +291 -291
- package/src/og/layer/Layer.js +71 -30
- package/src/og/layer/Material.js +109 -109
- package/src/og/layer/Vector.js +1 -0
- package/src/og/layer/XYZ.js +20 -12
- package/src/og/light/LightSource.js +364 -363
- package/src/og/math.js +2 -2
- package/src/og/quadTree/Node.js +7 -5
- package/src/og/renderer/Renderer.js +1 -1
- package/src/og/scene/Planet.js +103 -42
- package/src/og/segment/Segment.js +34 -56
- package/src/og/segment/Slice.js +1 -1
- package/src/og/shaders/drawnode.js +1 -1
- package/src/og/terrain/GlobusTerrain.js +31 -20
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/BaseWorker.js +46 -0
- package/src/og/utils/GeoImageCreator.js +164 -161
- package/src/og/utils/Loader.js +60 -33
- package/src/og/utils/NormalMapCreator.js +403 -412
- package/src/og/utils/PlainSegmentWorker.js +29 -55
- package/src/og/utils/TerrainWorker.js +572 -589
- package/src/og/utils/functionComposition.js +13 -0
- package/src/og/webgl/Handler.js +42 -41
- package/types/Object3d.d.ts +1 -0
- package/types/camera/PlanetCamera.d.ts +4 -0
- package/types/control/GeoImageDragControl.d.ts +2 -0
- package/types/control/LayerAnimation.d.ts +73 -0
- package/types/control/LayerSwitcher.d.ts +55 -11
- package/types/control/MouseNavigation.d.ts +1 -0
- package/types/control/MouseWheelZoomControl.d.ts +1 -0
- package/types/control/Sun.d.ts +1 -0
- package/types/control/TouchNavigation.d.ts +1 -0
- package/types/control/UIhelpers.d.ts +13 -0
- package/types/control/index.d.ts +2 -1
- package/types/entity/LabelHandler.d.ts +2 -0
- package/types/entity/LabelWorker.d.ts +5 -7
- package/types/layer/BaseGeoImage.d.ts +9 -1
- package/types/layer/CanvasTiles.d.ts +5 -1
- package/types/layer/GeoImage.d.ts +1 -0
- package/types/layer/GeoTexture2d.d.ts +1 -0
- package/types/layer/Layer.d.ts +5 -1
- package/types/layer/Vector.d.ts +7 -0
- package/types/layer/WMS.d.ts +1 -0
- package/types/layer/XYZ.d.ts +8 -6
- package/types/math.d.ts +1 -1
- package/types/quadTree/EntityCollectionNode.d.ts +7 -0
- package/types/quadTree/Node.d.ts +1 -2
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +16 -0
- package/types/scene/Planet.d.ts +19 -4
- package/types/segment/SegmentLonLat.d.ts +2 -0
- package/types/terrain/BilTerrain.d.ts +6 -0
- package/types/terrain/GlobusTerrain.d.ts +7 -0
- package/types/terrain/MapboxTerrain.d.ts +8 -0
- package/types/utils/BaseWorker.d.ts +14 -0
- package/types/utils/Loader.d.ts +3 -1
- package/types/utils/PlainSegmentWorker.d.ts +4 -6
- package/types/utils/TerrainWorker.d.ts +4 -6
- package/types/utils/functionComposition.d.ts +5 -0
- package/types/webgl/Handler.d.ts +4 -1
package/src/og/math.js
CHANGED
|
@@ -135,12 +135,12 @@ export function isPowerOfTwo(x) {
|
|
|
135
135
|
* @param {number} x - Input value.
|
|
136
136
|
* @returns {number} -
|
|
137
137
|
*/
|
|
138
|
-
export function nextHighestPowerOfTwo(x) {
|
|
138
|
+
export function nextHighestPowerOfTwo(x, maxValue = 4096) {
|
|
139
139
|
--x;
|
|
140
140
|
for (var i = 1; i < 32; i <<= 1) {
|
|
141
141
|
x = x | (x >> i);
|
|
142
142
|
}
|
|
143
|
-
return x + 1
|
|
143
|
+
return (x + 1) > maxValue ? maxValue : x + 1
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
/**
|
package/src/og/quadTree/Node.js
CHANGED
|
@@ -75,8 +75,7 @@ class Node {
|
|
|
75
75
|
this.sideSizeLog2 = [0, 0, 0, 0];
|
|
76
76
|
this.ready = false;
|
|
77
77
|
this.neighbors = [[], [], [], []];
|
|
78
|
-
this.
|
|
79
|
-
this.equalizedNeighborGridSize = [-1, -1, -1, -1];
|
|
78
|
+
this.equalizedSideWithNodeId = [this.nodeId, this.nodeId, this.nodeId, this.nodeId];
|
|
80
79
|
this.nodes = [null, null, null, null];
|
|
81
80
|
this.segment = new SegmentPrototype(this, planet, tileZoom, extent);
|
|
82
81
|
this._cameraInside = false;
|
|
@@ -639,6 +638,9 @@ class Node {
|
|
|
639
638
|
let tempVertices, tempVerticesHigh, tempVerticesLow, noDataVertices;
|
|
640
639
|
|
|
641
640
|
this.appliedTerrainNodeId = pn.nodeId;
|
|
641
|
+
this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] =
|
|
642
|
+
this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
|
|
643
|
+
|
|
642
644
|
|
|
643
645
|
let gridSize = pn.segment.gridSize / dZ2,
|
|
644
646
|
gridSizeExt = pn.segment.fileGridSize / dZ2;
|
|
@@ -819,6 +821,8 @@ class Node {
|
|
|
819
821
|
seg.terrainVerticesLow = tempVerticesLow;
|
|
820
822
|
|
|
821
823
|
this.appliedTerrainNodeId = this.nodeId;
|
|
824
|
+
this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] =
|
|
825
|
+
this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
|
|
822
826
|
|
|
823
827
|
if (pn.segment.terrainExists) {
|
|
824
828
|
seg.terrainExists = true;
|
|
@@ -883,9 +887,7 @@ class Node {
|
|
|
883
887
|
clearTree() {
|
|
884
888
|
var state = this.getState();
|
|
885
889
|
|
|
886
|
-
if (state === NOTRENDERING) {
|
|
887
|
-
this.destroyBranches();
|
|
888
|
-
} else if (state === RENDERING) {
|
|
890
|
+
if (state === NOTRENDERING || state === RENDERING) {
|
|
889
891
|
this.destroyBranches();
|
|
890
892
|
} else {
|
|
891
893
|
for (var i = 0; i < this.nodes.length; i++) {
|
package/src/og/scene/Planet.js
CHANGED
|
@@ -94,7 +94,13 @@ const EVENT_NAMES = [
|
|
|
94
94
|
* Triggered when all data is loaded
|
|
95
95
|
* @event og.scene.Planet#terraincompleted
|
|
96
96
|
*/
|
|
97
|
-
"terraincompleted"
|
|
97
|
+
"terraincompleted",
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Triggered when layer data is laded
|
|
101
|
+
* @event og.scene.Planet#terraincompleted
|
|
102
|
+
*/
|
|
103
|
+
"layerloadend"
|
|
98
104
|
];
|
|
99
105
|
|
|
100
106
|
/**
|
|
@@ -145,11 +151,18 @@ export class Planet extends RenderNode {
|
|
|
145
151
|
this._planetRadius2 = this.ellipsoid.getPolarSize() * this.ellipsoid.getPolarSize();
|
|
146
152
|
|
|
147
153
|
/**
|
|
148
|
-
*
|
|
149
|
-
* @
|
|
154
|
+
* Layers array.
|
|
155
|
+
* @protected
|
|
150
156
|
* @type {Array.<Layer>}
|
|
151
157
|
*/
|
|
152
|
-
this.
|
|
158
|
+
this._layers = [];
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Flag to trigger layer update in a next frame
|
|
162
|
+
* @type {boolean}
|
|
163
|
+
* @private
|
|
164
|
+
*/
|
|
165
|
+
this._updateLayer = false;
|
|
153
166
|
|
|
154
167
|
/**
|
|
155
168
|
* Current visible imagery tile layers array.
|
|
@@ -188,6 +201,13 @@ export class Planet extends RenderNode {
|
|
|
188
201
|
*/
|
|
189
202
|
this.terrain = null;
|
|
190
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Terrain provider Pool.
|
|
206
|
+
* @public
|
|
207
|
+
* @type {Terrain}
|
|
208
|
+
*/
|
|
209
|
+
this._terrainPool = null;
|
|
210
|
+
|
|
191
211
|
/**
|
|
192
212
|
* Camera is this.renderer.activeCamera pointer.
|
|
193
213
|
* @public
|
|
@@ -446,6 +466,10 @@ export class Planet extends RenderNode {
|
|
|
446
466
|
return Quat.getLookRotation(t, n);
|
|
447
467
|
}
|
|
448
468
|
|
|
469
|
+
get layers() {
|
|
470
|
+
return [...this._layers];
|
|
471
|
+
}
|
|
472
|
+
|
|
449
473
|
/**
|
|
450
474
|
* Add the given control to the renderer of the planet scene.
|
|
451
475
|
* @param {control.Control} control - Control.
|
|
@@ -484,10 +508,9 @@ export class Planet extends RenderNode {
|
|
|
484
508
|
* @returns {Layer} -
|
|
485
509
|
*/
|
|
486
510
|
getLayerByName(name) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return this.layers[i];
|
|
511
|
+
for (let i = 0, len = this._layers.length; i < len; i++) {
|
|
512
|
+
if (name === this._layers[i].name) {
|
|
513
|
+
return this._layers[i];
|
|
491
514
|
}
|
|
492
515
|
}
|
|
493
516
|
}
|
|
@@ -516,7 +539,7 @@ export class Planet extends RenderNode {
|
|
|
516
539
|
* @public
|
|
517
540
|
*/
|
|
518
541
|
addLayers(layers) {
|
|
519
|
-
for (
|
|
542
|
+
for (let i = 0, len = layers.length; i < len; i++) {
|
|
520
543
|
this.addLayer(layers[i]);
|
|
521
544
|
}
|
|
522
545
|
}
|
|
@@ -543,10 +566,30 @@ export class Planet extends RenderNode {
|
|
|
543
566
|
if (mats[lid]) {
|
|
544
567
|
mats[lid].clear();
|
|
545
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];
|
|
546
588
|
}
|
|
547
589
|
});
|
|
548
590
|
}
|
|
549
591
|
|
|
592
|
+
|
|
550
593
|
/**
|
|
551
594
|
* Get the collection of layers associated with this planet.
|
|
552
595
|
* @return {Array.<Layer>} Layers array.
|
|
@@ -689,11 +732,18 @@ export class Planet extends RenderNode {
|
|
|
689
732
|
this.renderer.screenTexture.height = this._heightPickingFramebuffer.textures[0];
|
|
690
733
|
}
|
|
691
734
|
|
|
735
|
+
_onLayerLoadend(layer) {
|
|
736
|
+
this.events.dispatch(this.events.layerloadend, layer);
|
|
737
|
+
}
|
|
738
|
+
|
|
692
739
|
/**
|
|
693
740
|
* @virtual
|
|
694
741
|
* @public
|
|
695
742
|
*/
|
|
696
743
|
init() {
|
|
744
|
+
|
|
745
|
+
this._tileLoader.events.on("layerloadend", this._onLayerLoadend, this);
|
|
746
|
+
|
|
697
747
|
// Initialization indexes table
|
|
698
748
|
segmentHelper.getInstance().setMaxGridSize(this._maxGridSize);
|
|
699
749
|
const TABLESIZE = this._maxGridSize;
|
|
@@ -705,10 +755,10 @@ export class Planet extends RenderNode {
|
|
|
705
755
|
!this._indexesCache[i][j] && (this._indexesCache[i][j] = new Array(TABLESIZE));
|
|
706
756
|
for (var k = 0; k <= TABLESIZE; k++) {
|
|
707
757
|
!this._indexesCache[i][j][k] &&
|
|
708
|
-
|
|
758
|
+
(this._indexesCache[i][j][k] = new Array(TABLESIZE));
|
|
709
759
|
for (var m = 0; m <= TABLESIZE; m++) {
|
|
710
760
|
!this._indexesCache[i][j][k][m] &&
|
|
711
|
-
|
|
761
|
+
(this._indexesCache[i][j][k][m] = new Array(TABLESIZE));
|
|
712
762
|
for (var q = 0; q <= TABLESIZE; q++) {
|
|
713
763
|
let ptr = {
|
|
714
764
|
buffer: null
|
|
@@ -795,7 +845,7 @@ export class Planet extends RenderNode {
|
|
|
795
845
|
// Applying shaders
|
|
796
846
|
this._initializeShaders();
|
|
797
847
|
|
|
798
|
-
this.
|
|
848
|
+
this._updateVisibleLayers();
|
|
799
849
|
|
|
800
850
|
this.renderer.addPickingCallback(this, this._frustumEntityCollectionPickingCallback);
|
|
801
851
|
|
|
@@ -936,9 +986,9 @@ export class Planet extends RenderNode {
|
|
|
936
986
|
* @public
|
|
937
987
|
*/
|
|
938
988
|
updateAttributionsList() {
|
|
939
|
-
|
|
940
|
-
for (
|
|
941
|
-
|
|
989
|
+
let html = "";
|
|
990
|
+
for (let i = 0, len = this._layers.length; i < len; i++) {
|
|
991
|
+
let li = this._layers[i];
|
|
942
992
|
if (li._visibility) {
|
|
943
993
|
if (li._attribution.length) {
|
|
944
994
|
html += "<li>" + li._attribution + "</li>";
|
|
@@ -949,20 +999,24 @@ export class Planet extends RenderNode {
|
|
|
949
999
|
this._applyAttribution(html)
|
|
950
1000
|
}
|
|
951
1001
|
|
|
1002
|
+
updateVisibleLayers() {
|
|
1003
|
+
this._updateLayer = true;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
952
1006
|
/**
|
|
953
1007
|
* Updates visible layers.
|
|
954
1008
|
* @public
|
|
955
1009
|
*/
|
|
956
|
-
|
|
1010
|
+
_updateVisibleLayers() {
|
|
957
1011
|
this.visibleTileLayers = [];
|
|
958
1012
|
this.visibleTileLayers.length = 0;
|
|
959
1013
|
|
|
960
1014
|
this.visibleVectorLayers = [];
|
|
961
1015
|
this.visibleVectorLayers.length = 0;
|
|
962
1016
|
|
|
963
|
-
|
|
964
|
-
for (
|
|
965
|
-
|
|
1017
|
+
let html = "";
|
|
1018
|
+
for (let i = 0, len = this._layers.length; i < len; i++) {
|
|
1019
|
+
let li = this._layers[i];
|
|
966
1020
|
if (li._visibility) {
|
|
967
1021
|
if (li._isBaseLayer) {
|
|
968
1022
|
this.createDefaultTextures(li._defaultTextures[0], li._defaultTextures[1]);
|
|
@@ -1021,21 +1075,21 @@ export class Planet extends RenderNode {
|
|
|
1021
1075
|
* @protected
|
|
1022
1076
|
*/
|
|
1023
1077
|
_sortLayers() {
|
|
1024
|
-
this.visibleVectorLayers.sort(
|
|
1025
|
-
|
|
1026
|
-
|
|
1078
|
+
this.visibleVectorLayers.sort(
|
|
1079
|
+
(a, b) => (a._zIndex - b._zIndex) || (a._height - b._height)
|
|
1080
|
+
);
|
|
1027
1081
|
|
|
1028
1082
|
this._visibleTileLayerSlices = [];
|
|
1029
1083
|
this._visibleTileLayerSlices.length = 0;
|
|
1030
1084
|
|
|
1031
1085
|
if (this.visibleTileLayers.length) {
|
|
1032
|
-
this.visibleTileLayers.sort(
|
|
1033
|
-
|
|
1034
|
-
|
|
1086
|
+
this.visibleTileLayers.sort((a, b) =>
|
|
1087
|
+
(a._height - b._height) || (a._zIndex - b._zIndex)
|
|
1088
|
+
);
|
|
1035
1089
|
|
|
1036
1090
|
var k = -1;
|
|
1037
1091
|
var currHeight = this.visibleTileLayers[0]._height;
|
|
1038
|
-
for (
|
|
1092
|
+
for (let i = 0, len = this.visibleTileLayers.length; i < len; i++) {
|
|
1039
1093
|
if (i % this.SLICE_SIZE === 0 || this.visibleTileLayers[i]._height !== currHeight) {
|
|
1040
1094
|
k++;
|
|
1041
1095
|
this._visibleTileLayerSlices[k] = [];
|
|
@@ -1154,6 +1208,12 @@ export class Planet extends RenderNode {
|
|
|
1154
1208
|
* @public
|
|
1155
1209
|
*/
|
|
1156
1210
|
frame() {
|
|
1211
|
+
|
|
1212
|
+
if (this._updateLayer) {
|
|
1213
|
+
this._updateLayer = false;
|
|
1214
|
+
this._updateVisibleLayers();
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1157
1217
|
this._renderScreenNodesPASS();
|
|
1158
1218
|
|
|
1159
1219
|
this._renderHeightPickingFramebufferPASS();
|
|
@@ -1188,16 +1248,16 @@ export class Planet extends RenderNode {
|
|
|
1188
1248
|
* @protected
|
|
1189
1249
|
*/
|
|
1190
1250
|
_renderScreenNodesPASS() {
|
|
1251
|
+
|
|
1191
1252
|
let sh, shu;
|
|
1192
1253
|
let renderer = this.renderer;
|
|
1193
1254
|
let h = renderer.handler;
|
|
1194
1255
|
let gl = h.gl;
|
|
1195
1256
|
let cam = renderer.activeCamera;
|
|
1196
|
-
let frustumIndex = cam.getCurrentFrustum()
|
|
1197
|
-
|
|
1198
|
-
gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
1257
|
+
let frustumIndex = cam.getCurrentFrustum(),
|
|
1258
|
+
firstPass = frustumIndex === cam.FARTHEST_FRUSTUM_INDEX;
|
|
1199
1259
|
|
|
1200
|
-
if (
|
|
1260
|
+
if (firstPass) {
|
|
1201
1261
|
if (this._skipPreRender/* && (!this._renderCompletedActivated || cam.isMoved)*/) {
|
|
1202
1262
|
this._collectRenderNodes();
|
|
1203
1263
|
}
|
|
@@ -1274,7 +1334,7 @@ export class Planet extends RenderNode {
|
|
|
1274
1334
|
let sli = sl[0];
|
|
1275
1335
|
for (var i = sli.length - 1; i >= 0; --i) {
|
|
1276
1336
|
let li = sli[i];
|
|
1277
|
-
if (li._fading && li._refreshFadingOpacity()) {
|
|
1337
|
+
if (li._fading && firstPass && li._refreshFadingOpacity()) {
|
|
1278
1338
|
sli.splice(i, 1);
|
|
1279
1339
|
}
|
|
1280
1340
|
}
|
|
@@ -1289,22 +1349,23 @@ export class Planet extends RenderNode {
|
|
|
1289
1349
|
s.screenRendering(sh, sl[0], 0);
|
|
1290
1350
|
}
|
|
1291
1351
|
|
|
1292
|
-
|
|
1352
|
+
gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
1293
1353
|
for (let j = 1, len = sl.length; j < len; j++) {
|
|
1294
1354
|
let slj = sl[j];
|
|
1295
1355
|
for (i = slj.length - 1; i >= 0; --i) {
|
|
1296
1356
|
let li = slj[i];
|
|
1297
|
-
if (li._fading && li._refreshFadingOpacity()) {
|
|
1357
|
+
if (li._fading && firstPass && li._refreshFadingOpacity()) {
|
|
1298
1358
|
slj.splice(i, 1);
|
|
1299
1359
|
}
|
|
1300
1360
|
}
|
|
1301
1361
|
|
|
1362
|
+
gl.polygonOffset(0, -j);
|
|
1302
1363
|
i = rn.length;
|
|
1303
|
-
//gl.polygonOffset(0, -j);
|
|
1304
1364
|
while (i--) {
|
|
1305
1365
|
rn[i].segment.screenRendering(sh, sl[j], j, this.transparentTexture, true);
|
|
1306
1366
|
}
|
|
1307
1367
|
}
|
|
1368
|
+
gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
1308
1369
|
|
|
1309
1370
|
gl.disable(gl.BLEND);
|
|
1310
1371
|
}
|
|
@@ -1342,7 +1403,7 @@ export class Planet extends RenderNode {
|
|
|
1342
1403
|
gl.uniform3fv(shu.eyePositionLow, cam.eyeLow);
|
|
1343
1404
|
|
|
1344
1405
|
// drawing planet nodes
|
|
1345
|
-
|
|
1406
|
+
let rn = this._renderedNodesInFrustum[frustumIndex],
|
|
1346
1407
|
sl = this._visibleTileLayerSlices;
|
|
1347
1408
|
|
|
1348
1409
|
let i = rn.length;
|
|
@@ -1387,15 +1448,15 @@ export class Planet extends RenderNode {
|
|
|
1387
1448
|
rn[i].segment.colorPickingRendering(sh, sl[0], 0);
|
|
1388
1449
|
}
|
|
1389
1450
|
|
|
1390
|
-
|
|
1451
|
+
gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
1391
1452
|
for (let j = 1, len = sl.length; j < len; j++) {
|
|
1392
1453
|
i = rn.length;
|
|
1393
|
-
|
|
1454
|
+
gl.polygonOffset(0, -j);
|
|
1394
1455
|
while (i--) {
|
|
1395
1456
|
rn[i].segment.colorPickingRendering(sh, sl[j], j, this.transparentTexture, true);
|
|
1396
1457
|
}
|
|
1397
1458
|
}
|
|
1398
|
-
|
|
1459
|
+
gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
1399
1460
|
|
|
1400
1461
|
gl.disable(gl.BLEND);
|
|
1401
1462
|
}
|
|
@@ -1438,7 +1499,7 @@ export class Planet extends RenderNode {
|
|
|
1438
1499
|
this._frustumEntityCollections.length = 0;
|
|
1439
1500
|
this._frustumEntityCollections = [];
|
|
1440
1501
|
|
|
1441
|
-
|
|
1502
|
+
let i = this.visibleVectorLayers.length;
|
|
1442
1503
|
while (i--) {
|
|
1443
1504
|
let vi = this.visibleVectorLayers[i];
|
|
1444
1505
|
|
|
@@ -1474,7 +1535,7 @@ export class Planet extends RenderNode {
|
|
|
1474
1535
|
|
|
1475
1536
|
this._normalMapCreator.clear();
|
|
1476
1537
|
this.terrain.abortLoading();
|
|
1477
|
-
this._tileLoader.
|
|
1538
|
+
this._tileLoader.abortAll();
|
|
1478
1539
|
|
|
1479
1540
|
var that = this;
|
|
1480
1541
|
// setTimeout(function () {
|
|
@@ -1811,8 +1872,8 @@ export class Planet extends RenderNode {
|
|
|
1811
1872
|
}
|
|
1812
1873
|
|
|
1813
1874
|
let readyCollections = {};
|
|
1814
|
-
for (let i = 0; i < this.
|
|
1815
|
-
let li = this.
|
|
1875
|
+
for (let i = 0; i < this._layers.length; i++) {
|
|
1876
|
+
let li = this._layers[i];
|
|
1816
1877
|
if (li instanceof Vector) {
|
|
1817
1878
|
li.each(function (e) {
|
|
1818
1879
|
if (e._entityCollection && !readyCollections[e._entityCollection.id]) {
|
|
@@ -386,8 +386,9 @@ class Segment {
|
|
|
386
386
|
* @param {Float32Array} elevations - Elevation data.
|
|
387
387
|
*/
|
|
388
388
|
elevationsExists(elevations) {
|
|
389
|
+
const segment = this;
|
|
389
390
|
if (this.plainReady && this.terrainIsLoading) {
|
|
390
|
-
this.planet._terrainWorker.make(
|
|
391
|
+
this.planet._terrainWorker.make(segment, elevations);
|
|
391
392
|
|
|
392
393
|
this.plainVerticesHigh = null;
|
|
393
394
|
this.plainVerticesLow = null;
|
|
@@ -403,19 +404,8 @@ class Segment {
|
|
|
403
404
|
}
|
|
404
405
|
|
|
405
406
|
_checkEqualization(neighborSide, neigborNode) {
|
|
406
|
-
return
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
//&&
|
|
410
|
-
//(
|
|
411
|
-
// this.node.equalizedNeighborId[neighborSide] !== neigborNode.appliedTerrainNodeId ||
|
|
412
|
-
// this.node.equalizedNeighborGridSize[neighborSide] !== neigborNode.segment.gridSize
|
|
413
|
-
//||
|
|
414
|
-
|
|
415
|
-
// neigborNode.equalizedNeighborId[OPSIDE[neighborSide]] !== this.node.appliedTerrainNodeId ||
|
|
416
|
-
// neigborNode.equalizedNeighborGridSize[OPSIDE[neighborSide]] !== this.gridSize
|
|
417
|
-
//)
|
|
418
|
-
);
|
|
407
|
+
return neigborNode && this.tileZoom >= neigborNode.segment.tileZoom &&
|
|
408
|
+
this.node.equalizedSideWithNodeId[neighborSide] !== neigborNode.equalizedSideWithNodeId[OPSIDE[neighborSide]];
|
|
419
409
|
}
|
|
420
410
|
|
|
421
411
|
equalize() {
|
|
@@ -433,11 +423,8 @@ class Segment {
|
|
|
433
423
|
|
|
434
424
|
let n = nn[N][0];
|
|
435
425
|
if (this._checkEqualization(N, n)) {
|
|
436
|
-
//this.node.equalizedNeighborId[N] = n.appliedTerrainNodeId;
|
|
437
|
-
//this.node.equalizedNeighborGridSize[N] = n.segment.gridSize;
|
|
438
426
|
|
|
439
|
-
|
|
440
|
-
//n.equalizedNeighborGridSize[OPSIDE[N]] = this.gridSize;
|
|
427
|
+
this.node.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[S];
|
|
441
428
|
|
|
442
429
|
this.readyToEngage = true;
|
|
443
430
|
|
|
@@ -476,11 +463,8 @@ class Segment {
|
|
|
476
463
|
|
|
477
464
|
n = nn[E][0];
|
|
478
465
|
if (this._checkEqualization(E, n)) {
|
|
479
|
-
//this.node.equalizedNeighborId[E] = n.appliedTerrainNodeId;
|
|
480
|
-
//this.node.equalizedNeighborGridSize[E] = n.segment.gridSize;
|
|
481
466
|
|
|
482
|
-
|
|
483
|
-
//n.equalizedNeighborGridSize[OPSIDE[E]] = this.gridSize;
|
|
467
|
+
this.node.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[W];
|
|
484
468
|
|
|
485
469
|
this.readyToEngage = true;
|
|
486
470
|
|
|
@@ -519,11 +503,8 @@ class Segment {
|
|
|
519
503
|
|
|
520
504
|
n = nn[S][0];
|
|
521
505
|
if (this._checkEqualization(S, n)) {
|
|
522
|
-
//this.node.equalizedNeighborId[S] = n.appliedTerrainNodeId;
|
|
523
|
-
//this.node.equalizedNeighborGridSize[S] = n.segment.gridSize;
|
|
524
506
|
|
|
525
|
-
|
|
526
|
-
//n.equalizedNeighborGridSize[OPSIDE[S]] = this.gridSize;
|
|
507
|
+
this.node.equalizedSideWithNodeId[S] = n.equalizedSideWithNodeId[N];
|
|
527
508
|
|
|
528
509
|
this.readyToEngage = true;
|
|
529
510
|
|
|
@@ -561,11 +542,8 @@ class Segment {
|
|
|
561
542
|
|
|
562
543
|
n = nn[W][0];
|
|
563
544
|
if (this._checkEqualization(W, n)) {
|
|
564
|
-
//this.node.equalizedNeighborId[W] = n.appliedTerrainNodeId;
|
|
565
|
-
//this.node.equalizedNeighborGridSize[W] = n.segment.gridSize;
|
|
566
545
|
|
|
567
|
-
|
|
568
|
-
//n.equalizedNeighborGridSize[OPSIDE[W]] = this.gridSize;
|
|
546
|
+
this.node.equalizedSideWithNodeId[W] = n.equalizedSideWithNodeId[E];
|
|
569
547
|
|
|
570
548
|
this.readyToEngage = true;
|
|
571
549
|
|
|
@@ -671,17 +649,12 @@ class Segment {
|
|
|
671
649
|
|
|
672
650
|
this.setBoundingVolumeArr(data.bounds);
|
|
673
651
|
|
|
674
|
-
//var b = data.bounds;
|
|
675
|
-
|
|
676
|
-
//this.setBoundingSphere(
|
|
677
|
-
// b[0] + (b[1] - b[0]) * 0.5,
|
|
678
|
-
// b[2] + (b[3] - b[2]) * 0.5,
|
|
679
|
-
// b[4] + (b[5] - b[4]) * 0.5,
|
|
680
|
-
// new Vec3(b[0], b[2], b[4])
|
|
681
|
-
//);
|
|
682
|
-
|
|
683
652
|
this.gridSize = Math.sqrt(this.terrainVertices.length / 3) - 1;
|
|
684
|
-
|
|
653
|
+
|
|
654
|
+
let n = this.node;
|
|
655
|
+
n.appliedTerrainNodeId = n.nodeId;
|
|
656
|
+
n.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[S] =
|
|
657
|
+
n.equalizedSideWithNodeId[W] = n.appliedTerrainNodeId;
|
|
685
658
|
|
|
686
659
|
this.terrainReady = true;
|
|
687
660
|
this.terrainIsLoading = false;
|
|
@@ -710,7 +683,10 @@ class Segment {
|
|
|
710
683
|
if (this.plainReady && this.terrainIsLoading) {
|
|
711
684
|
this.terrainIsLoading = false;
|
|
712
685
|
|
|
713
|
-
|
|
686
|
+
let n = this.node;
|
|
687
|
+
n.appliedTerrainNodeId = this.node.nodeId;
|
|
688
|
+
n.equalizedSideWithNodeId[N] = n.equalizedSideWithNodeId[E] = n.equalizedSideWithNodeId[S] =
|
|
689
|
+
n.equalizedSideWithNodeId[W] = n.appliedTerrainNodeId;
|
|
714
690
|
|
|
715
691
|
if (this.planet.lightEnabled && !this._inTheQueue) {
|
|
716
692
|
this.planet._normalMapCreator.queue(this);
|
|
@@ -735,6 +711,7 @@ class Segment {
|
|
|
735
711
|
this.terrainExists = false;
|
|
736
712
|
}
|
|
737
713
|
}
|
|
714
|
+
|
|
738
715
|
_normalMapEdgeEqualize(side) {
|
|
739
716
|
let nn = this.node.neighbors;
|
|
740
717
|
let n = nn[side][0];
|
|
@@ -1080,10 +1057,10 @@ class Segment {
|
|
|
1080
1057
|
v_rb = new Vec3(bigOne[9], bigOne[10], bigOne[11]);
|
|
1081
1058
|
|
|
1082
1059
|
let vn = new Vec3(
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1060
|
+
bigOne[3] - bigOne[0],
|
|
1061
|
+
bigOne[4] - bigOne[1],
|
|
1062
|
+
bigOne[5] - bigOne[2]
|
|
1063
|
+
),
|
|
1087
1064
|
vw = new Vec3(
|
|
1088
1065
|
bigOne[6] - bigOne[0],
|
|
1089
1066
|
bigOne[7] - bigOne[1],
|
|
@@ -1256,16 +1233,16 @@ class Segment {
|
|
|
1256
1233
|
|
|
1257
1234
|
n.sideSize[0] =
|
|
1258
1235
|
n.sideSize[1] =
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1236
|
+
n.sideSize[2] =
|
|
1237
|
+
n.sideSize[3] =
|
|
1238
|
+
this.gridSize =
|
|
1239
|
+
p.terrain.gridSizeByZoom[this.tileZoom] || p.terrain.plainGridSize;
|
|
1263
1240
|
|
|
1264
1241
|
n.sideSizeLog2[0] =
|
|
1265
1242
|
n.sideSizeLog2[1] =
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1243
|
+
n.sideSizeLog2[2] =
|
|
1244
|
+
n.sideSizeLog2[3] =
|
|
1245
|
+
Math.log2(p.terrain.gridSizeByZoom[this.tileZoom] || p.terrain.plainGridSize);
|
|
1269
1246
|
|
|
1270
1247
|
if (this.tileZoom <= p.terrain.maxZoom) {
|
|
1271
1248
|
var nmc = this.planet._normalMapCreator;
|
|
@@ -1435,7 +1412,7 @@ class Segment {
|
|
|
1435
1412
|
p = this.planet;
|
|
1436
1413
|
|
|
1437
1414
|
var currHeight, li;
|
|
1438
|
-
if (layerSlice) {
|
|
1415
|
+
if (layerSlice && layerSlice.length) {
|
|
1439
1416
|
li = layerSlice[0];
|
|
1440
1417
|
currHeight = li._height;
|
|
1441
1418
|
} else {
|
|
@@ -1541,7 +1518,7 @@ class Segment {
|
|
|
1541
1518
|
p = this.planet;
|
|
1542
1519
|
|
|
1543
1520
|
var currHeight;
|
|
1544
|
-
if (layerSlice) {
|
|
1521
|
+
if (layerSlice && layerSlice.length) {
|
|
1545
1522
|
currHeight = layerSlice[0]._height;
|
|
1546
1523
|
} else {
|
|
1547
1524
|
currHeight = 0;
|
|
@@ -1568,7 +1545,7 @@ class Segment {
|
|
|
1568
1545
|
p = this.planet;
|
|
1569
1546
|
|
|
1570
1547
|
var currHeight;
|
|
1571
|
-
if (layerSlice) {
|
|
1548
|
+
if (layerSlice && layerSlice.length) {
|
|
1572
1549
|
currHeight = layerSlice[0]._height;
|
|
1573
1550
|
} else {
|
|
1574
1551
|
currHeight = 0;
|
|
@@ -1632,7 +1609,7 @@ class Segment {
|
|
|
1632
1609
|
shu = sh.uniforms;
|
|
1633
1610
|
|
|
1634
1611
|
var currHeight;
|
|
1635
|
-
if (layerSlice) {
|
|
1612
|
+
if (layerSlice.length) {
|
|
1636
1613
|
currHeight = layerSlice[0]._height;
|
|
1637
1614
|
} else {
|
|
1638
1615
|
currHeight = 0;
|
|
@@ -1709,4 +1686,5 @@ class Segment {
|
|
|
1709
1686
|
return -1;
|
|
1710
1687
|
}
|
|
1711
1688
|
}
|
|
1689
|
+
|
|
1712
1690
|
export { Segment };
|
package/src/og/segment/Slice.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Program } from "../webgl/Program.js";
|
|
|
16
16
|
const NIGHT = `const vec3 nightStep = 10.0 * vec3(0.58, 0.48, 0.25);`;
|
|
17
17
|
|
|
18
18
|
const DEF_BLEND = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
|
|
19
|
-
src = texture( SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw )
|
|
19
|
+
src = texture( SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw );\
|
|
20
20
|
DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;`;
|
|
21
21
|
|
|
22
22
|
const DEF_BLEND_WEBGL1 = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
|