@openglobus/og 0.11.4 → 0.11.8

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 (260) hide show
  1. package/css/og.css +3 -2
  2. package/package.json +12 -14
  3. package/src/og/Clock.js +6 -10
  4. package/src/og/Events.js +5 -7
  5. package/src/og/Extent.js +73 -32
  6. package/src/og/Globe.js +8 -5
  7. package/src/og/ImageCanvas.js +18 -15
  8. package/src/og/LonLat.js +13 -10
  9. package/src/og/Popup.js +19 -17
  10. package/src/og/QueueArray.js +3 -4
  11. package/src/og/Rectangle.js +4 -6
  12. package/src/og/Stack.js +2 -4
  13. package/src/og/ajax.js +20 -14
  14. package/src/og/astro/earth.js +21 -15
  15. package/src/og/bv/Box.js +2 -3
  16. package/src/og/bv/Sphere.js +10 -7
  17. package/src/og/camera/Frustum.js +19 -12
  18. package/src/og/camera/PlanetCamera.js +9 -5
  19. package/src/og/control/CompassButton.js +1 -2
  20. package/src/og/control/Control.js +7 -9
  21. package/src/og/control/DebugInfo.js +0 -1
  22. package/src/og/control/KeyboardNavigation.js +9 -9
  23. package/src/og/control/LayerSwitcher.js +21 -20
  24. package/src/og/control/Lighting.js +74 -64
  25. package/src/og/control/MouseNavigation.js +21 -18
  26. package/src/og/control/MouseWheelZoomControl.js +257 -0
  27. package/src/og/control/SegmentBoundVisualization.js +5 -6
  28. package/src/og/control/ShowFps.js +12 -7
  29. package/src/og/control/SimpleNavigation.js +5 -7
  30. package/src/og/control/Sun.js +22 -12
  31. package/src/og/control/ToggleWireframe.js +3 -3
  32. package/src/og/control/TouchNavigation.js +43 -32
  33. package/src/og/control/ZoomControl.js +40 -24
  34. package/src/og/control/index.js +2 -0
  35. package/src/og/control/visibleExtent/Segment.js +1862 -0
  36. package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
  37. package/src/og/control/visibleExtent/drawnode.js +751 -0
  38. package/src/og/ellipsoid/Ellipsoid.js +149 -57
  39. package/src/og/ellipsoid/wgs84.js +3 -3
  40. package/src/og/entity/BaseBillboard.js +72 -30
  41. package/src/og/entity/Billboard.js +9 -5
  42. package/src/og/entity/BillboardHandler.js +315 -62
  43. package/src/og/entity/Entity.js +39 -1
  44. package/src/og/entity/EntityCollection.js +47 -24
  45. package/src/og/entity/GeoObject.js +228 -0
  46. package/src/og/entity/GeoObjectHandler.js +910 -0
  47. package/src/og/entity/GeometryHandler.js +595 -123
  48. package/src/og/entity/Label.js +62 -30
  49. package/src/og/entity/LabelHandler.js +40 -242
  50. package/src/og/entity/LabelWorker.js +218 -0
  51. package/src/og/entity/Object3d.js +504 -0
  52. package/src/og/entity/PointCloud.js +76 -28
  53. package/src/og/entity/PointCloudHandler.js +5 -5
  54. package/src/og/entity/Ray.js +49 -16
  55. package/src/og/entity/Strip.js +72 -43
  56. package/src/og/entity/StripHandler.js +23 -23
  57. package/src/og/layer/BaseGeoImage.js +50 -19
  58. package/src/og/layer/CanvasTiles.js +16 -17
  59. package/src/og/layer/GeoImage.js +8 -16
  60. package/src/og/layer/GeoTexture2d.js +2 -10
  61. package/src/og/layer/GeoVideo.js +2 -10
  62. package/src/og/layer/KML.js +55 -33
  63. package/src/og/layer/Layer.js +24 -32
  64. package/src/og/layer/Material.js +1 -1
  65. package/src/og/layer/Vector.js +94 -48
  66. package/src/og/layer/WMS.js +33 -18
  67. package/src/og/layer/XYZ.js +4 -5
  68. package/src/og/light/LightSource.js +19 -12
  69. package/src/og/math/Mat3.js +24 -12
  70. package/src/og/math/Mat4.js +603 -603
  71. package/src/og/math/Plane.js +19 -18
  72. package/src/og/math/Ray.js +17 -12
  73. package/src/og/math/Vec2.js +24 -14
  74. package/src/og/math/Vec3.js +60 -30
  75. package/src/og/math/coder.js +7 -7
  76. package/src/og/proj/EPSG3857.js +3 -3
  77. package/src/og/proj/EPSG4326.js +3 -3
  78. package/src/og/proj/Proj.js +2 -4
  79. package/src/og/quadTree/Node.js +3 -3
  80. package/src/og/renderer/Renderer.js +106 -124
  81. package/src/og/renderer/RendererEvents.js +45 -23
  82. package/src/og/scene/BaseNode.js +2 -3
  83. package/src/og/scene/Planet.js +51 -90
  84. package/src/og/scene/RenderNode.js +15 -8
  85. package/src/og/segment/Segment.js +60 -156
  86. package/src/og/segment/Slice.js +45 -0
  87. package/src/og/shaders/drawnode.js +245 -342
  88. package/src/og/shaders/geoObject.js +211 -0
  89. package/src/og/shaders/pointCloud.js +41 -41
  90. package/src/og/shaders/shape.js +12 -18
  91. package/src/og/shaders/skybox.js +36 -36
  92. package/src/og/shaders/toneMapping.js +1 -0
  93. package/src/og/shapes/BaseShape.js +108 -36
  94. package/src/og/shapes/Icosphere.js +25 -10
  95. package/src/og/shapes/Sphere.js +8 -11
  96. package/src/og/utils/FontAtlas.js +6 -2
  97. package/src/og/utils/GeoImageCreator.js +5 -1
  98. package/src/og/utils/TextureAtlas.js +18 -20
  99. package/src/og/utils/VectorTileCreator.js +1 -3
  100. package/src/og/utils/shared.js +2 -2
  101. package/src/og/webgl/Handler.js +215 -162
  102. package/src/og/webgl/Multisample.js +44 -16
  103. package/src/og/webgl/Program.js +78 -33
  104. package/src/og/webgl/callbacks.js +3 -3
  105. package/types/Clock.d.ts +0 -94
  106. package/types/Deferred.d.ts +0 -6
  107. package/types/Events.d.ts +0 -77
  108. package/types/Extent.d.ts +0 -166
  109. package/types/Globe.d.ts +0 -82
  110. package/types/ImageCanvas.d.ts +0 -123
  111. package/types/Lock.d.ts +0 -12
  112. package/types/LonLat.d.ts +0 -108
  113. package/types/Popup.d.ts +0 -42
  114. package/types/QueueArray.d.ts +0 -19
  115. package/types/Rectangle.d.ts +0 -80
  116. package/types/Stack.d.ts +0 -19
  117. package/types/ajax.d.ts +0 -24
  118. package/types/arial.d.ts +0 -48
  119. package/types/astro/astro.d.ts +0 -38
  120. package/types/astro/earth.d.ts +0 -7
  121. package/types/astro/jd.d.ts +0 -254
  122. package/types/bv/Box.d.ts +0 -30
  123. package/types/bv/Sphere.d.ts +0 -38
  124. package/types/bv/index.d.ts +0 -3
  125. package/types/camera/Camera.d.ts +0 -312
  126. package/types/camera/Frustum.d.ts +0 -133
  127. package/types/camera/PlanetCamera.d.ts +0 -218
  128. package/types/camera/index.d.ts +0 -3
  129. package/types/cons.d.ts +0 -40
  130. package/types/control/CompassButton.d.ts +0 -17
  131. package/types/control/Control.d.ts +0 -104
  132. package/types/control/DebugInfo.d.ts +0 -15
  133. package/types/control/EarthCoordinates.d.ts +0 -47
  134. package/types/control/EarthNavigation.d.ts +0 -42
  135. package/types/control/GeoImageDragControl.d.ts +0 -6
  136. package/types/control/KeyboardNavigation.d.ts +0 -21
  137. package/types/control/LayerSwitcher.d.ts +0 -21
  138. package/types/control/Lighting.d.ts +0 -16
  139. package/types/control/MouseNavigation.d.ts +0 -47
  140. package/types/control/ScaleControl.d.ts +0 -22
  141. package/types/control/ShowFps.d.ts +0 -11
  142. package/types/control/SimpleNavigation.d.ts +0 -25
  143. package/types/control/Sun.d.ts +0 -50
  144. package/types/control/ToggleWireframe.d.ts +0 -12
  145. package/types/control/TouchNavigation.d.ts +0 -48
  146. package/types/control/ZoomControl.d.ts +0 -27
  147. package/types/control/index.d.ts +0 -17
  148. package/types/ellipsoid/Ellipsoid.d.ts +0 -146
  149. package/types/ellipsoid/index.d.ts +0 -3
  150. package/types/ellipsoid/wgs84.d.ts +0 -6
  151. package/types/entity/BaseBillboard.d.ts +0 -208
  152. package/types/entity/Billboard.d.ts +0 -94
  153. package/types/entity/BillboardHandler.d.ts +0 -78
  154. package/types/entity/Entity.d.ts +0 -333
  155. package/types/entity/EntityCollection.d.ts +0 -311
  156. package/types/entity/Geometry.d.ts +0 -74
  157. package/types/entity/GeometryHandler.d.ts +0 -76
  158. package/types/entity/Label.d.ts +0 -189
  159. package/types/entity/LabelHandler.d.ts +0 -29
  160. package/types/entity/PointCloud.d.ts +0 -174
  161. package/types/entity/PointCloudHandler.d.ts +0 -38
  162. package/types/entity/Polyline.d.ts +0 -306
  163. package/types/entity/PolylineHandler.d.ts +0 -18
  164. package/types/entity/Ray.d.ts +0 -124
  165. package/types/entity/RayHandler.d.ts +0 -67
  166. package/types/entity/ShapeHandler.d.ts +0 -22
  167. package/types/entity/Strip.d.ts +0 -119
  168. package/types/entity/StripHandler.d.ts +0 -38
  169. package/types/entity/index.d.ts +0 -8
  170. package/types/index.core.d.ts +0 -65
  171. package/types/index.d.ts +0 -45
  172. package/types/index.webgl.d.ts +0 -7
  173. package/types/input/KeyboardHandler.d.ts +0 -10
  174. package/types/input/MouseHandler.d.ts +0 -5
  175. package/types/input/TouchHandler.d.ts +0 -5
  176. package/types/input/input.d.ts +0 -34
  177. package/types/layer/BaseGeoImage.d.ts +0 -94
  178. package/types/layer/CanvasTiles.d.ts +0 -68
  179. package/types/layer/GeoImage.d.ts +0 -52
  180. package/types/layer/GeoTexture2d.d.ts +0 -8
  181. package/types/layer/GeoVideo.d.ts +0 -55
  182. package/types/layer/KML.d.ts +0 -63
  183. package/types/layer/Layer.d.ts +0 -325
  184. package/types/layer/Material.d.ts +0 -45
  185. package/types/layer/Vector.d.ts +0 -208
  186. package/types/layer/WMS.d.ts +0 -63
  187. package/types/layer/XYZ.d.ts +0 -120
  188. package/types/layer/index.d.ts +0 -10
  189. package/types/light/LightSource.d.ts +0 -178
  190. package/types/math/Line2.d.ts +0 -11
  191. package/types/math/Line3.d.ts +0 -10
  192. package/types/math/Mat3.d.ts +0 -65
  193. package/types/math/Mat4.d.ts +0 -176
  194. package/types/math/Plane.d.ts +0 -18
  195. package/types/math/Quat.d.ts +0 -379
  196. package/types/math/Ray.d.ts +0 -82
  197. package/types/math/Vec2.d.ts +0 -309
  198. package/types/math/Vec3.d.ts +0 -460
  199. package/types/math/Vec4.d.ts +0 -162
  200. package/types/math/coder.d.ts +0 -43
  201. package/types/math/index.d.ts +0 -11
  202. package/types/math.d.ts +0 -261
  203. package/types/mercator.d.ts +0 -92
  204. package/types/proj/EPSG3857.d.ts +0 -6
  205. package/types/proj/EPSG4326.d.ts +0 -6
  206. package/types/proj/Proj.d.ts +0 -42
  207. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  208. package/types/quadTree/Node.d.ts +0 -61
  209. package/types/quadTree/quadTree.d.ts +0 -40
  210. package/types/renderer/Renderer.d.ts +0 -298
  211. package/types/renderer/RendererEvents.d.ts +0 -233
  212. package/types/res/images.d.ts +0 -3
  213. package/types/scene/Axes.d.ts +0 -11
  214. package/types/scene/BaseNode.d.ts +0 -60
  215. package/types/scene/Planet.d.ts +0 -577
  216. package/types/scene/RenderNode.d.ts +0 -142
  217. package/types/scene/SkyBox.d.ts +0 -10
  218. package/types/scene/index.d.ts +0 -4
  219. package/types/segment/Segment.d.ts +0 -279
  220. package/types/segment/SegmentLonLat.d.ts +0 -16
  221. package/types/segment/segmentHelper.d.ts +0 -13
  222. package/types/shaders/billboard.d.ts +0 -3
  223. package/types/shaders/depth.d.ts +0 -2
  224. package/types/shaders/drawnode.d.ts +0 -7
  225. package/types/shaders/label.d.ts +0 -4
  226. package/types/shaders/pointCloud.d.ts +0 -2
  227. package/types/shaders/polyline.d.ts +0 -3
  228. package/types/shaders/ray.d.ts +0 -2
  229. package/types/shaders/screenFrame.d.ts +0 -2
  230. package/types/shaders/shape.d.ts +0 -4
  231. package/types/shaders/skybox.d.ts +0 -2
  232. package/types/shaders/toneMapping.d.ts +0 -2
  233. package/types/shapes/BaseShape.d.ts +0 -250
  234. package/types/shapes/Sphere.d.ts +0 -41
  235. package/types/terrain/BilTerrain.d.ts +0 -7
  236. package/types/terrain/EmptyTerrain.d.ts +0 -72
  237. package/types/terrain/Geoid.d.ts +0 -26
  238. package/types/terrain/GlobusTerrain.d.ts +0 -116
  239. package/types/terrain/MapboxTerrain.d.ts +0 -7
  240. package/types/terrain/index.d.ts +0 -5
  241. package/types/utils/FontAtlas.d.ts +0 -14
  242. package/types/utils/GeoImageCreator.d.ts +0 -30
  243. package/types/utils/ImagesCacheManager.d.ts +0 -10
  244. package/types/utils/Loader.d.ts +0 -25
  245. package/types/utils/NormalMapCreator.d.ts +0 -39
  246. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  247. package/types/utils/TerrainWorker.d.ts +0 -9
  248. package/types/utils/TextureAtlas.d.ts +0 -111
  249. package/types/utils/VectorTileCreator.d.ts +0 -16
  250. package/types/utils/colorTable.d.ts +0 -143
  251. package/types/utils/earcut.d.ts +0 -6
  252. package/types/utils/shared.d.ts +0 -231
  253. package/types/webgl/Framebuffer.d.ts +0 -135
  254. package/types/webgl/Handler.d.ts +0 -388
  255. package/types/webgl/Multisample.d.ts +0 -89
  256. package/types/webgl/Program.d.ts +0 -155
  257. package/types/webgl/ProgramController.d.ts +0 -89
  258. package/types/webgl/callbacks.d.ts +0 -1
  259. package/types/webgl/index.d.ts +0 -6
  260. package/types/webgl/types.d.ts +0 -2
