@openglobus/og 0.13.8 → 0.13.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/css/og.css +388 -129
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +20 -19
- package/src/og/Globe.js +15 -16
- package/src/og/Object3d.js +33 -0
- package/src/og/control/GeoImageDragControl.js +102 -75
- package/src/og/control/LayerAnimation.js +306 -38
- package/src/og/control/LayerSwitcher.js +506 -159
- package/src/og/control/Lighting.js +27 -27
- package/src/og/control/RulerSwitcher.js +69 -0
- package/src/og/control/UIhelpers.js +146 -0
- package/src/og/control/index.js +3 -1
- package/src/og/control/ruler/RulerScene.js +6 -2
- package/src/og/control/visibleExtent/Segment.js +2 -1
- package/src/og/ellipsoid/wgs84.js +1 -1
- package/src/og/entity/LabelHandler.js +5 -2
- package/src/og/entity/LabelWorker.js +38 -53
- package/src/og/layer/BaseGeoImage.js +347 -312
- package/src/og/layer/CanvasTiles.js +312 -290
- package/src/og/layer/GeoImage.js +222 -214
- package/src/og/layer/GeoVideo.js +291 -291
- package/src/og/layer/Layer.js +71 -30
- package/src/og/layer/Material.js +109 -109
- package/src/og/layer/Vector.js +1 -0
- package/src/og/layer/XYZ.js +20 -12
- package/src/og/light/LightSource.js +364 -363
- package/src/og/math.js +2 -2
- package/src/og/quadTree/Node.js +7 -5
- package/src/og/renderer/Renderer.js +1 -1
- package/src/og/scene/Planet.js +103 -42
- package/src/og/segment/Segment.js +34 -56
- package/src/og/segment/Slice.js +1 -1
- package/src/og/shaders/drawnode.js +1 -1
- package/src/og/terrain/GlobusTerrain.js +31 -20
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/BaseWorker.js +46 -0
- package/src/og/utils/GeoImageCreator.js +164 -161
- package/src/og/utils/Loader.js +60 -33
- package/src/og/utils/NormalMapCreator.js +403 -412
- package/src/og/utils/PlainSegmentWorker.js +29 -55
- package/src/og/utils/TerrainWorker.js +572 -589
- package/src/og/utils/functionComposition.js +13 -0
- package/src/og/webgl/Handler.js +42 -41
- package/types/Object3d.d.ts +1 -0
- package/types/camera/PlanetCamera.d.ts +4 -0
- package/types/control/GeoImageDragControl.d.ts +2 -0
- package/types/control/LayerAnimation.d.ts +73 -0
- package/types/control/LayerSwitcher.d.ts +55 -11
- package/types/control/MouseNavigation.d.ts +1 -0
- package/types/control/MouseWheelZoomControl.d.ts +1 -0
- package/types/control/Sun.d.ts +1 -0
- package/types/control/TouchNavigation.d.ts +1 -0
- package/types/control/UIhelpers.d.ts +13 -0
- package/types/control/index.d.ts +2 -1
- package/types/entity/LabelHandler.d.ts +2 -0
- package/types/entity/LabelWorker.d.ts +5 -7
- package/types/layer/BaseGeoImage.d.ts +9 -1
- package/types/layer/CanvasTiles.d.ts +5 -1
- package/types/layer/GeoImage.d.ts +1 -0
- package/types/layer/GeoTexture2d.d.ts +1 -0
- package/types/layer/Layer.d.ts +5 -1
- package/types/layer/Vector.d.ts +7 -0
- package/types/layer/WMS.d.ts +1 -0
- package/types/layer/XYZ.d.ts +8 -6
- package/types/math.d.ts +1 -1
- package/types/quadTree/EntityCollectionNode.d.ts +7 -0
- package/types/quadTree/Node.d.ts +1 -2
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +16 -0
- package/types/scene/Planet.d.ts +19 -4
- package/types/segment/SegmentLonLat.d.ts +2 -0
- package/types/terrain/BilTerrain.d.ts +6 -0
- package/types/terrain/GlobusTerrain.d.ts +7 -0
- package/types/terrain/MapboxTerrain.d.ts +8 -0
- package/types/utils/BaseWorker.d.ts +14 -0
- package/types/utils/Loader.d.ts +3 -1
- package/types/utils/PlainSegmentWorker.d.ts +4 -6
- package/types/utils/TerrainWorker.d.ts +4 -6
- package/types/utils/functionComposition.d.ts +5 -0
- package/types/webgl/Handler.d.ts +4 -1
package/src/og/layer/GeoImage.js
CHANGED
|
@@ -1,215 +1,223 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/layer/GeoImage
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
gl.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
gl.
|
|
154
|
-
|
|
155
|
-
gl.
|
|
156
|
-
|
|
157
|
-
gl.
|
|
158
|
-
|
|
159
|
-
gl.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
gl.
|
|
164
|
-
|
|
165
|
-
this.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
gl.
|
|
200
|
-
gl.
|
|
201
|
-
gl.
|
|
202
|
-
|
|
203
|
-
gl.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
gl.
|
|
208
|
-
|
|
209
|
-
this.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module og/layer/GeoImage
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
8
|
+
import { nextHighestPowerOfTwo } from "../math.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Used to load and display a single image over specific corner coordinates on the globe, implements og.layer.BaseGeoImage interface.
|
|
12
|
+
* @class
|
|
13
|
+
* @extends {BaseGeoImage}
|
|
14
|
+
*/
|
|
15
|
+
class GeoImage extends BaseGeoImage {
|
|
16
|
+
constructor(name, options) {
|
|
17
|
+
super(name, options);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Image object.
|
|
21
|
+
* @private
|
|
22
|
+
* @type {Image}
|
|
23
|
+
*/
|
|
24
|
+
this._image = options.image || null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Image source url path.
|
|
28
|
+
* @private
|
|
29
|
+
* @type {String}
|
|
30
|
+
*/
|
|
31
|
+
this._src = options.src || null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get instanceName() {
|
|
35
|
+
return "GeoImage";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
abortLoading() {
|
|
39
|
+
this._image.src = "";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Sets image source url path.
|
|
44
|
+
* @public
|
|
45
|
+
* @param {String} srs - Image url path.
|
|
46
|
+
*/
|
|
47
|
+
setSrc(src) {
|
|
48
|
+
this._planet && this._planet._geoImageCreator.remove(this);
|
|
49
|
+
this._src = src;
|
|
50
|
+
this._sourceReady = false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Sets image object.
|
|
55
|
+
* @public
|
|
56
|
+
* @param {Image} image - Image object.
|
|
57
|
+
*/
|
|
58
|
+
setImage(image) {
|
|
59
|
+
this._planet && this._planet._geoImageCreator.remove(this);
|
|
60
|
+
this._image = image;
|
|
61
|
+
this._src = image.src;
|
|
62
|
+
this._sourceReady = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates source gl texture.
|
|
67
|
+
* @virtual
|
|
68
|
+
* @protected
|
|
69
|
+
*/
|
|
70
|
+
_createSourceTexture() {
|
|
71
|
+
if (!this._sourceCreated) {
|
|
72
|
+
this._sourceTexture = this._planet.renderer.handler.createTexture_l(this._image);
|
|
73
|
+
this._sourceCreated = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @private
|
|
79
|
+
* @param {Image} img
|
|
80
|
+
*/
|
|
81
|
+
_onLoad(img) {
|
|
82
|
+
this._frameWidth = nextHighestPowerOfTwo(img.width * 2, 4096);
|
|
83
|
+
this._frameHeight = nextHighestPowerOfTwo(img.height * 3, 4096);
|
|
84
|
+
this._sourceReady = true;
|
|
85
|
+
this._planet._geoImageCreator.add(this);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Loads planet segment material. In this case - GeoImage source image.
|
|
90
|
+
* @virtual
|
|
91
|
+
* @public
|
|
92
|
+
* @param {Material} material - GeoImage planet material.
|
|
93
|
+
*/
|
|
94
|
+
loadMaterial(material) {
|
|
95
|
+
material.isLoading = true;
|
|
96
|
+
this._creationProceeding = true;
|
|
97
|
+
if (!this._sourceReady && this._src) {
|
|
98
|
+
if (this._image) {
|
|
99
|
+
if (this._image.complete) {
|
|
100
|
+
this._onLoad(this._image);
|
|
101
|
+
} else if (this._image.src) {
|
|
102
|
+
let that = this;
|
|
103
|
+
this._image.addEventListener("load", function (e) {
|
|
104
|
+
that._onLoad(this);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
let that = this;
|
|
109
|
+
this._image = new Image();
|
|
110
|
+
this._image.addEventListener("load", function (e) {
|
|
111
|
+
that._onLoad(this);
|
|
112
|
+
});
|
|
113
|
+
this._image.src = this._src;
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
this._planet._geoImageCreator.add(this);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @virtual
|
|
122
|
+
* @param {Material} material - GeoImage material.
|
|
123
|
+
*/
|
|
124
|
+
abortMaterialLoading(material) {
|
|
125
|
+
this._image && (this._image.src = "");
|
|
126
|
+
this._creationProceeding = false;
|
|
127
|
+
material.isLoading = false;
|
|
128
|
+
material.isReady = false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
_renderingProjType1() {
|
|
132
|
+
var p = this._planet,
|
|
133
|
+
h = p.renderer.handler,
|
|
134
|
+
gl = h.gl,
|
|
135
|
+
creator = p._geoImageCreator;
|
|
136
|
+
|
|
137
|
+
this._refreshFrame && this._createFrame();
|
|
138
|
+
this._createSourceTexture();
|
|
139
|
+
|
|
140
|
+
var f = creator._framebuffer;
|
|
141
|
+
f.setSize(this._frameWidth, this._frameHeight);
|
|
142
|
+
f.activate();
|
|
143
|
+
|
|
144
|
+
h.programs.geoImageTransform.activate();
|
|
145
|
+
var sh = h.programs.geoImageTransform._program;
|
|
146
|
+
var sha = sh.attributes,
|
|
147
|
+
shu = sh.uniforms;
|
|
148
|
+
|
|
149
|
+
gl.disable(gl.CULL_FACE);
|
|
150
|
+
|
|
151
|
+
f.bindOutputTexture(this._materialTexture);
|
|
152
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
153
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
154
|
+
|
|
155
|
+
gl.uniform1i(shu.isFullExtent, this._isFullExtent);
|
|
156
|
+
|
|
157
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
158
|
+
|
|
159
|
+
gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
|
|
160
|
+
|
|
161
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
|
|
162
|
+
gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
163
|
+
gl.uniform4fv(shu.extentParams, this._extentMercParams);
|
|
164
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
165
|
+
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
166
|
+
gl.uniform1i(shu.sourceTexture, 0);
|
|
167
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
|
|
168
|
+
gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
169
|
+
f.deactivate();
|
|
170
|
+
|
|
171
|
+
gl.enable(gl.CULL_FACE);
|
|
172
|
+
|
|
173
|
+
this._ready = true;
|
|
174
|
+
|
|
175
|
+
this._creationProceeding = false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
_renderingProjType0() {
|
|
179
|
+
var p = this._planet,
|
|
180
|
+
h = p.renderer.handler,
|
|
181
|
+
gl = h.gl,
|
|
182
|
+
creator = p._geoImageCreator;
|
|
183
|
+
|
|
184
|
+
this._refreshFrame && this._createFrame();
|
|
185
|
+
this._createSourceTexture();
|
|
186
|
+
|
|
187
|
+
var f = creator._framebuffer;
|
|
188
|
+
f.setSize(this._frameWidth, this._frameHeight);
|
|
189
|
+
f.activate();
|
|
190
|
+
|
|
191
|
+
h.programs.geoImageTransform.activate();
|
|
192
|
+
var sh = h.programs.geoImageTransform._program;
|
|
193
|
+
var sha = sh.attributes,
|
|
194
|
+
shu = sh.uniforms;
|
|
195
|
+
|
|
196
|
+
gl.disable(gl.CULL_FACE);
|
|
197
|
+
|
|
198
|
+
f.bindOutputTexture(this._materialTexture);
|
|
199
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
200
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
201
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
202
|
+
|
|
203
|
+
gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
|
|
204
|
+
|
|
205
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
|
|
206
|
+
gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
207
|
+
gl.uniform4fv(shu.extentParams, this._extentWgs84Params);
|
|
208
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
209
|
+
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
210
|
+
gl.uniform1i(shu.sourceTexture, 0);
|
|
211
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
|
|
212
|
+
gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
213
|
+
f.deactivate();
|
|
214
|
+
|
|
215
|
+
gl.enable(gl.CULL_FACE);
|
|
216
|
+
|
|
217
|
+
this._ready = true;
|
|
218
|
+
|
|
219
|
+
this._creationProceeding = false;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
215
223
|
export { GeoImage };
|