@openglobus/og 0.11.2 → 0.11.7

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 (273) hide show
  1. package/package.json +13 -13
  2. package/src/og/Clock.js +10 -10
  3. package/src/og/Events.js +8 -6
  4. package/src/og/Extent.js +82 -41
  5. package/src/og/Globe.js +25 -13
  6. package/src/og/ImageCanvas.js +22 -16
  7. package/src/og/LonLat.js +16 -13
  8. package/src/og/Popup.js +21 -14
  9. package/src/og/QueueArray.js +6 -2
  10. package/src/og/Rectangle.js +11 -6
  11. package/src/og/Stack.js +5 -2
  12. package/src/og/ajax.js +21 -33
  13. package/src/og/astro/astro.js +5 -5
  14. package/src/og/astro/earth.js +22 -16
  15. package/src/og/astro/jd.js +23 -18
  16. package/src/og/astro/orbit.js +13 -11
  17. package/src/og/astro/rotation.js +17 -8
  18. package/src/og/bv/Box.js +7 -3
  19. package/src/og/bv/Sphere.js +14 -11
  20. package/src/og/camera/Camera.js +51 -54
  21. package/src/og/camera/Frustum.js +29 -18
  22. package/src/og/camera/PlanetCamera.js +32 -23
  23. package/src/og/control/CompassButton.js +5 -1
  24. package/src/og/control/Control.js +12 -10
  25. package/src/og/control/DebugInfo.js +4 -1
  26. package/src/og/control/EarthCoordinates.js +54 -33
  27. package/src/og/control/KeyboardNavigation.js +10 -10
  28. package/src/og/control/LayerSwitcher.js +22 -21
  29. package/src/og/control/Lighting.js +34 -3
  30. package/src/og/control/MouseNavigation.js +1 -1
  31. package/src/og/control/ScaleControl.js +1 -1
  32. package/src/og/control/SegmentBoundVisualization.js +6 -7
  33. package/src/og/control/ShowFps.js +13 -8
  34. package/src/og/control/SimpleNavigation.js +6 -8
  35. package/src/og/control/Sun.js +25 -15
  36. package/src/og/control/ToggleWireframe.js +4 -4
  37. package/src/og/control/TouchNavigation.js +44 -33
  38. package/src/og/control/ZoomControl.js +41 -25
  39. package/src/og/ellipsoid/Ellipsoid.js +162 -66
  40. package/src/og/ellipsoid/wgs84.js +4 -4
  41. package/src/og/entity/BaseBillboard.js +100 -56
  42. package/src/og/entity/Billboard.js +14 -10
  43. package/src/og/entity/BillboardHandler.js +317 -60
  44. package/src/og/entity/Entity.js +100 -68
  45. package/src/og/entity/EntityCollection.js +70 -47
  46. package/src/og/entity/GeoObject.js +228 -0
  47. package/src/og/entity/GeoObjectHandler.js +910 -0
  48. package/src/og/entity/Geometry.js +27 -24
  49. package/src/og/entity/GeometryHandler.js +596 -124
  50. package/src/og/entity/Label.js +80 -49
  51. package/src/og/entity/LabelHandler.js +45 -244
  52. package/src/og/entity/LabelWorker.js +218 -0
  53. package/src/og/entity/Object3d.js +504 -0
  54. package/src/og/entity/PointCloud.js +80 -32
  55. package/src/og/entity/PointCloudHandler.js +8 -8
  56. package/src/og/entity/Polyline.js +16 -16
  57. package/src/og/entity/Ray.js +60 -27
  58. package/src/og/entity/Strip.js +77 -48
  59. package/src/og/entity/StripHandler.js +26 -26
  60. package/src/og/entity/index.js +8 -16
  61. package/src/og/layer/BaseGeoImage.js +54 -23
  62. package/src/og/layer/CanvasTiles.js +24 -24
  63. package/src/og/layer/GeoImage.js +9 -9
  64. package/src/og/layer/GeoVideo.js +3 -3
  65. package/src/og/layer/KML.js +63 -37
  66. package/src/og/layer/Layer.js +44 -21
  67. package/src/og/layer/Material.js +23 -20
  68. package/src/og/layer/Vector.js +114 -68
  69. package/src/og/layer/WMS.js +34 -17
  70. package/src/og/layer/XYZ.js +48 -46
  71. package/src/og/light/LightSource.js +46 -39
  72. package/src/og/math/Mat3.js +34 -22
  73. package/src/og/math/Mat4.js +603 -459
  74. package/src/og/math/Plane.js +21 -20
  75. package/src/og/math/Quat.js +182 -139
  76. package/src/og/math/Ray.js +38 -33
  77. package/src/og/math/Vec2.js +85 -75
  78. package/src/og/math/Vec3.js +142 -112
  79. package/src/og/math/Vec4.js +27 -31
  80. package/src/og/math/coder.js +10 -10
  81. package/src/og/math.js +12 -12
  82. package/src/og/proj/EPSG3857.js +4 -4
  83. package/src/og/proj/EPSG4326.js +4 -4
  84. package/src/og/proj/Proj.js +4 -6
  85. package/src/og/quadTree/Node.js +8 -8
  86. package/src/og/renderer/Renderer.js +59 -52
  87. package/src/og/renderer/RendererEvents.js +50 -27
  88. package/src/og/scene/BaseNode.js +7 -8
  89. package/src/og/scene/Planet.js +102 -103
  90. package/src/og/scene/RenderNode.js +28 -21
  91. package/src/og/segment/Segment.js +26 -21
  92. package/src/og/segment/SegmentLonLat.js +5 -5
  93. package/src/og/shaders/drawnode.js +135 -142
  94. package/src/og/shaders/geoObject.js +211 -0
  95. package/src/og/shaders/pointCloud.js +41 -41
  96. package/src/og/shaders/shape.js +12 -18
  97. package/src/og/shaders/skybox.js +36 -36
  98. package/src/og/shaders/toneMapping.js +1 -0
  99. package/src/og/shapes/BaseShape.js +126 -54
  100. package/src/og/shapes/Icosphere.js +29 -14
  101. package/src/og/shapes/Sphere.js +12 -15
  102. package/src/og/terrain/BilTerrain.js +1 -0
  103. package/src/og/terrain/EmptyTerrain.js +2 -2
  104. package/src/og/terrain/GlobusTerrain.js +9 -9
  105. package/src/og/utils/FontAtlas.js +6 -2
  106. package/src/og/utils/TextureAtlas.js +22 -24
  107. package/src/og/utils/VectorTileCreator.js +1 -3
  108. package/src/og/utils/shared.js +16 -16
  109. package/src/og/webgl/Framebuffer.js +88 -40
  110. package/src/og/webgl/Handler.js +243 -169
  111. package/src/og/webgl/Multisample.js +47 -19
  112. package/src/og/webgl/Program.js +79 -34
  113. package/src/og/webgl/ProgramController.js +17 -13
  114. package/src/og/webgl/callbacks.js +8 -8
  115. package/src/og/inherits.js +0 -8
  116. package/src/og/utils/polylabel.js +0 -176
  117. package/types/Clock.d.ts +0 -90
  118. package/types/Deferred.d.ts +0 -6
  119. package/types/Events.d.ts +0 -73
  120. package/types/Extent.d.ts +0 -166
  121. package/types/Globe.d.ts +0 -75
  122. package/types/ImageCanvas.d.ts +0 -121
  123. package/types/Lock.d.ts +0 -12
  124. package/types/LonLat.d.ts +0 -108
  125. package/types/Popup.d.ts +0 -38
  126. package/types/QueueArray.d.ts +0 -15
  127. package/types/Rectangle.d.ts +0 -74
  128. package/types/Stack.d.ts +0 -15
  129. package/types/ajax.d.ts +0 -24
  130. package/types/arial.d.ts +0 -48
  131. package/types/astro/astro.d.ts +0 -38
  132. package/types/astro/earth.d.ts +0 -6
  133. package/types/astro/jd.d.ts +0 -254
  134. package/types/bv/Box.d.ts +0 -25
  135. package/types/bv/Sphere.d.ts +0 -38
  136. package/types/bv/index.d.ts +0 -3
  137. package/types/camera/Camera.d.ts +0 -303
  138. package/types/camera/Frustum.d.ts +0 -129
  139. package/types/camera/PlanetCamera.d.ts +0 -223
  140. package/types/camera/index.d.ts +0 -3
  141. package/types/cons.d.ts +0 -40
  142. package/types/control/CompassButton.d.ts +0 -18
  143. package/types/control/Control.d.ts +0 -101
  144. package/types/control/DebugInfo.d.ts +0 -16
  145. package/types/control/EarthCoordinates.d.ts +0 -47
  146. package/types/control/EarthNavigation.d.ts +0 -42
  147. package/types/control/GeoImageDragControl.d.ts +0 -6
  148. package/types/control/KeyboardNavigation.d.ts +0 -22
  149. package/types/control/LayerSwitcher.d.ts +0 -23
  150. package/types/control/Lighting.d.ts +0 -16
  151. package/types/control/MouseNavigation.d.ts +0 -51
  152. package/types/control/ScaleControl.d.ts +0 -22
  153. package/types/control/ShowFps.d.ts +0 -12
  154. package/types/control/SimpleNavigation.d.ts +0 -28
  155. package/types/control/Sun.d.ts +0 -52
  156. package/types/control/ToggleWireframe.d.ts +0 -12
  157. package/types/control/TouchNavigation.d.ts +0 -50
  158. package/types/control/ZoomControl.d.ts +0 -28
  159. package/types/control/index.d.ts +0 -17
  160. package/types/ellipsoid/Ellipsoid.d.ts +0 -142
  161. package/types/ellipsoid/index.d.ts +0 -3
  162. package/types/ellipsoid/wgs84.d.ts +0 -5
  163. package/types/entity/BaseBillboard.d.ts +0 -208
  164. package/types/entity/Billboard.d.ts +0 -94
  165. package/types/entity/BillboardHandler.d.ts +0 -74
  166. package/types/entity/Entity.d.ts +0 -331
  167. package/types/entity/EntityCollection.d.ts +0 -303
  168. package/types/entity/Geometry.d.ts +0 -73
  169. package/types/entity/GeometryHandler.d.ts +0 -76
  170. package/types/entity/Label.d.ts +0 -194
  171. package/types/entity/LabelHandler.d.ts +0 -24
  172. package/types/entity/PointCloud.d.ts +0 -174
  173. package/types/entity/PointCloudHandler.d.ts +0 -38
  174. package/types/entity/Polyline.d.ts +0 -304
  175. package/types/entity/PolylineHandler.d.ts +0 -18
  176. package/types/entity/Ray.d.ts +0 -123
  177. package/types/entity/RayHandler.d.ts +0 -67
  178. package/types/entity/ShapeHandler.d.ts +0 -22
  179. package/types/entity/Strip.d.ts +0 -118
  180. package/types/entity/StripHandler.d.ts +0 -38
  181. package/types/entity/index.d.ts +0 -8
  182. package/types/index.core.d.ts +0 -65
  183. package/types/index.d.ts +0 -45
  184. package/types/index.webgl.d.ts +0 -7
  185. package/types/inherits.d.ts +0 -4
  186. package/types/input/KeyboardHandler.d.ts +0 -10
  187. package/types/input/MouseHandler.d.ts +0 -5
  188. package/types/input/TouchHandler.d.ts +0 -5
  189. package/types/input/input.d.ts +0 -34
  190. package/types/layer/BaseGeoImage.d.ts +0 -107
  191. package/types/layer/CanvasTiles.d.ts +0 -75
  192. package/types/layer/GeoImage.d.ts +0 -65
  193. package/types/layer/GeoTexture2d.d.ts +0 -8
  194. package/types/layer/GeoVideo.d.ts +0 -80
  195. package/types/layer/KML.d.ts +0 -58
  196. package/types/layer/Layer.d.ts +0 -321
  197. package/types/layer/Material.d.ts +0 -48
  198. package/types/layer/Vector.d.ts +0 -228
  199. package/types/layer/WMS.d.ts +0 -66
  200. package/types/layer/XYZ.d.ts +0 -130
  201. package/types/layer/index.d.ts +0 -10
  202. package/types/light/LightSource.d.ts +0 -177
  203. package/types/math/Line2.d.ts +0 -11
  204. package/types/math/Line3.d.ts +0 -10
  205. package/types/math/Mat3.d.ts +0 -63
  206. package/types/math/Mat4.d.ts +0 -173
  207. package/types/math/Plane.d.ts +0 -17
  208. package/types/math/Quat.d.ts +0 -376
  209. package/types/math/Ray.d.ts +0 -81
  210. package/types/math/Vec2.d.ts +0 -308
  211. package/types/math/Vec3.d.ts +0 -459
  212. package/types/math/Vec4.d.ts +0 -161
  213. package/types/math/coder.d.ts +0 -42
  214. package/types/math/index.d.ts +0 -11
  215. package/types/math.d.ts +0 -261
  216. package/types/mercator.d.ts +0 -92
  217. package/types/proj/EPSG3857.d.ts +0 -5
  218. package/types/proj/EPSG4326.d.ts +0 -5
  219. package/types/proj/Proj.d.ts +0 -42
  220. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  221. package/types/quadTree/Node.d.ts +0 -61
  222. package/types/quadTree/quadTree.d.ts +0 -40
  223. package/types/renderer/Renderer.d.ts +0 -296
  224. package/types/renderer/RendererEvents.d.ts +0 -230
  225. package/types/res/images.d.ts +0 -3
  226. package/types/scene/Axes.d.ts +0 -11
  227. package/types/scene/BaseNode.d.ts +0 -60
  228. package/types/scene/Planet.d.ts +0 -574
  229. package/types/scene/RenderNode.d.ts +0 -143
  230. package/types/scene/SkyBox.d.ts +0 -10
  231. package/types/scene/index.d.ts +0 -4
  232. package/types/segment/Segment.d.ts +0 -271
  233. package/types/segment/SegmentLonLat.d.ts +0 -62
  234. package/types/segment/segmentHelper.d.ts +0 -13
  235. package/types/shaders/billboard.d.ts +0 -3
  236. package/types/shaders/depth.d.ts +0 -2
  237. package/types/shaders/drawnode.d.ts +0 -7
  238. package/types/shaders/label.d.ts +0 -4
  239. package/types/shaders/pointCloud.d.ts +0 -2
  240. package/types/shaders/polyline.d.ts +0 -3
  241. package/types/shaders/ray.d.ts +0 -2
  242. package/types/shaders/screenFrame.d.ts +0 -2
  243. package/types/shaders/shape.d.ts +0 -4
  244. package/types/shaders/skybox.d.ts +0 -2
  245. package/types/shaders/toneMapping.d.ts +0 -2
  246. package/types/shapes/BaseShape.d.ts +0 -247
  247. package/types/shapes/Sphere.d.ts +0 -41
  248. package/types/terrain/BilTerrain.d.ts +0 -8
  249. package/types/terrain/EmptyTerrain.d.ts +0 -72
  250. package/types/terrain/Geoid.d.ts +0 -26
  251. package/types/terrain/GlobusTerrain.d.ts +0 -153
  252. package/types/terrain/MapboxTerrain.d.ts +0 -8
  253. package/types/terrain/index.d.ts +0 -5
  254. package/types/utils/FontAtlas.d.ts +0 -14
  255. package/types/utils/GeoImageCreator.d.ts +0 -30
  256. package/types/utils/ImagesCacheManager.d.ts +0 -10
  257. package/types/utils/Loader.d.ts +0 -25
  258. package/types/utils/NormalMapCreator.d.ts +0 -39
  259. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  260. package/types/utils/TerrainWorker.d.ts +0 -9
  261. package/types/utils/TextureAtlas.d.ts +0 -111
  262. package/types/utils/VectorTileCreator.d.ts +0 -16
  263. package/types/utils/colorTable.d.ts +0 -143
  264. package/types/utils/earcut.d.ts +0 -6
  265. package/types/utils/shared.d.ts +0 -230
  266. package/types/webgl/Framebuffer.d.ts +0 -135
  267. package/types/webgl/Handler.d.ts +0 -372
  268. package/types/webgl/Multisample.d.ts +0 -89
  269. package/types/webgl/Program.d.ts +0 -155
  270. package/types/webgl/ProgramController.d.ts +0 -84
  271. package/types/webgl/callbacks.d.ts +0 -1
  272. package/types/webgl/index.d.ts +0 -6
  273. package/types/webgl/types.d.ts +0 -2
