@openglobus/og 0.10.6 → 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.
Files changed (163) hide show
  1. package/package.json +10 -7
  2. package/src/og/Extent.js +1 -1
  3. package/src/og/LonLat.js +7 -2
  4. package/src/og/Popup.js +2 -1
  5. package/src/og/camera/PlanetCamera.js +4 -2
  6. package/src/og/entity/EntityCollection.js +1 -1
  7. package/src/og/entity/LabelHandler.js +366 -74
  8. package/src/og/entity/Polyline.js +3 -2
  9. package/src/og/layer/KML.js +7 -5
  10. package/src/og/layer/Vector.js +5 -0
  11. package/src/og/layer/index.js +2 -1
  12. package/src/og/math/Vec2.js +448 -448
  13. package/src/og/math/Vec3.js +759 -757
  14. package/src/og/math/Vec4.js +216 -215
  15. package/src/og/scene/Planet.js +14 -4
  16. package/src/og/segment/SegmentLonLat.js +7 -0
  17. package/src/og/terrain/GlobusTerrain.js +4 -0
  18. package/src/og/utils/GeoImageCreator.js +123 -121
  19. package/src/og/utils/Loader.js +81 -80
  20. package/src/og/utils/NormalMapCreator.js +320 -318
  21. package/src/og/utils/VectorTileCreator.js +251 -250
  22. package/src/og/webgl/Framebuffer.js +265 -264
  23. package/src/og/webgl/Handler.js +1022 -1022
  24. package/src/og/webgl/Multisample.js +169 -168
  25. package/src/og/webgl/ProgramController.js +113 -112
  26. package/types/Clock.d.ts +90 -0
  27. package/types/Deferred.d.ts +6 -0
  28. package/types/Events.d.ts +73 -0
  29. package/types/Extent.d.ts +162 -0
  30. package/types/Globe.d.ts +80 -0
  31. package/types/ImageCanvas.d.ts +121 -0
  32. package/types/Lock.d.ts +12 -0
  33. package/types/LonLat.d.ts +108 -0
  34. package/types/Popup.d.ts +38 -0
  35. package/types/QueueArray.d.ts +15 -0
  36. package/types/Rectangle.d.ts +74 -0
  37. package/types/Stack.d.ts +15 -0
  38. package/types/ajax.d.ts +24 -0
  39. package/types/arial.d.ts +48 -0
  40. package/types/astro/astro.d.ts +38 -0
  41. package/types/astro/earth.d.ts +6 -0
  42. package/types/astro/jd.d.ts +254 -0
  43. package/types/bv/Box.d.ts +25 -0
  44. package/types/bv/Sphere.d.ts +32 -0
  45. package/types/bv/index.d.ts +3 -0
  46. package/types/camera/Camera.d.ts +303 -0
  47. package/types/camera/Frustum.d.ts +129 -0
  48. package/types/camera/PlanetCamera.d.ts +222 -0
  49. package/types/camera/index.d.ts +3 -0
  50. package/types/cons.d.ts +40 -0
  51. package/types/control/CompassButton.d.ts +17 -0
  52. package/types/control/Control.d.ts +101 -0
  53. package/types/control/DebugInfo.d.ts +16 -0
  54. package/types/control/EarthCoordinates.d.ts +47 -0
  55. package/types/control/GeoImageDragControl.d.ts +6 -0
  56. package/types/control/KeyboardNavigation.d.ts +22 -0
  57. package/types/control/LayerSwitcher.d.ts +23 -0
  58. package/types/control/Lighting.d.ts +16 -0
  59. package/types/control/ScaleControl.d.ts +22 -0
  60. package/types/control/ShowFps.d.ts +12 -0
  61. package/types/control/SimpleNavigation.d.ts +28 -0
  62. package/types/control/Sun.d.ts +52 -0
  63. package/types/control/ToggleWireframe.d.ts +12 -0
  64. package/types/control/ZoomControl.d.ts +28 -0
  65. package/types/control/index.d.ts +15 -0
  66. package/types/ellipsoid/Ellipsoid.d.ts +142 -0
  67. package/types/ellipsoid/index.d.ts +3 -0
  68. package/types/ellipsoid/wgs84.d.ts +5 -0
  69. package/types/entity/BaseBillboard.d.ts +208 -0
  70. package/types/entity/Billboard.d.ts +94 -0
  71. package/types/entity/BillboardHandler.d.ts +74 -0
  72. package/types/entity/Entity.d.ts +330 -0
  73. package/types/entity/EntityCollection.d.ts +303 -0
  74. package/types/entity/Geometry.d.ts +72 -0
  75. package/types/entity/GeometryHandler.d.ts +76 -0
  76. package/types/entity/Label.d.ts +194 -0
  77. package/types/entity/LabelHandler.d.ts +24 -0
  78. package/types/entity/PointCloud.d.ts +174 -0
  79. package/types/entity/PointCloudHandler.d.ts +38 -0
  80. package/types/entity/Polyline.d.ts +303 -0
  81. package/types/entity/PolylineHandler.d.ts +18 -0
  82. package/types/entity/Ray.d.ts +123 -0
  83. package/types/entity/RayHandler.d.ts +67 -0
  84. package/types/entity/ShapeHandler.d.ts +22 -0
  85. package/types/entity/Strip.d.ts +118 -0
  86. package/types/entity/StripHandler.d.ts +38 -0
  87. package/types/entity/index.d.ts +8 -0
  88. package/types/index.core.d.ts +65 -0
  89. package/types/index.d.ts +45 -0
  90. package/types/index.webgl.d.ts +7 -0
  91. package/types/inherits.d.ts +4 -0
  92. package/types/input/input.d.ts +34 -0
  93. package/types/layer/BaseGeoImage.d.ts +106 -0
  94. package/types/layer/CanvasTiles.d.ts +75 -0
  95. package/types/layer/GeoImage.d.ts +65 -0
  96. package/types/layer/GeoTexture2d.d.ts +8 -0
  97. package/types/layer/GeoVideo.d.ts +80 -0
  98. package/types/layer/KML.d.ts +58 -0
  99. package/types/layer/WMS.d.ts +66 -0
  100. package/types/layer/XYZ.d.ts +126 -0
  101. package/types/layer/index.d.ts +10 -0
  102. package/types/light/LightSource.d.ts +177 -0
  103. package/types/math/Mat3.d.ts +53 -0
  104. package/types/math/Mat4.d.ts +157 -0
  105. package/types/math/Plane.d.ts +17 -0
  106. package/types/math/Vec2.d.ts +308 -0
  107. package/types/math/Vec3.d.ts +459 -0
  108. package/types/math/Vec4.d.ts +161 -0
  109. package/types/math/coder.d.ts +42 -0
  110. package/types/math/index.d.ts +11 -0
  111. package/types/math.d.ts +261 -0
  112. package/types/mercator.d.ts +92 -0
  113. package/types/proj/EPSG3857.d.ts +5 -0
  114. package/types/proj/EPSG4326.d.ts +5 -0
  115. package/types/quadTree/quadTree.d.ts +40 -0
  116. package/types/renderer/RendererEvents.d.ts +230 -0
  117. package/types/res/images.d.ts +3 -0
  118. package/types/scene/Axes.d.ts +11 -0
  119. package/types/scene/BaseNode.d.ts +60 -0
  120. package/types/scene/Planet.d.ts +572 -0
  121. package/types/scene/RenderNode.d.ts +143 -0
  122. package/types/scene/SkyBox.d.ts +10 -0
  123. package/types/scene/index.d.ts +4 -0
  124. package/types/segment/segmentHelper.d.ts +13 -0
  125. package/types/shaders/billboard.d.ts +3 -0
  126. package/types/shaders/depth.d.ts +2 -0
  127. package/types/shaders/drawnode.d.ts +7 -0
  128. package/types/shaders/label.d.ts +4 -0
  129. package/types/shaders/pointCloud.d.ts +2 -0
  130. package/types/shaders/polyline.d.ts +3 -0
  131. package/types/shaders/ray.d.ts +2 -0
  132. package/types/shaders/screenFrame.d.ts +2 -0
  133. package/types/shaders/shape.d.ts +4 -0
  134. package/types/shaders/skybox.d.ts +2 -0
  135. package/types/shaders/toneMapping.d.ts +2 -0
  136. package/types/shapes/BaseShape.d.ts +247 -0
  137. package/types/shapes/Sphere.d.ts +41 -0
  138. package/types/terrain/BilTerrain.d.ts +8 -0
  139. package/types/terrain/EmptyTerrain.d.ts +72 -0
  140. package/types/terrain/Geoid.d.ts +26 -0
  141. package/types/terrain/GlobusTerrain.d.ts +153 -0
  142. package/types/terrain/MapboxTerrain.d.ts +8 -0
  143. package/types/terrain/index.d.ts +5 -0
  144. package/types/utils/FontAtlas.d.ts +14 -0
  145. package/types/utils/GeoImageCreator.d.ts +29 -0
  146. package/types/utils/ImagesCacheManager.d.ts +10 -0
  147. package/types/utils/Loader.d.ts +25 -0
  148. package/types/utils/NormalMapCreator.d.ts +39 -0
  149. package/types/utils/PlainSegmentWorker.d.ts +10 -0
  150. package/types/utils/TerrainWorker.d.ts +9 -0
  151. package/types/utils/TextureAtlas.d.ts +111 -0
  152. package/types/utils/VectorTileCreator.d.ts +16 -0
  153. package/types/utils/colorTable.d.ts +143 -0
  154. package/types/utils/earcut.d.ts +6 -0
  155. package/types/utils/shared.d.ts +230 -0
  156. package/types/webgl/Framebuffer.d.ts +135 -0
  157. package/types/webgl/Handler.d.ts +372 -0
  158. package/types/webgl/Multisample.d.ts +89 -0
  159. package/types/webgl/Program.d.ts +155 -0
  160. package/types/webgl/ProgramController.d.ts +84 -0
  161. package/types/webgl/callbacks.d.ts +1 -0
  162. package/types/webgl/index.d.ts +6 -0
  163. package/types/webgl/types.d.ts +2 -0
