@openglobus/og 0.11.2 → 0.11.7
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 +13 -13
- package/src/og/Clock.js +10 -10
- package/src/og/Events.js +8 -6
- package/src/og/Extent.js +82 -41
- package/src/og/Globe.js +25 -13
- package/src/og/ImageCanvas.js +22 -16
- package/src/og/LonLat.js +16 -13
- package/src/og/Popup.js +21 -14
- package/src/og/QueueArray.js +6 -2
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +5 -2
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +22 -16
- package/src/og/astro/jd.js +23 -18
- package/src/og/astro/orbit.js +13 -11
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +14 -11
- package/src/og/camera/Camera.js +51 -54
- package/src/og/camera/Frustum.js +29 -18
- package/src/og/camera/PlanetCamera.js +32 -23
- package/src/og/control/CompassButton.js +5 -1
- package/src/og/control/Control.js +12 -10
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +54 -33
- package/src/og/control/KeyboardNavigation.js +10 -10
- package/src/og/control/LayerSwitcher.js +22 -21
- package/src/og/control/Lighting.js +34 -3
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +6 -7
- package/src/og/control/ShowFps.js +13 -8
- package/src/og/control/SimpleNavigation.js +6 -8
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +4 -4
- package/src/og/control/TouchNavigation.js +44 -33
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/ellipsoid/Ellipsoid.js +162 -66
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +100 -56
- package/src/og/entity/Billboard.js +14 -10
- package/src/og/entity/BillboardHandler.js +317 -60
- package/src/og/entity/Entity.js +100 -68
- package/src/og/entity/EntityCollection.js +70 -47
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +27 -24
- package/src/og/entity/GeometryHandler.js +596 -124
- package/src/og/entity/Label.js +80 -49
- package/src/og/entity/LabelHandler.js +45 -244
- package/src/og/entity/LabelWorker.js +218 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +80 -32
- package/src/og/entity/PointCloudHandler.js +8 -8
- package/src/og/entity/Polyline.js +16 -16
- package/src/og/entity/Ray.js +60 -27
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +26 -26
- package/src/og/entity/index.js +8 -16
- package/src/og/layer/BaseGeoImage.js +54 -23
- package/src/og/layer/CanvasTiles.js +24 -24
- package/src/og/layer/GeoImage.js +9 -9
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +63 -37
- package/src/og/layer/Layer.js +44 -21
- package/src/og/layer/Material.js +23 -20
- package/src/og/layer/Vector.js +114 -68
- package/src/og/layer/WMS.js +34 -17
- package/src/og/layer/XYZ.js +48 -46
- package/src/og/light/LightSource.js +46 -39
- package/src/og/math/Mat3.js +34 -22
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +182 -139
- package/src/og/math/Ray.js +38 -33
- package/src/og/math/Vec2.js +85 -75
- package/src/og/math/Vec3.js +142 -112
- package/src/og/math/Vec4.js +27 -31
- package/src/og/math/coder.js +10 -10
- package/src/og/math.js +12 -12
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +4 -6
- package/src/og/quadTree/Node.js +8 -8
- package/src/og/renderer/Renderer.js +59 -52
- package/src/og/renderer/RendererEvents.js +50 -27
- package/src/og/scene/BaseNode.js +7 -8
- package/src/og/scene/Planet.js +102 -103
- package/src/og/scene/RenderNode.js +28 -21
- package/src/og/segment/Segment.js +26 -21
- package/src/og/segment/SegmentLonLat.js +5 -5
- package/src/og/shaders/drawnode.js +135 -142
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/pointCloud.js +41 -41
- package/src/og/shaders/shape.js +12 -18
- package/src/og/shaders/skybox.js +36 -36
- package/src/og/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +126 -54
- package/src/og/shapes/Icosphere.js +29 -14
- package/src/og/shapes/Sphere.js +12 -15
- package/src/og/terrain/BilTerrain.js +1 -0
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +9 -9
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/TextureAtlas.js +22 -24
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +16 -16
- package/src/og/webgl/Framebuffer.js +88 -40
- package/src/og/webgl/Handler.js +243 -169
- package/src/og/webgl/Multisample.js +47 -19
- package/src/og/webgl/Program.js +79 -34
- package/src/og/webgl/ProgramController.js +17 -13
- package/src/og/webgl/callbacks.js +8 -8
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/Clock.d.ts +0 -90
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -73
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -75
- package/types/ImageCanvas.d.ts +0 -121
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -38
- package/types/QueueArray.d.ts +0 -15
- package/types/Rectangle.d.ts +0 -74
- package/types/Stack.d.ts +0 -15
- package/types/ajax.d.ts +0 -24
- package/types/arial.d.ts +0 -48
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -6
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -25
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -303
- package/types/camera/Frustum.d.ts +0 -129
- package/types/camera/PlanetCamera.d.ts +0 -223
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -18
- package/types/control/Control.d.ts +0 -101
- package/types/control/DebugInfo.d.ts +0 -16
- package/types/control/EarthCoordinates.d.ts +0 -47
- package/types/control/EarthNavigation.d.ts +0 -42
- package/types/control/GeoImageDragControl.d.ts +0 -6
- package/types/control/KeyboardNavigation.d.ts +0 -22
- package/types/control/LayerSwitcher.d.ts +0 -23
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -51
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -12
- package/types/control/SimpleNavigation.d.ts +0 -28
- package/types/control/Sun.d.ts +0 -52
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -50
- package/types/control/ZoomControl.d.ts +0 -28
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -142
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -5
- package/types/entity/BaseBillboard.d.ts +0 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -74
- package/types/entity/Entity.d.ts +0 -331
- package/types/entity/EntityCollection.d.ts +0 -303
- package/types/entity/Geometry.d.ts +0 -73
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -194
- package/types/entity/LabelHandler.d.ts +0 -24
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -304
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -123
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -118
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.core.d.ts +0 -65
- package/types/index.d.ts +0 -45
- package/types/index.webgl.d.ts +0 -7
- package/types/inherits.d.ts +0 -4
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -34
- package/types/layer/BaseGeoImage.d.ts +0 -107
- package/types/layer/CanvasTiles.d.ts +0 -75
- package/types/layer/GeoImage.d.ts +0 -65
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -80
- package/types/layer/KML.d.ts +0 -58
- package/types/layer/Layer.d.ts +0 -321
- package/types/layer/Material.d.ts +0 -48
- package/types/layer/Vector.d.ts +0 -228
- package/types/layer/WMS.d.ts +0 -66
- package/types/layer/XYZ.d.ts +0 -130
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -177
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -63
- package/types/math/Mat4.d.ts +0 -173
- package/types/math/Plane.d.ts +0 -17
- package/types/math/Quat.d.ts +0 -376
- package/types/math/Ray.d.ts +0 -81
- package/types/math/Vec2.d.ts +0 -308
- package/types/math/Vec3.d.ts +0 -459
- package/types/math/Vec4.d.ts +0 -161
- package/types/math/coder.d.ts +0 -42
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -261
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -5
- package/types/proj/EPSG4326.d.ts +0 -5
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EntityCollectionNode.d.ts +0 -34
- package/types/quadTree/Node.d.ts +0 -61
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -296
- package/types/renderer/RendererEvents.d.ts +0 -230
- package/types/res/images.d.ts +0 -3
- package/types/scene/Axes.d.ts +0 -11
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -574
- package/types/scene/RenderNode.d.ts +0 -143
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -271
- package/types/segment/SegmentLonLat.d.ts +0 -62
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -7
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/shape.d.ts +0 -4
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shapes/BaseShape.d.ts +0 -247
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -8
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -153
- package/types/terrain/MapboxTerrain.d.ts +0 -8
- package/types/terrain/index.d.ts +0 -5
- package/types/utils/FontAtlas.d.ts +0 -14
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -25
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -10
- package/types/utils/TerrainWorker.d.ts +0 -9
- package/types/utils/TextureAtlas.d.ts +0 -111
- package/types/utils/VectorTileCreator.d.ts +0 -16
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/shared.d.ts +0 -230
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -372
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- package/types/webgl/ProgramController.d.ts +0 -84
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
|
@@ -30,7 +30,7 @@ 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:
|
|
@@ -41,7 +41,7 @@ const EVENT_NAMES = [
|
|
|
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,31 +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
|
-
|
|
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
175
|
material.applyImage(canvas);
|
|
176
|
-
}
|
|
176
|
+
}
|
|
177
|
+
that._dequeueRequest();
|
|
177
178
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
);
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
181
|
} else {
|
|
182
182
|
material.textureNotExists();
|
|
183
183
|
}
|
|
@@ -186,7 +186,7 @@ class CanvasTiles extends Layer {
|
|
|
186
186
|
/**
|
|
187
187
|
* Abort exact material loading.
|
|
188
188
|
* @public
|
|
189
|
-
* @param {
|
|
189
|
+
* @param {Material} material - Segment material.
|
|
190
190
|
*/
|
|
191
191
|
abortMaterialLoading(material) {
|
|
192
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;
|
|
@@ -220,4 +220,4 @@ class GeoImage extends BaseGeoImage {
|
|
|
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,11 +91,13 @@ 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
|
}
|
|
@@ -92,29 +107,37 @@ export class KML extends Vector {
|
|
|
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,14 +151,14 @@ 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();
|
|
@@ -145,15 +168,18 @@ export class KML extends Vector {
|
|
|
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
|
}
|
package/src/og/layer/Layer.js
CHANGED
|
@@ -28,10 +28,12 @@ export const FADING_FACTOR = 0.29;
|
|
|
28
28
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
29
29
|
* @param {boolean} [options.isBaseLayer=false] - This is a base layer.
|
|
30
30
|
* @param {boolean} [options.visibility=true] - Layer visibility.
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {
|
|
31
|
+
* @param {boolean} [options.isSRGB=false] - Layer image webgl nternal format.
|
|
32
|
+
* @param {Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
|
|
33
|
+
* @param {Vec3} [options.ambient=[0.1, 0.1, 0.1]] - Ambient RGB color.
|
|
34
|
+
* @param {Vec3} [options.diffuse=[0.9, 0.9, 0.9]] - Diffuse RGB color.
|
|
35
|
+
* @param {Vec3} [options.specular=[0.00025, 0.00015, 0.0001]] - Specular RGB color.
|
|
36
|
+
* @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
|
|
35
37
|
* @param {Number} [options.shininess=100] - Shininess.
|
|
36
38
|
*
|
|
37
39
|
* @fires og.Layer#visibilitychange
|
|
@@ -110,15 +112,15 @@ class Layer {
|
|
|
110
112
|
* @public
|
|
111
113
|
* @type {Object}
|
|
112
114
|
*/
|
|
113
|
-
this.ambient = utils.createColorRGB(options.ambient, new Vec3(0.
|
|
114
|
-
this.diffuse = utils.createColorRGB(options.diffuse, new Vec3(0.
|
|
115
|
-
this.specular = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.
|
|
115
|
+
this.ambient = utils.createColorRGB(options.ambient, new Vec3(0.2, 0.2, 0.2));
|
|
116
|
+
this.diffuse = utils.createColorRGB(options.diffuse, new Vec3(0.8, 0.8, 0.8));
|
|
117
|
+
this.specular = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.0003, 0.0003));
|
|
116
118
|
this.shininess = options.shininess || 20.0;
|
|
117
119
|
|
|
118
120
|
/**
|
|
119
121
|
* Planet node.
|
|
120
122
|
* @protected
|
|
121
|
-
* @type {
|
|
123
|
+
* @type {Planet}
|
|
122
124
|
*/
|
|
123
125
|
this._planet = null;
|
|
124
126
|
|
|
@@ -179,14 +181,22 @@ class Layer {
|
|
|
179
181
|
/**
|
|
180
182
|
* Visible degrees extent.
|
|
181
183
|
* @protected
|
|
182
|
-
* @type {
|
|
184
|
+
* @type {Extent}
|
|
183
185
|
*/
|
|
184
186
|
this._extent = null;
|
|
185
187
|
|
|
188
|
+
this.createTexture = null;
|
|
189
|
+
|
|
190
|
+
this._textureFilter = options.textureFilter ? options.textureFilter.trim().toUpperCase() : "MIPMAP";
|
|
191
|
+
|
|
192
|
+
this._isSRGB = options.isSRGB != undefined ? options.isSRGB : false;
|
|
193
|
+
|
|
194
|
+
this._internalFormat = null;
|
|
195
|
+
|
|
186
196
|
/**
|
|
187
197
|
* Visible mercator extent.
|
|
188
198
|
* @protected
|
|
189
|
-
* @type {
|
|
199
|
+
* @type {Extent}
|
|
190
200
|
*/
|
|
191
201
|
this._extentMerc = null;
|
|
192
202
|
|
|
@@ -201,7 +211,7 @@ class Layer {
|
|
|
201
211
|
/**
|
|
202
212
|
* Layer picking color. Assign when added to the planet.
|
|
203
213
|
* @protected
|
|
204
|
-
* @type {
|
|
214
|
+
* @type {Vec3}
|
|
205
215
|
*/
|
|
206
216
|
this._pickingColor = new Vec3();
|
|
207
217
|
|
|
@@ -210,7 +220,7 @@ class Layer {
|
|
|
210
220
|
/**
|
|
211
221
|
* Events handler.
|
|
212
222
|
* @public
|
|
213
|
-
* @type {
|
|
223
|
+
* @type {Events}
|
|
214
224
|
*/
|
|
215
225
|
this.events = new Events(EVENT_NAMES, this);
|
|
216
226
|
}
|
|
@@ -310,7 +320,7 @@ class Layer {
|
|
|
310
320
|
/**
|
|
311
321
|
* Compares layers instances.
|
|
312
322
|
* @public
|
|
313
|
-
* @param {
|
|
323
|
+
* @param {Layer} layer - Layer instance to compare.
|
|
314
324
|
* @returns {boolean} - Returns true if the layers is the same instance of the input.
|
|
315
325
|
*/
|
|
316
326
|
isEqual(layer) {
|
|
@@ -321,9 +331,18 @@ class Layer {
|
|
|
321
331
|
* Assign the planet.
|
|
322
332
|
* @protected
|
|
323
333
|
* @virtual
|
|
324
|
-
* @param {
|
|
325
|
-
*/
|
|
326
|
-
_assignPlanet(planet) {
|
|
334
|
+
* @param {Planet} planet - Planet render node.
|
|
335
|
+
*/
|
|
336
|
+
_assignPlanet(planet) {
|
|
337
|
+
// TODO: webgl1
|
|
338
|
+
if (this._isSRGB) {
|
|
339
|
+
this._internalFormat = planet.renderer.handler.gl.SRGB8_ALPHA8;
|
|
340
|
+
} else {
|
|
341
|
+
this._internalFormat = planet.renderer.handler.gl.RGBA8;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
this.createTexture = planet.renderer.handler.createTexture[this._textureFilter];
|
|
345
|
+
|
|
327
346
|
planet.layers.push(this);
|
|
328
347
|
this._planet = planet;
|
|
329
348
|
this.events.on("visibilitychange", planet._onLayerVisibilityChanged, planet);
|
|
@@ -348,7 +367,7 @@ class Layer {
|
|
|
348
367
|
/**
|
|
349
368
|
* Adds layer to the planet.
|
|
350
369
|
* @public
|
|
351
|
-
* @param {
|
|
370
|
+
* @param {Planet} planet - Adds layer to the planet.
|
|
352
371
|
*/
|
|
353
372
|
addTo(planet) {
|
|
354
373
|
if (!this._planet) {
|
|
@@ -360,7 +379,7 @@ class Layer {
|
|
|
360
379
|
/**
|
|
361
380
|
* Removes from planet.
|
|
362
381
|
* @public
|
|
363
|
-
* @returns {
|
|
382
|
+
* @returns {Layer} -This layer.
|
|
364
383
|
*/
|
|
365
384
|
remove() {
|
|
366
385
|
var p = this._planet;
|
|
@@ -386,7 +405,11 @@ class Layer {
|
|
|
386
405
|
* @virtual
|
|
387
406
|
*/
|
|
388
407
|
clear() {
|
|
389
|
-
|
|
408
|
+
if (this._planet) {
|
|
409
|
+
this._planet._clearLayerMaterial(this);
|
|
410
|
+
this._internalFormat = null;
|
|
411
|
+
this.createTexture = null;
|
|
412
|
+
}
|
|
390
413
|
}
|
|
391
414
|
|
|
392
415
|
/**
|
|
@@ -514,7 +537,7 @@ class Layer {
|
|
|
514
537
|
/**
|
|
515
538
|
* Sets visible geographical extent.
|
|
516
539
|
* @public
|
|
517
|
-
* @param {
|
|
540
|
+
* @param {Extent} extent - Layer visible geographical extent.
|
|
518
541
|
*/
|
|
519
542
|
setExtent(extent) {
|
|
520
543
|
var sw = extent.southWest.clone(),
|
|
@@ -533,7 +556,7 @@ class Layer {
|
|
|
533
556
|
/**
|
|
534
557
|
* Gets layer extent.
|
|
535
558
|
* @public
|
|
536
|
-
* @return {
|
|
559
|
+
* @return {Extent} - Layer geodetic extent.
|
|
537
560
|
*/
|
|
538
561
|
getExtent() {
|
|
539
562
|
return this._extent;
|
package/src/og/layer/Material.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
* @module og/layer/Material
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
7
|
class Material {
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {*} segment
|
|
12
|
-
* @param {*} layer
|
|
9
|
+
*
|
|
10
|
+
* @param {*} segment
|
|
11
|
+
* @param {*} layer
|
|
13
12
|
*/
|
|
14
13
|
constructor(segment, layer) {
|
|
15
14
|
this.segment = segment;
|
|
@@ -30,29 +29,33 @@ class Material {
|
|
|
30
29
|
this.pickingReady = false;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
assignLayer(layer) {
|
|
37
|
-
|
|
38
|
-
}
|
|
32
|
+
///**
|
|
33
|
+
// * @param {*} layer
|
|
34
|
+
// */
|
|
35
|
+
//assignLayer(layer) {
|
|
36
|
+
// this.layer = layer;
|
|
37
|
+
//}
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
|
-
*
|
|
40
|
+
*
|
|
42
41
|
*/
|
|
43
42
|
abortLoading() {
|
|
44
43
|
this.layer.abortMaterialLoading(this);
|
|
45
44
|
}
|
|
46
45
|
|
|
46
|
+
_createTexture(img) {
|
|
47
|
+
return this.layer.createTexture(img, this.layer._internalFormat);
|
|
48
|
+
}
|
|
49
|
+
|
|
47
50
|
/**
|
|
48
|
-
*
|
|
49
|
-
* @param {*} img
|
|
51
|
+
*
|
|
52
|
+
* @param {*} img
|
|
50
53
|
*/
|
|
51
54
|
applyImage(img) {
|
|
52
55
|
if (this.segment.initialized) {
|
|
53
56
|
this._updateTexture = null;
|
|
54
57
|
//this.image = img;
|
|
55
|
-
this.texture = this.
|
|
58
|
+
this.texture = this._createTexture(img);
|
|
56
59
|
this.appliedNodeId = this.segment.node.nodeId;
|
|
57
60
|
this.isReady = true;
|
|
58
61
|
this.pickingReady = true;
|
|
@@ -63,9 +66,9 @@ class Material {
|
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @param {*} texture
|
|
68
|
-
* @param {*} pickingMask
|
|
69
|
+
*
|
|
70
|
+
* @param {*} texture
|
|
71
|
+
* @param {*} pickingMask
|
|
69
72
|
*/
|
|
70
73
|
applyTexture(texture, pickingMask) {
|
|
71
74
|
if (this.segment.initialized) {
|
|
@@ -83,7 +86,7 @@ class Material {
|
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
|
-
*
|
|
89
|
+
*
|
|
87
90
|
*/
|
|
88
91
|
textureNotExists() {
|
|
89
92
|
if (this.segment.initialized) {
|
|
@@ -95,7 +98,7 @@ class Material {
|
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
/**
|
|
98
|
-
*
|
|
101
|
+
*
|
|
99
102
|
*/
|
|
100
103
|
clear() {
|
|
101
104
|
this.loadingAttempts = 0;
|