@openglobus/og 0.13.8 → 0.13.12
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 +2 -2
- package/src/og/entity/LabelWorker.js +36 -54
- 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
|
@@ -17,99 +17,367 @@ class LayerAnimation extends Control {
|
|
|
17
17
|
constructor(options = {}) {
|
|
18
18
|
super(options);
|
|
19
19
|
|
|
20
|
-
this.events = new Events(["change"])
|
|
20
|
+
this.events = new Events(["change", "idle", "play", "pause", "stop"])
|
|
21
21
|
|
|
22
|
-
this._name = `layerAnimation
|
|
23
|
-
|
|
24
|
-
this._layersArr = options.layers || [];
|
|
25
|
-
this._layersIndexesArr = this._layersArr.map((l) => l._id);
|
|
22
|
+
this._name = options.name || `layerAnimation-${this._id}`;
|
|
26
23
|
|
|
24
|
+
this._layersArr = options.layers ? [].concat(options.layers) : [];
|
|
27
25
|
this._currentIndex = -1;
|
|
26
|
+
|
|
27
|
+
this._playInterval = options.playInterval || 120;
|
|
28
|
+
this._playIntervalHandler = -1;
|
|
29
|
+
this._playIndex = 0;
|
|
30
|
+
|
|
31
|
+
this._frameSize = options.frameSize || 50;
|
|
32
|
+
|
|
33
|
+
this.repeat = options.repeat != undefined ? options.repeat : true;
|
|
34
|
+
|
|
35
|
+
this.skipTimeout = options.skipTimeout || 5000;
|
|
36
|
+
|
|
37
|
+
this._timeoutStart = 0;
|
|
28
38
|
}
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
_onViewchange() {
|
|
41
|
+
this._timeoutStart = performance.now();
|
|
42
|
+
}
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
_getFramesNum() {
|
|
45
|
+
return Math.ceil(this._layersArr.length / this._frameSize);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_setFrame(frameIndex) {
|
|
49
|
+
for (let i = 0, len = this._getFramesNum(); i < len; i++) {
|
|
50
|
+
if (i !== frameIndex) {
|
|
51
|
+
this._removeFrameFromPlanet(i);
|
|
52
|
+
} else {
|
|
53
|
+
this._appendFrameToPlanet(i);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_getFrameIndex(layerIndex) {
|
|
59
|
+
return Math.floor(layerIndex / this._frameSize);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_appendFrameToPlanet(frameIndex) {
|
|
63
|
+
if (this.planet) {
|
|
64
|
+
let minIndex = frameIndex * this._frameSize;
|
|
65
|
+
let maxIndex = minIndex + this._frameSize;
|
|
66
|
+
for (let i = minIndex, len = maxIndex > this._layersArr.length ? this._layersArr.length : maxIndex; i < len; i++) {
|
|
67
|
+
this.planet.addLayer(this._layersArr[i]);
|
|
68
|
+
}
|
|
38
69
|
}
|
|
70
|
+
}
|
|
39
71
|
|
|
72
|
+
_removeFrameFromPlanet(frameIndex) {
|
|
73
|
+
if (this.planet) {
|
|
74
|
+
let minIndex = frameIndex * this._frameSize;
|
|
75
|
+
let maxIndex = minIndex + this._frameSize;
|
|
76
|
+
for (let i = minIndex, len = maxIndex > this._layersArr.length ? this._layersArr.length : maxIndex; i < len; i++) {
|
|
77
|
+
this._layersArr[i].abortLoading();
|
|
78
|
+
this._layersArr[i].remove();
|
|
79
|
+
this._layersArr[i].setVisibility(false);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
40
83
|
|
|
84
|
+
oninit() {
|
|
85
|
+
super.oninit();
|
|
86
|
+
this.onactivate();
|
|
87
|
+
this._initLayers();
|
|
41
88
|
this._onLayerLoadend_ = this._onLayerLoadend.bind(this);
|
|
42
|
-
this.planet.
|
|
43
|
-
|
|
44
|
-
this.setCurrentIndex(0);
|
|
89
|
+
this.planet.events.on("layerloadend", this._onLayerLoadend_, this);
|
|
90
|
+
this._setCurrentIndexAsync(0, false, true);
|
|
45
91
|
}
|
|
46
92
|
|
|
47
93
|
onactivate() {
|
|
48
94
|
super.onactivate();
|
|
49
|
-
|
|
95
|
+
this._onViewchange_ = this._onViewchange.bind(this);
|
|
96
|
+
this.planet.camera.events.on("viewchange", this._onViewchange_, this);
|
|
97
|
+
|
|
98
|
+
this._onVisibityChange_ = this._onVisibityChange.bind(this);
|
|
99
|
+
this.planet.renderer.handler.events.on("visibilitychange", this._onVisibityChange_, this);
|
|
50
100
|
}
|
|
51
101
|
|
|
52
102
|
ondeactivate() {
|
|
53
103
|
super.ondeactivate();
|
|
104
|
+
this.planet.camera.events.off("viewchange", this._onViewchange_);
|
|
105
|
+
this._onViewchange_ = null;
|
|
54
106
|
|
|
55
107
|
for (let i = 0; i < this._layersArr.length; i++) {
|
|
56
108
|
this._layersArr[i].setVisibility(false);
|
|
57
|
-
this._layersArr[i].opacity = 1.0;
|
|
58
109
|
}
|
|
59
110
|
|
|
60
|
-
this.planet.
|
|
111
|
+
this.planet.events.off("layerloadend", this._onLayerLoadend_);
|
|
61
112
|
this._onLayerLoadend_ = null;
|
|
113
|
+
|
|
114
|
+
this.planet.renderer.handler.events.off("visibilitychange", this._onVisibityChange_);
|
|
115
|
+
this._onVisibityChange_ = null;
|
|
62
116
|
}
|
|
63
117
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
118
|
+
_onVisibityChange(isVisible) {
|
|
119
|
+
if (!isVisible) {
|
|
120
|
+
this.pause();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
clear() {
|
|
125
|
+
this.stop();
|
|
126
|
+
this._currentIndex = -1;
|
|
127
|
+
this._currVisibleIndex = -1;
|
|
128
|
+
let layersToRemove = this._layersArr;
|
|
129
|
+
this._layersArr = [];
|
|
130
|
+
for (let i = 0; i < layersToRemove.length; i++) {
|
|
131
|
+
layersToRemove[i].remove();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
_initLayers() {
|
|
136
|
+
if (this.planet) {
|
|
137
|
+
for (let i = 0, len = this._layersArr.length; i < len; i++) {
|
|
138
|
+
let li = this._layersArr[i];
|
|
139
|
+
li.setVisibility(false);
|
|
140
|
+
li.setBaseLayer(false);
|
|
141
|
+
li.opacity = 0.0;
|
|
73
142
|
}
|
|
143
|
+
this._appendFrameToPlanet(0);
|
|
74
144
|
}
|
|
75
145
|
}
|
|
76
146
|
|
|
77
147
|
setLayers(layers) {
|
|
78
|
-
|
|
148
|
+
this.clear();
|
|
149
|
+
this._layersArr = [].concat(layers);
|
|
150
|
+
this._initLayers();
|
|
79
151
|
}
|
|
80
152
|
|
|
81
153
|
appendLayer(layer) {
|
|
154
|
+
this._layersArr.push(layer);
|
|
155
|
+
layer.setVisibility(false);
|
|
156
|
+
layer.setBaseLayer(false);
|
|
157
|
+
layer.opacity = 0.0;
|
|
158
|
+
if (this.planet) {
|
|
159
|
+
//check current frame
|
|
160
|
+
this.planet.addLayer(layer);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* warning: Use XYZ.isIdle in requesAnimationFrame(after setVisibility)
|
|
166
|
+
* @returns {boolean} Returns truw if current layer is idle
|
|
167
|
+
*/
|
|
168
|
+
get isIdle() {
|
|
169
|
+
let currLayer = this._layersArr[this._currentIndex];
|
|
170
|
+
return currLayer && currLayer.isIdle || !currLayer;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get playInterval() {
|
|
174
|
+
return this._playInterval;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
set playInterval(val) {
|
|
178
|
+
if (val !== this._playInterval) {
|
|
179
|
+
this._playInterval = val;
|
|
180
|
+
if (this.isPlaying) {
|
|
181
|
+
this.pause();
|
|
182
|
+
this.play();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
get isPlaying() {
|
|
188
|
+
return this._playIntervalHandler !== -1;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
get layers() {
|
|
192
|
+
return this._layersArr;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
_checkEnd() {
|
|
196
|
+
if (this._playIndex > this._layersArr.length) {
|
|
197
|
+
if (this.repeat) {
|
|
198
|
+
this._playIndex = 0;
|
|
199
|
+
} else {
|
|
200
|
+
this.pause();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
play() {
|
|
206
|
+
if (!this.isPlaying) {
|
|
207
|
+
|
|
208
|
+
if (this._currentIndex >= this._layersArr.length - 1) {
|
|
209
|
+
this.stop();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
this._timeoutStart = performance.now();
|
|
213
|
+
|
|
214
|
+
this._playIntervalHandler = setInterval(() => {
|
|
215
|
+
this._checkEnd();
|
|
216
|
+
this._setCurrentIndexAsync(this._playIndex);
|
|
217
|
+
|
|
218
|
+
requestAnimationFrame(() => {
|
|
219
|
+
if (this.isIdle || (performance.now() - this._timeoutStart > this.skipTimeout)) {
|
|
220
|
+
this._playIndex++;
|
|
221
|
+
this._timeoutStart = performance.now();
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
}, this._playInterval);
|
|
226
|
+
|
|
227
|
+
this.events.dispatch(this.events.play);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
stop() {
|
|
232
|
+
if (this._playIndex > 0) {
|
|
233
|
+
this._clearInterval();
|
|
234
|
+
this._playIndex = 0;
|
|
235
|
+
this.setCurrentIndex(0);
|
|
236
|
+
this.events.dispatch(this.events.stop);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
pause() {
|
|
241
|
+
if (this.isPlaying) {
|
|
242
|
+
this._clearInterval();
|
|
243
|
+
this.events.dispatch(this.events.pause);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
_clearInterval() {
|
|
248
|
+
clearInterval(this._playIntervalHandler);
|
|
249
|
+
this._playIntervalHandler = -1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Waiting for the current index layer loadend and make it non transparent,
|
|
254
|
+
* and make prev layer transparent, also check previous frame index to cleanup.
|
|
255
|
+
* @param {Layer} layer
|
|
256
|
+
* @private
|
|
257
|
+
*/
|
|
258
|
+
_onLayerLoadend(layer) {
|
|
259
|
+
|
|
260
|
+
let currLayer = this._layersArr[this._currentIndex];
|
|
261
|
+
|
|
262
|
+
if (currLayer && currLayer.isEqual(layer)) {
|
|
82
263
|
|
|
264
|
+
// BRUTE
|
|
265
|
+
let currFrame = this._getFrameIndex(this._currentIndex);
|
|
266
|
+
let from = currFrame * this._frameSize,
|
|
267
|
+
to = this._currentIndex;
|
|
268
|
+
for (let i = from; i < to; i++) {
|
|
269
|
+
let li = this._layersArr[i];
|
|
270
|
+
li.opacity = 0;
|
|
271
|
+
li.setVisibility(false);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// * Make CURRENT Layer VISIBLE *
|
|
275
|
+
currLayer.opacity = 1.0;
|
|
276
|
+
|
|
277
|
+
let currVisibleLayer = this._layersArr[this._currVisibleIndex];
|
|
278
|
+
if (currVisibleLayer) {
|
|
279
|
+
currVisibleLayer.opacity = 0.0;
|
|
280
|
+
currVisibleLayer.setVisibility(false);
|
|
281
|
+
|
|
282
|
+
// If frame is changed - remove it from the planet
|
|
283
|
+
let prevFrame = this._getFrameIndex(this._currVisibleIndex);
|
|
284
|
+
if (this._getFrameIndex(this._currentIndex) !== prevFrame) {
|
|
285
|
+
this._removeFrameFromPlanet(prevFrame);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
this.events.dispatch(this.events.idle, currLayer);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Function sets layer index visible.
|
|
296
|
+
* @param {number} index
|
|
297
|
+
* @param {boolean} [stopPropagation]
|
|
298
|
+
*/
|
|
299
|
+
setCurrentIndex(index, stopPropagation) {
|
|
300
|
+
this._setCurrentIndexAsync(index, true, stopPropagation);
|
|
83
301
|
}
|
|
84
302
|
|
|
85
|
-
|
|
303
|
+
/**
|
|
304
|
+
* Function sets layer index visible. If the layer is idle (all visible tiles loaded), sets opacity to one,
|
|
305
|
+
* otherwise to ZERO it means that when all visible tiles will be loaded the opacity becomes ONE. So, previous
|
|
306
|
+
* layer remains non transparent (opacity = 1) till current layer is loading.
|
|
307
|
+
* @param {number} index
|
|
308
|
+
* @param {boolean} [forceVisibility]
|
|
309
|
+
* @param {boolean} [stopPropagation]
|
|
310
|
+
*/
|
|
311
|
+
_setCurrentIndexAsync(index, forceVisibility, stopPropagation) {
|
|
312
|
+
|
|
86
313
|
if (index != this._currentIndex && index >= 0 && index < this._layersArr.length) {
|
|
87
|
-
|
|
314
|
+
|
|
315
|
+
let prevCurrIndex = this._currentIndex;
|
|
88
316
|
this._currentIndex = index;
|
|
317
|
+
this._playIndex = index;
|
|
318
|
+
|
|
319
|
+
let prevCurrFrame = this._getFrameIndex(prevCurrIndex);
|
|
320
|
+
let currFrame = this._getFrameIndex(this._currentIndex);
|
|
89
321
|
|
|
90
|
-
let
|
|
322
|
+
let prevCurrLayer = this._layersArr[prevCurrIndex],
|
|
91
323
|
currLayer = this._layersArr[index];
|
|
92
324
|
|
|
325
|
+
let frameChanged = currFrame != prevCurrFrame;
|
|
326
|
+
if (frameChanged) {
|
|
327
|
+
this._appendFrameToPlanet(currFrame);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (prevCurrLayer) {
|
|
331
|
+
if (prevCurrLayer.isIdle) {
|
|
332
|
+
this._currVisibleIndex = prevCurrIndex;
|
|
333
|
+
} else {
|
|
334
|
+
prevCurrLayer.opacity = 0;
|
|
335
|
+
prevCurrLayer.setVisibility(false);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
93
339
|
if (currLayer) {
|
|
340
|
+
|
|
94
341
|
currLayer.opacity = 0.0;
|
|
95
342
|
currLayer.setVisibility(true);
|
|
343
|
+
|
|
96
344
|
requestAnimationFrame(() => {
|
|
97
|
-
if (currLayer.isIdle) {
|
|
345
|
+
if (currLayer.isIdle || forceVisibility) {
|
|
346
|
+
|
|
98
347
|
currLayer.opacity = 1.0;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
348
|
+
|
|
349
|
+
// If frame is changed - remove it from the planet
|
|
350
|
+
if (frameChanged) {
|
|
351
|
+
this._removeFrameFromPlanet(prevCurrFrame);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (prevCurrLayer) {
|
|
355
|
+
prevCurrLayer.opacity = 0.0;
|
|
356
|
+
prevCurrLayer.setVisibility(false);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
let currVisibleLayer = this._layersArr[this._currVisibleIndex];
|
|
360
|
+
if (currVisibleLayer) {
|
|
361
|
+
currVisibleLayer.opacity = 0.0;
|
|
362
|
+
currVisibleLayer.setVisibility(false);
|
|
102
363
|
}
|
|
103
364
|
}
|
|
104
365
|
});
|
|
366
|
+
|
|
367
|
+
if (!stopPropagation) {
|
|
368
|
+
this.events.dispatch(this.events.change, this._currentIndex, prevCurrIndex);
|
|
369
|
+
}
|
|
105
370
|
}
|
|
106
|
-
this.events.dispatch(this.events.change, this._currentIndex, this._prevIndex);
|
|
107
371
|
}
|
|
108
372
|
}
|
|
109
373
|
}
|
|
110
374
|
|
|
111
|
-
export function
|
|
375
|
+
export function
|
|
376
|
+
|
|
377
|
+
layerAnimation(options) {
|
|
112
378
|
return LayerAnimation(options);
|
|
113
379
|
}
|
|
114
380
|
|
|
115
|
-
export {
|
|
381
|
+
export {
|
|
382
|
+
LayerAnimation
|
|
383
|
+
};
|