@openglobus/og 0.13.7 → 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 +417 -0
- package/src/og/arial.js +1705 -1703
- package/src/og/camera/Camera.js +640 -640
- package/src/og/control/EarthCoordinates.js +1 -1
- package/src/og/control/GeoImageDragControl.js +102 -75
- package/src/og/control/LayerAnimation.js +383 -0
- package/src/og/control/LayerSwitcher.js +506 -159
- package/src/og/control/Lighting.js +27 -27
- package/src/og/control/MouseNavigation.js +460 -460
- package/src/og/control/RulerSwitcher.js +69 -0
- package/src/og/control/Sun.js +170 -170
- package/src/og/control/UIhelpers.js +146 -0
- package/src/og/control/ZoomControl.js +0 -2
- package/src/og/control/index.js +5 -1
- package/src/og/control/ruler/Ruler.js +43 -0
- package/src/og/control/ruler/RulerScene.js +374 -0
- package/src/og/control/visibleExtent/Segment.js +3 -5
- package/src/og/ellipsoid/Ellipsoid.js +19 -0
- package/src/og/ellipsoid/wgs84.js +1 -1
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/GeoObject.js +1 -1
- package/src/og/entity/LabelHandler.js +6 -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 +94 -70
- package/src/og/layer/Material.js +109 -109
- package/src/og/layer/Vector.js +81 -14
- package/src/og/layer/XYZ.js +23 -11
- package/src/og/light/LightSource.js +364 -363
- package/src/og/math/Vec3.js +1 -1
- package/src/og/math.js +6 -6
- package/src/og/quadTree/Node.js +8 -6
- package/src/og/renderer/Renderer.js +2 -3
- package/src/og/res/images.js +0 -2
- package/src/og/scene/Planet.js +106 -44
- package/src/og/segment/Segment.js +34 -64
- package/src/og/segment/Slice.js +1 -1
- package/src/og/shaders/drawnode.js +1 -1
- package/src/og/shaders/label.js +30 -42
- 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/FontAtlas.js +1 -2
- package/src/og/utils/GeoImageCreator.js +164 -161
- package/src/og/utils/Loader.js +187 -153
- 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/VectorTileCreator.js +1 -1
- package/src/og/utils/functionComposition.js +13 -0
- package/src/og/webgl/Handler.js +42 -41
- package/src/og/webgl/ProgramController.js +143 -143
- package/types/Object3d.d.ts +22 -0
- package/types/arial.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 +2 -1
- package/types/control/TouchNavigation.d.ts +1 -0
- package/types/control/UIhelpers.d.ts +13 -0
- package/types/control/index.d.ts +3 -1
- package/types/control/ruler/Ruler.d.ts +13 -0
- package/types/control/ruler/RulerScene.d.ts +48 -0
- package/types/ellipsoid/Ellipsoid.d.ts +8 -0
- 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 +28 -32
- package/types/layer/Vector.d.ts +9 -0
- package/types/layer/WMS.d.ts +1 -0
- package/types/layer/XYZ.d.ts +8 -5
- package/types/math.d.ts +2 -2
- 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/res/images.d.ts +0 -1
- package/types/scene/Planet.d.ts +21 -6
- 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 +4 -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/Layer.js
CHANGED
|
@@ -12,7 +12,7 @@ import { LonLat } from "../LonLat.js";
|
|
|
12
12
|
import { Material } from "./Material.js";
|
|
13
13
|
import { Vec3 } from "../math/Vec3.js";
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const FADING_RATIO = 15.8;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @classdesc
|
|
@@ -27,6 +27,7 @@ export const FADING_FACTOR = 0.29;
|
|
|
27
27
|
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
28
28
|
* @param {boolean} [options.isBaseLayer=false] - This is a base layer.
|
|
29
29
|
* @param {boolean} [options.visibility=true] - Layer visibility.
|
|
30
|
+
* @param {boolean} [options.displayInLayerSwitcher=true] - Presence of layer in dialog window of LayerSwitcher control.
|
|
30
31
|
* @param {boolean} [options.isSRGB=false] - Layer image webgl nternal format.
|
|
31
32
|
* @param {Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
|
|
32
33
|
* @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
|
|
@@ -34,29 +35,29 @@ export const FADING_FACTOR = 0.29;
|
|
|
34
35
|
* @fires og.Layer#visibilitychange
|
|
35
36
|
* @fires og.Layer#add
|
|
36
37
|
* @fires og.Layer#remove
|
|
37
|
-
* @fires og.layer.
|
|
38
|
-
* @fires og.layer.
|
|
39
|
-
* @fires og.layer.
|
|
40
|
-
* @fires og.layer.
|
|
41
|
-
* @fires og.layer.
|
|
42
|
-
* @fires og.layer.
|
|
43
|
-
* @fires og.layer.
|
|
44
|
-
* @fires og.layer.
|
|
45
|
-
* @fires og.layer.
|
|
46
|
-
* @fires og.layer.
|
|
47
|
-
* @fires og.layer.
|
|
48
|
-
* @fires og.layer.
|
|
49
|
-
* @fires og.layer.
|
|
50
|
-
* @fires og.layer.
|
|
51
|
-
* @fires og.layer.
|
|
52
|
-
* @fires og.layer.
|
|
53
|
-
* @fires og.layer.
|
|
54
|
-
* @fires og.layer.
|
|
55
|
-
* @fires og.layer.
|
|
56
|
-
* @fires og.layer.
|
|
57
|
-
* @fires og.layer.
|
|
58
|
-
* @fires og.layer.
|
|
59
|
-
* @fires og.layer.
|
|
38
|
+
* @fires og.layer.Layer#mousemove
|
|
39
|
+
* @fires og.layer.Layer#mouseenter
|
|
40
|
+
* @fires og.layer.Layer#mouseleave
|
|
41
|
+
* @fires og.layer.Layer#lclick
|
|
42
|
+
* @fires og.layer.Layer#rclick
|
|
43
|
+
* @fires og.layer.Layer#mclick
|
|
44
|
+
* @fires og.layer.Layer#ldblclick
|
|
45
|
+
* @fires og.layer.Layer#rdblclick
|
|
46
|
+
* @fires og.layer.Layer#mdblclick
|
|
47
|
+
* @fires og.layer.Layer#lup
|
|
48
|
+
* @fires og.layer.Layer#rup
|
|
49
|
+
* @fires og.layer.Layer#mup
|
|
50
|
+
* @fires og.layer.Layer#ldown
|
|
51
|
+
* @fires og.layer.Layer#rdown
|
|
52
|
+
* @fires og.layer.Layer#mdown
|
|
53
|
+
* @fires og.layer.Layer#lhold
|
|
54
|
+
* @fires og.layer.Layer#rhold
|
|
55
|
+
* @fires og.layer.Layer#mhold
|
|
56
|
+
* @fires og.layer.Layer#mousewheel
|
|
57
|
+
* @fires og.layer.Layer#touchmove
|
|
58
|
+
* @fires og.layer.Layer#touchstart
|
|
59
|
+
* @fires og.layer.Layer#touchend
|
|
60
|
+
* @fires og.layer.Layer#doubletouch
|
|
60
61
|
*/
|
|
61
62
|
class Layer {
|
|
62
63
|
constructor(name, options = {}) {
|
|
@@ -67,6 +68,8 @@ class Layer {
|
|
|
67
68
|
*/
|
|
68
69
|
this.name = name || "noname";
|
|
69
70
|
|
|
71
|
+
this.properties = options.properties || {};
|
|
72
|
+
|
|
70
73
|
this._labelMaxLetters = options.labelMaxLetters;
|
|
71
74
|
|
|
72
75
|
this.displayInLayerSwitcher =
|
|
@@ -141,7 +144,7 @@ class Layer {
|
|
|
141
144
|
|
|
142
145
|
this._fading = options.fading || false;
|
|
143
146
|
|
|
144
|
-
this._fadingFactor =
|
|
147
|
+
this._fadingFactor = this._opacity / FADING_RATIO;
|
|
145
148
|
|
|
146
149
|
if (this._fading) {
|
|
147
150
|
this._fadingOpacity = this._visibility ? this._opacity : 0.0;
|
|
@@ -204,7 +207,7 @@ class Layer {
|
|
|
204
207
|
* @public
|
|
205
208
|
* @type {Events}
|
|
206
209
|
*/
|
|
207
|
-
this.events = new Events(EVENT_NAMES, this);
|
|
210
|
+
this.events = new Events(options.events ? [...EVENT_NAMES, ...options.events] : EVENT_NAMES, this);
|
|
208
211
|
}
|
|
209
212
|
|
|
210
213
|
static getTMS(x, y, z) {
|
|
@@ -230,23 +233,6 @@ class Layer {
|
|
|
230
233
|
this.__lcounter = n;
|
|
231
234
|
}
|
|
232
235
|
|
|
233
|
-
static get __requestsCounter() {
|
|
234
|
-
return this.__reqcounter;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
static set __requestsCounter(v) {
|
|
238
|
-
this.__reqcounter = v;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Maximum loading queries at one time.
|
|
243
|
-
* @const
|
|
244
|
-
* @type {number}
|
|
245
|
-
*/
|
|
246
|
-
static get MAX_REQUESTS() {
|
|
247
|
-
return 7;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
236
|
get instanceName() {
|
|
251
237
|
return "Layer";
|
|
252
238
|
}
|
|
@@ -256,20 +242,18 @@ class Layer {
|
|
|
256
242
|
}
|
|
257
243
|
|
|
258
244
|
set opacity(opacity) {
|
|
259
|
-
if (this.
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
245
|
+
if (opacity !== this._opacity) {
|
|
246
|
+
if (this._fading) {
|
|
247
|
+
if (opacity > this._opacity) {
|
|
248
|
+
this._fadingFactor = (opacity - this._opacity) / FADING_RATIO;
|
|
249
|
+
} else if (opacity < this._opacity) {
|
|
250
|
+
this._fadingFactor = (opacity - this._opacity) / FADING_RATIO;
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
this._fadingOpacity = opacity;
|
|
264
254
|
}
|
|
265
|
-
|
|
266
|
-
this._fadingOpacity = opacity;
|
|
255
|
+
this._opacity = opacity;
|
|
267
256
|
}
|
|
268
|
-
this._opacity = opacity;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
get opacity() {
|
|
272
|
-
return this._opacity;
|
|
273
257
|
}
|
|
274
258
|
|
|
275
259
|
set pickingEnabled(picking) {
|
|
@@ -306,7 +290,7 @@ class Layer {
|
|
|
306
290
|
* @returns {boolean} - Returns true if the layers is the same instance of the input.
|
|
307
291
|
*/
|
|
308
292
|
isEqual(layer) {
|
|
309
|
-
return layer._id === this._id;
|
|
293
|
+
return layer && (layer._id === this._id);
|
|
310
294
|
}
|
|
311
295
|
|
|
312
296
|
/**
|
|
@@ -325,7 +309,9 @@ class Layer {
|
|
|
325
309
|
|
|
326
310
|
this.createTexture = planet.renderer.handler.createTexture[this._textureFilter];
|
|
327
311
|
|
|
328
|
-
planet
|
|
312
|
+
// TODO: replace to planet
|
|
313
|
+
planet._layers.push(this);
|
|
314
|
+
|
|
329
315
|
this._planet = planet;
|
|
330
316
|
this.events.on("visibilitychange", planet._onLayerVisibilityChanged, planet);
|
|
331
317
|
if (this._isBaseLayer && this._visibility) {
|
|
@@ -342,6 +328,10 @@ class Layer {
|
|
|
342
328
|
this._bindPicking();
|
|
343
329
|
}
|
|
344
330
|
|
|
331
|
+
get isIdle() {
|
|
332
|
+
return this._planet && this._planet._terrainCompletedActivated;
|
|
333
|
+
}
|
|
334
|
+
|
|
345
335
|
/**
|
|
346
336
|
* Assign picking color to the layer.
|
|
347
337
|
* @protected
|
|
@@ -369,17 +359,20 @@ class Layer {
|
|
|
369
359
|
* @returns {Layer} -This layer.
|
|
370
360
|
*/
|
|
371
361
|
remove() {
|
|
372
|
-
|
|
362
|
+
let p = this._planet;
|
|
373
363
|
if (p) {
|
|
374
|
-
|
|
375
|
-
|
|
364
|
+
//TODO: replace to planet
|
|
365
|
+
for (let i = 0; i < p._layers.length; i++) {
|
|
366
|
+
if (this.isEqual(p._layers[i])) {
|
|
376
367
|
p.renderer.clearPickingColor(this);
|
|
377
|
-
p.
|
|
368
|
+
p._layers.splice(i, 1);
|
|
378
369
|
p.updateVisibleLayers();
|
|
379
370
|
this.clear();
|
|
380
371
|
p.events.dispatch(p.events.layerremove, this);
|
|
381
372
|
this.events.dispatch(this.events.remove, p);
|
|
382
373
|
this._planet = null;
|
|
374
|
+
this._internalFormat = null;
|
|
375
|
+
this.createTexture = null;
|
|
383
376
|
return this;
|
|
384
377
|
}
|
|
385
378
|
}
|
|
@@ -394,8 +387,6 @@ class Layer {
|
|
|
394
387
|
clear() {
|
|
395
388
|
if (this._planet) {
|
|
396
389
|
this._planet._clearLayerMaterial(this);
|
|
397
|
-
this._internalFormat = null;
|
|
398
|
-
this.createTexture = null;
|
|
399
390
|
}
|
|
400
391
|
}
|
|
401
392
|
|
|
@@ -530,7 +521,7 @@ class Layer {
|
|
|
530
521
|
this._planet._renderCompleted = false;
|
|
531
522
|
}
|
|
532
523
|
|
|
533
|
-
this.applyMaterial(m);
|
|
524
|
+
this.applyMaterial(m, true);
|
|
534
525
|
}
|
|
535
526
|
|
|
536
527
|
_preLoadRecursive(node, maxZoom) {
|
|
@@ -620,6 +611,14 @@ class Layer {
|
|
|
620
611
|
// }
|
|
621
612
|
}
|
|
622
613
|
|
|
614
|
+
get opacity() {
|
|
615
|
+
return this._opacity;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
get screenOpacity() {
|
|
619
|
+
return this._fading ? this._fadingOpacity : this._opacity;
|
|
620
|
+
}
|
|
621
|
+
|
|
623
622
|
_refreshFadingOpacity() {
|
|
624
623
|
var p = this._planet;
|
|
625
624
|
if (
|
|
@@ -637,20 +636,45 @@ class Layer {
|
|
|
637
636
|
) {
|
|
638
637
|
this._fadingOpacity = this._opacity;
|
|
639
638
|
}
|
|
639
|
+
|
|
640
640
|
return false;
|
|
641
641
|
} else {
|
|
642
|
-
this._fadingOpacity -=
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}
|
|
642
|
+
//this._fadingOpacity -= this._opacity / FADING_RATIO;
|
|
643
|
+
//if (this._fadingOpacity < 0.0) {
|
|
644
|
+
this._fadingOpacity = 0.0;
|
|
645
|
+
//}
|
|
646
|
+
return !this._visibility;
|
|
648
647
|
}
|
|
649
648
|
}
|
|
650
649
|
|
|
651
650
|
createMaterial(segment) {
|
|
652
651
|
return new Material(segment, this);
|
|
653
652
|
}
|
|
653
|
+
|
|
654
|
+
redraw() {
|
|
655
|
+
if (this._planet) {
|
|
656
|
+
this._planet._quadTree.traverseTree((n) => {
|
|
657
|
+
if (n.segment.materials[this._id]) {
|
|
658
|
+
n.segment.materials[this._id].clear();
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
|
|
663
|
+
this._planet._quadTreeNorth.traverseTree((n) => {
|
|
664
|
+
if (n.segment.materials[this._id]) {
|
|
665
|
+
n.segment.materials[this._id].clear();
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
|
|
670
|
+
this._planet._quadTreeSouth.traverseTree((n) => {
|
|
671
|
+
if (n.segment.materials[this._id]) {
|
|
672
|
+
n.segment.materials[this._id].clear();
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
654
678
|
}
|
|
655
679
|
|
|
656
680
|
const EVENT_NAMES = [
|
package/src/og/layer/Material.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/layer/Material
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
class Material {
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {*} segment
|
|
11
|
-
* @param {*} layer
|
|
12
|
-
*/
|
|
13
|
-
constructor(segment, layer) {
|
|
14
|
-
this.segment = segment;
|
|
15
|
-
this.layer = layer;
|
|
16
|
-
this.isReady = false;
|
|
17
|
-
this.isLoading = false;
|
|
18
|
-
this.texture = null;
|
|
19
|
-
this.pickingMask = null;
|
|
20
|
-
//this.image = null;
|
|
21
|
-
this.textureExists = false;
|
|
22
|
-
this.appliedNodeId = 0;
|
|
23
|
-
this.texOffset = [0.0, 0.0, 1.0, 1.0];
|
|
24
|
-
this.loadingAttempts = 0;
|
|
25
|
-
|
|
26
|
-
// vector data
|
|
27
|
-
this._updateTexture = null;
|
|
28
|
-
this._updatePickingMask = null;
|
|
29
|
-
this.pickingReady = false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
///**
|
|
33
|
-
// * @param {*} layer
|
|
34
|
-
// */
|
|
35
|
-
//assignLayer(layer) {
|
|
36
|
-
// this.layer = layer;
|
|
37
|
-
//}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
abortLoading() {
|
|
43
|
-
this.layer.abortMaterialLoading(this);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
_createTexture(img) {
|
|
47
|
-
return this.layer.createTexture(img, this.layer._internalFormat);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param {*} img
|
|
53
|
-
*/
|
|
54
|
-
applyImage(img) {
|
|
55
|
-
if (this.segment.initialized) {
|
|
56
|
-
this._updateTexture = null;
|
|
57
|
-
//this.image = img;
|
|
58
|
-
this.texture = this._createTexture(img);
|
|
59
|
-
this.appliedNodeId = this.segment.node.nodeId;
|
|
60
|
-
this.isReady = true;
|
|
61
|
-
this.pickingReady = true;
|
|
62
|
-
this.textureExists = true;
|
|
63
|
-
this.isLoading = false;
|
|
64
|
-
this.texOffset = [0.0, 0.0, 1.0, 1.0];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* @param {*} texture
|
|
71
|
-
* @param {*} pickingMask
|
|
72
|
-
*/
|
|
73
|
-
applyTexture(texture, pickingMask) {
|
|
74
|
-
if (this.segment.initialized) {
|
|
75
|
-
this.texture = texture;
|
|
76
|
-
this._updateTexture = null;
|
|
77
|
-
this.pickingMask = pickingMask || null;
|
|
78
|
-
this._updatePickingMask = null;
|
|
79
|
-
this.isReady = true;
|
|
80
|
-
this.pickingReady = true;
|
|
81
|
-
this.textureExists = true;
|
|
82
|
-
this.isLoading = false;
|
|
83
|
-
this.appliedNodeId = this.segment.node.nodeId;
|
|
84
|
-
this.texOffset = [0.0, 0.0, 1.0, 1.0];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
*/
|
|
91
|
-
textureNotExists() {
|
|
92
|
-
if (this.segment.initialized) {
|
|
93
|
-
this.pickingReady = true;
|
|
94
|
-
this.isLoading = false;
|
|
95
|
-
this.isReady = true;
|
|
96
|
-
this.textureExists = false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
clear() {
|
|
104
|
-
this.loadingAttempts = 0;
|
|
105
|
-
this.layer.clearMaterial(this);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export { Material };
|
|
1
|
+
/**
|
|
2
|
+
* @module og/layer/Material
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
class Material {
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {*} segment
|
|
11
|
+
* @param {*} layer
|
|
12
|
+
*/
|
|
13
|
+
constructor(segment, layer) {
|
|
14
|
+
this.segment = segment;
|
|
15
|
+
this.layer = layer;
|
|
16
|
+
this.isReady = false;
|
|
17
|
+
this.isLoading = false;
|
|
18
|
+
this.texture = null;
|
|
19
|
+
this.pickingMask = null;
|
|
20
|
+
//this.image = null;
|
|
21
|
+
this.textureExists = false;
|
|
22
|
+
this.appliedNodeId = 0;
|
|
23
|
+
this.texOffset = [0.0, 0.0, 1.0, 1.0];
|
|
24
|
+
this.loadingAttempts = 0;
|
|
25
|
+
|
|
26
|
+
// vector data
|
|
27
|
+
this._updateTexture = null;
|
|
28
|
+
this._updatePickingMask = null;
|
|
29
|
+
this.pickingReady = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
///**
|
|
33
|
+
// * @param {*} layer
|
|
34
|
+
// */
|
|
35
|
+
//assignLayer(layer) {
|
|
36
|
+
// this.layer = layer;
|
|
37
|
+
//}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
abortLoading() {
|
|
43
|
+
this.layer.abortMaterialLoading(this);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_createTexture(img) {
|
|
47
|
+
return this.layer._planet && this.layer.createTexture(img, this.layer._internalFormat);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {*} img
|
|
53
|
+
*/
|
|
54
|
+
applyImage(img) {
|
|
55
|
+
if (this.segment.initialized) {
|
|
56
|
+
this._updateTexture = null;
|
|
57
|
+
//this.image = img;
|
|
58
|
+
this.texture = this._createTexture(img);
|
|
59
|
+
this.appliedNodeId = this.segment.node.nodeId;
|
|
60
|
+
this.isReady = true;
|
|
61
|
+
this.pickingReady = true;
|
|
62
|
+
this.textureExists = true;
|
|
63
|
+
this.isLoading = false;
|
|
64
|
+
this.texOffset = [0.0, 0.0, 1.0, 1.0];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param {*} texture
|
|
71
|
+
* @param {*} pickingMask
|
|
72
|
+
*/
|
|
73
|
+
applyTexture(texture, pickingMask) {
|
|
74
|
+
if (this.segment.initialized) {
|
|
75
|
+
this.texture = texture;
|
|
76
|
+
this._updateTexture = null;
|
|
77
|
+
this.pickingMask = pickingMask || null;
|
|
78
|
+
this._updatePickingMask = null;
|
|
79
|
+
this.isReady = true;
|
|
80
|
+
this.pickingReady = true;
|
|
81
|
+
this.textureExists = true;
|
|
82
|
+
this.isLoading = false;
|
|
83
|
+
this.appliedNodeId = this.segment.node.nodeId;
|
|
84
|
+
this.texOffset = [0.0, 0.0, 1.0, 1.0];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
textureNotExists() {
|
|
92
|
+
if (this.segment.initialized) {
|
|
93
|
+
this.pickingReady = true;
|
|
94
|
+
this.isLoading = false;
|
|
95
|
+
this.isReady = true;
|
|
96
|
+
this.textureExists = false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
clear() {
|
|
104
|
+
this.loadingAttempts = 0;
|
|
105
|
+
this.layer.clearMaterial(this);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { Material };
|
package/src/og/layer/Vector.js
CHANGED
|
@@ -83,6 +83,7 @@ class Vector extends Layer {
|
|
|
83
83
|
|
|
84
84
|
this._hasImageryTiles = false;
|
|
85
85
|
|
|
86
|
+
|
|
86
87
|
/**
|
|
87
88
|
* First index - near distance to the entity, after that entity becomes full scale.
|
|
88
89
|
* Second index - far distance to the entity, when entity becomes zero scale.
|
|
@@ -137,6 +138,11 @@ class Vector extends Layer {
|
|
|
137
138
|
});
|
|
138
139
|
this._bindEventsDefault(this._polylineEntityCollection);
|
|
139
140
|
|
|
141
|
+
this._geoObjectEntityCollection = new EntityCollection({
|
|
142
|
+
pickingEnabled: this.pickingEnabled
|
|
143
|
+
});
|
|
144
|
+
this._bindEventsDefault(this._geoObjectEntityCollection);
|
|
145
|
+
|
|
140
146
|
this._geometryHandler = new GeometryHandler(this);
|
|
141
147
|
|
|
142
148
|
this._entityCollectionsTree = null;
|
|
@@ -186,6 +192,7 @@ class Vector extends Layer {
|
|
|
186
192
|
this._geometryHandler.assignHandler(planet.renderer.handler);
|
|
187
193
|
this._polylineEntityCollection.addTo(planet, true);
|
|
188
194
|
this._stripEntityCollection.addTo(planet, true);
|
|
195
|
+
this._geoObjectEntityCollection.addTo(planet, true);
|
|
189
196
|
this.setEntities(this._entities);
|
|
190
197
|
}
|
|
191
198
|
return this;
|
|
@@ -285,6 +292,10 @@ class Vector extends Layer {
|
|
|
285
292
|
this._polylineEntityCollection.add(entity);
|
|
286
293
|
}
|
|
287
294
|
|
|
295
|
+
if (entity.geoObject) {
|
|
296
|
+
this._geoObjectEntityCollection.add(entity);
|
|
297
|
+
}
|
|
298
|
+
|
|
288
299
|
if (entity.geometry) {
|
|
289
300
|
this._hasImageryTiles = true;
|
|
290
301
|
if (this._planet) {
|
|
@@ -412,20 +423,22 @@ class Vector extends Layer {
|
|
|
412
423
|
|
|
413
424
|
this._polylineEntityCollection.setPickingEnabled(picking);
|
|
414
425
|
|
|
426
|
+
this._geoObjectEntityCollection.setPickingEnabled(picking);
|
|
427
|
+
|
|
415
428
|
this._entityCollectionsTree &&
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
429
|
+
this._entityCollectionsTree.traverseTree(function (node) {
|
|
430
|
+
node.entityCollection.setPickingEnabled(picking);
|
|
431
|
+
});
|
|
419
432
|
|
|
420
433
|
this._entityCollectionsTreeNorth &&
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
434
|
+
this._entityCollectionsTreeNorth.traverseTree(function (node) {
|
|
435
|
+
node.entityCollection.setPickingEnabled(picking);
|
|
436
|
+
});
|
|
424
437
|
|
|
425
438
|
this._entityCollectionsTreeSouth &&
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
439
|
+
this._entityCollectionsTreeSouth.traverseTree(function (node) {
|
|
440
|
+
node.entityCollection.setPickingEnabled(picking);
|
|
441
|
+
});
|
|
429
442
|
}
|
|
430
443
|
|
|
431
444
|
/**
|
|
@@ -527,10 +540,10 @@ class Vector extends Layer {
|
|
|
527
540
|
|
|
528
541
|
this._entities = new Array(temp.length);
|
|
529
542
|
|
|
530
|
-
|
|
543
|
+
let entitiesForTree = [];
|
|
531
544
|
|
|
532
|
-
for (
|
|
533
|
-
|
|
545
|
+
for (let i = 0; i < temp.length; i++) {
|
|
546
|
+
let ei = temp[i];
|
|
534
547
|
|
|
535
548
|
ei._layer = this;
|
|
536
549
|
ei._layerIndex = i;
|
|
@@ -539,6 +552,8 @@ class Vector extends Layer {
|
|
|
539
552
|
this._stripEntityCollection.add(ei);
|
|
540
553
|
} else if (ei.polyline || ei.ray) {
|
|
541
554
|
this._polylineEntityCollection.add(ei);
|
|
555
|
+
} else if (ei.geoObject) {
|
|
556
|
+
this._geoObjectEntityCollection.add(ei);
|
|
542
557
|
} else if (ei.billboard || ei.label || ei.shape) {
|
|
543
558
|
entitiesForTree.push(ei);
|
|
544
559
|
}
|
|
@@ -711,7 +726,7 @@ class Vector extends Layer {
|
|
|
711
726
|
}
|
|
712
727
|
|
|
713
728
|
_collectPolylineCollectionPASS(outArr) {
|
|
714
|
-
|
|
729
|
+
let ec = this._polylineEntityCollection;
|
|
715
730
|
|
|
716
731
|
ec._fadingOpacity = this._fadingOpacity;
|
|
717
732
|
ec.scaleByDistance = this.scaleByDistance;
|
|
@@ -762,6 +777,58 @@ class Vector extends Layer {
|
|
|
762
777
|
}
|
|
763
778
|
}
|
|
764
779
|
|
|
780
|
+
_collectGeoObjectCollectionPASS(outArr) {
|
|
781
|
+
let ec = this._geoObjectEntityCollection;
|
|
782
|
+
|
|
783
|
+
ec._fadingOpacity = this._fadingOpacity;
|
|
784
|
+
ec.scaleByDistance = this.scaleByDistance;
|
|
785
|
+
ec.pickingScale = this.pickingScale;
|
|
786
|
+
ec.polygonOffsetUnits = this.polygonOffsetUnits;
|
|
787
|
+
|
|
788
|
+
outArr.push(ec);
|
|
789
|
+
|
|
790
|
+
// if (this.clampToGround || this.relativeToGround) {
|
|
791
|
+
// let rtg = Number(this.relativeToGround);
|
|
792
|
+
//
|
|
793
|
+
// var nodes = this._planet._renderedNodes;
|
|
794
|
+
// var visibleExtent = this._planet.getViewExtent();
|
|
795
|
+
// var e = ec._entities;
|
|
796
|
+
// var e_i = e.length;
|
|
797
|
+
// let res = new Vec3();
|
|
798
|
+
//
|
|
799
|
+
// while (e_i--) {
|
|
800
|
+
// var p = e[e_i].polyline;
|
|
801
|
+
// if (visibleExtent.overlaps(p._extent)) {
|
|
802
|
+
// // TODO:this works only for mercator area.
|
|
803
|
+
// // needs to be working on poles.
|
|
804
|
+
// let coords = p._pathLonLatMerc,
|
|
805
|
+
// c_j = coords.length;
|
|
806
|
+
// while (c_j--) {
|
|
807
|
+
// var c_j_h = coords[c_j].length;
|
|
808
|
+
// while (c_j_h--) {
|
|
809
|
+
// let ll = coords[c_j][c_j_h],
|
|
810
|
+
// n_k = nodes.length;
|
|
811
|
+
// while (n_k--) {
|
|
812
|
+
// var seg = nodes[n_k].segment;
|
|
813
|
+
// if (seg._extent.isInside(ll)) {
|
|
814
|
+
// let cart = p._path3v[c_j][c_j_h];
|
|
815
|
+
// seg.getTerrainPoint(cart, ll, res);
|
|
816
|
+
// p.setPoint3v(
|
|
817
|
+
// res.addA(res.normal().scale((rtg && p.altitude) || 0.0)),
|
|
818
|
+
// c_j_h,
|
|
819
|
+
// c_j,
|
|
820
|
+
// true
|
|
821
|
+
// );
|
|
822
|
+
// break;
|
|
823
|
+
// }
|
|
824
|
+
// }
|
|
825
|
+
// }
|
|
826
|
+
// }
|
|
827
|
+
// }
|
|
828
|
+
// }
|
|
829
|
+
// }
|
|
830
|
+
}
|
|
831
|
+
|
|
765
832
|
collectVisibleCollections(outArr) {
|
|
766
833
|
var p = this._planet;
|
|
767
834
|
|
|
@@ -775,8 +842,8 @@ class Vector extends Layer {
|
|
|
775
842
|
|
|
776
843
|
// Common collections first
|
|
777
844
|
this._collectStripCollectionPASS(outArr);
|
|
778
|
-
|
|
779
845
|
this._collectPolylineCollectionPASS(outArr);
|
|
846
|
+
this._collectGeoObjectCollectionPASS(outArr);
|
|
780
847
|
|
|
781
848
|
// Merc nodes
|
|
782
849
|
this._secondPASS = [];
|