@@ -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
- const GeoImageCreator = function (planet, maxFrames) {
10
- this._gridSize = 64;
11
- this._planet = planet;
12
- this._framebuffer = null;
13
- this._texCoordsBuffer = null;
14
- this._indexBuffer = null;
15
- this.MAX_FRAMES = maxFrames || 5;
16
- this._currentFrame = 0;
17
- this._queue = [];
18
- this._animate = [];
19
- this._initialize();
20
- };
21
-
22
- GeoImageCreator.prototype._initialize = function () {
23
- this._initShaders();
24
- this._initBuffers();
25
- };
26
-
27
- /**
28
- * Creates geoImage corners coordinates grid buffer.
29
- * @public
30
- * @param{Array.<og.LonLat>} c - GeoImage corners coordinates.
31
- * @return{WebGLBuffer} Grid coordinates buffer.
32
- */
33
- GeoImageCreator.prototype.createGridBuffer = function (c, toMerc) {
34
- var gs = this._gridSize;
35
-
36
- var v03 = new LonLat((c[3].lon - c[0].lon) / gs, (c[3].lat - c[0].lat) / gs),
37
- v12 = new LonLat((c[2].lon - c[1].lon) / gs, (c[2].lat - c[1].lat) / gs),
38
- v01 = new LonLat((c[1].lon - c[0].lon) / gs, (c[1].lat - c[0].lat) / gs),
39
- v32 = new LonLat((c[2].lon - c[3].lon) / gs, (c[2].lat - c[3].lat) / gs);
40
-
41
- var grid = new Float32Array((gs + 1) * (gs + 1) * 2);
42
- var k = 0;
43
- for (let i = 0; i <= gs; i++) {
44
- var P03i = new LonLat(c[0].lon + i * v03.lon, c[0].lat + i * v03.lat),
45
- P12i = new LonLat(c[1].lon + i * v12.lon, c[1].lat + i * v12.lat);
46
- for (let j = 0; j <= gs; j++) {
47
- var P01j = new LonLat(c[0].lon + j * v01.lon, c[0].lat + j * v01.lat),
48
- P32j = new LonLat(c[3].lon + j * v32.lon, c[3].lat + j * v32.lat);
49
- var xx = utils.getLinesIntersectionLonLat(P03i, P12i, P01j, P32j);
50
- grid[k++] = xx.lon;
51
- grid[k++] = xx.lat;
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
- if (toMerc) {
56
- for (let i = 0; i < grid.length; i += 2) {
57
- let c = new LonLat(grid[i], grid[i + 1]).forwardMercator();
58
- grid[i] = c.lon;
59
- grid[i + 1] = c.lat;
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
- return this._planet.renderer.handler.createArrayBuffer(grid, 2, grid.length / 2);
63
- };
64
-
65
- GeoImageCreator.prototype.frame = function () {
66
- var i = this.MAX_FRAMES;
67
- while (i-- && this._queue.length) {
68
- var q = this._queue.shift();
69
- q._isRendering = false;
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
- GeoImageCreator.prototype.remove = function (geoImage) {
91
- if (geoImage._isRendering) {
92
- geoImage._creationProceeding = false;
93
- geoImage._isRendering = false;
94
- var arr;
95
- if (geoImage._animate) {
96
- arr = this._animate;
97
- } else {
98
- arr = this._queue;
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
- for (var i = 0; i < arr.length; i++) {
101
- if (arr[i].isEqual(geoImage)) {
102
- arr.splice(i, 1);
103
- return;
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
- GeoImageCreator.prototype._initBuffers = function () {
111
+ _initBuffers() {
110
112
 
111
- let h = this._planet.renderer.handler;
113
+ let h = this._planet.renderer.handler;
112
114
 
113
- this._framebuffer = new Framebuffer(h, { width: 2, height: 2, useDepth: false });
114
- this._framebuffer.init();
115
+ this._framebuffer = new Framebuffer(h, { width: 2, height: 2, useDepth: false });
116
+ this._framebuffer.init();
115
117
 
116
- this._framebufferMercProj = new Framebuffer(h, { width: 2, height: 2, useDepth: false });
117
- this._framebufferMercProj.init();
118
+ this._framebufferMercProj = new Framebuffer(h, { width: 2, height: 2, useDepth: false });
119
+ this._framebufferMercProj.init();
118
120
 
119
- let gs = Math.log2(this._gridSize);
121
+ let gs = Math.log2(this._gridSize);
120
122
 
121
- this._texCoordsBuffer = this._planet._textureCoordsBufferCache[gs];
123
+ this._texCoordsBuffer = this._planet._textureCoordsBufferCache[gs];
122
124
 
123
- this._indexBuffer = this._planet._indexesCache[gs][gs][gs][gs][gs].buffer;
125
+ this._indexBuffer = this._planet._indexesCache[gs][gs][gs][gs][gs].buffer;
124
126
 
125
- this._quadTexCoordsBuffer = h.createArrayBuffer(new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]), 2, 4);
126
- this._quadVertexBuffer = h.createArrayBuffer(new Float32Array([-1, 1, 1, 1, -1, -1, 1, -1]), 2, 4);
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
- GeoImageCreator.prototype._initShaders = function () {
131
+ _initShaders() {
130
132
 
131
- this._planet.renderer.handler.addProgram(new Program("geoImageTransform", {
132
- uniforms: {
133
- sourceTexture: { type: types.SAMPLER2D },
134
- extentParams: { type: types.VEC4 }
135
- },
136
- attributes: {
137
- corners: { type: types.VEC2, enableArray: true },
138
- texCoords: { type: types.VEC2, enableArray: true }
139
- },
140
- vertexShader: `attribute vec2 corners;
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
- fragmentShader:
149
- `precision highp float;
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
- export { GeoImageCreator };
160
+ }
@@ -14,99 +14,100 @@ if (window && !('createImageBitmap' in window)) {
14
14
  };
15
15
  };
16
16
 
17
- const Loader = function (maxRequests = 12) {
17
+ export class Loader {
18
18
 
19
- this.MAX_REQUESTS = maxRequests;
19
+ constructor(maxRequests = 12) {
20
20
 
21
- this.events = new Events(["loadend"]);
21
+ this.MAX_REQUESTS = maxRequests;
22
22
 
23
- this._loading = 0;
23
+ this.events = new Events(["loadend"]);
24
24
 
25
- this._queue = [];//new QueueArray();
25
+ this._loading = 0;
26
26
 
27
- this._promises = {
28
- 'json': r => r.json(),
29
- 'blob': r => r.blob(),
30
- 'arrayBuffer': r => r.arrayBuffer(),
31
- 'imageBitmap': r => r.blob().then(createImageBitmap),
32
- 'text': r => r.text()
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
- Loader.prototype.load = function (params, callback) {
37
- this._queue.push({ 'params': params, 'callback': callback });
38
- this._exec();
39
- };
38
+ load(params, callback) {
39
+ this._queue.push({ 'params': params, 'callback': callback });
40
+ this._exec();
41
+ };
40
42
 
41
- Loader.prototype.fetch = function (params) {
42
- return fetch(
43
- params.src,
44
- params.options || {})
43
+ fetch(params) {
44
+ return fetch(
45
+ params.src,
46
+ params.options || {})
45
47
 
46
- .then(response => {
47
- if (!response.ok) {
48
- throw Error(`Unable to load '${params.src}'`);
49
- }
50
- return this._promises[params.type || "blob"](response);
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
- .then(data => {
54
- return { 'status': "ready", 'data': data };
55
+ .then(data => {
56
+ return { 'status': "ready", 'data': data };
55
57
 
56
- })
58
+ })
57
59
 
58
- .catch(err => {
59
- return { 'status': "error", 'msg': err.toString() };
60
- });
61
- };
60
+ .catch(err => {
61
+ return { 'status': "error", 'msg': err.toString() };
62
+ });
63
+ };
62
64
 
63
- Loader.prototype._exec = function () {
64
-
65
- if (this._queue.length > 0 && this._loading < this.MAX_REQUESTS) {
66
-
67
- let q = this._queue.pop(),
68
- p = q.params;
69
-
70
- if (!p.filter || p.filter(p)) {
71
-
72
- this._loading++;
73
-
74
- return fetch(p.src, p.options || {})
75
- .then(response => {
76
- if (!response.ok) {
77
- throw Error(`Unable to load '${p.src}'`);
78
- }
79
- return this._promises[p.type || "blob"](response);
80
- })
81
- .then(data => {
82
- this._loading--;
83
- q.callback({ 'status': "ready", 'data': data });
84
- this._exec();
85
- })
86
- .catch(err => {
87
- this._loading--;
88
- q.callback({ 'status': "error", 'msg': err.toString() });
89
- this._exec();
90
- });
91
-
92
- } else {
93
- q.callback({ 'status': "abort" });
94
- this._exec();
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
- } else if (this._loading === 0) {
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
- for (let i = 0, len = this._queue.length; i < len; i++) {
106
- this._queue[i].callback({ 'status': "abort" });
107
- this._queue[i] = null;
108
- }
109
- this._queue = [];
110
- };
103
+ abort() {
104
+ //this._queue.each(e => e.callback({ 'status': "abort" }));
105
+ //this._queue.clear();
111
106
 
112
- export { Loader };
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
+ }