@openglobus/og 0.11.1 → 0.11.6

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 (255) hide show
  1. package/package.json +18 -20
  2. package/src/og/Clock.js +11 -11
  3. package/src/og/Deferred.js +1 -1
  4. package/src/og/Events.js +9 -7
  5. package/src/og/Extent.js +117 -72
  6. package/src/og/Globe.js +35 -22
  7. package/src/og/ImageCanvas.js +24 -18
  8. package/src/og/Lock.js +2 -2
  9. package/src/og/LonLat.js +40 -37
  10. package/src/og/Popup.js +21 -15
  11. package/src/og/QueueArray.js +7 -3
  12. package/src/og/Rectangle.js +11 -6
  13. package/src/og/Stack.js +8 -5
  14. package/src/og/ajax.js +21 -33
  15. package/src/og/astro/astro.js +5 -5
  16. package/src/og/astro/earth.js +23 -17
  17. package/src/og/astro/jd.js +44 -39
  18. package/src/og/astro/orbit.js +20 -18
  19. package/src/og/astro/rotation.js +17 -8
  20. package/src/og/bv/Box.js +7 -3
  21. package/src/og/bv/Sphere.js +17 -9
  22. package/src/og/camera/Camera.js +137 -86
  23. package/src/og/camera/Frustum.js +30 -19
  24. package/src/og/camera/PlanetCamera.js +30 -26
  25. package/src/og/control/CompassButton.js +8 -2
  26. package/src/og/control/Control.js +13 -11
  27. package/src/og/control/DebugInfo.js +4 -1
  28. package/src/og/control/EarthCoordinates.js +62 -41
  29. package/src/og/control/EarthNavigation.js +20 -22
  30. package/src/og/control/GeoImageDragControl.js +1 -1
  31. package/src/og/control/KeyboardNavigation.js +12 -12
  32. package/src/og/control/LayerSwitcher.js +24 -23
  33. package/src/og/control/Lighting.js +1 -1
  34. package/src/og/control/MouseNavigation.js +1 -1
  35. package/src/og/control/ScaleControl.js +1 -1
  36. package/src/og/control/SegmentBoundVisualization.js +8 -9
  37. package/src/og/control/ShowFps.js +15 -10
  38. package/src/og/control/SimpleNavigation.js +8 -10
  39. package/src/og/control/Sun.js +25 -15
  40. package/src/og/control/ToggleWireframe.js +5 -5
  41. package/src/og/control/TouchNavigation.js +58 -45
  42. package/src/og/control/ZoomControl.js +41 -25
  43. package/src/og/control/index.js +4 -0
  44. package/src/og/ellipsoid/Ellipsoid.js +181 -85
  45. package/src/og/ellipsoid/wgs84.js +4 -4
  46. package/src/og/entity/BaseBillboard.js +97 -44
  47. package/src/og/entity/Billboard.js +15 -11
  48. package/src/og/entity/BillboardHandler.js +314 -64
  49. package/src/og/entity/Entity.js +106 -74
  50. package/src/og/entity/EntityCollection.js +72 -49
  51. package/src/og/entity/GeoObject.js +228 -0
  52. package/src/og/entity/GeoObjectHandler.js +910 -0
  53. package/src/og/entity/Geometry.js +29 -26
  54. package/src/og/entity/GeometryHandler.js +598 -126
  55. package/src/og/entity/Label.js +74 -40
  56. package/src/og/entity/LabelHandler.js +47 -246
  57. package/src/og/entity/LabelWorker.js +213 -0
  58. package/src/og/entity/Object3d.js +504 -0
  59. package/src/og/entity/PointCloud.js +81 -33
  60. package/src/og/entity/PointCloudHandler.js +9 -9
  61. package/src/og/entity/Polyline.js +39 -39
  62. package/src/og/entity/Ray.js +61 -28
  63. package/src/og/entity/ShapeHandler.js +1 -1
  64. package/src/og/entity/Strip.js +77 -48
  65. package/src/og/entity/StripHandler.js +27 -27
  66. package/src/og/entity/index.js +8 -16
  67. package/src/og/input/KeyboardHandler.js +107 -104
  68. package/src/og/input/MouseHandler.js +81 -78
  69. package/src/og/input/TouchHandler.js +55 -51
  70. package/src/og/layer/BaseGeoImage.js +61 -30
  71. package/src/og/layer/CanvasTiles.js +26 -24
  72. package/src/og/layer/GeoImage.js +10 -10
  73. package/src/og/layer/GeoTexture2d.js +1 -1
  74. package/src/og/layer/GeoVideo.js +3 -3
  75. package/src/og/layer/KML.js +66 -40
  76. package/src/og/layer/Layer.js +27 -17
  77. package/src/og/layer/Material.js +93 -61
  78. package/src/og/layer/Vector.js +118 -72
  79. package/src/og/layer/WMS.js +36 -19
  80. package/src/og/layer/XYZ.js +55 -48
  81. package/src/og/light/LightSource.js +47 -40
  82. package/src/og/math/Line2.js +24 -24
  83. package/src/og/math/Line3.js +103 -102
  84. package/src/og/math/Mat3.js +134 -121
  85. package/src/og/math/Mat4.js +603 -459
  86. package/src/og/math/Plane.js +21 -20
  87. package/src/og/math/Quat.js +980 -927
  88. package/src/og/math/Ray.js +195 -187
  89. package/src/og/math/Vec2.js +127 -117
  90. package/src/og/math/Vec3.js +206 -176
  91. package/src/og/math/Vec4.js +49 -53
  92. package/src/og/math/coder.js +18 -18
  93. package/src/og/math.js +12 -12
  94. package/src/og/mercator.js +11 -11
  95. package/src/og/proj/EPSG3857.js +4 -4
  96. package/src/og/proj/EPSG4326.js +4 -4
  97. package/src/og/proj/Proj.js +31 -31
  98. package/src/og/quadTree/EntityCollectionNode.js +310 -300
  99. package/src/og/quadTree/Node.js +1008 -993
  100. package/src/og/renderer/Renderer.js +768 -747
  101. package/src/og/renderer/RendererEvents.js +9 -6
  102. package/src/og/scene/Axes.js +1 -1
  103. package/src/og/scene/BaseNode.js +8 -9
  104. package/src/og/scene/Planet.js +115 -87
  105. package/src/og/scene/RenderNode.js +29 -22
  106. package/src/og/scene/SkyBox.js +1 -1
  107. package/src/og/segment/Segment.js +1886 -1878
  108. package/src/og/segment/SegmentLonLat.js +298 -268
  109. package/src/og/segment/segmentHelper.js +11 -11
  110. package/src/og/shaders/bloom.js +1 -1
  111. package/src/og/shaders/blur.js +2 -2
  112. package/src/og/shaders/depth.js +1 -1
  113. package/src/og/shaders/geoObject.js +211 -0
  114. package/src/og/shaders/label.js +1 -1
  115. package/src/og/shaders/lumFilter.js +1 -1
  116. package/src/og/shaders/pointCloud.js +42 -42
  117. package/src/og/shaders/screenFrame.js +1 -1
  118. package/src/og/shaders/shape.js +15 -21
  119. package/src/og/shaders/skybox.js +37 -37
  120. package/src/og/shaders/toneMapping.js +1 -1
  121. package/src/og/shapes/BaseShape.js +129 -57
  122. package/src/og/shapes/Icosphere.js +30 -15
  123. package/src/og/shapes/Sphere.js +13 -16
  124. package/src/og/terrain/BilTerrain.js +2 -1
  125. package/src/og/terrain/EmptyTerrain.js +2 -2
  126. package/src/og/terrain/Geoid.js +2 -2
  127. package/src/og/terrain/GlobusTerrain.js +10 -10
  128. package/src/og/terrain/MapboxTerrain.js +1 -1
  129. package/src/og/utils/GeoImageCreator.js +9 -9
  130. package/src/og/utils/Loader.js +6 -6
  131. package/src/og/utils/NormalMapCreator.js +13 -13
  132. package/src/og/utils/TerrainWorker.js +1 -1
  133. package/src/og/utils/TextureAtlas.js +20 -22
  134. package/src/og/utils/VectorTileCreator.js +5 -5
  135. package/src/og/utils/earcut.js +1 -1
  136. package/src/og/utils/shared.js +15 -15
  137. package/src/og/webgl/Framebuffer.js +101 -53
  138. package/src/og/webgl/Handler.js +125 -85
  139. package/src/og/webgl/Multisample.js +55 -27
  140. package/src/og/webgl/Program.js +80 -35
  141. package/src/og/webgl/ProgramController.js +27 -23
  142. package/src/og/webgl/callbacks.js +8 -8
  143. package/types/Clock.d.ts +6 -2
  144. package/types/Deferred.d.ts +1 -1
  145. package/types/Events.d.ts +8 -4
  146. package/types/Extent.d.ts +37 -33
  147. package/types/Globe.d.ts +15 -13
  148. package/types/ImageCanvas.d.ts +5 -3
  149. package/types/LonLat.d.ts +24 -24
  150. package/types/Popup.d.ts +4 -0
  151. package/types/QueueArray.d.ts +6 -2
  152. package/types/Rectangle.d.ts +10 -4
  153. package/types/Stack.d.ts +4 -0
  154. package/types/ajax.d.ts +1 -1
  155. package/types/astro/earth.d.ts +3 -2
  156. package/types/bv/Box.d.ts +10 -5
  157. package/types/bv/Sphere.d.ts +13 -7
  158. package/types/camera/Camera.d.ts +90 -81
  159. package/types/camera/Frustum.d.ts +26 -22
  160. package/types/camera/PlanetCamera.d.ts +49 -53
  161. package/types/control/CompassButton.d.ts +4 -4
  162. package/types/control/Control.d.ts +7 -4
  163. package/types/control/DebugInfo.d.ts +3 -4
  164. package/types/control/EarthCoordinates.d.ts +6 -6
  165. package/types/control/EarthNavigation.d.ts +42 -0
  166. package/types/control/KeyboardNavigation.d.ts +3 -4
  167. package/types/control/LayerSwitcher.d.ts +3 -5
  168. package/types/control/Lighting.d.ts +3 -3
  169. package/types/control/MouseNavigation.d.ts +47 -0
  170. package/types/control/ScaleControl.d.ts +3 -3
  171. package/types/control/ShowFps.d.ts +3 -4
  172. package/types/control/SimpleNavigation.d.ts +3 -6
  173. package/types/control/Sun.d.ts +8 -10
  174. package/types/control/ToggleWireframe.d.ts +3 -3
  175. package/types/control/TouchNavigation.d.ts +48 -0
  176. package/types/control/ZoomControl.d.ts +3 -4
  177. package/types/control/index.d.ts +3 -1
  178. package/types/ellipsoid/Ellipsoid.d.ts +47 -43
  179. package/types/ellipsoid/wgs84.d.ts +3 -2
  180. package/types/entity/BaseBillboard.d.ts +41 -34
  181. package/types/entity/Billboard.d.ts +7 -7
  182. package/types/entity/BillboardHandler.d.ts +4 -0
  183. package/types/entity/Entity.d.ts +101 -83
  184. package/types/entity/EntityCollection.d.ts +57 -43
  185. package/types/entity/GeoObject.d.ts +111 -0
  186. package/types/entity/GeoObjectHandler.d.ts +77 -0
  187. package/types/entity/Geometry.d.ts +9 -7
  188. package/types/entity/GeometryHandler.d.ts +2 -2
  189. package/types/entity/Label.d.ts +24 -29
  190. package/types/entity/LabelHandler.d.ts +9 -2
  191. package/types/entity/LabelWorker.d.ts +9 -0
  192. package/types/entity/PointCloud.d.ts +8 -8
  193. package/types/entity/PointCloudHandler.d.ts +3 -3
  194. package/types/entity/Polyline.d.ts +58 -55
  195. package/types/entity/Ray.d.ts +19 -18
  196. package/types/entity/Strip.d.ts +8 -7
  197. package/types/entity/StripHandler.d.ts +3 -3
  198. package/types/entity/index.d.ts +7 -7
  199. package/types/input/KeyboardHandler.d.ts +10 -0
  200. package/types/input/MouseHandler.d.ts +5 -0
  201. package/types/input/TouchHandler.d.ts +5 -0
  202. package/types/layer/BaseGeoImage.d.ts +23 -35
  203. package/types/layer/CanvasTiles.d.ts +15 -22
  204. package/types/layer/GeoImage.d.ts +5 -18
  205. package/types/layer/GeoVideo.d.ts +5 -30
  206. package/types/layer/KML.d.ts +20 -15
  207. package/types/layer/Layer.d.ts +326 -0
  208. package/types/layer/Material.d.ts +45 -0
  209. package/types/layer/Vector.d.ts +208 -0
  210. package/types/layer/WMS.d.ts +4 -7
  211. package/types/layer/XYZ.d.ts +19 -25
  212. package/types/light/LightSource.d.ts +54 -53
  213. package/types/math/Line2.d.ts +11 -0
  214. package/types/math/Line3.d.ts +10 -0
  215. package/types/math/Mat3.d.ts +30 -18
  216. package/types/math/Mat4.d.ts +71 -52
  217. package/types/math/Plane.d.ts +5 -4
  218. package/types/math/Quat.d.ts +379 -0
  219. package/types/math/Ray.d.ts +82 -0
  220. package/types/math/Vec2.d.ts +102 -101
  221. package/types/math/Vec3.d.ts +143 -142
  222. package/types/math/Vec4.d.ts +40 -39
  223. package/types/math/coder.d.ts +12 -11
  224. package/types/math.d.ts +8 -8
  225. package/types/mercator.d.ts +3 -3
  226. package/types/proj/EPSG3857.d.ts +3 -2
  227. package/types/proj/EPSG4326.d.ts +3 -2
  228. package/types/proj/Proj.d.ts +42 -0
  229. package/types/quadTree/EntityCollectionNode.d.ts +34 -0
  230. package/types/quadTree/Node.d.ts +61 -0
  231. package/types/renderer/Renderer.d.ts +300 -0
  232. package/types/renderer/RendererEvents.d.ts +10 -7
  233. package/types/scene/BaseNode.d.ts +9 -9
  234. package/types/scene/Planet.d.ts +131 -126
  235. package/types/scene/RenderNode.d.ts +22 -23
  236. package/types/segment/Segment.d.ts +279 -0
  237. package/types/segment/SegmentLonLat.d.ts +16 -0
  238. package/types/shaders/geoObject.d.ts +3 -0
  239. package/types/shapes/BaseShape.d.ts +43 -40
  240. package/types/shapes/Sphere.d.ts +7 -7
  241. package/types/terrain/BilTerrain.d.ts +0 -1
  242. package/types/terrain/EmptyTerrain.d.ts +4 -4
  243. package/types/terrain/GlobusTerrain.d.ts +17 -54
  244. package/types/terrain/MapboxTerrain.d.ts +0 -1
  245. package/types/utils/GeoImageCreator.d.ts +3 -2
  246. package/types/utils/TextureAtlas.d.ts +8 -8
  247. package/types/utils/shared.d.ts +25 -24
  248. package/types/webgl/Framebuffer.d.ts +5 -5
  249. package/types/webgl/Handler.d.ts +68 -43
  250. package/types/webgl/Multisample.d.ts +5 -5
  251. package/types/webgl/Program.d.ts +8 -2
  252. package/types/webgl/ProgramController.d.ts +18 -13
  253. package/src/og/inherits.js +0 -8
  254. package/src/og/utils/polylabel.js +0 -176
  255. package/types/inherits.d.ts +0 -4
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,12 +100,17 @@ 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;
109
115
  // var Decl = Math.atan2(zequat, Math.sqrt(xequat * xequat + yequat * yequat)) * math.DEGREES;
