@openglobus/og 0.11.2 → 0.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/package.json +13 -13
  2. package/src/og/Clock.js +10 -10
  3. package/src/og/Events.js +8 -6
  4. package/src/og/Extent.js +82 -41
  5. package/src/og/Globe.js +25 -13
  6. package/src/og/ImageCanvas.js +22 -16
  7. package/src/og/LonLat.js +16 -13
  8. package/src/og/Popup.js +21 -14
  9. package/src/og/QueueArray.js +6 -2
  10. package/src/og/Rectangle.js +11 -6
  11. package/src/og/Stack.js +5 -2
  12. package/src/og/ajax.js +21 -33
  13. package/src/og/astro/astro.js +5 -5
  14. package/src/og/astro/earth.js +22 -16
  15. package/src/og/astro/jd.js +23 -18
  16. package/src/og/astro/orbit.js +13 -11
  17. package/src/og/astro/rotation.js +17 -8
  18. package/src/og/bv/Box.js +7 -3
  19. package/src/og/bv/Sphere.js +14 -11
  20. package/src/og/camera/Camera.js +51 -54
  21. package/src/og/camera/Frustum.js +29 -18
  22. package/src/og/camera/PlanetCamera.js +32 -23
  23. package/src/og/control/CompassButton.js +5 -1
  24. package/src/og/control/Control.js +12 -10
  25. package/src/og/control/DebugInfo.js +4 -1
  26. package/src/og/control/EarthCoordinates.js +54 -33
  27. package/src/og/control/KeyboardNavigation.js +10 -10
  28. package/src/og/control/LayerSwitcher.js +22 -21
  29. package/src/og/control/Lighting.js +34 -3
  30. package/src/og/control/MouseNavigation.js +1 -1
  31. package/src/og/control/ScaleControl.js +1 -1
  32. package/src/og/control/SegmentBoundVisualization.js +6 -7
  33. package/src/og/control/ShowFps.js +13 -8
  34. package/src/og/control/SimpleNavigation.js +6 -8
  35. package/src/og/control/Sun.js +25 -15
  36. package/src/og/control/ToggleWireframe.js +4 -4
  37. package/src/og/control/TouchNavigation.js +44 -33
  38. package/src/og/control/ZoomControl.js +41 -25
  39. package/src/og/ellipsoid/Ellipsoid.js +162 -66
  40. package/src/og/ellipsoid/wgs84.js +4 -4
  41. package/src/og/entity/BaseBillboard.js +100 -56
  42. package/src/og/entity/Billboard.js +14 -10
  43. package/src/og/entity/BillboardHandler.js +317 -60
  44. package/src/og/entity/Entity.js +100 -68
  45. package/src/og/entity/EntityCollection.js +70 -47
  46. package/src/og/entity/GeoObject.js +228 -0
  47. package/src/og/entity/GeoObjectHandler.js +910 -0
  48. package/src/og/entity/Geometry.js +27 -24
  49. package/src/og/entity/GeometryHandler.js +596 -124
  50. package/src/og/entity/Label.js +80 -49
  51. package/src/og/entity/LabelHandler.js +45 -244
  52. package/src/og/entity/LabelWorker.js +218 -0
  53. package/src/og/entity/Object3d.js +504 -0
  54. package/src/og/entity/PointCloud.js +80 -32
  55. package/src/og/entity/PointCloudHandler.js +8 -8
  56. package/src/og/entity/Polyline.js +16 -16
  57. package/src/og/entity/Ray.js +60 -27
  58. package/src/og/entity/Strip.js +77 -48
  59. package/src/og/entity/StripHandler.js +26 -26
  60. package/src/og/entity/index.js +8 -16
  61. package/src/og/layer/BaseGeoImage.js +54 -23
  62. package/src/og/layer/CanvasTiles.js +24 -24
  63. package/src/og/layer/GeoImage.js +9 -9
  64. package/src/og/layer/GeoVideo.js +3 -3
  65. package/src/og/layer/KML.js +63 -37
  66. package/src/og/layer/Layer.js +44 -21
  67. package/src/og/layer/Material.js +23 -20
  68. package/src/og/layer/Vector.js +114 -68
  69. package/src/og/layer/WMS.js +34 -17
  70. package/src/og/layer/XYZ.js +48 -46
  71. package/src/og/light/LightSource.js +46 -39
  72. package/src/og/math/Mat3.js +34 -22
  73. package/src/og/math/Mat4.js +603 -459
  74. package/src/og/math/Plane.js +21 -20
  75. package/src/og/math/Quat.js +182 -139
  76. package/src/og/math/Ray.js +38 -33
  77. package/src/og/math/Vec2.js +85 -75
  78. package/src/og/math/Vec3.js +142 -112
  79. package/src/og/math/Vec4.js +27 -31
  80. package/src/og/math/coder.js +10 -10
  81. package/src/og/math.js +12 -12
  82. package/src/og/proj/EPSG3857.js +4 -4
  83. package/src/og/proj/EPSG4326.js +4 -4
  84. package/src/og/proj/Proj.js +4 -6
  85. package/src/og/quadTree/Node.js +8 -8
  86. package/src/og/renderer/Renderer.js +59 -52
  87. package/src/og/renderer/RendererEvents.js +50 -27
  88. package/src/og/scene/BaseNode.js +7 -8
  89. package/src/og/scene/Planet.js +102 -103
  90. package/src/og/scene/RenderNode.js +28 -21
  91. package/src/og/segment/Segment.js +26 -21
  92. package/src/og/segment/SegmentLonLat.js +5 -5
  93. package/src/og/shaders/drawnode.js +135 -142
  94. package/src/og/shaders/geoObject.js +211 -0
  95. package/src/og/shaders/pointCloud.js +41 -41
  96. package/src/og/shaders/shape.js +12 -18
  97. package/src/og/shaders/skybox.js +36 -36
  98. package/src/og/shaders/toneMapping.js +1 -0
  99. package/src/og/shapes/BaseShape.js +126 -54
  100. package/src/og/shapes/Icosphere.js +29 -14
  101. package/src/og/shapes/Sphere.js +12 -15
  102. package/src/og/terrain/BilTerrain.js +1 -0
  103. package/src/og/terrain/EmptyTerrain.js +2 -2
  104. package/src/og/terrain/GlobusTerrain.js +9 -9
  105. package/src/og/utils/FontAtlas.js +6 -2
  106. package/src/og/utils/TextureAtlas.js +22 -24
  107. package/src/og/utils/VectorTileCreator.js +1 -3
  108. package/src/og/utils/shared.js +16 -16
  109. package/src/og/webgl/Framebuffer.js +88 -40
  110. package/src/og/webgl/Handler.js +243 -169
  111. package/src/og/webgl/Multisample.js +47 -19
  112. package/src/og/webgl/Program.js +79 -34
  113. package/src/og/webgl/ProgramController.js +17 -13
  114. package/src/og/webgl/callbacks.js +8 -8
  115. package/src/og/inherits.js +0 -8
  116. package/src/og/utils/polylabel.js +0 -176
  117. package/types/Clock.d.ts +0 -90
  118. package/types/Deferred.d.ts +0 -6
  119. package/types/Events.d.ts +0 -73
  120. package/types/Extent.d.ts +0 -166
  121. package/types/Globe.d.ts +0 -75
  122. package/types/ImageCanvas.d.ts +0 -121
  123. package/types/Lock.d.ts +0 -12
  124. package/types/LonLat.d.ts +0 -108
  125. package/types/Popup.d.ts +0 -38
  126. package/types/QueueArray.d.ts +0 -15
  127. package/types/Rectangle.d.ts +0 -74
  128. package/types/Stack.d.ts +0 -15
  129. package/types/ajax.d.ts +0 -24
  130. package/types/arial.d.ts +0 -48
  131. package/types/astro/astro.d.ts +0 -38
  132. package/types/astro/earth.d.ts +0 -6
  133. package/types/astro/jd.d.ts +0 -254
  134. package/types/bv/Box.d.ts +0 -25
  135. package/types/bv/Sphere.d.ts +0 -38
  136. package/types/bv/index.d.ts +0 -3
  137. package/types/camera/Camera.d.ts +0 -303
  138. package/types/camera/Frustum.d.ts +0 -129
  139. package/types/camera/PlanetCamera.d.ts +0 -223
  140. package/types/camera/index.d.ts +0 -3
  141. package/types/cons.d.ts +0 -40
  142. package/types/control/CompassButton.d.ts +0 -18
  143. package/types/control/Control.d.ts +0 -101
  144. package/types/control/DebugInfo.d.ts +0 -16
  145. package/types/control/EarthCoordinates.d.ts +0 -47
  146. package/types/control/EarthNavigation.d.ts +0 -42
  147. package/types/control/GeoImageDragControl.d.ts +0 -6
  148. package/types/control/KeyboardNavigation.d.ts +0 -22
  149. package/types/control/LayerSwitcher.d.ts +0 -23
  150. package/types/control/Lighting.d.ts +0 -16
  151. package/types/control/MouseNavigation.d.ts +0 -51
  152. package/types/control/ScaleControl.d.ts +0 -22
  153. package/types/control/ShowFps.d.ts +0 -12
  154. package/types/control/SimpleNavigation.d.ts +0 -28
  155. package/types/control/Sun.d.ts +0 -52
  156. package/types/control/ToggleWireframe.d.ts +0 -12
  157. package/types/control/TouchNavigation.d.ts +0 -50
  158. package/types/control/ZoomControl.d.ts +0 -28
  159. package/types/control/index.d.ts +0 -17
  160. package/types/ellipsoid/Ellipsoid.d.ts +0 -142
  161. package/types/ellipsoid/index.d.ts +0 -3
  162. package/types/ellipsoid/wgs84.d.ts +0 -5
  163. package/types/entity/BaseBillboard.d.ts +0 -208
  164. package/types/entity/Billboard.d.ts +0 -94
  165. package/types/entity/BillboardHandler.d.ts +0 -74
  166. package/types/entity/Entity.d.ts +0 -331
  167. package/types/entity/EntityCollection.d.ts +0 -303
  168. package/types/entity/Geometry.d.ts +0 -73
  169. package/types/entity/GeometryHandler.d.ts +0 -76
  170. package/types/entity/Label.d.ts +0 -194
  171. package/types/entity/LabelHandler.d.ts +0 -24
  172. package/types/entity/PointCloud.d.ts +0 -174
  173. package/types/entity/PointCloudHandler.d.ts +0 -38
  174. package/types/entity/Polyline.d.ts +0 -304
  175. package/types/entity/PolylineHandler.d.ts +0 -18
  176. package/types/entity/Ray.d.ts +0 -123
  177. package/types/entity/RayHandler.d.ts +0 -67
  178. package/types/entity/ShapeHandler.d.ts +0 -22
  179. package/types/entity/Strip.d.ts +0 -118
  180. package/types/entity/StripHandler.d.ts +0 -38
  181. package/types/entity/index.d.ts +0 -8
  182. package/types/index.core.d.ts +0 -65
  183. package/types/index.d.ts +0 -45
  184. package/types/index.webgl.d.ts +0 -7
  185. package/types/inherits.d.ts +0 -4
  186. package/types/input/KeyboardHandler.d.ts +0 -10
  187. package/types/input/MouseHandler.d.ts +0 -5
  188. package/types/input/TouchHandler.d.ts +0 -5
  189. package/types/input/input.d.ts +0 -34
  190. package/types/layer/BaseGeoImage.d.ts +0 -107
  191. package/types/layer/CanvasTiles.d.ts +0 -75
  192. package/types/layer/GeoImage.d.ts +0 -65
  193. package/types/layer/GeoTexture2d.d.ts +0 -8
  194. package/types/layer/GeoVideo.d.ts +0 -80
  195. package/types/layer/KML.d.ts +0 -58
  196. package/types/layer/Layer.d.ts +0 -321
  197. package/types/layer/Material.d.ts +0 -48
  198. package/types/layer/Vector.d.ts +0 -228
  199. package/types/layer/WMS.d.ts +0 -66
  200. package/types/layer/XYZ.d.ts +0 -130
  201. package/types/layer/index.d.ts +0 -10
  202. package/types/light/LightSource.d.ts +0 -177
  203. package/types/math/Line2.d.ts +0 -11
  204. package/types/math/Line3.d.ts +0 -10
  205. package/types/math/Mat3.d.ts +0 -63
  206. package/types/math/Mat4.d.ts +0 -173
  207. package/types/math/Plane.d.ts +0 -17
  208. package/types/math/Quat.d.ts +0 -376
  209. package/types/math/Ray.d.ts +0 -81
  210. package/types/math/Vec2.d.ts +0 -308
  211. package/types/math/Vec3.d.ts +0 -459
  212. package/types/math/Vec4.d.ts +0 -161
  213. package/types/math/coder.d.ts +0 -42
  214. package/types/math/index.d.ts +0 -11
  215. package/types/math.d.ts +0 -261
  216. package/types/mercator.d.ts +0 -92
  217. package/types/proj/EPSG3857.d.ts +0 -5
  218. package/types/proj/EPSG4326.d.ts +0 -5
  219. package/types/proj/Proj.d.ts +0 -42
  220. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  221. package/types/quadTree/Node.d.ts +0 -61
  222. package/types/quadTree/quadTree.d.ts +0 -40
  223. package/types/renderer/Renderer.d.ts +0 -296
  224. package/types/renderer/RendererEvents.d.ts +0 -230
  225. package/types/res/images.d.ts +0 -3
  226. package/types/scene/Axes.d.ts +0 -11
  227. package/types/scene/BaseNode.d.ts +0 -60
  228. package/types/scene/Planet.d.ts +0 -574
  229. package/types/scene/RenderNode.d.ts +0 -143
  230. package/types/scene/SkyBox.d.ts +0 -10
  231. package/types/scene/index.d.ts +0 -4
  232. package/types/segment/Segment.d.ts +0 -271
  233. package/types/segment/SegmentLonLat.d.ts +0 -62
  234. package/types/segment/segmentHelper.d.ts +0 -13
  235. package/types/shaders/billboard.d.ts +0 -3
  236. package/types/shaders/depth.d.ts +0 -2
  237. package/types/shaders/drawnode.d.ts +0 -7
  238. package/types/shaders/label.d.ts +0 -4
  239. package/types/shaders/pointCloud.d.ts +0 -2
  240. package/types/shaders/polyline.d.ts +0 -3
  241. package/types/shaders/ray.d.ts +0 -2
  242. package/types/shaders/screenFrame.d.ts +0 -2
  243. package/types/shaders/shape.d.ts +0 -4
  244. package/types/shaders/skybox.d.ts +0 -2
  245. package/types/shaders/toneMapping.d.ts +0 -2
  246. package/types/shapes/BaseShape.d.ts +0 -247
  247. package/types/shapes/Sphere.d.ts +0 -41
  248. package/types/terrain/BilTerrain.d.ts +0 -8
  249. package/types/terrain/EmptyTerrain.d.ts +0 -72
  250. package/types/terrain/Geoid.d.ts +0 -26
  251. package/types/terrain/GlobusTerrain.d.ts +0 -153
  252. package/types/terrain/MapboxTerrain.d.ts +0 -8
  253. package/types/terrain/index.d.ts +0 -5
  254. package/types/utils/FontAtlas.d.ts +0 -14
  255. package/types/utils/GeoImageCreator.d.ts +0 -30
  256. package/types/utils/ImagesCacheManager.d.ts +0 -10
  257. package/types/utils/Loader.d.ts +0 -25
  258. package/types/utils/NormalMapCreator.d.ts +0 -39
  259. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  260. package/types/utils/TerrainWorker.d.ts +0 -9
  261. package/types/utils/TextureAtlas.d.ts +0 -111
  262. package/types/utils/VectorTileCreator.d.ts +0 -16
  263. package/types/utils/colorTable.d.ts +0 -143
  264. package/types/utils/earcut.d.ts +0 -6
  265. package/types/utils/shared.d.ts +0 -230
  266. package/types/webgl/Framebuffer.d.ts +0 -135
  267. package/types/webgl/Handler.d.ts +0 -372
  268. package/types/webgl/Multisample.d.ts +0 -89
  269. package/types/webgl/Program.d.ts +0 -155
  270. package/types/webgl/ProgramController.d.ts +0 -84
  271. package/types/webgl/callbacks.d.ts +0 -1
  272. package/types/webgl/index.d.ts +0 -6
  273. package/types/webgl/types.d.ts +0 -2
