@openglobus/og 0.16.3 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) 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 +0 -4
  11. package/src/og/Extent.js +5 -9
  12. package/src/og/Globe.js +92 -55
  13. package/src/og/ImageCanvas.js +12 -5
  14. package/src/og/Lock.js +44 -48
  15. package/src/og/LonLat.js +0 -4
  16. package/src/og/Object3d.js +1 -1
  17. package/src/og/Stack.js +49 -53
  18. package/src/og/astro/earth.js +112 -116
  19. package/src/og/astro/jd.js +514 -518
  20. package/src/og/astro/orbit.js +119 -123
  21. package/src/og/astro/rotation.js +36 -40
  22. package/src/og/bv/Box.js +77 -81
  23. package/src/og/bv/Sphere.js +57 -61
  24. package/src/og/camera/Camera.js +20 -7
  25. package/src/og/camera/PlanetCamera.js +8 -15
  26. package/src/og/control/Atmosphere.js +0 -4
  27. package/src/og/control/Control.js +9 -8
  28. package/src/og/control/DebugInfo.js +0 -4
  29. package/src/og/control/DrawingSwitcher.js +117 -0
  30. package/src/og/control/EarthCoordinates.js +214 -214
  31. package/src/og/control/GeoImageDragControl.js +0 -4
  32. package/src/og/control/KeyboardNavigation.js +0 -4
  33. package/src/og/control/LayerAnimation.js +0 -4
  34. package/src/og/control/LayerSwitcher.js +2 -4
  35. package/src/og/control/Lighting.js +11 -15
  36. package/src/og/control/MouseNavigation.js +0 -4
  37. package/src/og/control/MouseWheelZoomControl.js +0 -4
  38. package/src/og/control/RulerSwitcher.js +0 -4
  39. package/src/og/control/ScaleControl.js +2 -6
  40. package/src/og/control/ShowFps.js +40 -44
  41. package/src/og/control/SimpleNavigation.js +10 -10
  42. package/src/og/control/SimpleSkyBackground.js +0 -4
  43. package/src/og/control/Sun.js +0 -4
  44. package/src/og/control/ToggleWireframe.js +35 -39
  45. package/src/og/control/ZoomControl.js +0 -4
  46. package/src/og/control/drawing/DrawingControl.js +51 -0
  47. package/src/og/control/drawing/LineStringDrawingScene.js +203 -0
  48. package/src/og/control/drawing/PolygonDrawingScene.js +785 -0
  49. package/src/og/control/elevationProfile/ElevationProfile.js +275 -0
  50. package/src/og/control/index.js +5 -1
  51. package/src/og/control/ruler/Ruler.js +0 -4
  52. package/src/og/control/ruler/RulerScene.js +3 -2
  53. package/src/og/control/selection/Selection.js +0 -4
  54. package/src/og/control/selection/SelectionScene.js +2 -4
  55. package/src/og/control/timeline/TimelineControl.js +4 -4
  56. package/src/og/control/timeline/TimelineModel.js +2 -2
  57. package/src/og/control/timeline/TimelineView.js +1 -0
  58. package/src/og/control/visibleExtent/Segment.js +5 -5
  59. package/src/og/control/visibleExtent/drawnode.js +0 -4
  60. package/src/og/ellipsoid/Ellipsoid.js +205 -275
  61. package/src/og/ellipsoid/wgs84.js +0 -4
  62. package/src/og/entity/BaseBillboard.js +375 -379
  63. package/src/og/entity/Billboard.js +0 -4
  64. package/src/og/entity/BillboardHandler.js +0 -4
  65. package/src/og/entity/Entity.js +22 -22
  66. package/src/og/entity/EntityCollection.js +7 -11
  67. package/src/og/entity/GeoObject.js +0 -4
  68. package/src/og/entity/GeoObjectHandler.js +0 -4
  69. package/src/og/entity/Geometry.js +5 -4
  70. package/src/og/entity/GeometryHandler.js +3 -4
  71. package/src/og/entity/Label.js +0 -4
  72. package/src/og/entity/LabelHandler.js +0 -4
  73. package/src/og/entity/PointCloud.js +0 -4
  74. package/src/og/entity/PointCloudHandler.js +122 -126
  75. package/src/og/entity/Polyline.js +4 -6
  76. package/src/og/entity/PolylineHandler.js +104 -108
  77. package/src/og/entity/Ray.js +29 -29
  78. package/src/og/entity/Strip.js +1 -1
  79. package/src/og/index.js +3 -1
  80. package/src/og/input/KeyboardHandler.js +128 -132
  81. package/src/og/input/MouseHandler.js +94 -98
  82. package/src/og/input/TouchHandler.js +59 -63
  83. package/src/og/input/input.js +44 -48
  84. package/src/og/layer/BaseGeoImage.js +5 -8
  85. package/src/og/layer/CanvasTiles.js +0 -4
  86. package/src/og/layer/GeoImage.js +0 -4
  87. package/src/og/layer/GeoTexture2d.js +0 -4
  88. package/src/og/layer/GeoVideo.js +0 -4
  89. package/src/og/layer/KML.js +1 -0
  90. package/src/og/layer/Layer.js +22 -26
  91. package/src/og/layer/Material.js +0 -4
  92. package/src/og/layer/Vector.js +23 -20
  93. package/src/og/layer/WMS.js +182 -186
  94. package/src/og/layer/XYZ.js +0 -4
  95. package/src/og/light/LightSource.js +0 -4
  96. package/src/og/math/Line2.js +28 -32
  97. package/src/og/math/Mat3.js +152 -156
  98. package/src/og/math/Ray.js +0 -4
  99. package/src/og/math/Vec2.js +0 -4
  100. package/src/og/math/Vec3.js +0 -4
  101. package/src/og/math/Vec4.js +0 -4
  102. package/src/og/math/coder.js +104 -104
  103. package/src/og/math.js +39 -7
  104. package/src/og/proj/EPSG3857.js +13 -13
  105. package/src/og/proj/Proj.js +59 -63
  106. package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +1 -0
  107. package/src/og/quadTree/EarthQuadTreeStrategy.js +1 -0
  108. package/src/og/quadTree/EntityCollectionNode.js +12 -16
  109. package/src/og/quadTree/MarsQuadTreeStrategy.js +1 -0
  110. package/src/og/quadTree/QuadTreeStrategy.js +1 -0
  111. package/src/og/quadTree/Wgs84QuadTreeStrategy.js +1 -0
  112. package/src/og/renderer/Renderer.js +109 -22
  113. package/src/og/renderer/RendererEvents.js +0 -4
  114. package/src/og/scene/Axes.js +74 -78
  115. package/src/og/scene/BaseNode.js +0 -4
  116. package/src/og/scene/Planet.js +114 -112
  117. package/src/og/scene/RenderNode.js +11 -3
  118. package/src/og/scene/SkyBox.js +104 -108
  119. package/src/og/segment/Segment.js +8 -4
  120. package/src/og/segment/SegmentLonLat.js +2 -6
  121. package/src/og/segment/segmentHelper.js +229 -225
  122. package/src/og/shaders/billboard.js +0 -4
  123. package/src/og/shaders/drawnode.js +5 -9
  124. package/src/og/shaders/geoObject.js +0 -4
  125. package/src/og/shaders/label.js +0 -4
  126. package/src/og/shaders/pickingMask.js +0 -4
  127. package/src/og/shaders/pointCloud.js +0 -4
  128. package/src/og/shaders/polyline.js +0 -4
  129. package/src/og/shaders/ray.js +0 -4
  130. package/src/og/shaders/skybox.js +0 -4
  131. package/src/og/terrain/EmptyTerrain.js +0 -4
  132. package/src/og/utils/FontAtlas.js +0 -4
  133. package/src/og/utils/GeoImageCreator.js +1 -2
  134. package/src/og/utils/NormalMapCreator.js +8 -9
  135. package/src/og/utils/VectorTileCreator.js +3 -9
  136. package/src/og/utils/shared.js +20 -1
  137. package/src/og/webgl/Framebuffer.js +0 -4
  138. package/src/og/webgl/Handler.js +45 -19
  139. package/src/og/webgl/Multisample.js +0 -4
  140. package/src/og/webgl/Program.js +0 -4
  141. package/src/og/webgl/ProgramController.js +2 -2
  142. package/types/Clock.d.ts +1 -1
  143. package/types/Extent.d.ts +5 -5
  144. package/types/Globe.d.ts +15 -1
  145. package/types/ImageCanvas.d.ts +5 -0
  146. package/types/bv/Box.d.ts +1 -1
  147. package/types/bv/Sphere.d.ts +3 -3
  148. package/types/camera/Camera.d.ts +3 -2
  149. package/types/camera/PlanetCamera.d.ts +4 -4
  150. package/types/control/DrawingSwitcher.d.ts +13 -0
  151. package/types/control/EarthCoordinates.d.ts +1 -1
  152. package/types/control/Lighting.d.ts +8 -8
  153. package/types/control/drawing/DrawingControl.d.ts +14 -0
  154. package/types/control/drawing/LineStringDrawingScene.d.ts +5 -0
  155. package/types/control/drawing/PolygonDrawingScene.d.ts +99 -0
  156. package/types/control/index.d.ts +3 -1
  157. package/types/control/ruler/RulerScene.d.ts +0 -1
  158. package/types/control/selection/SelectionScene.d.ts +0 -1
  159. package/types/ellipsoid/Ellipsoid.d.ts +50 -63
  160. package/types/entity/Entity.d.ts +3 -2
  161. package/types/entity/Geometry.d.ts +5 -0
  162. package/types/entity/Polyline.d.ts +1 -1
  163. package/types/entity/Ray.d.ts +1 -0
  164. package/types/index.d.ts +1 -0
  165. package/types/layer/BaseGeoImage.d.ts +1 -1
  166. package/types/layer/CanvasTiles.d.ts +1 -1
  167. package/types/layer/Layer.d.ts +1 -1
  168. package/types/layer/Vector.d.ts +1 -0
  169. package/types/math.d.ts +7 -0
  170. package/types/renderer/Renderer.d.ts +7 -1
  171. package/types/scene/Axes.d.ts +0 -1
  172. package/types/scene/Planet.d.ts +26 -24
  173. package/types/scene/RenderNode.d.ts +2 -0
  174. package/types/scene/SkyBox.d.ts +0 -1
  175. package/types/segment/Segment.d.ts +3 -2
  176. package/types/segment/SegmentLonLat.d.ts +0 -1
  177. package/types/utils/GeoImageCreator.d.ts +1 -1
  178. package/types/utils/NormalMapCreator.d.ts +1 -1
  179. package/types/utils/VectorTileCreator.d.ts +2 -2
  180. package/types/utils/shared.d.ts +2 -0
  181. package/types/webgl/Handler.d.ts +6 -4
