@openglobus/og 0.12.3 → 0.13.1
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 +0 -2
- 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 +7 -7
- package/src/og/Extent.js +3 -3
- package/src/og/Globe.js +277 -275
- package/src/og/ImageCanvas.js +3 -3
- package/src/og/LonLat.js +9 -9
- package/src/og/QueueArray.js +2 -2
- package/src/og/Rectangle.js +5 -5
- package/src/og/bv/Box.js +1 -1
- package/src/og/bv/Sphere.js +2 -2
- package/src/og/camera/Camera.js +1 -1
- package/src/og/camera/PlanetCamera.js +649 -646
- package/src/og/control/LayerSwitcher.js +1 -1
- package/src/og/control/MouseNavigation.js +22 -13
- package/src/og/control/MouseWheelZoomControl.js +2 -2
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/TouchNavigation.js +319 -319
- package/src/og/control/ZoomControl.js +132 -132
- package/src/og/control/visibleExtent/Segment.js +12 -12
- package/src/og/ellipsoid/Ellipsoid.js +577 -567
- package/src/og/entity/BillboardHandler.js +878 -1051
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/EntityCollection.js +847 -857
- package/src/og/entity/GeoObjectHandler.js +2 -2
- package/src/og/entity/LabelHandler.js +888 -1040
- package/src/og/entity/LabelWorker.js +0 -6
- package/src/og/entity/PointCloud.js +495 -495
- package/src/og/entity/Polyline.js +2218 -2222
- package/src/og/entity/RayHandler.js +1 -1
- package/src/og/layer/CanvasTiles.js +6 -3
- package/src/og/layer/GeoImage.js +1 -1
- package/src/og/layer/KML.js +5 -5
- package/src/og/layer/Layer.js +804 -752
- package/src/og/layer/Vector.js +997 -1010
- package/src/og/layer/XYZ.js +359 -357
- package/src/og/math/Line2.js +4 -4
- package/src/og/math/Quat.js +2 -2
- package/src/og/math/Ray.js +2 -2
- package/src/og/math/Vec2.js +524 -524
- package/src/og/math/Vec3.js +900 -900
- package/src/og/math/Vec4.js +261 -261
- package/src/og/math.js +397 -398
- package/src/og/quadTree/EntityCollectionNode.js +389 -387
- package/src/og/renderer/Renderer.js +14 -20
- package/src/og/renderer/RendererEvents.js +1034 -1045
- package/src/og/scene/Planet.js +12 -9
- package/src/og/scene/RenderNode.js +347 -354
- package/src/og/segment/Segment.js +3 -1
- package/src/og/segment/SegmentLonLat.js +1 -4
- package/src/og/shaders/billboard.js +220 -204
- package/src/og/shaders/drawnode.js +603 -603
- package/src/og/shaders/label.js +595 -456
- package/src/og/shaders/polyline.js +365 -361
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/FontAtlas.js +209 -200
- package/src/og/utils/GeoImageCreator.js +4 -5
- package/src/og/utils/TextureAtlas.js +4 -4
- package/src/og/utils/VectorTileCreator.js +414 -414
- package/src/og/utils/shared.js +1 -1
- package/src/og/webgl/Handler.js +28 -60
- package/src/og/webgl/Multisample.js +260 -260
- package/src/og/webgl/Program.js +411 -396
- package/types/bv/Box.d.ts +1 -1
- package/types/bv/Sphere.d.ts +1 -1
- package/types/camera/PlanetCamera.d.ts +3 -3
- package/types/control/LayerSwitcher.d.ts +1 -1
- package/types/ellipsoid/Ellipsoid.d.ts +9 -2
- package/types/entity/BillboardHandler.d.ts +0 -4
- package/types/entity/EntityCollection.d.ts +0 -8
- package/types/entity/LabelHandler.d.ts +0 -2
- package/types/entity/Polyline.d.ts +1 -1
- package/types/layer/KML.d.ts +11 -11
- package/types/layer/Layer.d.ts +5 -0
- package/types/layer/Vector.d.ts +1 -8
- package/types/math/Line2.d.ts +4 -4
- package/types/math/Ray.d.ts +2 -2
- package/types/math/Vec2.d.ts +1 -1
- package/types/math/Vec3.d.ts +1 -1
- package/types/math/Vec4.d.ts +2 -2
- package/types/math.d.ts +1 -1
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +1 -1
- package/types/shaders/label.d.ts +1 -1
- package/types/utils/FontAtlas.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +3 -3
- package/types/utils/VectorTileCreator.d.ts +4 -4
- package/types/utils/shared.d.ts +1 -1
- package/types/webgl/Handler.d.ts +6 -31
- package/types/webgl/Program.d.ts +2 -0
package/src/og/layer/Vector.js
CHANGED
|
@@ -1,1010 +1,997 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/layer/Vector
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import * as math from "../math.js";
|
|
8
|
-
import * as mercator from "../mercator.js";
|
|
9
|
-
import * as quadTree from "../quadTree/quadTree.js";
|
|
10
|
-
import { Entity } from "../entity/Entity.js";
|
|
11
|
-
import { EntityCollection } from "../entity/EntityCollection.js";
|
|
12
|
-
import { Extent } from "../Extent.js";
|
|
13
|
-
import {
|
|
14
|
-
EntityCollectionNode,
|
|
15
|
-
EntityCollectionNodeWGS84
|
|
16
|
-
} from "../quadTree/EntityCollectionNode.js";
|
|
17
|
-
import { GeometryHandler } from "../entity/GeometryHandler.js";
|
|
18
|
-
import { Layer } from "./Layer.js";
|
|
19
|
-
import { QueueArray } from "../QueueArray.js";
|
|
20
|
-
import { Vec3 } from "../math/Vec3.js";
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Creates entity instance array.
|
|
24
|
-
* @param {Entity[]} entities - Entity array.
|
|
25
|
-
* @returns {Entity[]} - Entity array.
|
|
26
|
-
*/
|
|
27
|
-
function _entitiesConstructor(entities) {
|
|
28
|
-
var res = [];
|
|
29
|
-
for (var i = 0; i < entities.length; i++) {
|
|
30
|
-
var ei = entities[i];
|
|
31
|
-
if (ei.instanceName === "Entity") {
|
|
32
|
-
res.push(ei);
|
|
33
|
-
} else {
|
|
34
|
-
res.push(new Entity(ei));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return res;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Vector layer represents alternative entities store. Used for geospatial data rendering like
|
|
42
|
-
* points, lines, polygons, geometry objects etc.
|
|
43
|
-
* @class
|
|
44
|
-
* @extends {Layer}
|
|
45
|
-
* @param {string} [name="noname"] - Layer name.
|
|
46
|
-
* @param {Object} [options] - Layer options:
|
|
47
|
-
* @param {number} [options.minZoom=0] - Minimal visible zoom. 0 is default
|
|
48
|
-
* @param {number} [options.maxZoom=50] - Maximal visible zoom. 50 is default.
|
|
49
|
-
* @param {string} [options.attribution] - Layer attribution.
|
|
50
|
-
* @param {string} [options.zIndex=0] - Layer Z-order index. 0 is default.
|
|
51
|
-
* @param {boolean} [options.visibility=true] - Layer visibility. True is default.
|
|
52
|
-
* @param {boolean} [options.isBaseLayer=false] - Layer base layer. False is default.
|
|
53
|
-
* @param {Array.<Entity>} [options.entities] - Entities array.
|
|
54
|
-
* @param {Array.<number>} [options.scaleByDistance] - Scale by distance parameters. (exactly 3 entries)
|
|
55
|
-
* First index - near distance to the entity, after entity becomes full scale.
|
|
56
|
-
* Second index - far distance to the entity, when entity becomes zero scale.
|
|
57
|
-
* Third index - far distance to the entity, when entity becomes invisible.
|
|
58
|
-
* @param {number} [options.nodeCapacity=30] - Maximum entities quantity in the tree node. Rendering optimization parameter. 30 is default.
|
|
59
|
-
* @param {boolean} [options.async=true] - Asynchronous vector data handling before rendering. True for optimization huge data.
|
|
60
|
-
* @param {boolean} [options.clampToGround = false] - Clamp vector data to the ground.
|
|
61
|
-
* @param {boolean} [options.relativeToGround = false] - Place vector data relative to the ground relief.
|
|
62
|
-
* @param {Number} [options.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @fires og.layer.Vector#
|
|
66
|
-
* @fires og.layer.Vector#
|
|
67
|
-
* @fires og.layer.Vector#
|
|
68
|
-
* @fires og.layer.Vector#
|
|
69
|
-
* @fires og.layer.Vector#
|
|
70
|
-
* @fires og.layer.Vector#
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* @param {
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this.
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.
|
|
148
|
-
this.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
*
|
|
161
|
-
* @
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
|
|
225
|
-
// if (ee.
|
|
226
|
-
// e.
|
|
227
|
-
// }
|
|
228
|
-
//
|
|
229
|
-
//
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
this.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (entity.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
) {
|
|
378
|
-
entity.
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
this.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
this.
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
this.
|
|
580
|
-
this,
|
|
581
|
-
quadTree.NW,
|
|
582
|
-
null,
|
|
583
|
-
0,
|
|
584
|
-
Extent.createFromArray([-
|
|
585
|
-
this._planet,
|
|
586
|
-
0
|
|
587
|
-
);
|
|
588
|
-
this.
|
|
589
|
-
this,
|
|
590
|
-
quadTree.NW,
|
|
591
|
-
null,
|
|
592
|
-
0,
|
|
593
|
-
Extent.createFromArray([-180,
|
|
594
|
-
this._planet,
|
|
595
|
-
0
|
|
596
|
-
);
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
entityCollection.events.on("
|
|
629
|
-
ve.dispatch(ve.
|
|
630
|
-
});
|
|
631
|
-
entityCollection.events.on("
|
|
632
|
-
ve.dispatch(ve.
|
|
633
|
-
});
|
|
634
|
-
entityCollection.events.on("
|
|
635
|
-
ve.dispatch(ve.
|
|
636
|
-
});
|
|
637
|
-
entityCollection.events.on("
|
|
638
|
-
ve.dispatch(ve.
|
|
639
|
-
});
|
|
640
|
-
entityCollection.events.on("
|
|
641
|
-
ve.dispatch(ve.
|
|
642
|
-
});
|
|
643
|
-
entityCollection.events.on("
|
|
644
|
-
ve.dispatch(ve.
|
|
645
|
-
});
|
|
646
|
-
entityCollection.events.on("
|
|
647
|
-
ve.dispatch(ve.
|
|
648
|
-
});
|
|
649
|
-
entityCollection.events.on("
|
|
650
|
-
ve.dispatch(ve.
|
|
651
|
-
});
|
|
652
|
-
entityCollection.events.on("
|
|
653
|
-
ve.dispatch(ve.
|
|
654
|
-
});
|
|
655
|
-
entityCollection.events.on("
|
|
656
|
-
ve.dispatch(ve.
|
|
657
|
-
});
|
|
658
|
-
entityCollection.events.on("
|
|
659
|
-
ve.dispatch(ve.
|
|
660
|
-
});
|
|
661
|
-
entityCollection.events.on("
|
|
662
|
-
ve.dispatch(ve.
|
|
663
|
-
});
|
|
664
|
-
entityCollection.events.on("
|
|
665
|
-
ve.dispatch(ve.
|
|
666
|
-
});
|
|
667
|
-
entityCollection.events.on("
|
|
668
|
-
ve.dispatch(ve.
|
|
669
|
-
});
|
|
670
|
-
entityCollection.events.on("
|
|
671
|
-
ve.dispatch(ve.
|
|
672
|
-
});
|
|
673
|
-
entityCollection.events.on("
|
|
674
|
-
ve.dispatch(ve.
|
|
675
|
-
});
|
|
676
|
-
entityCollection.events.on("
|
|
677
|
-
ve.dispatch(ve.
|
|
678
|
-
});
|
|
679
|
-
entityCollection.events.on("
|
|
680
|
-
ve.dispatch(ve.
|
|
681
|
-
});
|
|
682
|
-
entityCollection.events.on("
|
|
683
|
-
ve.dispatch(ve.
|
|
684
|
-
});
|
|
685
|
-
entityCollection.events.on("
|
|
686
|
-
ve.dispatch(ve.
|
|
687
|
-
});
|
|
688
|
-
entityCollection.events.on("
|
|
689
|
-
ve.dispatch(ve.
|
|
690
|
-
});
|
|
691
|
-
entityCollection.events.on("
|
|
692
|
-
ve.dispatch(ve.
|
|
693
|
-
});
|
|
694
|
-
entityCollection.events.on("
|
|
695
|
-
ve.dispatch(ve.
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
ec.
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
this.
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
this.
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
node.
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
*
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
*
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
* Triggered when new entity added to the layer.
|
|
999
|
-
* @event og.layer.Vector#entityadd
|
|
1000
|
-
*/
|
|
1001
|
-
"entityadd",
|
|
1002
|
-
|
|
1003
|
-
/**
|
|
1004
|
-
* Triggered when entity removes from the collection.
|
|
1005
|
-
* @event og.layer.Vector#entityremove
|
|
1006
|
-
*/
|
|
1007
|
-
"entityremove"
|
|
1008
|
-
];
|
|
1009
|
-
|
|
1010
|
-
export { Vector };
|
|
1
|
+
/**
|
|
2
|
+
* @module og/layer/Vector
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as math from "../math.js";
|
|
8
|
+
import * as mercator from "../mercator.js";
|
|
9
|
+
import * as quadTree from "../quadTree/quadTree.js";
|
|
10
|
+
import { Entity } from "../entity/Entity.js";
|
|
11
|
+
import { EntityCollection } from "../entity/EntityCollection.js";
|
|
12
|
+
import { Extent } from "../Extent.js";
|
|
13
|
+
import {
|
|
14
|
+
EntityCollectionNode,
|
|
15
|
+
EntityCollectionNodeWGS84
|
|
16
|
+
} from "../quadTree/EntityCollectionNode.js";
|
|
17
|
+
import { GeometryHandler } from "../entity/GeometryHandler.js";
|
|
18
|
+
import { Layer } from "./Layer.js";
|
|
19
|
+
import { QueueArray } from "../QueueArray.js";
|
|
20
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates entity instance array.
|
|
24
|
+
* @param {Entity[]} entities - Entity array.
|
|
25
|
+
* @returns {Entity[]} - Entity array.
|
|
26
|
+
*/
|
|
27
|
+
function _entitiesConstructor(entities) {
|
|
28
|
+
var res = [];
|
|
29
|
+
for (var i = 0; i < entities.length; i++) {
|
|
30
|
+
var ei = entities[i];
|
|
31
|
+
if (ei.instanceName === "Entity") {
|
|
32
|
+
res.push(ei);
|
|
33
|
+
} else {
|
|
34
|
+
res.push(new Entity(ei));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Vector layer represents alternative entities store. Used for geospatial data rendering like
|
|
42
|
+
* points, lines, polygons, geometry objects etc.
|
|
43
|
+
* @class
|
|
44
|
+
* @extends {Layer}
|
|
45
|
+
* @param {string} [name="noname"] - Layer name.
|
|
46
|
+
* @param {Object} [options] - Layer options:
|
|
47
|
+
* @param {number} [options.minZoom=0] - Minimal visible zoom. 0 is default
|
|
48
|
+
* @param {number} [options.maxZoom=50] - Maximal visible zoom. 50 is default.
|
|
49
|
+
* @param {string} [options.attribution] - Layer attribution.
|
|
50
|
+
* @param {string} [options.zIndex=0] - Layer Z-order index. 0 is default.
|
|
51
|
+
* @param {boolean} [options.visibility=true] - Layer visibility. True is default.
|
|
52
|
+
* @param {boolean} [options.isBaseLayer=false] - Layer base layer. False is default.
|
|
53
|
+
* @param {Array.<Entity>} [options.entities] - Entities array.
|
|
54
|
+
* @param {Array.<number>} [options.scaleByDistance] - Scale by distance parameters. (exactly 3 entries)
|
|
55
|
+
* First index - near distance to the entity, after entity becomes full scale.
|
|
56
|
+
* Second index - far distance to the entity, when entity becomes zero scale.
|
|
57
|
+
* Third index - far distance to the entity, when entity becomes invisible.
|
|
58
|
+
* @param {number} [options.nodeCapacity=30] - Maximum entities quantity in the tree node. Rendering optimization parameter. 30 is default.
|
|
59
|
+
* @param {boolean} [options.async=true] - Asynchronous vector data handling before rendering. True for optimization huge data.
|
|
60
|
+
* @param {boolean} [options.clampToGround = false] - Clamp vector data to the ground.
|
|
61
|
+
* @param {boolean} [options.relativeToGround = false] - Place vector data relative to the ground relief.
|
|
62
|
+
* @param {Number} [options.polygonOffsetUnits=0.0] - The multiplier by which an implementation-specific value is multiplied with to create a constant depth offset.
|
|
63
|
+
*
|
|
64
|
+
* @fires og.layer.Vector#entitymove
|
|
65
|
+
* @fires og.layer.Vector#draw
|
|
66
|
+
* @fires og.layer.Vector#add
|
|
67
|
+
* @fires og.layer.Vector#remove
|
|
68
|
+
* @fires og.layer.Vector#entityadd
|
|
69
|
+
* @fires og.layer.Vector#entityremove
|
|
70
|
+
* @fires og.layer.Vector#visibilitychange
|
|
71
|
+
*/
|
|
72
|
+
class Vector extends Layer {
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} name
|
|
75
|
+
* @param {*} [options]
|
|
76
|
+
*/
|
|
77
|
+
constructor(name, options = {}) {
|
|
78
|
+
super(name, options);
|
|
79
|
+
|
|
80
|
+
this.events.registerNames(EVENT_NAMES);
|
|
81
|
+
|
|
82
|
+
this.isVector = true;
|
|
83
|
+
|
|
84
|
+
this._hasImageryTiles = false;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* First index - near distance to the entity, after that entity becomes full scale.
|
|
88
|
+
* Second index - far distance to the entity, when entity becomes zero scale.
|
|
89
|
+
* Third index - far distance to the entity, when entity becomes invisible.
|
|
90
|
+
* @public
|
|
91
|
+
* @type {Array.<number>} - (exactly 3 entries)
|
|
92
|
+
*/
|
|
93
|
+
this.scaleByDistance = options.scaleByDistance || [math.MAX32, math.MAX32, math.MAX32];
|
|
94
|
+
|
|
95
|
+
this.pickingScale = options.pickingScale || 1;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Asynchronous data handling before rendering.
|
|
99
|
+
* @public
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
*/
|
|
102
|
+
this.async = options.async !== undefined ? options.async : true;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Vector data clamp to ground flag.
|
|
106
|
+
* @public
|
|
107
|
+
* @type {boolean}
|
|
108
|
+
*/
|
|
109
|
+
this.clampToGround = options.clampToGround || false;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Sets vector data relative to the ground relief.
|
|
113
|
+
* @public
|
|
114
|
+
* @type {boolean}
|
|
115
|
+
*/
|
|
116
|
+
this.relativeToGround = options.relativeToGround || false;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Maximum entities quantity in the tree node.
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
this._nodeCapacity = options.nodeCapacity || 30;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Stored entities.
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
this._entities = _entitiesConstructor(options.entities || []);
|
|
129
|
+
|
|
130
|
+
this._stripEntityCollection = new EntityCollection({
|
|
131
|
+
pickingEnabled: this.pickingEnabled
|
|
132
|
+
});
|
|
133
|
+
this._bindEventsDefault(this._stripEntityCollection);
|
|
134
|
+
|
|
135
|
+
this._polylineEntityCollection = new EntityCollection({
|
|
136
|
+
pickingEnabled: this.pickingEnabled
|
|
137
|
+
});
|
|
138
|
+
this._bindEventsDefault(this._polylineEntityCollection);
|
|
139
|
+
|
|
140
|
+
this._geometryHandler = new GeometryHandler(this);
|
|
141
|
+
|
|
142
|
+
this._entityCollectionsTree = null;
|
|
143
|
+
this._entityCollectionsTreeNorth = null;
|
|
144
|
+
this._entityCollectionsTreeSouth = null;
|
|
145
|
+
|
|
146
|
+
this._renderingNodes = {};
|
|
147
|
+
this._renderingNodesNorth = {};
|
|
148
|
+
this._renderingNodesSouth = {};
|
|
149
|
+
|
|
150
|
+
this._counter = 0;
|
|
151
|
+
this._deferredEntitiesPendingQueue = new QueueArray();
|
|
152
|
+
|
|
153
|
+
this._pendingsQueue = [];
|
|
154
|
+
|
|
155
|
+
// Creates collections tree
|
|
156
|
+
this.setEntities(this._entities);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Specifies the scale Units for gl.polygonOffset function to calculate depth values, 0.0 is default.
|
|
160
|
+
* @public
|
|
161
|
+
* @type {Number}
|
|
162
|
+
*/
|
|
163
|
+
this.polygonOffsetUnits =
|
|
164
|
+
options.polygonOffsetUnits != undefined ? options.polygonOffsetUnits : 0.0;
|
|
165
|
+
|
|
166
|
+
this.pickingEnabled = this._pickingEnabled;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
get instanceName() {
|
|
170
|
+
return "Vector";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_bindPicking() {
|
|
174
|
+
this._pickingColor.clear();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Adds layer to the planet.
|
|
179
|
+
* @public
|
|
180
|
+
* @param {Planet} planet - Planet scene object.
|
|
181
|
+
* @returns {layer.Vector} -
|
|
182
|
+
*/
|
|
183
|
+
addTo(planet) {
|
|
184
|
+
if (!this._planet) {
|
|
185
|
+
this._assignPlanet(planet);
|
|
186
|
+
this._geometryHandler.assignHandler(planet.renderer.handler);
|
|
187
|
+
this._polylineEntityCollection.addTo(planet, true);
|
|
188
|
+
this._stripEntityCollection.addTo(planet, true);
|
|
189
|
+
this.setEntities(this._entities);
|
|
190
|
+
}
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Returns stored entities.
|
|
196
|
+
* @public
|
|
197
|
+
* @returns {Array.<Entity>} -
|
|
198
|
+
*/
|
|
199
|
+
getEntities() {
|
|
200
|
+
return [].concat(this._entities);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
//_fitExtent(entity) {
|
|
204
|
+
// var ee = entity.getExtent(),
|
|
205
|
+
// e = this._extent,
|
|
206
|
+
// maxLon = -180, maxLat = -90,
|
|
207
|
+
// minLon = 180, minLat = 90;
|
|
208
|
+
|
|
209
|
+
// if (this._entities.length !== 0) {
|
|
210
|
+
// maxLon = e.southWest.lon;
|
|
211
|
+
// minLon = e.northEast.lon;
|
|
212
|
+
// maxLat = e.northEast.lat;
|
|
213
|
+
// minLat = e.southWest.lat;
|
|
214
|
+
// }
|
|
215
|
+
|
|
216
|
+
// if (ee.southWest.lon < minLon) {
|
|
217
|
+
// e.southWest.lon = ee.southWest.lon;
|
|
218
|
+
// }
|
|
219
|
+
// if (ee.southWest.lat < minLat) {
|
|
220
|
+
// e.southWest.lat = ee.southWest.lat;
|
|
221
|
+
// }
|
|
222
|
+
// if (ee.northEast.lon > maxLon) {
|
|
223
|
+
// e.northEast.lon = ee.northEast.lon;
|
|
224
|
+
// }
|
|
225
|
+
// if (ee.northEast.lat > maxLat) {
|
|
226
|
+
// e.northEast.lat = ee.northEast.lat;
|
|
227
|
+
// }
|
|
228
|
+
// this.setExtent(this._extent);
|
|
229
|
+
//}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Adds entity to the layer.
|
|
233
|
+
* @public
|
|
234
|
+
* @param {Entity} entity - Entity.
|
|
235
|
+
* @param {boolean} [rightNow] - Entity insertion option. False is deafult.
|
|
236
|
+
* @returns {layer.Vector} - Returns this layer.
|
|
237
|
+
*/
|
|
238
|
+
add(entity, rightNow) {
|
|
239
|
+
if (!(entity._layer || entity._entityCollection)) {
|
|
240
|
+
entity._layer = this;
|
|
241
|
+
entity._layerIndex = this._entities.length;
|
|
242
|
+
//this._fitExtent(entity);
|
|
243
|
+
this._entities.push(entity);
|
|
244
|
+
this._proceedEntity(entity, rightNow);
|
|
245
|
+
}
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Adds entity to the layer in the index position.
|
|
251
|
+
* @public
|
|
252
|
+
* @param {Entity} entity - Entity.
|
|
253
|
+
* @param {Number} index - Index position.
|
|
254
|
+
* @param {boolean} [rightNow] - Entity insertion option. False is deafult.
|
|
255
|
+
* @returns {layer.Vector} - Returns this layer.
|
|
256
|
+
*/
|
|
257
|
+
insert(entity, index, rightNow) {
|
|
258
|
+
if (!(entity._layer || entity._entityCollection)) {
|
|
259
|
+
entity._layer = this;
|
|
260
|
+
entity._layerIndex = index;
|
|
261
|
+
//this._fitExtent(entity);
|
|
262
|
+
this._entities.splice(index, 0, entity);
|
|
263
|
+
for (let i = index + 1, len = this._entities.length; i < len; i++) {
|
|
264
|
+
this._entities[i]._layerIndex = i;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
this._proceedEntity(entity, rightNow);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
_proceedEntity(entity, rightNow) {
|
|
274
|
+
let temp = this._hasImageryTiles;
|
|
275
|
+
|
|
276
|
+
//
|
|
277
|
+
// ...pointCloud, shape, model etc.
|
|
278
|
+
//
|
|
279
|
+
|
|
280
|
+
if (entity.strip) {
|
|
281
|
+
this._stripEntityCollection.add(entity);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (entity.polyline || entity.ray) {
|
|
285
|
+
this._polylineEntityCollection.add(entity);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (entity.geometry) {
|
|
289
|
+
this._hasImageryTiles = true;
|
|
290
|
+
if (this._planet) {
|
|
291
|
+
this._planet.renderer.assignPickingColor(entity);
|
|
292
|
+
this._geometryHandler.add(entity.geometry);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (entity.billboard || entity.label) {
|
|
297
|
+
if (this._planet) {
|
|
298
|
+
if (entity._cartesian.isZero() && !entity._lonlat.isZero()) {
|
|
299
|
+
entity._setCartesian3vSilent(
|
|
300
|
+
this._planet.ellipsoid.lonLatToCartesian(entity._lonlat)
|
|
301
|
+
);
|
|
302
|
+
} else {
|
|
303
|
+
entity._lonlat = this._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// north tree
|
|
307
|
+
if (entity._lonlat.lat > mercator.MAX_LAT) {
|
|
308
|
+
this._entityCollectionsTreeNorth.__setLonLat__(entity);
|
|
309
|
+
this._entityCollectionsTreeNorth.insertEntity(entity, rightNow);
|
|
310
|
+
} else if (entity._lonlat.lat < mercator.MIN_LAT) {
|
|
311
|
+
// south tree
|
|
312
|
+
this._entityCollectionsTreeSouth.__setLonLat__(entity);
|
|
313
|
+
this._entityCollectionsTreeSouth.insertEntity(entity, rightNow);
|
|
314
|
+
} else {
|
|
315
|
+
this._entityCollectionsTree.__setLonLat__(entity);
|
|
316
|
+
this._entityCollectionsTree.insertEntity(entity, rightNow);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (this._planet && this._hasImageryTiles !== temp) {
|
|
322
|
+
this._planet.updateVisibleLayers();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
this.events.dispatch(this.events.entityadd, entity);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Adds entity array to the layer.
|
|
330
|
+
* @public
|
|
331
|
+
* @param {Array.<Entity>} entities - Entities array.
|
|
332
|
+
* @param {boolean} [rightNow] - Entity insertion option. False is deafult.
|
|
333
|
+
* @returns {layer.Vector} - Returns this layer.
|
|
334
|
+
*/
|
|
335
|
+
addEntities(entities, rightNow) {
|
|
336
|
+
var i = entities.length;
|
|
337
|
+
while (i--) {
|
|
338
|
+
this.add(entities[i], rightNow);
|
|
339
|
+
}
|
|
340
|
+
return this;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Remove entity from layer.
|
|
345
|
+
* TODO: memory leaks.
|
|
346
|
+
* @public
|
|
347
|
+
* @param {Entity} entity - Entity to remove.
|
|
348
|
+
* @returns {layer.Vector} - Returns this layer.
|
|
349
|
+
*/
|
|
350
|
+
removeEntity(entity) {
|
|
351
|
+
if (entity._layer && this.isEqual(entity._layer)) {
|
|
352
|
+
this._entities.splice(entity._layerIndex, 1);
|
|
353
|
+
this._reindexEntitiesArray(entity._layerIndex);
|
|
354
|
+
entity._layer = null;
|
|
355
|
+
entity._layerIndex = -1;
|
|
356
|
+
|
|
357
|
+
if (entity._entityCollection) {
|
|
358
|
+
entity._entityCollection._removeEntitySilent(entity);
|
|
359
|
+
let node = entity._nodePtr;
|
|
360
|
+
while (node) {
|
|
361
|
+
node.count--;
|
|
362
|
+
node = node.parentNode;
|
|
363
|
+
}
|
|
364
|
+
if (
|
|
365
|
+
entity._nodePtr &&
|
|
366
|
+
entity._nodePtr.count === 0 &&
|
|
367
|
+
entity._nodePtr.deferredEntities.length === 0
|
|
368
|
+
) {
|
|
369
|
+
entity._nodePtr.entityCollection = null;
|
|
370
|
+
//
|
|
371
|
+
// ...
|
|
372
|
+
//
|
|
373
|
+
}
|
|
374
|
+
} else if (entity._nodePtr && entity._nodePtr.deferredEntities.length) {
|
|
375
|
+
var defEntities = entity._nodePtr.deferredEntities;
|
|
376
|
+
var j = defEntities.length;
|
|
377
|
+
while (j--) {
|
|
378
|
+
if (defEntities[j].id === entity.id) {
|
|
379
|
+
defEntities.splice(j, 1);
|
|
380
|
+
let node = entity._nodePtr;
|
|
381
|
+
while (node) {
|
|
382
|
+
node.count--;
|
|
383
|
+
node = node.parentNode;
|
|
384
|
+
}
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (entity.geometry) {
|
|
391
|
+
if (this._planet) {
|
|
392
|
+
this._geometryHandler.remove(entity.geometry);
|
|
393
|
+
this._planet.renderer.clearPickingColor(entity);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
entity._nodePtr && (entity._nodePtr = null);
|
|
398
|
+
this.events.dispatch(this.events.entityremove, entity);
|
|
399
|
+
}
|
|
400
|
+
return this;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Set layer picking events active.
|
|
405
|
+
* @public
|
|
406
|
+
* @param {boolean} picking - Picking enable flag.
|
|
407
|
+
*/
|
|
408
|
+
set pickingEnabled(picking) {
|
|
409
|
+
this._pickingEnabled = picking;
|
|
410
|
+
|
|
411
|
+
this._stripEntityCollection.setPickingEnabled(picking);
|
|
412
|
+
|
|
413
|
+
this._polylineEntityCollection.setPickingEnabled(picking);
|
|
414
|
+
|
|
415
|
+
this._entityCollectionsTree &&
|
|
416
|
+
this._entityCollectionsTree.traverseTree(function (node) {
|
|
417
|
+
node.entityCollection.setPickingEnabled(picking);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
this._entityCollectionsTreeNorth &&
|
|
421
|
+
this._entityCollectionsTreeNorth.traverseTree(function (node) {
|
|
422
|
+
node.entityCollection.setPickingEnabled(picking);
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
this._entityCollectionsTreeSouth &&
|
|
426
|
+
this._entityCollectionsTreeSouth.traverseTree(function (node) {
|
|
427
|
+
node.entityCollection.setPickingEnabled(picking);
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Refresh collected entities indexes from startIndex entitytes collection array position.
|
|
433
|
+
* @public
|
|
434
|
+
* @param {number} startIndex - Entity array index.
|
|
435
|
+
*/
|
|
436
|
+
_reindexEntitiesArray(startIndex) {
|
|
437
|
+
var e = this._entities;
|
|
438
|
+
for (var i = startIndex; i < e.length; i++) {
|
|
439
|
+
e[i]._layerIndex = i;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Removes entities from layer.
|
|
445
|
+
* @public
|
|
446
|
+
* @param {Array.<Entity>} entities - Entity array.
|
|
447
|
+
* @returns {layer.Vector} - Returns this layer.
|
|
448
|
+
*/
|
|
449
|
+
removeEntities(entities) {
|
|
450
|
+
var i = entities.length;
|
|
451
|
+
while (i--) {
|
|
452
|
+
this.removeEntity(entities[i]);
|
|
453
|
+
}
|
|
454
|
+
return this;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Sets scale by distance parameters.
|
|
459
|
+
* @public
|
|
460
|
+
* @param {number} near - Full scale entity distance.
|
|
461
|
+
* @param {number} far - Zerol scale entity distance.
|
|
462
|
+
* @param {number} [farInvisible] - Entity visibility distance.
|
|
463
|
+
* @returns {layer.Vector} -
|
|
464
|
+
*/
|
|
465
|
+
setScaleByDistance(near, far, farInvisible) {
|
|
466
|
+
this.scaleByDistance[0] = near;
|
|
467
|
+
this.scaleByDistance[1] = far;
|
|
468
|
+
this.scaleByDistance[2] = farInvisible || math.MAX32;
|
|
469
|
+
return this;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* TODO: Clear the layer.
|
|
474
|
+
* @public
|
|
475
|
+
*/
|
|
476
|
+
clear() {
|
|
477
|
+
let temp = new Array(this._entities.length);
|
|
478
|
+
|
|
479
|
+
for (let i = 0; i < temp.length; i++) {
|
|
480
|
+
temp[i] = this._entities[i];
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
let i = this._entities.length;
|
|
484
|
+
while (i--) {
|
|
485
|
+
this._entities[i].remove();
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
this._entities.length = 0;
|
|
489
|
+
this._entities = [];
|
|
490
|
+
for (let i = 0; i < temp.length; i++) {
|
|
491
|
+
this._entities[i] = temp[i];
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
this._entityCollectionsTree = null;
|
|
495
|
+
this._entityCollectionsTreeNorth = null;
|
|
496
|
+
this._entityCollectionsTreeSouth = null;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Safety entities loop.
|
|
501
|
+
* @public
|
|
502
|
+
* @param {callback} callback - Entity callback.
|
|
503
|
+
*/
|
|
504
|
+
each(callback) {
|
|
505
|
+
var e = this._entities;
|
|
506
|
+
var i = e.length;
|
|
507
|
+
while (i--) {
|
|
508
|
+
callback(e[i], i);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Removes current entities from layer and adds new entities.
|
|
514
|
+
* @public
|
|
515
|
+
* @param {Array.<Entity>} entities - New entity array.
|
|
516
|
+
* @returns {layer.Vector} - Returns layer instance.
|
|
517
|
+
*/
|
|
518
|
+
setEntities(entities) {
|
|
519
|
+
let temp = new Array(entities.length);
|
|
520
|
+
for (let i = 0, len = entities.length; i < len; i++) {
|
|
521
|
+
temp[i] = entities[i];
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
this.clear();
|
|
525
|
+
|
|
526
|
+
//var e = this._extent;
|
|
527
|
+
|
|
528
|
+
this._entities = new Array(temp.length);
|
|
529
|
+
|
|
530
|
+
var entitiesForTree = [];
|
|
531
|
+
|
|
532
|
+
for (var i = 0; i < temp.length; i++) {
|
|
533
|
+
var ei = temp[i];
|
|
534
|
+
|
|
535
|
+
ei._layer = this;
|
|
536
|
+
ei._layerIndex = i;
|
|
537
|
+
|
|
538
|
+
if (ei.strip) {
|
|
539
|
+
this._stripEntityCollection.add(ei);
|
|
540
|
+
} else if (ei.polyline || ei.ray) {
|
|
541
|
+
this._polylineEntityCollection.add(ei);
|
|
542
|
+
} else if (ei.billboard || ei.label || ei.shape) {
|
|
543
|
+
entitiesForTree.push(ei);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (ei.geometry) {
|
|
547
|
+
this._hasImageryTiles = true;
|
|
548
|
+
if (this._planet) {
|
|
549
|
+
this._planet.renderer.assignPickingColor(ei);
|
|
550
|
+
this._geometryHandler.add(ei.geometry);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
this._entities[i] = ei;
|
|
555
|
+
|
|
556
|
+
//var ext = ei.getExtent();
|
|
557
|
+
//if (ext.northEast.lon > e.northEast.lon) e.northEast.lon = ext.northEast.lon;
|
|
558
|
+
//if (ext.northEast.lat > e.northEast.lat) e.northEast.lat = ext.northEast.lat;
|
|
559
|
+
//if (ext.southWest.lon < e.southWest.lon) e.southWest.lon = ext.southWest.lon;
|
|
560
|
+
//if (ext.southWest.lat < e.southWest.lat) e.southWest.lat = ext.southWest.lat;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
this._createEntityCollectionsTree(entitiesForTree);
|
|
564
|
+
|
|
565
|
+
return this;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
_createEntityCollectionsTree(entitiesForTree) {
|
|
569
|
+
if (this._planet) {
|
|
570
|
+
this._entityCollectionsTree = new EntityCollectionNode(
|
|
571
|
+
this,
|
|
572
|
+
quadTree.NW,
|
|
573
|
+
null,
|
|
574
|
+
0,
|
|
575
|
+
Extent.createFromArray([-20037508.34, -20037508.34, 20037508.34, 20037508.34]),
|
|
576
|
+
this._planet,
|
|
577
|
+
0
|
|
578
|
+
);
|
|
579
|
+
this._entityCollectionsTreeNorth = new EntityCollectionNodeWGS84(
|
|
580
|
+
this,
|
|
581
|
+
quadTree.NW,
|
|
582
|
+
null,
|
|
583
|
+
0,
|
|
584
|
+
Extent.createFromArray([-180, mercator.MAX_LAT, 180, 90]),
|
|
585
|
+
this._planet,
|
|
586
|
+
0
|
|
587
|
+
);
|
|
588
|
+
this._entityCollectionsTreeSouth = new EntityCollectionNodeWGS84(
|
|
589
|
+
this,
|
|
590
|
+
quadTree.NW,
|
|
591
|
+
null,
|
|
592
|
+
0,
|
|
593
|
+
Extent.createFromArray([-180, -90, 180, mercator.MIN_LAT]),
|
|
594
|
+
this._planet,
|
|
595
|
+
0
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
for (let i = 0, len = entitiesForTree.length; i < len; i++) {
|
|
599
|
+
let entity = entitiesForTree[i];
|
|
600
|
+
// north tree
|
|
601
|
+
if (entity._lonlat.lat > mercator.MAX_LAT) {
|
|
602
|
+
this._entityCollectionsTreeNorth.__setLonLat__(entity);
|
|
603
|
+
} else if (entity._lonlat.lat < mercator.MIN_LAT) {
|
|
604
|
+
// south tree
|
|
605
|
+
this._entityCollectionsTreeSouth.__setLonLat__(entity);
|
|
606
|
+
} else {
|
|
607
|
+
this._entityCollectionsTree.__setLonLat__(entity);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
this._entityCollectionsTree.buildTree(entitiesForTree);
|
|
612
|
+
this._entityCollectionsTreeNorth.buildTree(entitiesForTree);
|
|
613
|
+
this._entityCollectionsTreeSouth.buildTree(entitiesForTree);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
_bindEventsDefault(entityCollection) {
|
|
618
|
+
var ve = this.events;
|
|
619
|
+
entityCollection.events.on("entitymove", function (e) {
|
|
620
|
+
ve.dispatch(ve.entitymove, e);
|
|
621
|
+
});
|
|
622
|
+
entityCollection.events.on("mousemove", function (e) {
|
|
623
|
+
ve.dispatch(ve.mousemove, e);
|
|
624
|
+
});
|
|
625
|
+
entityCollection.events.on("mouseenter", function (e) {
|
|
626
|
+
ve.dispatch(ve.mouseenter, e);
|
|
627
|
+
});
|
|
628
|
+
entityCollection.events.on("mouseleave", function (e) {
|
|
629
|
+
ve.dispatch(ve.mouseleave, e);
|
|
630
|
+
});
|
|
631
|
+
entityCollection.events.on("lclick", function (e) {
|
|
632
|
+
ve.dispatch(ve.lclick, e);
|
|
633
|
+
});
|
|
634
|
+
entityCollection.events.on("rclick", function (e) {
|
|
635
|
+
ve.dispatch(ve.rclick, e);
|
|
636
|
+
});
|
|
637
|
+
entityCollection.events.on("mclick", function (e) {
|
|
638
|
+
ve.dispatch(ve.mclick, e);
|
|
639
|
+
});
|
|
640
|
+
entityCollection.events.on("ldblclick", function (e) {
|
|
641
|
+
ve.dispatch(ve.ldblclick, e);
|
|
642
|
+
});
|
|
643
|
+
entityCollection.events.on("rdblclick", function (e) {
|
|
644
|
+
ve.dispatch(ve.rdblclick, e);
|
|
645
|
+
});
|
|
646
|
+
entityCollection.events.on("mdblclick", function (e) {
|
|
647
|
+
ve.dispatch(ve.mdblclick, e);
|
|
648
|
+
});
|
|
649
|
+
entityCollection.events.on("lup", function (e) {
|
|
650
|
+
ve.dispatch(ve.lup, e);
|
|
651
|
+
});
|
|
652
|
+
entityCollection.events.on("rup", function (e) {
|
|
653
|
+
ve.dispatch(ve.rup, e);
|
|
654
|
+
});
|
|
655
|
+
entityCollection.events.on("mup", function (e) {
|
|
656
|
+
ve.dispatch(ve.mup, e);
|
|
657
|
+
});
|
|
658
|
+
entityCollection.events.on("ldown", function (e) {
|
|
659
|
+
ve.dispatch(ve.ldown, e);
|
|
660
|
+
});
|
|
661
|
+
entityCollection.events.on("rdown", function (e) {
|
|
662
|
+
ve.dispatch(ve.rdown, e);
|
|
663
|
+
});
|
|
664
|
+
entityCollection.events.on("mdown", function (e) {
|
|
665
|
+
ve.dispatch(ve.mdown, e);
|
|
666
|
+
});
|
|
667
|
+
entityCollection.events.on("lhold", function (e) {
|
|
668
|
+
ve.dispatch(ve.lhold, e);
|
|
669
|
+
});
|
|
670
|
+
entityCollection.events.on("rhold", function (e) {
|
|
671
|
+
ve.dispatch(ve.rhold, e);
|
|
672
|
+
});
|
|
673
|
+
entityCollection.events.on("mhold", function (e) {
|
|
674
|
+
ve.dispatch(ve.mhold, e);
|
|
675
|
+
});
|
|
676
|
+
entityCollection.events.on("mousewheel", function (e) {
|
|
677
|
+
ve.dispatch(ve.mousewheel, e);
|
|
678
|
+
});
|
|
679
|
+
entityCollection.events.on("touchmove", function (e) {
|
|
680
|
+
ve.dispatch(ve.touchmove, e);
|
|
681
|
+
});
|
|
682
|
+
entityCollection.events.on("touchstart", function (e) {
|
|
683
|
+
ve.dispatch(ve.touchstart, e);
|
|
684
|
+
});
|
|
685
|
+
entityCollection.events.on("touchend", function (e) {
|
|
686
|
+
ve.dispatch(ve.touchend, e);
|
|
687
|
+
});
|
|
688
|
+
entityCollection.events.on("doubletouch", function (e) {
|
|
689
|
+
ve.dispatch(ve.doubletouch, e);
|
|
690
|
+
});
|
|
691
|
+
entityCollection.events.on("touchleave", function (e) {
|
|
692
|
+
ve.dispatch(ve.touchleave, e);
|
|
693
|
+
});
|
|
694
|
+
entityCollection.events.on("touchenter", function (e) {
|
|
695
|
+
ve.dispatch(ve.touchenter, e);
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
_collectStripCollectionPASS(outArr) {
|
|
700
|
+
var ec = this._stripEntityCollection;
|
|
701
|
+
|
|
702
|
+
ec._fadingOpacity = this._fadingOpacity;
|
|
703
|
+
ec.scaleByDistance = this.scaleByDistance;
|
|
704
|
+
ec.pickingScale = this.pickingScale;
|
|
705
|
+
ec.polygonOffsetUnits = this.polygonOffsetUnits;
|
|
706
|
+
|
|
707
|
+
outArr.push(ec);
|
|
708
|
+
//
|
|
709
|
+
// ...TODO: extent
|
|
710
|
+
//
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
_collectPolylineCollectionPASS(outArr) {
|
|
714
|
+
var ec = this._polylineEntityCollection;
|
|
715
|
+
|
|
716
|
+
ec._fadingOpacity = this._fadingOpacity;
|
|
717
|
+
ec.scaleByDistance = this.scaleByDistance;
|
|
718
|
+
ec.pickingScale = this.pickingScale;
|
|
719
|
+
ec.polygonOffsetUnits = this.polygonOffsetUnits;
|
|
720
|
+
|
|
721
|
+
outArr.push(ec);
|
|
722
|
+
|
|
723
|
+
if (this.clampToGround || this.relativeToGround) {
|
|
724
|
+
let rtg = Number(this.relativeToGround);
|
|
725
|
+
|
|
726
|
+
var nodes = this._planet._renderedNodes;
|
|
727
|
+
var visibleExtent = this._planet.getViewExtent();
|
|
728
|
+
var e = ec._entities;
|
|
729
|
+
var e_i = e.length;
|
|
730
|
+
let res = new Vec3();
|
|
731
|
+
|
|
732
|
+
while (e_i--) {
|
|
733
|
+
var p = e[e_i].polyline;
|
|
734
|
+
if (visibleExtent.overlaps(p._extent)) {
|
|
735
|
+
// TODO:this works only for mercator area.
|
|
736
|
+
// needs to be working on poles.
|
|
737
|
+
let coords = p._pathLonLatMerc,
|
|
738
|
+
c_j = coords.length;
|
|
739
|
+
while (c_j--) {
|
|
740
|
+
var c_j_h = coords[c_j].length;
|
|
741
|
+
while (c_j_h--) {
|
|
742
|
+
let ll = coords[c_j][c_j_h],
|
|
743
|
+
n_k = nodes.length;
|
|
744
|
+
while (n_k--) {
|
|
745
|
+
var seg = nodes[n_k].segment;
|
|
746
|
+
if (seg._extent.isInside(ll)) {
|
|
747
|
+
let cart = p._path3v[c_j][c_j_h];
|
|
748
|
+
seg.getTerrainPoint(cart, ll, res);
|
|
749
|
+
p.setPoint3v(
|
|
750
|
+
res.addA(res.normal().scale((rtg && p.altitude) || 0.0)),
|
|
751
|
+
c_j_h,
|
|
752
|
+
c_j,
|
|
753
|
+
true
|
|
754
|
+
);
|
|
755
|
+
break;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
collectVisibleCollections(outArr) {
|
|
766
|
+
var p = this._planet;
|
|
767
|
+
|
|
768
|
+
if (
|
|
769
|
+
(this._fading && this._fadingOpacity > 0.0) ||
|
|
770
|
+
(this.minZoom <= this._planet.maxCurrZoom && this.maxZoom >= p.maxCurrZoom)
|
|
771
|
+
) {
|
|
772
|
+
this._renderingNodes = {};
|
|
773
|
+
this._renderingNodesNorth = {};
|
|
774
|
+
this._renderingNodesSouth = {};
|
|
775
|
+
|
|
776
|
+
// Common collections first
|
|
777
|
+
this._collectStripCollectionPASS(outArr);
|
|
778
|
+
|
|
779
|
+
this._collectPolylineCollectionPASS(outArr);
|
|
780
|
+
|
|
781
|
+
// Merc nodes
|
|
782
|
+
this._secondPASS = [];
|
|
783
|
+
this._entityCollectionsTree.collectRenderCollectionsPASS1(p._visibleNodes, outArr);
|
|
784
|
+
var i = this._secondPASS.length;
|
|
785
|
+
while (i--) {
|
|
786
|
+
this._secondPASS[i].collectRenderCollectionsPASS2(
|
|
787
|
+
p._visibleNodes,
|
|
788
|
+
outArr,
|
|
789
|
+
this._secondPASS[i].nodeId
|
|
790
|
+
);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// North nodes
|
|
794
|
+
this._secondPASS = [];
|
|
795
|
+
this._entityCollectionsTreeNorth.collectRenderCollectionsPASS1(
|
|
796
|
+
p._visibleNodesNorth,
|
|
797
|
+
outArr
|
|
798
|
+
);
|
|
799
|
+
i = this._secondPASS.length;
|
|
800
|
+
while (i--) {
|
|
801
|
+
this._secondPASS[i].collectRenderCollectionsPASS2(
|
|
802
|
+
p._visibleNodesNorth,
|
|
803
|
+
outArr,
|
|
804
|
+
this._secondPASS[i].nodeId
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// South nodes
|
|
809
|
+
this._secondPASS = [];
|
|
810
|
+
this._entityCollectionsTreeSouth.collectRenderCollectionsPASS1(
|
|
811
|
+
p._visibleNodesSouth,
|
|
812
|
+
outArr
|
|
813
|
+
);
|
|
814
|
+
i = this._secondPASS.length;
|
|
815
|
+
while (i--) {
|
|
816
|
+
this._secondPASS[i].collectRenderCollectionsPASS2(
|
|
817
|
+
p._visibleNodesSouth,
|
|
818
|
+
outArr,
|
|
819
|
+
this._secondPASS[i].nodeId
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
_queueDeferredNode(node) {
|
|
826
|
+
if (this._visibility) {
|
|
827
|
+
node._inTheQueue = true;
|
|
828
|
+
if (this._counter >= 1) {
|
|
829
|
+
this._deferredEntitiesPendingQueue.push(node);
|
|
830
|
+
} else {
|
|
831
|
+
this._execDeferredNode(node);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
_execDeferredNode(node) {
|
|
837
|
+
this._counter++;
|
|
838
|
+
var that = this;
|
|
839
|
+
setTimeout(function () {
|
|
840
|
+
node.applyCollection();
|
|
841
|
+
that._counter--;
|
|
842
|
+
if (that._deferredEntitiesPendingQueue.length && that._counter < 1) {
|
|
843
|
+
while (that._deferredEntitiesPendingQueue.length) {
|
|
844
|
+
var n = that._deferredEntitiesPendingQueue.pop();
|
|
845
|
+
n._inTheQueue = false;
|
|
846
|
+
if (n.isVisible()) {
|
|
847
|
+
that._execDeferredNode(n);
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}, 0);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Start to load tile material.
|
|
857
|
+
* @public
|
|
858
|
+
* @virtual
|
|
859
|
+
* @param {Segment.Material} material - Current material.
|
|
860
|
+
*/
|
|
861
|
+
loadMaterial(material) {
|
|
862
|
+
var seg = material.segment;
|
|
863
|
+
|
|
864
|
+
if (this._isBaseLayer) {
|
|
865
|
+
material.texture = seg._isNorth
|
|
866
|
+
? seg.planet.solidTextureOne
|
|
867
|
+
: seg.planet.solidTextureTwo;
|
|
868
|
+
} else {
|
|
869
|
+
material.texture = seg.planet.transparentTexture;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
if (this._planet.layerLock.isFree()) {
|
|
873
|
+
material.isReady = false;
|
|
874
|
+
material.isLoading = true;
|
|
875
|
+
this._planet._vectorTileCreator.add(material);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Abort exact material loading.
|
|
881
|
+
* @public
|
|
882
|
+
* @param {Material} material - Segment material.
|
|
883
|
+
*/
|
|
884
|
+
abortMaterialLoading(material) {
|
|
885
|
+
material.isLoading = false;
|
|
886
|
+
material.isReady = false;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
applyMaterial(material) {
|
|
890
|
+
if (material.isReady) {
|
|
891
|
+
return [0, 0, 1, 1];
|
|
892
|
+
} else {
|
|
893
|
+
!material.isLoading && this.loadMaterial(material);
|
|
894
|
+
|
|
895
|
+
var segment = material.segment;
|
|
896
|
+
var pn = segment.node,
|
|
897
|
+
notEmpty = false;
|
|
898
|
+
|
|
899
|
+
var mId = this._id;
|
|
900
|
+
var psegm = material;
|
|
901
|
+
|
|
902
|
+
while (pn.parentNode) {
|
|
903
|
+
if (psegm && psegm.isReady) {
|
|
904
|
+
notEmpty = true;
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
pn = pn.parentNode;
|
|
908
|
+
psegm = pn.segment.materials[mId];
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
if (notEmpty) {
|
|
912
|
+
material.appliedNodeId = pn.nodeId;
|
|
913
|
+
material.texture = psegm.texture;
|
|
914
|
+
material.pickingMask = psegm.pickingMask;
|
|
915
|
+
var dZ2 = 1.0 / (2 << (segment.tileZoom - pn.segment.tileZoom - 1));
|
|
916
|
+
return [
|
|
917
|
+
segment.tileX * dZ2 - pn.segment.tileX,
|
|
918
|
+
segment.tileY * dZ2 - pn.segment.tileY,
|
|
919
|
+
dZ2,
|
|
920
|
+
dZ2
|
|
921
|
+
];
|
|
922
|
+
} else {
|
|
923
|
+
if (material.textureExists && material._updateTexture) {
|
|
924
|
+
material.texture = material._updateTexture;
|
|
925
|
+
material.pickingMask = material._updatePickingMask;
|
|
926
|
+
} else {
|
|
927
|
+
material.texture = segment.planet.transparentTexture;
|
|
928
|
+
material.pickingMask = segment.planet.transparentTexture;
|
|
929
|
+
}
|
|
930
|
+
return [0, 0, 1, 1];
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
clearMaterial(material) {
|
|
936
|
+
if (material.isReady) {
|
|
937
|
+
var gl = material.segment.handler.gl;
|
|
938
|
+
|
|
939
|
+
material.isReady = false;
|
|
940
|
+
material.pickingReady = false;
|
|
941
|
+
|
|
942
|
+
var t = material.texture;
|
|
943
|
+
material.texture = null;
|
|
944
|
+
t && !t.default && gl.deleteTexture(t);
|
|
945
|
+
|
|
946
|
+
t = material.pickingMask;
|
|
947
|
+
material.pickingMask = null;
|
|
948
|
+
t && !t.default && gl.deleteTexture(t);
|
|
949
|
+
|
|
950
|
+
t = material._updateTexture;
|
|
951
|
+
material._updateTexture = null;
|
|
952
|
+
t && !t.default && gl.deleteTexture(t);
|
|
953
|
+
|
|
954
|
+
t = material._updatePickingMask;
|
|
955
|
+
material._updatePickingMask = null;
|
|
956
|
+
t && !t.default && gl.deleteTexture(t);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
this.abortMaterialLoading(material);
|
|
960
|
+
|
|
961
|
+
material.isLoading = false;
|
|
962
|
+
material.textureExists = false;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
update() {
|
|
966
|
+
this._geometryHandler.update();
|
|
967
|
+
this.events.dispatch(this.events.draw, this);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
const EVENT_NAMES = [
|
|
972
|
+
/**
|
|
973
|
+
* Triggered when entity has moved.
|
|
974
|
+
* @event og.layer.Vector#draw
|
|
975
|
+
*/
|
|
976
|
+
"entitymove",
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Triggered when layer begin draw.
|
|
980
|
+
* @event og.layer.Vector#draw
|
|
981
|
+
*/
|
|
982
|
+
"draw",
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Triggered when new entity added to the layer.
|
|
986
|
+
* @event og.layer.Vector#entityadd
|
|
987
|
+
*/
|
|
988
|
+
"entityadd",
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Triggered when entity removes from the collection.
|
|
992
|
+
* @event og.layer.Vector#entityremove
|
|
993
|
+
*/
|
|
994
|
+
"entityremove"
|
|
995
|
+
];
|
|
996
|
+
|
|
997
|
+
export { Vector };
|