package/src/og/Popup.js CHANGED
@@ -1,11 +1,10 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- import { Events } from './Events.js';
4
- import { Vec3 } from './math/Vec3.js';
5
- import { getHTML, parseHTML, createLonLat } from './utils/shared.js';
3
+ import { Events } from "./Events.js";
4
+ import { Vec3 } from "./math/Vec3.js";
5
+ import { getHTML, parseHTML, createLonLat } from "./utils/shared.js";
6
6
 
7
- const TEMPLATE =
8
- `<div class="og-popup {className}">
7
+ const TEMPLATE = `<div class="og-popup {className}">
9
8
  <div class="og-popup-content-wrapper">
10
9
  <div class="og-popup-content"></div>
11
10
  </div>
@@ -20,8 +19,11 @@ const TEMPLATE =
20
19
  </div>`;
21
20
 
22
21
  class Popup {
22
+ /**
23
+ *
24
+ * @param {*} options
25
+ */
23
26
  constructor(options) {
24
-
25
27
  this._id = Popup._staticCounter++;
26
28
 
27
29
  this.events = new Events(["open", "close"]);
@@ -72,7 +74,13 @@ class Popup {
72
74
 
73
75
  setScreen(p) {
74
76
  if (this._planet) {
75
- this.el.style.transform = "translate(" + (p.x - this.clientWidth * 0.5) + "px, " + (p.y - this._planet.renderer.handler.canvas.height - this._tipEl.clientHeight) + "px)"
77
+ let r = this._planet.renderer.handler.pixelRatio;
78
+ this.el.style.transform =
79
+ "translate(" +
80
+ (p.x / r - this.clientWidth * 0.5) +
81
+ "px, " +
82
+ (p.y / r - this._planet.renderer.handler.canvas.clientHeight - this._tipEl.clientHeight) +
83
+ "px)";
76
84
  }
77
85
  }
78
86
 
@@ -97,8 +105,8 @@ class Popup {
97
105
  render(params) {
98
106
  this.el = this._renderTemplate(params);
99
107
  this._contentEl = this.el.querySelector(".og-popup-content");
100
- this._titleEl = this.el.querySelector(".og-popup-title")
101
- this._tipEl = this.el.querySelector(".og-popup-tip-container")
108
+ this._titleEl = this.el.querySelector(".og-popup-title");
109
+ this._tipEl = this.el.querySelector(".og-popup-tip-container");
102
110
  this.setOffset(this._offset[0], this._offset[1]);
103
111
  this.setContent(this._content);
104
112
  this.setTitle(this._title);
@@ -148,7 +156,6 @@ class Popup {
148
156
  }
149
157
 
150
158
  setCartesian3v(cart, height = 0) {
151
-
152
159
  this._cartPos = cart;
153
160
 
154
161
  if (this._planet) {
@@ -187,10 +194,10 @@ class Popup {
187
194
  if (content) {
188
195
  this.clear();
189
196
  this._content = content;
190
- if (typeof content === 'string') {
197
+ if (typeof content === "string") {
191
198
  this._contentEl.innerHTML = content;
192
199
  } else {
193
- this._contentEl.appendChild(content)
200
+ this._contentEl.appendChild(content);
194
201
  }
195
202
  }
196
203
  return this;
@@ -202,4 +209,4 @@ class Popup {
202
209
  }
203
210
  }
204
211
 
205
- export { Popup };
212
+ export { Popup };
@@ -1,6 +1,10 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  class QueueArray {
4
+ /**
5
+ *
6
+ * @param {number} [size]
7
+ */
4
8
  constructor(size) {
5
9
  this._size = size || 2048;
6
10
  this._array = new Array(this._size);
@@ -68,4 +72,4 @@ class QueueArray {
68
72
  }
69
73
  }
70
74
 
71
- export { QueueArray };
75
+ export { QueueArray };
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  /**
4
4
  * 2D Rectangle class.
@@ -7,10 +7,15 @@
7
7
  * @param {number} [top] - Top coordinate. 0 - default.
8
8
  * @param {number} [right] - Right coordinate. 0 - default.
9
9
  * @param {number} [bottom] - Bottom coordinate. 0 - default.
10
- */
10
+ */
11
11
  class Rectangle {
12
+ /**
13
+ * @param {number} [left] - Left coordinate. 0 - default.
14
+ * @param {number} [top] - Top coordinate. 0 - default.
15
+ * @param {number} [right] - Right coordinate. 0 - default.
16
+ * @param {number} [bottom] - Bottom coordinate. 0 - default.
17
+ */
12
18
  constructor(left, top, right, bottom) {
13
-
14
19
  /**
15
20
  * Left coordinate.
16
21
  * @public
@@ -43,7 +48,7 @@ class Rectangle {
43
48
  /**
44
49
  * Clone rectangle object.
45
50
  * @public
46
- * @returns {og.Rectangle}
51
+ * @returns {Rectangle}
47
52
  */
48
53
  clone() {
49
54
  return new Rectangle(this.left, this.top, this.right, this.bottom);
@@ -95,7 +100,7 @@ class Rectangle {
95
100
  * @type {boolean}
96
101
  */
97
102
  fit(width, height) {
98
- return (this.getWidth() == width && this.getHeight() == height);
103
+ return this.getWidth() == width && this.getHeight() == height;
99
104
  }
100
105
 
101
106
  isInside(x, y) {
@@ -103,4 +108,4 @@ class Rectangle {
103
108
  }
104
109
  }
105
110
 
106
- export { Rectangle };
111
+ export { Rectangle };
package/src/og/Stack.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @module og/Stack
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
7
  class Node {
8
8
  constructor() {
@@ -13,8 +13,11 @@ class Node {
13
13
  }
14
14
 
15
15
  class Stack {
16
+ /**
17
+ *
18
+ * @param {number} [size]
19
+ */
16
20
  constructor(size = 256) {
17
-
18
21
  this._current = new Node();
19
22
  this._head = this._current;
20
23
 
package/src/og/ajax.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @module og/ajax
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
7
  /**
8
8
  * Ajax parameters.
@@ -13,8 +13,7 @@ const ajax = {
13
13
  * Ajax ready state result.
14
14
  * @enum
15
15
  */
16
- ReadyState:
17
- {
16
+ ReadyState: {
18
17
  Uninitialized: 0,
19
18
  Loading: 1,
20
19
  Loaded: 2,
@@ -25,8 +24,7 @@ const ajax = {
25
24
  * Ajax status code.
26
25
  * @enum
27
26
  */
28
- Status:
29
- {
27
+ Status: {
30
28
  OK: 200,
31
29
  Created: 201,
32
30
  Accepted: 202,
@@ -88,24 +86,6 @@ const defaultParams = {
88
86
  responseType: "text"
89
87
  };
90
88
 
91
- function createXMLHttp() {
92
- var xhr = null;
93
- if (typeof XMLHttpRequest != "undefined") {
94
- xhr = new XMLHttpRequest();
95
- return xhr;
96
- } else if (window.ActiveXObject) {
97
- var ieXMLHttpVersions = ['MSXML2.XMLHttp.5.0', 'MSXML2.XMLHttp.4.0', 'MSXML2.XMLHttp.3.0', 'MSXML2.XMLHttp', 'Microsoft.XMLHttp'];
98
- for (var i = 0; i < ieXMLHttpVersions.length; i++) {
99
- try {
100
- xhr = new ActiveXObject(ieXMLHttpVersions[i]);
101
- return xhr;
102
- } catch (e) {
103
- throw new Error('og.ajax.createXMLHttp creation failed.');
104
- }
105
- }
106
- }
107
- }
108
-
109
89
  /**
110
90
  * Send an ajax request.
111
91
  * @function
@@ -122,10 +102,10 @@ function createXMLHttp() {
122
102
  * @returns {ajax.Xhr} - Returns object that could be aborted.
123
103
  */
124
104
  ajax.request = function (url, params) {
125
-
126
105
  params = params || {};
127
106
 
128
- var p = {}, i;
107
+ var p = {},
108
+ i;
129
109
 
130
110
  for (i in defaultParams) {
131
111
  p[i] = defaultParams[i];
@@ -137,18 +117,23 @@ ajax.request = function (url, params) {
137
117
 
138
118
  p.data = params.data;
139
119
 
140
- var xhr = createXMLHttp();
120
+ var xhr = new XMLHttpRequest();
141
121
 
142
122
  var customXhr = new Xhr(xhr);
143
123
 
144
- var body = null, d;
124
+ var body = null,
125
+ d;
145
126
 
146
127
  if (p.type === ajax.Method.Post) {
147
128
  if (p.data) {
148
129
  body = "";
149
130
  for (let key in p.data) {
150
131
  d = p.data[key];
151
- body += key + "=" + encodeURIComponent(d instanceof Object ? JSON.stringify(d) : d) + "&";
132
+ body +=
133
+ key +
134
+ "=" +
135
+ encodeURIComponent(d instanceof Object ? JSON.stringify(d) : d) +
136
+ "&";
152
137
  }
153
138
  body = body.slice(0, -1);
154
139
  }
@@ -158,7 +143,8 @@ ajax.request = function (url, params) {
158
143
  var tail = "?";
159
144
  for (let key in p.data) {
160
145
  d = p.data[key];
161
- tail += key + "=" + encodeURIComponent(d instanceof Object ? JSON.stringify(d) : d) + "&";
146
+ tail +=
147
+ key + "=" + encodeURIComponent(d instanceof Object ? JSON.stringify(d) : d) + "&";
162
148
  }
163
149
  tail = tail.slice(0, -1);
164
150
  xhr.open(p.type, url + tail, p.async);
@@ -190,7 +176,8 @@ ajax.request = function (url, params) {
190
176
  * @param {Object} Response data
191
177
  * @param {Object} Status object
192
178
  */
193
- params.abort && params.abort.call(params.sender || customXhr, xhr.response, xhr.status);
179
+ params.abort &&
180
+ params.abort.call(params.sender || customXhr, xhr.response, xhr.status);
194
181
  } else {
195
182
  /**
196
183
  * Error callback.
@@ -198,9 +185,10 @@ ajax.request = function (url, params) {
198
185
  * @param {Object} Response data
199
186
  * @param {Object} Status object
200
187
  */
201
- params.error && params.error.call(params.sender || customXhr, xhr.response, xhr.status);
188
+ params.error &&
189
+ params.error.call(params.sender || customXhr, xhr.response, xhr.status);
202
190
  }
203
- delete xhr['onreadystatechange'];
191
+ delete xhr["onreadystatechange"];
204
192
  xhr.onreadystatechange = null;
205
193
  xhr = null;
206
194
  } else {
@@ -213,4 +201,4 @@ ajax.request = function (url, params) {
213
201
  return customXhr;
214
202
  };
215
203
 
216
- export { ajax };
204
+ export { ajax };
@@ -1,6 +1,6 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- import * as jd from './jd.js';
3
+ import * as jd from "./jd.js";
4
4
 
5
5
  /**
6
6
  * Angle between J2000 mean equator and the ecliptic plane.
@@ -16,7 +16,7 @@ export const J2000_OBLIQUITY = 23.4392911;
16
16
  * @const
17
17
  * @type{Number}
18
18
  */
19
- export const AU_TO_METERS = 1.49597870e+11;
19
+ export const AU_TO_METERS = 1.4959787e11;
20
20
 
21
21
  /**
22
22
  * Terestrial and atomic time difference.
@@ -45,7 +45,7 @@ export const SUN_GRAVITATIONAL_PARAMETER = 1.32712440018e20;
45
45
  * @returns {Number} - returns barycentric dynamical time.
46
46
  */
47
47
  export function TAItoTDB(tai) {
48
- tai += og.astro.TDT_TAI * jd.ONE_BY_SECONDS_PER_DAY;
48
+ tai += TDT_TAI * jd.ONE_BY_SECONDS_PER_DAY;
49
49
  var g = 6.239996 + 0.0172019696544 * (tai - jd.J2000);
50
50
  return tai + 0.001658 * Math.sin(g + 1.671e-2 * Math.sin(g)) * jd.ONE_BY_SECONDS_PER_DAY;
51
- }
51
+ }
@@ -2,18 +2,18 @@
2
2
  * @module og/astro/earth
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import * as jd from './jd.js';
8
- import * as math from '../math.js';
9
- import * as astro from './astro.js';
10
- import { Quat } from '../math/Quat.js';
11
- import { Vec3 } from '../math/Vec3.js';
7
+ import * as jd from "./jd.js";
8
+ import * as math from "../math.js";
9
+ import * as astro from "./astro.js";
10
+ import { Quat } from "../math/Quat.js";
11
+ import { Vec3 } from "../math/Vec3.js";
12
12
 
13
13
  /**
14
14
  * Returns Sun position in the geocentric coordinate system by the time.
15
15
  * @param {Number} jDate - Julian date time.
16
- * @returns {og.Vec3} - Sun geocentric coordinates.
16
+ * @returns {Vec3} - Sun geocentric coordinates.
17
17
  */
18
18
  export function getSunPosition(jDate) {
19
19
  // http://stjarnhimlen.se/comp/tutorial.html
@@ -21,7 +21,7 @@ export function getSunPosition(jDate) {
21
21
  // e Eccentricity
22
22
  // T Time at perihelion
23
23
 
24
- // q Perihelion distance = a * (1 - e)
24
+ // q Perihelion distance = a * (1 - e)
25
25
  // Q Aphelion distance = a * (1 + e)
26
26
 
27
27
  // i Inclination, i.e. the "tilt" of the orbit relative to the
@@ -70,16 +70,17 @@ export function getSunPosition(jDate) {
70
70
 
71
71
  var d = jDate - jd.J2000;
72
72
 
73
- var w = 282.9404 + 4.70935E-5 * d; // longitude of perihelion
73
+ var w = 282.9404 + 4.70935e-5 * d; // longitude of perihelion
74
74
  // var a = 1.000000; // mean distance, a.u.
75
- var e = 0.016709 - 1.151E-9 * d; // eccentricity
76
- var M = math.rev(356.0470 + 0.9856002585 * d); // mean anomaly
75
+ var e = 0.016709 - 1.151e-9 * d; // eccentricity
76
+ var M = math.rev(356.047 + 0.9856002585 * d); // mean anomaly
77
77
 
78
- var oblecl = astro.J2000_OBLIQUITY - 3.563E-7 * d; // obliquity of the ecliptic
78
+ var oblecl = astro.J2000_OBLIQUITY - 3.563e-7 * d; // obliquity of the ecliptic
79
79
 
80
80
  // var L = math.rev(w + M); // Sun's mean longitude
81
81
 
82
- var E = M + math.DEGREES * e * Math.sin(M * math.RADIANS) * (1 + e * Math.cos(M * math.RADIANS)); // eccentric anomaly
82
+ var E =
83
+ M + math.DEGREES * e * Math.sin(M * math.RADIANS) * (1 + e * Math.cos(M * math.RADIANS)); // eccentric anomaly
83
84
 
84
85
  // Sun rectangular coordiantes, where the X axis points towards the perihelion
85
86
  var x = Math.cos(E * math.RADIANS) - e;
@@ -99,10 +100,15 @@ export function getSunPosition(jDate) {
99
100
  var yequat = y * Math.cos(oblecl * math.RADIANS);
100
101
  var zequat = y * Math.sin(oblecl * math.RADIANS);
101
102
 
102
- var theta = math.TWO_PI * (d * 24.0 / 23.9344694 - 259.853 / 360.0); // Siderial spin time
103
+ var theta = math.TWO_PI * ((d * 24.0) / 23.9344694 - 259.853 / 360.0); // Siderial spin time
103
104
 
104
- return Quat.yRotation(-theta).mulVec3(new Vec3(-yequat * astro.AU_TO_METERS,
105
- zequat * astro.AU_TO_METERS, -xequat * astro.AU_TO_METERS));
105
+ return Quat.yRotation(-theta).mulVec3(
106
+ new Vec3(
107
+ -yequat * astro.AU_TO_METERS,
108
+ zequat * astro.AU_TO_METERS,
109
+ -xequat * astro.AU_TO_METERS
110
+ )
111
+ );
106
112
 
107
113
  // Convert to RA and Decl
108
114
  // var RA = Math.atan2(yequat, xequat) * math.DEGREES;
@@ -2,9 +2,9 @@
2
2
  * @module og/astro/jd
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { binarySearch } from '../utils/shared.js';
7
+ import { binarySearch } from "../utils/shared.js";
8
8
 
9
9
  /**
10
10
  * Seconds in millisecond.
@@ -172,8 +172,13 @@ export function T(jd) {
172
172
  export function getDayNumber(year, month, day) {
173
173
  var a = ((month - 14) / 12) | 0;
174
174
  var b = year + 4800 + a;
175
- return (((1461 * b) / 4) | 0) + (((367 * (month - 2 - 12 * a)) / 12) | 0) -
176
- (((3 * (((b + 100) / 100) | 0)) / 4) | 0) + day - 32075;
175
+ return (
176
+ (((1461 * b) / 4) | 0) +
177
+ (((367 * (month - 2 - 12 * a)) / 12) | 0) -
178
+ (((3 * (((b + 100) / 100) | 0)) / 4) | 0) +
179
+ day -
180
+ 32075
181
+ );
177
182
  }
178
183
 
179
184
  /**
@@ -190,7 +195,8 @@ export function DateToUTC(date) {
190
195
  }
191
196
 
192
197
  var secondsOfDay =
193
- date.getUTCSeconds() + hour * SECONDS_PER_HOUR +
198
+ date.getUTCSeconds() +
199
+ hour * SECONDS_PER_HOUR +
194
200
  date.getUTCMinutes() * SECONDS_PER_MINUTE +
195
201
  date.getUTCMilliseconds() * SECONDS_PER_MILLISECOND;
196
202
 
@@ -198,7 +204,7 @@ export function DateToUTC(date) {
198
204
  dayNumber--;
199
205
  }
200
206
 
201
- var extraDays = secondsOfDay * ONE_BY_SECONDS_PER_DAY | 0;
207
+ var extraDays = (secondsOfDay * ONE_BY_SECONDS_PER_DAY) | 0;
202
208
  dayNumber += extraDays;
203
209
  secondsOfDay -= SECONDS_PER_DAY * extraDays;
204
210
 
@@ -300,7 +306,7 @@ export function UTCtoDate(utc) {
300
306
  }
301
307
 
302
308
  var L = (julianDayNumber + 68569) | 0;
303
- var N = (4 * L / 146097) | 0;
309
+ var N = ((4 * L) / 146097) | 0;
304
310
  L = (L - (((146097 * N + 3) / 4) | 0)) | 0;
305
311
  var I = ((4000 * (L + 1)) / 1461001) | 0;
306
312
  L = (L - (((1461 * I) / 4) | 0) + 31) | 0;
@@ -310,12 +316,12 @@ export function UTCtoDate(utc) {
310
316
  var month = (J + 2 - 12 * L) | 0;
311
317
  var year = (100 * (N - 49) + I + L) | 0;
312
318
 
313
- var hour = secondsOfDay * ONE_BY_SECONDS_PER_HOUR | 0;
319
+ var hour = (secondsOfDay * ONE_BY_SECONDS_PER_HOUR) | 0;
314
320
  var remainingSeconds = secondsOfDay - hour * SECONDS_PER_HOUR;
315
- var minute = remainingSeconds * ONE_BY_SECONDS_PER_MINUTE | 0;
321
+ var minute = (remainingSeconds * ONE_BY_SECONDS_PER_MINUTE) | 0;
316
322
  remainingSeconds = remainingSeconds - minute * SECONDS_PER_MINUTE;
317
323
  var second = remainingSeconds | 0;
318
- var millisecond = (remainingSeconds - second) * MILLISECONDS_PER_SECOND | 0;
324
+ var millisecond = ((remainingSeconds - second) * MILLISECONDS_PER_SECOND) | 0;
319
325
 
320
326
  hour += 12;
321
327
  if (hour > 23) {
@@ -331,11 +337,10 @@ export function UTCtoDate(utc) {
331
337
  * @returns {Date} JavaScript Date object
332
338
  */
333
339
  export function TAItoDate(tai) {
334
-
335
340
  var utc = TAItoUTC(tai);
336
341
  if (!utc) {
337
342
  utc = TAItoUTC(addSeconds(tai, -1));
338
- og.console.logWrn("TAItoDate:336 - can't conv utc.");
343
+ console.warn("TAItoDate:336 - can't conv utc.");
339
344
  }
340
345
 
341
346
  return UTCtoDate(utc);
@@ -399,7 +404,7 @@ export function addDays(jd, days) {
399
404
  export function getMilliseconds(jd) {
400
405
  var s = jd - (jd | 0);
401
406
  s *= SECONDS_PER_DAY;
402
- return (s - (s | 0)) * MILLISECONDS_PER_SECOND | 0;
407
+ return ((s - (s | 0)) * MILLISECONDS_PER_SECOND) | 0;
403
408
  }
404
409
 
405
410
  /**
@@ -421,12 +426,12 @@ export function getHours(jd) {
421
426
  var julianDayNumber = jd | 0;
422
427
  var secondsOfDay = (jd - julianDayNumber) * SECONDS_PER_DAY;
423
428
 
424
- var hour = secondsOfDay * ONE_BY_SECONDS_PER_HOUR | 0;
429
+ var hour = (secondsOfDay * ONE_BY_SECONDS_PER_HOUR) | 0;
425
430
  var remainingSeconds = secondsOfDay - hour * SECONDS_PER_HOUR;
426
- var minute = remainingSeconds * ONE_BY_SECONDS_PER_MINUTE | 0;
431
+ var minute = (remainingSeconds * ONE_BY_SECONDS_PER_MINUTE) | 0;
427
432
  remainingSeconds = remainingSeconds - minute * SECONDS_PER_MINUTE;
428
433
  var second = remainingSeconds | 0;
429
- var millisecond = (remainingSeconds - second) * MILLISECONDS_PER_SECOND | 0;
434
+ var millisecond = ((remainingSeconds - second) * MILLISECONDS_PER_SECOND) | 0;
430
435
 
431
436
  hour += 12 + minute / 60 + second / 3600 + millisecond / 1000;
432
437
  if (hour > 23) {
@@ -443,7 +448,7 @@ export function getHours(jd) {
443
448
  */
444
449
  export function getMinutes(jd) {
445
450
  var s = jd - (jd | 0);
446
- return s * MINUTES_PER_DAY | 0;
451
+ return (s * MINUTES_PER_DAY) | 0;
447
452
  }
448
453
 
449
454
  /**
@@ -507,7 +512,7 @@ const leapSecondsTable = [
507
512
  __ls(2453736.5, 33.0), // 2006-01-01T00:00:00.000Z
508
513
  __ls(2454832.5, 34.0), // 2009-01-01T00:00:00.000Z
509
514
  __ls(2456109.5, 35.0), // 2012-07-01T00:00:00.000Z
510
- __ls(2457204.5, 36.0) // 2015-07-01T00:00:00.000Z
515
+ __ls(2457204.5, 36.0) // 2015-07-01T00:00:00.000Z
511
516
  ];
512
517
 
513
518
  export const J2000TAI = UTCtoTAI(J2000);
@@ -2,10 +2,10 @@
2
2
  * @module og/astro/orbit
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import * as math from '../math.js';
8
- import { Mat3 } from '../math/Mat3.js';
7
+ import * as math from "../math.js";
8
+ import { Mat3 } from "../math/Mat3.js";
9
9
 
10
10
  export function getEccentricAnomaly(M, ecc) {
11
11
  if (ecc == 0.0) {
@@ -22,14 +22,14 @@ export function getEccentricAnomaly(M, ecc) {
22
22
  // Extremely stable Laguerre-Conway method for solving Kepler's
23
23
  // equation. Only use this for high-eccentricity orbits, as it
24
24
  // requires more calcuation.
25
- let E = M + 0.85 * ecc * sign(sin(M));
25
+ let E = M + 0.85 * ecc * Math.sign(Math.sin(M));
26
26
  return math.solve_iteration_fixed(solveKeplerLaguerreConway(ecc, M), E, 8);
27
27
  } else if (ecc == 1.0) {
28
28
  // TODO: Parabolic orbit
29
29
  return M;
30
30
  } else {
31
31
  // Laguerre-Conway method for hyperbolic (ecc > 1) orbits.
32
- let E = log(2 * M / ecc + 1.85);
32
+ let E = Math.log((2 * M) / ecc + 1.85);
33
33
  return math.solve_iteration_fixed(solveKeplerLaguerreConwayHyp(ecc, M), E, 30);
34
34
  }
35
35
  }
@@ -57,7 +57,7 @@ function solveKeplerLaguerreConway(ecc, M) {
57
57
  var f = x - s - M;
58
58
  var f1 = 1 - c;
59
59
  var f2 = s;
60
- x += -5 * f / (f1 + Math.sign(f1) * Math.sqrt(abs(16 * f1 * f1 - 20 * f * f2)));
60
+ x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
61
61
  return x;
62
62
  };
63
63
  }
@@ -69,7 +69,7 @@ function solveKeplerLaguerreConwayHyp(ecc, M) {
69
69
  var f = s - x - M;
70
70
  var f1 = c - 1;
71
71
  var f2 = s;
72
- x += -5 * f / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
72
+ x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
73
73
  return x;
74
74
  };
75
75
  }
@@ -77,7 +77,7 @@ function solveKeplerLaguerreConwayHyp(ecc, M) {
77
77
  export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) {
78
78
  var tol = 0.00000001745;
79
79
  var iterations = 20;
80
- var e = meanAnomaly - 2.0 * Math.PI * (meanAnomaly / (2.0 * Math.PI) | 0);
80
+ var e = meanAnomaly - 2.0 * Math.PI * ((meanAnomaly / (2.0 * Math.PI)) | 0);
81
81
  var err = 1;
82
82
  while (Math.abs(err) > tol && iterations > 0) {
83
83
  err = e - eccentricity * Math.sin(e) - meanAnomaly;
@@ -91,8 +91,10 @@ export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) {
91
91
  export function getTrueAnomaly(eccentricAnomaly, eccentricity) {
92
92
  var revs = Math.floor(eccentricAnomaly / math.TWO_PI);
93
93
  eccentricAnomaly -= revs * math.TWO_PI;
94
- var trueAnomaly = Math.atan2(Math.sin(eccentricAnomaly) * Math.sqrt(1 - eccentricity * eccentricity),
95
- Math.cos(eccentricAnomaly) - eccentricity);
94
+ var trueAnomaly = Math.atan2(
95
+ Math.sin(eccentricAnomaly) * Math.sqrt(1 - eccentricity * eccentricity),
96
+ Math.cos(eccentricAnomaly) - eccentricity
97
+ );
96
98
  trueAnomaly = math.zeroTwoPI(trueAnomaly);
97
99
  if (eccentricAnomaly < 0) {
98
100
  trueAnomaly -= math.TWO_PI;
@@ -118,4 +120,4 @@ export function getPerifocalToCartesianMatrix(argumentOfPeriapsis, inclination,
118
120
  res._m[7] = -cosraan * sini;
119
121
  res._m[8] = cosi;
120
122
  return res;
121
- }
123
+ }
@@ -2,20 +2,29 @@
2
2
  * @module og/astro/rotation
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- export function getRotationMatrix(rightAscension, declination) {
8
- xAxis.x = Math.cos(rightAscension + og.math.PI_TWO);
9
- xAxis.y = Math.sin(rightAscension + og.math.PI_TWO);
7
+ import { Vec3 } from "../math/Vec3.js";
8
+ import { Mat3 } from "../math/Mat3.js";
9
+ import { PI_TWO } from "../math.js";
10
+
11
+ export function getRotationMatrix(rightAscension, declination, res) {
12
+ let xAxis = new Vec3(),
13
+ zAxis = new Vec3();
14
+
15
+ res = res || new Mat3();
16
+
17
+ xAxis.x = Math.cos(rightAscension + PI_TWO);
18
+ xAxis.y = Math.sin(rightAscension + PI_TWO);
10
19
  xAxis.z = 0.0;
11
20
 
12
- var cosDec = Math.cos(declination);
21
+ let cosDec = Math.cos(declination);
13
22
 
14
23
  zAxis.x = cosDec * Math.cos(rightAscension);
15
24
  zAxis.y = cosDec * Math.sin(rightAscension);
16
25
  zAxis.z = Math.sin(declination);
17
26
 
18
- var yAxis = zAxis.cross(xAxis);
27
+ let yAxis = zAxis.cross(xAxis);
19
28
 
20
29
  res._m[0] = xAxis.x;
21
30
  res._m[1] = yAxis.x;
@@ -27,5 +36,5 @@ export function getRotationMatrix(rightAscension, declination) {
27
36
  res._m[7] = yAxis.z;
28
37
  res._m[8] = zAxis.z;
29
38
 
30
- return result;
31
- }
39
+ return res;
40
+ }
package/src/og/bv/Box.js CHANGED
@@ -11,11 +11,15 @@ import { Vec3 } from "../math/Vec3.js";
11
11
  * @class
12
12
  */
13
13
  class Box {
14
+ /**
15
+ *
16
+ * @param {*} boundsArr
17
+ */
14
18
  constructor(boundsArr) {
15
19
  /**
16
20
  * Vertices array.
17
21
  * @public
18
- * @type{Array.<og.Vec3>}
22
+ * @type{Array.<Vec3>}
19
23
  */
20
24
  this.vertices = [
21
25
  new Vec3(),
@@ -65,8 +69,8 @@ class Box {
65
69
 
66
70
  /**
67
71
  * Sets bounding box coordiantes by ellipsoid geodetic extend.
68
- * @param {og.Ellipsoid} ellipsoid - Ellipsoid.
69
- * @param {og.Extent} extent - Geodetic extent.
72
+ * @param {Ellipsoid} ellipsoid - Ellipsoid.
73
+ * @param {Extent} extent - Geodetic extent.
70
74
  */
71
75
  setFromExtent(ellipsoid, extent) {
72
76
  this.setFromBoundsArr(extent.getCartesianBounds(ellipsoid));