@openglobus/og 0.11.1 → 0.11.6
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 +18 -20
- package/src/og/Clock.js +11 -11
- package/src/og/Deferred.js +1 -1
- package/src/og/Events.js +9 -7
- package/src/og/Extent.js +117 -72
- package/src/og/Globe.js +35 -22
- package/src/og/ImageCanvas.js +24 -18
- package/src/og/Lock.js +2 -2
- package/src/og/LonLat.js +40 -37
- package/src/og/Popup.js +21 -15
- package/src/og/QueueArray.js +7 -3
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +8 -5
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +23 -17
- package/src/og/astro/jd.js +44 -39
- package/src/og/astro/orbit.js +20 -18
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +17 -9
- package/src/og/camera/Camera.js +137 -86
- package/src/og/camera/Frustum.js +30 -19
- package/src/og/camera/PlanetCamera.js +30 -26
- package/src/og/control/CompassButton.js +8 -2
- package/src/og/control/Control.js +13 -11
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +62 -41
- package/src/og/control/EarthNavigation.js +20 -22
- package/src/og/control/GeoImageDragControl.js +1 -1
- package/src/og/control/KeyboardNavigation.js +12 -12
- package/src/og/control/LayerSwitcher.js +24 -23
- package/src/og/control/Lighting.js +1 -1
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +8 -9
- package/src/og/control/ShowFps.js +15 -10
- package/src/og/control/SimpleNavigation.js +8 -10
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +5 -5
- package/src/og/control/TouchNavigation.js +58 -45
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/control/index.js +4 -0
- package/src/og/ellipsoid/Ellipsoid.js +181 -85
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +97 -44
- package/src/og/entity/Billboard.js +15 -11
- package/src/og/entity/BillboardHandler.js +314 -64
- package/src/og/entity/Entity.js +106 -74
- package/src/og/entity/EntityCollection.js +72 -49
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +29 -26
- package/src/og/entity/GeometryHandler.js +598 -126
- package/src/og/entity/Label.js +74 -40
- package/src/og/entity/LabelHandler.js +47 -246
- package/src/og/entity/LabelWorker.js +213 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +81 -33
- package/src/og/entity/PointCloudHandler.js +9 -9
- package/src/og/entity/Polyline.js +39 -39
- package/src/og/entity/Ray.js +61 -28
- package/src/og/entity/ShapeHandler.js +1 -1
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +27 -27
- package/src/og/entity/index.js +8 -16
- package/src/og/input/KeyboardHandler.js +107 -104
- package/src/og/input/MouseHandler.js +81 -78
- package/src/og/input/TouchHandler.js +55 -51
- package/src/og/layer/BaseGeoImage.js +61 -30
- package/src/og/layer/CanvasTiles.js +26 -24
- package/src/og/layer/GeoImage.js +10 -10
- package/src/og/layer/GeoTexture2d.js +1 -1
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +66 -40
- package/src/og/layer/Layer.js +27 -17
- package/src/og/layer/Material.js +93 -61
- package/src/og/layer/Vector.js +118 -72
- package/src/og/layer/WMS.js +36 -19
- package/src/og/layer/XYZ.js +55 -48
- package/src/og/light/LightSource.js +47 -40
- package/src/og/math/Line2.js +24 -24
- package/src/og/math/Line3.js +103 -102
- package/src/og/math/Mat3.js +134 -121
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +980 -927
- package/src/og/math/Ray.js +195 -187
- package/src/og/math/Vec2.js +127 -117
- package/src/og/math/Vec3.js +206 -176
- package/src/og/math/Vec4.js +49 -53
- package/src/og/math/coder.js +18 -18
- package/src/og/math.js +12 -12
- package/src/og/mercator.js +11 -11
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +31 -31
- package/src/og/quadTree/EntityCollectionNode.js +310 -300
- package/src/og/quadTree/Node.js +1008 -993
- package/src/og/renderer/Renderer.js +768 -747
- package/src/og/renderer/RendererEvents.js +9 -6
- package/src/og/scene/Axes.js +1 -1
- package/src/og/scene/BaseNode.js +8 -9
- package/src/og/scene/Planet.js +115 -87
- package/src/og/scene/RenderNode.js +29 -22
- package/src/og/scene/SkyBox.js +1 -1
- package/src/og/segment/Segment.js +1886 -1878
- package/src/og/segment/SegmentLonLat.js +298 -268
- package/src/og/segment/segmentHelper.js +11 -11
- package/src/og/shaders/bloom.js +1 -1
- package/src/og/shaders/blur.js +2 -2
- package/src/og/shaders/depth.js +1 -1
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/label.js +1 -1
- package/src/og/shaders/lumFilter.js +1 -1
- package/src/og/shaders/pointCloud.js +42 -42
- package/src/og/shaders/screenFrame.js +1 -1
- package/src/og/shaders/shape.js +15 -21
- package/src/og/shaders/skybox.js +37 -37
- package/src/og/shaders/toneMapping.js +1 -1
- package/src/og/shapes/BaseShape.js +129 -57
- package/src/og/shapes/Icosphere.js +30 -15
- package/src/og/shapes/Sphere.js +13 -16
- package/src/og/terrain/BilTerrain.js +2 -1
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/Geoid.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +10 -10
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/GeoImageCreator.js +9 -9
- package/src/og/utils/Loader.js +6 -6
- package/src/og/utils/NormalMapCreator.js +13 -13
- package/src/og/utils/TerrainWorker.js +1 -1
- package/src/og/utils/TextureAtlas.js +20 -22
- package/src/og/utils/VectorTileCreator.js +5 -5
- package/src/og/utils/earcut.js +1 -1
- package/src/og/utils/shared.js +15 -15
- package/src/og/webgl/Framebuffer.js +101 -53
- package/src/og/webgl/Handler.js +125 -85
- package/src/og/webgl/Multisample.js +55 -27
- package/src/og/webgl/Program.js +80 -35
- package/src/og/webgl/ProgramController.js +27 -23
- package/src/og/webgl/callbacks.js +8 -8
- package/types/Clock.d.ts +6 -2
- package/types/Deferred.d.ts +1 -1
- package/types/Events.d.ts +8 -4
- package/types/Extent.d.ts +37 -33
- package/types/Globe.d.ts +15 -13
- package/types/ImageCanvas.d.ts +5 -3
- package/types/LonLat.d.ts +24 -24
- package/types/Popup.d.ts +4 -0
- package/types/QueueArray.d.ts +6 -2
- package/types/Rectangle.d.ts +10 -4
- package/types/Stack.d.ts +4 -0
- package/types/ajax.d.ts +1 -1
- package/types/astro/earth.d.ts +3 -2
- package/types/bv/Box.d.ts +10 -5
- package/types/bv/Sphere.d.ts +13 -7
- package/types/camera/Camera.d.ts +90 -81
- package/types/camera/Frustum.d.ts +26 -22
- package/types/camera/PlanetCamera.d.ts +49 -53
- package/types/control/CompassButton.d.ts +4 -4
- package/types/control/Control.d.ts +7 -4
- package/types/control/DebugInfo.d.ts +3 -4
- package/types/control/EarthCoordinates.d.ts +6 -6
- package/types/control/EarthNavigation.d.ts +42 -0
- package/types/control/KeyboardNavigation.d.ts +3 -4
- package/types/control/LayerSwitcher.d.ts +3 -5
- package/types/control/Lighting.d.ts +3 -3
- package/types/control/MouseNavigation.d.ts +47 -0
- package/types/control/ScaleControl.d.ts +3 -3
- package/types/control/ShowFps.d.ts +3 -4
- package/types/control/SimpleNavigation.d.ts +3 -6
- package/types/control/Sun.d.ts +8 -10
- package/types/control/ToggleWireframe.d.ts +3 -3
- package/types/control/TouchNavigation.d.ts +48 -0
- package/types/control/ZoomControl.d.ts +3 -4
- package/types/control/index.d.ts +3 -1
- package/types/ellipsoid/Ellipsoid.d.ts +47 -43
- package/types/ellipsoid/wgs84.d.ts +3 -2
- package/types/entity/BaseBillboard.d.ts +41 -34
- package/types/entity/Billboard.d.ts +7 -7
- package/types/entity/BillboardHandler.d.ts +4 -0
- package/types/entity/Entity.d.ts +101 -83
- package/types/entity/EntityCollection.d.ts +57 -43
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +77 -0
- package/types/entity/Geometry.d.ts +9 -7
- package/types/entity/GeometryHandler.d.ts +2 -2
- package/types/entity/Label.d.ts +24 -29
- package/types/entity/LabelHandler.d.ts +9 -2
- package/types/entity/LabelWorker.d.ts +9 -0
- package/types/entity/PointCloud.d.ts +8 -8
- package/types/entity/PointCloudHandler.d.ts +3 -3
- package/types/entity/Polyline.d.ts +58 -55
- package/types/entity/Ray.d.ts +19 -18
- package/types/entity/Strip.d.ts +8 -7
- package/types/entity/StripHandler.d.ts +3 -3
- package/types/entity/index.d.ts +7 -7
- package/types/input/KeyboardHandler.d.ts +10 -0
- package/types/input/MouseHandler.d.ts +5 -0
- package/types/input/TouchHandler.d.ts +5 -0
- package/types/layer/BaseGeoImage.d.ts +23 -35
- package/types/layer/CanvasTiles.d.ts +15 -22
- package/types/layer/GeoImage.d.ts +5 -18
- package/types/layer/GeoVideo.d.ts +5 -30
- package/types/layer/KML.d.ts +20 -15
- package/types/layer/Layer.d.ts +326 -0
- package/types/layer/Material.d.ts +45 -0
- package/types/layer/Vector.d.ts +208 -0
- package/types/layer/WMS.d.ts +4 -7
- package/types/layer/XYZ.d.ts +19 -25
- package/types/light/LightSource.d.ts +54 -53
- package/types/math/Line2.d.ts +11 -0
- package/types/math/Line3.d.ts +10 -0
- package/types/math/Mat3.d.ts +30 -18
- package/types/math/Mat4.d.ts +71 -52
- package/types/math/Plane.d.ts +5 -4
- package/types/math/Quat.d.ts +379 -0
- package/types/math/Ray.d.ts +82 -0
- package/types/math/Vec2.d.ts +102 -101
- package/types/math/Vec3.d.ts +143 -142
- package/types/math/Vec4.d.ts +40 -39
- package/types/math/coder.d.ts +12 -11
- package/types/math.d.ts +8 -8
- package/types/mercator.d.ts +3 -3
- package/types/proj/EPSG3857.d.ts +3 -2
- package/types/proj/EPSG4326.d.ts +3 -2
- package/types/proj/Proj.d.ts +42 -0
- package/types/quadTree/EntityCollectionNode.d.ts +34 -0
- package/types/quadTree/Node.d.ts +61 -0
- package/types/renderer/Renderer.d.ts +300 -0
- package/types/renderer/RendererEvents.d.ts +10 -7
- package/types/scene/BaseNode.d.ts +9 -9
- package/types/scene/Planet.d.ts +131 -126
- package/types/scene/RenderNode.d.ts +22 -23
- package/types/segment/Segment.d.ts +279 -0
- package/types/segment/SegmentLonLat.d.ts +16 -0
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shapes/BaseShape.d.ts +43 -40
- package/types/shapes/Sphere.d.ts +7 -7
- package/types/terrain/BilTerrain.d.ts +0 -1
- package/types/terrain/EmptyTerrain.d.ts +4 -4
- package/types/terrain/GlobusTerrain.d.ts +17 -54
- package/types/terrain/MapboxTerrain.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +8 -8
- package/types/utils/shared.d.ts +25 -24
- package/types/webgl/Framebuffer.d.ts +5 -5
- package/types/webgl/Handler.d.ts +68 -43
- package/types/webgl/Multisample.d.ts +5 -5
- package/types/webgl/Program.d.ts +8 -2
- package/types/webgl/ProgramController.d.ts +18 -13
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/inherits.d.ts +0 -4
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* @module og/layer/BaseGeoImage
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as mercator from
|
|
8
|
-
import { Extent } from
|
|
9
|
-
import { Layer } from
|
|
10
|
-
import { LonLat } from
|
|
7
|
+
import * as mercator from "../mercator.js";
|
|
8
|
+
import { Extent } from "../Extent.js";
|
|
9
|
+
import { Layer } from "./Layer.js";
|
|
10
|
+
import { LonLat } from "../LonLat.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* BaseGeoImage layer represents square imagery layer that could be an static image, or animated video or webgl buffer object displayed on the globe.
|
|
14
14
|
* @class
|
|
15
|
-
* @extends {
|
|
15
|
+
* @extends {Layer}
|
|
16
16
|
*/
|
|
17
17
|
class BaseGeoImage extends Layer {
|
|
18
18
|
constructor(name, options) {
|
|
@@ -54,28 +54,37 @@ class BaseGeoImage extends Layer {
|
|
|
54
54
|
/**
|
|
55
55
|
* Gets corners coordinates.
|
|
56
56
|
* @public
|
|
57
|
-
* @return {Array.<
|
|
57
|
+
* @return {Array.<LonLat>} - (exactly 4 entries)
|
|
58
58
|
*/
|
|
59
59
|
getCornersLonLat() {
|
|
60
60
|
var c = this._cornersWgs84;
|
|
61
|
-
return [
|
|
62
|
-
|
|
61
|
+
return [
|
|
62
|
+
new LonLat(c[0].lon, c[0].lat),
|
|
63
|
+
new LonLat(c[1].lon, c[1].lat),
|
|
64
|
+
new LonLat(c[2].lon, c[2].lat),
|
|
65
|
+
new LonLat(c[3].lon, c[3].lat)
|
|
66
|
+
];
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* Gets corners coordinates.
|
|
67
71
|
* @public
|
|
68
|
-
* @return {Array.<Array<number
|
|
72
|
+
* @return {Array.<Array<number>>} - (exactly 3 entries)
|
|
69
73
|
*/
|
|
70
74
|
getCorners() {
|
|
71
75
|
var c = this._cornersWgs84;
|
|
72
|
-
return [
|
|
76
|
+
return [
|
|
77
|
+
[c[0].lon, c[0].lat],
|
|
78
|
+
[c[1].lon, c[1].lat],
|
|
79
|
+
[c[2].lon, c[2].lat],
|
|
80
|
+
[c[3].lon, c[3].lat]
|
|
81
|
+
];
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
/**
|
|
76
85
|
* Sets geoImage geographical corners coordinates.
|
|
77
86
|
* @public
|
|
78
|
-
* @param {Array.<Array.<number
|
|
87
|
+
* @param {Array.<Array.<number>>} corners - GeoImage corners coordinates. Where first coordinate (exactly 3 entries)
|
|
79
88
|
* coincedents to the left top image corner, secont to the right top image corner, third to the right bottom
|
|
80
89
|
* and fourth - left bottom image corner.
|
|
81
90
|
*/
|
|
@@ -86,13 +95,18 @@ class BaseGeoImage extends Layer {
|
|
|
86
95
|
/**
|
|
87
96
|
* Sets geoImage geographical corners coordinates.
|
|
88
97
|
* @public
|
|
89
|
-
* @param {Array.<
|
|
98
|
+
* @param {Array.<LonLat>} corners - GeoImage corners coordinates. Where first coordinate
|
|
90
99
|
* coincedents to the left top image corner, secont to the right top image corner, third to the right bottom
|
|
91
|
-
* and fourth - left bottom image corner.
|
|
100
|
+
* and fourth - left bottom image corner. (exactly 4 entries)
|
|
92
101
|
*/
|
|
93
102
|
setCornersLonLat(corners) {
|
|
94
103
|
this._refreshFrame = true;
|
|
95
|
-
this._cornersWgs84 = [
|
|
104
|
+
this._cornersWgs84 = [
|
|
105
|
+
corners[0].clone(),
|
|
106
|
+
corners[1].clone(),
|
|
107
|
+
corners[2].clone(),
|
|
108
|
+
corners[3].clone()
|
|
109
|
+
] || [0, 0, 0, 0];
|
|
96
110
|
|
|
97
111
|
for (var i = 0; i < this._cornersWgs84.length; i++) {
|
|
98
112
|
if (this._cornersWgs84[i].lat >= 89.9) {
|
|
@@ -105,8 +119,7 @@ class BaseGeoImage extends Layer {
|
|
|
105
119
|
this._extent.setByCoordinates(this._cornersWgs84);
|
|
106
120
|
|
|
107
121
|
var me = this._extent;
|
|
108
|
-
if (me.southWest.lat > mercator.MAX_LAT ||
|
|
109
|
-
me.northEast.lat < mercator.MIN_LAT) {
|
|
122
|
+
if (me.southWest.lat > mercator.MAX_LAT || me.northEast.lat < mercator.MIN_LAT) {
|
|
110
123
|
this._projType = 0;
|
|
111
124
|
this.rendering = this._renderingProjType0;
|
|
112
125
|
} else {
|
|
@@ -126,15 +139,32 @@ class BaseGeoImage extends Layer {
|
|
|
126
139
|
_createFrame() {
|
|
127
140
|
this._extentWgs84 = this._extent.clone();
|
|
128
141
|
|
|
129
|
-
this._cornersMerc = [
|
|
130
|
-
|
|
142
|
+
this._cornersMerc = [
|
|
143
|
+
this._cornersWgs84[0].forwardMercatorEPS01(),
|
|
144
|
+
this._cornersWgs84[1].forwardMercatorEPS01(),
|
|
145
|
+
this._cornersWgs84[2].forwardMercatorEPS01(),
|
|
146
|
+
this._cornersWgs84[3].forwardMercatorEPS01()
|
|
147
|
+
];
|
|
131
148
|
|
|
132
|
-
this._extentMerc = new Extent(
|
|
149
|
+
this._extentMerc = new Extent(
|
|
150
|
+
this._extentWgs84.southWest.forwardMercatorEPS01(),
|
|
151
|
+
this._extentWgs84.northEast.forwardMercatorEPS01()
|
|
152
|
+
);
|
|
133
153
|
|
|
134
154
|
if (this._projType === 0) {
|
|
135
|
-
this._extentWgs84Params = [
|
|
155
|
+
this._extentWgs84Params = [
|
|
156
|
+
this._extentWgs84.southWest.lon,
|
|
157
|
+
this._extentWgs84.southWest.lat,
|
|
158
|
+
2.0 / this._extentWgs84.getWidth(),
|
|
159
|
+
2.0 / this._extentWgs84.getHeight()
|
|
160
|
+
];
|
|
136
161
|
} else {
|
|
137
|
-
this._extentMercParams = [
|
|
162
|
+
this._extentMercParams = [
|
|
163
|
+
this._extentMerc.southWest.lon,
|
|
164
|
+
this._extentMerc.southWest.lat,
|
|
165
|
+
2.0 / this._extentMerc.getWidth(),
|
|
166
|
+
2.0 / this._extentMerc.getHeight()
|
|
167
|
+
];
|
|
138
168
|
}
|
|
139
169
|
|
|
140
170
|
// creates material frame textures
|
|
@@ -146,7 +176,10 @@ class BaseGeoImage extends Layer {
|
|
|
146
176
|
gl.deleteTexture(this._materialTexture);
|
|
147
177
|
this._materialTexture = h.createEmptyTexture_l(this._frameWidth, this._frameHeight);
|
|
148
178
|
|
|
149
|
-
this._gridBuffer = this._planet._geoImageCreator.createGridBuffer(
|
|
179
|
+
this._gridBuffer = this._planet._geoImageCreator.createGridBuffer(
|
|
180
|
+
this._cornersWgs84,
|
|
181
|
+
this._projType
|
|
182
|
+
);
|
|
150
183
|
|
|
151
184
|
this._refreshFrame = false;
|
|
152
185
|
}
|
|
@@ -154,7 +187,7 @@ class BaseGeoImage extends Layer {
|
|
|
154
187
|
|
|
155
188
|
/**
|
|
156
189
|
* @virtual
|
|
157
|
-
* @param {
|
|
190
|
+
* @param {Material} material - GeoImage material.
|
|
158
191
|
*/
|
|
159
192
|
abortMaterialLoading(material) {
|
|
160
193
|
this._creationProceeding = false;
|
|
@@ -200,7 +233,6 @@ class BaseGeoImage extends Layer {
|
|
|
200
233
|
*/
|
|
201
234
|
setVisibility(visibility) {
|
|
202
235
|
if (visibility !== this._visibility) {
|
|
203
|
-
|
|
204
236
|
super.setVisibility(visibility);
|
|
205
237
|
|
|
206
238
|
// remove from creator
|
|
@@ -215,7 +247,7 @@ class BaseGeoImage extends Layer {
|
|
|
215
247
|
/**
|
|
216
248
|
* @virtual
|
|
217
249
|
* @protected
|
|
218
|
-
* @param {
|
|
250
|
+
* @param {Material} material - GeoImage material.
|
|
219
251
|
*/
|
|
220
252
|
clearMaterial(material) {
|
|
221
253
|
material.image = null;
|
|
@@ -227,11 +259,10 @@ class BaseGeoImage extends Layer {
|
|
|
227
259
|
/**
|
|
228
260
|
* @virtual
|
|
229
261
|
* @protected
|
|
230
|
-
* @param {
|
|
231
|
-
* @returns {Array<
|
|
262
|
+
* @param {Material} material - GeoImage material.
|
|
263
|
+
* @returns {Array<number> } -
|
|
232
264
|
*/
|
|
233
265
|
applyMaterial(material) {
|
|
234
|
-
|
|
235
266
|
var segment = material.segment;
|
|
236
267
|
|
|
237
268
|
if (this._ready) {
|
|
@@ -276,6 +307,6 @@ class BaseGeoImage extends Layer {
|
|
|
276
307
|
get getFrameHeight() {
|
|
277
308
|
return this._frameHeight;
|
|
278
309
|
}
|
|
279
|
-
}
|
|
310
|
+
}
|
|
280
311
|
|
|
281
312
|
export { BaseGeoImage };
|
|
@@ -30,18 +30,18 @@ const EVENT_NAMES = [
|
|
|
30
30
|
/**
|
|
31
31
|
* Layer used to rendering each tile as a separate canvas object.
|
|
32
32
|
* @class
|
|
33
|
-
* @extends {
|
|
33
|
+
* @extends {Layer}
|
|
34
34
|
* //TODO: make asynchronous handler.
|
|
35
35
|
* @param {String} [name="noname"] - Layer name.
|
|
36
36
|
* @param {Object} options:
|
|
37
37
|
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
38
|
-
* @param {Array.<number
|
|
38
|
+
* @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color. (exactly 3 entries)
|
|
39
39
|
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
40
40
|
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
41
41
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
42
42
|
* @param {boolean} [options.isBaseLayer=false] - Base layer flag.
|
|
43
43
|
* @param {boolean} [options.visibility=true] - Layer visibility.
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {layer.CanvasTiles~drawTileCallback} [options.drawTile] - Draw tile callback.
|
|
45
45
|
* @fires og.layer.CanvasTiles#load
|
|
46
46
|
* @fires og.layer.CanvasTiles#loadend
|
|
47
47
|
*/
|
|
@@ -63,13 +63,13 @@ class CanvasTiles extends Layer {
|
|
|
63
63
|
/**
|
|
64
64
|
* Tile pending queue that waiting for create.
|
|
65
65
|
* @protected
|
|
66
|
-
* @type {Array.<
|
|
66
|
+
* @type {Array.<planetSegment.Material>}
|
|
67
67
|
*/
|
|
68
68
|
this._pendingsQueue = []; // new og.QueueArray();
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Draw tile callback.
|
|
72
|
-
* @type {
|
|
72
|
+
* @type {layer.CanvasTiles~drawTileCallback}
|
|
73
73
|
* @public
|
|
74
74
|
*/
|
|
75
75
|
this.drawTile = options.drawTile || null;
|
|
@@ -116,7 +116,7 @@ class CanvasTiles extends Layer {
|
|
|
116
116
|
* Start to load tile material.
|
|
117
117
|
* @public
|
|
118
118
|
* @virtual
|
|
119
|
-
* @param {
|
|
119
|
+
* @param {Material} material -
|
|
120
120
|
*/
|
|
121
121
|
loadMaterial(material) {
|
|
122
122
|
var seg = material.segment;
|
|
@@ -143,7 +143,7 @@ class CanvasTiles extends Layer {
|
|
|
143
143
|
/**
|
|
144
144
|
* Loads material image and apply it to the planet segment.
|
|
145
145
|
* @protected
|
|
146
|
-
* @param {
|
|
146
|
+
* @param {Material} material - Loads material image.
|
|
147
147
|
*/
|
|
148
148
|
_exec(material) {
|
|
149
149
|
CanvasTiles.__requestsCounter++;
|
|
@@ -153,29 +153,31 @@ class CanvasTiles extends Layer {
|
|
|
153
153
|
/**
|
|
154
154
|
* Tile custom draw function.
|
|
155
155
|
* @callback og.layer.CanvasTiles~drawTileCallback
|
|
156
|
-
* @param {
|
|
156
|
+
* @param {Material} material
|
|
157
157
|
* @param {applyCanvasCallback} applyCanvasCallback
|
|
158
158
|
*/
|
|
159
159
|
var e = that.events.load;
|
|
160
160
|
if (e.handlers.length) {
|
|
161
161
|
that.events.dispatch(e, material);
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
material.
|
|
163
|
+
requestAnimationFrame(() => {
|
|
164
|
+
that.drawTile(
|
|
165
|
+
material,
|
|
166
|
+
/**
|
|
167
|
+
* Apply canvas.
|
|
168
|
+
* @callback applyCanvasCallback
|
|
169
|
+
* @param {Object} canvas -
|
|
170
|
+
*/
|
|
171
|
+
function (canvas) {
|
|
172
|
+
that._counter--;
|
|
173
|
+
CanvasTiles.__requestsCounter--;
|
|
174
|
+
if (material.isLoading) {
|
|
175
|
+
material.applyImage(canvas);
|
|
176
|
+
}
|
|
177
|
+
that._dequeueRequest();
|
|
175
178
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
);
|
|
179
|
+
);
|
|
180
|
+
});
|
|
179
181
|
} else {
|
|
180
182
|
material.textureNotExists();
|
|
181
183
|
}
|
|
@@ -184,7 +186,7 @@ class CanvasTiles extends Layer {
|
|
|
184
186
|
/**
|
|
185
187
|
* Abort exact material loading.
|
|
186
188
|
* @public
|
|
187
|
-
* @param {
|
|
189
|
+
* @param {Material} material - Segment material.
|
|
188
190
|
*/
|
|
189
191
|
abortMaterialLoading(material) {
|
|
190
192
|
if (material.isLoading && material.image) {
|
package/src/og/layer/GeoImage.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* @module og/layer/GeoImage
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { BaseGeoImage } from
|
|
7
|
+
import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Used to load and display a single image over specific corner coordinates on the globe, implements og.layer.BaseGeoImage interface.
|
|
11
11
|
* @class
|
|
12
|
-
* @extends {
|
|
12
|
+
* @extends {BaseGeoImage}
|
|
13
13
|
*/
|
|
14
14
|
class GeoImage extends BaseGeoImage {
|
|
15
15
|
constructor(name, options) {
|
|
@@ -84,7 +84,7 @@ class GeoImage extends BaseGeoImage {
|
|
|
84
84
|
* Loads planet segment material. In this case - GeoImage source image.
|
|
85
85
|
* @virtual
|
|
86
86
|
* @public
|
|
87
|
-
* @param {
|
|
87
|
+
* @param {Material} material - GeoImage planet material.
|
|
88
88
|
*/
|
|
89
89
|
loadMaterial(material) {
|
|
90
90
|
material.isLoading = true;
|
|
@@ -95,14 +95,14 @@ class GeoImage extends BaseGeoImage {
|
|
|
95
95
|
this._onLoad(this._image);
|
|
96
96
|
} else if (this._image.src) {
|
|
97
97
|
let that = this;
|
|
98
|
-
this._image.addEventListener(
|
|
98
|
+
this._image.addEventListener("load", function (e) {
|
|
99
99
|
that._onLoad(this);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
} else {
|
|
103
103
|
let that = this;
|
|
104
104
|
this._image = new Image();
|
|
105
|
-
this._image.addEventListener(
|
|
105
|
+
this._image.addEventListener("load", function (e) {
|
|
106
106
|
that._onLoad(this);
|
|
107
107
|
});
|
|
108
108
|
this._image.src = this._src;
|
|
@@ -114,10 +114,10 @@ class GeoImage extends BaseGeoImage {
|
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* @virtual
|
|
117
|
-
* @param {
|
|
117
|
+
* @param {Material} material - GeoImage material.
|
|
118
118
|
*/
|
|
119
119
|
abortMaterialLoading(material) {
|
|
120
|
-
this._image && (this._image.src =
|
|
120
|
+
this._image && (this._image.src = "");
|
|
121
121
|
this._creationProceeding = false;
|
|
122
122
|
material.isLoading = false;
|
|
123
123
|
material.isReady = false;
|
|
@@ -218,6 +218,6 @@ class GeoImage extends BaseGeoImage {
|
|
|
218
218
|
|
|
219
219
|
this._creationProceeding = false;
|
|
220
220
|
}
|
|
221
|
-
}
|
|
221
|
+
}
|
|
222
222
|
|
|
223
|
-
export { GeoImage };
|
|
223
|
+
export { GeoImage };
|
package/src/og/layer/GeoVideo.js
CHANGED
|
@@ -9,7 +9,7 @@ import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
|
9
9
|
/**
|
|
10
10
|
* Used to load and display a video stream by specific corners coordinates on the globe, implements og.layer.BaseGeoImage interface.
|
|
11
11
|
* @class
|
|
12
|
-
* @extends {
|
|
12
|
+
* @extends {BaseGeoImage}
|
|
13
13
|
*/
|
|
14
14
|
class GeoVideo extends BaseGeoImage {
|
|
15
15
|
constructor(name, options) {
|
|
@@ -139,7 +139,7 @@ class GeoVideo extends BaseGeoImage {
|
|
|
139
139
|
* Loads planet segment material. In this case - GeoImage source video.
|
|
140
140
|
* @virtual
|
|
141
141
|
* @public
|
|
142
|
-
* @param {
|
|
142
|
+
* @param {Material} material - GeoImage planet material.
|
|
143
143
|
*/
|
|
144
144
|
loadMaterial(material) {
|
|
145
145
|
material.isLoading = true;
|
|
@@ -177,7 +177,7 @@ class GeoVideo extends BaseGeoImage {
|
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* @virtual
|
|
180
|
-
* @param {
|
|
180
|
+
* @param {Material} material - GeoImage material.
|
|
181
181
|
*/
|
|
182
182
|
abortMaterialLoading(material) {
|
|
183
183
|
this._video && (this._video.src = "");
|
package/src/og/layer/KML.js
CHANGED
|
@@ -2,41 +2,51 @@
|
|
|
2
2
|
* @module og/layer/KML
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
import { Entity } from
|
|
7
|
-
import { Extent } from
|
|
8
|
-
import { LonLat } from
|
|
9
|
-
import { Vector } from
|
|
5
|
+
"use strict";
|
|
6
|
+
import { Entity } from "../entity/Entity.js";
|
|
7
|
+
import { Extent } from "../Extent.js";
|
|
8
|
+
import { LonLat } from "../LonLat.js";
|
|
9
|
+
import { Vector } from "./Vector.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Layer to render KMLs files
|
|
13
13
|
* @class
|
|
14
|
-
* @extends {
|
|
14
|
+
* @extends {Vector}
|
|
15
15
|
*/
|
|
16
16
|
export class KML extends Vector {
|
|
17
|
-
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {string} name
|
|
18
|
+
*
|
|
19
|
+
* @param {string} name
|
|
21
20
|
* @param {*} [options]
|
|
22
21
|
*/
|
|
23
22
|
constructor(name, options = {}) {
|
|
24
23
|
super(name, options);
|
|
25
24
|
this._extent = null;
|
|
26
|
-
this._billboard = options.billboard || {
|
|
27
|
-
|
|
25
|
+
this._billboard = options.billboard || {
|
|
26
|
+
src: "https://openglobus.org/examples/billboards/carrot.png"
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @type {string}
|
|
30
|
+
*/
|
|
31
|
+
this._color = options.color || "#6689db";
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
get instanceName() {
|
|
31
|
-
return
|
|
35
|
+
return "KML";
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
/**
|
|
35
39
|
* @private
|
|
36
40
|
*/
|
|
37
41
|
_extractCoordonatesFromKml(xmlDoc) {
|
|
38
|
-
const raw = Array.from(xmlDoc.getElementsByTagName(
|
|
39
|
-
const coordinates = raw.map(item
|
|
42
|
+
const raw = Array.from(xmlDoc.getElementsByTagName("coordinates"));
|
|
43
|
+
const coordinates = raw.map((item) =>
|
|
44
|
+
item.textContent
|
|
45
|
+
.trim()
|
|
46
|
+
.replace(/\n/g, " ")
|
|
47
|
+
.split(" ")
|
|
48
|
+
.map((co) => co.split(",").map(parseFloat))
|
|
49
|
+
);
|
|
40
50
|
return coordinates;
|
|
41
51
|
}
|
|
42
52
|
|
|
@@ -44,32 +54,35 @@ export class KML extends Vector {
|
|
|
44
54
|
* Creates billboards or polylines from array of lonlat.
|
|
45
55
|
* @private
|
|
46
56
|
* @param {Array} coordonates
|
|
47
|
-
* @param {string} color
|
|
48
|
-
* @returns {Array<
|
|
57
|
+
* @param {string} color
|
|
58
|
+
* @returns {Array<Entity>}
|
|
49
59
|
*/
|
|
50
60
|
_convertCoordonatesIntoEntities(coordinates, color, billboard) {
|
|
51
61
|
const extent = new Extent(new LonLat(180.0, 90.0), new LonLat(-180.0, -90.0));
|
|
52
62
|
const addToExtent = (c) => {
|
|
53
|
-
const lon = c[0],
|
|
63
|
+
const lon = c[0],
|
|
64
|
+
lat = c[1];
|
|
54
65
|
if (lon < extent.southWest.lon) extent.southWest.lon = lon;
|
|
55
66
|
if (lat < extent.southWest.lat) extent.southWest.lat = lat;
|
|
56
67
|
if (lon > extent.northEast.lon) extent.northEast.lon = lon;
|
|
57
68
|
if (lat > extent.northEast.lat) extent.northEast.lat = lat;
|
|
58
69
|
};
|
|
59
70
|
const _pathes = [];
|
|
60
|
-
coordinates.forEach(kmlFile => kmlFile.forEach(p => _pathes.push(p)));
|
|
61
|
-
const entities = _pathes.map(path => {
|
|
71
|
+
coordinates.forEach((kmlFile) => kmlFile.forEach((p) => _pathes.push(p)));
|
|
72
|
+
const entities = _pathes.map((path) => {
|
|
62
73
|
if (path.length === 1) {
|
|
63
74
|
const lonlat = path[0];
|
|
64
75
|
const _entity = new Entity({ lonlat, billboard });
|
|
65
76
|
addToExtent(lonlat);
|
|
66
77
|
return _entity;
|
|
67
78
|
} else if (path.length > 1) {
|
|
68
|
-
const pathLonLat = path.map(item => {
|
|
79
|
+
const pathLonLat = path.map((item) => {
|
|
69
80
|
addToExtent(item);
|
|
70
81
|
return new LonLat(item[0], item[1], item[2]);
|
|
71
82
|
});
|
|
72
|
-
const _entity = new Entity({
|
|
83
|
+
const _entity = new Entity({
|
|
84
|
+
polyline: { pathLonLat: [pathLonLat], thickness: 3, color, isClosed: false }
|
|
85
|
+
});
|
|
73
86
|
return _entity;
|
|
74
87
|
}
|
|
75
88
|
});
|
|
@@ -78,43 +91,53 @@ export class KML extends Vector {
|
|
|
78
91
|
|
|
79
92
|
/**
|
|
80
93
|
* @private
|
|
94
|
+
* @returns {Document}
|
|
81
95
|
*/
|
|
82
96
|
_getXmlContent(file) {
|
|
83
|
-
return new Promise(resolve => {
|
|
97
|
+
return new Promise((resolve) => {
|
|
84
98
|
const fileReader = new FileReader();
|
|
85
|
-
fileReader.onload = async i =>
|
|
99
|
+
fileReader.onload = async (i) =>
|
|
100
|
+
resolve(new DOMParser().parseFromString(i.target.result, "text/xml"));
|
|
86
101
|
fileReader.readAsText(file);
|
|
87
102
|
});
|
|
88
|
-
}
|
|
103
|
+
}
|
|
89
104
|
|
|
90
105
|
/**
|
|
91
106
|
* @private
|
|
92
107
|
*/
|
|
93
108
|
_expandExtents(extent1, extent2) {
|
|
94
109
|
if (!extent1) return extent2;
|
|
95
|
-
if (extent2.southWest.lon < extent1.southWest.lon)
|
|
96
|
-
|
|
97
|
-
if (extent2.
|
|
98
|
-
|
|
110
|
+
if (extent2.southWest.lon < extent1.southWest.lon)
|
|
111
|
+
extent1.southWest.lon = extent2.southWest.lon;
|
|
112
|
+
if (extent2.southWest.lat < extent1.southWest.lat)
|
|
113
|
+
extent1.southWest.lat = extent2.southWest.lat;
|
|
114
|
+
if (extent2.northEast.lon > extent1.northEast.lon)
|
|
115
|
+
extent1.northEast.lon = extent2.northEast.lon;
|
|
116
|
+
if (extent2.northEast.lat > extent1.northEast.lat)
|
|
117
|
+
extent1.northEast.lat = extent2.northEast.lat;
|
|
99
118
|
return extent1;
|
|
100
119
|
}
|
|
101
120
|
|
|
102
121
|
/**
|
|
103
122
|
* @public
|
|
104
123
|
* @param {File[]} kmls
|
|
105
|
-
* @returns {Promise}
|
|
124
|
+
* @returns {Promise<{entities: Entity[], extent: Extent}>}
|
|
106
125
|
*/
|
|
107
126
|
async addKmlFromFiles(kmls) {
|
|
108
127
|
const kmlObjs = await Promise.all(kmls.map(this._getXmlContent));
|
|
109
128
|
const coordonates = kmlObjs.map(this._extractCoordonatesFromKml);
|
|
110
|
-
const { entities, extent } = this._convertCoordonatesIntoEntities(
|
|
129
|
+
const { entities, extent } = this._convertCoordonatesIntoEntities(
|
|
130
|
+
coordonates,
|
|
131
|
+
this._color,
|
|
132
|
+
this._billboard
|
|
133
|
+
);
|
|
111
134
|
this._extent = this._expandExtents(this._extent, extent);
|
|
112
135
|
entities.forEach(this.add.bind(this));
|
|
113
136
|
return { entities, extent };
|
|
114
137
|
}
|
|
115
138
|
|
|
116
139
|
/**
|
|
117
|
-
* @param {string} color
|
|
140
|
+
* @param {string} color
|
|
118
141
|
* @public
|
|
119
142
|
*/
|
|
120
143
|
setColor(color) {
|
|
@@ -128,32 +151,35 @@ export class KML extends Vector {
|
|
|
128
151
|
_getKmlFromUrl(url) {
|
|
129
152
|
return new Promise((resolve, reject) => {
|
|
130
153
|
const request = new XMLHttpRequest();
|
|
131
|
-
request.open(
|
|
132
|
-
request.responseType =
|
|
133
|
-
request.overrideMimeType(
|
|
154
|
+
request.open("GET", url, true);
|
|
155
|
+
request.responseType = "document";
|
|
156
|
+
request.overrideMimeType("text/xml");
|
|
134
157
|
request.onload = () => {
|
|
135
158
|
if (request.readyState === request.DONE && request.status === 200) {
|
|
136
159
|
resolve(request.responseXML);
|
|
137
160
|
} else {
|
|
138
|
-
reject(new Error(
|
|
161
|
+
reject(new Error("no valid kml file"));
|
|
139
162
|
}
|
|
140
163
|
};
|
|
141
164
|
request.send();
|
|
142
165
|
});
|
|
143
|
-
}
|
|
166
|
+
}
|
|
144
167
|
|
|
145
168
|
/**
|
|
146
169
|
* @public
|
|
147
170
|
* @param {string} url - Url of the KML to display. './myFile.kml' or 'http://mySite/myFile.kml' for example.
|
|
148
|
-
* @returns {Promise}
|
|
171
|
+
* @returns {Promise<{entities: Entity[], extent: Extent}>}
|
|
149
172
|
*/
|
|
150
173
|
async addKmlFromUrl(url) {
|
|
151
174
|
const kml = await this._getKmlFromUrl(url);
|
|
152
175
|
const coordonates = this._extractCoordonatesFromKml(kml);
|
|
153
|
-
const { entities, extent } = this._convertCoordonatesIntoEntities(
|
|
176
|
+
const { entities, extent } = this._convertCoordonatesIntoEntities(
|
|
177
|
+
[coordonates],
|
|
178
|
+
this._color,
|
|
179
|
+
this._billboard
|
|
180
|
+
);
|
|
154
181
|
this._extent = this._expandExtents(this._extent, extent);
|
|
155
182
|
entities.forEach(this.add.bind(this));
|
|
156
183
|
return { entities, extent };
|
|
157
184
|
}
|
|
158
|
-
|
|
159
|
-
};
|
|
185
|
+
}
|