@openglobus/og 0.12.4 → 0.13.2
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 +887 -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 +800 -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 +607 -603
- package/src/og/shaders/label.js +576 -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 +4 -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
|
@@ -1,387 +1,389 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/quadTree/EntityCollectionNode
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
'use strict';
|
|
6
|
-
|
|
7
|
-
import { Sphere } from '../bv/Sphere.js';
|
|
8
|
-
import { EntityCollection } from '../entity/EntityCollection.js';
|
|
9
|
-
import { Extent } from '../Extent.js';
|
|
10
|
-
import { LonLat } from '../LonLat.js';
|
|
11
|
-
import { Vec3 } from '../math/Vec3.js';
|
|
12
|
-
import * as mercator from '../mercator.js';
|
|
13
|
-
import * as quadTree from './quadTree.js';
|
|
14
|
-
|
|
15
|
-
class EntityCollectionNode {
|
|
16
|
-
|
|
17
|
-
constructor(layer, partId, parent, id, extent, planet, zoom) {
|
|
18
|
-
this.layer = layer;
|
|
19
|
-
this.parentNode = parent;
|
|
20
|
-
this.childrenNodes = [];
|
|
21
|
-
this.partId = partId;
|
|
22
|
-
this.nodeId = partId + id;
|
|
23
|
-
this.state = null;
|
|
24
|
-
this.extent = extent;
|
|
25
|
-
this.count = 0;
|
|
26
|
-
this.deferredEntities = [];
|
|
27
|
-
this.entityCollection = null;
|
|
28
|
-
this.zoom = zoom;
|
|
29
|
-
this._inTheQueue = false;
|
|
30
|
-
|
|
31
|
-
this.bsphere = new Sphere();
|
|
32
|
-
|
|
33
|
-
planet && this._setExtentBounds();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
insertEntity(entity, rightNow) {
|
|
37
|
-
this.buildTree([entity], rightNow);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
_addEntitiesToCollection(entities, rightNow) {
|
|
41
|
-
if (entities.length) {
|
|
42
|
-
var l = this.layer,
|
|
43
|
-
p = l._planet;
|
|
44
|
-
|
|
45
|
-
var ec = this.entityCollection;
|
|
46
|
-
|
|
47
|
-
if (!ec) {
|
|
48
|
-
ec = new EntityCollection({
|
|
49
|
-
pickingEnabled: l._pickingEnabled,
|
|
50
|
-
labelMaxLetters: l._labelMaxLetters
|
|
51
|
-
});
|
|
52
|
-
ec._layer = this.layer;
|
|
53
|
-
ec.addTo(p, true);
|
|
54
|
-
ec._quadNode = this;
|
|
55
|
-
l._bindEventsDefault(ec);
|
|
56
|
-
this.entityCollection = ec;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (rightNow || !l.async) {
|
|
60
|
-
this.entityCollection.addEntities(entities);
|
|
61
|
-
} else {
|
|
62
|
-
this.deferredEntities.push.apply(this.deferredEntities, entities);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
_setExtentBounds() {
|
|
68
|
-
if (!this.nodeId) {
|
|
69
|
-
this.bsphere.radius = this.layer._planet.ellipsoid._a;
|
|
70
|
-
this.bsphere.center = new Vec3();
|
|
71
|
-
} else {
|
|
72
|
-
this.bsphere.setFromExtent(this.layer._planet.ellipsoid, this.extent.inverseMercator());
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
__setLonLat__(entity) {
|
|
77
|
-
|
|
78
|
-
if (entity._lonlat.isZero() && !entity._cartesian.isZero()) {
|
|
79
|
-
entity._lonlat = this.layer._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (Math.abs(entity._lonlat.lat) < mercator.MAX_LAT) {
|
|
83
|
-
entity._lonlatMerc = entity._lonlat.forwardMercator();
|
|
84
|
-
} else {
|
|
85
|
-
entity._lonlatMerc = null;
|
|
86
|
-
}
|
|
87
|
-
return entity._lonlatMerc;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
buildTree(entities, rightNow) {
|
|
91
|
-
|
|
92
|
-
this.count += entities.length;
|
|
93
|
-
|
|
94
|
-
if (entities.length > this.layer._nodeCapacity
|
|
95
|
-
var cn = this.childrenNodes;
|
|
96
|
-
if (!cn.length) {
|
|
97
|
-
this.createChildrenNodes();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var en_nw = [],
|
|
101
|
-
en_ne = [],
|
|
102
|
-
en_sw = [],
|
|
103
|
-
en_se = [];
|
|
104
|
-
|
|
105
|
-
var i = entities.length;
|
|
106
|
-
while (i--) {
|
|
107
|
-
var ei = entities[i];
|
|
108
|
-
if (cn[quadTree.NW].isInside(ei)) {
|
|
109
|
-
ei._nodePtr = cn[quadTree.NW];
|
|
110
|
-
en_nw.push(ei);
|
|
111
|
-
} else if (cn[quadTree.NE].isInside(ei)) {
|
|
112
|
-
ei._nodePtr = cn[quadTree.NE];
|
|
113
|
-
en_ne.push(ei);
|
|
114
|
-
} else if (cn[quadTree.SW].isInside(ei)) {
|
|
115
|
-
ei._nodePtr = cn[quadTree.SW];
|
|
116
|
-
en_sw.push(ei);
|
|
117
|
-
} else if (cn[quadTree.SE].isInside(ei)) {
|
|
118
|
-
ei._nodePtr = cn[quadTree.SE];
|
|
119
|
-
en_se.push(ei);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
en_nw.length && cn[quadTree.NW].buildTree(en_nw, rightNow);
|
|
124
|
-
en_ne.length && cn[quadTree.NE].buildTree(en_ne, rightNow);
|
|
125
|
-
en_sw.length && cn[quadTree.SW].buildTree(en_sw, rightNow);
|
|
126
|
-
en_se.length && cn[quadTree.SE].buildTree(en_se, rightNow);
|
|
127
|
-
|
|
128
|
-
} else {
|
|
129
|
-
this._addEntitiesToCollection(entities, rightNow);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
isInside(entity) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
var
|
|
145
|
-
var
|
|
146
|
-
var
|
|
147
|
-
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
nd
|
|
151
|
-
|
|
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
|
-
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
ec
|
|
246
|
-
|
|
247
|
-
ec.
|
|
248
|
-
ec.
|
|
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
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
var
|
|
308
|
-
var
|
|
309
|
-
var
|
|
310
|
-
|
|
311
|
-
var
|
|
312
|
-
|
|
313
|
-
var
|
|
314
|
-
var
|
|
315
|
-
var
|
|
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
|
-
return true;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
*
|
|
361
|
-
* @param {*}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
this.layer.
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
this.
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
this.entityCollection.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module og/quadTree/EntityCollectionNode
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
import { Sphere } from '../bv/Sphere.js';
|
|
8
|
+
import { EntityCollection } from '../entity/EntityCollection.js';
|
|
9
|
+
import { Extent } from '../Extent.js';
|
|
10
|
+
import { LonLat } from '../LonLat.js';
|
|
11
|
+
import { Vec3 } from '../math/Vec3.js';
|
|
12
|
+
import * as mercator from '../mercator.js';
|
|
13
|
+
import * as quadTree from './quadTree.js';
|
|
14
|
+
|
|
15
|
+
class EntityCollectionNode {
|
|
16
|
+
|
|
17
|
+
constructor(layer, partId, parent, id, extent, planet, zoom) {
|
|
18
|
+
this.layer = layer;
|
|
19
|
+
this.parentNode = parent;
|
|
20
|
+
this.childrenNodes = [];
|
|
21
|
+
this.partId = partId;
|
|
22
|
+
this.nodeId = partId + id;
|
|
23
|
+
this.state = null;
|
|
24
|
+
this.extent = extent;
|
|
25
|
+
this.count = 0;
|
|
26
|
+
this.deferredEntities = [];
|
|
27
|
+
this.entityCollection = null;
|
|
28
|
+
this.zoom = zoom;
|
|
29
|
+
this._inTheQueue = false;
|
|
30
|
+
|
|
31
|
+
this.bsphere = new Sphere();
|
|
32
|
+
|
|
33
|
+
planet && this._setExtentBounds();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
insertEntity(entity, rightNow) {
|
|
37
|
+
this.buildTree([entity], rightNow);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_addEntitiesToCollection(entities, rightNow) {
|
|
41
|
+
if (entities.length) {
|
|
42
|
+
var l = this.layer,
|
|
43
|
+
p = l._planet;
|
|
44
|
+
|
|
45
|
+
var ec = this.entityCollection;
|
|
46
|
+
|
|
47
|
+
if (!ec) {
|
|
48
|
+
ec = new EntityCollection({
|
|
49
|
+
pickingEnabled: l._pickingEnabled,
|
|
50
|
+
labelMaxLetters: l._labelMaxLetters
|
|
51
|
+
});
|
|
52
|
+
ec._layer = this.layer;
|
|
53
|
+
ec.addTo(p, true);
|
|
54
|
+
ec._quadNode = this;
|
|
55
|
+
l._bindEventsDefault(ec);
|
|
56
|
+
this.entityCollection = ec;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (rightNow || !l.async) {
|
|
60
|
+
this.entityCollection.addEntities(entities);
|
|
61
|
+
} else {
|
|
62
|
+
this.deferredEntities.push.apply(this.deferredEntities, entities);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_setExtentBounds() {
|
|
68
|
+
if (!this.nodeId) {
|
|
69
|
+
this.bsphere.radius = this.layer._planet.ellipsoid._a;
|
|
70
|
+
this.bsphere.center = new Vec3();
|
|
71
|
+
} else {
|
|
72
|
+
this.bsphere.setFromExtent(this.layer._planet.ellipsoid, this.extent.inverseMercator());
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
__setLonLat__(entity) {
|
|
77
|
+
|
|
78
|
+
if (entity._lonlat.isZero() && !entity._cartesian.isZero()) {
|
|
79
|
+
entity._lonlat = this.layer._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (Math.abs(entity._lonlat.lat) < mercator.MAX_LAT) {
|
|
83
|
+
entity._lonlatMerc = entity._lonlat.forwardMercator();
|
|
84
|
+
} else {
|
|
85
|
+
entity._lonlatMerc = null;
|
|
86
|
+
}
|
|
87
|
+
return entity._lonlatMerc;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
buildTree(entities, rightNow) {
|
|
91
|
+
|
|
92
|
+
this.count += entities.length;
|
|
93
|
+
|
|
94
|
+
if (entities.length > this.layer._nodeCapacity) {
|
|
95
|
+
var cn = this.childrenNodes;
|
|
96
|
+
if (!cn.length) {
|
|
97
|
+
this.createChildrenNodes();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var en_nw = [],
|
|
101
|
+
en_ne = [],
|
|
102
|
+
en_sw = [],
|
|
103
|
+
en_se = [];
|
|
104
|
+
|
|
105
|
+
var i = entities.length;
|
|
106
|
+
while (i--) {
|
|
107
|
+
var ei = entities[i];
|
|
108
|
+
if (cn[quadTree.NW].isInside(ei)) {
|
|
109
|
+
ei._nodePtr = cn[quadTree.NW];
|
|
110
|
+
en_nw.push(ei);
|
|
111
|
+
} else if (cn[quadTree.NE].isInside(ei)) {
|
|
112
|
+
ei._nodePtr = cn[quadTree.NE];
|
|
113
|
+
en_ne.push(ei);
|
|
114
|
+
} else if (cn[quadTree.SW].isInside(ei)) {
|
|
115
|
+
ei._nodePtr = cn[quadTree.SW];
|
|
116
|
+
en_sw.push(ei);
|
|
117
|
+
} else if (cn[quadTree.SE].isInside(ei)) {
|
|
118
|
+
ei._nodePtr = cn[quadTree.SE];
|
|
119
|
+
en_se.push(ei);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
en_nw.length && cn[quadTree.NW].buildTree(en_nw, rightNow);
|
|
124
|
+
en_ne.length && cn[quadTree.NE].buildTree(en_ne, rightNow);
|
|
125
|
+
en_sw.length && cn[quadTree.SW].buildTree(en_sw, rightNow);
|
|
126
|
+
en_se.length && cn[quadTree.SE].buildTree(en_se, rightNow);
|
|
127
|
+
|
|
128
|
+
} else {
|
|
129
|
+
this._addEntitiesToCollection(entities, rightNow);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
isInside(entity) {
|
|
134
|
+
if (entity._lonlatMerc) {
|
|
135
|
+
return this.extent.isInside(entity._lonlatMerc);
|
|
136
|
+
} else {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
createChildrenNodes() {
|
|
142
|
+
var l = this.layer;
|
|
143
|
+
var ext = this.extent;
|
|
144
|
+
var size_x = ext.getWidth() * 0.5;
|
|
145
|
+
var size_y = ext.getHeight() * 0.5;
|
|
146
|
+
var ne = ext.northEast,
|
|
147
|
+
sw = ext.southWest;
|
|
148
|
+
var id = this.nodeId * 4 + 1;
|
|
149
|
+
var c = new LonLat(sw.lon + size_x, sw.lat + size_y);
|
|
150
|
+
var nd = this.childrenNodes;
|
|
151
|
+
var p = this.layer._planet;
|
|
152
|
+
var z = this.zoom + 1;
|
|
153
|
+
|
|
154
|
+
nd[quadTree.NW] = new EntityCollectionNode(l, quadTree.NW, this, id,
|
|
155
|
+
new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
|
|
156
|
+
|
|
157
|
+
nd[quadTree.NE] = new EntityCollectionNode(l, quadTree.NE, this, id,
|
|
158
|
+
new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
|
|
159
|
+
|
|
160
|
+
nd[quadTree.SW] = new EntityCollectionNode(l, quadTree.SW, this, id,
|
|
161
|
+
new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
|
|
162
|
+
|
|
163
|
+
nd[quadTree.SE] = new EntityCollectionNode(l, quadTree.SE, this, id,
|
|
164
|
+
new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
collectRenderCollectionsPASS1(visibleNodes, outArr) {
|
|
168
|
+
var n = visibleNodes[this.nodeId];
|
|
169
|
+
if (n) {
|
|
170
|
+
var cn = this.childrenNodes;
|
|
171
|
+
if (this.entityCollection) {
|
|
172
|
+
this.renderCollection(outArr, visibleNodes);
|
|
173
|
+
} else if (cn.length) {
|
|
174
|
+
if (n.state === quadTree.RENDERING) {
|
|
175
|
+
this.layer._secondPASS.push(this);
|
|
176
|
+
} else {
|
|
177
|
+
cn[quadTree.NW].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
178
|
+
cn[quadTree.NE].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
179
|
+
cn[quadTree.SW].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
180
|
+
cn[quadTree.SE].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId) {
|
|
187
|
+
var p = this.layer._planet;
|
|
188
|
+
var cam = p.renderer.activeCamera;
|
|
189
|
+
|
|
190
|
+
var altVis = (cam.eye.distance(this.bsphere.center) - this.bsphere.radius <
|
|
191
|
+
quadTree.VISIBLE_DISTANCE * Math.sqrt(cam._lonLat.height)) || cam._lonLat.height > 10000;
|
|
192
|
+
|
|
193
|
+
if (this.count > 0 && altVis &&
|
|
194
|
+
p.renderer.activeCamera.frustum.containsSphere(this.bsphere) > 0) {
|
|
195
|
+
|
|
196
|
+
var cn = this.childrenNodes;
|
|
197
|
+
|
|
198
|
+
if (this.entityCollection) {
|
|
199
|
+
this.renderCollection(outArr, visibleNodes, renderingNodeId);
|
|
200
|
+
} else if (cn.length) {
|
|
201
|
+
cn[quadTree.NW].collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId);
|
|
202
|
+
cn[quadTree.NE].collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId);
|
|
203
|
+
cn[quadTree.SW].collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId);
|
|
204
|
+
cn[quadTree.SE].collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
applyCollection() {
|
|
211
|
+
this.entityCollection.addEntities(this.deferredEntities);
|
|
212
|
+
this.deferredEntities.length = 0;
|
|
213
|
+
this.deferredEntities = [];
|
|
214
|
+
this._inTheQueue = false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
traverseTree(callback) {
|
|
218
|
+
|
|
219
|
+
var cn = this.childrenNodes;
|
|
220
|
+
|
|
221
|
+
if (this.entityCollection) {
|
|
222
|
+
callback(this);
|
|
223
|
+
} else if (cn.length) {
|
|
224
|
+
cn[quadTree.NW].traverseTree(callback);
|
|
225
|
+
cn[quadTree.NE].traverseTree(callback);
|
|
226
|
+
cn[quadTree.SW].traverseTree(callback);
|
|
227
|
+
cn[quadTree.SE].traverseTree(callback);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
renderCollection(outArr, visibleNodes, renderingNodeId) {
|
|
232
|
+
|
|
233
|
+
var l = this.layer;
|
|
234
|
+
|
|
235
|
+
l._renderingNodes[this.nodeId] = true;
|
|
236
|
+
|
|
237
|
+
if (this.deferredEntities.length && !this._inTheQueue) {
|
|
238
|
+
if (l.async) {
|
|
239
|
+
l._queueDeferredNode(this);
|
|
240
|
+
} else {
|
|
241
|
+
this.applyCollection();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
var ec = this.entityCollection;
|
|
246
|
+
|
|
247
|
+
ec._fadingOpacity = l._fadingOpacity;
|
|
248
|
+
ec.scaleByDistance = l.scaleByDistance;
|
|
249
|
+
ec.pickingScale = l.pickingScale;
|
|
250
|
+
ec.polygonOffsetUnits = l.polygonOffsetUnits;
|
|
251
|
+
|
|
252
|
+
outArr.push(ec);
|
|
253
|
+
|
|
254
|
+
if (l.clampToGround || l.relativeToGround) {
|
|
255
|
+
var e = ec._entities;
|
|
256
|
+
var i = e.length;
|
|
257
|
+
|
|
258
|
+
if (visibleNodes[this.nodeId] && visibleNodes[this.nodeId].state === quadTree.RENDERING) {
|
|
259
|
+
while (i--) {
|
|
260
|
+
let ei = e[i];
|
|
261
|
+
this.alignEntityToTheGround(ei, visibleNodes[this.nodeId].segment);
|
|
262
|
+
}
|
|
263
|
+
} else if (renderingNodeId) {
|
|
264
|
+
while (i--) {
|
|
265
|
+
let ei = e[i];
|
|
266
|
+
this.alignEntityToTheGround(ei, visibleNodes[renderingNodeId].segment);
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
var n = l._planet._renderedNodes;
|
|
270
|
+
while (i--) {
|
|
271
|
+
let ei = e[i];
|
|
272
|
+
let j = n.length;
|
|
273
|
+
while (j--) {
|
|
274
|
+
if (n[j].segment.isEntityInside(ei)) {
|
|
275
|
+
this.alignEntityToTheGround(ei, n[j].segment);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
alignEntityToTheGround(entity, segment) {
|
|
285
|
+
var res = new Vec3();
|
|
286
|
+
segment.getEntityTerrainPoint(entity, res);
|
|
287
|
+
entity._setCartesian3vSilent(res.addA(res.normal().scale((Number(this.layer.relativeToGround) && entity._altitude) || 0.0)));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
isVisible() {
|
|
291
|
+
if (this.layer._renderingNodes[this.nodeId]) {
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
class EntityCollectionNodeWGS84 extends EntityCollectionNode {
|
|
300
|
+
|
|
301
|
+
constructor(layer, partId, parent, id, extent, planet, zoom) {
|
|
302
|
+
super(layer, partId, parent, id, extent, planet, zoom);
|
|
303
|
+
this.isNorth = false;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
createChildrenNodes() {
|
|
307
|
+
var l = this.layer;
|
|
308
|
+
var ext = this.extent;
|
|
309
|
+
var size_x = ext.getWidth() * 0.5;
|
|
310
|
+
var size_y = ext.getHeight() * 0.5;
|
|
311
|
+
var ne = ext.northEast,
|
|
312
|
+
sw = ext.southWest;
|
|
313
|
+
var id = this.nodeId * 4 + 1;
|
|
314
|
+
var c = new LonLat(sw.lon + size_x, sw.lat + size_y);
|
|
315
|
+
var nd = this.childrenNodes;
|
|
316
|
+
var p = this.layer._planet;
|
|
317
|
+
var z = this.zoom + 1;
|
|
318
|
+
|
|
319
|
+
nd[quadTree.NW] = new EntityCollectionNodeWGS84(l, quadTree.NW, this, id,
|
|
320
|
+
new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
|
|
321
|
+
|
|
322
|
+
nd[quadTree.NE] = new EntityCollectionNodeWGS84(l, quadTree.NE, this, id,
|
|
323
|
+
new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
|
|
324
|
+
|
|
325
|
+
nd[quadTree.SW] = new EntityCollectionNodeWGS84(l, quadTree.SW, this, id,
|
|
326
|
+
new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
|
|
327
|
+
|
|
328
|
+
nd[quadTree.SE] = new EntityCollectionNodeWGS84(l, quadTree.SE, this, id,
|
|
329
|
+
new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
_setExtentBounds() {
|
|
333
|
+
if (this.extent.northEast.lat > 0) {
|
|
334
|
+
this.isNorth = true;
|
|
335
|
+
}
|
|
336
|
+
this.bsphere.setFromExtent(this.layer._planet.ellipsoid, this.extent);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
__setLonLat__(entity) {
|
|
340
|
+
if (entity._lonlat.isZero()) {
|
|
341
|
+
entity._lonlat = this.layer._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
342
|
+
}
|
|
343
|
+
return entity._lonlat;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
isVisible() {
|
|
347
|
+
if (this.isNorth && this.layer._renderingNodesNorth[this.nodeId]) {
|
|
348
|
+
return true;
|
|
349
|
+
} else if (this.layer._renderingNodesSouth[this.nodeId]) {
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
isInside(entity) {
|
|
356
|
+
return this.extent.isInside(entity._lonlat);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
*
|
|
361
|
+
* @param {*} outArr
|
|
362
|
+
* @param {*} visibleNodes
|
|
363
|
+
* @param {*} renderingNode
|
|
364
|
+
*/
|
|
365
|
+
renderCollection(outArr, visibleNodes, renderingNode) {
|
|
366
|
+
|
|
367
|
+
if (this.isNorth) {
|
|
368
|
+
this.layer._renderingNodesNorth[this.nodeId] = true;
|
|
369
|
+
} else {
|
|
370
|
+
this.layer._renderingNodesSouth[this.nodeId] = true;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (this.deferredEntities.length && !this._inTheQueue) {
|
|
374
|
+
if (this.layer.async) {
|
|
375
|
+
this.layer._queueDeferredNode(this);
|
|
376
|
+
} else {
|
|
377
|
+
this.applyCollection();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
this.entityCollection._fadingOpacity = this.layer._fadingOpacity;
|
|
382
|
+
this.entityCollection.scaleByDistance = this.layer.scaleByDistance;
|
|
383
|
+
this.entityCollection.pickingScale = this.layer.pickingScale;
|
|
384
|
+
|
|
385
|
+
outArr.push(this.entityCollection);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export { EntityCollectionNode, EntityCollectionNodeWGS84 };
|