@openglobus/og 0.16.3 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/README.md +1 -1
  2. package/css/og.css +24 -2
  3. package/dist/@openglobus/og.css +1 -1
  4. package/dist/@openglobus/og.esm.js +2 -2
  5. package/dist/@openglobus/og.esm.js.map +1 -1
  6. package/dist/@openglobus/og.umd.js +2 -2
  7. package/dist/@openglobus/og.umd.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/og/Clock.js +1 -5
  10. package/src/og/Events.js +2 -6
  11. package/src/og/Extent.js +5 -9
  12. package/src/og/Globe.js +93 -56
  13. package/src/og/ImageCanvas.js +13 -6
  14. package/src/og/Lock.js +44 -48
  15. package/src/og/LonLat.js +1 -5
  16. package/src/og/Object3d.js +2 -2
  17. package/src/og/QueueArray.js +1 -1
  18. package/src/og/Stack.js +49 -53
  19. package/src/og/astro/earth.js +112 -116
  20. package/src/og/astro/jd.js +514 -518
  21. package/src/og/astro/orbit.js +119 -123
  22. package/src/og/astro/rotation.js +36 -40
  23. package/src/og/bv/Box.js +77 -81
  24. package/src/og/bv/Sphere.js +57 -61
  25. package/src/og/camera/Camera.js +20 -7
  26. package/src/og/camera/Frustum.js +4 -4
  27. package/src/og/camera/PlanetCamera.js +15 -22
  28. package/src/og/cons.js +1 -1
  29. package/src/og/control/Atmosphere.js +0 -4
  30. package/src/og/control/Control.js +9 -8
  31. package/src/og/control/DebugInfo.js +3 -7
  32. package/src/og/control/DrawingSwitcher.js +117 -0
  33. package/src/og/control/EarthCoordinates.js +214 -214
  34. package/src/og/control/EarthNavigation.js +6 -13
  35. package/src/og/control/GeoImageDragControl.js +0 -4
  36. package/src/og/control/KeyboardNavigation.js +0 -4
  37. package/src/og/control/LayerAnimation.js +0 -4
  38. package/src/og/control/LayerSwitcher.js +2 -4
  39. package/src/og/control/Lighting.js +12 -16
  40. package/src/og/control/MouseNavigation.js +1 -5
  41. package/src/og/control/MouseWheelZoomControl.js +0 -4
  42. package/src/og/control/RulerSwitcher.js +0 -4
  43. package/src/og/control/ScaleControl.js +2 -6
  44. package/src/og/control/ShowFps.js +40 -44
  45. package/src/og/control/SimpleNavigation.js +10 -10
  46. package/src/og/control/SimpleSkyBackground.js +0 -4
  47. package/src/og/control/Sun.js +0 -4
  48. package/src/og/control/ToggleWireframe.js +35 -39
  49. package/src/og/control/ZoomControl.js +0 -4
  50. package/src/og/control/drawing/DrawingControl.js +51 -0
  51. package/src/og/control/drawing/LineStringDrawingScene.js +203 -0
  52. package/src/og/control/drawing/PolygonDrawingScene.js +785 -0
  53. package/src/og/control/elevationProfile/ElevationProfile.js +275 -0
  54. package/src/og/control/index.js +5 -1
  55. package/src/og/control/ruler/Ruler.js +0 -4
  56. package/src/og/control/ruler/RulerScene.js +3 -2
  57. package/src/og/control/selection/Selection.js +0 -4
  58. package/src/og/control/selection/SelectionScene.js +2 -4
  59. package/src/og/control/timeline/TimelineControl.js +4 -4
  60. package/src/og/control/timeline/TimelineModel.js +2 -2
  61. package/src/og/control/timeline/TimelineView.js +1 -0
  62. package/src/og/control/visibleExtent/Segment.js +7 -7
  63. package/src/og/control/visibleExtent/drawnode.js +0 -4
  64. package/src/og/ellipsoid/Ellipsoid.js +236 -325
  65. package/src/og/ellipsoid/wgs84.js +0 -4
  66. package/src/og/entity/BaseBillboard.js +375 -379
  67. package/src/og/entity/Billboard.js +0 -4
  68. package/src/og/entity/BillboardHandler.js +3 -7
  69. package/src/og/entity/Entity.js +22 -22
  70. package/src/og/entity/EntityCollection.js +14 -18
  71. package/src/og/entity/GeoObject.js +6 -8
  72. package/src/og/entity/GeoObjectHandler.js +30 -24
  73. package/src/og/entity/Geometry.js +5 -4
  74. package/src/og/entity/GeometryHandler.js +18 -19
  75. package/src/og/entity/Label.js +0 -4
  76. package/src/og/entity/LabelHandler.js +10 -14
  77. package/src/og/entity/LabelWorker.js +1 -1
  78. package/src/og/entity/PointCloud.js +2 -6
  79. package/src/og/entity/PointCloudHandler.js +122 -126
  80. package/src/og/entity/Polyline.js +15 -17
  81. package/src/og/entity/PolylineHandler.js +104 -108
  82. package/src/og/entity/Ray.js +29 -29
  83. package/src/og/entity/RayHandler.js +2 -2
  84. package/src/og/entity/Strip.js +1 -1
  85. package/src/og/entity/StripHandler.js +2 -2
  86. package/src/og/index.js +3 -1
  87. package/src/og/input/KeyboardHandler.js +128 -132
  88. package/src/og/input/MouseHandler.js +94 -98
  89. package/src/og/input/TouchHandler.js +59 -63
  90. package/src/og/input/input.js +44 -48
  91. package/src/og/layer/BaseGeoImage.js +6 -9
  92. package/src/og/layer/CanvasTiles.js +1 -5
  93. package/src/og/layer/GeoImage.js +0 -4
  94. package/src/og/layer/GeoTexture2d.js +0 -4
  95. package/src/og/layer/GeoVideo.js +0 -4
  96. package/src/og/layer/KML.js +1 -0
  97. package/src/og/layer/Layer.js +22 -26
  98. package/src/og/layer/Material.js +0 -4
  99. package/src/og/layer/Vector.js +25 -22
  100. package/src/og/layer/WMS.js +182 -186
  101. package/src/og/layer/XYZ.js +0 -4
  102. package/src/og/light/LightSource.js +0 -4
  103. package/src/og/math/Line2.js +28 -32
  104. package/src/og/math/Mat3.js +152 -156
  105. package/src/og/math/Ray.js +0 -4
  106. package/src/og/math/Vec2.js +0 -4
  107. package/src/og/math/Vec3.js +5 -4
  108. package/src/og/math/Vec4.js +0 -4
  109. package/src/og/math/coder.js +104 -104
  110. package/src/og/math.js +42 -10
  111. package/src/og/mercator.js +1 -1
  112. package/src/og/proj/EPSG3857.js +13 -13
  113. package/src/og/proj/Proj.js +59 -63
  114. package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +1 -0
  115. package/src/og/quadTree/EarthQuadTreeStrategy.js +1 -0
  116. package/src/og/quadTree/EntityCollectionNode.js +12 -16
  117. package/src/og/quadTree/MarsQuadTreeStrategy.js +1 -0
  118. package/src/og/quadTree/Node.js +15 -14
  119. package/src/og/quadTree/QuadTreeStrategy.js +1 -0
  120. package/src/og/quadTree/Wgs84QuadTreeStrategy.js +1 -0
  121. package/src/og/renderer/Renderer.js +114 -27
  122. package/src/og/renderer/RendererEvents.js +0 -4
  123. package/src/og/scene/Axes.js +74 -78
  124. package/src/og/scene/BaseNode.js +1 -5
  125. package/src/og/scene/Planet.js +127 -130
  126. package/src/og/scene/RenderNode.js +20 -12
  127. package/src/og/scene/SkyBox.js +104 -108
  128. package/src/og/segment/Segment.js +10 -6
  129. package/src/og/segment/SegmentLonLat.js +3 -7
  130. package/src/og/segment/segmentHelper.js +229 -225
  131. package/src/og/shaders/atmos.js +1 -1
  132. package/src/og/shaders/billboard.js +0 -4
  133. package/src/og/shaders/drawnode.js +5 -9
  134. package/src/og/shaders/geoObject.js +0 -4
  135. package/src/og/shaders/label.js +0 -4
  136. package/src/og/shaders/pickingMask.js +0 -4
  137. package/src/og/shaders/pointCloud.js +0 -4
  138. package/src/og/shaders/polyline.js +0 -4
  139. package/src/og/shaders/ray.js +0 -4
  140. package/src/og/shaders/skybox.js +0 -4
  141. package/src/og/terrain/EmptyTerrain.js +0 -4
  142. package/src/og/utils/FontAtlas.js +0 -4
  143. package/src/og/utils/GeoImageCreator.js +2 -3
  144. package/src/og/utils/NormalMapCreator.js +11 -12
  145. package/src/og/utils/PlainSegmentWorker.js +9 -9
  146. package/src/og/utils/TerrainWorker.js +2 -2
  147. package/src/og/utils/TextureAtlas.js +1 -1
  148. package/src/og/utils/VectorTileCreator.js +3 -9
  149. package/src/og/utils/earcut.js +8 -8
  150. package/src/og/utils/shared.js +30 -11
  151. package/src/og/webgl/Framebuffer.js +2 -6
  152. package/src/og/webgl/Handler.js +46 -20
  153. package/src/og/webgl/Multisample.js +2 -6
  154. package/src/og/webgl/Program.js +4 -8
  155. package/src/og/webgl/ProgramController.js +2 -2
  156. package/types/Clock.d.ts +1 -1
  157. package/types/Extent.d.ts +5 -5
  158. package/types/Globe.d.ts +15 -1
  159. package/types/ImageCanvas.d.ts +5 -0
  160. package/types/bv/Box.d.ts +1 -1
  161. package/types/bv/Sphere.d.ts +3 -3
  162. package/types/camera/Camera.d.ts +3 -2
  163. package/types/camera/PlanetCamera.d.ts +4 -4
  164. package/types/control/DrawingSwitcher.d.ts +13 -0
  165. package/types/control/EarthCoordinates.d.ts +1 -1
  166. package/types/control/Lighting.d.ts +8 -8
  167. package/types/control/drawing/DrawingControl.d.ts +14 -0
  168. package/types/control/drawing/LineStringDrawingScene.d.ts +5 -0
  169. package/types/control/drawing/PolygonDrawingScene.d.ts +99 -0
  170. package/types/control/index.d.ts +3 -1
  171. package/types/control/ruler/RulerScene.d.ts +0 -1
  172. package/types/control/selection/SelectionScene.d.ts +0 -1
  173. package/types/ellipsoid/Ellipsoid.d.ts +53 -64
  174. package/types/entity/Entity.d.ts +3 -2
  175. package/types/entity/GeoObject.d.ts +1 -2
  176. package/types/entity/Geometry.d.ts +5 -0
  177. package/types/entity/Polyline.d.ts +1 -1
  178. package/types/entity/Ray.d.ts +1 -0
  179. package/types/index.d.ts +1 -0
  180. package/types/layer/BaseGeoImage.d.ts +1 -1
  181. package/types/layer/CanvasTiles.d.ts +1 -1
  182. package/types/layer/Layer.d.ts +1 -1
  183. package/types/layer/Vector.d.ts +1 -0
  184. package/types/math/Vec3.d.ts +2 -0
  185. package/types/math.d.ts +7 -0
  186. package/types/renderer/Renderer.d.ts +7 -1
  187. package/types/scene/Axes.d.ts +0 -1
  188. package/types/scene/Planet.d.ts +27 -26
  189. package/types/scene/RenderNode.d.ts +2 -0
  190. package/types/scene/SkyBox.d.ts +0 -1
  191. package/types/segment/Segment.d.ts +3 -2
  192. package/types/segment/SegmentLonLat.d.ts +0 -1
  193. package/types/utils/GeoImageCreator.d.ts +1 -1
  194. package/types/utils/NormalMapCreator.d.ts +1 -1
  195. package/types/utils/VectorTileCreator.d.ts +2 -2
  196. package/types/utils/shared.d.ts +2 -0
  197. package/types/webgl/Handler.d.ts +6 -4
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/utils/NormalMapCreator
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { Lock } from "../Lock.js";
@@ -19,7 +15,7 @@ export class NormalMapCreator {
19
15
  this._maxTableSize = options.maxTableSize || 8;
20
16
 
21
17
  this._planet = planet;
22
- this._handler = planet.renderer.handler;
18
+ this._handler = null;
23
19
  this._verticesBufferArray = [];
24
20
  this._indexBufferArray = [];
25
21
  this._positionBuffer = null;
@@ -32,12 +28,15 @@ export class NormalMapCreator {
32
28
  this._queue = new QueueArray(1024);
33
29
 
34
30
  this._lock = new Lock();
35
-
36
- this._init();
37
31
  }
38
32
 
39
- _init() {
40
- var isWebkit = false; //('WebkitAppearance' in document.documentElement.style) && !/^((?!chrome).)*safari/i.test(navigator.userAgent);
33
+ init() {
34
+
35
+ this._maxTableSize = this._planet._maxGridSize || 8;
36
+
37
+ this._handler = this._planet.renderer.handler;
38
+
39
+ let isWebkit = false; //('WebkitAppearance' in document.documentElement.style) && !/^((?!chrome).)*safari/i.test(navigator.userAgent);
41
40
 
42
41
  /*==================================================================================
43
42
  * http://www.sunsetlakesoftware.com/2013/10/21/optimizing-gaussian-blurs-mobile-gpu
@@ -123,13 +122,13 @@ export class NormalMapCreator {
123
122
  this._normalMapVerticesTexture = this._handler.createEmptyTexture_l(this._width, this._height);
124
123
 
125
124
  //create vertices hasharray for different grid size segments from 2^4(16) to 2^7(128)
126
- for (var p = this._minTabelSize; p <= this._maxTableSize; p++) {
125
+ for (let p = this._minTabelSize; p <= this._maxTableSize; p++) {
127
126
  var gs = Math.pow(2, p);
128
127
  var gs2 = gs / 2;
129
128
  var vertices = new Float32Array((gs + 1) * (gs + 1) * 2);
130
129
 
131
- for (var i = 0; i <= gs; i++) {
132
- for (var j = 0; j <= gs; j++) {
130
+ for (let i = 0; i <= gs; i++) {
131
+ for (let j = 0; j <= gs; j++) {
133
132
  let ind = (i * (gs + 1) + j) * 2;
134
133
  vertices[ind] = -1 + j / gs2;
135
134
  vertices[ind + 1] = -1 + i / gs2;
@@ -193,7 +193,7 @@ const _programm = `
193
193
  this.z = z;
194
194
  };
195
195
 
196
- var lonLatToCartesian = function (lon, lat, heightFactor, res) {
196
+ var geodeticToCartesian = function (lon, lat, heightFactor, res) {
197
197
 
198
198
  let h = getHeightMSL(lon, lat) * heightFactor;
199
199
 
@@ -204,14 +204,14 @@ const _programm = `
204
204
 
205
205
  let N = A / Math.sqrt(1.0 - E2 * slt * slt);
206
206
  let nc = (N + h) * Math.cos(latrad);
207
-
208
- res.x = nc * Math.sin(lonrad);
209
- res.y = (N * (1.0 - E2) + h) * slt;
210
- res.z = nc * Math.cos(lonrad);
207
+
208
+ res.x = nc * Math.cos(lonrad);
209
+ res.y = nc * Math.sin(lonrad);
210
+ res.z = (N * (1 - E2) + h) * slt;
211
211
  };
212
212
 
213
- var lonLatToCartesianInverse = function (lon, lat, heightFactor, res){
214
- lonLatToCartesian(
213
+ var geodeticToCartesianInverse = function (lon, lat, heightFactor, res){
214
+ geodeticToCartesian(
215
215
  lon * INV_POLE_BY_180,
216
216
  INV_PI_BY_360 * Math.atan(Math.exp(lat * PI_BY_POLE)) - INV_PI_BY_180_HALF_PI,
217
217
  heightFactor,
@@ -279,9 +279,9 @@ const _programm = `
279
279
  let heightFactor = msg.data.params[13];
280
280
 
281
281
  if(msg.data.params[1] === 0.0){
282
- _projFunc = lonLatToCartesianInverse;
282
+ _projFunc = geodeticToCartesianInverse;
283
283
  }else{
284
- _projFunc = lonLatToCartesian;
284
+ _projFunc = geodeticToCartesian;
285
285
  }
286
286
 
287
287
  let maxFgs = Math.max(fgs, gridSize);
@@ -232,7 +232,7 @@ const _programm =
232
232
  normalMapVerticesHigh = new Float32Array(fileGridSize_one_x2 * 3);
233
233
  normalMapVerticesLow = new Float32Array(fileGridSize_one_x2 * 3);
234
234
 
235
- for (var k = 0; k < fileGridSize_one_x2; k++) {
235
+ for (let k = 0; k < fileGridSize_one_x2; k++) {
236
236
 
237
237
  var j = k % fileGridSize_one,
238
238
  i = ~~(k / fileGridSize_one);
@@ -502,7 +502,7 @@ const _programm =
502
502
  normalMapVerticesHigh.set(terrainVerticesHigh);
503
503
  normalMapVerticesLow.set(terrainVerticesLow);
504
504
 
505
- for(var k=0;k < gsgs; k++) {
505
+ for (let k = 0; k < gsgs; k++) {
506
506
 
507
507
  var j = k % gs,
508
508
  i = ~~(k / gs);
@@ -168,7 +168,7 @@ class TextureAtlas {
168
168
  this.clearCanvas();
169
169
 
170
170
  var newNodes = new Map();
171
- for (var i = 0; i < im.length; i++) {
171
+ for (let i = 0; i < im.length; i++) {
172
172
  this._completeNode(newNodes, this._btree.insert(im[i]));
173
173
  }
174
174
  this.nodes = null;
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/utils/VectorTileCreator
3
- */
4
-
5
1
  'use strict';
6
2
 
7
3
  import { doubleToTwoFloats2 } from '../math/coder.js';
@@ -14,19 +10,17 @@ let tempArr = new Float32Array(2);
14
10
  const MAX_FRAME_TIME = 25.0;
15
11
 
16
12
  export class VectorTileCreator {
17
-
18
13
  constructor(planet, width = 512, height = 512) {
19
-
20
14
  this._width = width;
21
15
  this._height = height;
22
- this._handler = planet.renderer.handler;
23
16
  this._planet = planet;
24
17
  this._framebuffer = null;
25
18
  this._queue = [];
26
- this._initialize();
27
19
  }
28
20
 
29
- _initialize() {
21
+ init() {
22
+
23
+ this._handler = this._planet.renderer.handler;
30
24
 
31
25
  //Line
32
26
  if (!this._handler.programs.vectorTileLineRasterization) {
@@ -45,7 +45,7 @@ function earcut(data, holeIndices, dim) {
45
45
  minX = maxX = data[0];
46
46
  minY = maxY = data[1];
47
47
 
48
- for (var i = dim; i < outerLen; i += dim) {
48
+ for (let i = dim; i < outerLen; i += dim) {
49
49
  x = data[i];
50
50
  y = data[i + 1];
51
51
  if (x < minX) minX = x;
@@ -610,7 +610,7 @@ function deviation(data, holeIndices, dim, triangles) {
610
610
 
611
611
  var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
612
612
  if (hasHoles) {
613
- for (var i = 0, len = holeIndices.length; i < len; i++) {
613
+ for (let i = 0, len = holeIndices.length; i < len; i++) {
614
614
  var start = holeIndices[i] * dim;
615
615
  var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
616
616
  polygonArea -= Math.abs(signedArea(data, start, end, dim));
@@ -618,7 +618,7 @@ function deviation(data, holeIndices, dim, triangles) {
618
618
  }
619
619
 
620
620
  var trianglesArea = 0;
621
- for (i = 0; i < triangles.length; i += 3) {
621
+ for (let i = 0; i < triangles.length; i += 3) {
622
622
  var a = triangles[i] * dim;
623
623
  var b = triangles[i + 1] * dim;
624
624
  var c = triangles[i + 2] * dim;
@@ -633,7 +633,7 @@ function deviation(data, holeIndices, dim, triangles) {
633
633
 
634
634
  function signedArea(data, start, end, dim) {
635
635
  var sum = 0;
636
- for (var i = start, j = end - dim; i < end; i += dim) {
636
+ for (let i = start, j = end - dim; i < end; i += dim) {
637
637
  sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
638
638
  j = i;
639
639
  }
@@ -646,9 +646,9 @@ function flatten(data) {
646
646
  result = { vertices: [], holes: [], dimensions: dim },
647
647
  holeIndex = 0;
648
648
 
649
- for (var i = 0; i < data.length; i++) {
650
- for (var j = 0; j < data[i].length; j++) {
651
- for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
649
+ for (let i = 0; i < data.length; i++) {
650
+ for (let j = 0; j < data[i].length; j++) {
651
+ for (let d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
652
652
  }
653
653
  if (i > 0) {
654
654
  holeIndex += data[i - 1].length;
@@ -658,4 +658,4 @@ function flatten(data) {
658
658
  return result;
659
659
  }
660
660
 
661
- export { earcut, flatten };
661
+ export { earcut, flatten };
@@ -152,7 +152,7 @@ export function parseHTML(htmlStr) {
152
152
  var p = document.createElement("div");
153
153
  p.innerHTML = htmlStr;
154
154
  var domArr = [];
155
- for (var i = 0; i < p.childNodes.length; i++) {
155
+ for (let i = 0; i < p.childNodes.length; i++) {
156
156
  domArr.push(p.childNodes[i]);
157
157
  p.removeChild(p.childNodes[i]);
158
158
  }
@@ -419,7 +419,7 @@ export function xmlToJson(xml) {
419
419
  // do attributes
420
420
  if (xml.attributes.length > 0) {
421
421
  obj["@attributes"] = {};
422
- for (var j = 0; j < xml.attributes.length; j++) {
422
+ for (let j = 0; j < xml.attributes.length; j++) {
423
423
  var attribute = xml.attributes.item(j);
424
424
  obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
425
425
  }
@@ -431,7 +431,7 @@ export function xmlToJson(xml) {
431
431
 
432
432
  // do children
433
433
  if (xml.hasChildNodes()) {
434
- for (var i = 0; i < xml.childNodes.length; i++) {
434
+ for (let i = 0; i < xml.childNodes.length; i++) {
435
435
  var item = xml.childNodes.item(i);
436
436
  var nodeName = item.nodeName;
437
437
  if (typeof obj[nodeName] === "undefined") {
@@ -511,12 +511,12 @@ export function base64toBlob(base64Data, contentType) {
511
511
  var slicesCount = Math.ceil(bytesLength / sliceSize);
512
512
  var byteArrays = new Array(slicesCount);
513
513
 
514
- for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
514
+ for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
515
515
  var begin = sliceIndex * sliceSize;
516
516
  var end = Math.min(begin + sliceSize, bytesLength);
517
517
 
518
518
  var bytes = new Array(end - begin);
519
- for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
519
+ for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
520
520
  bytes[i] = byteCharacters[offset].charCodeAt(0);
521
521
  }
522
522
  byteArrays[sliceIndex] = new Uint8Array(bytes);
@@ -751,7 +751,7 @@ export function concatArrays(a = [], b) {
751
751
  if (ArrayBuffer.isView(a)) {
752
752
  return concatTypedArrays(a, b);
753
753
  } else {
754
- for (var i = 0; i < b.length; i++) {
754
+ for (let i = 0; i < b.length; i++) {
755
755
  a.push(b[i]);
756
756
  }
757
757
  return a;
@@ -858,8 +858,8 @@ export function getMatrixSubArray(sourceArr, gridSize, i0, j0, size) {
858
858
  var res = new Float64Array(size_1 * size_1 * 3);
859
859
 
860
860
  var vInd = 0;
861
- for (var i = i0; i < i0size; i++) {
862
- for (var j = j0; j < j0size; j++) {
861
+ for (let i = i0; i < i0size; i++) {
862
+ for (let j = j0; j < j0size; j++) {
863
863
  var ind = 3 * (i * (gridSize + 1) + j);
864
864
 
865
865
  res[vInd++] = sourceArr[ind];
@@ -902,8 +902,8 @@ export function getMatrixSubArrayBoundsExt(
902
902
  gridSize += 1;
903
903
  var vInd = 0,
904
904
  nInd = 0;
905
- for (var i = i0; i < i0size; i++) {
906
- for (var j = j0; j < j0size; j++) {
905
+ for (let i = i0; i < i0size; i++) {
906
+ for (let j = j0; j < j0size; j++) {
907
907
  let indBy3 = i * gridSize + j,
908
908
  ind = 3 * indBy3;
909
909
 
@@ -956,6 +956,7 @@ export async function loadImage(url) {
956
956
  resolve(image);
957
957
  });
958
958
  image.src = url;
959
+ image.crossOrigin = ""
959
960
  return image;
960
961
  });
961
962
  }
@@ -967,4 +968,22 @@ export async function loadImage(url) {
967
968
  */
968
969
  export function isImageLoaded(image) {
969
970
  return image.complete && image.naturalHeight !== 0;
970
- }
971
+ }
972
+
973
+ export function distanceFormat(v) {
974
+ if (v > 1000) {
975
+ return `${(v / 1000).toFixed(1)} km`;
976
+ } else if (v > 9) {
977
+ return `${Math.round(v)} m`;
978
+ } else {
979
+ return `${v.toFixed(1)} m`;
980
+ }
981
+ }
982
+
983
+ export function getUrlParam(paramName) {
984
+ let urlParams = new URLSearchParams(location.search);
985
+ let param = urlParams.get(paramName);
986
+ if (param) {
987
+ return Number(param);
988
+ }
989
+ }
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/webgl/Framebuffer
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { ImageCanvas } from "../ImageCanvas.js";
@@ -125,7 +121,7 @@ export class Framebuffer {
125
121
  destroy() {
126
122
  var gl = this.handler.gl;
127
123
 
128
- for (var i = 0; i < this.textures.length; i++) {
124
+ for (let i = 0; i < this.textures.length; i++) {
129
125
  gl.deleteTexture(this.textures[i]);
130
126
  }
131
127
  this.textures = new Array(this._size);
@@ -152,7 +148,7 @@ export class Framebuffer {
152
148
 
153
149
  if (!this._isBare) {
154
150
  let attachmentArr = [];
155
- for (var i = 0; i < this.textures.length; i++) {
151
+ for (let i = 0; i < this.textures.length; i++) {
156
152
  let ti = this.textures[i] || this.handler.createEmptyTexture2DExt(this._width, this._height, this._filter, this._internalFormatArr[i], this._formatArr[i], this._typeArr[i]);
157
153
 
158
154
  let att_i = gl[this._attachmentArr[i]];
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/webgl/Handler
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { Clock } from "../Clock.js";
@@ -10,7 +6,7 @@ import { Events } from "../Events.js";
10
6
  import { ImageCanvas } from "../ImageCanvas.js";
11
7
  import { Vec2 } from "../math/Vec2.js";
12
8
  import { Stack } from "../Stack.js";
13
- import { isEmpty } from "../utils/shared.js";
9
+ import { getUrlParam, isEmpty } from "../utils/shared.js";
14
10
  import { ProgramController } from "./ProgramController.js";
15
11
 
16
12
  const vendorPrefixes = ["", "WEBKIT_", "MOZ_"];
@@ -23,7 +19,7 @@ const MAX_LEVELS = 2;
23
19
  /**
24
20
  * A WebGL handler for accessing low-level WebGL capabilities.
25
21
  * @class
26
- * @param {string} id - Canvas element id that WebGL handler assing with. If it's null
22
+ * @param {string | HTMLCanvasElement} canvasTarget - Canvas element target.
27
23
  * or undefined creates hidden canvas and handler bacomes hidden.
28
24
  * @param {Object} [params] - Handler options:
29
25
  * @param {number} [params.anisotropy] - Anisotropy filter degree. 8 is default.
@@ -32,7 +28,7 @@ const MAX_LEVELS = 2;
32
28
  * @param {Array.<string>} [params.extensions] - Additional WebGL extension list. Available by default: EXT_texture_filter_anisotropic.
33
29
  */
34
30
  class Handler {
35
- constructor(id, params = {}) {
31
+ constructor(canvasTarget, params = {}) {
36
32
 
37
33
  this.events = new Events(["visibilitychange", "resize"]);
38
34
  /**
@@ -94,7 +90,7 @@ class Handler {
94
90
  this._params.anisotropy = this._params.anisotropy || 4;
95
91
  this._params.width = this._params.width || 256;
96
92
  this._params.height = this._params.height || 256;
97
- this._params.pixelRatio = this._params.pixelRatio || 1.0;
93
+ this._params.pixelRatio = getUrlParam('og_dpi') || this._params.pixelRatio || 1.0;
98
94
  this._params.context = this._params.context || {};
99
95
  this._params.extensions = this._params.extensions || [];
100
96
  this._oneByHeight = 1.0 / (this._params.height * this._params.pixelRatio);
@@ -109,11 +105,11 @@ class Handler {
109
105
  this.extensions = {};
110
106
 
111
107
  /**
112
- * HTML Canvas object id.
108
+ * HTML Canvas target.
113
109
  * @private
114
110
  * @type {Object}
115
111
  */
116
- this._id = id;
112
+ this._canvasTarget = canvasTarget;
117
113
 
118
114
  this._lastAnimationFrameTime = 0;
119
115
 
@@ -144,11 +140,31 @@ class Handler {
144
140
 
145
141
  this.ONCANVASRESIZE = null;
146
142
 
143
+ this._createCanvas();
144
+
147
145
  if (params.autoActivate || isEmpty(params.autoActivate)) {
148
146
  this.initialize();
149
147
  }
150
148
  }
151
149
 
150
+ isInitialized() {
151
+ return this._initialized;
152
+ }
153
+
154
+ _createCanvas() {
155
+ if (this._canvasTarget) {
156
+ if (this._canvasTarget instanceof HTMLElement) {
157
+ this.canvas = this._canvasTarget;
158
+ } else {
159
+ this.canvas = document.getElementById(this._canvasTarget) || document.querySelector(this._canvasTarget);
160
+ }
161
+ } else {
162
+ this.canvas = document.createElement("canvas");
163
+ this.canvas.width = this._params.width;
164
+ this.canvas.height = this._params.height;
165
+ }
166
+ }
167
+
152
168
  /**
153
169
  * The return value is null if the extension is not supported, or an extension object otherwise.
154
170
  * @param {Object} gl - WebGl context pointer.
@@ -611,17 +627,12 @@ class Handler {
611
627
  * @public
612
628
  */
613
629
  initialize() {
614
- if (this._id) {
615
- this.canvas = document.getElementById(this._id);
616
- } else {
617
- this.canvas = document.createElement("canvas");
618
- this.canvas.width = this._params.width;
619
- this.canvas.height = this._params.height;
620
- }
630
+
631
+ if (this._initialized) return;
621
632
 
622
633
  this.gl = Handler.getContext(this.canvas, this._params.context);
623
634
 
624
- if(this.gl) {
635
+ if (this.gl) {
625
636
  this._initialized = true;
626
637
 
627
638
  /** Sets default extensions */
@@ -1017,6 +1028,9 @@ class Handler {
1017
1028
 
1018
1029
  this.stop();
1019
1030
 
1031
+ //
1032
+ // Dispose shaders
1033
+ //
1020
1034
  for (let p in this.programs) {
1021
1035
  this.removeProgram(p);
1022
1036
  }
@@ -1030,6 +1044,9 @@ class Handler {
1030
1044
  this.framebufferStack = null;
1031
1045
  this.framebufferStack = new Stack();
1032
1046
 
1047
+ //
1048
+ // Destroy canvas
1049
+ //
1033
1050
  if (this.canvas.parentNode) {
1034
1051
  this.canvas.parentNode.removeChild(this.canvas);
1035
1052
  }
@@ -1037,6 +1054,9 @@ class Handler {
1037
1054
  this.canvas.height = 1;
1038
1055
  this.canvas = null;
1039
1056
 
1057
+ //
1058
+ // Clear attrib pointers
1059
+ //
1040
1060
  let numAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
1041
1061
  let tmp = gl.createBuffer();
1042
1062
  gl.bindBuffer(gl.ARRAY_BUFFER, tmp);
@@ -1047,13 +1067,19 @@ class Handler {
1047
1067
  }
1048
1068
  gl.deleteBuffer(tmp);
1049
1069
 
1050
- let numTextureUnits = gl.getParameter(gl.MAX_TEXTlURE_IMAGE_UNITS);
1070
+ //
1071
+ // Clear all possible textures
1072
+ //
1073
+ let numTextureUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
1051
1074
  for (let ii = 0; ii < numTextureUnits; ++ii) {
1052
1075
  gl.activeTexture(gl.TEXTURE0 + ii);
1053
1076
  gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
1054
1077
  gl.bindTexture(gl.TEXTURE_2D, null);
1055
1078
  }
1056
1079
 
1080
+ //
1081
+ // Hard reset
1082
+ //
1057
1083
  gl.activeTexture(gl.TEXTURE0);
1058
1084
  gl.useProgram(null);
1059
1085
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
@@ -1112,7 +1138,7 @@ class Handler {
1112
1138
  // const data = new DataView(xhr.response);
1113
1139
  // const array =
1114
1140
  // new Float32Array(data.byteLength / Float32Array.BYTES_PER_ELEMENT);
1115
- // for (var i = 0; i < array.length; ++i) {
1141
+ // for (let i = 0; i < array.length; ++i) {
1116
1142
  // array[i] = data.getFloat32(i * Float32Array.BYTES_PER_ELEMENT, true);
1117
1143
  // }
1118
1144
  // callback(array);
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/webgl/Multisample
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  /**
@@ -92,7 +88,7 @@ export class Multisample {
92
88
  destroy() {
93
89
  var gl = this.handler.gl;
94
90
 
95
- for (var i = 0; i < this.renderbuffers.length; i++) {
91
+ for (let i = 0; i < this.renderbuffers.length; i++) {
96
92
  gl.deleteRenderbuffer(this.renderbuffers[i]);
97
93
  }
98
94
  this.renderbuffers = new Array(this._size);
@@ -120,7 +116,7 @@ export class Multisample {
120
116
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._fbo);
121
117
 
122
118
  let colorAttachments = [];
123
- for (var i = 0; i < this.renderbuffers.length; i++) {
119
+ for (let i = 0; i < this.renderbuffers.length; i++) {
124
120
  let rb = gl.createRenderbuffer();
125
121
  gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
126
122
 
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/webgl/Program
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { cons } from "../cons.js";
@@ -158,7 +154,7 @@ class Program {
158
154
  */
159
155
  set(material) {
160
156
  this._textureID = 0;
161
- for (var i in material) {
157
+ for (let i in material) {
162
158
  this._variables[i].value = material[i];
163
159
  this._variables[i]._callback(this, this._variables[i]);
164
160
  }
@@ -171,7 +167,7 @@ class Program {
171
167
  apply() {
172
168
  this._textureID = 0;
173
169
  var v = this._variables;
174
- for (var i in v) {
170
+ for (let i in v) {
175
171
  v[i]._callback(this, v[i]);
176
172
  }
177
173
  }
@@ -322,7 +318,7 @@ class Program {
322
318
 
323
319
  this.use();
324
320
 
325
- for (var a in this._attributes) {
321
+ for (let a in this._attributes) {
326
322
  //this.attributes[a]._name = a;
327
323
  this._variables[a] = this._attributes[a];
328
324
 
@@ -375,7 +371,7 @@ class Program {
375
371
  this.attributes[a] = this._p[a];
376
372
  }
377
373
 
378
- for (var u in this._uniforms) {
374
+ for (let u in this._uniforms) {
379
375
  //this.uniforms[u]._name = u;
380
376
 
381
377
  if (typeof this._uniforms[u].type === "string") {
@@ -1,8 +1,8 @@
1
+ "use strict";
2
+
1
3
  import { Handler } from "./Handler.js";
2
4
  import { Program } from "./Program.js";
3
5
 
4
- "use strict";
5
-
6
6
  /**
7
7
  * This is shader program controller that used by hadler object to access the shader
8
8
  * program capabilities, like switching program during the rendering.
package/types/Clock.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * @param {number} [params.startDate=0.0] - Julian start date.
6
6
  * @param {number} [params.endDate=0.0] - Julian end date.
7
7
  * @param {number} [params.currentDate] - Julian current date. Default: current date.
8
- * @param {number} [params.multiplier=1.0] - Time speed multiolier.
8
+ * @param {number} [params.multiplier=1.0] - Time speed multiplier.
9
9
  */
10
10
  export class Clock {
11
11
  static set _staticCounter(arg: any);
package/types/Extent.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Represents geographical coordinates extent.
3
3
  * @class
4
- * @param {LonLat} [sw] - South West extent corner coordiantes.
5
- * @param {LonLat} [ne] - North East extent corner coordiantes.
4
+ * @param {LonLat} [sw] - South West extent corner coordinates.
5
+ * @param {LonLat} [ne] - North East extent corner coordinates.
6
6
  */
7
7
  export class Extent {
8
8
  /**
@@ -35,7 +35,7 @@ export class Extent {
35
35
  */
36
36
  static createByCoordinates(arr: Array<LonLat>): Extent;
37
37
  /**
38
- * Creates bound extent instance by coordinate array.
38
+ * Creates bound extent instance by coordinates array.
39
39
  * @static
40
40
  * @param {Array.<Array<number>>} arr - Coordinate array. (exactly 2 entries)
41
41
  * @return {Extent} Extent object.
@@ -53,8 +53,8 @@ export class Extent {
53
53
  */
54
54
  static fromTile(x: number, y: number, z: number, width: number, height: number): Extent;
55
55
  /**
56
- * @param {LonLat} [sw] - South West extent corner coordiantes.
57
- * @param {LonLat} [ne] - North East extent corner coordiantes.
56
+ * @param {LonLat} [sw] - South West extent corner coordinates.
57
+ * @param {LonLat} [ne] - North East extent corner coordinates.
58
58
  */
59
59
  constructor(sw?: LonLat, ne?: LonLat);
60
60
  /**
package/types/Globe.d.ts CHANGED
@@ -45,16 +45,26 @@
45
45
  * @param {Number} [options.quadTreeStrategyPrototype] - Prototype of quadTree. QuadTreeStrategy for Earth is default.
46
46
  * @param {Number} [options.msaa] - MSAA antialiasing parameter: 2,4,8,16. Default is 4.
47
47
  * @param {Number} [options.dpi] - Device pixel ratio. Default is current screen DPI.
48
+ * @param {Boolean} [options.atmosphereEnabled] - Enables atmosphere effect.
48
49
  */
49
50
  export class Globe {
51
+ static set __staticCounter(arg: any);
52
+ static get __staticCounter(): any;
50
53
  static set _staticCounter(arg: any);
51
54
  static get _staticCounter(): any;
52
55
  /**
53
56
  * @param {*} options
54
57
  */
55
58
  constructor(options: any);
59
+ $target: any;
60
+ _instanceID: string;
56
61
  _canvas: HTMLCanvasElement;
57
- div: any;
62
+ /**
63
+ * Dom element where WebGL canvas creates
64
+ * @public
65
+ * @type {Element}
66
+ */
67
+ public $inner: Element;
58
68
  /**
59
69
  * Interface for the renderer context(events, input states, renderer nodes etc.)
60
70
  * @public
@@ -78,6 +88,7 @@ export class Globe {
78
88
  _opacityCounter: number;
79
89
  _fadeHandler: any;
80
90
  _stopHandler: any;
91
+ start(): void;
81
92
  /**
82
93
  * Starts screen brightness fading in effect by the duration time.
83
94
  * @public
@@ -89,6 +100,9 @@ export class Globe {
89
100
  * @param {number} duration - Fadeout duration time.
90
101
  */
91
102
  public fadeOut(): void;
103
+ attachTo(target: any): void;
104
+ detach(): void;
105
+ destroy(): void;
92
106
  }
93
107
  import { Renderer } from "./renderer/Renderer.js";
94
108
  import { Planet } from "./scene/Planet.js";