@@ -211,14 +211,10 @@ class GeoVideo extends BaseGeoImage {
211
211
  var sha = sh.attributes,
212
212
  shu = sh.uniforms;
213
213
 
214
- var tr = this.transparentColor[0],
215
- tg = this.transparentColor[1],
216
- tb = this.transparentColor[2];
217
-
218
214
  gl.disable(gl.CULL_FACE);
219
215
 
220
216
  f.bindOutputTexture(this._materialTexture);
221
- gl.clearColor(tr, tg, tb, 0.0);
217
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
222
218
  gl.clear(gl.COLOR_BUFFER_BIT);
223
219
  gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
224
220
 
@@ -265,14 +261,10 @@ class GeoVideo extends BaseGeoImage {
265
261
  var sha = sh.attributes,
266
262
  shu = sh.uniforms;
267
263
 
268
- var tr = this.transparentColor[0],
269
- tg = this.transparentColor[1],
270
- tb = this.transparentColor[2];
271
-
272
264
  gl.disable(gl.CULL_FACE);
273
265
 
274
266
  f.bindOutputTexture(this._materialTexture);
275
- gl.clearColor(tr, tg, tb, 0.0);
267
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
276
268
  gl.clear(gl.COLOR_BUFFER_BIT);
277
269
  gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
278
270
 
@@ -2,11 +2,11 @@
2
2
  * @module og/layer/KML
3
3
  */
4
4
 
5
- 'use strict';
6
- import { Entity } from '../entity/Entity.js';
7
- import { Extent } from '../Extent.js';
8
- import { LonLat } from '../LonLat.js';
9
- import { Vector } from './Vector.js';
5
+ "use strict";
6
+ import { Entity } from "../entity/Entity.js";
7
+ import { Extent } from "../Extent.js";
8
+ import { LonLat } from "../LonLat.js";
9
+ import { Vector } from "./Vector.js";
10
10
 
11
11
  /**
12
12
  * Layer to render KMLs files
@@ -14,32 +14,39 @@ import { Vector } from './Vector.js';
14
14
  * @extends {Vector}
15
15
  */
16
16
  export class KML extends Vector {
17
-
18
17
  /**
19
- *
20
- * @param {string} name
18
+ *
19
+ * @param {string} name
21
20
  * @param {*} [options]
22
21
  */
23
22
  constructor(name, options = {}) {
24
23
  super(name, options);
25
24
  this._extent = null;
26
- this._billboard = options.billboard || { src: 'https://openglobus.org/examples/billboards/carrot.png' };
25
+ this._billboard = options.billboard || {
26
+ src: "https://openglobus.org/examples/billboards/carrot.png"
27
+ };
27
28
  /**
28
29
  * @type {string}
29
30
  */
30
- this._color = options.color || '#6689db';
31
+ this._color = options.color || "#6689db";
31
32
  }
32
33
 
33
34
  get instanceName() {
34
- return 'KML';
35
+ return "KML";
35
36
  }
36
37
 
37
38
  /**
38
39
  * @private
39
40
  */
40
41
  _extractCoordonatesFromKml(xmlDoc) {
41
- const raw = Array.from(xmlDoc.getElementsByTagName('coordinates'));
42
- const coordinates = raw.map(item => item.textContent.trim().replace(/\n/g, ' ').split(' ').map(co => co.split(',').map(parseFloat)));
42
+ const raw = Array.from(xmlDoc.getElementsByTagName("coordinates"));
43
+ const coordinates = raw.map((item) =>
44
+ item.textContent
45
+ .trim()
46
+ .replace(/\n/g, " ")
47
+ .split(" ")
48
+ .map((co) => co.split(",").map(parseFloat))
49
+ );
43
50
  return coordinates;
44
51
  }
45
52
 
@@ -47,32 +54,35 @@ export class KML extends Vector {
47
54
  * Creates billboards or polylines from array of lonlat.
48
55
  * @private
49
56
  * @param {Array} coordonates
50
- * @param {string} color
57
+ * @param {string} color
51
58
  * @returns {Array<Entity>}
52
59
  */
53
60
  _convertCoordonatesIntoEntities(coordinates, color, billboard) {
54
61
  const extent = new Extent(new LonLat(180.0, 90.0), new LonLat(-180.0, -90.0));
55
62
  const addToExtent = (c) => {
56
- const lon = c[0], lat = c[1];
63
+ const lon = c[0],
64
+ lat = c[1];
57
65
  if (lon < extent.southWest.lon) extent.southWest.lon = lon;
58
66
  if (lat < extent.southWest.lat) extent.southWest.lat = lat;
59
67
  if (lon > extent.northEast.lon) extent.northEast.lon = lon;
60
68
  if (lat > extent.northEast.lat) extent.northEast.lat = lat;
61
69
  };
62
70
  const _pathes = [];
63
- coordinates.forEach(kmlFile => kmlFile.forEach(p => _pathes.push(p)));
64
- const entities = _pathes.map(path => {
71
+ coordinates.forEach((kmlFile) => kmlFile.forEach((p) => _pathes.push(p)));
72
+ const entities = _pathes.map((path) => {
65
73
  if (path.length === 1) {
66
74
  const lonlat = path[0];
67
75
  const _entity = new Entity({ lonlat, billboard });
68
76
  addToExtent(lonlat);
69
77
  return _entity;
70
78
  } else if (path.length > 1) {
71
- const pathLonLat = path.map(item => {
79
+ const pathLonLat = path.map((item) => {
72
80
  addToExtent(item);
73
81
  return new LonLat(item[0], item[1], item[2]);
74
82
  });
75
- const _entity = new Entity({ polyline: { pathLonLat: [pathLonLat], thickness: 3, color, isClosed: false } });
83
+ const _entity = new Entity({
84
+ polyline: { pathLonLat: [pathLonLat], thickness: 3, color, isClosed: false }
85
+ });
76
86
  return _entity;
77
87
  }
78
88
  });
@@ -84,9 +94,10 @@ export class KML extends Vector {
84
94
  * @returns {Document}
85
95
  */
86
96
  _getXmlContent(file) {
87
- return new Promise(resolve => {
97
+ return new Promise((resolve) => {
88
98
  const fileReader = new FileReader();
89
- fileReader.onload = async i => resolve((new DOMParser()).parseFromString(i.target.result, 'text/xml'));
99
+ fileReader.onload = async (i) =>
100
+ resolve(new DOMParser().parseFromString(i.target.result, "text/xml"));
90
101
  fileReader.readAsText(file);
91
102
  });
92
103
  }
@@ -96,10 +107,14 @@ export class KML extends Vector {
96
107
  */
97
108
  _expandExtents(extent1, extent2) {
98
109
  if (!extent1) return extent2;
99
- if (extent2.southWest.lon < extent1.southWest.lon) extent1.southWest.lon = extent2.southWest.lon;
100
- if (extent2.southWest.lat < extent1.southWest.lat) extent1.southWest.lat = extent2.southWest.lat;
101
- if (extent2.northEast.lon > extent1.northEast.lon) extent1.northEast.lon = extent2.northEast.lon;
102
- if (extent2.northEast.lat > extent1.northEast.lat) extent1.northEast.lat = extent2.northEast.lat;
110
+ if (extent2.southWest.lon < extent1.southWest.lon)
111
+ extent1.southWest.lon = extent2.southWest.lon;
112
+ if (extent2.southWest.lat < extent1.southWest.lat)
113
+ extent1.southWest.lat = extent2.southWest.lat;
114
+ if (extent2.northEast.lon > extent1.northEast.lon)
115
+ extent1.northEast.lon = extent2.northEast.lon;
116
+ if (extent2.northEast.lat > extent1.northEast.lat)
117
+ extent1.northEast.lat = extent2.northEast.lat;
103
118
  return extent1;
104
119
  }
105
120
 
@@ -111,14 +126,18 @@ export class KML extends Vector {
111
126
  async addKmlFromFiles(kmls) {
112
127
  const kmlObjs = await Promise.all(kmls.map(this._getXmlContent));
113
128
  const coordonates = kmlObjs.map(this._extractCoordonatesFromKml);
114
- const { entities, extent } = this._convertCoordonatesIntoEntities(coordonates, this._color, this._billboard);
129
+ const { entities, extent } = this._convertCoordonatesIntoEntities(
130
+ coordonates,
131
+ this._color,
132
+ this._billboard
133
+ );
115
134
  this._extent = this._expandExtents(this._extent, extent);
116
135
  entities.forEach(this.add.bind(this));
117
136
  return { entities, extent };
118
137
  }
119
138
 
120
139
  /**
121
- * @param {string} color
140
+ * @param {string} color
122
141
  * @public
123
142
  */
124
143
  setColor(color) {
@@ -132,14 +151,14 @@ export class KML extends Vector {
132
151
  _getKmlFromUrl(url) {
133
152
  return new Promise((resolve, reject) => {
134
153
  const request = new XMLHttpRequest();
135
- request.open('GET', url, true);
136
- request.responseType = 'document';
137
- request.overrideMimeType('text/xml');
154
+ request.open("GET", url, true);
155
+ request.responseType = "document";
156
+ request.overrideMimeType("text/xml");
138
157
  request.onload = () => {
139
158
  if (request.readyState === request.DONE && request.status === 200) {
140
159
  resolve(request.responseXML);
141
160
  } else {
142
- reject(new Error('no valid kml file'));
161
+ reject(new Error("no valid kml file"));
143
162
  }
144
163
  };
145
164
  request.send();
@@ -154,10 +173,13 @@ export class KML extends Vector {
154
173
  async addKmlFromUrl(url) {
155
174
  const kml = await this._getKmlFromUrl(url);
156
175
  const coordonates = this._extractCoordonatesFromKml(kml);
157
- const { entities, extent } = this._convertCoordonatesIntoEntities([coordonates], this._color, this._billboard);
176
+ const { entities, extent } = this._convertCoordonatesIntoEntities(
177
+ [coordonates],
178
+ this._color,
179
+ this._billboard
180
+ );
158
181
  this._extent = this._expandExtents(this._extent, extent);
159
182
  entities.forEach(this.add.bind(this));
160
183
  return { entities, extent };
161
184
  }
162
-
163
185
  }
@@ -11,7 +11,6 @@ import { Extent } from "../Extent.js";
11
11
  import { LonLat } from "../LonLat.js";
12
12
  import { Material } from "./Material.js";
13
13
  import { Vec3 } from "../math/Vec3.js";
14
- import { createTexture } from "../webgl/Handler.js";
15
14
 
16
15
  export const FADING_FACTOR = 0.29;
17
16
 
@@ -23,17 +22,14 @@ export const FADING_FACTOR = 0.29;
23
22
  * @param {String} [name="noname"] - Layer name.
24
23
  * @param {Object} [options] - Layer options:
25
24
  * @param {number} [options.opacity=1.0] - Layer opacity.
26
- * @param {Array.<number>} [options.transparentColor=[-1,-1,-1]] - RGB color that defines transparent color. (exactly 3 entries)
27
25
  * @param {number} [options.minZoom=0] - Minimal visibility zoom level.
28
26
  * @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
29
27
  * @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
30
28
  * @param {boolean} [options.isBaseLayer=false] - This is a base layer.
31
29
  * @param {boolean} [options.visibility=true] - Layer visibility.
30
+ * @param {boolean} [options.isSRGB=false] - Layer image webgl nternal format.
32
31
  * @param {Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
33
- * @param {Vec3} [options.ambient=[0.1, 0.1, 0.21]] - Ambient RGB color.
34
- * @param {Vec3} [options.diffuse=[1.0, 1.0, 1.0]] - Diffuse RGB color.
35
- * @param {Vec3} [options.specular=[0.00025, 0.00015, 0.0001]] - Specular RGB color.
36
- * @param {Number} [options.shininess=100] - Shininess.
32
+ * @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
37
33
  *
38
34
  * @fires og.Layer#visibilitychange
39
35
  * @fires og.Layer#add
@@ -85,13 +81,6 @@ class Layer {
85
81
  */
86
82
  this._opacity = options.opacity || 1.0;
87
83
 
88
- /**
89
- * Transparent RGB color mask.
90
- * @public
91
- * @type {Array.<number>} - (exactly 3 entries)
92
- */
93
- this.transparentColor = options.transparentColor || [-1, -1, -1];
94
-
95
84
  /**
96
85
  * Minimal zoom level when layer is visibile.
97
86
  * @public
@@ -106,16 +95,6 @@ class Layer {
106
95
  */
107
96
  this.maxZoom = options.maxZoom || 50;
108
97
 
109
- /**
110
- * Layer light material parameters.
111
- * @public
112
- * @type {Object}
113
- */
114
- this.ambient = utils.createColorRGB(options.ambient, new Vec3(0.1, 0.1, 0.21));
115
- this.diffuse = utils.createColorRGB(options.diffuse, new Vec3(0.5, 0.5, 0.35));
116
- this.specular = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.00012, 0.00001));
117
- this.shininess = options.shininess || 20.0;
118
-
119
98
  /**
120
99
  * Planet node.
121
100
  * @protected
@@ -184,13 +163,13 @@ class Layer {
184
163
  */
185
164
  this._extent = null;
186
165
 
187
- if (options.textureFilter) {
188
- this.createTexture =
189
- createTexture[options.textureFilter.trim().toUpperCase()] ||
190
- createTexture[textureFilter.LINEAR];
191
- } else {
192
- this.createTexture = createTexture.ANISOTROPHIC;
193
- }
166
+ this.createTexture = null;
167
+
168
+ this._textureFilter = options.textureFilter ? options.textureFilter.trim().toUpperCase() : "MIPMAP";
169
+
170
+ this._isSRGB = options.isSRGB != undefined ? options.isSRGB : false;
171
+
172
+ this._internalFormat = null;
194
173
 
195
174
  /**
196
175
  * Visible mercator extent.
@@ -332,7 +311,16 @@ class Layer {
332
311
  * @virtual
333
312
  * @param {Planet} planet - Planet render node.
334
313
  */
335
- _assignPlanet(planet) {
314
+ _assignPlanet(planet) {
315
+ // TODO: webgl1
316
+ if (this._isSRGB) {
317
+ this._internalFormat = planet.renderer.handler.gl.SRGB8_ALPHA8;
318
+ } else {
319
+ this._internalFormat = planet.renderer.handler.gl.RGBA8;
320
+ }
321
+
322
+ this.createTexture = planet.renderer.handler.createTexture[this._textureFilter];
323
+
336
324
  planet.layers.push(this);
337
325
  this._planet = planet;
338
326
  this.events.on("visibilitychange", planet._onLayerVisibilityChanged, planet);
@@ -395,7 +383,11 @@ class Layer {
395
383
  * @virtual
396
384
  */
397
385
  clear() {
398
- this._planet && this._planet._clearLayerMaterial(this);
386
+ if (this._planet) {
387
+ this._planet._clearLayerMaterial(this);
388
+ this._internalFormat = null;
389
+ this.createTexture = null;
390
+ }
399
391
  }
400
392
 
401
393
  /**
@@ -44,7 +44,7 @@ class Material {
44
44
  }
45
45
 
46
46
  _createTexture(img) {
47
- return this.layer.createTexture(this.segment.handler, img);
47
+ return this.layer.createTexture(img, this.layer._internalFormat);
48
48
  }
49
49
 
50
50
  /**
@@ -2,19 +2,22 @@
2
2
  * @module og/layer/Vector
3
3
  */
4
4
 
5
- 'use strict';
6
-
7
- import * as math from '../math.js';
8
- import * as mercator from '../mercator.js';
9
- import * as quadTree from '../quadTree/quadTree.js';
10
- import { Entity } from '../entity/Entity.js';
11
- import { EntityCollection } from '../entity/EntityCollection.js';
12
- import { Extent } from '../Extent.js';
13
- import { EntityCollectionNode, EntityCollectionNodeWGS84 } from '../quadTree/EntityCollectionNode.js';
14
- import { GeometryHandler } from '../entity/GeometryHandler.js';
15
- import { Layer } from './Layer.js';
16
- import { QueueArray } from '../QueueArray.js';
17
- import { Vec3 } from '../math/Vec3.js';
5
+ "use strict";
6
+
7
+ import * as math from "../math.js";
8
+ import * as mercator from "../mercator.js";
9
+ import * as quadTree from "../quadTree/quadTree.js";
10
+ import { Entity } from "../entity/Entity.js";
11
+ import { EntityCollection } from "../entity/EntityCollection.js";
12
+ import { Extent } from "../Extent.js";
13
+ import {
14
+ EntityCollectionNode,
15
+ EntityCollectionNodeWGS84
16
+ } from "../quadTree/EntityCollectionNode.js";
17
+ import { GeometryHandler } from "../entity/GeometryHandler.js";
18
+ import { Layer } from "./Layer.js";
19
+ import { QueueArray } from "../QueueArray.js";
20
+ import { Vec3 } from "../math/Vec3.js";
18
21
 
19
22
  /**
20
23
  * Creates entity instance array.
@@ -68,13 +71,11 @@ function _entitiesConstructor(entities) {
68
71
  * @fires og.layer.Vector#visibilitychange
69
72
  */
70
73
  class Vector extends Layer {
71
-
72
74
  /**
73
- * @param {string} name
75
+ * @param {string} name
74
76
  * @param {*} [options]
75
77
  */
76
78
  constructor(name, options = {}) {
77
-
78
79
  super(name, options);
79
80
 
80
81
  this.events.registerNames(EVENT_NAMES);
@@ -160,14 +161,16 @@ class Vector extends Layer {
160
161
  * @public
161
162
  * @type {Number}
162
163
  */
163
- this.polygonOffsetFactor = options.polygonOffsetFactor != undefined ? options.polygonOffsetFactor : 0.0;
164
+ this.polygonOffsetFactor =
165
+ options.polygonOffsetFactor != undefined ? options.polygonOffsetFactor : 0.0;
164
166
 
165
167
  /**
166
168
  * Specifies the scale Units for gl.polygonOffset function to calculate depth values, 0.0 is default.
167
169
  * @public
168
170
  * @type {Number}
169
171
  */
170
- this.polygonOffsetUnits = options.polygonOffsetUnits != undefined ? options.polygonOffsetUnits : -637000.0;
172
+ this.polygonOffsetUnits =
173
+ options.polygonOffsetUnits != undefined ? options.polygonOffsetUnits : -637000.0;
171
174
 
172
175
  this.pickingEnabled = this._pickingEnabled;
173
176
  }
@@ -277,7 +280,6 @@ class Vector extends Layer {
277
280
  }
278
281
 
279
282
  _proceedEntity(entity, rightNow) {
280
-
281
283
  let temp = this._hasImageryTiles;
282
284
 
283
285
  //
@@ -302,9 +304,10 @@ class Vector extends Layer {
302
304
 
303
305
  if (entity.billboard || entity.label) {
304
306
  if (this._planet) {
305
-
306
307
  if (entity._cartesian.isZero() && !entity._lonlat.isZero()) {
307
- entity._setCartesian3vSilent(this._planet.ellipsoid.lonLatToCartesian(entity._lonlat));
308
+ entity._setCartesian3vSilent(
309
+ this._planet.ellipsoid.lonLatToCartesian(entity._lonlat)
310
+ );
308
311
  } else {
309
312
  entity._lonlat = this._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
310
313
  }
@@ -367,15 +370,17 @@ class Vector extends Layer {
367
370
  node.count--;
368
371
  node = node.parentNode;
369
372
  }
370
- if (entity._nodePtr && entity._nodePtr.count === 0 &&
371
- entity._nodePtr.deferredEntities.length === 0) {
373
+ if (
374
+ entity._nodePtr &&
375
+ entity._nodePtr.count === 0 &&
376
+ entity._nodePtr.deferredEntities.length === 0
377
+ ) {
372
378
  entity._nodePtr.entityCollection = null;
373
379
  //
374
380
  // ...
375
381
  //
376
382
  }
377
- } else if (entity._nodePtr &&
378
- entity._nodePtr.deferredEntities.length) {
383
+ } else if (entity._nodePtr && entity._nodePtr.deferredEntities.length) {
379
384
  var defEntities = entity._nodePtr.deferredEntities;
380
385
  var j = defEntities.length;
381
386
  while (j--) {
@@ -478,7 +483,6 @@ class Vector extends Layer {
478
483
  * @public
479
484
  */
480
485
  clear() {
481
-
482
486
  let temp = new Array(this._entities.length);
483
487
 
484
488
  for (let i = 0; i < temp.length; i++) {
@@ -521,7 +525,6 @@ class Vector extends Layer {
521
525
  * @returns {layer.Vector} - Returns layer instance.
522
526
  */
523
527
  setEntities(entities) {
524
-
525
528
  let temp = new Array(entities.length);
526
529
  for (let i = 0, len = entities.length; i < len; i++) {
527
530
  temp[i] = entities[i];
@@ -573,12 +576,33 @@ class Vector extends Layer {
573
576
 
574
577
  _createEntityCollectionsTree(entitiesForTree) {
575
578
  if (this._planet) {
576
- this._entityCollectionsTree = new EntityCollectionNode(this, quadTree.NW, null, 0,
577
- Extent.createFromArray([-20037508.34, -20037508.34, 20037508.34, 20037508.34]), this._planet, 0);
578
- this._entityCollectionsTreeNorth = new EntityCollectionNodeWGS84(this, quadTree.NW, null, 0,
579
- Extent.createFromArray([-180, mercator.MAX_LAT, 180, 90]), this._planet, 0);
580
- this._entityCollectionsTreeSouth = new EntityCollectionNodeWGS84(this, quadTree.NW, null, 0,
581
- Extent.createFromArray([-180, -90, 180, mercator.MIN_LAT]), this._planet, 0);
579
+ this._entityCollectionsTree = new EntityCollectionNode(
580
+ this,
581
+ quadTree.NW,
582
+ null,
583
+ 0,
584
+ Extent.createFromArray([-20037508.34, -20037508.34, 20037508.34, 20037508.34]),
585
+ this._planet,
586
+ 0
587
+ );
588
+ this._entityCollectionsTreeNorth = new EntityCollectionNodeWGS84(
589
+ this,
590
+ quadTree.NW,
591
+ null,
592
+ 0,
593
+ Extent.createFromArray([-180, mercator.MAX_LAT, 180, 90]),
594
+ this._planet,
595
+ 0
596
+ );
597
+ this._entityCollectionsTreeSouth = new EntityCollectionNodeWGS84(
598
+ this,
599
+ quadTree.NW,
600
+ null,
601
+ 0,
602
+ Extent.createFromArray([-180, -90, 180, mercator.MIN_LAT]),
603
+ this._planet,
604
+ 0
605
+ );
582
606
 
583
607
  for (let i = 0, len = entitiesForTree.length; i < len; i++) {
584
608
  let entity = entitiesForTree[i];
@@ -682,7 +706,6 @@ class Vector extends Layer {
682
706
  }
683
707
 
684
708
  _collectStripCollectionPASS(outArr) {
685
-
686
709
  var ec = this._stripEntityCollection;
687
710
 
688
711
  ec._fadingOpacity = this._fadingOpacity;
@@ -699,7 +722,6 @@ class Vector extends Layer {
699
722
  }
700
723
 
701
724
  _collectPolylineCollectionPASS(outArr) {
702
-
703
725
  var ec = this._polylineEntityCollection;
704
726
 
705
727
  ec._fadingOpacity = this._fadingOpacity;
@@ -737,7 +759,12 @@ class Vector extends Layer {
737
759
  if (seg._extent.isInside(ll)) {
738
760
  let cart = p._path3v[c_j][c_j_h];
739
761
  seg.getTerrainPoint(cart, ll, res);
740
- p.setPoint3v(res.addA(res.normal().scale((rtg && p.altitude) || 0.0)), c_j_h, c_j, true);
762
+ p.setPoint3v(
763
+ res.addA(res.normal().scale((rtg && p.altitude) || 0.0)),
764
+ c_j_h,
765
+ c_j,
766
+ true
767
+ );
741
768
  break;
742
769
  }
743
770
  }
@@ -751,9 +778,10 @@ class Vector extends Layer {
751
778
  collectVisibleCollections(outArr) {
752
779
  var p = this._planet;
753
780
 
754
- if ((this._fading && this._fadingOpacity > 0.0) ||
755
- (this.minZoom <= this._planet.maxCurrZoom && this.maxZoom >= p.maxCurrZoom)) {
756
-
781
+ if (
782
+ (this._fading && this._fadingOpacity > 0.0) ||
783
+ (this.minZoom <= this._planet.maxCurrZoom && this.maxZoom >= p.maxCurrZoom)
784
+ ) {
757
785
  this._renderingNodes = {};
758
786
  this._renderingNodesNorth = {};
759
787
  this._renderingNodesSouth = {};
@@ -768,23 +796,41 @@ class Vector extends Layer {
768
796
  this._entityCollectionsTree.collectRenderCollectionsPASS1(p._visibleNodes, outArr);
769
797
  var i = this._secondPASS.length;
770
798
  while (i--) {
771
- this._secondPASS[i].collectRenderCollectionsPASS2(p._visibleNodes, outArr, this._secondPASS[i].nodeId);
799
+ this._secondPASS[i].collectRenderCollectionsPASS2(
800
+ p._visibleNodes,
801
+ outArr,
802
+ this._secondPASS[i].nodeId
803
+ );
772
804
  }
773
805
 
774
806
  // North nodes
775
807
  this._secondPASS = [];
776
- this._entityCollectionsTreeNorth.collectRenderCollectionsPASS1(p._visibleNodesNorth, outArr);
808
+ this._entityCollectionsTreeNorth.collectRenderCollectionsPASS1(
809
+ p._visibleNodesNorth,
810
+ outArr
811
+ );
777
812
  i = this._secondPASS.length;
778
813
  while (i--) {
779
- this._secondPASS[i].collectRenderCollectionsPASS2(p._visibleNodesNorth, outArr, this._secondPASS[i].nodeId);
814
+ this._secondPASS[i].collectRenderCollectionsPASS2(
815
+ p._visibleNodesNorth,
816
+ outArr,
817
+ this._secondPASS[i].nodeId
818
+ );
780
819
  }
781
820
 
782
821
  // South nodes
783
822
  this._secondPASS = [];
784
- this._entityCollectionsTreeSouth.collectRenderCollectionsPASS1(p._visibleNodesSouth, outArr);
823
+ this._entityCollectionsTreeSouth.collectRenderCollectionsPASS1(
824
+ p._visibleNodesSouth,
825
+ outArr
826
+ );
785
827
  i = this._secondPASS.length;
786
828
  while (i--) {
787
- this._secondPASS[i].collectRenderCollectionsPASS2(p._visibleNodesSouth, outArr, this._secondPASS[i].nodeId);
829
+ this._secondPASS[i].collectRenderCollectionsPASS2(
830
+ p._visibleNodesSouth,
831
+ outArr,
832
+ this._secondPASS[i].nodeId
833
+ );
788
834
  }
789
835
  }
790
836
  }
@@ -826,11 +872,12 @@ class Vector extends Layer {
826
872
  * @param {Segment.Material} material - Current material.
827
873
  */
828
874
  loadMaterial(material) {
829
-
830
875
  var seg = material.segment;
831
876
 
832
877
  if (this._isBaseLayer) {
833
- material.texture = seg._isNorth ? seg.planet.solidTextureOne : seg.planet.solidTextureTwo;
878
+ material.texture = seg._isNorth
879
+ ? seg.planet.solidTextureOne
880
+ : seg.planet.solidTextureTwo;
834
881
  } else {
835
882
  material.texture = seg.planet.transparentTexture;
836
883
  }
@@ -856,7 +903,6 @@ class Vector extends Layer {
856
903
  if (material.isReady) {
857
904
  return [0, 0, 1, 1];
858
905
  } else {
859
-
860
906
  !material.isLoading && this.loadMaterial(material);
861
907
 
862
908
  var segment = material.segment;
@@ -961,4 +1007,4 @@ const EVENT_NAMES = [
961
1007
  "entityremove"
962
1008
  ];
963
1009
 
964
- export { Vector };
1010
+ export { Vector };