110
- };
116
+ }
@@ -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.
@@ -160,7 +160,7 @@ export const J2000 = 2451545.0;
160
160
  */
161
161
  export function T(jd) {
162
162
  return (jd - J2000) / DAYS_PER_JULIAN_CENTURY;
163
- };
163
+ }
164
164
 
165
165
  /**
166
166
  * Gets the date's julian day.
@@ -172,9 +172,14 @@ 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;
177
- };
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
+ );
182
+ }
178
183
 
179
184
  /**
180
185
  * Converts javascript date to the universal(UTC) julian date.
@@ -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
 
@@ -208,7 +214,7 @@ export function DateToUTC(date) {
208
214
  }
209
215
 
210
216
  return dayNumber + secondsOfDay * ONE_BY_SECONDS_PER_DAY;
211
- };
217
+ }
212
218
 
213
219
  /**
214
220
  * Converts javascript date to the atomic(TAI) julian date.
@@ -217,7 +223,7 @@ export function DateToUTC(date) {
217
223
  */
218
224
  export function DateToTAI(date) {
219
225
  return UTCtoTAI(DateToUTC(date));
220
- };
226
+ }
221
227
 
222
228
  /**
223
229
  * Converts coordinated universal(UTC) julian date to atomic(TAI) julian date.
@@ -248,7 +254,7 @@ export function UTCtoTAI(jd) {
248
254
  }
249
255
 
250
256
  return jd + offset * ONE_BY_SECONDS_PER_DAY;
251
- };
257
+ }
252
258
 
253
259
  /**
254
260
  * Converts atomic julian date(TAI) to the coordinated universal(UTC) julian date.
@@ -284,7 +290,7 @@ export function TAItoUTC(tai) {
284
290
  }
285
291
 
286
292
  return tai - leapSeconds[index - 1].leapSeconds * ONE_BY_SECONDS_PER_DAY;
287
- };
293
+ }
288
294
 
289
295
  /**
290
296
  * Converts UTC julian date to the javascript date object.
@@ -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) {
@@ -323,7 +329,7 @@ export function UTCtoDate(utc) {
323
329
  }
324
330
 
325
331
  return new Date(Date.UTC(year, month - 1, day, hour, minute, second, millisecond));
326
- };
332
+ }
327
333
 
328
334
  /**
329
335
  * Converts TAI julian date to the javascript date object.
@@ -331,15 +337,14 @@ 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);
342
- };
347
+ }
343
348
 
344
349
  /**
345
350
  * Adds milliseconds to the julian date.
@@ -349,7 +354,7 @@ export function TAItoDate(tai) {
349
354
  */
