@openglobus/og 0.16.3 → 0.17.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 +1 -1
- package/css/og.css +24 -2
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/og/Clock.js +1 -5
- package/src/og/Events.js +2 -6
- package/src/og/Extent.js +5 -9
- package/src/og/Globe.js +93 -56
- package/src/og/ImageCanvas.js +13 -6
- package/src/og/Lock.js +44 -48
- package/src/og/LonLat.js +1 -5
- package/src/og/Object3d.js +2 -2
- package/src/og/QueueArray.js +1 -1
- package/src/og/Stack.js +49 -53
- package/src/og/astro/earth.js +112 -116
- package/src/og/astro/jd.js +514 -518
- package/src/og/astro/orbit.js +119 -123
- package/src/og/astro/rotation.js +36 -40
- package/src/og/bv/Box.js +77 -81
- package/src/og/bv/Sphere.js +57 -61
- package/src/og/camera/Camera.js +20 -7
- package/src/og/camera/Frustum.js +4 -4
- package/src/og/camera/PlanetCamera.js +15 -22
- package/src/og/cons.js +1 -1
- package/src/og/control/Atmosphere.js +0 -4
- package/src/og/control/Control.js +9 -8
- package/src/og/control/DebugInfo.js +3 -7
- package/src/og/control/DrawingSwitcher.js +117 -0
- package/src/og/control/EarthCoordinates.js +214 -214
- package/src/og/control/EarthNavigation.js +6 -13
- package/src/og/control/GeoImageDragControl.js +0 -4
- package/src/og/control/KeyboardNavigation.js +0 -4
- package/src/og/control/LayerAnimation.js +0 -4
- package/src/og/control/LayerSwitcher.js +2 -4
- package/src/og/control/Lighting.js +12 -16
- package/src/og/control/MouseNavigation.js +1 -5
- package/src/og/control/MouseWheelZoomControl.js +0 -4
- package/src/og/control/RulerSwitcher.js +0 -4
- package/src/og/control/ScaleControl.js +2 -6
- package/src/og/control/ShowFps.js +40 -44
- package/src/og/control/SimpleNavigation.js +10 -10
- package/src/og/control/SimpleSkyBackground.js +0 -4
- package/src/og/control/Sun.js +0 -4
- package/src/og/control/ToggleWireframe.js +35 -39
- package/src/og/control/ZoomControl.js +0 -4
- package/src/og/control/drawing/DrawingControl.js +51 -0
- package/src/og/control/drawing/LineStringDrawingScene.js +203 -0
- package/src/og/control/drawing/PolygonDrawingScene.js +785 -0
- package/src/og/control/elevationProfile/ElevationProfile.js +275 -0
- package/src/og/control/index.js +5 -1
- package/src/og/control/ruler/Ruler.js +0 -4
- package/src/og/control/ruler/RulerScene.js +3 -2
- package/src/og/control/selection/Selection.js +0 -4
- package/src/og/control/selection/SelectionScene.js +2 -4
- package/src/og/control/timeline/TimelineControl.js +4 -4
- package/src/og/control/timeline/TimelineModel.js +2 -2
- package/src/og/control/timeline/TimelineView.js +1 -0
- package/src/og/control/visibleExtent/Segment.js +7 -7
- package/src/og/control/visibleExtent/drawnode.js +0 -4
- package/src/og/ellipsoid/Ellipsoid.js +236 -325
- package/src/og/ellipsoid/wgs84.js +0 -4
- package/src/og/entity/BaseBillboard.js +375 -379
- package/src/og/entity/Billboard.js +0 -4
- package/src/og/entity/BillboardHandler.js +3 -7
- package/src/og/entity/Entity.js +22 -22
- package/src/og/entity/EntityCollection.js +14 -18
- package/src/og/entity/GeoObject.js +6 -8
- package/src/og/entity/GeoObjectHandler.js +30 -24
- package/src/og/entity/Geometry.js +5 -4
- package/src/og/entity/GeometryHandler.js +18 -19
- package/src/og/entity/Label.js +0 -4
- package/src/og/entity/LabelHandler.js +10 -14
- package/src/og/entity/LabelWorker.js +1 -1
- package/src/og/entity/PointCloud.js +2 -6
- package/src/og/entity/PointCloudHandler.js +122 -126
- package/src/og/entity/Polyline.js +15 -17
- package/src/og/entity/PolylineHandler.js +104 -108
- package/src/og/entity/Ray.js +29 -29
- package/src/og/entity/RayHandler.js +2 -2
- package/src/og/entity/Strip.js +1 -1
- package/src/og/entity/StripHandler.js +2 -2
- package/src/og/index.js +3 -1
- package/src/og/input/KeyboardHandler.js +128 -132
- package/src/og/input/MouseHandler.js +94 -98
- package/src/og/input/TouchHandler.js +59 -63
- package/src/og/input/input.js +44 -48
- package/src/og/layer/BaseGeoImage.js +6 -9
- package/src/og/layer/CanvasTiles.js +1 -5
- package/src/og/layer/GeoImage.js +0 -4
- package/src/og/layer/GeoTexture2d.js +0 -4
- package/src/og/layer/GeoVideo.js +0 -4
- package/src/og/layer/KML.js +1 -0
- package/src/og/layer/Layer.js +22 -26
- package/src/og/layer/Material.js +0 -4
- package/src/og/layer/Vector.js +25 -22
- package/src/og/layer/WMS.js +182 -186
- package/src/og/layer/XYZ.js +0 -4
- package/src/og/light/LightSource.js +0 -4
- package/src/og/math/Line2.js +28 -32
- package/src/og/math/Mat3.js +152 -156
- package/src/og/math/Ray.js +0 -4
- package/src/og/math/Vec2.js +0 -4
- package/src/og/math/Vec3.js +5 -4
- package/src/og/math/Vec4.js +0 -4
- package/src/og/math/coder.js +104 -104
- package/src/og/math.js +42 -10
- package/src/og/mercator.js +1 -1
- package/src/og/proj/EPSG3857.js +13 -13
- package/src/og/proj/Proj.js +59 -63
- package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +1 -0
- package/src/og/quadTree/EarthQuadTreeStrategy.js +1 -0
- package/src/og/quadTree/EntityCollectionNode.js +12 -16
- package/src/og/quadTree/MarsQuadTreeStrategy.js +1 -0
- package/src/og/quadTree/Node.js +15 -14
- package/src/og/quadTree/QuadTreeStrategy.js +1 -0
- package/src/og/quadTree/Wgs84QuadTreeStrategy.js +1 -0
- package/src/og/renderer/Renderer.js +114 -27
- package/src/og/renderer/RendererEvents.js +0 -4
- package/src/og/scene/Axes.js +74 -78
- package/src/og/scene/BaseNode.js +1 -5
- package/src/og/scene/Planet.js +127 -130
- package/src/og/scene/RenderNode.js +20 -12
- package/src/og/scene/SkyBox.js +104 -108
- package/src/og/segment/Segment.js +10 -6
- package/src/og/segment/SegmentLonLat.js +3 -7
- package/src/og/segment/segmentHelper.js +229 -225
- package/src/og/shaders/atmos.js +1 -1
- package/src/og/shaders/billboard.js +0 -4
- package/src/og/shaders/drawnode.js +5 -9
- package/src/og/shaders/geoObject.js +0 -4
- package/src/og/shaders/label.js +0 -4
- package/src/og/shaders/pickingMask.js +0 -4
- package/src/og/shaders/pointCloud.js +0 -4
- package/src/og/shaders/polyline.js +0 -4
- package/src/og/shaders/ray.js +0 -4
- package/src/og/shaders/skybox.js +0 -4
- package/src/og/terrain/EmptyTerrain.js +0 -4
- package/src/og/utils/FontAtlas.js +0 -4
- package/src/og/utils/GeoImageCreator.js +2 -3
- package/src/og/utils/NormalMapCreator.js +11 -12
- package/src/og/utils/PlainSegmentWorker.js +9 -9
- package/src/og/utils/TerrainWorker.js +2 -2
- package/src/og/utils/TextureAtlas.js +1 -1
- package/src/og/utils/VectorTileCreator.js +3 -9
- package/src/og/utils/earcut.js +8 -8
- package/src/og/utils/shared.js +30 -11
- package/src/og/webgl/Framebuffer.js +2 -6
- package/src/og/webgl/Handler.js +46 -20
- package/src/og/webgl/Multisample.js +2 -6
- package/src/og/webgl/Program.js +4 -8
- package/src/og/webgl/ProgramController.js +2 -2
- package/types/Clock.d.ts +1 -1
- package/types/Extent.d.ts +5 -5
- package/types/Globe.d.ts +15 -1
- package/types/ImageCanvas.d.ts +5 -0
- package/types/bv/Box.d.ts +1 -1
- package/types/bv/Sphere.d.ts +3 -3
- package/types/camera/Camera.d.ts +3 -2
- package/types/camera/PlanetCamera.d.ts +4 -4
- package/types/control/DrawingSwitcher.d.ts +13 -0
- package/types/control/EarthCoordinates.d.ts +1 -1
- package/types/control/Lighting.d.ts +8 -8
- package/types/control/drawing/DrawingControl.d.ts +14 -0
- package/types/control/drawing/LineStringDrawingScene.d.ts +5 -0
- package/types/control/drawing/PolygonDrawingScene.d.ts +99 -0
- package/types/control/index.d.ts +3 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/SelectionScene.d.ts +0 -1
- package/types/ellipsoid/Ellipsoid.d.ts +53 -64
- package/types/entity/Entity.d.ts +3 -2
- package/types/entity/GeoObject.d.ts +1 -2
- package/types/entity/Geometry.d.ts +5 -0
- package/types/entity/Polyline.d.ts +1 -1
- package/types/entity/Ray.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/layer/BaseGeoImage.d.ts +1 -1
- package/types/layer/CanvasTiles.d.ts +1 -1
- package/types/layer/Layer.d.ts +1 -1
- package/types/layer/Vector.d.ts +1 -0
- package/types/math/Vec3.d.ts +2 -0
- package/types/math.d.ts +7 -0
- package/types/renderer/Renderer.d.ts +7 -1
- package/types/scene/Axes.d.ts +0 -1
- package/types/scene/Planet.d.ts +27 -26
- package/types/scene/RenderNode.d.ts +2 -0
- package/types/scene/SkyBox.d.ts +0 -1
- package/types/segment/Segment.d.ts +3 -2
- package/types/segment/SegmentLonLat.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +1 -1
- package/types/utils/NormalMapCreator.d.ts +1 -1
- package/types/utils/VectorTileCreator.d.ts +2 -2
- package/types/utils/shared.d.ts +2 -0
- package/types/webgl/Handler.d.ts +6 -4
package/src/og/proj/EPSG3857.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/proj/EPSG3857
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import { Proj, Units } from "./Proj.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* EPSG:3857 projection object.
|
|
11
|
-
* @type {Proj}
|
|
12
|
-
*/
|
|
13
|
-
export const EPSG3857 = new Proj({ code: "epsg:3857", units: Units.METERS });
|
|
1
|
+
/**
|
|
2
|
+
* @module og/proj/EPSG3857
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Proj, Units } from "./Proj.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* EPSG:3857 projection object.
|
|
11
|
+
* @type {Proj}
|
|
12
|
+
*/
|
|
13
|
+
export const EPSG3857 = new Proj({ code: "epsg:3857", units: Units.METERS });
|
package/src/og/proj/Proj.js
CHANGED
|
@@ -1,63 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { Proj };
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Projection units: 'degrees', 'ft', 'm' or 'km'.
|
|
5
|
+
* @enum {string}
|
|
6
|
+
* @api
|
|
7
|
+
*/
|
|
8
|
+
export const Units = {
|
|
9
|
+
DEGREES: "degrees",
|
|
10
|
+
FEET: "ft",
|
|
11
|
+
METERS: "m",
|
|
12
|
+
KILOMETERS: "km"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Meters per unit lookup table.
|
|
17
|
+
* @const
|
|
18
|
+
* @type {Object.<og.proj.Units, number>}
|
|
19
|
+
*/
|
|
20
|
+
export const METERS_PER_UNIT = {};
|
|
21
|
+
METERS_PER_UNIT[Units.FEET] = 0.3048;
|
|
22
|
+
METERS_PER_UNIT[Units.METERS] = 1;
|
|
23
|
+
METERS_PER_UNIT[Units.KILOMETERS] = 1000;
|
|
24
|
+
|
|
25
|
+
let _counter = 0;
|
|
26
|
+
class Proj {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
* @type {string}
|
|
31
|
+
*/
|
|
32
|
+
this.code = options.code;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @public
|
|
36
|
+
* @type {proj.Units}
|
|
37
|
+
*/
|
|
38
|
+
this.units = /** @type {Units} */ (options.units);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Projection identifier, especially usefull for comparison.
|
|
42
|
+
* @const
|
|
43
|
+
* @type {integer}
|
|
44
|
+
*/
|
|
45
|
+
this.id = _counter++;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Compare projections.
|
|
50
|
+
* @public
|
|
51
|
+
* @param {Proj} proj - Projetion object.
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
equal(proj) {
|
|
55
|
+
return proj.id === this.id;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { Proj };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/quadTree/EntityCollectionNode
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
'use strict';
|
|
6
2
|
|
|
7
3
|
import { Sphere } from '../bv/Sphere.js';
|
|
@@ -75,16 +71,16 @@ class EntityCollectionNode {
|
|
|
75
71
|
|
|
76
72
|
__setLonLat__(entity) {
|
|
77
73
|
|
|
78
|
-
if (entity.
|
|
79
|
-
entity.
|
|
74
|
+
if (entity._lonLat.isZero() && !entity._cartesian.isZero()) {
|
|
75
|
+
entity._lonLat = this.layer._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
80
76
|
}
|
|
81
77
|
|
|
82
|
-
if (Math.abs(entity.
|
|
83
|
-
entity.
|
|
78
|
+
if (Math.abs(entity._lonLat.lat) < mercator.MAX_LAT) {
|
|
79
|
+
entity._lonLatMerc = entity._lonLat.forwardMercator();
|
|
84
80
|
} else {
|
|
85
|
-
entity.
|
|
81
|
+
entity._lonLatMerc = null;
|
|
86
82
|
}
|
|
87
|
-
return entity.
|
|
83
|
+
return entity._lonLatMerc;
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
buildTree(entities, rightNow) {
|
|
@@ -131,8 +127,8 @@ class EntityCollectionNode {
|
|
|
131
127
|
}
|
|
132
128
|
|
|
133
129
|
isInside(entity) {
|
|
134
|
-
if (entity.
|
|
135
|
-
return this.extent.isInside(entity.
|
|
130
|
+
if (entity._lonLatMerc) {
|
|
131
|
+
return this.extent.isInside(entity._lonLatMerc);
|
|
136
132
|
} else {
|
|
137
133
|
return false;
|
|
138
134
|
}
|
|
@@ -343,10 +339,10 @@ class EntityCollectionNodeWGS84 extends EntityCollectionNode {
|
|
|
343
339
|
}
|
|
344
340
|
|
|
345
341
|
__setLonLat__(entity) {
|
|
346
|
-
if (entity.
|
|
347
|
-
entity.
|
|
342
|
+
if (entity._lonLat.isZero()) {
|
|
343
|
+
entity._lonLat = this.layer._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
|
|
348
344
|
}
|
|
349
|
-
return entity.
|
|
345
|
+
return entity._lonLat;
|
|
350
346
|
}
|
|
351
347
|
|
|
352
348
|
isVisible() {
|
|
@@ -359,7 +355,7 @@ class EntityCollectionNodeWGS84 extends EntityCollectionNode {
|
|
|
359
355
|
}
|
|
360
356
|
|
|
361
357
|
isInside(entity) {
|
|
362
|
-
return this.extent.isInside(entity.
|
|
358
|
+
return this.extent.isInside(entity._lonLat);
|
|
363
359
|
}
|
|
364
360
|
|
|
365
361
|
/**
|
package/src/og/quadTree/Node.js
CHANGED
|
@@ -76,16 +76,17 @@ class Node {
|
|
|
76
76
|
createChildrenNodes() {
|
|
77
77
|
this.ready = true;
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
const p = this.planet;
|
|
80
|
+
const ps = this.segment;
|
|
81
|
+
const ext = ps._extent;
|
|
82
|
+
const z = ps.tileZoom + 1;
|
|
83
|
+
const size_x = ext.getWidth() * 0.5;
|
|
84
|
+
const size_y = ext.getHeight() * 0.5;
|
|
85
|
+
const ne = ext.northEast;
|
|
86
|
+
const sw = ext.southWest;
|
|
87
|
+
const id = this.nodeId * 4 + 1;
|
|
88
|
+
const c = new LonLat(sw.lon + size_x, sw.lat + size_y);
|
|
89
|
+
const nd = this.nodes;
|
|
89
90
|
|
|
90
91
|
nd[NW] = new Node(this.SegmentPrototype, p, NW, this, id, z, new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)));
|
|
91
92
|
nd[NE] = new Node(this.SegmentPrototype, p, NE, this, id, z, new Extent(c, new LonLat(ne.lon, ne.lat)));
|
|
@@ -333,7 +334,7 @@ class Node {
|
|
|
333
334
|
|
|
334
335
|
var nodes = this.planet._renderedNodes;
|
|
335
336
|
|
|
336
|
-
for (
|
|
337
|
+
for (let i = nodes.length - 1; i >= 0; --i) {
|
|
337
338
|
var ni = nodes[i];
|
|
338
339
|
|
|
339
340
|
var cs = this.getCommonSide(ni);
|
|
@@ -597,7 +598,7 @@ class Node {
|
|
|
597
598
|
tempVerticesHigh = new Float32Array(3 * _vertOrder.length);
|
|
598
599
|
tempVerticesLow = new Float32Array(3 * _vertOrder.length);
|
|
599
600
|
|
|
600
|
-
for (
|
|
601
|
+
for (let i = 0; i < _vertOrder.length; i++) {
|
|
601
602
|
let vi_y = _vertOrder[i].y + t_i0, vi_x = _vertOrder[i].x + t_j0;
|
|
602
603
|
|
|
603
604
|
let vi_x_is = vi_x * gridSize, vi_y_is = vi_y * gridSize;
|
|
@@ -725,7 +726,7 @@ class Node {
|
|
|
725
726
|
if (state === NOTRENDERING || state === RENDERING) {
|
|
726
727
|
this.destroyBranches();
|
|
727
728
|
} else {
|
|
728
|
-
for (
|
|
729
|
+
for (let i = 0; i < this.nodes.length; i++) {
|
|
729
730
|
this.nodes[i] && this.nodes[i].clearTree();
|
|
730
731
|
}
|
|
731
732
|
}
|
|
@@ -763,7 +764,7 @@ class Node {
|
|
|
763
764
|
traverseTree(callback) {
|
|
764
765
|
callback(this);
|
|
765
766
|
if (this.ready) {
|
|
766
|
-
for (
|
|
767
|
+
for (let i = 0; i < this.nodes.length; i++) {
|
|
767
768
|
this.nodes[i].traverseTree(callback);
|
|
768
769
|
}
|
|
769
770
|
}
|
|
@@ -230,11 +230,24 @@ class Renderer {
|
|
|
230
230
|
this.__useDistanceFramebuffer__ = true;
|
|
231
231
|
|
|
232
232
|
if (params.autoActivate || isEmpty(params.autoActivate)) {
|
|
233
|
-
this.initialize();
|
|
234
233
|
this.start();
|
|
235
234
|
}
|
|
236
235
|
}
|
|
237
236
|
|
|
237
|
+
enableBlendOneSrcAlpha() {
|
|
238
|
+
let gl = this.handler.gl;
|
|
239
|
+
gl.enable(gl.BLEND);
|
|
240
|
+
gl.blendEquation(gl.FUNC_ADD);
|
|
241
|
+
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
enableBlendDefault() {
|
|
245
|
+
let gl = this.handler.gl;
|
|
246
|
+
gl.enable(gl.BLEND);
|
|
247
|
+
gl.blendEquation(gl.FUNC_ADD);
|
|
248
|
+
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
|
|
249
|
+
}
|
|
250
|
+
|
|
238
251
|
/**
|
|
239
252
|
* Sets renderer events activity.
|
|
240
253
|
* @param {Boolean} activity - Events activity.
|
|
@@ -252,7 +265,7 @@ class Renderer {
|
|
|
252
265
|
}
|
|
253
266
|
|
|
254
267
|
removeDepthCallback(id) {
|
|
255
|
-
for (
|
|
268
|
+
for (let i = 0; i < this._depthCallbacks.length; i++) {
|
|
256
269
|
if (id === this._depthCallbacks[i].id) {
|
|
257
270
|
this._depthCallbacks.splice(i, 1);
|
|
258
271
|
break;
|
|
@@ -269,7 +282,7 @@ class Renderer {
|
|
|
269
282
|
}
|
|
270
283
|
|
|
271
284
|
removeDistanceCallback(id) {
|
|
272
|
-
for (
|
|
285
|
+
for (let i = 0; i < this._distanceCallbacks.length; i++) {
|
|
273
286
|
if (id === this._distanceCallbacks[i].id) {
|
|
274
287
|
this._distanceCallbacks.splice(i, 1);
|
|
275
288
|
break;
|
|
@@ -297,7 +310,7 @@ class Renderer {
|
|
|
297
310
|
* @param {Number} id - Handler id to remove.
|
|
298
311
|
*/
|
|
299
312
|
removePickingCallback(id) {
|
|
300
|
-
for (
|
|
313
|
+
for (let i = 0; i < this._pickingCallbacks.length; i++) {
|
|
301
314
|
if (id === this._pickingCallbacks[i].id) {
|
|
302
315
|
this._pickingCallbacks.splice(i, 1);
|
|
303
316
|
break;
|
|
@@ -401,7 +414,7 @@ class Renderer {
|
|
|
401
414
|
* @param {Array.<control.Control>} cArr - Control array.
|
|
402
415
|
*/
|
|
403
416
|
addControls(cArr) {
|
|
404
|
-
for (
|
|
417
|
+
for (let i = 0; i < cArr.length; i++) {
|
|
405
418
|
cArr[i].addTo(this);
|
|
406
419
|
}
|
|
407
420
|
}
|
|
@@ -414,17 +427,24 @@ class Renderer {
|
|
|
414
427
|
control.remove();
|
|
415
428
|
}
|
|
416
429
|
|
|
430
|
+
isInitialized() {
|
|
431
|
+
return this._initialized;
|
|
432
|
+
}
|
|
433
|
+
|
|
417
434
|
/**
|
|
418
435
|
* Renderer initialization.
|
|
419
436
|
* @public
|
|
420
437
|
*/
|
|
421
438
|
initialize() {
|
|
439
|
+
|
|
422
440
|
if (this._initialized) {
|
|
423
441
|
return;
|
|
424
442
|
} else {
|
|
425
443
|
this._initialized = true;
|
|
426
444
|
}
|
|
427
445
|
|
|
446
|
+
this.handler.initialize();
|
|
447
|
+
|
|
428
448
|
this.billboardsTextureAtlas.assignHandler(this.handler);
|
|
429
449
|
this.geoObjectsTextureAtlas.assignHandler(this.handler);
|
|
430
450
|
|
|
@@ -537,17 +557,24 @@ class Renderer {
|
|
|
537
557
|
|
|
538
558
|
this.screenFramePositionBuffer = this.handler.createArrayBuffer(new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), 2, 4);
|
|
539
559
|
|
|
540
|
-
let temp = this.controls;
|
|
541
|
-
this.controls = {};
|
|
542
|
-
for (let i in temp) {
|
|
543
|
-
this.addControl(temp[i]);
|
|
544
|
-
}
|
|
545
560
|
|
|
546
561
|
this.outputTexture = this.screenTexture.screen;
|
|
547
562
|
|
|
548
563
|
this.fontAtlas.initFont("arial", arial.data, arial.image);
|
|
549
564
|
|
|
550
565
|
this._pickingMaskCoordinatesBuffer = this.handler.createArrayBuffer(new Float32Array([0, 0]), 2, 1);
|
|
566
|
+
|
|
567
|
+
this._initializeRenderNodes();
|
|
568
|
+
|
|
569
|
+
this._initializeControls();
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
_initializeControls() {
|
|
573
|
+
let temp = this.controls;
|
|
574
|
+
this.controls = {};
|
|
575
|
+
for (let i in temp) {
|
|
576
|
+
this.addControl(temp[i]);
|
|
577
|
+
}
|
|
551
578
|
}
|
|
552
579
|
|
|
553
580
|
resize() {
|
|
@@ -616,6 +643,12 @@ class Renderer {
|
|
|
616
643
|
}
|
|
617
644
|
}
|
|
618
645
|
|
|
646
|
+
_initializeRenderNodes() {
|
|
647
|
+
for (let i = 0; i < this._renderNodesArr.length; i++) {
|
|
648
|
+
this._renderNodesArr[i].initialize();
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
619
652
|
/**
|
|
620
653
|
* Adds render node to the renderer before specific node.
|
|
621
654
|
* @public
|
|
@@ -643,7 +676,7 @@ class Renderer {
|
|
|
643
676
|
* @param {Array.<scene.RenderNode>} nodesArr - Render nodes array.
|
|
644
677
|
*/
|
|
645
678
|
addNodes(nodesArr) {
|
|
646
|
-
for (
|
|
679
|
+
for (let i = 0; i < nodesArr.length; i++) {
|
|
647
680
|
this.addNode(nodesArr[i]);
|
|
648
681
|
}
|
|
649
682
|
}
|
|
@@ -674,10 +707,8 @@ class Renderer {
|
|
|
674
707
|
let ec = this._entityCollections;
|
|
675
708
|
|
|
676
709
|
if (ec.length) {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
gl.blendEquation(gl.FUNC_ADD);
|
|
680
|
-
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
|
|
710
|
+
|
|
711
|
+
this.enableBlendDefault();
|
|
681
712
|
|
|
682
713
|
//geoObject
|
|
683
714
|
let i = ec.length;
|
|
@@ -709,9 +740,7 @@ class Renderer {
|
|
|
709
740
|
if (ec.length) {
|
|
710
741
|
let gl = this.handler.gl;
|
|
711
742
|
|
|
712
|
-
|
|
713
|
-
gl.blendEquation(gl.FUNC_ADD);
|
|
714
|
-
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
|
|
743
|
+
this.enableBlendDefault();
|
|
715
744
|
|
|
716
745
|
// billboards pass
|
|
717
746
|
gl.activeTexture(gl.TEXTURE0);
|
|
@@ -775,10 +804,6 @@ class Renderer {
|
|
|
775
804
|
|
|
776
805
|
let h = this.handler, gl = h.gl;
|
|
777
806
|
|
|
778
|
-
gl.enable(gl.BLEND);
|
|
779
|
-
gl.blendEquation(gl.FUNC_ADD);
|
|
780
|
-
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
|
|
781
|
-
|
|
782
807
|
gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
|
783
808
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
784
809
|
|
|
@@ -805,10 +830,7 @@ class Renderer {
|
|
|
805
830
|
|
|
806
831
|
i = rn.length;
|
|
807
832
|
while (i--) {
|
|
808
|
-
|
|
809
|
-
gl.blendEquation(gl.FUNC_ADD);
|
|
810
|
-
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
|
|
811
|
-
|
|
833
|
+
this.enableBlendDefault();
|
|
812
834
|
rn[i].drawNode();
|
|
813
835
|
}
|
|
814
836
|
|
|
@@ -1087,12 +1109,77 @@ class Renderer {
|
|
|
1087
1109
|
}
|
|
1088
1110
|
|
|
1089
1111
|
/**
|
|
1090
|
-
* Function starts
|
|
1112
|
+
* Function starts renderer
|
|
1091
1113
|
* @public
|
|
1092
1114
|
*/
|
|
1093
1115
|
start() {
|
|
1116
|
+
if (!this._initialized) {
|
|
1117
|
+
this.initialize();
|
|
1118
|
+
}
|
|
1094
1119
|
this.handler.start();
|
|
1095
1120
|
}
|
|
1121
|
+
|
|
1122
|
+
destroy() {
|
|
1123
|
+
for (let i in this.controls) {
|
|
1124
|
+
this.controls[i].remove();
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
for (let i = 0; i < this._renderNodesArr.length; i++) {
|
|
1128
|
+
this._renderNodesArr[i].remove();
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
this.div = null;
|
|
1132
|
+
|
|
1133
|
+
this._renderNodesArr = [];
|
|
1134
|
+
|
|
1135
|
+
this.renderNodes = {};
|
|
1136
|
+
|
|
1137
|
+
this.activeCamera = null;
|
|
1138
|
+
|
|
1139
|
+
this.controls = {};
|
|
1140
|
+
|
|
1141
|
+
this.controlsBag = {};
|
|
1142
|
+
|
|
1143
|
+
this.colorObjects = new Map();
|
|
1144
|
+
|
|
1145
|
+
this._pickingCallbacks = [];
|
|
1146
|
+
|
|
1147
|
+
this.pickingFramebuffer = null;
|
|
1148
|
+
|
|
1149
|
+
this._tempPickingPix_ = null;
|
|
1150
|
+
|
|
1151
|
+
this.distanceFramebuffer = null;
|
|
1152
|
+
|
|
1153
|
+
this._distanceCallbacks = [];
|
|
1154
|
+
|
|
1155
|
+
this._tempDistancePix_ = null;
|
|
1156
|
+
|
|
1157
|
+
this._depthCallbacks = [];
|
|
1158
|
+
|
|
1159
|
+
this.depthFramebuffer = null;
|
|
1160
|
+
|
|
1161
|
+
this.sceneFramebuffer = null;
|
|
1162
|
+
|
|
1163
|
+
this.blitFramebuffer = null;
|
|
1164
|
+
|
|
1165
|
+
this.toneMappingFramebuffer = null;
|
|
1166
|
+
|
|
1167
|
+
// todo
|
|
1168
|
+
//this.billboardsTextureAtlas.clear();
|
|
1169
|
+
//this.geoObjectsTextureAtlas.clear()
|
|
1170
|
+
//this.fontAtlas.clear();
|
|
1171
|
+
|
|
1172
|
+
this._entityCollections = [];
|
|
1173
|
+
|
|
1174
|
+
this.colorObjects = null;
|
|
1175
|
+
|
|
1176
|
+
this.handler.destroy();
|
|
1177
|
+
|
|
1178
|
+
this.handler = null;
|
|
1179
|
+
|
|
1180
|
+
this._initialized = false;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1096
1183
|
}
|
|
1097
1184
|
|
|
1098
1185
|
export { Renderer };
|