@openglobus/og 0.15.4 → 0.16.0
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 +4 -8
- package/css/og.css +1 -1
- 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 +13 -14
- package/src/og/Globe.js +5 -2
- package/src/og/LonLat.js +224 -193
- package/src/og/Object3d.js +21 -2
- package/src/og/bv/index.js +2 -2
- package/src/og/camera/Camera.js +4 -16
- package/src/og/camera/PlanetCamera.js +15 -15
- package/src/og/control/KeyboardNavigation.js +153 -169
- package/src/og/control/MouseNavigation.js +0 -20
- package/src/og/control/RulerSwitcher.js +2 -2
- package/src/og/control/SimpleNavigation.js +10 -10
- package/src/og/control/ZoomControl.js +2 -2
- package/src/og/control/heightRuler/HeightRulerScene.js +6 -2
- package/src/og/control/index.js +5 -2
- package/src/og/control/ruler/RulerScene.js +11 -8
- package/src/og/control/timeline/TimelineControl.js +5 -3
- package/src/og/control/timeline/TimelineModel.js +4 -0
- package/src/og/control/timeline/TimelineView.js +10 -3
- package/src/og/control/visibleExtent/Segment.js +36 -42
- package/src/og/ellipsoid/Ellipsoid.js +41 -11
- package/src/og/entity/Entity.js +3 -3
- package/src/og/entity/EntityCollection.js +2 -2
- package/src/og/entity/Label.js +1 -1
- package/src/og/entity/Polyline.js +4 -2
- package/src/og/index.js +4 -7
- package/src/og/layer/CanvasTiles.js +70 -23
- package/src/og/layer/GeoImage.js +40 -18
- package/src/og/layer/Vector.js +21 -17
- package/src/og/layer/WMS.js +2 -2
- package/src/og/layer/XYZ.js +2 -2
- package/src/og/math.js +2 -1
- package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +26 -0
- package/src/og/quadTree/EntityCollectionNode.js +8 -2
- package/src/og/quadTree/Node.js +44 -50
- package/src/og/quadTree/index.js +2 -0
- package/src/og/renderer/Renderer.js +14 -1
- package/src/og/scene/Planet.js +12 -8
- package/src/og/scene/index.js +3 -3
- package/src/og/segment/Segment.js +125 -120
- package/src/og/terrain/EmptyTerrain.js +19 -7
- package/src/og/terrain/GlobusTerrain.js +23 -18
- package/src/og/terrain/MapboxTerrain.js +7 -8
- package/src/og/terrain/index.js +4 -4
- package/src/og/utils/objParser.js +227 -0
- package/src/og/utils/shared.js +9 -0
- package/src/og/webgl/Handler.js +1 -3
- package/types/Globe.d.ts +2 -0
- package/types/LonLat.d.ts +20 -1
- package/types/Object3d.d.ts +2 -0
- package/types/Popup.d.ts +1 -1
- package/types/bv/index.d.ts +2 -2
- package/types/camera/PlanetCamera.d.ts +1 -8
- package/types/camera/index.d.ts +2 -2
- package/types/control/GeoImageDragControl.d.ts +1 -1
- package/types/control/LayerAnimation.d.ts +1 -1
- package/types/control/Lighting.d.ts +2 -2
- package/types/control/heightRuler/HeightRulerScene.d.ts +1 -1
- package/types/control/index.d.ts +3 -2
- package/types/control/ruler/RulerScene.d.ts +5 -4
- package/types/control/selection/SelectionScene.d.ts +3 -3
- package/types/control/timeline/TimelineControl.d.ts +10 -0
- package/types/control/timeline/TimelineModel.d.ts +33 -0
- package/types/control/timeline/TimelineView.d.ts +57 -0
- package/types/control/timeline/timelineUtils.d.ts +9 -0
- package/types/ellipsoid/Ellipsoid.d.ts +27 -8
- package/types/ellipsoid/index.d.ts +2 -2
- package/types/entity/Entity.d.ts +3 -3
- package/types/entity/EntityCollection.d.ts +2 -2
- package/types/entity/Label.d.ts +1 -1
- package/types/entity/Polyline.d.ts +1 -0
- package/types/index.d.ts +45 -46
- package/types/layer/CanvasTiles.d.ts +2 -1
- package/types/layer/GeoImage.d.ts +7 -1
- package/types/layer/GeoTexture2d.d.ts +1 -1
- package/types/layer/Vector.d.ts +3 -3
- package/types/layer/XYZ.d.ts +1 -1
- package/types/layer/index.d.ts +9 -9
- package/types/math/Line2.d.ts +1 -1
- package/types/math/Line3.d.ts +1 -1
- package/types/math/index.d.ts +10 -10
- package/types/mercator.d.ts +1 -1
- package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +3 -0
- package/types/quadTree/EntityCollectionNode.d.ts +1 -1
- package/types/quadTree/index.d.ts +2 -0
- package/types/renderer/Renderer.d.ts +2 -2
- package/types/scene/Axes.d.ts +1 -1
- package/types/scene/SkyBox.d.ts +1 -1
- package/types/scene/index.d.ts +3 -3
- package/types/segment/Segment.d.ts +11 -14
- package/types/shaders/atmos.d.ts +1 -1
- package/types/shaders/billboard.d.ts +1 -1
- package/types/shaders/depth.d.ts +1 -1
- package/types/shaders/label.d.ts +1 -1
- package/types/shaders/pickingMask.d.ts +1 -1
- package/types/shaders/pointCloud.d.ts +1 -1
- package/types/shaders/polyline.d.ts +1 -1
- package/types/shaders/ray.d.ts +1 -1
- package/types/shaders/screenFrame.d.ts +1 -1
- package/types/shaders/skybox.d.ts +1 -1
- package/types/shaders/toneMapping.d.ts +1 -1
- package/types/terrain/BilTerrain.d.ts +1 -0
- package/types/terrain/EmptyTerrain.d.ts +13 -2
- package/types/terrain/GlobusTerrain.d.ts +2 -1
- package/types/terrain/MapboxTerrain.d.ts +1 -3
- package/types/terrain/index.d.ts +4 -4
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/ButtonGroup.d.ts +12 -0
- package/types/ui/Dialog.d.ts +2 -2
- package/types/ui/Slider.d.ts +1 -1
- package/types/ui/ToggleButton.d.ts +1 -1
- package/types/ui/View.d.ts +1 -1
- package/types/utils/GeoImageCreator.d.ts +2 -2
- package/types/utils/ImagesCacheManager.d.ts +1 -1
- package/types/utils/Loader.d.ts +1 -1
- package/types/utils/VectorTileCreator.d.ts +1 -1
- package/types/utils/objParser.d.ts +8 -0
- package/types/utils/shared.d.ts +6 -0
- package/types/webgl/Handler.d.ts +2 -2
- package/src/og/index.core.js +0 -116
- package/src/og/index.webgl.js +0 -17
- package/types/index.core.d.ts +0 -65
- package/types/index.webgl.d.ts +0 -7
package/src/og/layer/GeoImage.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { nextHighestPowerOfTwo } from "../math.js";
|
|
8
8
|
import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
9
|
+
import { isImageLoaded } from "../utils/shared.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Used to load and display a single image over specific corner coordinates on the globe, implements og.layer.BaseGeoImage interface.
|
|
@@ -48,6 +49,11 @@ class GeoImage extends BaseGeoImage {
|
|
|
48
49
|
this._planet && this._planet._geoImageCreator.remove(this);
|
|
49
50
|
this._src = src;
|
|
50
51
|
this._sourceReady = false;
|
|
52
|
+
this._sourceCreated = false;
|
|
53
|
+
this._image = new Image();
|
|
54
|
+
this._onLoad_ = this._onLoad.bind(this);
|
|
55
|
+
this._image.addEventListener("load", this._onLoad_);
|
|
56
|
+
this._image.src = src;
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
/**
|
|
@@ -57,9 +63,16 @@ class GeoImage extends BaseGeoImage {
|
|
|
57
63
|
*/
|
|
58
64
|
setImage(image) {
|
|
59
65
|
this._planet && this._planet._geoImageCreator.remove(this);
|
|
66
|
+
this._sourceCreated = false;
|
|
67
|
+
this._sourceReady = false;
|
|
60
68
|
this._image = image;
|
|
61
69
|
this._src = image.src;
|
|
62
|
-
this.
|
|
70
|
+
if (isImageLoaded(this._image)) {
|
|
71
|
+
this._applyImage(this._image);
|
|
72
|
+
} else {
|
|
73
|
+
this._onLoad_ = this._onLoad.bind(this);
|
|
74
|
+
this._image.addEventListener("load", this._onLoad_);
|
|
75
|
+
}
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
/**
|
|
@@ -76,15 +89,28 @@ class GeoImage extends BaseGeoImage {
|
|
|
76
89
|
|
|
77
90
|
/**
|
|
78
91
|
* @private
|
|
79
|
-
* @param {Image} img
|
|
92
|
+
* @param {Image} [img]
|
|
93
|
+
*/
|
|
94
|
+
_onLoad() {
|
|
95
|
+
this._applyImage(this._image);
|
|
96
|
+
this._image.removeEventListener("load", this._onLoad_);
|
|
97
|
+
this._onLoad_ = undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @private
|
|
102
|
+
* @param {Image} [img]
|
|
80
103
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
_applyImage(img) {
|
|
105
|
+
if (img) {
|
|
106
|
+
this._frameWidth = nextHighestPowerOfTwo(img.width * 2, 4096);
|
|
107
|
+
this._frameHeight = nextHighestPowerOfTwo(img.height * 3, 4096);
|
|
108
|
+
this._sourceReady = true;
|
|
109
|
+
this._planet._geoImageCreator.add(this);
|
|
110
|
+
}
|
|
86
111
|
}
|
|
87
112
|
|
|
113
|
+
|
|
88
114
|
/**
|
|
89
115
|
* Loads planet segment material. In this case - GeoImage source image.
|
|
90
116
|
* @virtual
|
|
@@ -96,20 +122,16 @@ class GeoImage extends BaseGeoImage {
|
|
|
96
122
|
this._creationProceeding = true;
|
|
97
123
|
if (!this._sourceReady && this._src) {
|
|
98
124
|
if (this._image) {
|
|
99
|
-
if (this._image
|
|
100
|
-
this.
|
|
101
|
-
} else
|
|
102
|
-
|
|
103
|
-
this._image.addEventListener("load",
|
|
104
|
-
that._onLoad(this);
|
|
105
|
-
});
|
|
125
|
+
if (isImageLoaded(this._image)) {
|
|
126
|
+
this._applyImage(this._image);
|
|
127
|
+
} else {
|
|
128
|
+
this._onLoad_ = this._onLoad.bind(this);
|
|
129
|
+
this._image.addEventListener("load", this._onLoad_);
|
|
106
130
|
}
|
|
107
131
|
} else {
|
|
108
|
-
let that = this;
|
|
109
132
|
this._image = new Image();
|
|
110
|
-
this.
|
|
111
|
-
|
|
112
|
-
});
|
|
133
|
+
this._onLoad_ = this._onLoad.bind(this);
|
|
134
|
+
this._image.addEventListener("load", this._onLoad_);
|
|
113
135
|
this._image.src = this._src;
|
|
114
136
|
}
|
|
115
137
|
} else {
|
package/src/og/layer/Vector.js
CHANGED
|
@@ -239,7 +239,7 @@ class Vector extends Layer {
|
|
|
239
239
|
* Adds entity to the layer.
|
|
240
240
|
* @public
|
|
241
241
|
* @param {Entity} entity - Entity.
|
|
242
|
-
* @param {boolean} [rightNow] - Entity insertion option. False is
|
|
242
|
+
* @param {boolean} [rightNow] - Entity insertion option. False is default.
|
|
243
243
|
* @returns {layer.Vector} - Returns this layer.
|
|
244
244
|
*/
|
|
245
245
|
add(entity, rightNow) {
|
|
@@ -258,7 +258,7 @@ class Vector extends Layer {
|
|
|
258
258
|
* @public
|
|
259
259
|
* @param {Entity} entity - Entity.
|
|
260
260
|
* @param {Number} index - Index position.
|
|
261
|
-
* @param {boolean} [rightNow] - Entity insertion option. False is
|
|
261
|
+
* @param {boolean} [rightNow] - Entity insertion option. False is default.
|
|
262
262
|
* @returns {layer.Vector} - Returns this layer.
|
|
263
263
|
*/
|
|
264
264
|
insert(entity, index, rightNow) {
|
|
@@ -336,7 +336,7 @@ class Vector extends Layer {
|
|
|
336
336
|
* Adds entity array to the layer.
|
|
337
337
|
* @public
|
|
338
338
|
* @param {Array.<Entity>} entities - Entities array.
|
|
339
|
-
* @param {boolean} [rightNow] - Entity insertion option. False is
|
|
339
|
+
* @param {boolean} [rightNow] - Entity insertion option. False is default.
|
|
340
340
|
* @returns {layer.Vector} - Returns this layer.
|
|
341
341
|
*/
|
|
342
342
|
addEntities(entities, rightNow) {
|
|
@@ -757,12 +757,13 @@ class Vector extends Layer {
|
|
|
757
757
|
if (seg._extent.isInside(ll)) {
|
|
758
758
|
let cart = p._path3v[c_j][c_j_h];
|
|
759
759
|
seg.getTerrainPoint(cart, ll, res);
|
|
760
|
-
p.
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
c_j,
|
|
764
|
-
|
|
765
|
-
|
|
760
|
+
let alt = (rtg && p.altitude) || 0.0;
|
|
761
|
+
if (alt) {
|
|
762
|
+
let n = this._planet.ellipsoid.getSurfaceNormal3v(res);
|
|
763
|
+
p.setPoint3v(res.addA(n.scale(alt)), c_j_h, c_j, true);
|
|
764
|
+
} else {
|
|
765
|
+
p.setPoint3v(res, c_j_h, c_j, true);
|
|
766
|
+
}
|
|
766
767
|
break;
|
|
767
768
|
}
|
|
768
769
|
}
|
|
@@ -843,7 +844,8 @@ class Vector extends Layer {
|
|
|
843
844
|
|
|
844
845
|
// Merc nodes
|
|
845
846
|
this._secondPASS = [];
|
|
846
|
-
this._entityCollectionsTree
|
|
847
|
+
this._entityCollectionsTree &&
|
|
848
|
+
this._entityCollectionsTree.collectRenderCollectionsPASS1(p._visibleNodes, outArr);
|
|
847
849
|
var i = this._secondPASS.length;
|
|
848
850
|
while (i--) {
|
|
849
851
|
this._secondPASS[i].collectRenderCollectionsPASS2(
|
|
@@ -855,9 +857,10 @@ class Vector extends Layer {
|
|
|
855
857
|
|
|
856
858
|
// North nodes
|
|
857
859
|
this._secondPASS = [];
|
|
858
|
-
this._entityCollectionsTreeNorth
|
|
859
|
-
|
|
860
|
-
|
|
860
|
+
this._entityCollectionsTreeNorth &&
|
|
861
|
+
this._entityCollectionsTreeNorth.collectRenderCollectionsPASS1(
|
|
862
|
+
p._visibleNodesNorth,
|
|
863
|
+
outArr
|
|
861
864
|
);
|
|
862
865
|
i = this._secondPASS.length;
|
|
863
866
|
while (i--) {
|
|
@@ -870,10 +873,11 @@ class Vector extends Layer {
|
|
|
870
873
|
|
|
871
874
|
// South nodes
|
|
872
875
|
this._secondPASS = [];
|
|
873
|
-
this._entityCollectionsTreeSouth
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
876
|
+
this._entityCollectionsTreeSouth &&
|
|
877
|
+
this._entityCollectionsTreeSouth.collectRenderCollectionsPASS1(
|
|
878
|
+
p._visibleNodesSouth,
|
|
879
|
+
outArr
|
|
880
|
+
);
|
|
877
881
|
i = this._secondPASS.length;
|
|
878
882
|
while (i--) {
|
|
879
883
|
this._secondPASS[i].collectRenderCollectionsPASS2(
|
package/src/og/layer/WMS.js
CHANGED
|
@@ -97,8 +97,8 @@ class WMS extends XYZ {
|
|
|
97
97
|
extra
|
|
98
98
|
|
|
99
99
|
) {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
return `${url}/?LAYERS=${layers}&FORMAT=${format}&SERVICE=WMS&VERSION=${version}&REQUEST=${request}&SRS=${srs}&BBOX=${bbox}&WIDTH=${width}&HEIGHT=${height}` +
|
|
101
|
+
(extra ? `&${extra}` : "");
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
static get_bbox_v1_1_1(extent) {
|
package/src/og/layer/XYZ.js
CHANGED
|
@@ -44,7 +44,7 @@ class XYZ extends Layer {
|
|
|
44
44
|
* @param {string} name - Layer name.
|
|
45
45
|
* @param {*} options
|
|
46
46
|
*/
|
|
47
|
-
constructor(name, options) {
|
|
47
|
+
constructor(name, options = {}) {
|
|
48
48
|
super(name, options);
|
|
49
49
|
|
|
50
50
|
this.events.registerNames(EVENT_NAMES);
|
|
@@ -316,7 +316,7 @@ class XYZ extends Layer {
|
|
|
316
316
|
clearMaterial(material) {
|
|
317
317
|
if (material.isReady && material.textureExists) {
|
|
318
318
|
!material.texture.default &&
|
|
319
|
-
|
|
319
|
+
material.segment.handler.gl.deleteTexture(material.texture);
|
|
320
320
|
material.texture = null;
|
|
321
321
|
|
|
322
322
|
if (material.image) {
|
package/src/og/math.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { Extent } from "../Extent.js";
|
|
3
|
+
import { EPSG4326 } from "../proj/EPSG4326.js";
|
|
4
|
+
import { Node } from "../quadTree/Node.js";
|
|
5
|
+
import * as quadTree from "../quadTree/quadTree.js";
|
|
6
|
+
import { SegmentLonLatWgs84 } from "../segment/SegmentLonLatWgs84.js";
|
|
7
|
+
import { QuadTreeStrategy } from "./QuadTreeStrategy.js";
|
|
8
|
+
|
|
9
|
+
export class EPSG4326QuadTreeStrategy extends QuadTreeStrategy {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.name = "EPSG4326";
|
|
13
|
+
this.projection = EPSG4326;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
init() {
|
|
17
|
+
let earthQuadTreeSouth = new Node(SegmentLonLatWgs84, this.planet, quadTree.NW, null, 0, 0,
|
|
18
|
+
Extent.createFromArray([-180, -90, 0, 90])
|
|
19
|
+
);
|
|
20
|
+
let earthQuadTreeWest = new Node(SegmentLonLatWgs84, this.planet, quadTree.NW, null, 0, 0,
|
|
21
|
+
Extent.createFromArray([0, -90, 180, 90])
|
|
22
|
+
);
|
|
23
|
+
this._quadTreeList.push(earthQuadTreeSouth);
|
|
24
|
+
this._quadTreeList.push(earthQuadTreeWest);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -282,9 +282,15 @@ class EntityCollectionNode {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
alignEntityToTheGround(entity, segment) {
|
|
285
|
-
|
|
285
|
+
let res = new Vec3();
|
|
286
286
|
segment.getEntityTerrainPoint(entity, res);
|
|
287
|
-
|
|
287
|
+
let alt = (Number(this.layer.relativeToGround) && entity._altitude) || 0.0;
|
|
288
|
+
if (alt) {
|
|
289
|
+
let n = this.layer._planet.ellipsoid.getSurfaceNormal3v(res);
|
|
290
|
+
entity._setCartesian3vSilent(res.addA(n.scale(alt)));
|
|
291
|
+
} else {
|
|
292
|
+
entity._setCartesian3vSilent(res);
|
|
293
|
+
}
|
|
288
294
|
}
|
|
289
295
|
|
|
290
296
|
isVisible() {
|
package/src/og/quadTree/Node.js
CHANGED
|
@@ -177,26 +177,21 @@ class Node {
|
|
|
177
177
|
this.neighbors[2] = [];
|
|
178
178
|
this.neighbors[3] = [];
|
|
179
179
|
|
|
180
|
-
let seg = this.segment,
|
|
180
|
+
let seg = this.segment,
|
|
181
|
+
planet = this.planet;
|
|
181
182
|
|
|
182
183
|
this._cameraInside = false;
|
|
183
184
|
|
|
184
|
-
let insideLonLat = null;
|
|
185
|
-
|
|
186
185
|
// Search a node which the camera is flying over.
|
|
187
186
|
if (!this.parentNode || this.parentNode._cameraInside) {
|
|
188
187
|
let inside;
|
|
189
188
|
if (Math.abs(cam._lonLat.lat) <= MAX_LAT && seg._projection.id === EPSG3857.id) {
|
|
190
189
|
inside = seg._extent.isInside(cam._lonLatMerc);
|
|
191
|
-
insideLonLat = cam._lonLatMerc;
|
|
192
190
|
} else if (seg._projection.id === EPSG4326.id) {
|
|
193
191
|
inside = seg._extent.isInside(cam._lonLat);
|
|
194
|
-
insideLonLat = cam._lonLat;
|
|
195
192
|
}
|
|
196
193
|
|
|
197
194
|
if (inside) {
|
|
198
|
-
cam._insideSegmentPosition.lon = insideLonLat.lon;
|
|
199
|
-
cam._insideSegmentPosition.lat = insideLonLat.lat;
|
|
200
195
|
cam._insideSegment = seg;
|
|
201
196
|
this._cameraInside = true;
|
|
202
197
|
}
|
|
@@ -247,7 +242,7 @@ class Node {
|
|
|
247
242
|
seg._collectVisibleNodes();
|
|
248
243
|
}
|
|
249
244
|
|
|
250
|
-
if (seg.tileZoom < 2
|
|
245
|
+
if (seg.tileZoom < 2) {
|
|
251
246
|
this.traverseNodes(cam, maxZoom, terrainReadySegment, stopLoading);
|
|
252
247
|
} else if (seg.terrainReady && (!maxZoom && cam.projectedSize(seg.bsphere.center, seg._plainRadius) < planet._lodSize || maxZoom && ((seg.tileZoom === maxZoom) || !altVis))) {
|
|
253
248
|
|
|
@@ -285,7 +280,7 @@ class Node {
|
|
|
285
280
|
}
|
|
286
281
|
|
|
287
282
|
renderNode(inFrustum, onlyTerrain, terrainReadySegment, stopLoading) {
|
|
288
|
-
|
|
283
|
+
let seg = this.segment;
|
|
289
284
|
|
|
290
285
|
// Create and load terrain data
|
|
291
286
|
if (!seg.terrainReady) {
|
|
@@ -305,7 +300,7 @@ class Node {
|
|
|
305
300
|
}
|
|
306
301
|
|
|
307
302
|
// Create normal map texture
|
|
308
|
-
if (seg.planet.lightEnabled && !seg.normalMapReady
|
|
303
|
+
if (seg.planet.lightEnabled && !seg.normalMapReady) {
|
|
309
304
|
this.whileNormalMapCreating();
|
|
310
305
|
}
|
|
311
306
|
|
|
@@ -487,36 +482,28 @@ class Node {
|
|
|
487
482
|
}
|
|
488
483
|
|
|
489
484
|
whileNormalMapCreating() {
|
|
490
|
-
var seg = this.segment;
|
|
491
|
-
var maxZ = this.planet.terrain.maxZoom;
|
|
492
485
|
|
|
493
|
-
|
|
486
|
+
let seg = this.segment;
|
|
487
|
+
|
|
488
|
+
if (/*seg.tileZoom <= seg.planet.terrain.maxNativeZoom && */!seg.terrainIsLoading && seg.terrainExists && !seg._inTheQueue) {
|
|
494
489
|
seg.planet._normalMapCreator.queue(seg);
|
|
495
490
|
}
|
|
496
491
|
|
|
497
|
-
|
|
498
|
-
|
|
492
|
+
let pn = this;
|
|
499
493
|
while (pn.parentNode && !pn.segment.normalMapReady) {
|
|
500
494
|
pn = pn.parentNode;
|
|
501
495
|
}
|
|
502
496
|
|
|
503
|
-
|
|
497
|
+
let dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1);
|
|
504
498
|
|
|
505
499
|
seg.normalMapTexture = pn.segment.normalMapTexture;
|
|
506
500
|
seg.normalMapTextureBias[0] = seg.tileX - pn.segment.tileX * dZ2;
|
|
507
501
|
seg.normalMapTextureBias[1] = seg.tileY - pn.segment.tileY * dZ2;
|
|
508
502
|
seg.normalMapTextureBias[2] = 1.0 / dZ2;
|
|
509
|
-
|
|
510
|
-
if (seg.tileZoom > maxZ) {
|
|
511
|
-
if (pn.segment.tileZoom === maxZ) {
|
|
512
|
-
seg.parentNormalMapReady = true;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
503
|
}
|
|
516
504
|
|
|
517
505
|
whileTerrainLoading(terrainReadySegment, stopLoading) {
|
|
518
506
|
const seg = this.segment;
|
|
519
|
-
const terrain = this.planet.terrain;
|
|
520
507
|
|
|
521
508
|
let pn = this;
|
|
522
509
|
|
|
@@ -529,18 +516,23 @@ class Node {
|
|
|
529
516
|
}
|
|
530
517
|
|
|
531
518
|
if (pn.segment.terrainReady && this.appliedTerrainNodeId !== pn.nodeId) {
|
|
532
|
-
let dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1),
|
|
519
|
+
let dZ2 = 2 << (seg.tileZoom - pn.segment.tileZoom - 1),
|
|
520
|
+
offsetX = seg.tileX - pn.segment.tileX * dZ2,
|
|
533
521
|
offsetY = seg.tileY - pn.segment.tileY * dZ2;
|
|
534
522
|
|
|
535
523
|
let pseg = pn.segment;
|
|
536
524
|
|
|
537
|
-
let tempVertices,
|
|
525
|
+
let tempVertices,
|
|
526
|
+
tempVerticesHigh,
|
|
527
|
+
tempVerticesLow,
|
|
528
|
+
noDataVertices;
|
|
538
529
|
|
|
539
530
|
this.appliedTerrainNodeId = pn.nodeId;
|
|
540
531
|
this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] = this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
|
|
541
532
|
|
|
542
533
|
|
|
543
|
-
let gridSize = pn.segment.gridSize / dZ2,
|
|
534
|
+
let gridSize = pn.segment.gridSize / dZ2,
|
|
535
|
+
gridSizeExt = pn.segment.fileGridSize / dZ2;
|
|
544
536
|
|
|
545
537
|
BOUNDS.xmin = MAX;
|
|
546
538
|
BOUNDS.xmax = MIN;
|
|
@@ -562,7 +554,7 @@ class Node {
|
|
|
562
554
|
}
|
|
563
555
|
|
|
564
556
|
getMatrixSubArrayBoundsExt(pseg.terrainVertices, pseg.terrainVerticesHigh, pseg.terrainVerticesLow, pseg.noDataVertices, pseg.gridSize, gridSize * offsetY, gridSize * offsetX, gridSize, tempVertices, tempVerticesHigh, tempVerticesLow, BOUNDS, noDataVertices);
|
|
565
|
-
} else if (gridSizeExt >= 1) {
|
|
557
|
+
} else if (gridSizeExt >= 1 && pn.segment.terrainExists) {
|
|
566
558
|
seg.gridSize = gridSizeExt;
|
|
567
559
|
|
|
568
560
|
let len = (gridSizeExt + 1) * (gridSizeExt + 1) * 3;
|
|
@@ -658,9 +650,9 @@ class Node {
|
|
|
658
650
|
|
|
659
651
|
seg.setBoundingVolume(BOUNDS.xmin, BOUNDS.ymin, BOUNDS.zmin, BOUNDS.xmax, BOUNDS.ymax, BOUNDS.zmax);
|
|
660
652
|
|
|
661
|
-
if (seg.tileZoom > terrain.maxZoom) {
|
|
662
|
-
if (pn.segment.tileZoom >= terrain.maxZoom) {
|
|
663
|
-
|
|
653
|
+
if (seg.tileZoom > seg.planet.terrain.maxZoom) {
|
|
654
|
+
if (pn.segment.tileZoom >= seg.planet.terrain.maxZoom) {
|
|
655
|
+
|
|
664
656
|
seg._plainRadius = pn.segment._plainRadius / dZ2;
|
|
665
657
|
|
|
666
658
|
seg.terrainReady = true;
|
|
@@ -670,11 +662,12 @@ class Node {
|
|
|
670
662
|
seg.terrainVerticesHigh = tempVerticesHigh;
|
|
671
663
|
seg.terrainVerticesLow = tempVerticesLow;
|
|
672
664
|
|
|
665
|
+
seg.passReady = true;
|
|
666
|
+
|
|
673
667
|
this.appliedTerrainNodeId = this.nodeId;
|
|
674
668
|
this.equalizedSideWithNodeId[N] = this.equalizedSideWithNodeId[E] = this.equalizedSideWithNodeId[S] = this.equalizedSideWithNodeId[W] = this.appliedTerrainNodeId;
|
|
675
669
|
|
|
676
670
|
if (pn.segment.terrainExists) {
|
|
677
|
-
seg.terrainExists = true;
|
|
678
671
|
seg.normalMapVertices = tempVertices;
|
|
679
672
|
seg.fileGridSize = Math.sqrt(tempVertices.length / 3) - 1;
|
|
680
673
|
|
|
@@ -687,26 +680,27 @@ class Node {
|
|
|
687
680
|
seg.normalMapNormals = pseg.normalMapNormals;
|
|
688
681
|
}
|
|
689
682
|
}
|
|
690
|
-
} else {
|
|
691
|
-
pn = this;
|
|
692
|
-
while (pn.parentNode && pn.segment.tileZoom !== terrain.maxZoom) {
|
|
693
|
-
pn = pn.parentNode;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
let pns = pn.segment;
|
|
697
|
-
|
|
698
|
-
if (!pns.initialized) {
|
|
699
|
-
pns.initialize();
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
if (!pns.plainProcessing) {
|
|
703
|
-
pn.segment.createPlainSegmentAsync();
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
if (pns.plainReady && !stopLoading) {
|
|
707
|
-
pns.loadTerrain(true);
|
|
708
|
-
}
|
|
709
683
|
}
|
|
684
|
+
// else {
|
|
685
|
+
// pn = this;
|
|
686
|
+
// while (pn.parentNode && pn.segment.tileZoom !== seg.planet.terrain.maxZoom) {
|
|
687
|
+
// pn = pn.parentNode;
|
|
688
|
+
// }
|
|
689
|
+
//
|
|
690
|
+
// let pns = pn.segment;
|
|
691
|
+
//
|
|
692
|
+
// if (!pns.initialized) {
|
|
693
|
+
// pns.initialize();
|
|
694
|
+
// }
|
|
695
|
+
//
|
|
696
|
+
// if (!pns.plainProcessing) {
|
|
697
|
+
// pn.segment.createPlainSegmentAsync();
|
|
698
|
+
// }
|
|
699
|
+
//
|
|
700
|
+
// if (pns.plainReady && !stopLoading) {
|
|
701
|
+
// pns.loadTerrain(true);
|
|
702
|
+
// }
|
|
703
|
+
// }
|
|
710
704
|
}
|
|
711
705
|
}
|
|
712
706
|
}
|
package/src/og/quadTree/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { EarthQuadTreeStrategy } from "./EarthQuadTreeStrategy.js";
|
|
2
2
|
import { MarsQuadTreeStrategy } from "./MarsQuadTreeStrategy.js";
|
|
3
|
+
import { EPSG4326QuadTreeStrategy } from "./EPSG4326QuadTreeStrategy.js";
|
|
3
4
|
import { QuadTreeStrategy } from "./QuadTreeStrategy.js";
|
|
4
5
|
import { Wgs84QuadTreeStrategy } from "./Wgs84QuadTreeStrategy.js";
|
|
5
6
|
|
|
6
7
|
const quadTreeStrategyType = {
|
|
8
|
+
epsg4326: EPSG4326QuadTreeStrategy,
|
|
7
9
|
earth: EarthQuadTreeStrategy,
|
|
8
10
|
mars: MarsQuadTreeStrategy,
|
|
9
11
|
wgs84: Wgs84QuadTreeStrategy
|
|
@@ -24,6 +24,8 @@ let __depthCallbackCounter__ = 0;
|
|
|
24
24
|
|
|
25
25
|
let __distanceCallbackCounter__ = 0;
|
|
26
26
|
|
|
27
|
+
const MSAA_DEFAULT = 0;
|
|
28
|
+
|
|
27
29
|
/**
|
|
28
30
|
* Represents high level WebGL context interface that starts WebGL handler working in real time.
|
|
29
31
|
* @class
|
|
@@ -177,7 +179,13 @@ class Renderer {
|
|
|
177
179
|
this.depthFramebuffer = null;
|
|
178
180
|
|
|
179
181
|
let urlParams = new URLSearchParams(location.search);
|
|
180
|
-
|
|
182
|
+
let msaaParam = urlParams.get('og_msaa');
|
|
183
|
+
if (msaaParam) {
|
|
184
|
+
this._msaa = Number(urlParams.get('og_msaa'));
|
|
185
|
+
} else {
|
|
186
|
+
this._msaa = params.msaa != undefined ? params.msaa : MSAA_DEFAULT;
|
|
187
|
+
}
|
|
188
|
+
|
|
181
189
|
this._internalFormat = "RGBA16F";
|
|
182
190
|
this._format = "RGBA";
|
|
183
191
|
this._type = "FLOAT";
|
|
@@ -783,6 +791,7 @@ class Renderer {
|
|
|
783
791
|
// Rendering scene nodes and entityCollections
|
|
784
792
|
let rn = this._renderNodesArr;
|
|
785
793
|
let k = frustums.length;
|
|
794
|
+
|
|
786
795
|
while (k--) {
|
|
787
796
|
this.activeCamera.setCurrentFrustum(k);
|
|
788
797
|
gl.clear(gl.DEPTH_BUFFER_BIT);
|
|
@@ -796,6 +805,10 @@ class Renderer {
|
|
|
796
805
|
|
|
797
806
|
i = rn.length;
|
|
798
807
|
while (i--) {
|
|
808
|
+
gl.enable(gl.BLEND);
|
|
809
|
+
gl.blendEquation(gl.FUNC_ADD);
|
|
810
|
+
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
|
|
811
|
+
|
|
799
812
|
rn[i].drawNode();
|
|
800
813
|
}
|
|
801
814
|
|
package/src/og/scene/Planet.js
CHANGED
|
@@ -354,7 +354,7 @@ export class Planet extends RenderNode {
|
|
|
354
354
|
*/
|
|
355
355
|
this._useSpecularTexture = isUndef(options.useSpecularTexture) ? true : options.useSpecularTexture;
|
|
356
356
|
|
|
357
|
-
this._maxGridSize = Math.log2(options.maxGridSize ||
|
|
357
|
+
this._maxGridSize = Math.log2(options.maxGridSize || 256);
|
|
358
358
|
|
|
359
359
|
/**
|
|
360
360
|
* Segment multiple textures size.(4 - convinient value for the most devices)
|
|
@@ -1142,7 +1142,14 @@ export class Planet extends RenderNode {
|
|
|
1142
1142
|
}
|
|
1143
1143
|
|
|
1144
1144
|
if (this.camera.isFirstPass) {
|
|
1145
|
+
this.camera.update();
|
|
1145
1146
|
this._firstPASS();
|
|
1147
|
+
this.camera.checkTerrainCollision();
|
|
1148
|
+
this.camera.update();
|
|
1149
|
+
|
|
1150
|
+
// Here is the planet node dispatches a draw event before
|
|
1151
|
+
// rendering begins and we have got render nodes.
|
|
1152
|
+
this.events.dispatch(this.events.draw, this);
|
|
1146
1153
|
}
|
|
1147
1154
|
|
|
1148
1155
|
this.drawEntityCollections(this._frustumEntityCollections);
|
|
@@ -1196,10 +1203,6 @@ export class Planet extends RenderNode {
|
|
|
1196
1203
|
}
|
|
1197
1204
|
this._skipPreRender = true;
|
|
1198
1205
|
|
|
1199
|
-
// Here is the planet node dispatches a draw event before
|
|
1200
|
-
// rendering begins and we have got render nodes.
|
|
1201
|
-
this.events.dispatch(this.events.draw, this);
|
|
1202
|
-
|
|
1203
1206
|
this.transformLights();
|
|
1204
1207
|
|
|
1205
1208
|
this._normalMapCreator.frame();
|
|
@@ -1228,7 +1231,7 @@ export class Planet extends RenderNode {
|
|
|
1228
1231
|
|
|
1229
1232
|
gl.enable(gl.BLEND);
|
|
1230
1233
|
gl.blendEquation(gl.FUNC_ADD);
|
|
1231
|
-
gl.blendFunc(gl.
|
|
1234
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
1232
1235
|
|
|
1233
1236
|
if (this.lightEnabled) {
|
|
1234
1237
|
h.programs.drawnode_screen_wl.activate();
|
|
@@ -1338,7 +1341,7 @@ export class Planet extends RenderNode {
|
|
|
1338
1341
|
|
|
1339
1342
|
gl.enable(gl.BLEND);
|
|
1340
1343
|
gl.blendEquation(gl.FUNC_ADD);
|
|
1341
|
-
gl.blendFunc(gl.
|
|
1344
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
1342
1345
|
|
|
1343
1346
|
if (this.lightEnabled) {
|
|
1344
1347
|
h.programs.drawnode_screen_wl.activate();
|
|
@@ -1546,7 +1549,8 @@ export class Planet extends RenderNode {
|
|
|
1546
1549
|
gl.uniform3fv(shu.frustumPickingColor, cam.frustum._pickingColorU);
|
|
1547
1550
|
|
|
1548
1551
|
// drawing planet nodes
|
|
1549
|
-
|
|
1552
|
+
let rn = this._renderedNodesInFrustum[cam.getCurrentFrustum()],
|
|
1553
|
+
sl = this._visibleTileLayerSlices;
|
|
1550
1554
|
|
|
1551
1555
|
let i = rn.length;
|
|
1552
1556
|
while (i--) {
|
package/src/og/scene/index.js
CHANGED