@@ -1,123 +1,119 @@
1
- /**
2
- * @module og/astro/orbit
3
- */
4
-
5
- "use strict";
6
-
7
- import * as math from "../math.js";
8
- import { Mat3 } from "../math/Mat3.js";
9
-
10
- export function getEccentricAnomaly(M, ecc) {
11
- if (ecc == 0.0) {
12
- // Circular orbit
13
- return M;
14
- } else if (ecc < 0.2) {
15
- // Low eccentricity, so use the standard iteration technique
16
- return math.solve_iteration_fixed(solveKeplerFunc1(ecc, M), M, 5);
17
- } else if (ecc < 0.9) {
18
- // Higher eccentricity elliptical orbit; use a more complex but
19
- // much faster converging iteration.
20
- return math.solve_iteration_fixed(solveKeplerFunc2(ecc, M), M, 6);
21
- } else if (ecc < 1.0) {
22
- // Extremely stable Laguerre-Conway method for solving Kepler's
23
- // equation. Only use this for high-eccentricity orbits, as it
24
- // requires more calcuation.
25
- let E = M + 0.85 * ecc * Math.sign(Math.sin(M));
26
- return math.solve_iteration_fixed(solveKeplerLaguerreConway(ecc, M), E, 8);
27
- } else if (ecc == 1.0) {
28
- // TODO: Parabolic orbit
29
- return M;
30
- } else {
31
- // Laguerre-Conway method for hyperbolic (ecc > 1) orbits.
32
- let E = Math.log((2 * M) / ecc + 1.85);
33
- return math.solve_iteration_fixed(solveKeplerLaguerreConwayHyp(ecc, M), E, 30);
34
- }
35
- }
36
-
37
- // Standard iteration for solving Kepler's Equation
38
- function solveKeplerFunc1(ecc, M) {
39
- return function (x) {
40
- return M + ecc * Math.sin(x);
41
- };
42
- }
43
-
44
- // Faster converging iteration for Kepler's Equation; more efficient
45
- // than above for orbits with eccentricities greater than 0.3. This
46
- // is from Jean Meeus's _Astronomical Algorithms_ (2nd ed), p. 199
47
- function solveKeplerFunc2(ecc, M) {
48
- return function (x) {
49
- return x + (M + ecc * Math.sin(x) - x) / (1 - ecc * Math.cos(x));
50
- };
51
- }
52
-
53
- function solveKeplerLaguerreConway(ecc, M) {
54
- return function (x) {
55
- var s = ecc * Math.sin(x);
56
- var c = ecc * Math.cos(x);
57
- var f = x - s - M;
58
- var f1 = 1 - c;
59
- var f2 = s;
60
- x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
61
- return x;
62
- };
63
- }
64
-
65
- function solveKeplerLaguerreConwayHyp(ecc, M) {
66
- return function (x) {
67
- var s = ecc * Math.sinh(x);
68
- var c = ecc * Math.cosh(x);
69
- var f = s - x - M;
70
- var f1 = c - 1;
71
- var f2 = s;
72
- x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
73
- return x;
74
- };
75
- }
76
-
77
- export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) {
78
- var tol = 0.00000001745;
79
- var iterations = 20;
80
- var e = meanAnomaly - 2.0 * Math.PI * ((meanAnomaly / (2.0 * Math.PI)) | 0);
81
- var err = 1;
82
- while (Math.abs(err) > tol && iterations > 0) {
83
- err = e - eccentricity * Math.sin(e) - meanAnomaly;
84
- var delta = err / (1 - eccentricity * Math.cos(e));
85
- e -= delta;
86
- iterations--;
87
- }
88
- return e;
89
- }
90
-
91
- export function getTrueAnomaly(eccentricAnomaly, eccentricity) {
92
- var revs = Math.floor(eccentricAnomaly / math.TWO_PI);
93
- eccentricAnomaly -= revs * math.TWO_PI;
94
- var trueAnomaly = Math.atan2(
95
- Math.sin(eccentricAnomaly) * Math.sqrt(1 - eccentricity * eccentricity),
96
- Math.cos(eccentricAnomaly) - eccentricity
97
- );
98
- trueAnomaly = math.zeroTwoPI(trueAnomaly);
99
- if (eccentricAnomaly < 0) {
100
- trueAnomaly -= math.TWO_PI;
101
- }
102
- return trueAnomaly + revs * math.TWO_PI;
103
- }
104
-
105
- export function getPerifocalToCartesianMatrix(argumentOfPeriapsis, inclination, rightAscension) {
106
- var res = new Mat3();
107
- var cosap = Math.cos(argumentOfPeriapsis),
108
- sinap = Math.sin(argumentOfPeriapsis),
109
- cosi = Math.cos(inclination),
110
- sini = Math.sin(inclination),
111
- cosraan = Math.cos(rightAscension),
112
- sinraan = Math.sin(rightAscension);
113
- res._m[0] = cosraan * cosap - sinraan * sinap * cosi;
114
- res._m[1] = sinraan * cosap + cosraan * sinap * cosi;
115
- res._m[2] = sinap * sini;
116
- res._m[3] = -cosraan * sinap - sinraan * cosap * cosi;
117
- res._m[4] = -sinraan * sinap + cosraan * cosap * cosi;
118
- res._m[5] = cosap * sini;
119
- res._m[6] = sinraan * sini;
120
- res._m[7] = -cosraan * sini;
121
- res._m[8] = cosi;
122
- return res;
123
- }
1
+ "use strict";
2
+
3
+ import * as math from "../math.js";
4
+ import { Mat3 } from "../math/Mat3.js";
5
+
6
+ export function getEccentricAnomaly(M, ecc) {
7
+ if (ecc == 0.0) {
8
+ // Circular orbit
9
+ return M;
10
+ } else if (ecc < 0.2) {
11
+ // Low eccentricity, so use the standard iteration technique
12
+ return math.solve_iteration_fixed(solveKeplerFunc1(ecc, M), M, 5);
13
+ } else if (ecc < 0.9) {
14
+ // Higher eccentricity elliptical orbit; use a more complex but
15
+ // much faster converging iteration.
16
+ return math.solve_iteration_fixed(solveKeplerFunc2(ecc, M), M, 6);
17
+ } else if (ecc < 1.0) {
18
+ // Extremely stable Laguerre-Conway method for solving Kepler's
19
+ // equation. Only use this for high-eccentricity orbits, as it
20
+ // requires more calcuation.
21
+ let E = M + 0.85 * ecc * Math.sign(Math.sin(M));
22
+ return math.solve_iteration_fixed(solveKeplerLaguerreConway(ecc, M), E, 8);
23
+ } else if (ecc == 1.0) {
24
+ // TODO: Parabolic orbit
25
+ return M;
26
+ } else {
27
+ // Laguerre-Conway method for hyperbolic (ecc > 1) orbits.
28
+ let E = Math.log((2 * M) / ecc + 1.85);
29
+ return math.solve_iteration_fixed(solveKeplerLaguerreConwayHyp(ecc, M), E, 30);
30
+ }
31
+ }
32
+
33
+ // Standard iteration for solving Kepler's Equation
34
+ function solveKeplerFunc1(ecc, M) {
35
+ return function (x) {
36
+ return M + ecc * Math.sin(x);
37
+ };
38
+ }
39
+
40
+ // Faster converging iteration for Kepler's Equation; more efficient
41
+ // than above for orbits with eccentricities greater than 0.3. This
42
+ // is from Jean Meeus's _Astronomical Algorithms_ (2nd ed), p. 199
43
+ function solveKeplerFunc2(ecc, M) {
44
+ return function (x) {
45
+ return x + (M + ecc * Math.sin(x) - x) / (1 - ecc * Math.cos(x));
46
+ };
47
+ }
48
+
49
+ function solveKeplerLaguerreConway(ecc, M) {
50
+ return function (x) {
51
+ var s = ecc * Math.sin(x);
52
+ var c = ecc * Math.cos(x);
53
+ var f = x - s - M;
54
+ var f1 = 1 - c;
55
+ var f2 = s;
56
+ x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
57
+ return x;
58
+ };
59
+ }
60
+
61
+ function solveKeplerLaguerreConwayHyp(ecc, M) {
62
+ return function (x) {
63
+ var s = ecc * Math.sinh(x);
64
+ var c = ecc * Math.cosh(x);
65
+ var f = s - x - M;
66
+ var f1 = c - 1;
67
+ var f2 = s;
68
+ x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
69
+ return x;
70
+ };
71
+ }
72
+
73
+ export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) {
74
+ var tol = 0.00000001745;
75
+ var iterations = 20;
76
+ var e = meanAnomaly - 2.0 * Math.PI * ((meanAnomaly / (2.0 * Math.PI)) | 0);
77
+ var err = 1;
78
+ while (Math.abs(err) > tol && iterations > 0) {
79
+ err = e - eccentricity * Math.sin(e) - meanAnomaly;
80
+ var delta = err / (1 - eccentricity * Math.cos(e));
81
+ e -= delta;
82
+ iterations--;
83
+ }
84
+ return e;
85
+ }
86
+
87
+ export function getTrueAnomaly(eccentricAnomaly, eccentricity) {
88
+ var revs = Math.floor(eccentricAnomaly / math.TWO_PI);
89
+ eccentricAnomaly -= revs * math.TWO_PI;
90
+ var trueAnomaly = Math.atan2(
91
+ Math.sin(eccentricAnomaly) * Math.sqrt(1 - eccentricity * eccentricity),
92
+ Math.cos(eccentricAnomaly) - eccentricity
93
+ );
94
+ trueAnomaly = math.zeroTwoPI(trueAnomaly);
95
+ if (eccentricAnomaly < 0) {
96
+ trueAnomaly -= math.TWO_PI;
97
+ }
98
+ return trueAnomaly + revs * math.TWO_PI;
99
+ }
100
+
101
+ export function getPerifocalToCartesianMatrix(argumentOfPeriapsis, inclination, rightAscension) {
102
+ var res = new Mat3();
103
+ var cosap = Math.cos(argumentOfPeriapsis),
104
+ sinap = Math.sin(argumentOfPeriapsis),
105
+ cosi = Math.cos(inclination),
106
+ sini = Math.sin(inclination),
107
+ cosraan = Math.cos(rightAscension),
108
+ sinraan = Math.sin(rightAscension);
109
+ res._m[0] = cosraan * cosap - sinraan * sinap * cosi;
110
+ res._m[1] = sinraan * cosap + cosraan * sinap * cosi;
111
+ res._m[2] = sinap * sini;
112
+ res._m[3] = -cosraan * sinap - sinraan * cosap * cosi;
113
+ res._m[4] = -sinraan * sinap + cosraan * cosap * cosi;
114
+ res._m[5] = cosap * sini;
115
+ res._m[6] = sinraan * sini;
116
+ res._m[7] = -cosraan * sini;
117
+ res._m[8] = cosi;
118
+ return res;
119
+ }
@@ -1,40 +1,36 @@
1
- /**
2
- * @module og/astro/rotation
3
- */
4
-
5
- "use strict";
6
-
7
- import { PI_TWO } from "../math.js";
8
- import { Mat3 } from "../math/Mat3.js";
9
- import { Vec3 } from "../math/Vec3.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);
19
- xAxis.z = 0.0;
20
-
21
- let cosDec = Math.cos(declination);
22
-
23
- zAxis.x = cosDec * Math.cos(rightAscension);
24
- zAxis.y = cosDec * Math.sin(rightAscension);
25
- zAxis.z = Math.sin(declination);
26
-
27
- let yAxis = zAxis.cross(xAxis);
28
-
29
- res._m[0] = xAxis.x;
30
- res._m[1] = yAxis.x;
31
- res._m[2] = zAxis.x;
32
- res._m[3] = xAxis.y;
33
- res._m[4] = yAxis.y;
34
- res._m[5] = zAxis.y;
35
- res._m[6] = xAxis.z;
36
- res._m[7] = yAxis.z;
37
- res._m[8] = zAxis.z;
38
-
39
- return res;
40
- }
1
+ "use strict";
2
+
3
+ import { PI_TWO } from "../math.js";
4
+ import { Mat3 } from "../math/Mat3.js";
5
+ import { Vec3 } from "../math/Vec3.js";
6
+
7
+ export function getRotationMatrix(rightAscension, declination, res) {
8
+ let xAxis = new Vec3(),
9
+ zAxis = new Vec3();
10
+
11
+ res = res || new Mat3();
12
+
13
+ xAxis.x = Math.cos(rightAscension + PI_TWO);
14
+ xAxis.y = Math.sin(rightAscension + PI_TWO);
15
+ xAxis.z = 0.0;
16
+
17
+ let cosDec = Math.cos(declination);
18
+
19
+ zAxis.x = cosDec * Math.cos(rightAscension);
20
+ zAxis.y = cosDec * Math.sin(rightAscension);
21
+ zAxis.z = Math.sin(declination);
22
+
23
+ let yAxis = zAxis.cross(xAxis);
24
+
25
+ res._m[0] = xAxis.x;
26
+ res._m[1] = yAxis.x;
27
+ res._m[2] = zAxis.x;
28
+ res._m[3] = xAxis.y;
29
+ res._m[4] = yAxis.y;
30
+ res._m[5] = zAxis.y;
31
+ res._m[6] = xAxis.z;
32
+ res._m[7] = yAxis.z;
33
+ res._m[8] = zAxis.z;
34
+
35
+ return res;
36
+ }
package/src/og/bv/Box.js CHANGED
@@ -1,81 +1,77 @@
1
- /**
2
- * @module og/bv/Box
3
- */
4
-
5
- "use strict";
6
-
7
- import { Vec3 } from "../math/Vec3.js";
8
-
9
- /**
10
- * Bounding box class.
11
- * @class
12
- */
13
- class Box {
14
- /**
15
- *
16
- * @param {*} boundsArr
17
- */
18
- constructor(boundsArr = [0, 0, 0, 0, 0, 0]) {
19
- /**
20
- * Vertices array.
21
- * @public
22
- * @type{Array.<Vec3>}
23
- */
24
- this.vertices = [
25
- new Vec3(),
26
- new Vec3(),
27
- new Vec3(),
28
- new Vec3(),
29
- new Vec3(),
30
- new Vec3(),
31
- new Vec3(),
32
- new Vec3()
33
- ];
34
-
35
- if (boundsArr) {
36
- this.setFromBoundsArr(boundsArr);
37
- }
38
- }
39
-
40
- copy(bbox) {
41
- for (let i = 0, len = this.vertices.length; i < len; i++) {
42
- this.vertices[i].copy(bbox.vertices[i]);
43
- }
44
- }
45
-
46
- /**
47
- * Sets bounding box coordinates by the bounds array.
48
- * @param {Array.<number>} bounds - Bounds is an array where [minX, minY, minZ, maxX, maxY, maxZ]
49
- */
50
- setFromBoundsArr(bounds) {
51
- var xmin = bounds[0],
52
- xmax = bounds[3],
53
- ymin = bounds[1],
54
- ymax = bounds[4],
55
- zmin = bounds[2],
56
- zmax = bounds[5];
57
-
58
- var v = this.vertices;
59
-
60
- v[0].set(xmin, ymin, zmin);
61
- v[1].set(xmax, ymin, zmin);
62
- v[2].set(xmax, ymin, zmax);
63
- v[3].set(xmin, ymin, zmax);
64
- v[4].set(xmin, ymax, zmin);
65
- v[5].set(xmax, ymax, zmin);
66
- v[6].set(xmax, ymax, zmax);
67
- v[7].set(xmin, ymax, zmax);
68
- }
69
-
70
- /**
71
- * Sets bounding box coordiantes by ellipsoid geodetic extend.
72
- * @param {Ellipsoid} ellipsoid - Ellipsoid.
73
- * @param {Extent} extent - Geodetic extent.
74
- */
75
- setFromExtent(ellipsoid, extent) {
76
- this.setFromBoundsArr(extent.getCartesianBounds(ellipsoid));
77
- }
78
- }
79
-
80
- export { Box };
81
-
1
+ "use strict";
2
+
3
+ import { Vec3 } from "../math/Vec3.js";
4
+
5
+ /**
6
+ * Bounding box class.
7
+ * @class
8
+ */
9
+ class Box {
10
+ /**
11
+ *
12
+ * @param {*} boundsArr
13
+ */
14
+ constructor(boundsArr = [0, 0, 0, 0, 0, 0]) {
15
+ /**
16
+ * Vertices array.
17
+ * @public
18
+ * @type{Array.<Vec3>}
19
+ */
20
+ this.vertices = [
21
+ new Vec3(),
22
+ new Vec3(),
23
+ new Vec3(),
24
+ new Vec3(),
25
+ new Vec3(),
26
+ new Vec3(),
27
+ new Vec3(),
28
+ new Vec3()
29
+ ];
30
+
31
+ if (boundsArr) {
32
+ this.setFromBoundsArr(boundsArr);
33
+ }
34
+ }
35
+
36
+ copy(bbox) {
37
+ for (let i = 0, len = this.vertices.length; i < len; i++) {
38
+ this.vertices[i].copy(bbox.vertices[i]);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Sets bounding box coordinates by the bounds array.
44
+ * @param {Array.<number>} bounds - Bounds is an array where [minX, minY, minZ, maxX, maxY, maxZ]
45
+ */
46
+ setFromBoundsArr(bounds) {
47
+ var xmin = bounds[0],
48
+ xmax = bounds[3],
49
+ ymin = bounds[1],
50
+ ymax = bounds[4],
51
+ zmin = bounds[2],
52
+ zmax = bounds[5];
53
+
54
+ var v = this.vertices;
55
+
56
+ v[0].set(xmin, ymin, zmin);
57
+ v[1].set(xmax, ymin, zmin);
58
+ v[2].set(xmax, ymin, zmax);
59
+ v[3].set(xmin, ymin, zmax);
60
+ v[4].set(xmin, ymax, zmin);
61
+ v[5].set(xmax, ymax, zmin);
62
+ v[6].set(xmax, ymax, zmax);
63
+ v[7].set(xmin, ymax, zmax);
64
+ }
65
+
66
+ /**
67
+ * Sets bounding box coordinates by ellipsoid geodetic extend.
68
+ * @param {Ellipsoid} ellipsoid - Ellipsoid.
69
+ * @param {Extent} extent - Geodetic extent.
70
+ */
71
+ setFromExtent(ellipsoid, extent) {
72
+ this.setFromBoundsArr(extent.getCartesianBounds(ellipsoid));
73
+ }
74
+ }
75
+
76
+ export { Box };
77
+
@@ -1,61 +1,57 @@
1
- /**
2
- * @module og/bv/Sphere
3
- */
4
-
5
- "use strict";
6
-
7
- import { Vec3 } from "../math/Vec3.js";
8
-
9
- /**
10
- * Bounding sphere class.
11
- * @class
12
- * @param {Number} [radius] - Bounding sphere radius.
13
- * @param {Vec3} [center] - Bounding sphere coordiantes.
14
- */
15
- class Sphere {
16
- /**
17
- *
18
- * @param {number} radius
19
- * @param {Vec3} center
20
- */
21
- constructor(radius = 0, center = Vec3.ZERO) {
22
- /**
23
- * Sphere radius.
24
- * @public
25
- * @type {Number}
26
- */
27
- this.radius = radius;
28
-
29
- /**
30
- * Sphere coordiantes.
31
- * @public
32
- * @type {Vec3}
33
- */
34
- this.center = center ? center.clone() : new Vec3();
35
- }
36
-
37
- /**
38
- * Sets bounding sphere coordinates by the bounds array.
39
- * @param {Array.<number>} bounds - Bounds is an array where [minX, minY, minZ, maxX, maxY, maxZ]
40
- */
41
- setFromBounds(bounds) {
42
- let m = new Vec3(bounds[0], bounds[1], bounds[2]);
43
- this.center.set(
44
- m.x + (bounds[3] - m.x) * 0.5,
45
- m.y + (bounds[3] - m.y) * 0.5,
46
- m.z + (bounds[5] - m.z) * 0.5
47
- );
48
- this.radius = this.center.distance(m);
49
- }
50
-
51
- /**
52
- * Sets bounding sphere coordiantes by ellipsoid geodetic extend.
53
- * @param {Ellipsoid} ellipsoid - Ellipsoid.
54
- * @param {Extent} extent - Geodetic extent.
55
- */
56
- setFromExtent(ellipsoid, extent) {
57
- this.setFromBounds(extent.getCartesianBounds(ellipsoid));
58
- }
59
- }
60
-
61
- export { Sphere };
1
+ "use strict";
2
+
3
+ import { Vec3 } from "../math/Vec3.js";
4
+
5
+ /**
6
+ * Bounding sphere class.
7
+ * @class
8
+ * @param {Number} [radius] - Bounding sphere radius.
9
+ * @param {Vec3} [center] - Bounding sphere coordinates.
10
+ */
11
+ class Sphere {
12
+ /**
13
+ *
14
+ * @param {number} radius
15
+ * @param {Vec3} center
16
+ */
17
+ constructor(radius = 0, center = Vec3.ZERO) {
18
+ /**
19
+ * Sphere radius.
20
+ * @public
21
+ * @type {Number}
22
+ */
23
+ this.radius = radius;
24
+
25
+ /**
26
+ * Sphere coordinates.
27
+ * @public
28
+ * @type {Vec3}
29
+ */
30
+ this.center = center ? center.clone() : new Vec3();
31
+ }
32
+
33
+ /**
34
+ * Sets bounding sphere coordinates by the bounds array.
35
+ * @param {Array.<number>} bounds - Bounds is an array where [minX, minY, minZ, maxX, maxY, maxZ]
36
+ */
37
+ setFromBounds(bounds) {
38
+ let m = new Vec3(bounds[0], bounds[1], bounds[2]);
39
+ this.center.set(
40
+ m.x + (bounds[3] - m.x) * 0.5,
41
+ m.y + (bounds[3] - m.y) * 0.5,
42
+ m.z + (bounds[5] - m.z) * 0.5
43
+ );
44
+ this.radius = this.center.distance(m);
45
+ }
46
+
47
+ /**
48
+ * Sets bounding sphere coordinates by ellipsoid geodetic extend.
49
+ * @param {Ellipsoid} ellipsoid - Ellipsoid.
50
+ * @param {Extent} extent - Geodetic extent.
51
+ */
52
+ setFromExtent(ellipsoid, extent) {
53
+ this.setFromBounds(extent.getCartesianBounds(ellipsoid));
54
+ }
55
+ }
56
+
57
+ export { Sphere };