350
355
  export function addMilliseconds(jd, milliseconds) {
351
356
  return jd + milliseconds * ONE_BY_MILLISECONDS_PER_DAY;
352
- };
357
+ }
353
358
 
354
359
  /**
355
360
  * Adds seconds to the julian date.
@@ -359,7 +364,7 @@ export function addMilliseconds(jd, milliseconds) {
359
364
  */
360
365
  export function addSeconds(jd, seconds) {
361
366
  return jd + seconds * ONE_BY_SECONDS_PER_DAY;
362
- };
367
+ }
363
368
 
364
369
  /**
365
370
  * Adds hours to the julian date.
@@ -369,7 +374,7 @@ export function addSeconds(jd, seconds) {
369
374
  */
370
375
  export function addHours(jd, hours) {
371
376
  return jd + hours * ONE_BY_HOURS_PER_DAY;
372
- };
377
+ }
373
378
 
374
379
  /**
375
380
  * Adds minutes to the julian date.
@@ -379,7 +384,7 @@ export function addHours(jd, hours) {
379
384
  */
380
385
  export function addMinutes(jd, minutes) {
381
386
  return jd + minutes * MINUTES_PER_DAY;
382
- };
387
+ }
383
388
 
384
389
  /**
385
390
  * Adds days to the julian date.
@@ -389,7 +394,7 @@ export function addMinutes(jd, minutes) {
389
394
  */
