@openglobus/og 0.10.4 → 0.11.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/css/og.css +1 -1
- package/package.json +11 -9
- package/src/og/Extent.js +274 -273
- package/src/og/Globe.js +11 -3
- package/src/og/LonLat.js +152 -146
- package/src/og/Popup.js +2 -1
- package/src/og/camera/PlanetCamera.js +112 -38
- package/src/og/control/EarthNavigation.js +259 -0
- package/src/og/control/MouseNavigation.js +68 -40
- package/src/og/entity/EntityCollection.js +1 -1
- package/src/og/entity/LabelHandler.js +366 -74
- package/src/og/entity/Polyline.js +3 -2
- package/src/og/layer/CanvasTiles.js +32 -30
- package/src/og/layer/KML.js +159 -0
- package/src/og/layer/Vector.js +5 -0
- package/src/og/layer/index.js +2 -1
- package/src/og/math/Vec2.js +448 -448
- package/src/og/math/Vec3.js +759 -757
- package/src/og/math/Vec4.js +216 -215
- package/src/og/quadTree/Node.js +67 -13
- package/src/og/renderer/RendererEvents.js +21 -16
- package/src/og/scene/Planet.js +25 -10
- package/src/og/segment/Segment.js +3 -3
- package/src/og/segment/SegmentLonLat.js +7 -0
- package/src/og/terrain/GlobusTerrain.js +4 -0
- package/src/og/utils/FontAtlas.js +1 -0
- package/src/og/utils/GeoImageCreator.js +123 -121
- package/src/og/utils/Loader.js +81 -80
- package/src/og/utils/NormalMapCreator.js +320 -318
- package/src/og/utils/VectorTileCreator.js +251 -250
- package/src/og/webgl/Framebuffer.js +265 -264
- package/src/og/webgl/Handler.js +1022 -1001
- package/src/og/webgl/Multisample.js +169 -168
- package/src/og/webgl/ProgramController.js +113 -112
- package/types/Clock.d.ts +90 -0
- package/types/Deferred.d.ts +6 -0
- package/types/Events.d.ts +73 -0
- package/types/Extent.d.ts +162 -0
- package/types/Globe.d.ts +80 -0
- package/types/ImageCanvas.d.ts +121 -0
- package/types/Lock.d.ts +12 -0
- package/types/LonLat.d.ts +108 -0
- package/types/Popup.d.ts +38 -0
- package/types/QueueArray.d.ts +15 -0
- package/types/Rectangle.d.ts +74 -0
- package/types/Stack.d.ts +15 -0
- package/types/ajax.d.ts +24 -0
- package/types/arial.d.ts +48 -0
- package/types/astro/astro.d.ts +38 -0
- package/types/astro/earth.d.ts +6 -0
- package/types/astro/jd.d.ts +254 -0
- package/types/bv/Box.d.ts +25 -0
- package/types/bv/Sphere.d.ts +32 -0
- package/types/bv/index.d.ts +3 -0
- package/types/camera/Camera.d.ts +303 -0
- package/types/camera/Frustum.d.ts +129 -0
- package/types/camera/PlanetCamera.d.ts +222 -0
- package/types/camera/index.d.ts +3 -0
- package/types/cons.d.ts +40 -0
- package/types/control/CompassButton.d.ts +17 -0
- package/types/control/Control.d.ts +101 -0
- package/types/control/DebugInfo.d.ts +16 -0
- package/types/control/EarthCoordinates.d.ts +47 -0
- package/types/control/GeoImageDragControl.d.ts +6 -0
- package/types/control/KeyboardNavigation.d.ts +22 -0
- package/types/control/LayerSwitcher.d.ts +23 -0
- package/types/control/Lighting.d.ts +16 -0
- package/types/control/ScaleControl.d.ts +22 -0
- package/types/control/ShowFps.d.ts +12 -0
- package/types/control/SimpleNavigation.d.ts +28 -0
- package/types/control/Sun.d.ts +52 -0
- package/types/control/ToggleWireframe.d.ts +12 -0
- package/types/control/ZoomControl.d.ts +28 -0
- package/types/control/index.d.ts +15 -0
- package/types/ellipsoid/Ellipsoid.d.ts +142 -0
- package/types/ellipsoid/index.d.ts +3 -0
- package/types/ellipsoid/wgs84.d.ts +5 -0
- package/types/entity/BaseBillboard.d.ts +208 -0
- package/types/entity/Billboard.d.ts +94 -0
- package/types/entity/BillboardHandler.d.ts +74 -0
- package/types/entity/Entity.d.ts +330 -0
- package/types/entity/EntityCollection.d.ts +303 -0
- package/types/entity/Geometry.d.ts +72 -0
- package/types/entity/GeometryHandler.d.ts +76 -0
- package/types/entity/Label.d.ts +194 -0
- package/types/entity/LabelHandler.d.ts +24 -0
- package/types/entity/PointCloud.d.ts +174 -0
- package/types/entity/PointCloudHandler.d.ts +38 -0
- package/types/entity/Polyline.d.ts +303 -0
- package/types/entity/PolylineHandler.d.ts +18 -0
- package/types/entity/Ray.d.ts +123 -0
- package/types/entity/RayHandler.d.ts +67 -0
- package/types/entity/ShapeHandler.d.ts +22 -0
- package/types/entity/Strip.d.ts +118 -0
- package/types/entity/StripHandler.d.ts +38 -0
- package/types/entity/index.d.ts +8 -0
- package/types/index.core.d.ts +65 -0
- package/types/index.d.ts +45 -0
- package/types/index.webgl.d.ts +7 -0
- package/types/inherits.d.ts +4 -0
- package/types/input/input.d.ts +34 -0
- package/types/layer/BaseGeoImage.d.ts +106 -0
- package/types/layer/CanvasTiles.d.ts +75 -0
- package/types/layer/GeoImage.d.ts +65 -0
- package/types/layer/GeoTexture2d.d.ts +8 -0
- package/types/layer/GeoVideo.d.ts +80 -0
- package/types/layer/KML.d.ts +58 -0
- package/types/layer/WMS.d.ts +66 -0
- package/types/layer/XYZ.d.ts +126 -0
- package/types/layer/index.d.ts +10 -0
- package/types/light/LightSource.d.ts +177 -0
- package/types/math/Mat3.d.ts +53 -0
- package/types/math/Mat4.d.ts +157 -0
- package/types/math/Plane.d.ts +17 -0
- package/types/math/Vec2.d.ts +308 -0
- package/types/math/Vec3.d.ts +459 -0
- package/types/math/Vec4.d.ts +161 -0
- package/types/math/coder.d.ts +42 -0
- package/types/math/index.d.ts +11 -0
- package/types/math.d.ts +261 -0
- package/types/mercator.d.ts +92 -0
- package/types/proj/EPSG3857.d.ts +5 -0
- package/types/proj/EPSG4326.d.ts +5 -0
- package/types/quadTree/quadTree.d.ts +40 -0
- package/types/renderer/RendererEvents.d.ts +230 -0
- package/types/res/images.d.ts +3 -0
- package/types/scene/Axes.d.ts +11 -0
- package/types/scene/BaseNode.d.ts +60 -0
- package/types/scene/Planet.d.ts +572 -0
- package/types/scene/RenderNode.d.ts +143 -0
- package/types/scene/SkyBox.d.ts +10 -0
- package/types/scene/index.d.ts +4 -0
- package/types/segment/segmentHelper.d.ts +13 -0
- package/types/shaders/billboard.d.ts +3 -0
- package/types/shaders/depth.d.ts +2 -0
- package/types/shaders/drawnode.d.ts +7 -0
- package/types/shaders/label.d.ts +4 -0
- package/types/shaders/pointCloud.d.ts +2 -0
- package/types/shaders/polyline.d.ts +3 -0
- package/types/shaders/ray.d.ts +2 -0
- package/types/shaders/screenFrame.d.ts +2 -0
- package/types/shaders/shape.d.ts +4 -0
- package/types/shaders/skybox.d.ts +2 -0
- package/types/shaders/toneMapping.d.ts +2 -0
- package/types/shapes/BaseShape.d.ts +247 -0
- package/types/shapes/Sphere.d.ts +41 -0
- package/types/terrain/BilTerrain.d.ts +8 -0
- package/types/terrain/EmptyTerrain.d.ts +72 -0
- package/types/terrain/Geoid.d.ts +26 -0
- package/types/terrain/GlobusTerrain.d.ts +153 -0
- package/types/terrain/MapboxTerrain.d.ts +8 -0
- package/types/terrain/index.d.ts +5 -0
- package/types/utils/FontAtlas.d.ts +14 -0
- package/types/utils/GeoImageCreator.d.ts +29 -0
- package/types/utils/ImagesCacheManager.d.ts +10 -0
- package/types/utils/Loader.d.ts +25 -0
- package/types/utils/NormalMapCreator.d.ts +39 -0
- package/types/utils/PlainSegmentWorker.d.ts +10 -0
- package/types/utils/TerrainWorker.d.ts +9 -0
- package/types/utils/TextureAtlas.d.ts +111 -0
- package/types/utils/VectorTileCreator.d.ts +16 -0
- package/types/utils/colorTable.d.ts +143 -0
- package/types/utils/earcut.d.ts +6 -0
- package/types/utils/shared.d.ts +230 -0
- package/types/webgl/Framebuffer.d.ts +135 -0
- package/types/webgl/Handler.d.ts +372 -0
- package/types/webgl/Multisample.d.ts +89 -0
- package/types/webgl/Program.d.ts +155 -0
- package/types/webgl/ProgramController.d.ts +84 -0
- package/types/webgl/callbacks.d.ts +1 -0
- package/types/webgl/index.d.ts +6 -0
- package/types/webgl/types.d.ts +2 -0
package/src/og/scene/Planet.js
CHANGED
|
@@ -100,7 +100,7 @@ const EVENT_NAMES = [
|
|
|
100
100
|
* @fires og.scene.Planet#layervisibilitychange
|
|
101
101
|
* @fires og.scene.Planet#geoimageadd
|
|
102
102
|
*/
|
|
103
|
-
class Planet extends RenderNode {
|
|
103
|
+
export class Planet extends RenderNode {
|
|
104
104
|
constructor(options = {}) {
|
|
105
105
|
super(options.name);
|
|
106
106
|
|
|
@@ -174,6 +174,9 @@ class Planet extends RenderNode {
|
|
|
174
174
|
*/
|
|
175
175
|
this.camera = null;
|
|
176
176
|
|
|
177
|
+
this._minAltitude = options.minAltitude;
|
|
178
|
+
this._maxAltitude = options.maxAltitude;
|
|
179
|
+
|
|
177
180
|
/**
|
|
178
181
|
* Screen mouse pointer projected to planet cartesian position.
|
|
179
182
|
* @public
|
|
@@ -672,6 +675,10 @@ class Planet extends RenderNode {
|
|
|
672
675
|
}
|
|
673
676
|
}
|
|
674
677
|
|
|
678
|
+
this.renderer.events.on("resize", () => {
|
|
679
|
+
this._renderCompletedActivated = false;
|
|
680
|
+
});
|
|
681
|
+
|
|
675
682
|
// Initialize texture coordinates buffer pool
|
|
676
683
|
this._textureCoordsBufferCache = [];
|
|
677
684
|
|
|
@@ -699,7 +706,9 @@ class Planet extends RenderNode {
|
|
|
699
706
|
this.camera = this.renderer.activeCamera = new PlanetCamera(this, {
|
|
700
707
|
eye: new Vec3(0, 0, 28000000),
|
|
701
708
|
look: new Vec3(0, 0, 0),
|
|
702
|
-
up: new Vec3(0, 1, 0)
|
|
709
|
+
up: new Vec3(0, 1, 0),
|
|
710
|
+
minAltitude: this._minAltitude,
|
|
711
|
+
maxAltitude: this._maxAltitude
|
|
703
712
|
});
|
|
704
713
|
|
|
705
714
|
this.camera.update();
|
|
@@ -800,11 +809,11 @@ class Planet extends RenderNode {
|
|
|
800
809
|
this._quadTree.renderNode();
|
|
801
810
|
this._normalMapCreator.drawSingle(this._quadTree.segment);
|
|
802
811
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
812
|
+
for (var i = 0; i < this._quadTree.nodes.length; i++) {
|
|
813
|
+
this._quadTree.nodes[i].segment.createPlainSegment();
|
|
814
|
+
this._quadTree.nodes[i].renderNode(true);
|
|
815
|
+
this._normalMapCreator.drawSingle(this._quadTree.nodes[i].segment);
|
|
816
|
+
}
|
|
808
817
|
|
|
809
818
|
this._quadTreeNorth.createChildrenNodes();
|
|
810
819
|
this._quadTreeNorth.segment.createPlainSegment();
|
|
@@ -1087,7 +1096,9 @@ class Planet extends RenderNode {
|
|
|
1087
1096
|
gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
1088
1097
|
|
|
1089
1098
|
if (frustumIndex === cam.FARTHEST_FRUSTUM_INDEX) {
|
|
1090
|
-
this.
|
|
1099
|
+
if (!this._renderCompletedActivated || this.camera._moved) {
|
|
1100
|
+
this._collectRenderNodes();
|
|
1101
|
+
}
|
|
1091
1102
|
|
|
1092
1103
|
// Here is the planet node dispatches a draw event before
|
|
1093
1104
|
// rendering begins and we have got render nodes.
|
|
@@ -1691,6 +1702,9 @@ class Planet extends RenderNode {
|
|
|
1691
1702
|
* @param {og.Vec3} [look] - Camera "look at" point.
|
|
1692
1703
|
* @param {og.Vec3} [up] - Camera UP vector on the end of a flying.
|
|
1693
1704
|
* @param {Number} [ampl] - Altitude amplitude factor.
|
|
1705
|
+
* @param [completeCallback]
|
|
1706
|
+
* @param [startCallback]
|
|
1707
|
+
* @param [frameCallback]
|
|
1694
1708
|
*/
|
|
1695
1709
|
flyCartesian(cartesian, look, up, ampl, completeCallback, startCallback, frameCallback) {
|
|
1696
1710
|
this.renderer.activeCamera.flyCartesian(
|
|
@@ -1711,6 +1725,9 @@ class Planet extends RenderNode {
|
|
|
1711
1725
|
* @param {og.Vec3} [look] - Camera "look at" point on the end of a flying.
|
|
1712
1726
|
* @param {og.Vec3} [up] - Camera UP vector on the end of a flying.
|
|
1713
1727
|
* @param {Number} [ampl] - Altitude amplitude factor.
|
|
1728
|
+
* @param [completeCallback]
|
|
1729
|
+
* @param [startCallback]
|
|
1730
|
+
* @param [frameCallback]
|
|
1714
1731
|
*/
|
|
1715
1732
|
flyLonLat(lonlat, look, up, ampl, completeCallback, startCallback, frameCallback) {
|
|
1716
1733
|
this.renderer.activeCamera.flyLonLat(
|
|
@@ -1761,5 +1778,3 @@ class Planet extends RenderNode {
|
|
|
1761
1778
|
}
|
|
1762
1779
|
}
|
|
1763
1780
|
}
|
|
1764
|
-
|
|
1765
|
-
export { Planet };
|
|
@@ -12,7 +12,7 @@ import { Box } from "../bv/Box.js";
|
|
|
12
12
|
import { Vec3 } from "../math/Vec3.js";
|
|
13
13
|
import * as segmentHelper from "../segment/segmentHelper.js";
|
|
14
14
|
|
|
15
|
-
export const MAX_NORMAL_ZOOM =
|
|
15
|
+
export const MAX_NORMAL_ZOOM = 7;
|
|
16
16
|
|
|
17
17
|
var _tempHigh = new Vec3();
|
|
18
18
|
var _tempLow = new Vec3();
|
|
@@ -1000,7 +1000,7 @@ Segment.prototype.createBoundsByExtent = function () {
|
|
|
1000
1000
|
var coord_ne = ellipsoid.geodeticToCartesian(extent.northEast.lon, extent.northEast.lat);
|
|
1001
1001
|
|
|
1002
1002
|
// check for zoom
|
|
1003
|
-
if (this.tileZoom
|
|
1003
|
+
if (this.tileZoom <= MAX_NORMAL_ZOOM) {
|
|
1004
1004
|
var coord_nw = ellipsoid.geodeticToCartesian(extent.southWest.lon, extent.northEast.lat);
|
|
1005
1005
|
var coord_se = ellipsoid.geodeticToCartesian(extent.northEast.lon, extent.southWest.lat);
|
|
1006
1006
|
|
|
@@ -1037,7 +1037,7 @@ Segment.prototype.createBoundsByParent = function () {
|
|
|
1037
1037
|
this.bsphere.center.z = pn.segment.bsphere.center.z;
|
|
1038
1038
|
this.bsphere.radius = pn.segment.bsphere.radius;
|
|
1039
1039
|
|
|
1040
|
-
if (this.tileZoom
|
|
1040
|
+
if (this.tileZoom <= MAX_NORMAL_ZOOM) {
|
|
1041
1041
|
let i0 = gridSize * offsetY;
|
|
1042
1042
|
let j0 = gridSize * offsetX;
|
|
1043
1043
|
|
|
@@ -93,6 +93,13 @@ SegmentLonLat.prototype._assignTileIndexes = function () {
|
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
var p2 = Math.pow(2, tileZoom);
|
|
97
|
+
this.tileXE = (this.tileX + 1) % p2;
|
|
98
|
+
this.tileXW = (p2 + this.tileX - 1) % p2;
|
|
99
|
+
|
|
100
|
+
this.tileYN = this.tileY - 1;
|
|
101
|
+
this.tileYS = this.tileY + 1;
|
|
102
|
+
|
|
96
103
|
this.tileIndex = Layer.getTileIndex(this.tileX, this.tileY, tileZoom);
|
|
97
104
|
};
|
|
98
105
|
|
|
@@ -1,143 +1,145 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
import { LonLat } from '../LonLat.js';
|
|
3
4
|
import * as utils from '../utils/shared.js';
|
|
4
5
|
import { Framebuffer } from '../webgl/Framebuffer.js';
|
|
5
|
-
import { LonLat } from '../LonLat.js';
|
|
6
6
|
import { Program } from '../webgl/Program.js';
|
|
7
7
|
import { types } from '../webgl/types.js';
|
|
8
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
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
9
|
+
export class GeoImageCreator {
|
|
10
|
+
|
|
11
|
+
constructor(planet, maxFrames) {
|
|
12
|
+
this._gridSize = 64;
|
|
13
|
+
this._planet = planet;
|
|
14
|
+
this._framebuffer = null;
|
|
15
|
+
this._texCoordsBuffer = null;
|
|
16
|
+
this._indexBuffer = null;
|
|
17
|
+
this.MAX_FRAMES = maxFrames || 5;
|
|
18
|
+
this._currentFrame = 0;
|
|
19
|
+
this._queue = [];
|
|
20
|
+
this._animate = [];
|
|
21
|
+
this._initialize();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
_initialize() {
|
|
25
|
+
this._initShaders();
|
|
26
|
+
this._initBuffers();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates geoImage corners coordinates grid buffer.
|
|
31
|
+
* @public
|
|
32
|
+
* @param{Array.<og.LonLat>} c - GeoImage corners coordinates.
|
|
33
|
+
* @return{WebGLBuffer} Grid coordinates buffer.
|
|
34
|
+
*/
|
|
35
|
+
createGridBuffer(c, toMerc) {
|
|
36
|
+
var gs = this._gridSize;
|
|
37
|
+
|
|
38
|
+
var v03 = new LonLat((c[3].lon - c[0].lon) / gs, (c[3].lat - c[0].lat) / gs),
|
|
39
|
+
v12 = new LonLat((c[2].lon - c[1].lon) / gs, (c[2].lat - c[1].lat) / gs),
|
|
40
|
+
v01 = new LonLat((c[1].lon - c[0].lon) / gs, (c[1].lat - c[0].lat) / gs),
|
|
41
|
+
v32 = new LonLat((c[2].lon - c[3].lon) / gs, (c[2].lat - c[3].lat) / gs);
|
|
42
|
+
|
|
43
|
+
var grid = new Float32Array((gs + 1) * (gs + 1) * 2);
|
|
44
|
+
var k = 0;
|
|
45
|
+
for (let i = 0; i <= gs; i++) {
|
|
46
|
+
var P03i = new LonLat(c[0].lon + i * v03.lon, c[0].lat + i * v03.lat),
|
|
47
|
+
P12i = new LonLat(c[1].lon + i * v12.lon, c[1].lat + i * v12.lat);
|
|
48
|
+
for (let j = 0; j <= gs; j++) {
|
|
49
|
+
var P01j = new LonLat(c[0].lon + j * v01.lon, c[0].lat + j * v01.lat),
|
|
50
|
+
P32j = new LonLat(c[3].lon + j * v32.lon, c[3].lat + j * v32.lat);
|
|
51
|
+
var xx = utils.getLinesIntersectionLonLat(P03i, P12i, P01j, P32j);
|
|
52
|
+
grid[k++] = xx.lon;
|
|
53
|
+
grid[k++] = xx.lat;
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
|
-
}
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
if (toMerc) {
|
|
58
|
+
for (let i = 0; i < grid.length; i += 2) {
|
|
59
|
+
let c = new LonLat(grid[i], grid[i + 1]).forwardMercator();
|
|
60
|
+
grid[i] = c.lon;
|
|
61
|
+
grid[i + 1] = c.lat;
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
q.rendering();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
i = this._animate.length;
|
|
74
|
-
while (i--) {
|
|
75
|
-
this._animate[i].rendering();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
GeoImageCreator.prototype.add = function (geoImage) {
|
|
80
|
-
if (!geoImage._isRendering) {
|
|
81
|
-
geoImage._isRendering = true;
|
|
82
|
-
if (geoImage._animate) {
|
|
83
|
-
this._animate.push(geoImage);
|
|
84
|
-
} else {
|
|
85
|
-
this._queue.push(geoImage);
|
|
64
|
+
return this._planet.renderer.handler.createArrayBuffer(grid, 2, grid.length / 2);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
frame() {
|
|
68
|
+
var i = this.MAX_FRAMES;
|
|
69
|
+
while (i-- && this._queue.length) {
|
|
70
|
+
var q = this._queue.shift();
|
|
71
|
+
q._isRendering = false;
|
|
72
|
+
q.rendering();
|
|
86
73
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (geoImage.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
|
|
75
|
+
i = this._animate.length;
|
|
76
|
+
while (i--) {
|
|
77
|
+
this._animate[i].rendering();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
add(geoImage) {
|
|
82
|
+
if (!geoImage._isRendering) {
|
|
83
|
+
geoImage._isRendering = true;
|
|
84
|
+
if (geoImage._animate) {
|
|
85
|
+
this._animate.push(geoImage);
|
|
86
|
+
} else {
|
|
87
|
+
this._queue.push(geoImage);
|
|
88
|
+
}
|
|
99
89
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
remove(geoImage) {
|
|
93
|
+
if (geoImage._isRendering) {
|
|
94
|
+
geoImage._creationProceeding = false;
|
|
95
|
+
geoImage._isRendering = false;
|
|
96
|
+
var arr;
|
|
97
|
+
if (geoImage._animate) {
|
|
98
|
+
arr = this._animate;
|
|
99
|
+
} else {
|
|
100
|
+
arr = this._queue;
|
|
101
|
+
}
|
|
102
|
+
for (var i = 0; i < arr.length; i++) {
|
|
103
|
+
if (arr[i].isEqual(geoImage)) {
|
|
104
|
+
arr.splice(i, 1);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
109
|
+
};
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
_initBuffers() {
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
let h = this._planet.renderer.handler;
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
this._framebuffer = new Framebuffer(h, { width: 2, height: 2, useDepth: false });
|
|
116
|
+
this._framebuffer.init();
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
this._framebufferMercProj = new Framebuffer(h, { width: 2, height: 2, useDepth: false });
|
|
119
|
+
this._framebufferMercProj.init();
|
|
118
120
|
|
|
119
|
-
|
|
121
|
+
let gs = Math.log2(this._gridSize);
|
|
120
122
|
|
|
121
|
-
|
|
123
|
+
this._texCoordsBuffer = this._planet._textureCoordsBufferCache[gs];
|
|
122
124
|
|
|
123
|
-
|
|
125
|
+
this._indexBuffer = this._planet._indexesCache[gs][gs][gs][gs][gs].buffer;
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
127
|
+
this._quadTexCoordsBuffer = h.createArrayBuffer(new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]), 2, 4);
|
|
128
|
+
this._quadVertexBuffer = h.createArrayBuffer(new Float32Array([-1, 1, 1, 1, -1, -1, 1, -1]), 2, 4);
|
|
129
|
+
};
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
_initShaders() {
|
|
130
132
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
133
|
+
this._planet.renderer.handler.addProgram(new Program("geoImageTransform", {
|
|
134
|
+
uniforms: {
|
|
135
|
+
sourceTexture: { type: types.SAMPLER2D },
|
|
136
|
+
extentParams: { type: types.VEC4 }
|
|
137
|
+
},
|
|
138
|
+
attributes: {
|
|
139
|
+
corners: { type: types.VEC2, enableArray: true },
|
|
140
|
+
texCoords: { type: types.VEC2, enableArray: true }
|
|
141
|
+
},
|
|
142
|
+
vertexShader: `attribute vec2 corners;
|
|
141
143
|
attribute vec2 texCoords;
|
|
142
144
|
varying vec2 v_texCoords;
|
|
143
145
|
uniform vec4 extentParams;
|
|
@@ -145,14 +147,14 @@ GeoImageCreator.prototype._initShaders = function () {
|
|
|
145
147
|
v_texCoords = texCoords;
|
|
146
148
|
gl_Position = vec4((-1.0 + (corners - extentParams.xy) * extentParams.zw) * vec2(1.0, -1.0), 0.0, 1.0);
|
|
147
149
|
}`,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
fragmentShader:
|
|
151
|
+
`precision highp float;
|
|
150
152
|
uniform sampler2D sourceTexture;
|
|
151
153
|
varying vec2 v_texCoords;
|
|
152
154
|
void main () {
|
|
153
155
|
gl_FragColor = texture2D(sourceTexture, v_texCoords);
|
|
154
156
|
}`
|
|
155
|
-
|
|
156
|
-
};
|
|
157
|
+
}));
|
|
158
|
+
};
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
}
|
package/src/og/utils/Loader.js
CHANGED
|
@@ -14,99 +14,100 @@ if (window && !('createImageBitmap' in window)) {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
export class Loader {
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
constructor(maxRequests = 12) {
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
this.MAX_REQUESTS = maxRequests;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
this.events = new Events(["loadend"]);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
this._loading = 0;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
this._queue = [];//new QueueArray();
|
|
28
|
+
|
|
29
|
+
this._promises = {
|
|
30
|
+
'json': r => r.json(),
|
|
31
|
+
'blob': r => r.blob(),
|
|
32
|
+
'arrayBuffer': r => r.arrayBuffer(),
|
|
33
|
+
'imageBitmap': r => r.blob().then(createImageBitmap),
|
|
34
|
+
'text': r => r.text()
|
|
35
|
+
};
|
|
33
36
|
};
|
|
34
|
-
};
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
38
|
+
load(params, callback) {
|
|
39
|
+
this._queue.push({ 'params': params, 'callback': callback });
|
|
40
|
+
this._exec();
|
|
41
|
+
};
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
fetch(params) {
|
|
44
|
+
return fetch(
|
|
45
|
+
params.src,
|
|
46
|
+
params.options || {})
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
.then(response => {
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
throw Error(`Unable to load '${params.src}'`);
|
|
51
|
+
}
|
|
52
|
+
return this._promises[params.type || "blob"](response);
|
|
53
|
+
})
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
.then(data => {
|
|
56
|
+
return { 'status': "ready", 'data': data };
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
})
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
60
|
+
.catch(err => {
|
|
61
|
+
return { 'status': "error", 'msg': err.toString() };
|
|
62
|
+
});
|
|
63
|
+
};
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
65
|
+
_exec() {
|
|
66
|
+
|
|
67
|
+
if (this._queue.length > 0 && this._loading < this.MAX_REQUESTS) {
|
|
68
|
+
|
|
69
|
+
let q = this._queue.pop(),
|
|
70
|
+
p = q.params;
|
|
71
|
+
|
|
72
|
+
if (!p.filter || p.filter(p)) {
|
|
73
|
+
|
|
74
|
+
this._loading++;
|
|
75
|
+
|
|
76
|
+
return fetch(p.src, p.options || {})
|
|
77
|
+
.then(response => {
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
throw Error(`Unable to load '${p.src}'`);
|
|
80
|
+
}
|
|
81
|
+
return this._promises[p.type || "blob"](response);
|
|
82
|
+
})
|
|
83
|
+
.then(data => {
|
|
84
|
+
this._loading--;
|
|
85
|
+
q.callback({ 'status': "ready", 'data': data });
|
|
86
|
+
this._exec();
|
|
87
|
+
})
|
|
88
|
+
.catch(err => {
|
|
89
|
+
this._loading--;
|
|
90
|
+
q.callback({ 'status': "error", 'msg': err.toString() });
|
|
91
|
+
this._exec();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
} else {
|
|
95
|
+
q.callback({ 'status': "abort" });
|
|
96
|
+
this._exec();
|
|
97
|
+
}
|
|
98
|
+
} else if (this._loading === 0) {
|
|
99
|
+
this.events.dispatch(this.events.loadend);
|
|
95
100
|
}
|
|
96
|
-
}
|
|
97
|
-
this.events.dispatch(this.events.loadend);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
Loader.prototype.abort = function () {
|
|
102
|
-
//this._queue.each(e => e.callback({ 'status': "abort" }));
|
|
103
|
-
//this._queue.clear();
|
|
101
|
+
};
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
this._queue
|
|
107
|
-
this._queue
|
|
108
|
-
}
|
|
109
|
-
this._queue = [];
|
|
110
|
-
};
|
|
103
|
+
abort() {
|
|
104
|
+
//this._queue.each(e => e.callback({ 'status': "abort" }));
|
|
105
|
+
//this._queue.clear();
|
|
111
106
|
|
|
112
|
-
|
|
107
|
+
for (let i = 0, len = this._queue.length; i < len; i++) {
|
|
108
|
+
this._queue[i].callback({ 'status': "abort" });
|
|
109
|
+
this._queue[i] = null;
|
|
110
|
+
}
|
|
111
|
+
this._queue = [];
|
|
112
|
+
};
|
|
113
|
+
}
|