@openglobus/og 0.11.1 → 0.11.6
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/package.json +18 -20
- package/src/og/Clock.js +11 -11
- package/src/og/Deferred.js +1 -1
- package/src/og/Events.js +9 -7
- package/src/og/Extent.js +117 -72
- package/src/og/Globe.js +35 -22
- package/src/og/ImageCanvas.js +24 -18
- package/src/og/Lock.js +2 -2
- package/src/og/LonLat.js +40 -37
- package/src/og/Popup.js +21 -15
- package/src/og/QueueArray.js +7 -3
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +8 -5
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +23 -17
- package/src/og/astro/jd.js +44 -39
- package/src/og/astro/orbit.js +20 -18
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +17 -9
- package/src/og/camera/Camera.js +137 -86
- package/src/og/camera/Frustum.js +30 -19
- package/src/og/camera/PlanetCamera.js +30 -26
- package/src/og/control/CompassButton.js +8 -2
- package/src/og/control/Control.js +13 -11
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +62 -41
- package/src/og/control/EarthNavigation.js +20 -22
- package/src/og/control/GeoImageDragControl.js +1 -1
- package/src/og/control/KeyboardNavigation.js +12 -12
- package/src/og/control/LayerSwitcher.js +24 -23
- package/src/og/control/Lighting.js +1 -1
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +8 -9
- package/src/og/control/ShowFps.js +15 -10
- package/src/og/control/SimpleNavigation.js +8 -10
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +5 -5
- package/src/og/control/TouchNavigation.js +58 -45
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/control/index.js +4 -0
- package/src/og/ellipsoid/Ellipsoid.js +181 -85
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +97 -44
- package/src/og/entity/Billboard.js +15 -11
- package/src/og/entity/BillboardHandler.js +314 -64
- package/src/og/entity/Entity.js +106 -74
- package/src/og/entity/EntityCollection.js +72 -49
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +29 -26
- package/src/og/entity/GeometryHandler.js +598 -126
- package/src/og/entity/Label.js +74 -40
- package/src/og/entity/LabelHandler.js +47 -246
- package/src/og/entity/LabelWorker.js +213 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +81 -33
- package/src/og/entity/PointCloudHandler.js +9 -9
- package/src/og/entity/Polyline.js +39 -39
- package/src/og/entity/Ray.js +61 -28
- package/src/og/entity/ShapeHandler.js +1 -1
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +27 -27
- package/src/og/entity/index.js +8 -16
- package/src/og/input/KeyboardHandler.js +107 -104
- package/src/og/input/MouseHandler.js +81 -78
- package/src/og/input/TouchHandler.js +55 -51
- package/src/og/layer/BaseGeoImage.js +61 -30
- package/src/og/layer/CanvasTiles.js +26 -24
- package/src/og/layer/GeoImage.js +10 -10
- package/src/og/layer/GeoTexture2d.js +1 -1
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +66 -40
- package/src/og/layer/Layer.js +27 -17
- package/src/og/layer/Material.js +93 -61
- package/src/og/layer/Vector.js +118 -72
- package/src/og/layer/WMS.js +36 -19
- package/src/og/layer/XYZ.js +55 -48
- package/src/og/light/LightSource.js +47 -40
- package/src/og/math/Line2.js +24 -24
- package/src/og/math/Line3.js +103 -102
- package/src/og/math/Mat3.js +134 -121
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +980 -927
- package/src/og/math/Ray.js +195 -187
- package/src/og/math/Vec2.js +127 -117
- package/src/og/math/Vec3.js +206 -176
- package/src/og/math/Vec4.js +49 -53
- package/src/og/math/coder.js +18 -18
- package/src/og/math.js +12 -12
- package/src/og/mercator.js +11 -11
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +31 -31
- package/src/og/quadTree/EntityCollectionNode.js +310 -300
- package/src/og/quadTree/Node.js +1008 -993
- package/src/og/renderer/Renderer.js +768 -747
- package/src/og/renderer/RendererEvents.js +9 -6
- package/src/og/scene/Axes.js +1 -1
- package/src/og/scene/BaseNode.js +8 -9
- package/src/og/scene/Planet.js +115 -87
- package/src/og/scene/RenderNode.js +29 -22
- package/src/og/scene/SkyBox.js +1 -1
- package/src/og/segment/Segment.js +1886 -1878
- package/src/og/segment/SegmentLonLat.js +298 -268
- package/src/og/segment/segmentHelper.js +11 -11
- package/src/og/shaders/bloom.js +1 -1
- package/src/og/shaders/blur.js +2 -2
- package/src/og/shaders/depth.js +1 -1
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/label.js +1 -1
- package/src/og/shaders/lumFilter.js +1 -1
- package/src/og/shaders/pointCloud.js +42 -42
- package/src/og/shaders/screenFrame.js +1 -1
- package/src/og/shaders/shape.js +15 -21
- package/src/og/shaders/skybox.js +37 -37
- package/src/og/shaders/toneMapping.js +1 -1
- package/src/og/shapes/BaseShape.js +129 -57
- package/src/og/shapes/Icosphere.js +30 -15
- package/src/og/shapes/Sphere.js +13 -16
- package/src/og/terrain/BilTerrain.js +2 -1
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/Geoid.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +10 -10
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/GeoImageCreator.js +9 -9
- package/src/og/utils/Loader.js +6 -6
- package/src/og/utils/NormalMapCreator.js +13 -13
- package/src/og/utils/TerrainWorker.js +1 -1
- package/src/og/utils/TextureAtlas.js +20 -22
- package/src/og/utils/VectorTileCreator.js +5 -5
- package/src/og/utils/earcut.js +1 -1
- package/src/og/utils/shared.js +15 -15
- package/src/og/webgl/Framebuffer.js +101 -53
- package/src/og/webgl/Handler.js +125 -85
- package/src/og/webgl/Multisample.js +55 -27
- package/src/og/webgl/Program.js +80 -35
- package/src/og/webgl/ProgramController.js +27 -23
- package/src/og/webgl/callbacks.js +8 -8
- package/types/Clock.d.ts +6 -2
- package/types/Deferred.d.ts +1 -1
- package/types/Events.d.ts +8 -4
- package/types/Extent.d.ts +37 -33
- package/types/Globe.d.ts +15 -13
- package/types/ImageCanvas.d.ts +5 -3
- package/types/LonLat.d.ts +24 -24
- package/types/Popup.d.ts +4 -0
- package/types/QueueArray.d.ts +6 -2
- package/types/Rectangle.d.ts +10 -4
- package/types/Stack.d.ts +4 -0
- package/types/ajax.d.ts +1 -1
- package/types/astro/earth.d.ts +3 -2
- package/types/bv/Box.d.ts +10 -5
- package/types/bv/Sphere.d.ts +13 -7
- package/types/camera/Camera.d.ts +90 -81
- package/types/camera/Frustum.d.ts +26 -22
- package/types/camera/PlanetCamera.d.ts +49 -53
- package/types/control/CompassButton.d.ts +4 -4
- package/types/control/Control.d.ts +7 -4
- package/types/control/DebugInfo.d.ts +3 -4
- package/types/control/EarthCoordinates.d.ts +6 -6
- package/types/control/EarthNavigation.d.ts +42 -0
- package/types/control/KeyboardNavigation.d.ts +3 -4
- package/types/control/LayerSwitcher.d.ts +3 -5
- package/types/control/Lighting.d.ts +3 -3
- package/types/control/MouseNavigation.d.ts +47 -0
- package/types/control/ScaleControl.d.ts +3 -3
- package/types/control/ShowFps.d.ts +3 -4
- package/types/control/SimpleNavigation.d.ts +3 -6
- package/types/control/Sun.d.ts +8 -10
- package/types/control/ToggleWireframe.d.ts +3 -3
- package/types/control/TouchNavigation.d.ts +48 -0
- package/types/control/ZoomControl.d.ts +3 -4
- package/types/control/index.d.ts +3 -1
- package/types/ellipsoid/Ellipsoid.d.ts +47 -43
- package/types/ellipsoid/wgs84.d.ts +3 -2
- package/types/entity/BaseBillboard.d.ts +41 -34
- package/types/entity/Billboard.d.ts +7 -7
- package/types/entity/BillboardHandler.d.ts +4 -0
- package/types/entity/Entity.d.ts +101 -83
- package/types/entity/EntityCollection.d.ts +57 -43
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +77 -0
- package/types/entity/Geometry.d.ts +9 -7
- package/types/entity/GeometryHandler.d.ts +2 -2
- package/types/entity/Label.d.ts +24 -29
- package/types/entity/LabelHandler.d.ts +9 -2
- package/types/entity/LabelWorker.d.ts +9 -0
- package/types/entity/PointCloud.d.ts +8 -8
- package/types/entity/PointCloudHandler.d.ts +3 -3
- package/types/entity/Polyline.d.ts +58 -55
- package/types/entity/Ray.d.ts +19 -18
- package/types/entity/Strip.d.ts +8 -7
- package/types/entity/StripHandler.d.ts +3 -3
- package/types/entity/index.d.ts +7 -7
- package/types/input/KeyboardHandler.d.ts +10 -0
- package/types/input/MouseHandler.d.ts +5 -0
- package/types/input/TouchHandler.d.ts +5 -0
- package/types/layer/BaseGeoImage.d.ts +23 -35
- package/types/layer/CanvasTiles.d.ts +15 -22
- package/types/layer/GeoImage.d.ts +5 -18
- package/types/layer/GeoVideo.d.ts +5 -30
- package/types/layer/KML.d.ts +20 -15
- package/types/layer/Layer.d.ts +326 -0
- package/types/layer/Material.d.ts +45 -0
- package/types/layer/Vector.d.ts +208 -0
- package/types/layer/WMS.d.ts +4 -7
- package/types/layer/XYZ.d.ts +19 -25
- package/types/light/LightSource.d.ts +54 -53
- package/types/math/Line2.d.ts +11 -0
- package/types/math/Line3.d.ts +10 -0
- package/types/math/Mat3.d.ts +30 -18
- package/types/math/Mat4.d.ts +71 -52
- package/types/math/Plane.d.ts +5 -4
- package/types/math/Quat.d.ts +379 -0
- package/types/math/Ray.d.ts +82 -0
- package/types/math/Vec2.d.ts +102 -101
- package/types/math/Vec3.d.ts +143 -142
- package/types/math/Vec4.d.ts +40 -39
- package/types/math/coder.d.ts +12 -11
- package/types/math.d.ts +8 -8
- package/types/mercator.d.ts +3 -3
- package/types/proj/EPSG3857.d.ts +3 -2
- package/types/proj/EPSG4326.d.ts +3 -2
- package/types/proj/Proj.d.ts +42 -0
- package/types/quadTree/EntityCollectionNode.d.ts +34 -0
- package/types/quadTree/Node.d.ts +61 -0
- package/types/renderer/Renderer.d.ts +300 -0
- package/types/renderer/RendererEvents.d.ts +10 -7
- package/types/scene/BaseNode.d.ts +9 -9
- package/types/scene/Planet.d.ts +131 -126
- package/types/scene/RenderNode.d.ts +22 -23
- package/types/segment/Segment.d.ts +279 -0
- package/types/segment/SegmentLonLat.d.ts +16 -0
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shapes/BaseShape.d.ts +43 -40
- package/types/shapes/Sphere.d.ts +7 -7
- package/types/terrain/BilTerrain.d.ts +0 -1
- package/types/terrain/EmptyTerrain.d.ts +4 -4
- package/types/terrain/GlobusTerrain.d.ts +17 -54
- package/types/terrain/MapboxTerrain.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +8 -8
- package/types/utils/shared.d.ts +25 -24
- package/types/webgl/Framebuffer.d.ts +5 -5
- package/types/webgl/Handler.d.ts +68 -43
- package/types/webgl/Multisample.d.ts +5 -5
- package/types/webgl/Program.d.ts +8 -2
- package/types/webgl/ProgramController.d.ts +18 -13
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/inherits.d.ts +0 -4
|
@@ -4,374 +4,384 @@
|
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import * as quadTree from './quadTree.js';
|
|
7
|
+
import { Sphere } from '../bv/Sphere.js';
|
|
9
8
|
import { EntityCollection } from '../entity/EntityCollection.js';
|
|
10
9
|
import { Extent } from '../Extent.js';
|
|
11
10
|
import { LonLat } from '../LonLat.js';
|
|
12
|
-
import { inherits } from '../inherits.js';
|
|
13
|
-
import { Sphere } from '../bv/Sphere.js';
|
|
14
11
|
import { Vec3 } from '../math/Vec3.js';
|
|
12
|
+
import * as mercator from '../mercator.js';
|
|
13
|
+
import * as quadTree from './quadTree.js';
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.buildTree([entity], rightNow);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
EntityCollectionNode.prototype._addEntitiesToCollection = function (entities, rightNow) {
|
|
40
|
-
if (entities.length) {
|
|
41
|
-
var l = this.layer,
|
|
42
|
-
p = l._planet;
|
|
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
|
+
}
|
|
43
35
|
|
|
44
|
-
|
|
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
|
+
}
|
|
45
58
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
ec._layer = this.layer;
|
|
52
|
-
ec.addTo(p, true);
|
|
53
|
-
ec._quadNode = this;
|
|
54
|
-
l._bindEventsDefault(ec);
|
|
55
|
-
this.entityCollection = ec;
|
|
59
|
+
if (rightNow || !l.async) {
|
|
60
|
+
this.entityCollection.addEntities(entities);
|
|
61
|
+
} else {
|
|
62
|
+
this.deferredEntities.push.apply(this.deferredEntities, entities);
|
|
63
|
+
}
|
|
56
64
|
}
|
|
65
|
+
}
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
_setExtentBounds() {
|
|
68
|
+
if (!this.nodeId) {
|
|
69
|
+
this.bsphere.radius = this.layer._planet.ellipsoid._a;
|
|
70
|
+
this.bsphere.center = new Vec3();
|
|
60
71
|
} else {
|
|
61
|
-
this.
|
|
72
|
+
this.bsphere.setFromExtent(this.layer._planet.ellipsoid, this.extent.inverseMercator());
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
EntityCollectionNode.prototype._setExtentBounds = function () {
|
|
67
|
-
if (!this.nodeId) {
|
|
68
|
-
this.bsphere.radius = this.layer._planet.ellipsoid._a;
|
|
69
|
-
this.bsphere.center = new Vec3();
|
|
70
|
-
} else {
|
|
71
|
-
this.bsphere.setFromExtent(this.layer._planet.ellipsoid, this.extent.inverseMercator());
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
__setLonLat__(entity) {
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
if (entity._lonlat.isZero() && !entity._cartesian.isZero()) {
|
|
79
|
+
entity._lonlat = this.layer._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
80
|
+
}
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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;
|
|
85
88
|
}
|
|
86
|
-
return entity._lonlatMerc;
|
|
87
|
-
};
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
buildTree(entities, rightNow) {
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
this.count += entities.length;
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
if (entities.length > this.layer._nodeCapacity || this.zoom > this.layer.minZoom) {
|
|
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 = [];
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
en_sw.push(ei);
|
|
116
|
-
} else if (cn[quadTree.SE].isInside(ei)) {
|
|
117
|
-
ei._nodePtr = cn[quadTree.SE];
|
|
118
|
-
en_se.push(ei);
|
|
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
|
+
}
|
|
119
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);
|
|
120
130
|
}
|
|
131
|
+
}
|
|
121
132
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
en_se.length && cn[quadTree.SE].buildTree(en_se, rightNow);
|
|
133
|
+
isInside(entity) {
|
|
134
|
+
return this.extent.isInside(entity._lonlatMerc);
|
|
135
|
+
}
|
|
126
136
|
|
|
127
|
-
|
|
128
|
-
this.
|
|
137
|
+
createChildrenNodes() {
|
|
138
|
+
var l = this.layer;
|
|
139
|
+
var ext = this.extent;
|
|
140
|
+
var size_x = ext.getWidth() * 0.5;
|
|
141
|
+
var size_y = ext.getHeight() * 0.5;
|
|
142
|
+
var ne = ext.northEast,
|
|
143
|
+
sw = ext.southWest;
|
|
144
|
+
var id = this.nodeId * 4 + 1;
|
|
145
|
+
var c = new LonLat(sw.lon + size_x, sw.lat + size_y);
|
|
146
|
+
var nd = this.childrenNodes;
|
|
147
|
+
var p = this.layer._planet;
|
|
148
|
+
var z = this.zoom + 1;
|
|
149
|
+
|
|
150
|
+
nd[quadTree.NW] = new EntityCollectionNode(l, quadTree.NW, this, id,
|
|
151
|
+
new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
|
|
152
|
+
|
|
153
|
+
nd[quadTree.NE] = new EntityCollectionNode(l, quadTree.NE, this, id,
|
|
154
|
+
new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
|
|
155
|
+
|
|
156
|
+
nd[quadTree.SW] = new EntityCollectionNode(l, quadTree.SW, this, id,
|
|
157
|
+
new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
|
|
158
|
+
|
|
159
|
+
nd[quadTree.SE] = new EntityCollectionNode(l, quadTree.SE, this, id,
|
|
160
|
+
new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
|
|
129
161
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
var p = this.layer._planet;
|
|
147
|
-
var z = this.zoom + 1;
|
|
148
|
-
|
|
149
|
-
nd[quadTree.NW] = new EntityCollectionNode(l, quadTree.NW, this, id,
|
|
150
|
-
new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
|
|
151
|
-
|
|
152
|
-
nd[quadTree.NE] = new EntityCollectionNode(l, quadTree.NE, this, id,
|
|
153
|
-
new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
|
|
154
|
-
|
|
155
|
-
nd[quadTree.SW] = new EntityCollectionNode(l, quadTree.SW, this, id,
|
|
156
|
-
new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
|
|
157
|
-
|
|
158
|
-
nd[quadTree.SE] = new EntityCollectionNode(l, quadTree.SE, this, id,
|
|
159
|
-
new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
EntityCollectionNode.prototype.collectRenderCollectionsPASS1 = function (visibleNodes, outArr) {
|
|
163
|
-
var n = visibleNodes[this.nodeId];
|
|
164
|
-
if (n) {
|
|
165
|
-
var cn = this.childrenNodes;
|
|
166
|
-
if (this.entityCollection) {
|
|
167
|
-
this.renderCollection(outArr, visibleNodes);
|
|
168
|
-
} else if (cn.length) {
|
|
169
|
-
if (n.state === quadTree.RENDERING) {
|
|
170
|
-
this.layer._secondPASS.push(this);
|
|
171
|
-
} else {
|
|
172
|
-
cn[quadTree.NW].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
173
|
-
cn[quadTree.NE].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
174
|
-
cn[quadTree.SW].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
175
|
-
cn[quadTree.SE].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
162
|
+
|
|
163
|
+
collectRenderCollectionsPASS1(visibleNodes, outArr) {
|
|
164
|
+
var n = visibleNodes[this.nodeId];
|
|
165
|
+
if (n) {
|
|
166
|
+
var cn = this.childrenNodes;
|
|
167
|
+
if (this.entityCollection) {
|
|
168
|
+
this.renderCollection(outArr, visibleNodes);
|
|
169
|
+
} else if (cn.length) {
|
|
170
|
+
if (n.state === quadTree.RENDERING) {
|
|
171
|
+
this.layer._secondPASS.push(this);
|
|
172
|
+
} else {
|
|
173
|
+
cn[quadTree.NW].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
174
|
+
cn[quadTree.NE].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
175
|
+
cn[quadTree.SW].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
176
|
+
cn[quadTree.SE].collectRenderCollectionsPASS1(visibleNodes, outArr);
|
|
177
|
+
}
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
|
-
};
|
|
180
181
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId) {
|
|
183
|
+
var p = this.layer._planet;
|
|
184
|
+
var cam = p.renderer.activeCamera;
|
|
185
|
+
|
|
186
|
+
var altVis = (cam.eye.distance(this.bsphere.center) - this.bsphere.radius <
|
|
187
|
+
quadTree.VISIBLE_DISTANCE * Math.sqrt(cam._lonLat.height)) || cam._lonLat.height > 10000;
|
|
184
188
|
|
|
185
|
-
|
|
186
|
-
|
|
189
|
+
if (this.count > 0 && altVis &&
|
|
190
|
+
p.renderer.activeCamera.frustum.containsSphere(this.bsphere) > 0) {
|
|
187
191
|
|
|
188
|
-
|
|
189
|
-
|
|
192
|
+
var cn = this.childrenNodes;
|
|
193
|
+
|
|
194
|
+
if (this.entityCollection) {
|
|
195
|
+
this.renderCollection(outArr, visibleNodes, renderingNodeId);
|
|
196
|
+
} else if (cn.length) {
|
|
197
|
+
cn[quadTree.NW].collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId);
|
|
198
|
+
cn[quadTree.NE].collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId);
|
|
199
|
+
cn[quadTree.SW].collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId);
|
|
200
|
+
cn[quadTree.SE].collectRenderCollectionsPASS2(visibleNodes, outArr, renderingNodeId);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
applyCollection() {
|
|
207
|
+
this.entityCollection.addEntities(this.deferredEntities);
|
|
208
|
+
this.deferredEntities.length = 0;
|
|
209
|
+
this.deferredEntities = [];
|
|
210
|
+
this._inTheQueue = false;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
traverseTree(callback) {
|
|
190
214
|
|
|
191
215
|
var cn = this.childrenNodes;
|
|
192
216
|
|
|
193
217
|
if (this.entityCollection) {
|
|
194
|
-
this
|
|
218
|
+
callback(this);
|
|
195
219
|
} else if (cn.length) {
|
|
196
|
-
cn[quadTree.NW].
|
|
197
|
-
cn[quadTree.NE].
|
|
198
|
-
cn[quadTree.SW].
|
|
199
|
-
cn[quadTree.SE].
|
|
220
|
+
cn[quadTree.NW].traverseTree(callback);
|
|
221
|
+
cn[quadTree.NE].traverseTree(callback);
|
|
222
|
+
cn[quadTree.SW].traverseTree(callback);
|
|
223
|
+
cn[quadTree.SE].traverseTree(callback);
|
|
200
224
|
}
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
EntityCollectionNode.prototype.applyCollection = function () {
|
|
206
|
-
this.entityCollection.addEntities(this.deferredEntities);
|
|
207
|
-
this.deferredEntities.length = 0;
|
|
208
|
-
this.deferredEntities = [];
|
|
209
|
-
this._inTheQueue = false;
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
EntityCollectionNode.prototype.traverseTree = function (callback) {
|
|
213
|
-
|
|
214
|
-
var cn = this.childrenNodes;
|
|
215
|
-
|
|
216
|
-
if (this.entityCollection) {
|
|
217
|
-
callback(this);
|
|
218
|
-
} else if (cn.length) {
|
|
219
|
-
cn[quadTree.NW].traverseTree(callback);
|
|
220
|
-
cn[quadTree.NE].traverseTree(callback);
|
|
221
|
-
cn[quadTree.SW].traverseTree(callback);
|
|
222
|
-
cn[quadTree.SE].traverseTree(callback);
|
|
223
225
|
}
|
|
224
|
-
};
|
|
225
226
|
|
|
226
|
-
|
|
227
|
+
renderCollection(outArr, visibleNodes, renderingNodeId) {
|
|
227
228
|
|
|
228
|
-
|
|
229
|
+
var l = this.layer;
|
|
229
230
|
|
|
230
|
-
|
|
231
|
+
l._renderingNodes[this.nodeId] = true;
|
|
231
232
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
if (this.deferredEntities.length && !this._inTheQueue) {
|
|
234
|
+
if (l.async) {
|
|
235
|
+
l._queueDeferredNode(this);
|
|
236
|
+
} else {
|
|
237
|
+
this.applyCollection();
|
|
238
|
+
}
|
|
237
239
|
}
|
|
238
|
-
}
|
|
239
240
|
|
|
240
|
-
|
|
241
|
+
var ec = this.entityCollection;
|
|
241
242
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
ec._fadingOpacity = l._fadingOpacity;
|
|
244
|
+
ec.scaleByDistance = l.scaleByDistance;
|
|
245
|
+
ec.pickingScale = l.pickingScale;
|
|
245
246
|
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
ec.polygonOffsetFactor = l.polygonOffsetFactor;
|
|
248
|
+
ec.polygonOffsetUnits = l.polygonOffsetUnits;
|
|
248
249
|
|
|
249
|
-
|
|
250
|
+
outArr.push(ec);
|
|
250
251
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
if (l.clampToGround || l.relativeToGround) {
|
|
253
|
+
var e = ec._entities;
|
|
254
|
+
var i = e.length;
|
|
254
255
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
256
|
+
if (visibleNodes[this.nodeId] && visibleNodes[this.nodeId].state === quadTree.RENDERING) {
|
|
257
|
+
while (i--) {
|
|
258
|
+
let ei = e[i];
|
|
259
|
+
this.alignEntityToTheGround(ei, visibleNodes[this.nodeId].segment);
|
|
260
|
+
}
|
|
261
|
+
} else if (renderingNodeId) {
|
|
262
|
+
while (i--) {
|
|
263
|
+
let ei = e[i];
|
|
264
|
+
this.alignEntityToTheGround(ei, visibleNodes[renderingNodeId].segment);
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
var n = l._planet._renderedNodes;
|
|
268
|
+
while (i--) {
|
|
269
|
+
let ei = e[i];
|
|
270
|
+
let j = n.length;
|
|
271
|
+
while (j--) {
|
|
272
|
+
if (n[j].segment.isEntityInside(ei)) {
|
|
273
|
+
this.alignEntityToTheGround(ei, n[j].segment);
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
274
276
|
}
|
|
275
277
|
}
|
|
276
278
|
}
|
|
277
279
|
}
|
|
278
280
|
}
|
|
279
|
-
};
|
|
280
281
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
282
|
+
alignEntityToTheGround(entity, segment) {
|
|
283
|
+
var res = new Vec3();
|
|
284
|
+
segment.getEntityTerrainPoint(entity, res);
|
|
285
|
+
entity._setCartesian3vSilent(res.addA(res.normal().scale((Number(this.layer.relativeToGround) && entity._altitude) || 0.0)));
|
|
286
|
+
}
|
|
286
287
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
isVisible() {
|
|
289
|
+
if (this.layer._renderingNodes[this.nodeId]) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
return false;
|
|
290
293
|
}
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
inherits(EntityCollectionNodeWGS84, EntityCollectionNode);
|
|
300
|
-
|
|
301
|
-
EntityCollectionNodeWGS84.prototype.createChildrenNodes = function () {
|
|
302
|
-
var l = this.layer;
|
|
303
|
-
var ext = this.extent;
|
|
304
|
-
var size_x = ext.getWidth() * 0.5;
|
|
305
|
-
var size_y = ext.getHeight() * 0.5;
|
|
306
|
-
var ne = ext.northEast,
|
|
307
|
-
sw = ext.southWest;
|
|
308
|
-
var id = this.nodeId * 4 + 1;
|
|
309
|
-
var c = new LonLat(sw.lon + size_x, sw.lat + size_y);
|
|
310
|
-
var nd = this.childrenNodes;
|
|
311
|
-
var p = this.layer._planet;
|
|
312
|
-
var z = this.zoom + 1;
|
|
313
|
-
|
|
314
|
-
nd[quadTree.NW] = new EntityCollectionNodeWGS84(l, quadTree.NW, this, id,
|
|
315
|
-
new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
|
|
316
|
-
|
|
317
|
-
nd[quadTree.NE] = new EntityCollectionNodeWGS84(l, quadTree.NE, this, id,
|
|
318
|
-
new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
|
|
319
|
-
|
|
320
|
-
nd[quadTree.SW] = new EntityCollectionNodeWGS84(l, quadTree.SW, this, id,
|
|
321
|
-
new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
|
|
322
|
-
|
|
323
|
-
nd[quadTree.SE] = new EntityCollectionNodeWGS84(l, quadTree.SE, this, id,
|
|
324
|
-
new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
EntityCollectionNodeWGS84.prototype._setExtentBounds = function () {
|
|
328
|
-
if (this.extent.northEast.lat > 0) {
|
|
329
|
-
this.isNorth = true;
|
|
294
|
+
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
class EntityCollectionNodeWGS84 extends EntityCollectionNode {
|
|
298
|
+
|
|
299
|
+
constructor(layer, partId, parent, id, extent, planet, zoom) {
|
|
300
|
+
super(layer, partId, parent, id, extent, planet, zoom);
|
|
301
|
+
this.isNorth = false;
|
|
330
302
|
}
|
|
331
|
-
this.bsphere.setFromExtent(this.layer._planet.ellipsoid, this.extent);
|
|
332
|
-
};
|
|
333
303
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
304
|
+
createChildrenNodes() {
|
|
305
|
+
var l = this.layer;
|
|
306
|
+
var ext = this.extent;
|
|
307
|
+
var size_x = ext.getWidth() * 0.5;
|
|
308
|
+
var size_y = ext.getHeight() * 0.5;
|
|
309
|
+
var ne = ext.northEast,
|
|
310
|
+
sw = ext.southWest;
|
|
311
|
+
var id = this.nodeId * 4 + 1;
|
|
312
|
+
var c = new LonLat(sw.lon + size_x, sw.lat + size_y);
|
|
313
|
+
var nd = this.childrenNodes;
|
|
314
|
+
var p = this.layer._planet;
|
|
315
|
+
var z = this.zoom + 1;
|
|
316
|
+
|
|
317
|
+
nd[quadTree.NW] = new EntityCollectionNodeWGS84(l, quadTree.NW, this, id,
|
|
318
|
+
new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
|
|
319
|
+
|
|
320
|
+
nd[quadTree.NE] = new EntityCollectionNodeWGS84(l, quadTree.NE, this, id,
|
|
321
|
+
new Extent(c, new LonLat(ne.lon, ne.lat)), p, z);
|
|
322
|
+
|
|
323
|
+
nd[quadTree.SW] = new EntityCollectionNodeWGS84(l, quadTree.SW, this, id,
|
|
324
|
+
new Extent(new LonLat(sw.lon, sw.lat), c), p, z);
|
|
325
|
+
|
|
326
|
+
nd[quadTree.SE] = new EntityCollectionNodeWGS84(l, quadTree.SE, this, id,
|
|
327
|
+
new Extent(new LonLat(sw.lon + size_x, sw.lat), new LonLat(ne.lon, sw.lat + size_y)), p, z);
|
|
337
328
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
} else if (this.layer._renderingNodesSouth[this.nodeId]) {
|
|
345
|
-
return true;
|
|
329
|
+
|
|
330
|
+
_setExtentBounds() {
|
|
331
|
+
if (this.extent.northEast.lat > 0) {
|
|
332
|
+
this.isNorth = true;
|
|
333
|
+
}
|
|
334
|
+
this.bsphere.setFromExtent(this.layer._planet.ellipsoid, this.extent);
|
|
346
335
|
}
|
|
347
|
-
return false;
|
|
348
|
-
};
|
|
349
336
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
337
|
+
__setLonLat__(entity) {
|
|
338
|
+
if (entity._lonlat.isZero()) {
|
|
339
|
+
entity._lonlat = this.layer._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
340
|
+
}
|
|
341
|
+
return entity._lonlat;
|
|
342
|
+
}
|
|
353
343
|
|
|
354
|
-
|
|
344
|
+
isVisible() {
|
|
345
|
+
if (this.isNorth && this.layer._renderingNodesNorth[this.nodeId]) {
|
|
346
|
+
return true;
|
|
347
|
+
} else if (this.layer._renderingNodesSouth[this.nodeId]) {
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
355
352
|
|
|
356
|
-
|
|
357
|
-
this.
|
|
358
|
-
} else {
|
|
359
|
-
this.layer._renderingNodesSouth[this.nodeId] = true;
|
|
353
|
+
isInside(entity) {
|
|
354
|
+
return this.extent.isInside(entity._lonlat);
|
|
360
355
|
}
|
|
361
356
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
357
|
+
/**
|
|
358
|
+
*
|
|
359
|
+
* @param {*} outArr
|
|
360
|
+
* @param {*} visibleNodes
|
|
361
|
+
* @param {*} renderingNode
|
|
362
|
+
*/
|
|
363
|
+
renderCollection(outArr, visibleNodes, renderingNode) {
|
|
364
|
+
|
|
365
|
+
if (this.isNorth) {
|
|
366
|
+
this.layer._renderingNodesNorth[this.nodeId] = true;
|
|
365
367
|
} else {
|
|
366
|
-
this.
|
|
368
|
+
this.layer._renderingNodesSouth[this.nodeId] = true;
|
|
367
369
|
}
|
|
368
|
-
}
|
|
369
370
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
if (this.deferredEntities.length && !this._inTheQueue) {
|
|
372
|
+
if (this.layer.async) {
|
|
373
|
+
this.layer._queueDeferredNode(this);
|
|
374
|
+
} else {
|
|
375
|
+
this.applyCollection();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
373
378
|
|
|
374
|
-
|
|
375
|
-
|
|
379
|
+
this.entityCollection._fadingOpacity = this.layer._fadingOpacity;
|
|
380
|
+
this.entityCollection.scaleByDistance = this.layer.scaleByDistance;
|
|
381
|
+
this.entityCollection.pickingScale = this.layer.pickingScale;
|
|
382
|
+
|
|
383
|
+
outArr.push(this.entityCollection);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
376
386
|
|
|
377
|
-
export { EntityCollectionNode, EntityCollectionNodeWGS84 };
|
|
387
|
+
export { EntityCollectionNode, EntityCollectionNodeWGS84 };
|