390
395
  export function addDays(jd, days) {
391
396
  return jd + days;
392
- };
397
+ }
393
398
 
394
399
  /**
395
400
  * Gets milliseconds of a julian date.
@@ -399,8 +404,8 @@ 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;
403
- };
407
+ return ((s - (s | 0)) * MILLISECONDS_PER_SECOND) | 0;
408
+ }
404
409
 
405
410
  /**
406
411
  * Gets seconds of a julian date.
@@ -410,7 +415,7 @@ export function getMilliseconds(jd) {
410
415
  export function getSeconds(jd) {
411
416
  var s = jd - (jd | 0);
412
417
  return s * SECONDS_PER_DAY;
413
- };
418
+ }
414
419
 
415
420
  /**
416
421
  * Gets hours of a julian date.
@@ -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) {
@@ -434,7 +439,7 @@ export function getHours(jd) {
434
439
  }
435
440
 
436
441
  return hour;
437
- };
442
+ }
438
443
 
439
444
  /**
440
445
  * Gets minutes of a julian date.
@@ -443,8 +448,8 @@ 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;
447
- };
451
+ return (s * MINUTES_PER_DAY) | 0;
452
+ }
448
453
 
449
454
  /**
450
455
  * Gets days of a julian date.
@@ -453,7 +458,7 @@ export function getMinutes(jd) {
453
458
  */
