@openglobus/og 0.12.0 → 0.12.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/package.json +10 -10
- package/src/og/layer/CanvasTiles.js +8 -11
- package/src/og/layer/XYZ.js +8 -8
- package/src/og/quadTree/Node.js +2 -2
- package/src/og/scene/Planet.js +41 -8
- package/src/og/segment/Segment.js +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "[OpenGlobus](http://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"example": "./sandbox"
|
|
@@ -43,24 +43,24 @@
|
|
|
43
43
|
"./css/og.css": "./css/og.css"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@babel/preset-env": "^7.16.
|
|
46
|
+
"@babel/preset-env": "^7.16.8",
|
|
47
47
|
"@rollup/plugin-json": "^4.1.0",
|
|
48
|
-
"@types/jest": "^27.0
|
|
49
|
-
"eslint": "^8.
|
|
48
|
+
"@types/jest": "^27.4.0",
|
|
49
|
+
"eslint": "^8.6.0",
|
|
50
50
|
"jaguarjs-jsdoc": "^1.1.0",
|
|
51
|
-
"jest": "^27.
|
|
51
|
+
"jest": "^27.4.7",
|
|
52
52
|
"jest-canvas-mock": "^2.3.1",
|
|
53
53
|
"jest-webgl-canvas-mock": "^0.2.3",
|
|
54
54
|
"jsdoc": "^3.6.7",
|
|
55
|
-
"lint-staged": "^12.1.
|
|
55
|
+
"lint-staged": "^12.1.7",
|
|
56
56
|
"local-web-server": "^5.1.1",
|
|
57
57
|
"msdf-bmfont-xml": "^2.5.4",
|
|
58
|
-
"postcss": "^8.4.
|
|
59
|
-
"prettier": "^2.5.
|
|
60
|
-
"rollup": "^2.
|
|
58
|
+
"postcss": "^8.4.5",
|
|
59
|
+
"prettier": "^2.5.1",
|
|
60
|
+
"rollup": "^2.63.0",
|
|
61
61
|
"rollup-plugin-postcss": "^4.0.2",
|
|
62
62
|
"rollup-plugin-terser": "^7.0.2",
|
|
63
|
-
"typescript": "^4.5.
|
|
63
|
+
"typescript": "^4.5.4"
|
|
64
64
|
},
|
|
65
65
|
"lint-staged": {
|
|
66
66
|
"*.{js,ts}": [
|
|
@@ -98,17 +98,14 @@ class CanvasTiles extends Layer {
|
|
|
98
98
|
* @public
|
|
99
99
|
* @param {boolean} visibility - Layer visibility.
|
|
100
100
|
*/
|
|
101
|
-
setVisibility(visibility) {
|
|
101
|
+
setVisibility(visibility) {
|
|
102
102
|
if (visibility !== this._visibility) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
} else if (!visibility) {
|
|
103
|
+
super.setVisibility(visibility);
|
|
104
|
+
|
|
105
|
+
if (!visibility) {
|
|
107
106
|
this.abortLoading();
|
|
108
107
|
}
|
|
109
|
-
|
|
110
|
-
this.events.dispatch(this.events.visibilitychange, this);
|
|
111
|
-
}
|
|
108
|
+
}
|
|
112
109
|
}
|
|
113
110
|
|
|
114
111
|
/**
|
|
@@ -128,7 +125,7 @@ class CanvasTiles extends Layer {
|
|
|
128
125
|
material.texture = seg.planet.transparentTexture;
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
if (this._planet.layerLock.isFree()) {
|
|
128
|
+
if (this._planet.layerLock.isFree() || material.segment.tileZoom < 2) {
|
|
132
129
|
material.isReady = false;
|
|
133
130
|
material.isLoading = true;
|
|
134
131
|
if (CanvasTiles.__requestsCounter >= CanvasTiles.MAX_REQUESTS && this._counter) {
|
|
@@ -240,12 +237,12 @@ class CanvasTiles extends Layer {
|
|
|
240
237
|
var mId = this._id;
|
|
241
238
|
var psegm = material;
|
|
242
239
|
while (pn.parentNode) {
|
|
240
|
+
pn = pn.parentNode;
|
|
241
|
+
psegm = pn.segment.materials[mId];
|
|
243
242
|
if (psegm && psegm.isReady) {
|
|
244
243
|
notEmpty = true;
|
|
245
244
|
break;
|
|
246
245
|
}
|
|
247
|
-
pn = pn.parentNode;
|
|
248
|
-
psegm = pn.segment.materials[mId];
|
|
249
246
|
}
|
|
250
247
|
|
|
251
248
|
if (notEmpty) {
|
package/src/og/layer/XYZ.js
CHANGED
|
@@ -151,8 +151,9 @@ class XYZ extends Layer {
|
|
|
151
151
|
} else {
|
|
152
152
|
material.texture = seg.planet.transparentTexture;
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
|
|
155
|
+
// Q: Maybe we should change "<2" to material.segment.tileZoom < (material.layer.minZoom + 1)
|
|
156
|
+
if (this._planet.layerLock.isFree() || material.segment.tileZoom < 2) {
|
|
156
157
|
material.isReady = false;
|
|
157
158
|
material.isLoading = true;
|
|
158
159
|
|
|
@@ -245,17 +246,16 @@ class XYZ extends Layer {
|
|
|
245
246
|
let mId = this._id;
|
|
246
247
|
let psegm = material;
|
|
247
248
|
while (pn.parentNode) {
|
|
249
|
+
pn = pn.parentNode;
|
|
250
|
+
psegm = pn.segment.materials[mId];
|
|
248
251
|
if (psegm && psegm.textureExists) {
|
|
249
252
|
notEmpty = true;
|
|
250
253
|
break;
|
|
251
254
|
}
|
|
252
|
-
pn = pn.parentNode;
|
|
253
|
-
psegm = pn.segment.materials[mId];
|
|
254
255
|
}
|
|
255
|
-
|
|
256
|
-
let maxNativeZoom = material.layer.maxNativeZoom;
|
|
257
256
|
|
|
258
|
-
if (segment.
|
|
257
|
+
if (segment.passReady) {
|
|
258
|
+
let maxNativeZoom = material.layer.maxNativeZoom;
|
|
259
259
|
if (pn.segment.tileZoom === maxNativeZoom) {
|
|
260
260
|
material.textureNotExists();
|
|
261
261
|
} else if (material.segment.tileZoom <= maxNativeZoom) {
|
|
@@ -312,7 +312,7 @@ class XYZ extends Layer {
|
|
|
312
312
|
|
|
313
313
|
material.isReady = false;
|
|
314
314
|
material.textureExists = false;
|
|
315
|
-
material.isLoading = false;
|
|
315
|
+
material.isLoading = false;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
/**
|
package/src/og/quadTree/Node.js
CHANGED
|
@@ -275,7 +275,7 @@ class Node {
|
|
|
275
275
|
maxZoom && ((seg.tileZoom === maxZoom) || !altVis))) {
|
|
276
276
|
|
|
277
277
|
if (altVis) {
|
|
278
|
-
seg.
|
|
278
|
+
seg.passReady = true;
|
|
279
279
|
this.renderNode(this.inFrustum, !this.inFrustum, terrainReadySegment, stopLoading);
|
|
280
280
|
} else {
|
|
281
281
|
this.state = NOTRENDERING;
|
|
@@ -287,7 +287,7 @@ class Node {
|
|
|
287
287
|
(!maxZoom || maxZoom && cam.projectedSize(seg.bsphere.center, seg.bsphere.radius) > this.planet._maxLodSize)) {
|
|
288
288
|
this.traverseNodes(cam, maxZoom, seg, stopLoading);
|
|
289
289
|
} else if (altVis) {
|
|
290
|
-
seg.
|
|
290
|
+
seg.passReady = maxZoom ? seg.terrainReady : false;
|
|
291
291
|
this.renderNode(this.inFrustum, !this.inFrustum, terrainReadySegment, stopLoading);
|
|
292
292
|
} else {
|
|
293
293
|
this.state = NOTRENDERING;
|
package/src/og/scene/Planet.js
CHANGED
|
@@ -815,35 +815,65 @@ export class Planet extends RenderNode {
|
|
|
815
815
|
}
|
|
816
816
|
|
|
817
817
|
_preRender() {
|
|
818
|
+
// Zoom 0
|
|
818
819
|
this._quadTree.createChildrenNodes();
|
|
819
|
-
this._quadTree.segment.createPlainSegment();
|
|
820
|
+
this._quadTree.segment.createPlainSegment();
|
|
821
|
+
|
|
822
|
+
// Zoom 1
|
|
823
|
+
for (let i = 0; i < this._quadTree.nodes.length; i++) {
|
|
824
|
+
this._quadTree.nodes[i].segment.createPlainSegment();
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// same for poles
|
|
828
|
+
this._quadTreeNorth.createChildrenNodes();
|
|
829
|
+
this._quadTreeNorth.segment.createPlainSegment();
|
|
830
|
+
|
|
831
|
+
for (let i = 0; i < this._quadTreeNorth.nodes.length; i++) {
|
|
832
|
+
this._quadTreeNorth.nodes[i].segment.createPlainSegment();
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
this._quadTreeSouth.createChildrenNodes();
|
|
836
|
+
this._quadTreeSouth.segment.createPlainSegment();
|
|
837
|
+
|
|
838
|
+
for (let i = 0; i < this._quadTreeSouth.nodes.length; i++) {
|
|
839
|
+
this._quadTreeSouth.nodes[i].segment.createPlainSegment();
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
this._preLoad();
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
_preLoad() {
|
|
846
|
+
this._skipPreRender = false;
|
|
847
|
+
|
|
848
|
+
// Zoom 0
|
|
849
|
+
this._quadTree.segment.passReady = true;
|
|
820
850
|
this._quadTree.renderNode(true);
|
|
821
851
|
this._normalMapCreator.drawSingle(this._quadTree.segment);
|
|
822
852
|
|
|
853
|
+
// Zoom 1
|
|
823
854
|
for (let i = 0; i < this._quadTree.nodes.length; i++) {
|
|
824
|
-
this._quadTree.nodes[i].segment.
|
|
855
|
+
this._quadTree.nodes[i].segment.passReady = true;
|
|
825
856
|
this._quadTree.nodes[i].renderNode(true);
|
|
826
857
|
this._normalMapCreator.drawSingle(this._quadTree.nodes[i].segment);
|
|
827
858
|
}
|
|
828
859
|
|
|
829
|
-
|
|
830
|
-
this._quadTreeNorth.segment.
|
|
860
|
+
// Same for poles
|
|
861
|
+
this._quadTreeNorth.segment.passReady = true;
|
|
831
862
|
this._quadTreeNorth.renderNode(true);
|
|
832
863
|
this._normalMapCreator.drawSingle(this._quadTreeNorth.segment);
|
|
833
864
|
|
|
834
865
|
for (let i = 0; i < this._quadTreeNorth.nodes.length; i++) {
|
|
835
|
-
this._quadTreeNorth.nodes[i].segment.
|
|
866
|
+
this._quadTreeNorth.nodes[i].segment.passReady = true;
|
|
836
867
|
this._quadTreeNorth.nodes[i].renderNode(true);
|
|
837
868
|
this._normalMapCreator.drawSingle(this._quadTreeNorth.nodes[i].segment);
|
|
838
869
|
}
|
|
839
870
|
|
|
840
|
-
this._quadTreeSouth.
|
|
841
|
-
this._quadTreeSouth.segment.createPlainSegment();
|
|
871
|
+
this._quadTreeSouth.segment.passReady = true;
|
|
842
872
|
this._quadTreeSouth.renderNode(true);
|
|
843
873
|
this._normalMapCreator.drawSingle(this._quadTreeSouth.segment);
|
|
844
874
|
|
|
845
875
|
for (let i = 0; i < this._quadTreeSouth.nodes.length; i++) {
|
|
846
|
-
this._quadTreeSouth.nodes[i].segment.
|
|
876
|
+
this._quadTreeSouth.nodes[i].segment.passReady = true;
|
|
847
877
|
this._quadTreeSouth.nodes[i].renderNode(true);
|
|
848
878
|
this._normalMapCreator.drawSingle(this._quadTreeSouth.nodes[i].segment);
|
|
849
879
|
}
|
|
@@ -924,6 +954,9 @@ export class Planet extends RenderNode {
|
|
|
924
954
|
if (li._attribution.length) {
|
|
925
955
|
html += "<li>" + li._attribution + "</li>";
|
|
926
956
|
}
|
|
957
|
+
|
|
958
|
+
this._preLoad();
|
|
959
|
+
|
|
927
960
|
} else if (li._fading && li._fadingOpacity > 0) {
|
|
928
961
|
if (li.hasImageryTiles()) {
|
|
929
962
|
this.visibleTileLayers.push(li);
|
|
@@ -199,6 +199,12 @@ class Segment {
|
|
|
199
199
|
*/
|
|
200
200
|
this.terrainExists = false;
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Means that tree passage reach the segment, and the segment terrain is ready.
|
|
204
|
+
* @type {boolean}
|
|
205
|
+
*/
|
|
206
|
+
this.passReady = false;
|
|
207
|
+
|
|
202
208
|
this.plainVertices = null;
|
|
203
209
|
this.plainVerticesHigh = null;
|
|
204
210
|
this.plainVerticesLow = null;
|