@openglobus/og 0.11.5 → 0.12.0

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 (267) hide show
  1. package/css/og.css +5 -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 +25 -10
  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/Camera.js +70 -79
  18. package/src/og/camera/Frustum.js +19 -12
  19. package/src/og/camera/PlanetCamera.js +33 -34
  20. package/src/og/control/CompassButton.js +1 -2
  21. package/src/og/control/Control.js +7 -9
  22. package/src/og/control/DebugInfo.js +2 -3
  23. package/src/og/control/EarthNavigation.js +26 -17
  24. package/src/og/control/KeyboardNavigation.js +9 -9
  25. package/src/og/control/LayerSwitcher.js +21 -20
  26. package/src/og/control/Lighting.js +74 -64
  27. package/src/og/control/MouseNavigation.js +30 -29
  28. package/src/og/control/MouseWheelZoomControl.js +257 -0
  29. package/src/og/control/SegmentBoundVisualization.js +5 -6
  30. package/src/og/control/ShowFps.js +12 -7
  31. package/src/og/control/SimpleNavigation.js +5 -7
  32. package/src/og/control/Sun.js +24 -14
  33. package/src/og/control/ToggleWireframe.js +3 -3
  34. package/src/og/control/TouchNavigation.js +43 -32
  35. package/src/og/control/ZoomControl.js +40 -24
  36. package/src/og/control/index.js +2 -0
  37. package/src/og/control/visibleExtent/Segment.js +1862 -0
  38. package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
  39. package/src/og/control/visibleExtent/drawnode.js +751 -0
  40. package/src/og/ellipsoid/Ellipsoid.js +149 -57
  41. package/src/og/ellipsoid/wgs84.js +3 -3
  42. package/src/og/entity/BaseBillboard.js +72 -30
  43. package/src/og/entity/Billboard.js +9 -5
  44. package/src/og/entity/BillboardHandler.js +315 -62
  45. package/src/og/entity/Entity.js +742 -704
  46. package/src/og/entity/EntityCollection.js +47 -24
  47. package/src/og/entity/GeoObject.js +228 -0
  48. package/src/og/entity/GeoObjectHandler.js +895 -0
  49. package/src/og/entity/GeometryHandler.js +595 -123
  50. package/src/og/entity/Label.js +62 -30
  51. package/src/og/entity/LabelHandler.js +42 -243
  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 +76 -28
  55. package/src/og/entity/PointCloudHandler.js +5 -5
  56. package/src/og/entity/Ray.js +49 -16
  57. package/src/og/entity/Strip.js +72 -43
  58. package/src/og/entity/StripHandler.js +23 -23
  59. package/src/og/layer/BaseGeoImage.js +50 -19
  60. package/src/og/layer/CanvasTiles.js +16 -17
  61. package/src/og/layer/GeoImage.js +8 -16
  62. package/src/og/layer/GeoTexture2d.js +2 -10
  63. package/src/og/layer/GeoVideo.js +2 -10
  64. package/src/og/layer/KML.js +55 -33
  65. package/src/og/layer/Layer.js +24 -33
  66. package/src/og/layer/Material.js +1 -1
  67. package/src/og/layer/Vector.js +94 -48
  68. package/src/og/layer/WMS.js +33 -18
  69. package/src/og/layer/XYZ.js +24 -26
  70. package/src/og/light/LightSource.js +19 -12
  71. package/src/og/math/Mat3.js +24 -12
  72. package/src/og/math/Mat4.js +603 -603
  73. package/src/og/math/Plane.js +19 -18
  74. package/src/og/math/Ray.js +17 -12
  75. package/src/og/math/Vec2.js +24 -14
  76. package/src/og/math/Vec3.js +78 -32
  77. package/src/og/math/coder.js +7 -7
  78. package/src/og/proj/EPSG3857.js +3 -3
  79. package/src/og/proj/EPSG4326.js +3 -3
  80. package/src/og/proj/Proj.js +2 -4
  81. package/src/og/quadTree/Node.js +50 -95
  82. package/src/og/quadTree/quadTree.js +1 -1
  83. package/src/og/renderer/Renderer.js +106 -126
  84. package/src/og/renderer/RendererEvents.js +45 -23
  85. package/src/og/scene/BaseNode.js +2 -3
  86. package/src/og/scene/Planet.js +139 -191
  87. package/src/og/scene/RenderNode.js +15 -8
  88. package/src/og/segment/Segment.js +93 -268
  89. package/src/og/segment/Slice.js +45 -0
  90. package/src/og/shaders/drawnode.js +174 -360
  91. package/src/og/shaders/geoObject.js +211 -0
  92. package/src/og/shaders/pointCloud.js +41 -41
  93. package/src/og/shaders/shape.js +12 -18
  94. package/src/og/shaders/skybox.js +36 -36
  95. package/src/og/shaders/toneMapping.js +1 -0
  96. package/src/og/shapes/BaseShape.js +108 -36
  97. package/src/og/shapes/Icosphere.js +25 -10
  98. package/src/og/shapes/Sphere.js +8 -11
  99. package/src/og/terrain/EmptyTerrain.js +3 -2
  100. package/src/og/terrain/GlobusTerrain.js +2 -0
  101. package/src/og/utils/FontAtlas.js +6 -2
  102. package/src/og/utils/GeoImageCreator.js +5 -1
  103. package/src/og/utils/Loader.js +1 -1
  104. package/src/og/utils/PlainSegmentWorker.js +0 -13
  105. package/src/og/utils/TextureAtlas.js +18 -20
  106. package/src/og/utils/VectorTileCreator.js +1 -3
  107. package/src/og/utils/shared.js +2 -2
  108. package/src/og/webgl/Handler.js +219 -162
  109. package/src/og/webgl/Multisample.js +44 -16
  110. package/src/og/webgl/Program.js +78 -33
  111. package/src/og/webgl/callbacks.js +3 -3
  112. package/types/Clock.d.ts +0 -94
  113. package/types/Deferred.d.ts +0 -6
  114. package/types/Events.d.ts +0 -77
  115. package/types/Extent.d.ts +0 -166
  116. package/types/Globe.d.ts +0 -82
  117. package/types/ImageCanvas.d.ts +0 -123
  118. package/types/Lock.d.ts +0 -12
  119. package/types/LonLat.d.ts +0 -108
  120. package/types/Popup.d.ts +0 -42
  121. package/types/QueueArray.d.ts +0 -19
  122. package/types/Rectangle.d.ts +0 -80
  123. package/types/Stack.d.ts +0 -19
  124. package/types/ajax.d.ts +0 -24
  125. package/types/arial.d.ts +0 -48
  126. package/types/astro/astro.d.ts +0 -38
  127. package/types/astro/earth.d.ts +0 -7
  128. package/types/astro/jd.d.ts +0 -254
  129. package/types/bv/Box.d.ts +0 -30
  130. package/types/bv/Sphere.d.ts +0 -38
  131. package/types/bv/index.d.ts +0 -3
  132. package/types/camera/Camera.d.ts +0 -312
  133. package/types/camera/Frustum.d.ts +0 -133
  134. package/types/camera/PlanetCamera.d.ts +0 -218
  135. package/types/camera/index.d.ts +0 -3
  136. package/types/cons.d.ts +0 -40
  137. package/types/control/CompassButton.d.ts +0 -17
  138. package/types/control/Control.d.ts +0 -104
  139. package/types/control/DebugInfo.d.ts +0 -15
  140. package/types/control/EarthCoordinates.d.ts +0 -47
  141. package/types/control/EarthNavigation.d.ts +0 -42
  142. package/types/control/GeoImageDragControl.d.ts +0 -6
  143. package/types/control/KeyboardNavigation.d.ts +0 -21
  144. package/types/control/LayerSwitcher.d.ts +0 -21
  145. package/types/control/Lighting.d.ts +0 -16
  146. package/types/control/MouseNavigation.d.ts +0 -47
  147. package/types/control/ScaleControl.d.ts +0 -22
  148. package/types/control/ShowFps.d.ts +0 -11
  149. package/types/control/SimpleNavigation.d.ts +0 -25
  150. package/types/control/Sun.d.ts +0 -50
  151. package/types/control/ToggleWireframe.d.ts +0 -12
  152. package/types/control/TouchNavigation.d.ts +0 -48
  153. package/types/control/ZoomControl.d.ts +0 -27
  154. package/types/control/index.d.ts +0 -17
  155. package/types/ellipsoid/Ellipsoid.d.ts +0 -146
  156. package/types/ellipsoid/index.d.ts +0 -3
  157. package/types/ellipsoid/wgs84.d.ts +0 -6
  158. package/types/entity/BaseBillboard.d.ts +0 -208
  159. package/types/entity/Billboard.d.ts +0 -94
  160. package/types/entity/BillboardHandler.d.ts +0 -78
  161. package/types/entity/Entity.d.ts +0 -333
  162. package/types/entity/EntityCollection.d.ts +0 -311
  163. package/types/entity/Geometry.d.ts +0 -74
  164. package/types/entity/GeometryHandler.d.ts +0 -76
  165. package/types/entity/Label.d.ts +0 -189
  166. package/types/entity/LabelHandler.d.ts +0 -29
  167. package/types/entity/PointCloud.d.ts +0 -174
  168. package/types/entity/PointCloudHandler.d.ts +0 -38
  169. package/types/entity/Polyline.d.ts +0 -306
  170. package/types/entity/PolylineHandler.d.ts +0 -18
  171. package/types/entity/Ray.d.ts +0 -124
  172. package/types/entity/RayHandler.d.ts +0 -67
  173. package/types/entity/ShapeHandler.d.ts +0 -22
  174. package/types/entity/Strip.d.ts +0 -119
  175. package/types/entity/StripHandler.d.ts +0 -38
  176. package/types/entity/index.d.ts +0 -8
  177. package/types/index.core.d.ts +0 -65
  178. package/types/index.d.ts +0 -45
  179. package/types/index.webgl.d.ts +0 -7
  180. package/types/input/KeyboardHandler.d.ts +0 -10
  181. package/types/input/MouseHandler.d.ts +0 -5
  182. package/types/input/TouchHandler.d.ts +0 -5
  183. package/types/input/input.d.ts +0 -34
  184. package/types/layer/BaseGeoImage.d.ts +0 -94
  185. package/types/layer/CanvasTiles.d.ts +0 -68
  186. package/types/layer/GeoImage.d.ts +0 -52
  187. package/types/layer/GeoTexture2d.d.ts +0 -8
  188. package/types/layer/GeoVideo.d.ts +0 -55
  189. package/types/layer/KML.d.ts +0 -63
  190. package/types/layer/Layer.d.ts +0 -326
  191. package/types/layer/Material.d.ts +0 -45
  192. package/types/layer/Vector.d.ts +0 -208
  193. package/types/layer/WMS.d.ts +0 -63
  194. package/types/layer/XYZ.d.ts +0 -120
  195. package/types/layer/index.d.ts +0 -10
  196. package/types/light/LightSource.d.ts +0 -178
  197. package/types/math/Line2.d.ts +0 -11
  198. package/types/math/Line3.d.ts +0 -10
  199. package/types/math/Mat3.d.ts +0 -65
  200. package/types/math/Mat4.d.ts +0 -176
  201. package/types/math/Plane.d.ts +0 -18
  202. package/types/math/Quat.d.ts +0 -379
  203. package/types/math/Ray.d.ts +0 -82
  204. package/types/math/Vec2.d.ts +0 -309
  205. package/types/math/Vec3.d.ts +0 -460
  206. package/types/math/Vec4.d.ts +0 -162
  207. package/types/math/coder.d.ts +0 -43
  208. package/types/math/index.d.ts +0 -11
  209. package/types/math.d.ts +0 -261
  210. package/types/mercator.d.ts +0 -92
  211. package/types/proj/EPSG3857.d.ts +0 -6
  212. package/types/proj/EPSG4326.d.ts +0 -6
  213. package/types/proj/Proj.d.ts +0 -42
  214. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  215. package/types/quadTree/Node.d.ts +0 -61
  216. package/types/quadTree/quadTree.d.ts +0 -40
  217. package/types/renderer/Renderer.d.ts +0 -298
  218. package/types/renderer/RendererEvents.d.ts +0 -233
  219. package/types/res/images.d.ts +0 -3
  220. package/types/scene/Axes.d.ts +0 -11
  221. package/types/scene/BaseNode.d.ts +0 -60
  222. package/types/scene/Planet.d.ts +0 -577
  223. package/types/scene/RenderNode.d.ts +0 -142
  224. package/types/scene/SkyBox.d.ts +0 -10
  225. package/types/scene/index.d.ts +0 -4
  226. package/types/segment/Segment.d.ts +0 -279
  227. package/types/segment/SegmentLonLat.d.ts +0 -16
  228. package/types/segment/segmentHelper.d.ts +0 -13
  229. package/types/shaders/billboard.d.ts +0 -3
  230. package/types/shaders/depth.d.ts +0 -2
  231. package/types/shaders/drawnode.d.ts +0 -7
  232. package/types/shaders/label.d.ts +0 -4
  233. package/types/shaders/pointCloud.d.ts +0 -2
  234. package/types/shaders/polyline.d.ts +0 -3
  235. package/types/shaders/ray.d.ts +0 -2
  236. package/types/shaders/screenFrame.d.ts +0 -2
  237. package/types/shaders/shape.d.ts +0 -4
  238. package/types/shaders/skybox.d.ts +0 -2
  239. package/types/shaders/toneMapping.d.ts +0 -2
  240. package/types/shapes/BaseShape.d.ts +0 -250
  241. package/types/shapes/Sphere.d.ts +0 -41
  242. package/types/terrain/BilTerrain.d.ts +0 -7
  243. package/types/terrain/EmptyTerrain.d.ts +0 -72
  244. package/types/terrain/Geoid.d.ts +0 -26
  245. package/types/terrain/GlobusTerrain.d.ts +0 -116
  246. package/types/terrain/MapboxTerrain.d.ts +0 -7
  247. package/types/terrain/index.d.ts +0 -5
  248. package/types/utils/FontAtlas.d.ts +0 -14
  249. package/types/utils/GeoImageCreator.d.ts +0 -30
  250. package/types/utils/ImagesCacheManager.d.ts +0 -10
  251. package/types/utils/Loader.d.ts +0 -25
  252. package/types/utils/NormalMapCreator.d.ts +0 -39
  253. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  254. package/types/utils/TerrainWorker.d.ts +0 -9
  255. package/types/utils/TextureAtlas.d.ts +0 -111
  256. package/types/utils/VectorTileCreator.d.ts +0 -16
  257. package/types/utils/colorTable.d.ts +0 -143
  258. package/types/utils/earcut.d.ts +0 -6
  259. package/types/utils/shared.d.ts +0 -231
  260. package/types/webgl/Framebuffer.d.ts +0 -135
  261. package/types/webgl/Handler.d.ts +0 -388
  262. package/types/webgl/Multisample.d.ts +0 -89
  263. package/types/webgl/Program.d.ts +0 -155
  264. package/types/webgl/ProgramController.d.ts +0 -89
  265. package/types/webgl/callbacks.d.ts +0 -1
  266. package/types/webgl/index.d.ts +0 -6
  267. 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,18 +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 {string} [options.textureFilter=["anisotrophyc"]] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotrophic".