@@ -1,11 +1,11 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- import { ImageCanvas } from '../ImageCanvas.js';
4
- import { Rectangle } from '../Rectangle.js';
5
- import { ImagesCacheManager } from './ImagesCacheManager.js';
3
+ import { ImageCanvas } from "../ImageCanvas.js";
4
+ import { Rectangle } from "../Rectangle.js";
5
+ import { ImagesCacheManager } from "./ImagesCacheManager.js";
6
6
 
7
7
  /**
8
- * Texture atlas stores images in one texture. Each image has its own
8
+ * Texture atlas stores images in one texture. Each image has its own
9
9
  * atlas texture coordinates.
10
10
  * @class
11
11
  * @param {number} [width] - Texture atlas width, if it hasn't 1024 default.
@@ -13,11 +13,10 @@ import { ImagesCacheManager } from './ImagesCacheManager.js';
13
13
  */
14
14
  class TextureAtlas {
15
15
  constructor(width, height) {
16
-
17
16
  /**
18
17
  * Atlas nodes where input images store. It can be access by image.__nodeIndex.
19
18
  * @public
20
- * @type {Array.<og.utils.TextureAtlasNode >}
19
+ * @type {Array.<utils.TextureAtlasNode >}
21
20
  */
22
21
  this.nodes = [];
23
22
 
@@ -71,7 +70,7 @@ class TextureAtlas {
71
70
  /**
72
71
  * Sets openglobus gl handler that creates gl texture.
73
72
  * @public
74
- * @param {og.webgl.Handler} handler - WebGL handler.
73
+ * @param {Handler} handler - WebGL handler.
75
74
  */
76
75
  assignHandler(handler) {
77
76
  this._handler = handler;
@@ -93,12 +92,11 @@ class TextureAtlas {
93
92
  * Adds image to the atlas and returns creted node with texture coordinates of the stored image.
94
93
  * @public
95
94
  * @param {Object} image - Input javascript image object.
96
- * @param {boolean} [fastInsert] - If it's true atlas doesnt restore all images again
95
+ * @param {boolean} [fastInsert] - If it's true atlas doesnt restore all images again
97
96
  * and store image in the curent atlas sheme.
98
- * @returns {og.utils.TextureAtlasNode} -
97
+ * @returns {utils.TextureAtlasNode} -
99
98
  */
100
99
  addImage(image, fastInsert) {
101
-
102
100
  if (!(image.width && image.height)) {
103
101
  return;
104
102
  }
@@ -145,11 +143,10 @@ class TextureAtlas {
145
143
  /**
146
144
  * Main atlas making function.
147
145
  * @private
148
- * @param {boolean} [fastInsert] - If it's true atlas doesnt restore all images again
146
+ * @param {boolean} [fastInsert] - If it's true atlas doesnt restore all images again
149
147
  * and store image in the curent atlas sheme.
150
148
  */
151
149
  _makeAtlas(fastInsert) {
152
-
153
150
  if (fastInsert && this._btree) {
154
151
  let im = this._images[this._images.length - 1];
155
152
  this._completeNode(this.nodes, this._btree.insert(im));
@@ -157,10 +154,15 @@ class TextureAtlas {
157
154
  let im = this._images.slice(0);
158
155
 
159
156
  im.sort(function (b, a) {
160
- return ((a.atlasWidth || a.width) - (b.atlasWidth || b.width)) || ((a.atlasHeight || a.height) - (b.atlasHeight || b.height));
157
+ return (
158
+ (a.atlasWidth || a.width) - (b.atlasWidth || b.width) ||
159
+ (a.atlasHeight || a.height) - (b.atlasHeight || b.height)
160
+ );
161
161
  });
162
162
 
163
- this._btree = new TextureAtlasNode(new Rectangle(0, 0, this.canvas.getWidth(), this.canvas.getHeight()));
163
+ this._btree = new TextureAtlasNode(
164
+ new Rectangle(0, 0, this.canvas.getWidth(), this.canvas.getHeight())
165
+ );
164
166
  this._btree.atlas = this;
165
167
 
166
168
  this.clearCanvas();
@@ -178,19 +180,19 @@ class TextureAtlas {
178
180
  * Creates atlas gl texture.
179
181
  * @public
180
182
  */
181
- createTexture(img) {
183
+ createTexture(img, internalFormat) {
182
184
  if (this._handler) {
183
185
  this._handler.gl.deleteTexture(this.texture);
184
186
  if (img) {
185
187
  this.canvas.resize(img.width, img.height);
186
188
  this.canvas.drawImage(img, 0, 0, img.width, img.height);
187
189
  }
188
- this.texture = this._handler.createTexture_l(this.canvas._canvas);
190
+ this.texture = this._handler.createTexture_l(this.canvas._canvas, internalFormat);
189
191
  }
190
192
  }
191
193
 
192
194
  /**
193
- * Image handler callback.
195
+ * Image handler callback.
194
196
  * @callback Object~successCallback
195
197
  * @param {Image} img - Loaded image.
196
198
  */
@@ -215,7 +217,7 @@ class TextureAtlas {
215
217
  /**
216
218
  * Atlas binary tree node.
217
219
  * @class
218
- * @param {og.Rectangle} rect - Node image rectangle.
220
+ * @param {Rectangle} rect - Node image rectangle.
219
221
  */
220
222
  class TextureAtlasNode {
221
223
  constructor(rect, texCoords) {
@@ -227,9 +229,7 @@ class TextureAtlasNode {
227
229
  }
228
230
 
229
231
  insert(img) {
230
-
231
232
  if (this.childNodes) {
232
-
233
233
  var newNode = this.childNodes[0].insert(img);
234
234
 
235
235
  if (newNode != null) {
@@ -237,9 +237,7 @@ class TextureAtlasNode {
237
237
  }
238
238
 
239
239
  return this.childNodes[1].insert(img);
240
-
241
240
  } else {
242
-
243
241
  if (this.image != null) {
244
242
  return null;
245
243
  }
@@ -279,4 +277,4 @@ class TextureAtlasNode {
279
277
  }
280
278
  }
281
279
 
282
- export { TextureAtlas, TextureAtlasNode };
280
+ export { TextureAtlas, TextureAtlasNode };
@@ -217,8 +217,6 @@ export class VectorTileCreator {
217
217
 
218
218
  // var prevLayerId = -1;
219
219
 
220
- var extentParams = new Float32Array(4);
221
-
222
220
  var extentParamsHigh = new Float32Array(4);
223
221
  var extentParamsLow = new Float32Array(4);
224
222
 
@@ -245,7 +243,7 @@ export class VectorTileCreator {
245
243
 
246
244
  f.bindOutputTexture(texture);
247
245
 
248
- gl.clearColor(1.0, 1.0, 1.0, 0.0);
246
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
249
247
  gl.clear(gl.COLOR_BUFFER_BIT);
250
248
 
251
249
  var extent = material.segment.getExtentMerc();
@@ -56,7 +56,7 @@ export function readTextFile(fileUrl) {
56
56
  * Convert html color string to the RGBA number vector.
57
57
  * @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.
58
58
  * @param {number} [opacity] - Opacity for the output vector.
59
- * @returns {og.math.Vec4} -
59
+ * @returns {math.Vec4} -
60
60
  */
61
61
  export function htmlColorToRgba(htmlColor, opacity) {
62
62
  var hColor = colorTable[htmlColor];
@@ -99,7 +99,7 @@ export function htmlColorToFloat32Array(htmlColor, opacity) {
99
99
  * Convert html color string to the RGB number vector.
100
100
  * @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.
101
101
  * @param {number} [opacity] - Opacity for the output vector.
102
- * @returns {og.Vec3} -
102
+ * @returns {Vec3} -
103
103
  */
104
104
  export function htmlColorToRgb(htmlColor) {
105
105
  var hColor = colorTable[htmlColor];
@@ -283,7 +283,7 @@ export function binarySearchFast(arr, x) {
283
283
  * Finds an item in a sorted array.
284
284
  * @param {Array} ar The sorted array to search.
285
285
  * @param {Object} el The item to find in the array.
286
- * @param {og.utils.binarySearch~compare_fn} compare_fn comparator The function to use to compare the item to
286
+ * @param {utils.binarySearch~compare_fn} compare_fn comparator The function to use to compare the item to
287
287
  * elements in the array.
288
288
  * @returns {Number} a negative number if a is less than b; 0 if a is equal to b;a positive number of a is greater than b.
289
289
  *
@@ -316,7 +316,7 @@ export function binarySearch(ar, el, compare_fn) {
316
316
  * Binary insertion that uses binarySearch algorithm.
317
317
  * @param {Array} ar - The sorted array to insert.
318
318
  * @param {Object} el - The item to insert.
319
- * @param {og.utils.binarySearch~compare_fn} compare_fn - comparator The function to use to compare the item to
319
+ * @param {utils.binarySearch~compare_fn} compare_fn - comparator The function to use to compare the item to
320
320
  * elements in the array.
321
321
  * @returns {Number} Array index position in which item inserted in.
322
322
  */
@@ -332,12 +332,12 @@ export function binaryInsert(ar, el, compare_fn) {
332
332
  /**
333
333
  * Returns two segment lines intersection coordinate.
334
334
  * @static
335
- * @param {og.math.Vec2} start1 - First line first coordinate.
336
- * @param {og.math.Vec2} end1 - First line second coordinate.
337
- * @param {og.math.Vec2} start2 - Second line first coordinate.
338
- * @param {og.math.Vec2} end2 - Second line second coordinate.
335
+ * @param {math.Vec2} start1 - First line first coordinate.
336
+ * @param {math.Vec2} end1 - First line second coordinate.
337
+ * @param {math.Vec2} start2 - Second line first coordinate.
338
+ * @param {math.Vec2} end2 - Second line second coordinate.
339
339
  * @param {boolean} [isSegment] - Lines are segments.
340
- * @return {og.math.Vec2} - Intersection coordinate.
340
+ * @return {math.Vec2} - Intersection coordinate.
341
341
  */
342
342
  export function getLinesIntersection2v(start1, end1, start2, end2, isSegment) {
343
343
  var dir1 = end1.sub(start1);
@@ -372,12 +372,12 @@ export function getLinesIntersection2v(start1, end1, start2, end2, isSegment) {
372
372
  /**
373
373
  * Returns two segment lines intersection coordinate.
374
374
  * @static
375
- * @param {og.math.Vec2} start1 - First line first coordinate.
376
- * @param {og.math.Vec2} end1 - First line second coordinate.
377
- * @param {og.math.Vec2} start2 - Second line first coordinate.
378
- * @param {og.math.Vec2} end2 - Second line second coordinate.
375
+ * @param {math.Vec2} start1 - First line first coordinate.
376
+ * @param {math.Vec2} end1 - First line second coordinate.
377
+ * @param {math.Vec2} start2 - Second line first coordinate.
378
+ * @param {math.Vec2} end2 - Second line second coordinate.
379
379
  * @param {boolean} [isSegment] - Lines are segments.
380
- * @return {og.math.Vec2} - Intersection coordinate.
380
+ * @return {math.Vec2} - Intersection coordinate.
381
381
  */
382
382
  export function getLinesIntersectionLonLat(start1, end1, start2, end2, isSegment) {
383
383
  var dir1 = new LonLat(end1.lon - start1.lon, end1.lat - start1.lat);
@@ -752,7 +752,7 @@ export function concatTypedArrays(a, b) {
752
752
  * @param {TypedArray | Array} a
753
753
  * @param {TypedArray | Array} b
754
754
  */
755
- export function concatArrays(a, b) {
755
+ export function concatArrays(a = [], b) {
756
756
  if (ArrayBuffer.isView(a)) {
757
757
  return concatTypedArrays(a, b);
758
758
  } else {
@@ -940,4 +940,4 @@ export function cloneArray(items) {
940
940
  */
941
941
  export function isUndef(obj) {
942
942
  return obj === void 0;
943
- }
943
+ }
@@ -2,14 +2,14 @@
2
2
  * @module og/webgl/Framebuffer
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { ImageCanvas } from '../ImageCanvas.js';
7
+ import { ImageCanvas } from "../ImageCanvas.js";
8
8
 
9
9
  /**
10
10
  * Class represents framebuffer.
11
11
  * @class
12
- * @param {og.webgl.Handler} handler - WebGL handler.
12
+ * @param {Handler} handler - WebGL handler.
13
13
  * @param {Object} [options] - Framebuffer options:
14
14
  * @param {number} [options.width] - Framebuffer width. Default is handler canvas width.
15
15
  * @param {number} [options.height] - Framebuffer height. Default is handler canvas height.
@@ -21,13 +21,11 @@ import { ImageCanvas } from '../ImageCanvas.js';
21
21
  * @param {Boolean} [options.useDepth] - Using depth buffer during the rendering.
22
22
  */
23
23
  export class Framebuffer {
24
-
25
24
  constructor(handler, options = {}) {
26
-
27
25
  /**
28
26
  * WebGL handler.
29
27
  * @public
30
- * @type {og.webgl.Handler}
28
+ * @type {Handler}
31
29
  */
32
30
  this.handler = handler;
33
31
 
@@ -49,20 +47,27 @@ export class Framebuffer {
49
47
 
50
48
  this._filter = options.filter || "NEAREST";
51
49
 
52
- this._internalFormatArr = options.internalFormat instanceof Array ? options.internalFormat : [options.internalFormat || "RGBA"];
50
+ this._internalFormatArr =
51
+ options.internalFormat instanceof Array
52
+ ? options.internalFormat
53
+ : [options.internalFormat || "RGBA"];
53
54
 
54
- this._formatArr = options.format instanceof Array ? options.format : [options.format || "RGBA"];
55
+ this._formatArr =
56
+ options.format instanceof Array ? options.format : [options.format || "RGBA"];
55
57
 
56
- this._typeArr = options.type instanceof Array ? options.type : [options.type || "UNSIGNED_BYTE"];
58
+ this._typeArr =
59
+ options.type instanceof Array ? options.type : [options.type || "UNSIGNED_BYTE"];
57
60
 
58
- this._attachmentArr = options.attachment instanceof Array ?
59
- options.attachment.map((a, i) => {
60
- let res = a.toUpperCase();
61
- if (res === "COLOR_ATTACHMENT") {
62
- return `${res}${i.toString()}`;
63
- }
64
- return res;
65
- }) : [options.attachment || "COLOR_ATTACHMENT0"];
61
+ this._attachmentArr =
62
+ options.attachment instanceof Array
63
+ ? options.attachment.map((a, i) => {
64
+ let res = a.toUpperCase();
65
+ if (res === "COLOR_ATTACHMENT") {
66
+ return `${res}${i.toString()}`;
67
+ }
68
+ return res;
69
+ })
70
+ : [options.attachment || "COLOR_ATTACHMENT0"];
66
71
 
67
72
  /**
68
73
  * Framebuffer width.
@@ -78,12 +83,13 @@ export class Framebuffer {
78
83
  */
79
84
  this._height = options.height || handler.canvas.height;
80
85
 
81
- this._depthComponent = options.depthComponent != undefined ? options.depthComponent : "DEPTH_COMPONENT16";
86
+ this._depthComponent =
87
+ options.depthComponent != undefined ? options.depthComponent : "DEPTH_COMPONENT16";
82
88
 
83
89
  this._useDepth = options.useDepth != undefined ? options.useDepth : true;
84
90
 
85
91
  /**
86
- * Framebuffer activity.
92
+ * Framebuffer activity.
87
93
  * @private
88
94
  * @type {boolean}
89
95
  */
@@ -100,19 +106,25 @@ export class Framebuffer {
100
106
  }
101
107
 
102
108
  static blit(sourceFramebuffer, destFramebuffer, glAttachment, glMask, glFilter) {
103
-
104
109
  let gl = sourceFramebuffer.handler.gl;
105
110
 
106
111
  gl.bindFramebuffer(gl.READ_FRAMEBUFFER, sourceFramebuffer._fbo);
107
- gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, framebuffer._fbo);
112
+ gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, destFramebuffer._fbo);
108
113
  gl.readBuffer(glAttachment);
109
114
 
110
115
  gl.clearBufferfv(gl.COLOR, 0, [0.0, 0.0, 0.0, 1.0]);
111
116
 
112
117
  gl.blitFramebuffer(
113
- 0, 0, sourceFramebuffer._width, sourceFramebuffer._height,
114
- 0, 0, destFramebuffer._width, destFramebuffer._height,
115
- glMask, glFilter
118
+ 0,
119
+ 0,
120
+ sourceFramebuffer._width,
121
+ sourceFramebuffer._height,
122
+ 0,
123
+ 0,
124
+ destFramebuffer._width,
125
+ destFramebuffer._height,
126
+ glMask,
127
+ glFilter
116
128
  );
117
129
 
118
130
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
@@ -151,8 +163,8 @@ export class Framebuffer {
151
163
  if (!this._isBare) {
152
164
  let attachmentArr = [];
153
165
  for (var i = 0; i < this.textures.length; i++) {
154
-
155
- let ti = this.textures[i] ||
166
+ let ti =
167
+ this.textures[i] ||
156
168
  this.handler.createEmptyTexture2DExt(
157
169
  this._width,
158
170
  this._height,
@@ -178,8 +190,18 @@ export class Framebuffer {
178
190
  if (this._useDepth) {
179
191
  this._depthRenderbuffer = gl.createRenderbuffer();
180
192
  gl.bindRenderbuffer(gl.RENDERBUFFER, this._depthRenderbuffer);
181
- gl.renderbufferStorage(gl.RENDERBUFFER, gl[this._depthComponent], this._width, this._height);
182
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._depthRenderbuffer);
193
+ gl.renderbufferStorage(
194
+ gl.RENDERBUFFER,
195
+ gl[this._depthComponent],
196
+ this._width,
197
+ this._height
198
+ );
199
+ gl.framebufferRenderbuffer(
200
+ gl.FRAMEBUFFER,
201
+ gl.DEPTH_ATTACHMENT,
202
+ gl.RENDERBUFFER,
203
+ this._depthRenderbuffer
204
+ );
183
205
  gl.bindRenderbuffer(gl.RENDERBUFFER, null);
184
206
  }
185
207
 
@@ -197,7 +219,13 @@ export class Framebuffer {
197
219
  bindOutputTexture(texture, glAttachment) {
198
220
  var gl = this.handler.gl;
199
221
  gl.bindTexture(gl.TEXTURE_2D, texture);
200
- gl.framebufferTexture2D(gl.FRAMEBUFFER, glAttachment || gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
222
+ gl.framebufferTexture2D(
223
+ gl.FRAMEBUFFER,
224
+ glAttachment || gl.COLOR_ATTACHMENT0,
225
+ gl.TEXTURE_2D,
226
+ texture,
227
+ 0
228
+ );
201
229
  gl.bindTexture(gl.TEXTURE_2D, null);
202
230
  }
203
231
 
@@ -248,7 +276,15 @@ export class Framebuffer {
248
276
  var gl = this.handler.gl;
249
277
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);
250
278
  gl.readBuffer && gl.readBuffer(gl.COLOR_ATTACHMENT0 + index || 0);
251
- gl.readPixels(nx * this._width, ny * this._height, w, h, gl.RGBA, gl[this._typeArr[index]], res);
279
+ gl.readPixels(
280
+ nx * this._width,
281
+ ny * this._height,
282
+ w,
283
+ h,
284
+ gl.RGBA,
285
+ gl[this._typeArr[index]],
286
+ res
287
+ );
252
288
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
253
289
  }
254
290
 
@@ -262,14 +298,22 @@ export class Framebuffer {
262
298
  var gl = this.handler.gl;
263
299
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);
264
300
  gl.readBuffer && gl.readBuffer(gl.COLOR_ATTACHMENT0 + attachmentIndex);
265
- gl.readPixels(0, 0, this._width, this._height, gl.RGBA, gl[this._typeArr[attachmentIndex]], res);
301
+ gl.readPixels(
302
+ 0,
303
+ 0,
304
+ this._width,
305
+ this._height,
306
+ gl.RGBA,
307
+ gl[this._typeArr[attachmentIndex]],
308
+ res
309
+ );
266
310
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
267
311
  }
268
312
 
269
313
  /**
270
314
  * Activate framebuffer frame to draw.
271
315
  * @public
272
- * @returns {og.webgl.Framebuffer} Returns Current framebuffer.
316
+ * @returns {Framebuffer} Returns Current framebuffer.
273
317
  */
274
318
  activate() {
275
319
  var gl = this.handler.gl;
@@ -323,17 +367,21 @@ export class Framebuffer {
323
367
  openImage() {
324
368
  var img = this.getImage();
325
369
  var dataUrl = img.src;
326
- var windowContent = '<!DOCTYPE html>';
327
- windowContent += '<html>';
328
- windowContent += '<head><title>Print</title></head>';
329
- windowContent += '<body>';
370
+ var windowContent = "<!DOCTYPE html>";
371
+ windowContent += "<html>";
372
+ windowContent += "<head><title>Print</title></head>";
373
+ windowContent += "<body>";
330
374
  windowContent += '<img src="' + dataUrl + '">';
331
- windowContent += '</body>';
332
- windowContent += '</html>';
333
- var printWin = window.open('', '', 'width=' + img.width + 'px ,height=' + img.height + 'px');
375
+ windowContent += "</body>";
376
+ windowContent += "</html>";
377
+ var printWin = window.open(
378
+ "",
379
+ "",
380
+ "width=" + img.width + "px ,height=" + img.height + "px"
381
+ );
334
382
  printWin.document.open();
335
383
  printWin.document.write(windowContent);
336
384
  printWin.document.close();
337
385
  printWin.focus();
338
386
  }
339
- }
387
+ }