@openglobus/og 0.13.7 → 0.13.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 -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 +417 -0
- package/src/og/arial.js +1705 -1703
- package/src/og/camera/Camera.js +640 -640
- package/src/og/control/EarthCoordinates.js +1 -1
- package/src/og/control/GeoImageDragControl.js +102 -75
- package/src/og/control/LayerAnimation.js +383 -0
- package/src/og/control/LayerSwitcher.js +506 -159
- package/src/og/control/Lighting.js +27 -27
- package/src/og/control/MouseNavigation.js +460 -460
- package/src/og/control/RulerSwitcher.js +69 -0
- package/src/og/control/Sun.js +170 -170
- package/src/og/control/UIhelpers.js +146 -0
- package/src/og/control/ZoomControl.js +0 -2
- package/src/og/control/index.js +5 -1
- package/src/og/control/ruler/Ruler.js +43 -0
- package/src/og/control/ruler/RulerScene.js +374 -0
- package/src/og/control/visibleExtent/Segment.js +3 -5
- package/src/og/ellipsoid/Ellipsoid.js +19 -0
- package/src/og/ellipsoid/wgs84.js +1 -1
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/GeoObject.js +1 -1
- package/src/og/entity/LabelHandler.js +6 -2
- package/src/og/entity/LabelWorker.js +38 -53
- 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 +94 -70
- package/src/og/layer/Material.js +109 -109
- package/src/og/layer/Vector.js +81 -14
- package/src/og/layer/XYZ.js +23 -11
- package/src/og/light/LightSource.js +364 -363
- package/src/og/math/Vec3.js +1 -1
- package/src/og/math.js +6 -6
- package/src/og/quadTree/Node.js +8 -6
- package/src/og/renderer/Renderer.js +2 -3
- package/src/og/res/images.js +0 -2
- package/src/og/scene/Planet.js +106 -44
- package/src/og/segment/Segment.js +34 -64
- package/src/og/segment/Slice.js +1 -1
- package/src/og/shaders/drawnode.js +1 -1
- package/src/og/shaders/label.js +30 -42
- 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/FontAtlas.js +1 -2
- package/src/og/utils/GeoImageCreator.js +164 -161
- package/src/og/utils/Loader.js +187 -153
- 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/VectorTileCreator.js +1 -1
- package/src/og/utils/functionComposition.js +13 -0
- package/src/og/webgl/Handler.js +42 -41
- package/src/og/webgl/ProgramController.js +143 -143
- package/types/Object3d.d.ts +22 -0
- package/types/arial.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 +2 -1
- package/types/control/TouchNavigation.d.ts +1 -0
- package/types/control/UIhelpers.d.ts +13 -0
- package/types/control/index.d.ts +3 -1
- package/types/control/ruler/Ruler.d.ts +13 -0
- package/types/control/ruler/RulerScene.d.ts +48 -0
- package/types/ellipsoid/Ellipsoid.d.ts +8 -0
- 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 +28 -32
- package/types/layer/Vector.d.ts +9 -0
- package/types/layer/WMS.d.ts +1 -0
- package/types/layer/XYZ.d.ts +8 -5
- package/types/math.d.ts +2 -2
- 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/res/images.d.ts +0 -1
- package/types/scene/Planet.d.ts +21 -6
- 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 +4 -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/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
|
|
@@ -227,7 +247,7 @@ export class Planet extends RenderNode {
|
|
|
227
247
|
*/
|
|
228
248
|
this.maxCurrZoom = math.MIN;
|
|
229
249
|
|
|
230
|
-
this._viewExtent =
|
|
250
|
+
this._viewExtent = new Extent(new LonLat(180, 180), new LonLat(-180, -180));
|
|
231
251
|
|
|
232
252
|
/**
|
|
233
253
|
* @protected
|
|
@@ -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] = [];
|
|
@@ -1072,7 +1126,8 @@ export class Planet extends RenderNode {
|
|
|
1072
1126
|
// clear first
|
|
1073
1127
|
this._clearRenderedNodeList();
|
|
1074
1128
|
|
|
1075
|
-
this._viewExtent
|
|
1129
|
+
this._viewExtent.southWest.set(180, 180);
|
|
1130
|
+
this._viewExtent.northEast.set(-180, -180);
|
|
1076
1131
|
|
|
1077
1132
|
this._visibleNodes = {};
|
|
1078
1133
|
this._visibleNodesNorth = {};
|
|
@@ -1153,6 +1208,12 @@ export class Planet extends RenderNode {
|
|
|
1153
1208
|
* @public
|
|
1154
1209
|
*/
|
|
1155
1210
|
frame() {
|
|
1211
|
+
|
|
1212
|
+
if (this._updateLayer) {
|
|
1213
|
+
this._updateLayer = false;
|
|
1214
|
+
this._updateVisibleLayers();
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1156
1217
|
this._renderScreenNodesPASS();
|
|
1157
1218
|
|
|
1158
1219
|
this._renderHeightPickingFramebufferPASS();
|
|
@@ -1187,16 +1248,16 @@ export class Planet extends RenderNode {
|
|
|
1187
1248
|
* @protected
|
|
1188
1249
|
*/
|
|
1189
1250
|
_renderScreenNodesPASS() {
|
|
1251
|
+
|
|
1190
1252
|
let sh, shu;
|
|
1191
1253
|
let renderer = this.renderer;
|
|
1192
1254
|
let h = renderer.handler;
|
|
1193
1255
|
let gl = h.gl;
|
|
1194
1256
|
let cam = renderer.activeCamera;
|
|
1195
|
-
let frustumIndex = cam.getCurrentFrustum()
|
|
1196
|
-
|
|
1197
|
-
gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
1257
|
+
let frustumIndex = cam.getCurrentFrustum(),
|
|
1258
|
+
firstPass = frustumIndex === cam.FARTHEST_FRUSTUM_INDEX;
|
|
1198
1259
|
|
|
1199
|
-
if (
|
|
1260
|
+
if (firstPass) {
|
|
1200
1261
|
if (this._skipPreRender/* && (!this._renderCompletedActivated || cam.isMoved)*/) {
|
|
1201
1262
|
this._collectRenderNodes();
|
|
1202
1263
|
}
|
|
@@ -1273,7 +1334,7 @@ export class Planet extends RenderNode {
|
|
|
1273
1334
|
let sli = sl[0];
|
|
1274
1335
|
for (var i = sli.length - 1; i >= 0; --i) {
|
|
1275
1336
|
let li = sli[i];
|
|
1276
|
-
if (li._fading && li._refreshFadingOpacity()) {
|
|
1337
|
+
if (li._fading && firstPass && li._refreshFadingOpacity()) {
|
|
1277
1338
|
sli.splice(i, 1);
|
|
1278
1339
|
}
|
|
1279
1340
|
}
|
|
@@ -1288,22 +1349,23 @@ export class Planet extends RenderNode {
|
|
|
1288
1349
|
s.screenRendering(sh, sl[0], 0);
|
|
1289
1350
|
}
|
|
1290
1351
|
|
|
1291
|
-
|
|
1352
|
+
gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
1292
1353
|
for (let j = 1, len = sl.length; j < len; j++) {
|
|
1293
1354
|
let slj = sl[j];
|
|
1294
1355
|
for (i = slj.length - 1; i >= 0; --i) {
|
|
1295
1356
|
let li = slj[i];
|
|
1296
|
-
if (li._fading && li._refreshFadingOpacity()) {
|
|
1357
|
+
if (li._fading && firstPass && li._refreshFadingOpacity()) {
|
|
1297
1358
|
slj.splice(i, 1);
|
|
1298
1359
|
}
|
|
1299
1360
|
}
|
|
1300
1361
|
|
|
1362
|
+
gl.polygonOffset(0, -j);
|
|
1301
1363
|
i = rn.length;
|
|
1302
|
-
//gl.polygonOffset(0, -j);
|
|
1303
1364
|
while (i--) {
|
|
1304
1365
|
rn[i].segment.screenRendering(sh, sl[j], j, this.transparentTexture, true);
|
|
1305
1366
|
}
|
|
1306
1367
|
}
|
|
1368
|
+
gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
1307
1369
|
|
|
1308
1370
|
gl.disable(gl.BLEND);
|
|
1309
1371
|
}
|
|
@@ -1341,7 +1403,7 @@ export class Planet extends RenderNode {
|
|
|
1341
1403
|
gl.uniform3fv(shu.eyePositionLow, cam.eyeLow);
|
|
1342
1404
|
|
|
1343
1405
|
// drawing planet nodes
|
|
1344
|
-
|
|
1406
|
+
let rn = this._renderedNodesInFrustum[frustumIndex],
|
|
1345
1407
|
sl = this._visibleTileLayerSlices;
|
|
1346
1408
|
|
|
1347
1409
|
let i = rn.length;
|
|
@@ -1386,15 +1448,15 @@ export class Planet extends RenderNode {
|
|
|
1386
1448
|
rn[i].segment.colorPickingRendering(sh, sl[0], 0);
|
|
1387
1449
|
}
|
|
1388
1450
|
|
|
1389
|
-
|
|
1451
|
+
gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
1390
1452
|
for (let j = 1, len = sl.length; j < len; j++) {
|
|
1391
1453
|
i = rn.length;
|
|
1392
|
-
|
|
1454
|
+
gl.polygonOffset(0, -j);
|
|
1393
1455
|
while (i--) {
|
|
1394
1456
|
rn[i].segment.colorPickingRendering(sh, sl[j], j, this.transparentTexture, true);
|
|
1395
1457
|
}
|
|
1396
1458
|
}
|
|
1397
|
-
|
|
1459
|
+
gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
1398
1460
|
|
|
1399
1461
|
gl.disable(gl.BLEND);
|
|
1400
1462
|
}
|
|
@@ -1437,7 +1499,7 @@ export class Planet extends RenderNode {
|
|
|
1437
1499
|
this._frustumEntityCollections.length = 0;
|
|
1438
1500
|
this._frustumEntityCollections = [];
|
|
1439
1501
|
|
|
1440
|
-
|
|
1502
|
+
let i = this.visibleVectorLayers.length;
|
|
1441
1503
|
while (i--) {
|
|
1442
1504
|
let vi = this.visibleVectorLayers[i];
|
|
1443
1505
|
|
|
@@ -1473,7 +1535,7 @@ export class Planet extends RenderNode {
|
|
|
1473
1535
|
|
|
1474
1536
|
this._normalMapCreator.clear();
|
|
1475
1537
|
this.terrain.abortLoading();
|
|
1476
|
-
this._tileLoader.
|
|
1538
|
+
this._tileLoader.abortAll();
|
|
1477
1539
|
|
|
1478
1540
|
var that = this;
|
|
1479
1541
|
// setTimeout(function () {
|
|
@@ -1810,8 +1872,8 @@ export class Planet extends RenderNode {
|
|
|
1810
1872
|
}
|
|
1811
1873
|
|
|
1812
1874
|
let readyCollections = {};
|
|
1813
|
-
for (let i = 0; i < this.
|
|
1814
|
-
let li = this.
|
|
1875
|
+
for (let i = 0; i < this._layers.length; i++) {
|
|
1876
|
+
let li = this._layers[i];
|
|
1815
1877
|
if (li instanceof Vector) {
|
|
1816
1878
|
li.each(function (e) {
|
|
1817
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],
|
|
@@ -1209,14 +1186,6 @@ class Segment {
|
|
|
1209
1186
|
_addViewExtent() {
|
|
1210
1187
|
var ext = this._extentLonLat;
|
|
1211
1188
|
|
|
1212
|
-
if (!this.planet._viewExtent) {
|
|
1213
|
-
this.planet._viewExtent = new Extent(
|
|
1214
|
-
new LonLat(ext.southWest.lon, ext.southWest.lat),
|
|
1215
|
-
new LonLat(ext.northEast.lon, ext.northEast.lat)
|
|
1216
|
-
);
|
|
1217
|
-
return;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
1189
|
var viewExt = this.planet._viewExtent;
|
|
1221
1190
|
|
|
1222
1191
|
if (ext.southWest.lon < viewExt.southWest.lon) {
|
|
@@ -1264,16 +1233,16 @@ class Segment {
|
|
|
1264
1233
|
|
|
1265
1234
|
n.sideSize[0] =
|
|
1266
1235
|
n.sideSize[1] =
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1236
|
+
n.sideSize[2] =
|
|
1237
|
+
n.sideSize[3] =
|
|
1238
|
+
this.gridSize =
|
|
1239
|
+
p.terrain.gridSizeByZoom[this.tileZoom] || p.terrain.plainGridSize;
|
|
1271
1240
|
|
|
1272
1241
|
n.sideSizeLog2[0] =
|
|
1273
1242
|
n.sideSizeLog2[1] =
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1243
|
+
n.sideSizeLog2[2] =
|
|
1244
|
+
n.sideSizeLog2[3] =
|
|
1245
|
+
Math.log2(p.terrain.gridSizeByZoom[this.tileZoom] || p.terrain.plainGridSize);
|
|
1277
1246
|
|
|
1278
1247
|
if (this.tileZoom <= p.terrain.maxZoom) {
|
|
1279
1248
|
var nmc = this.planet._normalMapCreator;
|
|
@@ -1443,7 +1412,7 @@ class Segment {
|
|
|
1443
1412
|
p = this.planet;
|
|
1444
1413
|
|
|
1445
1414
|
var currHeight, li;
|
|
1446
|
-
if (layerSlice) {
|
|
1415
|
+
if (layerSlice && layerSlice.length) {
|
|
1447
1416
|
li = layerSlice[0];
|
|
1448
1417
|
currHeight = li._height;
|
|
1449
1418
|
} else {
|
|
@@ -1549,7 +1518,7 @@ class Segment {
|
|
|
1549
1518
|
p = this.planet;
|
|
1550
1519
|
|
|
1551
1520
|
var currHeight;
|
|
1552
|
-
if (layerSlice) {
|
|
1521
|
+
if (layerSlice && layerSlice.length) {
|
|
1553
1522
|
currHeight = layerSlice[0]._height;
|
|
1554
1523
|
} else {
|
|
1555
1524
|
currHeight = 0;
|
|
@@ -1576,7 +1545,7 @@ class Segment {
|
|
|
1576
1545
|
p = this.planet;
|
|
1577
1546
|
|
|
1578
1547
|
var currHeight;
|
|
1579
|
-
if (layerSlice) {
|
|
1548
|
+
if (layerSlice && layerSlice.length) {
|
|
1580
1549
|
currHeight = layerSlice[0]._height;
|
|
1581
1550
|
} else {
|
|
1582
1551
|
currHeight = 0;
|
|
@@ -1640,7 +1609,7 @@ class Segment {
|
|
|
1640
1609
|
shu = sh.uniforms;
|
|
1641
1610
|
|
|
1642
1611
|
var currHeight;
|
|
1643
|
-
if (layerSlice) {
|
|
1612
|
+
if (layerSlice.length) {
|
|
1644
1613
|
currHeight = layerSlice[0]._height;
|
|
1645
1614
|
} else {
|
|
1646
1615
|
currHeight = 0;
|
|
@@ -1717,4 +1686,5 @@ class Segment {
|
|
|
1717
1686
|
return -1;
|
|
1718
1687
|
}
|
|
1719
1688
|
}
|
|
1689
|
+
|
|
1720
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) \
|