37
- * @param {Number} [options.shininess=100] - Shininess.
32
+ * @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
38
33
  *
39
34
  * @fires og.Layer#visibilitychange
40
35
  * @fires og.Layer#add
@@ -86,13 +81,6 @@ class Layer {
86
81
  */
87
82
  this._opacity = options.opacity || 1.0;
88
83
 
89
- /**
90
- * Transparent RGB color mask.
91
- * @public
92
- * @type {Array.<number>} - (exactly 3 entries)
93
- */
94
- this.transparentColor = options.transparentColor || [-1, -1, -1];
95
-
96
84
  /**
97
85
  * Minimal zoom level when layer is visibile.
98
86
  * @public
@@ -107,16 +95,6 @@ class Layer {
107
95
  */
108
96
  this.maxZoom = options.maxZoom || 50;
109
97
 
110
- /**
111
- * Layer light material parameters.
112
- * @public
113
- * @type {Object}
114
- */
115
- this.ambient = utils.createColorRGB(options.ambient, new Vec3(0.1, 0.1, 0.21));
116
- this.diffuse = utils.createColorRGB(options.diffuse, new Vec3(0.5, 0.5, 0.35));
117
- this.specular = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.00012, 0.00001));
118
- this.shininess = options.shininess || 20.0;
119
-
120
98
  /**
121
99
  * Planet node.
122
100
  * @protected
@@ -185,13 +163,13 @@ class Layer {
185
163
  */
186
164
  this._extent = null;
187
165
 
188
- if (options.textureFilter) {
189
- this.createTexture =
190
- createTexture[options.textureFilter.trim().toUpperCase()] ||
191
- createTexture.ANISOTROPHIC;
192
- } else {
193
- this.createTexture = createTexture.ANISOTROPHIC;
194
- }
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;
195
173
 
196
174
  /**
197
175
  * Visible mercator extent.
@@ -333,7 +311,16 @@ class Layer {
333
311
  * @virtual
334
312
  * @param {Planet} planet - Planet render node.
335
313
  */
336
- _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
+
337
324
  planet.layers.push(this);
338
325
  this._planet = planet;
339
326
  this.events.on("visibilitychange", planet._onLayerVisibilityChanged, planet);
@@ -396,7 +383,11 @@ class Layer {
396
383
  * @virtual
397
384
  */
398
385
  clear() {
399
- this._planet && this._planet._clearLayerMaterial(this);
386
+ if (this._planet) {
387
+ this._planet._clearLayerMaterial(this);
388
+ this._internalFormat = null;
389
+ this.createTexture = null;
390
+ }
400
391
  }
401
392
 
402
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 };