454
459
  export function getDays(jd) {
455
460
  return jd | 0;
456
- };
461
+ }
457
462
 
458
463
  /**
459
464
  * Returns days in seconds.
@@ -462,7 +467,7 @@ export function getDays(jd) {
462
467
  */
463
468
  export function secondsToDays(s) {
464
469
  return s * ONE_BY_SECONDS_PER_DAY;
465
- };
470
+ }
466
471
 
467
472
  /**
468
473
  * Returns seconds in days.
@@ -471,14 +476,14 @@ export function secondsToDays(s) {
471
476
  */
472
477
  export function daysToSeconds(d) {
473
478
  return d * SECONDS_PER_DAY;
474
- };
479
+ }
475
480
 
476
481
  function __ls(jd, leapSeconds) {
477
482
  return {
478
483
  jd: jd,
479
484
  leapSeconds: leapSeconds
480
485
  };
481
- };
486
+ }
482
487
 
483
488
  const leapSecondsTable = [
484
489
  __ls(2441317.5, 10.0), // 1972-01-01T00:00:00.000Z
@@ -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,24 +22,24 @@ 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
+ }
36
36
 
37
37
  // Standard iteration for solving Kepler's Equation
38
38
  function solveKeplerFunc1(ecc, M) {
39
39
  return function (x) {
40
40
  return M + ecc * Math.sin(x);
41
41
  };
42
- };
42
+ }
43
43
 
44
44
  // Faster converging iteration for Kepler's Equation; more efficient
45
45
  // than above for orbits with eccentricities greater than 0.3. This
@@ -48,7 +48,7 @@ function solveKeplerFunc2(ecc, M) {
48
48
  return function (x) {
49
49
  return x + (M + ecc * Math.sin(x) - x) / (1 - ecc * Math.cos(x));
50
50
  };
51
- };
51
+ }
52
52
 
53
53
  function solveKeplerLaguerreConway(ecc, M) {
54
54
  return function (x) {
@@ -57,10 +57,10 @@ 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
+ }
64
64
 
65
65
  function solveKeplerLaguerreConwayHyp(ecc, M) {
66
66
  return function (x) {
@@ -69,15 +69,15 @@ 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
+ }
76
76
 
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;
@@ -86,19 +86,21 @@ export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) {
86
86
  iterations--;
87
87
  }
88
88
  return e;
89
- };
89
+ }
90
90
 
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;
99
101
  }
100
102
  return trueAnomaly + revs * math.TWO_PI;
101
- };
103
+ }
102
104
 
103
105
  export function getPerifocalToCartesianMatrix(argumentOfPeriapsis, inclination, rightAscension) {
104
106
  var res = new Mat3();
@@ -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
+ }